implement SQL function calls, unquote

This commit is contained in:
Jeremy Penner 2022-04-09 11:36:19 -04:00
parent f33b0cd695
commit 35d9fc10e7
2 changed files with 2 additions and 0 deletions

View file

@ -175,6 +175,7 @@
[:set column subexpr] (.. column " = " (self:gen-expr analysis subexpr))
(where [:var name] (. analysis.variable-mapping name)) (self:gen-expr analysis (. analysis.variable-mapping name))
(where [op lhs rhs] (. infix-ops op)) (.. "(" (self:gen-expr analysis lhs) " " op " " (self:gen-expr analysis rhs) ")")
[funcname & args] (.. funcname "(" (cat args ", " #(self:gen-expr analysis $1)) ")")
_ (error (.. "Unrecognized expression " (fv expr)))))
(fn Compiler.gen-rule-clause [self analysis-parent [head & literals]]

View file

@ -4,6 +4,7 @@
(fn clause [c]
(match c
(where [escape expr] (list? c) (= (tostring escape) :unquote)) expr
(where [escape expr] (list? c) (= (tostring escape) :hashfn)) `[:const ,expr]
(where [name & params] (sequence? c)) `[:literal ,(tostring name) ,(icollect [_ param (ipairs params)] (clause param))]
(where [head & args] (list? c) (sym? head)) (icollect [_ expr (ipairs args) :into [(tostring head)]] (clause expr))