diff 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
line wrap: on
line diff
--- a/src/sql.sml	Mon Jul 06 01:31:04 2015 -0700
+++ b/src/sql.sml	Tue Jul 07 00:07:24 2015 -0700
@@ -325,6 +325,11 @@
                      constK "SUM",
                      constK "AVG"]
 
+fun arithmetic pExp = follow (const "(")
+                             (follow pExp
+                                     (follow (altL (map const [" + ", " - ", " * ", " / "]))
+                                             (follow pExp (const ")"))))
+
 val unmodeled = altL [const "COUNT(*)",
                       const "CURRENT_TIMESTAMP"]
 
@@ -340,6 +345,7 @@
            wrap uw_ident Computed,
            wrap known SqKnown,
            wrap func SqFunc,
+           wrap (arithmetic sqexp) (fn _ => Unmodeled),
            wrap unmodeled (fn () => Unmodeled),
            wrap (if !sqlcacheMode then sqlifySqlcache else sqlify) Inj,
            wrap (follow (const "COALESCE(") (follow sqexp (follow (const ",")