summaryrefslogtreecommitdiff
path: root/src/sql.sml
diff options
context:
space:
mode:
authorGravatar Ziv Scully <ziv@mit.edu>2015-07-07 00:07:24 -0700
committerGravatar Ziv Scully <ziv@mit.edu>2015-07-07 00:07:24 -0700
commit03b7950e3639899de788cac8824a0e7f4be8a0bd (patch)
tree3863c03ffd1f8d9c22e67f009292ede55f64d4f7 /src/sql.sml
parentf9021ccf1a76dd7e570061849acdec515b5be790 (diff)
Add limited support for parsing SQL arithmetic.
Diffstat (limited to 'src/sql.sml')
-rw-r--r--src/sql.sml6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/sql.sml b/src/sql.sml
index 959575e9..27894e3f 100644
--- a/src/sql.sml
+++ b/src/sql.sml
@@ -325,6 +325,11 @@ val funcName = altL [constK "COUNT",
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 @@ fun sqexp chs =
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 ",")