This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch NLPCRAFT-206
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-206 by this push:
     new 0876ae5  WIP.
0876ae5 is described below

commit 0876ae579dbb10153ac147ac2fe5a9908654af7b
Author: Aaron Radzinski <[email protected]>
AuthorDate: Sat Feb 13 16:47:36 2021 -0800

    WIP.
---
 .../model/intent/impl/antlr4/NCIntentDsl.g4        |  23 +-
 .../model/intent/impl/antlr4/NCIntentDsl.interp    |   4 +-
 .../impl/antlr4/NCIntentDslBaseListener.java       |  98 ++-
 .../model/intent/impl/antlr4/NCIntentDslLexer.java |   2 +-
 .../intent/impl/antlr4/NCIntentDslListener.java    | 116 ++-
 .../intent/impl/antlr4/NCIntentDslParser.java      | 883 ++++++++++++---------
 .../intent/impl/ver2/NCIntentDslCompiler.scala     | 353 ++++----
 7 files changed, 938 insertions(+), 541 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDsl.g4
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDsl.g4
index 8c6bc55..c1caf42 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDsl.g4
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDsl.g4
@@ -52,15 +52,18 @@ javaFqn
     ;
 termId: LPAR ID RPAR;
 expr
-    : unary
-    | expr (AND | OR | EQ | NEQ | MULT | DIV | PLUS | MINUS | MOD | LTEQ | 
GTEQ | LT | GT) expr
-    | atom
-    | expr COMMA atom
-    | LPAR expr RPAR
-    | call
+    // NOTE: order of productions defines precedence.
+    : op=(MINUS | NOT) expr # unaryExpr
+    | LPAR expr RPAR # parExpr
+    | expr op=(MULT | DIV | MOD) expr # multExpr
+    | expr op=(PLUS | MINUS) expr # plusExpr
+    | expr op=(LTEQ | GTEQ | LT | GT) expr # compExpr
+    | expr op=(EQ | NEQ) expr # eqExpr
+    | expr op=(AND | OR) expr # logExpr
+    | atom # atomExpr
+    | expr COMMA atom # listExpr
+    | ID LPAR expr? RPAR # callExpr
     ;
-unary: (MINUS | NOT) expr;
-call: ID LPAR expr? RPAR; // Buit-in function call.
 atom
     : NULL
     | INT REAL? EXP?
@@ -83,6 +86,8 @@ minMaxShortcut
 minMaxRange: LBR INT COMMA INT RBR;
 SQSTRING: SQUOTE (~'\'')* SQUOTE;
 DQSTRING: DQUOTE (~'"')* DQUOTE;
+BOOL: 'true' | 'false';
+NULL: 'null';
 EQ: '==';
 NEQ: '!=';
 GTEQ: '>=';
@@ -115,8 +120,6 @@ MULT: '*';
 DIV: '/';
 MOD: '%';
 DOLLAR: '$';
-BOOL: 'true' | 'false';
-NULL: 'null';
 INT: '0' | [1-9] [_0-9]*;
 REAL: DOT [0-9]+;
 EXP: [Ee] [+\-]? INT;
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDsl.interp
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDsl.interp
index bc92308..99b35ec 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDsl.interp
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDsl.interp
@@ -115,8 +115,6 @@ clsNer
 javaFqn
 termId
 expr
-unary
-call
 atom
 qstring
 minMax
@@ -125,4 +123,4 @@ minMaxRange
 
 
 atn:
-[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 49, 237, 4, 2, 
9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 
4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 
14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 
20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 3, 2, 3, 2, 
5, 2, 51, 10, 2, 3, 2, 5, 2, 54, 10, 2, 3, 2, 5, 2, 57, 10, 2, 3, 2, 3, 2, 3, 
2, 3, 3, 3, 3, 3, 3, 3,  [...]
\ No newline at end of file
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 49, 241, 4, 2, 
9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 
4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 
14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 
20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 3, 2, 3, 2, 5, 2, 47, 10, 2, 3, 2, 5, 2, 
50, 10, 2, 3, 2, 5, 2, 53, 10, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
4, 3, 4, 3, 4, 3, 4, 3 [...]
\ No newline at end of file
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslBaseListener.java
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslBaseListener.java
index 52d0a51..6007b7f 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslBaseListener.java
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslBaseListener.java
@@ -1,4 +1,4 @@
-// Generated from 
/Users/nivanov/incubator-nlpcraft/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDsl.g4
 by ANTLR 4.9.1
+// Generated from C:/Users/Nikita 
Ivanov/Documents/GitHub/incubator-nlpcraft/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4\NCIntentDsl.g4
 by ANTLR 4.9.1
 package org.apache.nlpcraft.model.intent.impl.antlr4;
 
 import org.antlr.v4.runtime.ParserRuleContext;
@@ -196,37 +196,121 @@ public class NCIntentDslBaseListener implements 
NCIntentDslListener {
         *
         * <p>The default implementation does nothing.</p>
         */
-       @Override public void enterExpr(NCIntentDslParser.ExprContext ctx) { }
+       @Override public void enterParExpr(NCIntentDslParser.ParExprContext 
ctx) { }
        /**
         * {@inheritDoc}
         *
         * <p>The default implementation does nothing.</p>
         */
-       @Override public void exitExpr(NCIntentDslParser.ExprContext ctx) { }
+       @Override public void exitParExpr(NCIntentDslParser.ParExprContext ctx) 
{ }
        /**
         * {@inheritDoc}
         *
         * <p>The default implementation does nothing.</p>
         */
-       @Override public void enterUnary(NCIntentDslParser.UnaryContext ctx) { }
+       @Override public void enterEqExpr(NCIntentDslParser.EqExprContext ctx) 
{ }
        /**
         * {@inheritDoc}
         *
         * <p>The default implementation does nothing.</p>
         */
-       @Override public void exitUnary(NCIntentDslParser.UnaryContext ctx) { }
+       @Override public void exitEqExpr(NCIntentDslParser.EqExprContext ctx) { 
}
        /**
         * {@inheritDoc}
         *
         * <p>The default implementation does nothing.</p>
         */
-       @Override public void enterCall(NCIntentDslParser.CallContext ctx) { }
+       @Override public void enterUnaryExpr(NCIntentDslParser.UnaryExprContext 
ctx) { }
        /**
         * {@inheritDoc}
         *
         * <p>The default implementation does nothing.</p>
         */
-       @Override public void exitCall(NCIntentDslParser.CallContext ctx) { }
+       @Override public void exitUnaryExpr(NCIntentDslParser.UnaryExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void enterCompExpr(NCIntentDslParser.CompExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void exitCompExpr(NCIntentDslParser.CompExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void enterAtomExpr(NCIntentDslParser.AtomExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void exitAtomExpr(NCIntentDslParser.AtomExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void enterCallExpr(NCIntentDslParser.CallExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void exitCallExpr(NCIntentDslParser.CallExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void enterMultExpr(NCIntentDslParser.MultExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void exitMultExpr(NCIntentDslParser.MultExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void enterListExpr(NCIntentDslParser.ListExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void exitListExpr(NCIntentDslParser.ListExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void enterPlusExpr(NCIntentDslParser.PlusExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void exitPlusExpr(NCIntentDslParser.PlusExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void enterLogExpr(NCIntentDslParser.LogExprContext 
ctx) { }
+       /**
+        * {@inheritDoc}
+        *
+        * <p>The default implementation does nothing.</p>
+        */
+       @Override public void exitLogExpr(NCIntentDslParser.LogExprContext ctx) 
{ }
        /**
         * {@inheritDoc}
         *
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslLexer.java
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslLexer.java
index c2227dd..04d8d18 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslLexer.java
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslLexer.java
@@ -1,4 +1,4 @@
-// Generated from 
/Users/nivanov/incubator-nlpcraft/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDsl.g4
 by ANTLR 4.9.1
+// Generated from C:/Users/Nikita 
Ivanov/Documents/GitHub/incubator-nlpcraft/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4\NCIntentDsl.g4
 by ANTLR 4.9.1
 package org.apache.nlpcraft.model.intent.impl.antlr4;
 import org.antlr.v4.runtime.Lexer;
 import org.antlr.v4.runtime.CharStream;
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslListener.java
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslListener.java
index 2277019..5778c43 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslListener.java
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslListener.java
@@ -1,4 +1,4 @@
-// Generated from 
/Users/nivanov/incubator-nlpcraft/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDsl.g4
 by ANTLR 4.9.1
+// Generated from C:/Users/Nikita 
Ivanov/Documents/GitHub/incubator-nlpcraft/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4\NCIntentDsl.g4
 by ANTLR 4.9.1
 package org.apache.nlpcraft.model.intent.impl.antlr4;
 import org.antlr.v4.runtime.tree.ParseTreeListener;
 
@@ -158,35 +158,125 @@ public interface NCIntentDslListener extends 
ParseTreeListener {
         */
        void exitTermId(NCIntentDslParser.TermIdContext ctx);
        /**
-        * Enter a parse tree produced by {@link NCIntentDslParser#expr}.
+        * Enter a parse tree produced by the {@code parExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
         * @param ctx the parse tree
         */
-       void enterExpr(NCIntentDslParser.ExprContext ctx);
+       void enterParExpr(NCIntentDslParser.ParExprContext ctx);
        /**
-        * Exit a parse tree produced by {@link NCIntentDslParser#expr}.
+        * Exit a parse tree produced by the {@code parExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
         * @param ctx the parse tree
         */
-       void exitExpr(NCIntentDslParser.ExprContext ctx);
+       void exitParExpr(NCIntentDslParser.ParExprContext ctx);
        /**
-        * Enter a parse tree produced by {@link NCIntentDslParser#unary}.
+        * Enter a parse tree produced by the {@code eqExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
         * @param ctx the parse tree
         */
-       void enterUnary(NCIntentDslParser.UnaryContext ctx);
+       void enterEqExpr(NCIntentDslParser.EqExprContext ctx);
        /**
-        * Exit a parse tree produced by {@link NCIntentDslParser#unary}.
+        * Exit a parse tree produced by the {@code eqExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
         * @param ctx the parse tree
         */
-       void exitUnary(NCIntentDslParser.UnaryContext ctx);
+       void exitEqExpr(NCIntentDslParser.EqExprContext ctx);
        /**
-        * Enter a parse tree produced by {@link NCIntentDslParser#call}.
+        * Enter a parse tree produced by the {@code unaryExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
         * @param ctx the parse tree
         */
-       void enterCall(NCIntentDslParser.CallContext ctx);
+       void enterUnaryExpr(NCIntentDslParser.UnaryExprContext ctx);
        /**
-        * Exit a parse tree produced by {@link NCIntentDslParser#call}.
+        * Exit a parse tree produced by the {@code unaryExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
         * @param ctx the parse tree
         */
-       void exitCall(NCIntentDslParser.CallContext ctx);
+       void exitUnaryExpr(NCIntentDslParser.UnaryExprContext ctx);
+       /**
+        * Enter a parse tree produced by the {@code compExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void enterCompExpr(NCIntentDslParser.CompExprContext ctx);
+       /**
+        * Exit a parse tree produced by the {@code compExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void exitCompExpr(NCIntentDslParser.CompExprContext ctx);
+       /**
+        * Enter a parse tree produced by the {@code atomExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void enterAtomExpr(NCIntentDslParser.AtomExprContext ctx);
+       /**
+        * Exit a parse tree produced by the {@code atomExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void exitAtomExpr(NCIntentDslParser.AtomExprContext ctx);
+       /**
+        * Enter a parse tree produced by the {@code callExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void enterCallExpr(NCIntentDslParser.CallExprContext ctx);
+       /**
+        * Exit a parse tree produced by the {@code callExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void exitCallExpr(NCIntentDslParser.CallExprContext ctx);
+       /**
+        * Enter a parse tree produced by the {@code multExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void enterMultExpr(NCIntentDslParser.MultExprContext ctx);
+       /**
+        * Exit a parse tree produced by the {@code multExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void exitMultExpr(NCIntentDslParser.MultExprContext ctx);
+       /**
+        * Enter a parse tree produced by the {@code listExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void enterListExpr(NCIntentDslParser.ListExprContext ctx);
+       /**
+        * Exit a parse tree produced by the {@code listExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void exitListExpr(NCIntentDslParser.ListExprContext ctx);
+       /**
+        * Enter a parse tree produced by the {@code plusExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void enterPlusExpr(NCIntentDslParser.PlusExprContext ctx);
+       /**
+        * Exit a parse tree produced by the {@code plusExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void exitPlusExpr(NCIntentDslParser.PlusExprContext ctx);
+       /**
+        * Enter a parse tree produced by the {@code logExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void enterLogExpr(NCIntentDslParser.LogExprContext ctx);
+       /**
+        * Exit a parse tree produced by the {@code logExpr}
+        * labeled alternative in {@link NCIntentDslParser#expr}.
+        * @param ctx the parse tree
+        */
+       void exitLogExpr(NCIntentDslParser.LogExprContext ctx);
        /**
         * Enter a parse tree produced by {@link NCIntentDslParser#atom}.
         * @param ctx the parse tree
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslParser.java
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslParser.java
index aea685d..d7a1358 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslParser.java
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDslParser.java
@@ -1,4 +1,4 @@
-// Generated from 
/Users/nivanov/incubator-nlpcraft/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4/NCIntentDsl.g4
 by ANTLR 4.9.1
+// Generated from C:/Users/Nikita 
Ivanov/Documents/GitHub/incubator-nlpcraft/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/antlr4\NCIntentDsl.g4
 by ANTLR 4.9.1
 package org.apache.nlpcraft.model.intent.impl.antlr4;
 import org.antlr.v4.runtime.atn.*;
 import org.antlr.v4.runtime.dfa.DFA;
@@ -27,15 +27,14 @@ public class NCIntentDslParser extends Parser {
                RULE_intent = 0, RULE_intentId = 1, RULE_orderedDecl = 2, 
RULE_flowDecl = 3, 
                RULE_metaDecl = 4, RULE_jsonObj = 5, RULE_jsonPair = 6, 
RULE_jsonVal = 7, 
                RULE_jsonArr = 8, RULE_terms = 9, RULE_termEq = 10, RULE_term = 
11, RULE_clsNer = 12, 
-               RULE_javaFqn = 13, RULE_termId = 14, RULE_expr = 15, RULE_unary 
= 16, 
-               RULE_call = 17, RULE_atom = 18, RULE_qstring = 19, RULE_minMax 
= 20, RULE_minMaxShortcut = 21, 
-               RULE_minMaxRange = 22;
+               RULE_javaFqn = 13, RULE_termId = 14, RULE_expr = 15, RULE_atom 
= 16, RULE_qstring = 17, 
+               RULE_minMax = 18, RULE_minMaxShortcut = 19, RULE_minMaxRange = 
20;
        private static String[] makeRuleNames() {
                return new String[] {
                        "intent", "intentId", "orderedDecl", "flowDecl", 
"metaDecl", "jsonObj", 
                        "jsonPair", "jsonVal", "jsonArr", "terms", "termEq", 
"term", "clsNer", 
-                       "javaFqn", "termId", "expr", "unary", "call", "atom", 
"qstring", "minMax", 
-                       "minMaxShortcut", "minMaxRange"
+                       "javaFqn", "termId", "expr", "atom", "qstring", 
"minMax", "minMaxShortcut", 
+                       "minMaxRange"
                };
        }
        public static final String[] ruleNames = makeRuleNames();
@@ -149,41 +148,41 @@ public class NCIntentDslParser extends Parser {
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(46);
+                       setState(42);
                        intentId();
-                       setState(48);
+                       setState(44);
                        _errHandler.sync(this);
                        _la = _input.LA(1);
                        if (_la==T__1) {
                                {
-                               setState(47);
+                               setState(43);
                                orderedDecl();
                                }
                        }
 
-                       setState(51);
+                       setState(47);
                        _errHandler.sync(this);
                        _la = _input.LA(1);
                        if (_la==T__2) {
                                {
-                               setState(50);
+                               setState(46);
                                flowDecl();
                                }
                        }
 
-                       setState(54);
+                       setState(50);
                        _errHandler.sync(this);
                        _la = _input.LA(1);
                        if (_la==T__3) {
                                {
-                               setState(53);
+                               setState(49);
                                metaDecl();
                                }
                        }
 
-                       setState(56);
+                       setState(52);
                        terms(0);
-                       setState(57);
+                       setState(53);
                        match(EOF);
                        }
                }
@@ -221,11 +220,11 @@ public class NCIntentDslParser extends Parser {
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(59);
+                       setState(55);
                        match(T__0);
-                       setState(60);
+                       setState(56);
                        match(ASSIGN);
-                       setState(61);
+                       setState(57);
                        match(ID);
                        }
                }
@@ -263,11 +262,11 @@ public class NCIntentDslParser extends Parser {
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(63);
+                       setState(59);
                        match(T__1);
-                       setState(64);
+                       setState(60);
                        match(ASSIGN);
-                       setState(65);
+                       setState(61);
                        match(BOOL);
                        }
                }
@@ -307,11 +306,11 @@ public class NCIntentDslParser extends Parser {
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(67);
+                       setState(63);
                        match(T__2);
-                       setState(68);
+                       setState(64);
                        match(ASSIGN);
-                       setState(69);
+                       setState(65);
                        qstring();
                        }
                }
@@ -351,11 +350,11 @@ public class NCIntentDslParser extends Parser {
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(71);
+                       setState(67);
                        match(T__3);
-                       setState(72);
+                       setState(68);
                        match(ASSIGN);
-                       setState(73);
+                       setState(69);
                        jsonObj();
                        }
                }
@@ -402,42 +401,42 @@ public class NCIntentDslParser extends Parser {
                enterRule(_localctx, 10, RULE_jsonObj);
                int _la;
                try {
-                       setState(88);
+                       setState(84);
                        _errHandler.sync(this);
                        switch ( 
getInterpreter().adaptivePredict(_input,4,_ctx) ) {
                        case 1:
                                enterOuterAlt(_localctx, 1);
                                {
-                               setState(75);
+                               setState(71);
                                match(LBRACE);
-                               setState(76);
+                               setState(72);
                                jsonPair();
-                               setState(81);
+                               setState(77);
                                _errHandler.sync(this);
                                _la = _input.LA(1);
                                while (_la==COMMA) {
                                        {
                                        {
-                                       setState(77);
+                                       setState(73);
                                        match(COMMA);
-                                       setState(78);
+                                       setState(74);
                                        jsonPair();
                                        }
                                        }
-                                       setState(83);
+                                       setState(79);
                                        _errHandler.sync(this);
                                        _la = _input.LA(1);
                                }
-                               setState(84);
+                               setState(80);
                                match(RBRACE);
                                }
                                break;
                        case 2:
                                enterOuterAlt(_localctx, 2);
                                {
-                               setState(86);
+                               setState(82);
                                match(LBRACE);
-                               setState(87);
+                               setState(83);
                                match(RBRACE);
                                }
                                break;
@@ -482,11 +481,11 @@ public class NCIntentDslParser extends Parser {
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(90);
+                       setState(86);
                        qstring();
-                       setState(91);
+                       setState(87);
                        match(COLON);
-                       setState(92);
+                       setState(88);
                        jsonVal();
                        }
                }
@@ -536,14 +535,14 @@ public class NCIntentDslParser extends Parser {
                enterRule(_localctx, 14, RULE_jsonVal);
                int _la;
                try {
-                       setState(109);
+                       setState(105);
                        _errHandler.sync(this);
                        switch (_input.LA(1)) {
                        case SQSTRING:
                        case DQSTRING:
                                enterOuterAlt(_localctx, 1);
                                {
-                               setState(94);
+                               setState(90);
                                qstring();
                                }
                                break;
@@ -551,34 +550,34 @@ public class NCIntentDslParser extends Parser {
                        case INT:
                                enterOuterAlt(_localctx, 2);
                                {
-                               setState(96);
+                               setState(92);
                                _errHandler.sync(this);
                                _la = _input.LA(1);
                                if (_la==MINUS) {
                                        {
-                                       setState(95);
+                                       setState(91);
                                        match(MINUS);
                                        }
                                }
 
-                               setState(98);
+                               setState(94);
                                match(INT);
-                               setState(100);
+                               setState(96);
                                _errHandler.sync(this);
                                _la = _input.LA(1);
                                if (_la==REAL) {
                                        {
-                                       setState(99);
+                                       setState(95);
                                        match(REAL);
                                        }
                                }
 
-                               setState(103);
+                               setState(99);
                                _errHandler.sync(this);
                                _la = _input.LA(1);
                                if (_la==EXP) {
                                        {
-                                       setState(102);
+                                       setState(98);
                                        match(EXP);
                                        }
                                }
@@ -588,28 +587,28 @@ public class NCIntentDslParser extends Parser {
                        case LBRACE:
                                enterOuterAlt(_localctx, 3);
                                {
-                               setState(105);
+                               setState(101);
                                jsonObj();
                                }
                                break;
                        case LBR:
                                enterOuterAlt(_localctx, 4);
                                {
-                               setState(106);
+                               setState(102);
                                jsonArr();
                                }
                                break;
                        case BOOL:
                                enterOuterAlt(_localctx, 5);
                                {
-                               setState(107);
+                               setState(103);
                                match(BOOL);
                                }
                                break;
                        case NULL:
                                enterOuterAlt(_localctx, 6);
                                {
-                               setState(108);
+                               setState(104);
                                match(NULL);
                                }
                                break;
@@ -660,42 +659,42 @@ public class NCIntentDslParser extends Parser {
                enterRule(_localctx, 16, RULE_jsonArr);
                int _la;
                try {
-                       setState(124);
+                       setState(120);
                        _errHandler.sync(this);
                        switch ( 
getInterpreter().adaptivePredict(_input,10,_ctx) ) {
                        case 1:
                                enterOuterAlt(_localctx, 1);
                                {
-                               setState(111);
+                               setState(107);
                                match(LBR);
-                               setState(112);
+                               setState(108);
                                jsonVal();
-                               setState(117);
+                               setState(113);
                                _errHandler.sync(this);
                                _la = _input.LA(1);
                                while (_la==COMMA) {
                                        {
                                        {
-                                       setState(113);
+                                       setState(109);
                                        match(COMMA);
-                                       setState(114);
+                                       setState(110);
                                        jsonVal();
                                        }
                                        }
-                                       setState(119);
+                                       setState(115);
                                        _errHandler.sync(this);
                                        _la = _input.LA(1);
                                }
-                               setState(120);
+                               setState(116);
                                match(RBR);
                                }
                                break;
                        case 2:
                                enterOuterAlt(_localctx, 2);
                                {
-                               setState(122);
+                               setState(118);
                                match(LBR);
-                               setState(123);
+                               setState(119);
                                match(RBR);
                                }
                                break;
@@ -749,11 +748,11 @@ public class NCIntentDslParser extends Parser {
                        enterOuterAlt(_localctx, 1);
                        {
                        {
-                       setState(127);
+                       setState(123);
                        term();
                        }
                        _ctx.stop = _input.LT(-1);
-                       setState(133);
+                       setState(129);
                        _errHandler.sync(this);
                        _alt = getInterpreter().adaptivePredict(_input,11,_ctx);
                        while ( _alt!=2 && 
_alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
@@ -764,14 +763,14 @@ public class NCIntentDslParser extends Parser {
                                        {
                                        _localctx = new 
TermsContext(_parentctx, _parentState);
                                        pushNewRecursionContext(_localctx, 
_startState, RULE_terms);
-                                       setState(129);
+                                       setState(125);
                                        if (!(precpred(_ctx, 1))) throw new 
FailedPredicateException(this, "precpred(_ctx, 1)");
-                                       setState(130);
+                                       setState(126);
                                        term();
                                        }
                                        } 
                                }
-                               setState(135);
+                               setState(131);
                                _errHandler.sync(this);
                                _alt = 
getInterpreter().adaptivePredict(_input,11,_ctx);
                        }
@@ -812,7 +811,7 @@ public class NCIntentDslParser extends Parser {
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(136);
+                       setState(132);
                        _la = _input.LA(1);
                        if ( !(_la==TILDA || _la==ASSIGN) ) {
                        _errHandler.recoverInline(this);
@@ -878,31 +877,31 @@ public class NCIntentDslParser extends Parser {
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(138);
+                       setState(134);
                        match(T__4);
-                       setState(140);
+                       setState(136);
                        _errHandler.sync(this);
                        _la = _input.LA(1);
                        if (_la==LPAR) {
                                {
-                               setState(139);
+                               setState(135);
                                termId();
                                }
                        }
 
-                       setState(142);
+                       setState(138);
                        termEq();
-                       setState(151);
+                       setState(147);
                        _errHandler.sync(this);
                        switch (_input.LA(1)) {
                        case LBRACE:
                                {
                                {
-                               setState(143);
+                               setState(139);
                                match(LBRACE);
-                               setState(144);
+                               setState(140);
                                expr(0);
-                               setState(145);
+                               setState(141);
                                match(RBRACE);
                                }
                                }
@@ -910,11 +909,11 @@ public class NCIntentDslParser extends Parser {
                        case DIV:
                                {
                                {
-                               setState(147);
+                               setState(143);
                                match(DIV);
-                               setState(148);
+                               setState(144);
                                clsNer();
-                               setState(149);
+                               setState(145);
                                match(DIV);
                                }
                                }
@@ -922,12 +921,12 @@ public class NCIntentDslParser extends Parser {
                        default:
                                throw new NoViableAltException(this);
                        }
-                       setState(154);
+                       setState(150);
                        _errHandler.sync(this);
                        switch ( 
getInterpreter().adaptivePredict(_input,14,_ctx) ) {
                        case 1:
                                {
-                               setState(153);
+                               setState(149);
                                minMax();
                                }
                                break;
@@ -972,19 +971,19 @@ public class NCIntentDslParser extends Parser {
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(157);
+                       setState(153);
                        _errHandler.sync(this);
                        _la = _input.LA(1);
                        if (_la==ID) {
                                {
-                               setState(156);
+                               setState(152);
                                javaFqn(0);
                                }
                        }
 
-                       setState(159);
+                       setState(155);
                        match(POUND);
-                       setState(160);
+                       setState(156);
                        match(ID);
                        }
                }
@@ -1035,11 +1034,11 @@ public class NCIntentDslParser extends Parser {
                        enterOuterAlt(_localctx, 1);
                        {
                        {
-                       setState(163);
+                       setState(159);
                        match(ID);
                        }
                        _ctx.stop = _input.LT(-1);
-                       setState(170);
+                       setState(166);
                        _errHandler.sync(this);
                        _alt = getInterpreter().adaptivePredict(_input,16,_ctx);
                        while ( _alt!=2 && 
_alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
@@ -1050,16 +1049,16 @@ public class NCIntentDslParser extends Parser {
                                        {
                                        _localctx = new 
JavaFqnContext(_parentctx, _parentState);
                                        pushNewRecursionContext(_localctx, 
_startState, RULE_javaFqn);
-                                       setState(165);
+                                       setState(161);
                                        if (!(precpred(_ctx, 1))) throw new 
FailedPredicateException(this, "precpred(_ctx, 1)");
-                                       setState(166);
+                                       setState(162);
                                        match(DOT);
-                                       setState(167);
+                                       setState(163);
                                        match(ID);
                                        }
                                        } 
                                }
-                               setState(172);
+                               setState(168);
                                _errHandler.sync(this);
                                _alt = 
getInterpreter().adaptivePredict(_input,16,_ctx);
                        }
@@ -1100,11 +1099,11 @@ public class NCIntentDslParser extends Parser {
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(173);
+                       setState(169);
                        match(LPAR);
-                       setState(174);
+                       setState(170);
                        match(ID);
-                       setState(175);
+                       setState(171);
                        match(RPAR);
                        }
                }
@@ -1120,48 +1119,199 @@ public class NCIntentDslParser extends Parser {
        }
 
        public static class ExprContext extends ParserRuleContext {
-               public UnaryContext unary() {
-                       return getRuleContext(UnaryContext.class,0);
+               public ExprContext(ParserRuleContext parent, int invokingState) 
{
+                       super(parent, invokingState);
                }
-               public AtomContext atom() {
-                       return getRuleContext(AtomContext.class,0);
+               @Override public int getRuleIndex() { return RULE_expr; }
+        
+               public ExprContext() { }
+               public void copyFrom(ExprContext ctx) {
+                       super.copyFrom(ctx);
                }
+       }
+       public static class ParExprContext extends ExprContext {
                public TerminalNode LPAR() { return 
getToken(NCIntentDslParser.LPAR, 0); }
+               public ExprContext expr() {
+                       return getRuleContext(ExprContext.class,0);
+               }
+               public TerminalNode RPAR() { return 
getToken(NCIntentDslParser.RPAR, 0); }
+               public ParExprContext(ExprContext ctx) { copyFrom(ctx); }
+               @Override
+               public void enterRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterParExpr(this);
+               }
+               @Override
+               public void exitRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitParExpr(this);
+               }
+       }
+       public static class EqExprContext extends ExprContext {
+               public Token op;
                public List<ExprContext> expr() {
                        return getRuleContexts(ExprContext.class);
                }
                public ExprContext expr(int i) {
                        return getRuleContext(ExprContext.class,i);
                }
-               public TerminalNode RPAR() { return 
getToken(NCIntentDslParser.RPAR, 0); }
-               public CallContext call() {
-                       return getRuleContext(CallContext.class,0);
-               }
-               public TerminalNode AND() { return 
getToken(NCIntentDslParser.AND, 0); }
-               public TerminalNode OR() { return 
getToken(NCIntentDslParser.OR, 0); }
                public TerminalNode EQ() { return 
getToken(NCIntentDslParser.EQ, 0); }
                public TerminalNode NEQ() { return 
getToken(NCIntentDslParser.NEQ, 0); }
-               public TerminalNode MULT() { return 
getToken(NCIntentDslParser.MULT, 0); }
-               public TerminalNode DIV() { return 
getToken(NCIntentDslParser.DIV, 0); }
-               public TerminalNode PLUS() { return 
getToken(NCIntentDslParser.PLUS, 0); }
+               public EqExprContext(ExprContext ctx) { copyFrom(ctx); }
+               @Override
+               public void enterRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterEqExpr(this);
+               }
+               @Override
+               public void exitRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitEqExpr(this);
+               }
+       }
+       public static class UnaryExprContext extends ExprContext {
+               public Token op;
+               public ExprContext expr() {
+                       return getRuleContext(ExprContext.class,0);
+               }
                public TerminalNode MINUS() { return 
getToken(NCIntentDslParser.MINUS, 0); }
-               public TerminalNode MOD() { return 
getToken(NCIntentDslParser.MOD, 0); }
+               public TerminalNode NOT() { return 
getToken(NCIntentDslParser.NOT, 0); }
+               public UnaryExprContext(ExprContext ctx) { copyFrom(ctx); }
+               @Override
+               public void enterRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterUnaryExpr(this);
+               }
+               @Override
+               public void exitRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitUnaryExpr(this);
+               }
+       }
+       public static class CompExprContext extends ExprContext {
+               public Token op;
+               public List<ExprContext> expr() {
+                       return getRuleContexts(ExprContext.class);
+               }
+               public ExprContext expr(int i) {
+                       return getRuleContext(ExprContext.class,i);
+               }
                public TerminalNode LTEQ() { return 
getToken(NCIntentDslParser.LTEQ, 0); }
                public TerminalNode GTEQ() { return 
getToken(NCIntentDslParser.GTEQ, 0); }
                public TerminalNode LT() { return 
getToken(NCIntentDslParser.LT, 0); }
                public TerminalNode GT() { return 
getToken(NCIntentDslParser.GT, 0); }
+               public CompExprContext(ExprContext ctx) { copyFrom(ctx); }
+               @Override
+               public void enterRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterCompExpr(this);
+               }
+               @Override
+               public void exitRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitCompExpr(this);
+               }
+       }
+       public static class AtomExprContext extends ExprContext {
+               public AtomContext atom() {
+                       return getRuleContext(AtomContext.class,0);
+               }
+               public AtomExprContext(ExprContext ctx) { copyFrom(ctx); }
+               @Override
+               public void enterRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterAtomExpr(this);
+               }
+               @Override
+               public void exitRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitAtomExpr(this);
+               }
+       }
+       public static class CallExprContext extends ExprContext {
+               public TerminalNode ID() { return 
getToken(NCIntentDslParser.ID, 0); }
+               public TerminalNode LPAR() { return 
getToken(NCIntentDslParser.LPAR, 0); }
+               public TerminalNode RPAR() { return 
getToken(NCIntentDslParser.RPAR, 0); }
+               public ExprContext expr() {
+                       return getRuleContext(ExprContext.class,0);
+               }
+               public CallExprContext(ExprContext ctx) { copyFrom(ctx); }
+               @Override
+               public void enterRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterCallExpr(this);
+               }
+               @Override
+               public void exitRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitCallExpr(this);
+               }
+       }
+       public static class MultExprContext extends ExprContext {
+               public Token op;
+               public List<ExprContext> expr() {
+                       return getRuleContexts(ExprContext.class);
+               }
+               public ExprContext expr(int i) {
+                       return getRuleContext(ExprContext.class,i);
+               }
+               public TerminalNode MULT() { return 
getToken(NCIntentDslParser.MULT, 0); }
+               public TerminalNode DIV() { return 
getToken(NCIntentDslParser.DIV, 0); }
+               public TerminalNode MOD() { return 
getToken(NCIntentDslParser.MOD, 0); }
+               public MultExprContext(ExprContext ctx) { copyFrom(ctx); }
+               @Override
+               public void enterRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterMultExpr(this);
+               }
+               @Override
+               public void exitRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitMultExpr(this);
+               }
+       }
+       public static class ListExprContext extends ExprContext {
+               public ExprContext expr() {
+                       return getRuleContext(ExprContext.class,0);
+               }
                public TerminalNode COMMA() { return 
getToken(NCIntentDslParser.COMMA, 0); }
-               public ExprContext(ParserRuleContext parent, int invokingState) 
{
-                       super(parent, invokingState);
+               public AtomContext atom() {
+                       return getRuleContext(AtomContext.class,0);
                }
-               @Override public int getRuleIndex() { return RULE_expr; }
+               public ListExprContext(ExprContext ctx) { copyFrom(ctx); }
+               @Override
+               public void enterRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterListExpr(this);
+               }
+               @Override
+               public void exitRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitListExpr(this);
+               }
+       }
+       public static class PlusExprContext extends ExprContext {
+               public Token op;
+               public List<ExprContext> expr() {
+                       return getRuleContexts(ExprContext.class);
+               }
+               public ExprContext expr(int i) {
+                       return getRuleContext(ExprContext.class,i);
+               }
+               public TerminalNode PLUS() { return 
getToken(NCIntentDslParser.PLUS, 0); }
+               public TerminalNode MINUS() { return 
getToken(NCIntentDslParser.MINUS, 0); }
+               public PlusExprContext(ExprContext ctx) { copyFrom(ctx); }
+               @Override
+               public void enterRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterPlusExpr(this);
+               }
+               @Override
+               public void exitRule(ParseTreeListener listener) {
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitPlusExpr(this);
+               }
+       }
+       public static class LogExprContext extends ExprContext {
+               public Token op;
+               public List<ExprContext> expr() {
+                       return getRuleContexts(ExprContext.class);
+               }
+               public ExprContext expr(int i) {
+                       return getRuleContext(ExprContext.class,i);
+               }
+               public TerminalNode AND() { return 
getToken(NCIntentDslParser.AND, 0); }
+               public TerminalNode OR() { return 
getToken(NCIntentDslParser.OR, 0); }
+               public LogExprContext(ExprContext ctx) { copyFrom(ctx); }
                @Override
                public void enterRule(ParseTreeListener listener) {
-                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterExpr(this);
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterLogExpr(this);
                }
                @Override
                public void exitRule(ParseTreeListener listener) {
-                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitExpr(this);
+                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitLogExpr(this);
                }
        }
 
@@ -1181,14 +1331,42 @@ public class NCIntentDslParser extends Parser {
                        int _alt;
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(185);
+                       setState(187);
                        _errHandler.sync(this);
                        switch (_input.LA(1)) {
                        case NOT:
                        case MINUS:
                                {
+                               _localctx = new UnaryExprContext(_localctx);
+                               _ctx = _localctx;
+                               _prevctx = _localctx;
+
+                               setState(174);
+                               ((UnaryExprContext)_localctx).op = _input.LT(1);
+                               _la = _input.LA(1);
+                               if ( !(_la==NOT || _la==MINUS) ) {
+                                       ((UnaryExprContext)_localctx).op = 
(Token)_errHandler.recoverInline(this);
+                               }
+                               else {
+                                       if ( _input.LA(1)==Token.EOF ) 
matchedEOF = true;
+                                       _errHandler.reportMatch(this);
+                                       consume();
+                               }
+                               setState(175);
+                               expr(10);
+                               }
+                               break;
+                       case LPAR:
+                               {
+                               _localctx = new ParExprContext(_localctx);
+                               _ctx = _localctx;
+                               _prevctx = _localctx;
+                               setState(176);
+                               match(LPAR);
+                               setState(177);
+                               expr(0);
                                setState(178);
-                               unary();
+                               match(RPAR);
                                }
                                break;
                        case SQSTRING:
@@ -1197,79 +1375,174 @@ public class NCIntentDslParser extends Parser {
                        case NULL:
                        case INT:
                                {
-                               setState(179);
+                               _localctx = new AtomExprContext(_localctx);
+                               _ctx = _localctx;
+                               _prevctx = _localctx;
+                               setState(180);
                                atom();
                                }
                                break;
-                       case LPAR:
+                       case ID:
                                {
-                               setState(180);
-                               match(LPAR);
+                               _localctx = new CallExprContext(_localctx);
+                               _ctx = _localctx;
+                               _prevctx = _localctx;
                                setState(181);
-                               expr(0);
+                               match(ID);
                                setState(182);
-                               match(RPAR);
-                               }
-                               break;
-                       case ID:
-                               {
+                               match(LPAR);
                                setState(184);
-                               call();
+                               _errHandler.sync(this);
+                               _la = _input.LA(1);
+                               if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 
((1L << SQSTRING) | (1L << DQSTRING) | (1L << NOT) | (1L << LPAR) | (1L << 
MINUS) | (1L << BOOL) | (1L << NULL) | (1L << INT) | (1L << ID))) != 0)) {
+                                       {
+                                       setState(183);
+                                       expr(0);
+                                       }
+                               }
+
+                               setState(186);
+                               match(RPAR);
                                }
                                break;
                        default:
                                throw new NoViableAltException(this);
                        }
                        _ctx.stop = _input.LT(-1);
-                       setState(195);
+                       setState(209);
                        _errHandler.sync(this);
-                       _alt = getInterpreter().adaptivePredict(_input,19,_ctx);
+                       _alt = getInterpreter().adaptivePredict(_input,20,_ctx);
                        while ( _alt!=2 && 
_alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
                                if ( _alt==1 ) {
                                        if ( _parseListeners!=null ) 
triggerExitRuleEvent();
                                        _prevctx = _localctx;
                                        {
-                                       setState(193);
+                                       setState(207);
                                        _errHandler.sync(this);
-                                       switch ( 
getInterpreter().adaptivePredict(_input,18,_ctx) ) {
+                                       switch ( 
getInterpreter().adaptivePredict(_input,19,_ctx) ) {
                                        case 1:
                                                {
-                                               _localctx = new 
ExprContext(_parentctx, _parentState);
+                                               _localctx = new 
MultExprContext(new ExprContext(_parentctx, _parentState));
+                                               
pushNewRecursionContext(_localctx, _startState, RULE_expr);
+                                               setState(189);
+                                               if (!(precpred(_ctx, 8))) throw 
new FailedPredicateException(this, "precpred(_ctx, 8)");
+                                               setState(190);
+                                               ((MultExprContext)_localctx).op 
= _input.LT(1);
+                                               _la = _input.LA(1);
+                                               if ( !((((_la) & ~0x3f) == 0 && 
((1L << _la) & ((1L << MULT) | (1L << DIV) | (1L << MOD))) != 0)) ) {
+                                                       
((MultExprContext)_localctx).op = (Token)_errHandler.recoverInline(this);
+                                               }
+                                               else {
+                                                       if ( 
_input.LA(1)==Token.EOF ) matchedEOF = true;
+                                                       
_errHandler.reportMatch(this);
+                                                       consume();
+                                               }
+                                               setState(191);
+                                               expr(9);
+                                               }
+                                               break;
+                                       case 2:
+                                               {
+                                               _localctx = new 
PlusExprContext(new ExprContext(_parentctx, _parentState));
+                                               
pushNewRecursionContext(_localctx, _startState, RULE_expr);
+                                               setState(192);
+                                               if (!(precpred(_ctx, 7))) throw 
new FailedPredicateException(this, "precpred(_ctx, 7)");
+                                               setState(193);
+                                               ((PlusExprContext)_localctx).op 
= _input.LT(1);
+                                               _la = _input.LA(1);
+                                               if ( !(_la==MINUS || _la==PLUS) 
) {
+                                                       
((PlusExprContext)_localctx).op = (Token)_errHandler.recoverInline(this);
+                                               }
+                                               else {
+                                                       if ( 
_input.LA(1)==Token.EOF ) matchedEOF = true;
+                                                       
_errHandler.reportMatch(this);
+                                                       consume();
+                                               }
+                                               setState(194);
+                                               expr(8);
+                                               }
+                                               break;
+                                       case 3:
+                                               {
+                                               _localctx = new 
CompExprContext(new ExprContext(_parentctx, _parentState));
+                                               
pushNewRecursionContext(_localctx, _startState, RULE_expr);
+                                               setState(195);
+                                               if (!(precpred(_ctx, 6))) throw 
new FailedPredicateException(this, "precpred(_ctx, 6)");
+                                               setState(196);
+                                               ((CompExprContext)_localctx).op 
= _input.LT(1);
+                                               _la = _input.LA(1);
+                                               if ( !((((_la) & ~0x3f) == 0 && 
((1L << _la) & ((1L << GTEQ) | (1L << LTEQ) | (1L << GT) | (1L << LT))) != 0)) 
) {
+                                                       
((CompExprContext)_localctx).op = (Token)_errHandler.recoverInline(this);
+                                               }
+                                               else {
+                                                       if ( 
_input.LA(1)==Token.EOF ) matchedEOF = true;
+                                                       
_errHandler.reportMatch(this);
+                                                       consume();
+                                               }
+                                               setState(197);
+                                               expr(7);
+                                               }
+                                               break;
+                                       case 4:
+                                               {
+                                               _localctx = new 
EqExprContext(new ExprContext(_parentctx, _parentState));
                                                
pushNewRecursionContext(_localctx, _startState, RULE_expr);
-                                               setState(187);
+                                               setState(198);
                                                if (!(precpred(_ctx, 5))) throw 
new FailedPredicateException(this, "precpred(_ctx, 5)");
-                                               setState(188);
+                                               setState(199);
+                                               ((EqExprContext)_localctx).op = 
_input.LT(1);
                                                _la = _input.LA(1);
-                                               if ( !((((_la) & ~0x3f) == 0 && 
((1L << _la) & ((1L << EQ) | (1L << NEQ) | (1L << GTEQ) | (1L << LTEQ) | (1L << 
GT) | (1L << LT) | (1L << AND) | (1L << OR) | (1L << MINUS) | (1L << PLUS) | 
(1L << MULT) | (1L << DIV) | (1L << MOD))) != 0)) ) {
-                                               _errHandler.recoverInline(this);
+                                               if ( !(_la==EQ || _la==NEQ) ) {
+                                                       
((EqExprContext)_localctx).op = (Token)_errHandler.recoverInline(this);
                                                }
                                                else {
                                                        if ( 
_input.LA(1)==Token.EOF ) matchedEOF = true;
                                                        
_errHandler.reportMatch(this);
                                                        consume();
                                                }
-                                               setState(189);
+                                               setState(200);
                                                expr(6);
                                                }
                                                break;
-                                       case 2:
+                                       case 5:
                                                {
-                                               _localctx = new 
ExprContext(_parentctx, _parentState);
+                                               _localctx = new 
LogExprContext(new ExprContext(_parentctx, _parentState));
                                                
pushNewRecursionContext(_localctx, _startState, RULE_expr);
-                                               setState(190);
-                                               if (!(precpred(_ctx, 3))) throw 
new FailedPredicateException(this, "precpred(_ctx, 3)");
-                                               setState(191);
+                                               setState(201);
+                                               if (!(precpred(_ctx, 4))) throw 
new FailedPredicateException(this, "precpred(_ctx, 4)");
+                                               setState(202);
+                                               ((LogExprContext)_localctx).op 
= _input.LT(1);
+                                               _la = _input.LA(1);
+                                               if ( !(_la==AND || _la==OR) ) {
+                                                       
((LogExprContext)_localctx).op = (Token)_errHandler.recoverInline(this);
+                                               }
+                                               else {
+                                                       if ( 
_input.LA(1)==Token.EOF ) matchedEOF = true;
+                                                       
_errHandler.reportMatch(this);
+                                                       consume();
+                                               }
+                                               setState(203);
+                                               expr(5);
+                                               }
+                                               break;
+                                       case 6:
+                                               {
+                                               _localctx = new 
ListExprContext(new ExprContext(_parentctx, _parentState));
+                                               
pushNewRecursionContext(_localctx, _startState, RULE_expr);
+                                               setState(204);
+                                               if (!(precpred(_ctx, 2))) throw 
new FailedPredicateException(this, "precpred(_ctx, 2)");
+                                               setState(205);
                                                match(COMMA);
-                                               setState(192);
+                                               setState(206);
                                                atom();
                                                }
                                                break;
                                        }
                                        } 
                                }
-                               setState(197);
+                               setState(211);
                                _errHandler.sync(this);
-                               _alt = 
getInterpreter().adaptivePredict(_input,19,_ctx);
+                               _alt = 
getInterpreter().adaptivePredict(_input,20,_ctx);
                        }
                        }
                }
@@ -1284,115 +1557,6 @@ public class NCIntentDslParser extends Parser {
                return _localctx;
        }
 
-       public static class UnaryContext extends ParserRuleContext {
-               public ExprContext expr() {
-                       return getRuleContext(ExprContext.class,0);
-               }
-               public TerminalNode MINUS() { return 
getToken(NCIntentDslParser.MINUS, 0); }
-               public TerminalNode NOT() { return 
getToken(NCIntentDslParser.NOT, 0); }
-               public UnaryContext(ParserRuleContext parent, int 
invokingState) {
-                       super(parent, invokingState);
-               }
-               @Override public int getRuleIndex() { return RULE_unary; }
-               @Override
-               public void enterRule(ParseTreeListener listener) {
-                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterUnary(this);
-               }
-               @Override
-               public void exitRule(ParseTreeListener listener) {
-                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitUnary(this);
-               }
-       }
-
-       public final UnaryContext unary() throws RecognitionException {
-               UnaryContext _localctx = new UnaryContext(_ctx, getState());
-               enterRule(_localctx, 32, RULE_unary);
-               int _la;
-               try {
-                       enterOuterAlt(_localctx, 1);
-                       {
-                       setState(198);
-                       _la = _input.LA(1);
-                       if ( !(_la==NOT || _la==MINUS) ) {
-                       _errHandler.recoverInline(this);
-                       }
-                       else {
-                               if ( _input.LA(1)==Token.EOF ) matchedEOF = 
true;
-                               _errHandler.reportMatch(this);
-                               consume();
-                       }
-                       setState(199);
-                       expr(0);
-                       }
-               }
-               catch (RecognitionException re) {
-                       _localctx.exception = re;
-                       _errHandler.reportError(this, re);
-                       _errHandler.recover(this, re);
-               }
-               finally {
-                       exitRule();
-               }
-               return _localctx;
-       }
-
-       public static class CallContext extends ParserRuleContext {
-               public TerminalNode ID() { return 
getToken(NCIntentDslParser.ID, 0); }
-               public TerminalNode LPAR() { return 
getToken(NCIntentDslParser.LPAR, 0); }
-               public TerminalNode RPAR() { return 
getToken(NCIntentDslParser.RPAR, 0); }
-               public ExprContext expr() {
-                       return getRuleContext(ExprContext.class,0);
-               }
-               public CallContext(ParserRuleContext parent, int invokingState) 
{
-                       super(parent, invokingState);
-               }
-               @Override public int getRuleIndex() { return RULE_call; }
-               @Override
-               public void enterRule(ParseTreeListener listener) {
-                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).enterCall(this);
-               }
-               @Override
-               public void exitRule(ParseTreeListener listener) {
-                       if ( listener instanceof NCIntentDslListener ) 
((NCIntentDslListener)listener).exitCall(this);
-               }
-       }
-
-       public final CallContext call() throws RecognitionException {
-               CallContext _localctx = new CallContext(_ctx, getState());
-               enterRule(_localctx, 34, RULE_call);
-               int _la;
-               try {
-                       enterOuterAlt(_localctx, 1);
-                       {
-                       setState(201);
-                       match(ID);
-                       setState(202);
-                       match(LPAR);
-                       setState(204);
-                       _errHandler.sync(this);
-                       _la = _input.LA(1);
-                       if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << 
SQSTRING) | (1L << DQSTRING) | (1L << NOT) | (1L << LPAR) | (1L << MINUS) | (1L 
<< BOOL) | (1L << NULL) | (1L << INT) | (1L << ID))) != 0)) {
-                               {
-                               setState(203);
-                               expr(0);
-                               }
-                       }
-
-                       setState(206);
-                       match(RPAR);
-                       }
-               }
-               catch (RecognitionException re) {
-                       _localctx.exception = re;
-                       _errHandler.reportError(this, re);
-                       _errHandler.recover(this, re);
-               }
-               finally {
-                       exitRule();
-               }
-               return _localctx;
-       }
-
        public static class AtomContext extends ParserRuleContext {
                public TerminalNode NULL() { return 
getToken(NCIntentDslParser.NULL, 0); }
                public TerminalNode INT() { return 
getToken(NCIntentDslParser.INT, 0); }
@@ -1418,39 +1582,39 @@ public class NCIntentDslParser extends Parser {
 
        public final AtomContext atom() throws RecognitionException {
                AtomContext _localctx = new AtomContext(_ctx, getState());
-               enterRule(_localctx, 36, RULE_atom);
+               enterRule(_localctx, 32, RULE_atom);
                try {
-                       setState(218);
+                       setState(222);
                        _errHandler.sync(this);
                        switch (_input.LA(1)) {
                        case NULL:
                                enterOuterAlt(_localctx, 1);
                                {
-                               setState(208);
+                               setState(212);
                                match(NULL);
                                }
                                break;
                        case INT:
                                enterOuterAlt(_localctx, 2);
                                {
-                               setState(209);
+                               setState(213);
                                match(INT);
-                               setState(211);
+                               setState(215);
                                _errHandler.sync(this);
                                switch ( 
getInterpreter().adaptivePredict(_input,21,_ctx) ) {
                                case 1:
                                        {
-                                       setState(210);
+                                       setState(214);
                                        match(REAL);
                                        }
                                        break;
                                }
-                               setState(214);
+                               setState(218);
                                _errHandler.sync(this);
                                switch ( 
getInterpreter().adaptivePredict(_input,22,_ctx) ) {
                                case 1:
                                        {
-                                       setState(213);
+                                       setState(217);
                                        match(EXP);
                                        }
                                        break;
@@ -1460,7 +1624,7 @@ public class NCIntentDslParser extends Parser {
                        case BOOL:
                                enterOuterAlt(_localctx, 3);
                                {
-                               setState(216);
+                               setState(220);
                                match(BOOL);
                                }
                                break;
@@ -1468,7 +1632,7 @@ public class NCIntentDslParser extends Parser {
                        case DQSTRING:
                                enterOuterAlt(_localctx, 4);
                                {
-                               setState(217);
+                               setState(221);
                                qstring();
                                }
                                break;
@@ -1506,12 +1670,12 @@ public class NCIntentDslParser extends Parser {
 
        public final QstringContext qstring() throws RecognitionException {
                QstringContext _localctx = new QstringContext(_ctx, getState());
-               enterRule(_localctx, 38, RULE_qstring);
+               enterRule(_localctx, 34, RULE_qstring);
                int _la;
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(220);
+                       setState(224);
                        _la = _input.LA(1);
                        if ( !(_la==SQSTRING || _la==DQSTRING) ) {
                        _errHandler.recoverInline(this);
@@ -1557,9 +1721,9 @@ public class NCIntentDslParser extends Parser {
 
        public final MinMaxContext minMax() throws RecognitionException {
                MinMaxContext _localctx = new MinMaxContext(_ctx, getState());
-               enterRule(_localctx, 40, RULE_minMax);
+               enterRule(_localctx, 36, RULE_minMax);
                try {
-                       setState(224);
+                       setState(228);
                        _errHandler.sync(this);
                        switch (_input.LA(1)) {
                        case PLUS:
@@ -1567,14 +1731,14 @@ public class NCIntentDslParser extends Parser {
                        case MULT:
                                enterOuterAlt(_localctx, 1);
                                {
-                               setState(222);
+                               setState(226);
                                minMaxShortcut();
                                }
                                break;
                        case LBR:
                                enterOuterAlt(_localctx, 2);
                                {
-                               setState(223);
+                               setState(227);
                                minMaxRange();
                                }
                                break;
@@ -1613,12 +1777,12 @@ public class NCIntentDslParser extends Parser {
 
        public final MinMaxShortcutContext minMaxShortcut() throws 
RecognitionException {
                MinMaxShortcutContext _localctx = new 
MinMaxShortcutContext(_ctx, getState());
-               enterRule(_localctx, 42, RULE_minMaxShortcut);
+               enterRule(_localctx, 38, RULE_minMaxShortcut);
                int _la;
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(226);
+                       setState(230);
                        _la = _input.LA(1);
                        if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << 
PLUS) | (1L << QUESTION) | (1L << MULT))) != 0)) ) {
                        _errHandler.recoverInline(this);
@@ -1665,19 +1829,19 @@ public class NCIntentDslParser extends Parser {
 
        public final MinMaxRangeContext minMaxRange() throws 
RecognitionException {
                MinMaxRangeContext _localctx = new MinMaxRangeContext(_ctx, 
getState());
-               enterRule(_localctx, 44, RULE_minMaxRange);
+               enterRule(_localctx, 40, RULE_minMaxRange);
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(228);
+                       setState(232);
                        match(LBR);
-                       setState(229);
+                       setState(233);
                        match(INT);
-                       setState(230);
+                       setState(234);
                        match(COMMA);
-                       setState(231);
+                       setState(235);
                        match(INT);
-                       setState(232);
+                       setState(236);
                        match(RBR);
                        }
                }
@@ -1720,90 +1884,101 @@ public class NCIntentDslParser extends Parser {
        private boolean expr_sempred(ExprContext _localctx, int predIndex) {
                switch (predIndex) {
                case 2:
-                       return precpred(_ctx, 5);
+                       return precpred(_ctx, 8);
                case 3:
-                       return precpred(_ctx, 3);
+                       return precpred(_ctx, 7);
+               case 4:
+                       return precpred(_ctx, 6);
+               case 5:
+                       return precpred(_ctx, 5);
+               case 6:
+                       return precpred(_ctx, 4);
+               case 7:
+                       return precpred(_ctx, 2);
                }
                return true;
        }
 
        public static final String _serializedATN =
-               
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\61\u00ed\4\2\t\2"+
+               
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\61\u00f1\4\2\t\2"+
                
"\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+
                
"\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+
-               
"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\3\2\3\2\5"+
-               
"\2\63\n\2\3\2\5\2\66\n\2\3\2\5\29\n\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\4"+
-               
"\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\7\7R\n\7"+
-               
"\f\7\16\7U\13\7\3\7\3\7\3\7\3\7\5\7[\n\7\3\b\3\b\3\b\3\b\3\t\3\t\5\tc"+
-               
"\n\t\3\t\3\t\5\tg\n\t\3\t\5\tj\n\t\3\t\3\t\3\t\3\t\5\tp\n\t\3\n\3\n\3"+
-               
"\n\3\n\7\nv\n\n\f\n\16\ny\13\n\3\n\3\n\3\n\3\n\5\n\177\n\n\3\13\3\13\3"+
-               
"\13\3\13\3\13\7\13\u0086\n\13\f\13\16\13\u0089\13\13\3\f\3\f\3\r\3\r\5"+
-               
"\r\u008f\n\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\5\r\u009a\n\r\3\r\5\r"+
-               
"\u009d\n\r\3\16\5\16\u00a0\n\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17"+
-               
"\3\17\7\17\u00ab\n\17\f\17\16\17\u00ae\13\17\3\20\3\20\3\20\3\20\3\21"+
-               
"\3\21\3\21\3\21\3\21\3\21\3\21\3\21\5\21\u00bc\n\21\3\21\3\21\3\21\3\21"+
-               
"\3\21\3\21\7\21\u00c4\n\21\f\21\16\21\u00c7\13\21\3\22\3\22\3\22\3\23"+
-               
"\3\23\3\23\5\23\u00cf\n\23\3\23\3\23\3\24\3\24\3\24\5\24\u00d6\n\24\3"+
-               
"\24\5\24\u00d9\n\24\3\24\3\24\5\24\u00dd\n\24\3\25\3\25\3\26\3\26\5\26"+
-               
"\u00e3\n\26\3\27\3\27\3\30\3\30\3\30\3\30\3\30\3\30\3\30\2\5\24\34 \31"+
-               "\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 
\"$&(*,.\2\7\4\2\32\32##\6\2\n"+
-               "\21  $$&(\4\2\23\23  
\3\2\b\t\3\2$&\2\u00f6\2\60\3\2\2\2\4=\3\2\2\2\6"+
-               
"A\3\2\2\2\bE\3\2\2\2\nI\3\2\2\2\fZ\3\2\2\2\16\\\3\2\2\2\20o\3\2\2\2\22"+
-               
"~\3\2\2\2\24\u0080\3\2\2\2\26\u008a\3\2\2\2\30\u008c\3\2\2\2\32\u009f"+
-               "\3\2\2\2\34\u00a4\3\2\2\2\36\u00af\3\2\2\2 
\u00bb\3\2\2\2\"\u00c8\3\2"+
-               
"\2\2$\u00cb\3\2\2\2&\u00dc\3\2\2\2(\u00de\3\2\2\2*\u00e2\3\2\2\2,\u00e4"+
-               
"\3\2\2\2.\u00e6\3\2\2\2\60\62\5\4\3\2\61\63\5\6\4\2\62\61\3\2\2\2\62\63"+
-               
"\3\2\2\2\63\65\3\2\2\2\64\66\5\b\5\2\65\64\3\2\2\2\65\66\3\2\2\2\668\3"+
-               
"\2\2\2\679\5\n\6\28\67\3\2\2\289\3\2\2\29:\3\2\2\2:;\5\24\13\2;<\7\2\2"+
-               
"\3<\3\3\2\2\2=>\7\3\2\2>?\7#\2\2?@\7/\2\2@\5\3\2\2\2AB\7\4\2\2BC\7#\2"+
-               
"\2CD\7*\2\2D\7\3\2\2\2EF\7\5\2\2FG\7#\2\2GH\5(\25\2H\t\3\2\2\2IJ\7\6\2"+
-               
"\2JK\7#\2\2KL\5\f\7\2L\13\3\2\2\2MN\7\26\2\2NS\5\16\b\2OP\7\36\2\2PR\5"+
-               
"\16\b\2QO\3\2\2\2RU\3\2\2\2SQ\3\2\2\2ST\3\2\2\2TV\3\2\2\2US\3\2\2\2VW"+
-               
"\7\27\2\2W[\3\2\2\2XY\7\26\2\2Y[\7\27\2\2ZM\3\2\2\2ZX\3\2\2\2[\r\3\2\2"+
-               "\2\\]\5(\25\2]^\7\37\2\2^_\5\20\t\2_\17\3\2\2\2`p\5(\25\2ac\7 
\2\2ba\3"+
-               
"\2\2\2bc\3\2\2\2cd\3\2\2\2df\7,\2\2eg\7-\2\2fe\3\2\2\2fg\3\2\2\2gi\3\2"+
-               
"\2\2hj\7.\2\2ih\3\2\2\2ij\3\2\2\2jp\3\2\2\2kp\5\f\7\2lp\5\22\n\2mp\7*"+
-               
"\2\2np\7+\2\2o`\3\2\2\2ob\3\2\2\2ok\3\2\2\2ol\3\2\2\2om\3\2\2\2on\3\2"+
-               
"\2\2p\21\3\2\2\2qr\7\33\2\2rw\5\20\t\2st\7\36\2\2tv\5\20\t\2us\3\2\2\2"+
-               
"vy\3\2\2\2wu\3\2\2\2wx\3\2\2\2xz\3\2\2\2yw\3\2\2\2z{\7\34\2\2{\177\3\2"+
-               
"\2\2|}\7\33\2\2}\177\7\34\2\2~q\3\2\2\2~|\3\2\2\2\177\23\3\2\2\2\u0080"+
-               
"\u0081\b\13\1\2\u0081\u0082\5\30\r\2\u0082\u0087\3\2\2\2\u0083\u0084\f"+
-               
"\3\2\2\u0084\u0086\5\30\r\2\u0085\u0083\3\2\2\2\u0086\u0089\3\2\2\2\u0087"+
-               
"\u0085\3\2\2\2\u0087\u0088\3\2\2\2\u0088\25\3\2\2\2\u0089\u0087\3\2\2"+
-               
"\2\u008a\u008b\t\2\2\2\u008b\27\3\2\2\2\u008c\u008e\7\7\2\2\u008d\u008f"+
-               
"\5\36\20\2\u008e\u008d\3\2\2\2\u008e\u008f\3\2\2\2\u008f\u0090\3\2\2\2"+
-               "\u0090\u0099\5\26\f\2\u0091\u0092\7\26\2\2\u0092\u0093\5 
\21\2\u0093\u0094"+
-               
"\7\27\2\2\u0094\u009a\3\2\2\2\u0095\u0096\7\'\2\2\u0096\u0097\5\32\16"+
-               
"\2\u0097\u0098\7\'\2\2\u0098\u009a\3\2\2\2\u0099\u0091\3\2\2\2\u0099\u0095"+
-               
"\3\2\2\2\u009a\u009c\3\2\2\2\u009b\u009d\5*\26\2\u009c\u009b\3\2\2\2\u009c"+
-               
"\u009d\3\2\2\2\u009d\31\3\2\2\2\u009e\u00a0\5\34\17\2\u009f\u009e\3\2"+
-               
"\2\2\u009f\u00a0\3\2\2\2\u00a0\u00a1\3\2\2\2\u00a1\u00a2\7\35\2\2\u00a2"+
-               
"\u00a3\7/\2\2\u00a3\33\3\2\2\2\u00a4\u00a5\b\17\1\2\u00a5\u00a6\7/\2\2"+
-               
"\u00a6\u00ac\3\2\2\2\u00a7\u00a8\f\3\2\2\u00a8\u00a9\7!\2\2\u00a9\u00ab"+
-               
"\7/\2\2\u00aa\u00a7\3\2\2\2\u00ab\u00ae\3\2\2\2\u00ac\u00aa\3\2\2\2\u00ac"+
-               
"\u00ad\3\2\2\2\u00ad\35\3\2\2\2\u00ae\u00ac\3\2\2\2\u00af\u00b0\7\24\2"+
-               
"\2\u00b0\u00b1\7/\2\2\u00b1\u00b2\7\25\2\2\u00b2\37\3\2\2\2\u00b3\u00b4"+
-               
"\b\21\1\2\u00b4\u00bc\5\"\22\2\u00b5\u00bc\5&\24\2\u00b6\u00b7\7\24\2"+
-               "\2\u00b7\u00b8\5 
\21\2\u00b8\u00b9\7\25\2\2\u00b9\u00bc\3\2\2\2\u00ba"+
-               
"\u00bc\5$\23\2\u00bb\u00b3\3\2\2\2\u00bb\u00b5\3\2\2\2\u00bb\u00b6\3\2"+
-               
"\2\2\u00bb\u00ba\3\2\2\2\u00bc\u00c5\3\2\2\2\u00bd\u00be\f\7\2\2\u00be"+
-               "\u00bf\t\3\2\2\u00bf\u00c4\5 
\21\b\u00c0\u00c1\f\5\2\2\u00c1\u00c2\7\36"+
-               
"\2\2\u00c2\u00c4\5&\24\2\u00c3\u00bd\3\2\2\2\u00c3\u00c0\3\2\2\2\u00c4"+
-               
"\u00c7\3\2\2\2\u00c5\u00c3\3\2\2\2\u00c5\u00c6\3\2\2\2\u00c6!\3\2\2\2"+
-               "\u00c7\u00c5\3\2\2\2\u00c8\u00c9\t\4\2\2\u00c9\u00ca\5 
\21\2\u00ca#\3"+
-               "\2\2\2\u00cb\u00cc\7/\2\2\u00cc\u00ce\7\24\2\2\u00cd\u00cf\5 
\21\2\u00ce"+
-               
"\u00cd\3\2\2\2\u00ce\u00cf\3\2\2\2\u00cf\u00d0\3\2\2\2\u00d0\u00d1\7\25"+
-               
"\2\2\u00d1%\3\2\2\2\u00d2\u00dd\7+\2\2\u00d3\u00d5\7,\2\2\u00d4\u00d6"+
-               
"\7-\2\2\u00d5\u00d4\3\2\2\2\u00d5\u00d6\3\2\2\2\u00d6\u00d8\3\2\2\2\u00d7"+
-               
"\u00d9\7.\2\2\u00d8\u00d7\3\2\2\2\u00d8\u00d9\3\2\2\2\u00d9\u00dd\3\2"+
-               
"\2\2\u00da\u00dd\7*\2\2\u00db\u00dd\5(\25\2\u00dc\u00d2\3\2\2\2\u00dc"+
-               
"\u00d3\3\2\2\2\u00dc\u00da\3\2\2\2\u00dc\u00db\3\2\2\2\u00dd\'\3\2\2\2"+
-               
"\u00de\u00df\t\5\2\2\u00df)\3\2\2\2\u00e0\u00e3\5,\27\2\u00e1\u00e3\5"+
-               
".\30\2\u00e2\u00e0\3\2\2\2\u00e2\u00e1\3\2\2\2\u00e3+\3\2\2\2\u00e4\u00e5"+
-               
"\t\6\2\2\u00e5-\3\2\2\2\u00e6\u00e7\7\33\2\2\u00e7\u00e8\7,\2\2\u00e8"+
-               
"\u00e9\7\36\2\2\u00e9\u00ea\7,\2\2\u00ea\u00eb\7\34\2\2\u00eb/\3\2\2\2"+
-               
"\33\62\658SZbfiow~\u0087\u008e\u0099\u009c\u009f\u00ac\u00bb\u00c3\u00c5"+
-               "\u00ce\u00d5\u00d8\u00dc\u00e2";
+               
"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\3\2\3\2\5\2/\n\2\3\2\5\2\62\n"+
+               
"\2\3\2\5\2\65\n\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\5\3\5"+
+               
"\3\5\3\5\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\7\7N\n\7\f\7\16\7Q\13\7\3\7\3"+
+               
"\7\3\7\3\7\5\7W\n\7\3\b\3\b\3\b\3\b\3\t\3\t\5\t_\n\t\3\t\3\t\5\tc\n\t"+
+               
"\3\t\5\tf\n\t\3\t\3\t\3\t\3\t\5\tl\n\t\3\n\3\n\3\n\3\n\7\nr\n\n\f\n\16"+
+               
"\nu\13\n\3\n\3\n\3\n\3\n\5\n{\n\n\3\13\3\13\3\13\3\13\3\13\7\13\u0082"+
+               
"\n\13\f\13\16\13\u0085\13\13\3\f\3\f\3\r\3\r\5\r\u008b\n\r\3\r\3\r\3\r"+
+               
"\3\r\3\r\3\r\3\r\3\r\3\r\5\r\u0096\n\r\3\r\5\r\u0099\n\r\3\16\5\16\u009c"+
+               
"\n\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\7\17\u00a7\n\17\f\17"+
+               
"\16\17\u00aa\13\17\3\20\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3"+
+               
"\21\3\21\3\21\3\21\3\21\5\21\u00bb\n\21\3\21\5\21\u00be\n\21\3\21\3\21"+
+               
"\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21"+
+               
"\3\21\3\21\7\21\u00d2\n\21\f\21\16\21\u00d5\13\21\3\22\3\22\3\22\5\22"+
+               
"\u00da\n\22\3\22\5\22\u00dd\n\22\3\22\3\22\5\22\u00e1\n\22\3\23\3\23\3"+
+               
"\24\3\24\5\24\u00e7\n\24\3\25\3\25\3\26\3\26\3\26\3\26\3\26\3\26\3\26"+
+               "\2\5\24\34 \27\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 
\"$&(*\2\13\4\2"+
+               "\32\32##\4\2\23\23  \3\2&(\4\2  
$$\3\2\f\17\3\2\n\13\3\2\20\21\3\2\b\t"+
+               
"\3\2$&\2\u0100\2,\3\2\2\2\49\3\2\2\2\6=\3\2\2\2\bA\3\2\2\2\nE\3\2\2\2"+
+               
"\fV\3\2\2\2\16X\3\2\2\2\20k\3\2\2\2\22z\3\2\2\2\24|\3\2\2\2\26\u0086\3"+
+               
"\2\2\2\30\u0088\3\2\2\2\32\u009b\3\2\2\2\34\u00a0\3\2\2\2\36\u00ab\3\2"+
+               "\2\2 
\u00bd\3\2\2\2\"\u00e0\3\2\2\2$\u00e2\3\2\2\2&\u00e6\3\2\2\2(\u00e8"+
+               
"\3\2\2\2*\u00ea\3\2\2\2,.\5\4\3\2-/\5\6\4\2.-\3\2\2\2./\3\2\2\2/\61\3"+
+               
"\2\2\2\60\62\5\b\5\2\61\60\3\2\2\2\61\62\3\2\2\2\62\64\3\2\2\2\63\65\5"+
+               
"\n\6\2\64\63\3\2\2\2\64\65\3\2\2\2\65\66\3\2\2\2\66\67\5\24\13\2\678\7"+
+               
"\2\2\38\3\3\2\2\29:\7\3\2\2:;\7#\2\2;<\7/\2\2<\5\3\2\2\2=>\7\4\2\2>?\7"+
+               
"#\2\2?@\7*\2\2@\7\3\2\2\2AB\7\5\2\2BC\7#\2\2CD\5$\23\2D\t\3\2\2\2EF\7"+
+               
"\6\2\2FG\7#\2\2GH\5\f\7\2H\13\3\2\2\2IJ\7\26\2\2JO\5\16\b\2KL\7\36\2\2"+
+               
"LN\5\16\b\2MK\3\2\2\2NQ\3\2\2\2OM\3\2\2\2OP\3\2\2\2PR\3\2\2\2QO\3\2\2"+
+               
"\2RS\7\27\2\2SW\3\2\2\2TU\7\26\2\2UW\7\27\2\2VI\3\2\2\2VT\3\2\2\2W\r\3"+
+               
"\2\2\2XY\5$\23\2YZ\7\37\2\2Z[\5\20\t\2[\17\3\2\2\2\\l\5$\23\2]_\7 \2\2"+
+               
"^]\3\2\2\2^_\3\2\2\2_`\3\2\2\2`b\7,\2\2ac\7-\2\2ba\3\2\2\2bc\3\2\2\2c"+
+               
"e\3\2\2\2df\7.\2\2ed\3\2\2\2ef\3\2\2\2fl\3\2\2\2gl\5\f\7\2hl\5\22\n\2"+
+               
"il\7*\2\2jl\7+\2\2k\\\3\2\2\2k^\3\2\2\2kg\3\2\2\2kh\3\2\2\2ki\3\2\2\2"+
+               
"kj\3\2\2\2l\21\3\2\2\2mn\7\33\2\2ns\5\20\t\2op\7\36\2\2pr\5\20\t\2qo\3"+
+               
"\2\2\2ru\3\2\2\2sq\3\2\2\2st\3\2\2\2tv\3\2\2\2us\3\2\2\2vw\7\34\2\2w{"+
+               
"\3\2\2\2xy\7\33\2\2y{\7\34\2\2zm\3\2\2\2zx\3\2\2\2{\23\3\2\2\2|}\b\13"+
+               
"\1\2}~\5\30\r\2~\u0083\3\2\2\2\177\u0080\f\3\2\2\u0080\u0082\5\30\r\2"+
+               
"\u0081\177\3\2\2\2\u0082\u0085\3\2\2\2\u0083\u0081\3\2\2\2\u0083\u0084"+
+               
"\3\2\2\2\u0084\25\3\2\2\2\u0085\u0083\3\2\2\2\u0086\u0087\t\2\2\2\u0087"+
+               
"\27\3\2\2\2\u0088\u008a\7\7\2\2\u0089\u008b\5\36\20\2\u008a\u0089\3\2"+
+               
"\2\2\u008a\u008b\3\2\2\2\u008b\u008c\3\2\2\2\u008c\u0095\5\26\f\2\u008d"+
+               "\u008e\7\26\2\2\u008e\u008f\5 
\21\2\u008f\u0090\7\27\2\2\u0090\u0096\3"+
+               
"\2\2\2\u0091\u0092\7\'\2\2\u0092\u0093\5\32\16\2\u0093\u0094\7\'\2\2\u0094"+
+               
"\u0096\3\2\2\2\u0095\u008d\3\2\2\2\u0095\u0091\3\2\2\2\u0096\u0098\3\2"+
+               
"\2\2\u0097\u0099\5&\24\2\u0098\u0097\3\2\2\2\u0098\u0099\3\2\2\2\u0099"+
+               
"\31\3\2\2\2\u009a\u009c\5\34\17\2\u009b\u009a\3\2\2\2\u009b\u009c\3\2"+
+               
"\2\2\u009c\u009d\3\2\2\2\u009d\u009e\7\35\2\2\u009e\u009f\7/\2\2\u009f"+
+               
"\33\3\2\2\2\u00a0\u00a1\b\17\1\2\u00a1\u00a2\7/\2\2\u00a2\u00a8\3\2\2"+
+               
"\2\u00a3\u00a4\f\3\2\2\u00a4\u00a5\7!\2\2\u00a5\u00a7\7/\2\2\u00a6\u00a3"+
+               
"\3\2\2\2\u00a7\u00aa\3\2\2\2\u00a8\u00a6\3\2\2\2\u00a8\u00a9\3\2\2\2\u00a9"+
+               
"\35\3\2\2\2\u00aa\u00a8\3\2\2\2\u00ab\u00ac\7\24\2\2\u00ac\u00ad\7/\2"+
+               
"\2\u00ad\u00ae\7\25\2\2\u00ae\37\3\2\2\2\u00af\u00b0\b\21\1\2\u00b0\u00b1"+
+               "\t\3\2\2\u00b1\u00be\5 
\21\f\u00b2\u00b3\7\24\2\2\u00b3\u00b4\5 \21\2"+
+               
"\u00b4\u00b5\7\25\2\2\u00b5\u00be\3\2\2\2\u00b6\u00be\5\"\22\2\u00b7\u00b8"+
+               "\7/\2\2\u00b8\u00ba\7\24\2\2\u00b9\u00bb\5 
\21\2\u00ba\u00b9\3\2\2\2\u00ba"+
+               
"\u00bb\3\2\2\2\u00bb\u00bc\3\2\2\2\u00bc\u00be\7\25\2\2\u00bd\u00af\3"+
+               
"\2\2\2\u00bd\u00b2\3\2\2\2\u00bd\u00b6\3\2\2\2\u00bd\u00b7\3\2\2\2\u00be"+
+               
"\u00d3\3\2\2\2\u00bf\u00c0\f\n\2\2\u00c0\u00c1\t\4\2\2\u00c1\u00d2\5 "+
+               "\21\13\u00c2\u00c3\f\t\2\2\u00c3\u00c4\t\5\2\2\u00c4\u00d2\5 
\21\n\u00c5"+
+               "\u00c6\f\b\2\2\u00c6\u00c7\t\6\2\2\u00c7\u00d2\5 
\21\t\u00c8\u00c9\f\7"+
+               "\2\2\u00c9\u00ca\t\7\2\2\u00ca\u00d2\5 
\21\b\u00cb\u00cc\f\6\2\2\u00cc"+
+               "\u00cd\t\b\2\2\u00cd\u00d2\5 
\21\7\u00ce\u00cf\f\4\2\2\u00cf\u00d0\7\36"+
+               
"\2\2\u00d0\u00d2\5\"\22\2\u00d1\u00bf\3\2\2\2\u00d1\u00c2\3\2\2\2\u00d1"+
+               
"\u00c5\3\2\2\2\u00d1\u00c8\3\2\2\2\u00d1\u00cb\3\2\2\2\u00d1\u00ce\3\2"+
+               
"\2\2\u00d2\u00d5\3\2\2\2\u00d3\u00d1\3\2\2\2\u00d3\u00d4\3\2\2\2\u00d4"+
+               
"!\3\2\2\2\u00d5\u00d3\3\2\2\2\u00d6\u00e1\7+\2\2\u00d7\u00d9\7,\2\2\u00d8"+
+               
"\u00da\7-\2\2\u00d9\u00d8\3\2\2\2\u00d9\u00da\3\2\2\2\u00da\u00dc\3\2"+
+               
"\2\2\u00db\u00dd\7.\2\2\u00dc\u00db\3\2\2\2\u00dc\u00dd\3\2\2\2\u00dd"+
+               
"\u00e1\3\2\2\2\u00de\u00e1\7*\2\2\u00df\u00e1\5$\23\2\u00e0\u00d6\3\2"+
+               
"\2\2\u00e0\u00d7\3\2\2\2\u00e0\u00de\3\2\2\2\u00e0\u00df\3\2\2\2\u00e1"+
+               
"#\3\2\2\2\u00e2\u00e3\t\t\2\2\u00e3%\3\2\2\2\u00e4\u00e7\5(\25\2\u00e5"+
+               
"\u00e7\5*\26\2\u00e6\u00e4\3\2\2\2\u00e6\u00e5\3\2\2\2\u00e7\'\3\2\2\2"+
+               
"\u00e8\u00e9\t\n\2\2\u00e9)\3\2\2\2\u00ea\u00eb\7\33\2\2\u00eb\u00ec\7"+
+               
",\2\2\u00ec\u00ed\7\36\2\2\u00ed\u00ee\7,\2\2\u00ee\u00ef\7\34\2\2\u00ef"+
+               
"+\3\2\2\2\33.\61\64OV^beksz\u0083\u008a\u0095\u0098\u009b\u00a8\u00ba"+
+               "\u00bd\u00d1\u00d3\u00d9\u00dc\u00e0\u00e6";
        public static final ATN _ATN =
                new ATNDeserializer().deserialize(_serializedATN.toCharArray());
        static {
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/ver2/NCIntentDslCompiler.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/ver2/NCIntentDslCompiler.scala
index b7c7312..d2fa4ee 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/ver2/NCIntentDslCompiler.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/ver2/NCIntentDslCompiler.scala
@@ -30,7 +30,9 @@ import scala.collection.immutable.HashMap
 import scala.collection.mutable
 import scala.collection.mutable.ArrayBuffer
 import java.lang.{Double ⇒ JDouble, IllegalArgumentException ⇒ IAE, Long ⇒ 
JLong}
-import java.util.{List ⇒ JList, Map ⇒ JMap}
+import java.util.{List ⇒ JList}
+
+import scala.language.implicitConversions
 
 object NCIntentDslCompiler extends LazyLogging {
     // Compiler cache.
@@ -72,6 +74,25 @@ object NCIntentDslCompiler extends LazyLogging {
         private def asJList(v: AnyRef): JList[AnyRef] = 
v.asInstanceOf[JList[AnyRef]]
         private def isJList(v: AnyRef): Boolean = v.isInstanceOf[JList[AnyRef]]
 
+        private def pushAny(any: AnyRef, usedTok: Boolean)(implicit stack: 
StackType): Unit =
+            stack.push(NCDslTermRetVal(any, usedTok))
+        private def pushLong(any: Long, usedTok: Boolean)(implicit stack: 
StackType): Unit =
+            stack.push(NCDslTermRetVal(Long.box(any), usedTok))
+        private def pushDouble(any: Double, usedTok: Boolean)(implicit stack: 
StackType): Unit =
+            stack.push(NCDslTermRetVal(Double.box(any), usedTok))
+        private def pushBoolean(any: Boolean, usedTok: Boolean)(implicit 
stack: StackType): Unit =
+            stack.push(NCDslTermRetVal(Boolean.box(any), usedTok))
+
+        private def errBinaryOp(op: String, val1: AnyRef, val2: AnyRef): Unit =
+            throw new IAE(s"Unexpected '$op' operation for values: $val1, 
$val2")
+        private def errUnknownFun(fun: String): Unit =
+            throw new IAE(s"Unknown built-in function: $fun")
+        private def errParamNum(fun: String): Unit =
+            throw new IAE(s"Invalid number of parameters for built-in 
function: $fun")
+        private def errParamType(fun: String): Unit =
+            throw new IAE(s"Invalid parameter type for built-in function: 
$fun")
+
+
         /**
          *
          * @param min
@@ -93,164 +114,190 @@ object NCIntentDslCompiler extends LazyLogging {
                 assert(false)
         }
 
-        //noinspection TypeCheckCanBeMatch
-        override def exitExpr(ctx: NCIntentDslParser.ExprContext): Unit = {
-            if (ctx.atom() != null) {} // Just a val - no-op.
-            else if (ctx.LPAR() != null && ctx.RPAR() != null) {} // Just a 
val in brackets - no-op.
-            else if (ctx.COMMA() != null) { // Collection.
-                termCode += ((_, stack: StackType, _) ⇒ {
-                    require(stack.nonEmpty)
+        /**
+         *
+         * @param stack
+         * @return
+         */
+        private def pop2()(implicit stack: StackType): (AnyRef, AnyRef, 
Boolean) = {
+            // Stack pop in reverse order of push...
+            val NCDslTermRetVal(val2, f1) = stack.pop()
+            val NCDslTermRetVal(val1, f2) = stack.pop()
 
-                    val NCDslTermRetVal(lastVal, usedTok) = stack.pop()
+            (val1, val2, f1 || f2)
+        }
 
-                    // Only use Java collections.
-                    val newVal: AnyRef =
-                        if (lastVal.isInstanceOf[JList[Object]]) {
-                            val x = lastVal.asInstanceOf[JList[Object]]
+        override def exitListExpr(ctx: NCIntentDslParser.ListExprContext): 
Unit = {
+            termCode += ((_, stack: StackType, _) ⇒ {
+                require(stack.nonEmpty)
 
-                            x.add(mkVal(ctx.atom().getText))
+                val NCDslTermRetVal(lastVal, usedTok) = stack.pop()
 
-                            x
-                        }
-                        else
-                            java.util.Collections.singletonList(lastVal)
+                // Only use Java collections.
+                val newVal: AnyRef = lastVal match {
+                    case x: JList[Object] ⇒ x.add(mkVal(ctx.atom().getText)); x
+                    case _ ⇒ java.util.Collections.singletonList(lastVal)
+                }
 
-                    stack.push(NCDslTermRetVal(newVal, usedTok))
-                })
-            }
-            else if (ctx.MINUS() != null || ctx.PLUS() != null || ctx.MULT() 
!= null || ctx.DIV() != null || ctx.MOD() != null) {
-                termCode += ((_, stack: StackType, _) ⇒ {
-                    require(stack.size >= 2)
-
-                    // Stack pop in reverse order of push...
-                    val NCDslTermRetVal(val2, f1) = stack.pop()
-                    val NCDslTermRetVal(val1, f2) = stack.pop()
-
-                    val usedTok = f1 || f2
-                    
-                    def push(any: AnyRef): Unit = 
stack.push(NCDslTermRetVal(any, usedTok))
-                    def pushLong(any: Long): Unit = 
stack.push(NCDslTermRetVal(Long.box(any), usedTok))
-                    def pushDouble(any: Double): Unit = 
stack.push(NCDslTermRetVal(Double.box(any), usedTok))
-
-                    def error(op: String): Unit = throw new IAE(s"Unexpected 
'$op' operation for values: $val1, $val2")
-                    
-                    if (ctx.PLUS() != null) { // '+'.
-                        if (isJList(val1) && isJList(val2)) {
-                            val lst1 = asJList(val1)
-                            val lst2 = asJList(val2)
-    
-                            lst1.addAll(lst2)
-                            
-                            push(lst1)
-                        }
-                        else if (isJList(val1)) {
-                            val lst1 = asJList(val1)
-                            
-                            lst1.add(val2)
-                            
-                            push(lst1)
-                        }
-                        else if (isJList(val2)) {
-                            val lst2 = asJList(val2)
-    
-                            lst2.add(val1)
-    
-                            push(lst2)
-                        }
-                        else if (isString(val1) && isString(val2))
-                            push(asString(val1) + asString(val2))
-                        else if (isJLong(val1) && isJLong(val2))
-                            pushLong(asJLong(val1).longValue() + 
asJLong(val2).longValue())
-                        else if (isJLong(val1) && isJDouble(val2))
-                            pushDouble(asJLong(val1).longValue() + 
asJDouble(val2).doubleValue())
-                        else if (isJDouble(val1) && isJLong(val2))
-                            pushDouble(asJDouble(val1).doubleValue() + 
asJLong(val2).longValue())
-                        else if (isJDouble(val1) && isJDouble(val2))
-                            pushDouble(asJDouble(val1).doubleValue() + 
asJDouble(val2).doubleValue())
-                        else
-                            error("+")
+                pushAny(newVal, usedTok)(stack)
+            })
+        }
+
+
+        override def exitUnaryExpr(ctx: NCIntentDslParser.UnaryExprContext): 
Unit = {
+            termCode += ((_, stack: StackType, _) ⇒ {
+
+            })
+        }
+
+        override def exitMultExpr(ctx: NCIntentDslParser.MultExprContext): 
Unit = {
+            termCode += ((_, stack: StackType, _) ⇒ {
+                require(stack.size >= 2)
+
+                implicit val s = stack
+
+                val (val1, val2, usedTok) = pop2()
+
+                if (ctx.MULT() != null) {
+                    if (isJLong(val1) && isJLong(val2))
+                        pushLong(asJLong(val1).longValue() * 
asJLong(val2).longValue(), usedTok)
+                    else if (isJLong(val1) && isJDouble(val2))
+                        pushDouble(asJLong(val1).longValue() * 
asJDouble(val2).doubleValue(), usedTok)
+                    else if (isJDouble(val1) && isJLong(val2))
+                        pushDouble(asJDouble(val1).doubleValue() * 
asJLong(val2).longValue(), usedTok)
+                    else if (isJDouble(val1) && isJDouble(val2))
+                        pushDouble(asJDouble(val1).doubleValue() * 
asJDouble(val2).doubleValue(), usedTok)
+                    else
+                        errBinaryOp("*", val1, val2)
+                }
+                else if (ctx.MOD() != null) {
+                    if (isJLong(val1) && isJLong(val2))
+                        pushLong(asJLong(val1).longValue() % 
asJLong(val2).longValue(), usedTok)
+                    else
+                        errBinaryOp("%", val1, val2)
+                }
+                else {
+                    assert(ctx.DIV() != null)
+
+                    if (isJLong(val1) && isJLong(val2))
+                        pushLong(asJLong(val1).longValue() / 
asJLong(val2).longValue(), usedTok)
+                    else if (isJLong(val1) && isJDouble(val2))
+                        pushDouble(asJLong(val1).longValue() / 
asJDouble(val2).doubleValue(), usedTok)
+                    else if (isJDouble(val1) && isJLong(val2))
+                        pushDouble(asJDouble(val1).doubleValue() / 
asJLong(val2).longValue(), usedTok)
+                    else if (isJDouble(val1) && isJDouble(val2))
+                        pushDouble(asJDouble(val1).doubleValue() / 
asJDouble(val2).doubleValue(), usedTok)
+                    else
+                        errBinaryOp("/", val1, val2)
+                }
+            })
+        }
+
+        override def exitPlusExpr(ctx: NCIntentDslParser.PlusExprContext): 
Unit = {
+            termCode += ((_, stack: StackType, _) ⇒ {
+                require(stack.size >= 2)
+
+                implicit val s = stack
+
+                val (val1, val2, usedTok) = pop2()
+
+                if (ctx.PLUS() != null) {
+                    if (isJList(val1) && isJList(val2)) {
+                        val lst1 = asJList(val1)
+                        val lst2 = asJList(val2)
+
+                        lst1.addAll(lst2)
+
+                        pushAny(lst1, usedTok)
                     }
-                    else if (ctx.MINUS() != null) { // '-'.
-                        if (isJList(val1) && isJList(val2)) {
-                            val lst1 = asJList(val1)
-                            val lst2 = asJList(val2)
-                            
-                            lst1.removeAll(lst2)
-
-                            push(lst1)
-                        }
-                        else if (isJList(val1)) {
-                            val lst1 = asJList(val1)
-                            
-                            lst1.remove(val2)
-                            
-                            push(lst1)
-                        }
-                        else if (isJLong(val1) && isJLong(val2))
-                            pushLong(asJLong(val1).longValue() - 
asJLong(val2).longValue())
-                        else if (isJLong(val1) && isJDouble(val2))
-                            pushDouble(asJLong(val1).longValue() - 
asJDouble(val2).doubleValue())
-                        else if (isJDouble(val1) && isJLong(val2))
-                            pushDouble(asJDouble(val1).doubleValue() - 
asJLong(val2).longValue())
-                        else if (isJDouble(val1) && isJDouble(val2))
-                            pushDouble(asJDouble(val1).doubleValue() - 
asJDouble(val2).doubleValue())
-                        else
-                            error("-")
+                    else if (isJList(val1)) {
+                        val lst1 = asJList(val1)
+
+                        lst1.add(val2)
+
+                        pushAny(lst1, usedTok)
                     }
-                    else if (ctx.MULT() != null) { // '*'.
-                        if (isJLong(val1) && isJLong(val2))
-                            pushLong(asJLong(val1).longValue() * 
asJLong(val2).longValue())
-                        else if (isJLong(val1) && isJDouble(val2))
-                            pushDouble(asJLong(val1).longValue() * 
asJDouble(val2).doubleValue())
-                        else if (isJDouble(val1) && isJLong(val2))
-                            pushDouble(asJDouble(val1).doubleValue() * 
asJLong(val2).longValue())
-                        else if (isJDouble(val1) && isJDouble(val2))
-                            pushDouble(asJDouble(val1).doubleValue() * 
asJDouble(val2).doubleValue())
-                        else
-                            error("*")
+                    else if (isJList(val2)) {
+                        val lst2 = asJList(val2)
+
+                        lst2.add(val1)
+
+                        pushAny(lst2, usedTok)
                     }
-                    else if (ctx.DIV() != null) { // '/'.
-                        if (isJLong(val1) && isJLong(val2))
-                            pushLong(asJLong(val1).longValue() / 
asJLong(val2).longValue())
-                        else if (isJLong(val1) && isJDouble(val2))
-                            pushDouble(asJLong(val1).longValue() / 
asJDouble(val2).doubleValue())
-                        else if (isJDouble(val1) && isJLong(val2))
-                            pushDouble(asJDouble(val1).doubleValue() / 
asJLong(val2).longValue())
-                        else if (isJDouble(val1) && isJDouble(val2))
-                            pushDouble(asJDouble(val1).doubleValue() / 
asJDouble(val2).doubleValue())
-                        else
-                            error("/")
+                    else if (isString(val1) && isString(val2))
+                        pushAny(asString(val1) + asString(val2), usedTok)
+                    else if (isJLong(val1) && isJLong(val2))
+                        pushLong(asJLong(val1).longValue() + 
asJLong(val2).longValue(), usedTok)
+                    else if (isJLong(val1) && isJDouble(val2))
+                        pushDouble(asJLong(val1).longValue() + 
asJDouble(val2).doubleValue(), usedTok)
+                    else if (isJDouble(val1) && isJLong(val2))
+                        pushDouble(asJDouble(val1).doubleValue() + 
asJLong(val2).longValue(), usedTok)
+                    else if (isJDouble(val1) && isJDouble(val2))
+                        pushDouble(asJDouble(val1).doubleValue() + 
asJDouble(val2).doubleValue(), usedTok)
+                    else
+                        errBinaryOp("+", val1, val2)
+                }
+                else {
+                    assert(ctx.MINUS() != null)
+
+                    if (isJList(val1) && isJList(val2)) {
+                        val lst1 = asJList(val1)
+                        val lst2 = asJList(val2)
+
+                        lst1.removeAll(lst2)
+
+                        pushAny(lst1, usedTok)
                     }
-                    else if (ctx.MOD() != null) { // '%'.
-                        if (isJLong(val1) && isJLong(val2))
-                            pushLong(asJLong(val1).longValue() % 
asJLong(val2).longValue())
-                        else
-                            error("%")
+                    else if (isJList(val1)) {
+                        val lst1 = asJList(val1)
+
+                        lst1.remove(val2)
+
+                        pushAny(lst1, usedTok)
                     }
+                    else if (isJLong(val1) && isJLong(val2))
+                        pushLong(asJLong(val1).longValue() - 
asJLong(val2).longValue(), usedTok)
+                    else if (isJLong(val1) && isJDouble(val2))
+                        pushDouble(asJLong(val1).longValue() - 
asJDouble(val2).doubleValue(), usedTok)
+                    else if (isJDouble(val1) && isJLong(val2))
+                        pushDouble(asJDouble(val1).doubleValue() - 
asJLong(val2).longValue(), usedTok)
+                    else if (isJDouble(val1) && isJDouble(val2))
+                        pushDouble(asJDouble(val1).doubleValue() - 
asJDouble(val2).doubleValue(), usedTok)
                     else
-                        assert(false)
-                })
-            }
+                        errBinaryOp("-", val1, val2)
+                }
+            })
+        }
+
+        override def exitCompExpr(ctx: NCIntentDslParser.CompExprContext): 
Unit = {
+            termCode += ((_, stack: StackType, _) ⇒ {
+            })
         }
 
-        override def exitCall(ctx: NCIntentDslParser.CallContext): Unit = {
+        override def exitLogExpr(ctx: NCIntentDslParser.LogExprContext): Unit 
= {
+            termCode += ((_, stack: StackType, _) ⇒ {
+
+            })
+
+        }
+
+        override def exitEqExpr(ctx: NCIntentDslParser.EqExprContext): Unit = {
+            termCode += ((_, stack: StackType, _) ⇒ {
+
+            })
+        }
+
+        override def exitCallExpr(ctx: NCIntentDslParser.CallExprContext): 
Unit = {
             val fun = ctx.ID().getText
 
             termCode += ((tok: NCToken, stack: StackType, ctx: 
NCDslTermContext) ⇒ {
-                val NCDslTermRetVal(param, usedTok) = if (stack.nonEmpty) 
stack.pop else (null, false)
+                implicit val s = stack
 
-                def push(any: AnyRef, f: Boolean): Unit = 
stack.push(NCDslTermRetVal(any, f))
-                def pushLong(any: Long, f: Boolean): Unit = 
stack.push(NCDslTermRetVal(Long.box(any), f))
-                def pushDouble(any: Double, f: Boolean): Unit = 
stack.push(NCDslTermRetVal(Double.box(any), f))
-                def pushBoolean(any: Boolean, f: Boolean): Unit = 
stack.push(NCDslTermRetVal(Boolean.box(any), f))
-
-                def unknownFun(): Unit = throw new IAE(s"Unknown built-in 
function: $fun")
-                def errParamNum(): Unit = throw new IAE(s"Invalid number of 
parameters for built-in function: $fun")
-                def errParamType(): Unit = throw new IAE(s"Invalid parameter 
type for built-in function: $fun")
+                val NCDslTermRetVal(param, usedTok) = if (stack.nonEmpty) 
stack.pop else (null, false)
 
-                def check1String(): Unit = if (param == null) errParamNum() 
else if (!isString(param)) errParamType()
-                def check1Long(): Unit = if (param == null) errParamNum() else 
if (!isJLong(param)) errParamType()
-                def check1Double(): Unit = if (param == null) errParamNum() 
else if (!isJDouble(param)) errParamType()
+                def check1String(): Unit = if (param == null) errParamNum(fun) 
else if (!isString(param)) errParamType(fun)
+                def check1Long(): Unit = if (param == null) errParamNum(fun) 
else if (!isJLong(param)) errParamType(fun)
+                def check1Double(): Unit = if (param == null) errParamNum(fun) 
else if (!isJDouble(param)) errParamType(fun)
 
                 def doTrim(): String = { check1String(); 
asString(param).strip() }
                 def doUppercase(): String = { check1String(); 
asString(param).toUpperCase() }
@@ -274,20 +321,20 @@ object NCIntentDslCompiler extends LazyLogging {
                     case "if" ⇒
 
                     // Token functions.
-                    case "id" ⇒ push(tok.getId, true)
-                    case "ancestors" ⇒ push(tok.getAncestors, true)
-                    case "parent" ⇒ push(tok.getParentId, true)
-                    case "groups" ⇒ push(tok.getGroups, true)
-                    case "value" ⇒ push(tok.getValue, true)
-                    case "aliases" ⇒ push(tok.getAliases, true)
+                    case "id" ⇒ pushAny(tok.getId, true)
+                    case "ancestors" ⇒ pushAny(tok.getAncestors, true)
+                    case "parent" ⇒ pushAny(tok.getParentId, true)
+                    case "groups" ⇒ pushAny(tok.getGroups, true)
+                    case "value" ⇒ pushAny(tok.getValue, true)
+                    case "aliases" ⇒ pushAny(tok.getAliases, true)
                     case "start_idx" ⇒ pushLong(tok.getStartCharIndex, true)
                     case "end_idx" ⇒ pushLong(tok.getEndCharIndex, true)
 
                     // String functions.
-                    case "trim" ⇒ push(doTrim(), usedTok)
-                    case "strip" ⇒ push(doTrim(), usedTok)
-                    case "uppercase" ⇒ push(doUppercase(), usedTok)
-                    case "lowercase" ⇒ push(doLowercase(), usedTok)
+                    case "trim" ⇒ pushAny(doTrim(), usedTok)
+                    case "strip" ⇒ pushAny(doTrim(), usedTok)
+                    case "uppercase" ⇒ pushAny(doUppercase(), usedTok)
+                    case "lowercase" ⇒ pushAny(doLowercase(), usedTok)
                     case "is_alpha" ⇒ pushBoolean(doIsAlpha(), usedTok)
                     case "is_alphanum" ⇒ pushBoolean(doIsAlphaNum(), usedTok)
                     case "is_whitespace" ⇒ pushBoolean(doIsWhitespace(), 
usedTok)
@@ -364,7 +411,7 @@ object NCIntentDslCompiler extends LazyLogging {
                     case "msec" ⇒
                     case "now" ⇒
 
-                    case _ ⇒ unknownFun()
+                    case _ ⇒ errUnknownFun(fun)
                 }
             })
         }
@@ -407,7 +454,7 @@ object NCIntentDslCompiler extends LazyLogging {
         }
 
         override def exitAtom(ctx: NCIntentDslParser.AtomContext): Unit = {
-            termCode += ((_, stack, _) ⇒ 
stack.push(NCDslTermRetVal(mkVal(ctx.getText), usedTok = false)))
+            termCode += ((_, stack, _) ⇒ pushAny(mkVal(ctx.getText), 
false)(stack))
         }
 
         /**

Reply via email to