diff --git a/resources/gensql/query/base.bnf b/resources/gensql/query/base.bnf index aac1a3a2..b5d61964 100644 --- a/resources/gensql/query/base.bnf +++ b/resources/gensql/query/base.bnf @@ -125,7 +125,8 @@ scalar-expr ::= scalar-expr-0 ::= scalar-expr-4 | expr-binop ::= scalar-expr-5 | expr-addition | expr-subtraction ::= scalar-expr-6 | expr-multiplication | expr-division - ::= scalar-expr-7 | expr-function-call + ::= scalar-expr-7 | expr-exponentiation + ::= scalar-expr-8 | expr-function-call expr-disjunction ::= scalar-expr-0 ws #'(?i)OR' ws scalar-expr-1 expr-conjunction ::= scalar-expr-1 ws #'(?i)AND' ws scalar-expr-2 @@ -140,9 +141,15 @@ expr-subtraction ::= scalar-expr-4 ws? '-' ws? scalar-expr-5 expr-multiplication ::= scalar-expr-5 ws? '*' ws? scalar-expr-6 expr-division ::= scalar-expr-5 ws? '/' ws? scalar-expr-6 +expr-exponentiation ::= scalar-expr-6 ws? '^' ws? scalar-expr-7 + (* currently only log - will likely add more later *) - ::= expr-function-call-log + ::= expr-function-call-log | expr-function-call-sqrt | expr-function-call-sin | expr-function-call-cos | expr-function-call-tan expr-function-call-log ::= 'log(' ws? scalar-expr-6 ws? ')' +expr-function-call-sqrt ::= 'sqrt(' ws? scalar-expr-6 ws? ')' +expr-function-call-sin ::= 'sin(' ws? scalar-expr-6 ws? ')' +expr-function-call-cos ::= 'cos(' ws? scalar-expr-6 ws? ')' +expr-function-call-tan ::= 'tan(' ws? scalar-expr-6 ws? ')' scalar-expr-group ::= '(' ws? scalar-expr ws? ')' diff --git a/resources/gensql/query/permissive.bnf b/resources/gensql/query/permissive.bnf index e0b074fa..f4cc3774 100644 --- a/resources/gensql/query/permissive.bnf +++ b/resources/gensql/query/permissive.bnf @@ -1,5 +1,5 @@ ::= scalar-expr-1 | expr-disjunction | probability-expr | mutual-info-expr - ::= scalar-expr-group | identifier | value + ::= scalar-expr-group | identifier | value (* model-expr *) diff --git a/resources/gensql/query/strict.bnf b/resources/gensql/query/strict.bnf index 4673f718..bd3c0105 100644 --- a/resources/gensql/query/strict.bnf +++ b/resources/gensql/query/strict.bnf @@ -1,4 +1,4 @@ - ::= scalar-expr-group + ::= scalar-expr-group | identifier | value | probability-expr diff --git a/src/gensql/query/scalar.cljc b/src/gensql/query/scalar.cljc index 8192fbb0..5454e5b2 100644 --- a/src/gensql/query/scalar.cljc +++ b/src/gensql/query/scalar.cljc @@ -60,8 +60,10 @@ [:expr-subtraction left _ right] `(~'- ~(plan left) ~(plan right)) [:expr-multiplication left _ right] `(~'* ~(plan left) ~(plan right)) [:expr-division left _ right] `(~'/ ~(plan left) ~(plan right)) + [:expr-exponentiation left _ right] `(~'pow ~(plan left) ~(plan right)) [:expr-function-call-log _log child _] `(~'log ~(plan child)) + [:expr-function-call-sqrt _sqrt child _] `(~'sqrt ~(plan child)) [:expr-binop left [:binop [:is _]] right] `(~'= ~(plan left) ~(plan right)) [:expr-binop left [:binop [:is-not & _]] right] `(~'not= ~(plan left) ~(plan right)) @@ -299,7 +301,9 @@ '- (nil-safe (auto-unbox -)) '* (nil-safe (auto-unbox *)) '/ (nil-safe (auto-unbox /)) - 'log (nil-safe (auto-unbox math/log))} + 'pow (nil-safe (auto-unbox math/pow)) + 'log (nil-safe (auto-unbox math/log)) + 'sqrt (nil-safe (auto-unbox math/sqrt))} 'gensql {'safe-get safe-get 'prob prob 'pdf pdf