comparison src/sql.sml @ 2239:f70a91f7810d

Add limited support for parsing SQL arithmetic.
author Ziv Scully <ziv@mit.edu>
date Tue, 07 Jul 2015 00:07:24 -0700
parents 7f92d70a326e
children 27899da8780b
comparison
equal deleted inserted replaced
2238:7f92d70a326e 2239:f70a91f7810d
323 constK "MIN", 323 constK "MIN",
324 constK "MAX", 324 constK "MAX",
325 constK "SUM", 325 constK "SUM",
326 constK "AVG"] 326 constK "AVG"]
327 327
328 fun arithmetic pExp = follow (const "(")
329 (follow pExp
330 (follow (altL (map const [" + ", " - ", " * ", " / "]))
331 (follow pExp (const ")"))))
332
328 val unmodeled = altL [const "COUNT(*)", 333 val unmodeled = altL [const "COUNT(*)",
329 const "CURRENT_TIMESTAMP"] 334 const "CURRENT_TIMESTAMP"]
330 335
331 val sqlcacheMode = ref false; 336 val sqlcacheMode = ref false;
332 337
338 wrap (const "NULL") (fn () => Null), 343 wrap (const "NULL") (fn () => Null),
339 wrap field Field, 344 wrap field Field,
340 wrap uw_ident Computed, 345 wrap uw_ident Computed,
341 wrap known SqKnown, 346 wrap known SqKnown,
342 wrap func SqFunc, 347 wrap func SqFunc,
348 wrap (arithmetic sqexp) (fn _ => Unmodeled),
343 wrap unmodeled (fn () => Unmodeled), 349 wrap unmodeled (fn () => Unmodeled),
344 wrap (if !sqlcacheMode then sqlifySqlcache else sqlify) Inj, 350 wrap (if !sqlcacheMode then sqlifySqlcache else sqlify) Inj,
345 wrap (follow (const "COALESCE(") (follow sqexp (follow (const ",") 351 wrap (follow (const "COALESCE(") (follow sqexp (follow (const ",")
346 (follow (keep (fn ch => ch <> #")")) (const ")"))))) 352 (follow (keep (fn ch => ch <> #")")) (const ")")))))
347 (fn ((), (e, _)) => e), 353 (fn ((), (e, _)) => e),