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 fc9fc0e WIP.
fc9fc0e is described below
commit fc9fc0eb8d49e79ef61ded513ac75be5a418bfd7
Author: Aaron Radzinski <[email protected]>
AuthorDate: Sat Feb 13 21:45:39 2021 -0800
WIP.
---
.../model/intent/impl/antlr4/NCIntentDsl.g4 | 7 +-
.../model/intent/impl/antlr4/NCIntentDsl.interp | 3 +-
.../impl/antlr4/NCIntentDslBaseListener.java | 12 +-
.../intent/impl/antlr4/NCIntentDslListener.java | 22 +-
.../intent/impl/antlr4/NCIntentDslParser.java | 609 ++++++++++++---------
.../intent/impl/ver2/NCIntentDslCompiler.scala | 250 +++++----
6 files changed, 508 insertions(+), 395 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 fd965b4..cba5303 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
@@ -61,8 +61,11 @@ expr
| expr op=(EQ | NEQ) expr # eqExpr
| expr op=(AND | OR) expr # logExpr
| atom # atomExpr
- | ID LPAR expr? RPAR # callExpr
- | expr COMMA expr # listExpr
+ | ID LPAR paramList? RPAR # callExpr
+ ;
+paramList
+ : expr
+ | paramList COMMA expr
;
atom
: NULL
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 1eb286b..98c1576 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,6 +115,7 @@ clsNer
javaFqn
termId
expr
+paramList
atom
qstring
minMax
@@ -123,4 +124,4 @@ minMaxRange
atn:
-[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
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 49, 251, 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, 3, 2, 3, 2, 5, 2, 49, 10,
2, 3, 2, 5, 2, 52, 10, 2, 3, 2, 5, 2, 55, 10, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3,
3, 3, 3, 3, 3, 4, 3, 4, [...]
\ 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 6007b7f..2b2eb5a 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
@@ -280,37 +280,37 @@ public class NCIntentDslBaseListener implements
NCIntentDslListener {
*
* <p>The default implementation does nothing.</p>
*/
- @Override public void enterListExpr(NCIntentDslParser.ListExprContext
ctx) { }
+ @Override public void enterPlusExpr(NCIntentDslParser.PlusExprContext
ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
- @Override public void exitListExpr(NCIntentDslParser.ListExprContext
ctx) { }
+ @Override public void exitPlusExpr(NCIntentDslParser.PlusExprContext
ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
- @Override public void enterPlusExpr(NCIntentDslParser.PlusExprContext
ctx) { }
+ @Override public void enterLogExpr(NCIntentDslParser.LogExprContext
ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
- @Override public void exitPlusExpr(NCIntentDslParser.PlusExprContext
ctx) { }
+ @Override public void exitLogExpr(NCIntentDslParser.LogExprContext ctx)
{ }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
- @Override public void enterLogExpr(NCIntentDslParser.LogExprContext
ctx) { }
+ @Override public void enterParamList(NCIntentDslParser.ParamListContext
ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
- @Override public void exitLogExpr(NCIntentDslParser.LogExprContext ctx)
{ }
+ @Override public void exitParamList(NCIntentDslParser.ParamListContext
ctx) { }
/**
* {@inheritDoc}
*
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 5778c43..6100002 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
@@ -242,18 +242,6 @@ public interface NCIntentDslListener extends
ParseTreeListener {
*/
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
@@ -278,6 +266,16 @@ public interface NCIntentDslListener extends
ParseTreeListener {
*/
void exitLogExpr(NCIntentDslParser.LogExprContext ctx);
/**
+ * Enter a parse tree produced by {@link NCIntentDslParser#paramList}.
+ * @param ctx the parse tree
+ */
+ void enterParamList(NCIntentDslParser.ParamListContext ctx);
+ /**
+ * Exit a parse tree produced by {@link NCIntentDslParser#paramList}.
+ * @param ctx the parse tree
+ */
+ void exitParamList(NCIntentDslParser.ParamListContext 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 5cba0cc..308c8bd 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
@@ -27,14 +27,15 @@ 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_atom
= 16, RULE_qstring = 17,
- RULE_minMax = 18, RULE_minMaxShortcut = 19, RULE_minMaxRange =
20;
+ RULE_javaFqn = 13, RULE_termId = 14, RULE_expr = 15,
RULE_paramList = 16,
+ RULE_atom = 17, RULE_qstring = 18, RULE_minMax = 19,
RULE_minMaxShortcut = 20,
+ RULE_minMaxRange = 21;
private static String[] makeRuleNames() {
return new String[] {
"intent", "intentId", "orderedDecl", "flowDecl",
"metaDecl", "jsonObj",
"jsonPair", "jsonVal", "jsonArr", "terms", "termEq",
"term", "clsNer",
- "javaFqn", "termId", "expr", "atom", "qstring",
"minMax", "minMaxShortcut",
- "minMaxRange"
+ "javaFqn", "termId", "expr", "paramList", "atom",
"qstring", "minMax",
+ "minMaxShortcut", "minMaxRange"
};
}
public static final String[] ruleNames = makeRuleNames();
@@ -148,41 +149,41 @@ public class NCIntentDslParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(42);
- intentId();
setState(44);
+ intentId();
+ setState(46);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==T__1) {
{
- setState(43);
+ setState(45);
orderedDecl();
}
}
- setState(47);
+ setState(49);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==T__2) {
{
- setState(46);
+ setState(48);
flowDecl();
}
}
- setState(50);
+ setState(52);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==T__3) {
{
- setState(49);
+ setState(51);
metaDecl();
}
}
- setState(52);
+ setState(54);
terms(0);
- setState(53);
+ setState(55);
match(EOF);
}
}
@@ -220,11 +221,11 @@ public class NCIntentDslParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(55);
+ setState(57);
match(T__0);
- setState(56);
+ setState(58);
match(ASSIGN);
- setState(57);
+ setState(59);
match(ID);
}
}
@@ -262,11 +263,11 @@ public class NCIntentDslParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(59);
+ setState(61);
match(T__1);
- setState(60);
+ setState(62);
match(ASSIGN);
- setState(61);
+ setState(63);
match(BOOL);
}
}
@@ -306,11 +307,11 @@ public class NCIntentDslParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(63);
+ setState(65);
match(T__2);
- setState(64);
+ setState(66);
match(ASSIGN);
- setState(65);
+ setState(67);
qstring();
}
}
@@ -350,11 +351,11 @@ public class NCIntentDslParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(67);
+ setState(69);
match(T__3);
- setState(68);
+ setState(70);
match(ASSIGN);
- setState(69);
+ setState(71);
jsonObj();
}
}
@@ -401,42 +402,42 @@ public class NCIntentDslParser extends Parser {
enterRule(_localctx, 10, RULE_jsonObj);
int _la;
try {
- setState(84);
+ setState(86);
_errHandler.sync(this);
switch (
getInterpreter().adaptivePredict(_input,4,_ctx) ) {
case 1:
enterOuterAlt(_localctx, 1);
{
- setState(71);
+ setState(73);
match(LBRACE);
- setState(72);
+ setState(74);
jsonPair();
- setState(77);
+ setState(79);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==COMMA) {
{
{
- setState(73);
+ setState(75);
match(COMMA);
- setState(74);
+ setState(76);
jsonPair();
}
}
- setState(79);
+ setState(81);
_errHandler.sync(this);
_la = _input.LA(1);
}
- setState(80);
+ setState(82);
match(RBRACE);
}
break;
case 2:
enterOuterAlt(_localctx, 2);
{
- setState(82);
+ setState(84);
match(LBRACE);
- setState(83);
+ setState(85);
match(RBRACE);
}
break;
@@ -481,11 +482,11 @@ public class NCIntentDslParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(86);
+ setState(88);
qstring();
- setState(87);
+ setState(89);
match(COLON);
- setState(88);
+ setState(90);
jsonVal();
}
}
@@ -535,14 +536,14 @@ public class NCIntentDslParser extends Parser {
enterRule(_localctx, 14, RULE_jsonVal);
int _la;
try {
- setState(105);
+ setState(107);
_errHandler.sync(this);
switch (_input.LA(1)) {
case SQSTRING:
case DQSTRING:
enterOuterAlt(_localctx, 1);
{
- setState(90);
+ setState(92);
qstring();
}
break;
@@ -550,34 +551,34 @@ public class NCIntentDslParser extends Parser {
case INT:
enterOuterAlt(_localctx, 2);
{
- setState(92);
+ setState(94);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==MINUS) {
{
- setState(91);
+ setState(93);
match(MINUS);
}
}
- setState(94);
- match(INT);
setState(96);
+ match(INT);
+ setState(98);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==REAL) {
{
- setState(95);
+ setState(97);
match(REAL);
}
}
- setState(99);
+ setState(101);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==EXP) {
{
- setState(98);
+ setState(100);
match(EXP);
}
}
@@ -587,28 +588,28 @@ public class NCIntentDslParser extends Parser {
case LBRACE:
enterOuterAlt(_localctx, 3);
{
- setState(101);
+ setState(103);
jsonObj();
}
break;
case LBR:
enterOuterAlt(_localctx, 4);
{
- setState(102);
+ setState(104);
jsonArr();
}
break;
case BOOL:
enterOuterAlt(_localctx, 5);
{
- setState(103);
+ setState(105);
match(BOOL);
}
break;
case NULL:
enterOuterAlt(_localctx, 6);
{
- setState(104);
+ setState(106);
match(NULL);
}
break;
@@ -659,42 +660,42 @@ public class NCIntentDslParser extends Parser {
enterRule(_localctx, 16, RULE_jsonArr);
int _la;
try {
- setState(120);
+ setState(122);
_errHandler.sync(this);
switch (
getInterpreter().adaptivePredict(_input,10,_ctx) ) {
case 1:
enterOuterAlt(_localctx, 1);
{
- setState(107);
+ setState(109);
match(LBR);
- setState(108);
+ setState(110);
jsonVal();
- setState(113);
+ setState(115);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==COMMA) {
{
{
- setState(109);
+ setState(111);
match(COMMA);
- setState(110);
+ setState(112);
jsonVal();
}
}
- setState(115);
+ setState(117);
_errHandler.sync(this);
_la = _input.LA(1);
}
- setState(116);
+ setState(118);
match(RBR);
}
break;
case 2:
enterOuterAlt(_localctx, 2);
{
- setState(118);
+ setState(120);
match(LBR);
- setState(119);
+ setState(121);
match(RBR);
}
break;
@@ -748,11 +749,11 @@ public class NCIntentDslParser extends Parser {
enterOuterAlt(_localctx, 1);
{
{
- setState(123);
+ setState(125);
term();
}
_ctx.stop = _input.LT(-1);
- setState(129);
+ setState(131);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,11,_ctx);
while ( _alt!=2 &&
_alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
@@ -763,14 +764,14 @@ public class NCIntentDslParser extends Parser {
{
_localctx = new
TermsContext(_parentctx, _parentState);
pushNewRecursionContext(_localctx,
_startState, RULE_terms);
- setState(125);
+ setState(127);
if (!(precpred(_ctx, 1))) throw new
FailedPredicateException(this, "precpred(_ctx, 1)");
- setState(126);
+ setState(128);
term();
}
}
}
- setState(131);
+ setState(133);
_errHandler.sync(this);
_alt =
getInterpreter().adaptivePredict(_input,11,_ctx);
}
@@ -811,7 +812,7 @@ public class NCIntentDslParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(132);
+ setState(134);
_la = _input.LA(1);
if ( !(_la==TILDA || _la==ASSIGN) ) {
_errHandler.recoverInline(this);
@@ -877,31 +878,31 @@ public class NCIntentDslParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(134);
- match(T__4);
setState(136);
+ match(T__4);
+ setState(138);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==LPAR) {
{
- setState(135);
+ setState(137);
termId();
}
}
- setState(138);
+ setState(140);
termEq();
- setState(147);
+ setState(149);
_errHandler.sync(this);
switch (_input.LA(1)) {
case LBRACE:
{
{
- setState(139);
+ setState(141);
match(LBRACE);
- setState(140);
+ setState(142);
expr(0);
- setState(141);
+ setState(143);
match(RBRACE);
}
}
@@ -909,11 +910,11 @@ public class NCIntentDslParser extends Parser {
case DIV:
{
{
- setState(143);
+ setState(145);
match(DIV);
- setState(144);
+ setState(146);
clsNer();
- setState(145);
+ setState(147);
match(DIV);
}
}
@@ -921,12 +922,12 @@ public class NCIntentDslParser extends Parser {
default:
throw new NoViableAltException(this);
}
- setState(150);
+ setState(152);
_errHandler.sync(this);
switch (
getInterpreter().adaptivePredict(_input,14,_ctx) ) {
case 1:
{
- setState(149);
+ setState(151);
minMax();
}
break;
@@ -971,19 +972,19 @@ public class NCIntentDslParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(153);
+ setState(155);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==ID) {
{
- setState(152);
+ setState(154);
javaFqn(0);
}
}
- setState(155);
+ setState(157);
match(POUND);
- setState(156);
+ setState(158);
match(ID);
}
}
@@ -1034,11 +1035,11 @@ public class NCIntentDslParser extends Parser {
enterOuterAlt(_localctx, 1);
{
{
- setState(159);
+ setState(161);
match(ID);
}
_ctx.stop = _input.LT(-1);
- setState(166);
+ setState(168);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,16,_ctx);
while ( _alt!=2 &&
_alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
@@ -1049,16 +1050,16 @@ public class NCIntentDslParser extends Parser {
{
_localctx = new
JavaFqnContext(_parentctx, _parentState);
pushNewRecursionContext(_localctx,
_startState, RULE_javaFqn);
- setState(161);
+ setState(163);
if (!(precpred(_ctx, 1))) throw new
FailedPredicateException(this, "precpred(_ctx, 1)");
- setState(162);
+ setState(164);
match(DOT);
- setState(163);
+ setState(165);
match(ID);
}
}
}
- setState(168);
+ setState(170);
_errHandler.sync(this);
_alt =
getInterpreter().adaptivePredict(_input,16,_ctx);
}
@@ -1099,11 +1100,11 @@ public class NCIntentDslParser extends Parser {
try {
enterOuterAlt(_localctx, 1);
{
- setState(169);
+ setState(171);
match(LPAR);
- setState(170);
+ setState(172);
match(ID);
- setState(171);
+ setState(173);
match(RPAR);
}
}
@@ -1222,8 +1223,8 @@ public class NCIntentDslParser extends Parser {
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 ParamListContext paramList() {
+ return getRuleContext(ParamListContext.class,0);
}
public CallExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
@@ -1256,24 +1257,6 @@ public class NCIntentDslParser extends Parser {
if ( listener instanceof NCIntentDslListener )
((NCIntentDslListener)listener).exitMultExpr(this);
}
}
- public static class ListExprContext extends ExprContext {
- public List<ExprContext> expr() {
- return getRuleContexts(ExprContext.class);
- }
- public ExprContext expr(int i) {
- return getRuleContext(ExprContext.class,i);
- }
- public TerminalNode COMMA() { return
getToken(NCIntentDslParser.COMMA, 0); }
- 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() {
@@ -1331,7 +1314,7 @@ public class NCIntentDslParser extends Parser {
int _alt;
enterOuterAlt(_localctx, 1);
{
- setState(187);
+ setState(189);
_errHandler.sync(this);
switch (_input.LA(1)) {
case NOT:
@@ -1341,7 +1324,7 @@ public class NCIntentDslParser extends Parser {
_ctx = _localctx;
_prevctx = _localctx;
- setState(174);
+ setState(176);
((UnaryExprContext)_localctx).op = _input.LT(1);
_la = _input.LA(1);
if ( !(_la==NOT || _la==MINUS) ) {
@@ -1352,8 +1335,8 @@ public class NCIntentDslParser extends Parser {
_errHandler.reportMatch(this);
consume();
}
- setState(175);
- expr(10);
+ setState(177);
+ expr(9);
}
break;
case LPAR:
@@ -1361,11 +1344,11 @@ public class NCIntentDslParser extends Parser {
_localctx = new ParExprContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
- setState(176);
+ setState(178);
match(LPAR);
- setState(177);
+ setState(179);
expr(0);
- setState(178);
+ setState(180);
match(RPAR);
}
break;
@@ -1378,7 +1361,7 @@ public class NCIntentDslParser extends Parser {
_localctx = new AtomExprContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
- setState(180);
+ setState(182);
atom();
}
break;
@@ -1387,21 +1370,21 @@ public class NCIntentDslParser extends Parser {
_localctx = new CallExprContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
- setState(181);
+ setState(183);
match(ID);
- setState(182);
- match(LPAR);
setState(184);
+ match(LPAR);
+ setState(186);
_errHandler.sync(this);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) &
((1L << SQSTRING) | (1L << DQSTRING) | (1L << BOOL) | (1L << NULL) | (1L <<
NOT) | (1L << LPAR) | (1L << MINUS) | (1L << INT) | (1L << ID))) != 0)) {
{
- setState(183);
- expr(0);
+ setState(185);
+ paramList(0);
}
}
- setState(186);
+ setState(188);
match(RPAR);
}
break;
@@ -1409,7 +1392,7 @@ public class NCIntentDslParser extends Parser {
throw new NoViableAltException(this);
}
_ctx.stop = _input.LT(-1);
- setState(209);
+ setState(208);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,20,_ctx);
while ( _alt!=2 &&
_alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
@@ -1417,16 +1400,16 @@ public class NCIntentDslParser extends Parser {
if ( _parseListeners!=null )
triggerExitRuleEvent();
_prevctx = _localctx;
{
- setState(207);
+ setState(206);
_errHandler.sync(this);
switch (
getInterpreter().adaptivePredict(_input,19,_ctx) ) {
case 1:
{
_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);
+ setState(191);
+ if (!(precpred(_ctx, 7))) throw
new FailedPredicateException(this, "precpred(_ctx, 7)");
+ setState(192);
((MultExprContext)_localctx).op
= _input.LT(1);
_la = _input.LA(1);
if ( !((((_la) & ~0x3f) == 0 &&
((1L << _la) & ((1L << MULT) | (1L << DIV) | (1L << MOD))) != 0)) ) {
@@ -1437,17 +1420,17 @@ public class NCIntentDslParser extends Parser {
_errHandler.reportMatch(this);
consume();
}
- setState(191);
- expr(9);
+ setState(193);
+ expr(8);
}
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);
+ setState(194);
+ if (!(precpred(_ctx, 6))) throw
new FailedPredicateException(this, "precpred(_ctx, 6)");
+ setState(195);
((PlusExprContext)_localctx).op
= _input.LT(1);
_la = _input.LA(1);
if ( !(_la==MINUS || _la==PLUS)
) {
@@ -1458,17 +1441,17 @@ public class NCIntentDslParser extends Parser {
_errHandler.reportMatch(this);
consume();
}
- setState(194);
- expr(8);
+ setState(196);
+ expr(7);
}
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);
+ setState(197);
+ if (!(precpred(_ctx, 5))) throw
new FailedPredicateException(this, "precpred(_ctx, 5)");
+ setState(198);
((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))
) {
@@ -1479,17 +1462,17 @@ public class NCIntentDslParser extends Parser {
_errHandler.reportMatch(this);
consume();
}
- setState(197);
- expr(7);
+ setState(199);
+ expr(6);
}
break;
case 4:
{
_localctx = new
EqExprContext(new ExprContext(_parentctx, _parentState));
pushNewRecursionContext(_localctx, _startState, RULE_expr);
- setState(198);
- if (!(precpred(_ctx, 5))) throw
new FailedPredicateException(this, "precpred(_ctx, 5)");
- setState(199);
+ setState(200);
+ if (!(precpred(_ctx, 4))) throw
new FailedPredicateException(this, "precpred(_ctx, 4)");
+ setState(201);
((EqExprContext)_localctx).op =
_input.LT(1);
_la = _input.LA(1);
if ( !(_la==EQ || _la==NEQ) ) {
@@ -1500,17 +1483,17 @@ public class NCIntentDslParser extends Parser {
_errHandler.reportMatch(this);
consume();
}
- setState(200);
- expr(6);
+ setState(202);
+ expr(5);
}
break;
case 5:
{
_localctx = new
LogExprContext(new ExprContext(_parentctx, _parentState));
pushNewRecursionContext(_localctx, _startState, RULE_expr);
- setState(201);
- if (!(precpred(_ctx, 4))) throw
new FailedPredicateException(this, "precpred(_ctx, 4)");
- setState(202);
+ setState(203);
+ if (!(precpred(_ctx, 3))) throw
new FailedPredicateException(this, "precpred(_ctx, 3)");
+ setState(204);
((LogExprContext)_localctx).op
= _input.LT(1);
_la = _input.LA(1);
if ( !(_la==AND || _la==OR) ) {
@@ -1521,26 +1504,14 @@ public class NCIntentDslParser extends Parser {
_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, 1))) throw
new FailedPredicateException(this, "precpred(_ctx, 1)");
setState(205);
- match(COMMA);
- setState(206);
- expr(2);
+ expr(4);
}
break;
}
}
}
- setState(211);
+ setState(210);
_errHandler.sync(this);
_alt =
getInterpreter().adaptivePredict(_input,20,_ctx);
}
@@ -1557,6 +1528,85 @@ public class NCIntentDslParser extends Parser {
return _localctx;
}
+ public static class ParamListContext extends ParserRuleContext {
+ public ExprContext expr() {
+ return getRuleContext(ExprContext.class,0);
+ }
+ public ParamListContext paramList() {
+ return getRuleContext(ParamListContext.class,0);
+ }
+ public TerminalNode COMMA() { return
getToken(NCIntentDslParser.COMMA, 0); }
+ public ParamListContext(ParserRuleContext parent, int
invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_paramList; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof NCIntentDslListener )
((NCIntentDslListener)listener).enterParamList(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof NCIntentDslListener )
((NCIntentDslListener)listener).exitParamList(this);
+ }
+ }
+
+ public final ParamListContext paramList() throws RecognitionException {
+ return paramList(0);
+ }
+
+ private ParamListContext paramList(int _p) throws RecognitionException {
+ ParserRuleContext _parentctx = _ctx;
+ int _parentState = getState();
+ ParamListContext _localctx = new ParamListContext(_ctx,
_parentState);
+ ParamListContext _prevctx = _localctx;
+ int _startState = 32;
+ enterRecursionRule(_localctx, 32, RULE_paramList, _p);
+ try {
+ int _alt;
+ enterOuterAlt(_localctx, 1);
+ {
+ {
+ setState(212);
+ expr(0);
+ }
+ _ctx.stop = _input.LT(-1);
+ setState(219);
+ _errHandler.sync(this);
+ _alt = getInterpreter().adaptivePredict(_input,21,_ctx);
+ while ( _alt!=2 &&
_alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
+ if ( _alt==1 ) {
+ if ( _parseListeners!=null )
triggerExitRuleEvent();
+ _prevctx = _localctx;
+ {
+ {
+ _localctx = new
ParamListContext(_parentctx, _parentState);
+ pushNewRecursionContext(_localctx,
_startState, RULE_paramList);
+ setState(214);
+ if (!(precpred(_ctx, 1))) throw new
FailedPredicateException(this, "precpred(_ctx, 1)");
+ setState(215);
+ match(COMMA);
+ setState(216);
+ expr(0);
+ }
+ }
+ }
+ setState(221);
+ _errHandler.sync(this);
+ _alt =
getInterpreter().adaptivePredict(_input,21,_ctx);
+ }
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ unrollRecursionContexts(_parentctx);
+ }
+ return _localctx;
+ }
+
public static class AtomContext extends ParserRuleContext {
public TerminalNode NULL() { return
getToken(NCIntentDslParser.NULL, 0); }
public TerminalNode INT() { return
getToken(NCIntentDslParser.INT, 0); }
@@ -1582,39 +1632,39 @@ public class NCIntentDslParser extends Parser {
public final AtomContext atom() throws RecognitionException {
AtomContext _localctx = new AtomContext(_ctx, getState());
- enterRule(_localctx, 32, RULE_atom);
+ enterRule(_localctx, 34, RULE_atom);
try {
- setState(222);
+ setState(232);
_errHandler.sync(this);
switch (_input.LA(1)) {
case NULL:
enterOuterAlt(_localctx, 1);
{
- setState(212);
+ setState(222);
match(NULL);
}
break;
case INT:
enterOuterAlt(_localctx, 2);
{
- setState(213);
+ setState(223);
match(INT);
- setState(215);
+ setState(225);
_errHandler.sync(this);
- switch (
getInterpreter().adaptivePredict(_input,21,_ctx) ) {
+ switch (
getInterpreter().adaptivePredict(_input,22,_ctx) ) {
case 1:
{
- setState(214);
+ setState(224);
match(REAL);
}
break;
}
- setState(218);
+ setState(228);
_errHandler.sync(this);
- switch (
getInterpreter().adaptivePredict(_input,22,_ctx) ) {
+ switch (
getInterpreter().adaptivePredict(_input,23,_ctx) ) {
case 1:
{
- setState(217);
+ setState(227);
match(EXP);
}
break;
@@ -1624,7 +1674,7 @@ public class NCIntentDslParser extends Parser {
case BOOL:
enterOuterAlt(_localctx, 3);
{
- setState(220);
+ setState(230);
match(BOOL);
}
break;
@@ -1632,7 +1682,7 @@ public class NCIntentDslParser extends Parser {
case DQSTRING:
enterOuterAlt(_localctx, 4);
{
- setState(221);
+ setState(231);
qstring();
}
break;
@@ -1670,12 +1720,12 @@ public class NCIntentDslParser extends Parser {
public final QstringContext qstring() throws RecognitionException {
QstringContext _localctx = new QstringContext(_ctx, getState());
- enterRule(_localctx, 34, RULE_qstring);
+ enterRule(_localctx, 36, RULE_qstring);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
- setState(224);
+ setState(234);
_la = _input.LA(1);
if ( !(_la==SQSTRING || _la==DQSTRING) ) {
_errHandler.recoverInline(this);
@@ -1721,9 +1771,9 @@ public class NCIntentDslParser extends Parser {
public final MinMaxContext minMax() throws RecognitionException {
MinMaxContext _localctx = new MinMaxContext(_ctx, getState());
- enterRule(_localctx, 36, RULE_minMax);
+ enterRule(_localctx, 38, RULE_minMax);
try {
- setState(228);
+ setState(238);
_errHandler.sync(this);
switch (_input.LA(1)) {
case PLUS:
@@ -1731,14 +1781,14 @@ public class NCIntentDslParser extends Parser {
case MULT:
enterOuterAlt(_localctx, 1);
{
- setState(226);
+ setState(236);
minMaxShortcut();
}
break;
case LBR:
enterOuterAlt(_localctx, 2);
{
- setState(227);
+ setState(237);
minMaxRange();
}
break;
@@ -1777,12 +1827,12 @@ public class NCIntentDslParser extends Parser {
public final MinMaxShortcutContext minMaxShortcut() throws
RecognitionException {
MinMaxShortcutContext _localctx = new
MinMaxShortcutContext(_ctx, getState());
- enterRule(_localctx, 38, RULE_minMaxShortcut);
+ enterRule(_localctx, 40, RULE_minMaxShortcut);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
- setState(230);
+ setState(240);
_la = _input.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L <<
PLUS) | (1L << QUESTION) | (1L << MULT))) != 0)) ) {
_errHandler.recoverInline(this);
@@ -1829,19 +1879,19 @@ public class NCIntentDslParser extends Parser {
public final MinMaxRangeContext minMaxRange() throws
RecognitionException {
MinMaxRangeContext _localctx = new MinMaxRangeContext(_ctx,
getState());
- enterRule(_localctx, 40, RULE_minMaxRange);
+ enterRule(_localctx, 42, RULE_minMaxRange);
try {
enterOuterAlt(_localctx, 1);
{
- setState(232);
+ setState(242);
match(LBR);
- setState(233);
+ setState(243);
match(INT);
- setState(234);
+ setState(244);
match(COMMA);
- setState(235);
+ setState(245);
match(INT);
- setState(236);
+ setState(246);
match(RBR);
}
}
@@ -1864,6 +1914,8 @@ public class NCIntentDslParser extends Parser {
return javaFqn_sempred((JavaFqnContext)_localctx,
predIndex);
case 15:
return expr_sempred((ExprContext)_localctx, predIndex);
+ case 16:
+ return paramList_sempred((ParamListContext)_localctx,
predIndex);
}
return true;
}
@@ -1884,15 +1936,20 @@ public class NCIntentDslParser extends Parser {
private boolean expr_sempred(ExprContext _localctx, int predIndex) {
switch (predIndex) {
case 2:
- return precpred(_ctx, 8);
- case 3:
return precpred(_ctx, 7);
- case 4:
+ case 3:
return precpred(_ctx, 6);
- case 5:
+ case 4:
return precpred(_ctx, 5);
- case 6:
+ case 5:
return precpred(_ctx, 4);
+ case 6:
+ return precpred(_ctx, 3);
+ }
+ return true;
+ }
+ private boolean paramList_sempred(ParamListContext _localctx, int
predIndex) {
+ switch (predIndex) {
case 7:
return precpred(_ctx, 1);
}
@@ -1900,85 +1957,89 @@ public class NCIntentDslParser extends Parser {
}
public static final String _serializedATN =
-
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\61\u00f1\4\2\t\2"+
+
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\61\u00fb\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\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"+
-
"\34\34%%\4\2\25\25\"\"\3\2(*\4\2\"\"&&\3\2\16\21\3\2\f\r\3\2\22\23\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\n\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\30\2\2JO\5\16\b\2KL\7 \2\2L"+
-
"N\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\2"+
-
"RS\7\31\2\2SW\3\2\2\2TU\7\30\2\2UW\7\31\2\2VI\3\2\2\2VT\3\2\2\2W\r\3\2"+
-
"\2\2XY\5$\23\2YZ\7!\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\2ce\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\2il\7"+
-
"\n\2\2jl\7\13\2\2k\\\3\2\2\2k^\3\2\2\2kg\3\2\2\2kh\3\2\2\2ki\3\2\2\2k"+
- "j\3\2\2\2l\21\3\2\2\2mn\7\35\2\2ns\5\20\t\2op\7
\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\36\2\2w{\3"+
-
"\2\2\2xy\7\35\2\2y{\7\36\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"+
- "\30\2\2\u008e\u008f\5
\21\2\u008f\u0090\7\31\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\37\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\26\2\2\u00ac\u00ad\7/\2\2\u00ad\u00ae"+
-
"\7\27\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\26\2\2\u00b3\u00b4\5
\21\2\u00b4\u00b5\7"+
-
"\27\2\2\u00b5\u00be\3\2\2\2\u00b6\u00be\5\"\22\2\u00b7\u00b8\7/\2\2\u00b8"+
- "\u00ba\7\26\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\27\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\3\2\2\u00cf\u00d0\7
\2\2\u00d0"+
- "\u00d2\5
\21\4\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\13\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\n\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\35\2\2\u00eb\u00ec\7,\2\2\u00ec"+
- "\u00ed\7
\2\2\u00ed\u00ee\7,\2\2\u00ee\u00ef\7\36\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";
+
"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\3\2\3\2\5\2\61\n\2"+
+
"\3\2\5\2\64\n\2\3\2\5\2\67\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\7P\n\7\f\7\16\7"+
+
"S\13\7\3\7\3\7\3\7\3\7\5\7Y\n\7\3\b\3\b\3\b\3\b\3\t\3\t\5\ta\n\t\3\t\3"+
+
"\t\5\te\n\t\3\t\5\th\n\t\3\t\3\t\3\t\3\t\5\tn\n\t\3\n\3\n\3\n\3\n\7\n"+
+
"t\n\n\f\n\16\nw\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\u0084\n\13\f\13\16\13\u0087\13\13\3\f\3\f\3\r\3\r\5\r\u008d\n\r"+
+
"\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\5\r\u0098\n\r\3\r\5\r\u009b\n\r\3"+
+
"\16\5\16\u009e\n\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\7\17"+
+
"\u00a9\n\17\f\17\16\17\u00ac\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\u00bd\n\21\3\21\5\21\u00c0"+
+
"\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\7\21\u00d1\n\21\f\21\16\21\u00d4\13\21\3\22\3\22\3\22\3\22"+
+
"\3\22\3\22\7\22\u00dc\n\22\f\22\16\22\u00df\13\22\3\23\3\23\3\23\5\23"+
+
"\u00e4\n\23\3\23\5\23\u00e7\n\23\3\23\3\23\5\23\u00eb\n\23\3\24\3\24\3"+
+
"\25\3\25\5\25\u00f1\n\25\3\26\3\26\3\27\3\27\3\27\3\27\3\27\3\27\3\27"+
+ "\2\6\24\34 \"\30\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36
\"$&(*,\2\13\4"+
+
"\2\34\34%%\4\2\25\25\"\"\3\2(*\4\2\"\"&&\3\2\16\21\3\2\f\r\3\2\22\23\3"+
+
"\2\b\t\3\2&(\2\u0109\2.\3\2\2\2\4;\3\2\2\2\6?\3\2\2\2\bC\3\2\2\2\nG\3"+
+
"\2\2\2\fX\3\2\2\2\16Z\3\2\2\2\20m\3\2\2\2\22|\3\2\2\2\24~\3\2\2\2\26\u0088"+
+
"\3\2\2\2\30\u008a\3\2\2\2\32\u009d\3\2\2\2\34\u00a2\3\2\2\2\36\u00ad\3"+
+ "\2\2\2
\u00bf\3\2\2\2\"\u00d5\3\2\2\2$\u00ea\3\2\2\2&\u00ec\3\2\2\2(\u00f0"+
+
"\3\2\2\2*\u00f2\3\2\2\2,\u00f4\3\2\2\2.\60\5\4\3\2/\61\5\6\4\2\60/\3\2"+
+
"\2\2\60\61\3\2\2\2\61\63\3\2\2\2\62\64\5\b\5\2\63\62\3\2\2\2\63\64\3\2"+
+
"\2\2\64\66\3\2\2\2\65\67\5\n\6\2\66\65\3\2\2\2\66\67\3\2\2\2\678\3\2\2"+
+
"\289\5\24\13\29:\7\2\2\3:\3\3\2\2\2;<\7\3\2\2<=\7%\2\2=>\7/\2\2>\5\3\2"+
+
"\2\2?@\7\4\2\2@A\7%\2\2AB\7\n\2\2B\7\3\2\2\2CD\7\5\2\2DE\7%\2\2EF\5&\24"+
+
"\2F\t\3\2\2\2GH\7\6\2\2HI\7%\2\2IJ\5\f\7\2J\13\3\2\2\2KL\7\30\2\2LQ\5"+
+ "\16\b\2MN\7
\2\2NP\5\16\b\2OM\3\2\2\2PS\3\2\2\2QO\3\2\2\2QR\3\2\2\2RT"+
+
"\3\2\2\2SQ\3\2\2\2TU\7\31\2\2UY\3\2\2\2VW\7\30\2\2WY\7\31\2\2XK\3\2\2"+
+
"\2XV\3\2\2\2Y\r\3\2\2\2Z[\5&\24\2[\\\7!\2\2\\]\5\20\t\2]\17\3\2\2\2^n"+
+
"\5&\24\2_a\7\"\2\2`_\3\2\2\2`a\3\2\2\2ab\3\2\2\2bd\7,\2\2ce\7-\2\2dc\3"+
+
"\2\2\2de\3\2\2\2eg\3\2\2\2fh\7.\2\2gf\3\2\2\2gh\3\2\2\2hn\3\2\2\2in\5"+
+
"\f\7\2jn\5\22\n\2kn\7\n\2\2ln\7\13\2\2m^\3\2\2\2m`\3\2\2\2mi\3\2\2\2m"+
+
"j\3\2\2\2mk\3\2\2\2ml\3\2\2\2n\21\3\2\2\2op\7\35\2\2pu\5\20\t\2qr\7 \2"+
+
"\2rt\5\20\t\2sq\3\2\2\2tw\3\2\2\2us\3\2\2\2uv\3\2\2\2vx\3\2\2\2wu\3\2"+
+
"\2\2xy\7\36\2\2y}\3\2\2\2z{\7\35\2\2{}\7\36\2\2|o\3\2\2\2|z\3\2\2\2}\23"+
+
"\3\2\2\2~\177\b\13\1\2\177\u0080\5\30\r\2\u0080\u0085\3\2\2\2\u0081\u0082"+
+
"\f\3\2\2\u0082\u0084\5\30\r\2\u0083\u0081\3\2\2\2\u0084\u0087\3\2\2\2"+
+
"\u0085\u0083\3\2\2\2\u0085\u0086\3\2\2\2\u0086\25\3\2\2\2\u0087\u0085"+
+
"\3\2\2\2\u0088\u0089\t\2\2\2\u0089\27\3\2\2\2\u008a\u008c\7\7\2\2\u008b"+
+
"\u008d\5\36\20\2\u008c\u008b\3\2\2\2\u008c\u008d\3\2\2\2\u008d\u008e\3"+
+ "\2\2\2\u008e\u0097\5\26\f\2\u008f\u0090\7\30\2\2\u0090\u0091\5
\21\2\u0091"+
+
"\u0092\7\31\2\2\u0092\u0098\3\2\2\2\u0093\u0094\7)\2\2\u0094\u0095\5\32"+
+
"\16\2\u0095\u0096\7)\2\2\u0096\u0098\3\2\2\2\u0097\u008f\3\2\2\2\u0097"+
+
"\u0093\3\2\2\2\u0098\u009a\3\2\2\2\u0099\u009b\5(\25\2\u009a\u0099\3\2"+
+
"\2\2\u009a\u009b\3\2\2\2\u009b\31\3\2\2\2\u009c\u009e\5\34\17\2\u009d"+
+
"\u009c\3\2\2\2\u009d\u009e\3\2\2\2\u009e\u009f\3\2\2\2\u009f\u00a0\7\37"+
+
"\2\2\u00a0\u00a1\7/\2\2\u00a1\33\3\2\2\2\u00a2\u00a3\b\17\1\2\u00a3\u00a4"+
+
"\7/\2\2\u00a4\u00aa\3\2\2\2\u00a5\u00a6\f\3\2\2\u00a6\u00a7\7#\2\2\u00a7"+
+
"\u00a9\7/\2\2\u00a8\u00a5\3\2\2\2\u00a9\u00ac\3\2\2\2\u00aa\u00a8\3\2"+
+
"\2\2\u00aa\u00ab\3\2\2\2\u00ab\35\3\2\2\2\u00ac\u00aa\3\2\2\2\u00ad\u00ae"+
+
"\7\26\2\2\u00ae\u00af\7/\2\2\u00af\u00b0\7\27\2\2\u00b0\37\3\2\2\2\u00b1"+
+ "\u00b2\b\21\1\2\u00b2\u00b3\t\3\2\2\u00b3\u00c0\5
\21\13\u00b4\u00b5\7"+
+ "\26\2\2\u00b5\u00b6\5
\21\2\u00b6\u00b7\7\27\2\2\u00b7\u00c0\3\2\2\2\u00b8"+
+
"\u00c0\5$\23\2\u00b9\u00ba\7/\2\2\u00ba\u00bc\7\26\2\2\u00bb\u00bd\5\""+
+
"\22\2\u00bc\u00bb\3\2\2\2\u00bc\u00bd\3\2\2\2\u00bd\u00be\3\2\2\2\u00be"+
+
"\u00c0\7\27\2\2\u00bf\u00b1\3\2\2\2\u00bf\u00b4\3\2\2\2\u00bf\u00b8\3"+
+
"\2\2\2\u00bf\u00b9\3\2\2\2\u00c0\u00d2\3\2\2\2\u00c1\u00c2\f\t\2\2\u00c2"+
+ "\u00c3\t\4\2\2\u00c3\u00d1\5
\21\n\u00c4\u00c5\f\b\2\2\u00c5\u00c6\t\5"+
+ "\2\2\u00c6\u00d1\5
\21\t\u00c7\u00c8\f\7\2\2\u00c8\u00c9\t\6\2\2\u00c9"+
+ "\u00d1\5
\21\b\u00ca\u00cb\f\6\2\2\u00cb\u00cc\t\7\2\2\u00cc\u00d1\5 "+
+ "\21\7\u00cd\u00ce\f\5\2\2\u00ce\u00cf\t\b\2\2\u00cf\u00d1\5
\21\6\u00d0"+
+
"\u00c1\3\2\2\2\u00d0\u00c4\3\2\2\2\u00d0\u00c7\3\2\2\2\u00d0\u00ca\3\2"+
+
"\2\2\u00d0\u00cd\3\2\2\2\u00d1\u00d4\3\2\2\2\u00d2\u00d0\3\2\2\2\u00d2"+
+
"\u00d3\3\2\2\2\u00d3!\3\2\2\2\u00d4\u00d2\3\2\2\2\u00d5\u00d6\b\22\1\2"+
+ "\u00d6\u00d7\5
\21\2\u00d7\u00dd\3\2\2\2\u00d8\u00d9\f\3\2\2\u00d9\u00da"+
+ "\7 \2\2\u00da\u00dc\5
\21\2\u00db\u00d8\3\2\2\2\u00dc\u00df\3\2\2\2\u00dd"+
+
"\u00db\3\2\2\2\u00dd\u00de\3\2\2\2\u00de#\3\2\2\2\u00df\u00dd\3\2\2\2"+
+
"\u00e0\u00eb\7\13\2\2\u00e1\u00e3\7,\2\2\u00e2\u00e4\7-\2\2\u00e3\u00e2"+
+
"\3\2\2\2\u00e3\u00e4\3\2\2\2\u00e4\u00e6\3\2\2\2\u00e5\u00e7\7.\2\2\u00e6"+
+
"\u00e5\3\2\2\2\u00e6\u00e7\3\2\2\2\u00e7\u00eb\3\2\2\2\u00e8\u00eb\7\n"+
+
"\2\2\u00e9\u00eb\5&\24\2\u00ea\u00e0\3\2\2\2\u00ea\u00e1\3\2\2\2\u00ea"+
+
"\u00e8\3\2\2\2\u00ea\u00e9\3\2\2\2\u00eb%\3\2\2\2\u00ec\u00ed\t\t\2\2"+
+
"\u00ed\'\3\2\2\2\u00ee\u00f1\5*\26\2\u00ef\u00f1\5,\27\2\u00f0\u00ee\3"+
+
"\2\2\2\u00f0\u00ef\3\2\2\2\u00f1)\3\2\2\2\u00f2\u00f3\t\n\2\2\u00f3+\3"+
+ "\2\2\2\u00f4\u00f5\7\35\2\2\u00f5\u00f6\7,\2\2\u00f6\u00f7\7
\2\2\u00f7"+
+
"\u00f8\7,\2\2\u00f8\u00f9\7\36\2\2\u00f9-\3\2\2\2\34\60\63\66QX`dgmu|"+
+
"\u0085\u008c\u0097\u009a\u009d\u00aa\u00bc\u00bf\u00d0\u00d2\u00dd\u00e3"+
+ "\u00e6\u00ea\u00f0";
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 77519e8..206c850 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,6 @@ 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
import java.util.{List ⇒ JList, Map ⇒ JMap}
import scala.language.implicitConversions
@@ -68,9 +67,11 @@ object NCIntentDslCompiler extends LazyLogging {
private def isJLong(v: AnyRef): Boolean = v.isInstanceOf[JLong]
private def isJDouble(v: AnyRef): Boolean = v.isInstanceOf[JDouble]
private def isString(v: AnyRef): Boolean = v.isInstanceOf[String]
+ private def isBoolean(v: AnyRef): Boolean = v.isInstanceOf[Boolean]
private def asJLong(v: AnyRef): Long =
v.asInstanceOf[JLong].longValue()
private def asJDouble(v: AnyRef): Double =
v.asInstanceOf[JDouble].doubleValue()
private def asString(v: AnyRef): String = v.asInstanceOf[String]
+ private def asBoolean(v: AnyRef): Boolean = v.asInstanceOf[Boolean]
private def asJList(v: AnyRef): JList[AnyRef] =
v.asInstanceOf[JList[AnyRef]]
private def isJList(v: AnyRef): Boolean = v.isInstanceOf[JList[AnyRef]]
private def asJMap(v: AnyRef): JMap[AnyRef, AnyRef] =
v.asInstanceOf[JMap[AnyRef, AnyRef]]
@@ -85,15 +86,16 @@ object NCIntentDslCompiler extends LazyLogging {
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")
-
+ private def errUnaryOp(op: String, v: AnyRef): IAE =
+ new IAE(s"Unexpected '$op' operation for value: $v")
+ private def errBinaryOp(op: String, v1: AnyRef, v2: AnyRef): IAE =
+ new IAE(s"Unexpected '$op' operation for values: $v1, $v2")
+ private def errUnknownFun(fun: String): IAE =
+ new IAE(s"Unknown built-in function: $fun")
+ private def errParamNum(fun: String): IAE =
+ new IAE(s"Invalid number of parameters for built-in function:
$fun")
+ private def errParamType(fun: String): IAE =
+ new IAE(s"Invalid parameter type for built-in function: $fun")
/**
*
@@ -122,54 +124,48 @@ object NCIntentDslCompiler extends LazyLogging {
* @return
*/
private def pop2()(implicit stack: StackType): (AnyRef, AnyRef,
Boolean) = {
- // Stack pop in reverse order of push...
+ // Stack pops in reverse order of push...
val NCDslTermRetVal(val2, f1) = stack.pop()
val NCDslTermRetVal(val1, f2) = stack.pop()
(val1, val2, f1 || f2)
}
- override def exitListExpr(ctx: NCIntentDslParser.ListExprContext):
Unit = {
- termCode += ((_, stack: StackType, _) ⇒ {
- require(stack.size >= 2)
-
- implicit val s = stack
-
- val (val1, val2, usedTok) = pop2()
-
- if (isJList(val1) && isJList(val2)) {
- val lst1 = asJList(val1)
- val lst2 = asJList(val2)
-
- lst1.addAll(lst2)
-
- pushAny(lst1, usedTok)
+ /**
+ *
+ * @param stack
+ * @return
+ */
+ private def pop1()(implicit stack: StackType): (AnyRef, Boolean) = {
+ val NCDslTermRetVal(v, f) = stack.pop()
- }
- else if (isJList(val1)) {
- val lst = asJList(val1)
+ (v, f)
+ }
- lst.add(val2)
+ override def exitUnaryExpr(ctx: NCIntentDslParser.UnaryExprContext):
Unit = {
+ termCode += ((_, stack: StackType, _) ⇒ {
+ require(stack.nonEmpty)
- pushAny(lst, usedTok)
- }
- else if (isJList(val2)) {
- val lst = asJList(val2)
+ implicit val s = stack
- lst.add(val1)
+ val (v, usedTok) = pop1()
- pushAny(lst, usedTok)
+ if (ctx.MINUS() != null) {
+ if (isJDouble(v))
+ pushDouble(-asJDouble(v), usedTok)
+ else if (isJLong(v))
+ pushLong(-asJLong(v), usedTok)
+ else
+ throw errUnaryOp("-", v)
}
else {
- pushAny(util.Arrays.asList(val1, val2), usedTok)
- }
- })
- }
-
-
- override def exitUnaryExpr(ctx: NCIntentDslParser.UnaryExprContext):
Unit = {
- termCode += ((_, stack: StackType, _) ⇒ {
+ assert(ctx.NOT() != null)
+ if (isBoolean(v))
+ pushBoolean(!asBoolean(v), usedTok)
+ else
+ throw errUnaryOp("!", v)
+ }
})
}
@@ -179,39 +175,39 @@ object NCIntentDslCompiler extends LazyLogging {
implicit val s = stack
- val (val1, val2, usedTok) = pop2()
+ val (v1, v2, usedTok) = pop2()
if (ctx.MULT() != null) {
- if (isJLong(val1) && isJLong(val2))
- pushLong(asJLong(val1) * asJLong(val2), usedTok)
- else if (isJLong(val1) && isJDouble(val2))
- pushDouble(asJLong(val1) * asJDouble(val2), usedTok)
- else if (isJDouble(val1) && isJLong(val2))
- pushDouble(asJDouble(val1) * asJLong(val2), usedTok)
- else if (isJDouble(val1) && isJDouble(val2))
- pushDouble(asJDouble(val1) * asJDouble(val2), usedTok)
+ if (isJLong(v1) && isJLong(v2))
+ pushLong(asJLong(v1) * asJLong(v2), usedTok)
+ else if (isJLong(v1) && isJDouble(v2))
+ pushDouble(asJLong(v1) * asJDouble(v2), usedTok)
+ else if (isJDouble(v1) && isJLong(v2))
+ pushDouble(asJDouble(v1) * asJLong(v2), usedTok)
+ else if (isJDouble(v1) && isJDouble(v2))
+ pushDouble(asJDouble(v1) * asJDouble(v2), usedTok)
else
- errBinaryOp("*", val1, val2)
+ throw errBinaryOp("*", v1, v2)
}
else if (ctx.MOD() != null) {
- if (isJLong(val1) && isJLong(val2))
- pushLong(asJLong(val1) % asJLong(val2), usedTok)
+ if (isJLong(v1) && isJLong(v2))
+ pushLong(asJLong(v1) % asJLong(v2), usedTok)
else
- errBinaryOp("%", val1, val2)
+ throw errBinaryOp("%", v1, v2)
}
else {
assert(ctx.DIV() != null)
- if (isJLong(val1) && isJLong(val2))
- pushLong(asJLong(val1) / asJLong(val2), usedTok)
- else if (isJLong(val1) && isJDouble(val2))
- pushDouble(asJLong(val1) / asJDouble(val2), usedTok)
- else if (isJDouble(val1) && isJLong(val2))
- pushDouble(asJDouble(val1) / asJLong(val2), usedTok)
- else if (isJDouble(val1) && isJDouble(val2))
- pushDouble(asJDouble(val1) / asJDouble(val2), usedTok)
+ if (isJLong(v1) && isJLong(v2))
+ pushLong(asJLong(v1) / asJLong(v2), usedTok)
+ else if (isJLong(v1) && isJDouble(v2))
+ pushDouble(asJLong(v1) / asJDouble(v2), usedTok)
+ else if (isJDouble(v1) && isJLong(v2))
+ pushDouble(asJDouble(v1) / asJLong(v2), usedTok)
+ else if (isJDouble(v1) && isJDouble(v2))
+ pushDouble(asJDouble(v1) / asJDouble(v2), usedTok)
else
- errBinaryOp("/", val1, val2)
+ throw errBinaryOp("/", v1, v2)
}
})
}
@@ -222,35 +218,35 @@ object NCIntentDslCompiler extends LazyLogging {
implicit val s = stack
- val (val1, val2, usedTok) = pop2()
+ val (v1, v2, usedTok) = pop2()
if (ctx.PLUS != null) {
- if (isString(val1) && isString(val2))
- pushAny(asString(val1) + asString(val2), usedTok)
- else if (isJLong(val1) && isJLong(val2))
- pushLong(asJLong(val1) + asJLong(val2), usedTok)
- else if (isJLong(val1) && isJDouble(val2))
- pushDouble(asJLong(val1) + asJDouble(val2), usedTok)
- else if (isJDouble(val1) && isJLong(val2))
- pushDouble(asJDouble(val1) + asJLong(val2), usedTok)
- else if (isJDouble(val1) && isJDouble(val2))
- pushDouble(asJDouble(val1) + asJDouble(val2), usedTok)
+ if (isString(v1) && isString(v2))
+ pushAny(asString(v1) + asString(v2), usedTok)
+ else if (isJLong(v1) && isJLong(v2))
+ pushLong(asJLong(v1) + asJLong(v2), usedTok)
+ else if (isJLong(v1) && isJDouble(v2))
+ pushDouble(asJLong(v1) + asJDouble(v2), usedTok)
+ else if (isJDouble(v1) && isJLong(v2))
+ pushDouble(asJDouble(v1) + asJLong(v2), usedTok)
+ else if (isJDouble(v1) && isJDouble(v2))
+ pushDouble(asJDouble(v1) + asJDouble(v2), usedTok)
else
- errBinaryOp("+", val1, val2)
+ throw errBinaryOp("+", v1, v2)
}
else {
assert(ctx.MINUS != null)
- if (isJLong(val1) && isJLong(val2))
- pushLong(asJLong(val1) - asJLong(val2), usedTok)
- else if (isJLong(val1) && isJDouble(val2))
- pushDouble(asJLong(val1) - asJDouble(val2), usedTok)
- else if (isJDouble(val1) && isJLong(val2))
- pushDouble(asJDouble(val1) - asJLong(val2), usedTok)
- else if (isJDouble(val1) && isJDouble(val2))
- pushDouble(asJDouble(val1) - asJDouble(val2), usedTok)
+ if (isJLong(v1) && isJLong(v2))
+ pushLong(asJLong(v1) - asJLong(v2), usedTok)
+ else if (isJLong(v1) && isJDouble(v2))
+ pushDouble(asJLong(v1) - asJDouble(v2), usedTok)
+ else if (isJDouble(v1) && isJLong(v2))
+ pushDouble(asJDouble(v1) - asJLong(v2), usedTok)
+ else if (isJDouble(v1) && isJDouble(v2))
+ pushDouble(asJDouble(v1) - asJDouble(v2), usedTok)
else
- errBinaryOp("-", val1, val2)
+ throw errBinaryOp("-", v1, v2)
}
})
}
@@ -261,19 +257,57 @@ object NCIntentDslCompiler extends LazyLogging {
implicit val s = stack
- val (val1, val2, usedTok) = pop2()
+ val (v1, v2, usedTok) = pop2()
if (ctx.LT() != null) {
-
+ if (isJLong(v1) && isJLong(v2))
+ pushBoolean(asJLong(v1) < asJLong(v2), usedTok)
+ else if (isJLong(v1) && isJDouble(v2))
+ pushBoolean(asJLong(v1) < asJDouble(v2), usedTok)
+ else if (isJDouble(v1) && isJLong(v2))
+ pushBoolean(asJDouble(v1) < asJLong(v2), usedTok)
+ else if (isJDouble(v1) && isJDouble(v2))
+ pushBoolean(asJDouble(v1) < asJDouble(v2), usedTok)
+ else
+ throw errBinaryOp("<", v1, v2)
}
else if (ctx.GT() != null) {
-
+ if (isJLong(v1) && isJLong(v2))
+ pushBoolean(asJLong(v1) > asJLong(v2), usedTok)
+ else if (isJLong(v1) && isJDouble(v2))
+ pushBoolean(asJLong(v1) > asJDouble(v2), usedTok)
+ else if (isJDouble(v1) && isJLong(v2))
+ pushBoolean(asJDouble(v1) > asJLong(v2), usedTok)
+ else if (isJDouble(v1) && isJDouble(v2))
+ pushBoolean(asJDouble(v1) > asJDouble(v2), usedTok)
+ else
+ throw errBinaryOp(">", v1, v2)
}
else if (ctx.LTEQ() != null) {
-
+ if (isJLong(v1) && isJLong(v2))
+ pushBoolean(asJLong(v1) <= asJLong(v2), usedTok)
+ else if (isJLong(v1) && isJDouble(v2))
+ pushBoolean(asJLong(v1) <= asJDouble(v2), usedTok)
+ else if (isJDouble(v1) && isJLong(v2))
+ pushBoolean(asJDouble(v1) <= asJLong(v2), usedTok)
+ else if (isJDouble(v1) && isJDouble(v2))
+ pushBoolean(asJDouble(v1) <= asJDouble(v2), usedTok)
+ else
+ throw errBinaryOp("<=", v1, v2)
}
else {
- assert(ctx.GT() != null)
+ assert(ctx.GTEQ() != null)
+
+ if (isJLong(v1) && isJLong(v2))
+ pushBoolean(asJLong(v1) >= asJLong(v2), usedTok)
+ else if (isJLong(v1) && isJDouble(v2))
+ pushBoolean(asJLong(v1) >= asJDouble(v2), usedTok)
+ else if (isJDouble(v1) && isJLong(v2))
+ pushBoolean(asJDouble(v1) >= asJLong(v2), usedTok)
+ else if (isJDouble(v1) && isJDouble(v2))
+ pushBoolean(asJDouble(v1) >= asJDouble(v2), usedTok)
+ else
+ throw errBinaryOp(">=", v1, v2)
}
})
}
@@ -284,13 +318,17 @@ object NCIntentDslCompiler extends LazyLogging {
implicit val s = stack
- val (val1, val2, usedTok) = pop2()
+ val (v1, v2, usedTok) = pop2()
- if (ctx.AND() != null) {
+ if (!isBoolean(v1) || !isBoolean(v2))
+ throw errBinaryOp(if (ctx.AND() != null) "&&" else "||",
v1, v2)
- }
+ if (ctx.AND() != null)
+ pushBoolean(asBoolean(v1) && asBoolean(v2), usedTok)
else {
assert(ctx.OR() != null)
+
+ pushBoolean(asBoolean(v1) || asBoolean(v2), usedTok)
}
})
}
@@ -301,13 +339,24 @@ object NCIntentDslCompiler extends LazyLogging {
implicit val s = stack
- val (val1, val2, usedTok) = pop2()
+ val (v1, v2, usedTok) = pop2()
- if (ctx.EQ() != null) {
+ def doEq(op: String): Boolean = {
+ if (isJLong(v1) && isJLong(v2))
+ asJLong(v1) == asJLong(v2)
+ if (isJLong(v1) && isJLong(v2))
+ asJLong(v1) == asJLong(v2)
+ else
+ throw errBinaryOp(op, v1, v2)
}
+
+ if (ctx.EQ() != null)
+ pushBoolean(doEq("=="), usedTok)
else {
assert(ctx.NEQ() != null)
+
+ pushBoolean(!doEq("!='"), usedTok)
}
})
}
@@ -320,9 +369,9 @@ object NCIntentDslCompiler extends LazyLogging {
val NCDslTermRetVal(param, usedTok) = if (stack.nonEmpty)
stack.pop else (null, false)
- 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 check1String(): Unit = if (param == null) throw
errParamNum(fun) else if (!isString(param)) throw errParamType(fun)
+ def check1Long(): Unit = if (param == null) throw
errParamNum(fun) else if (!isJLong(param)) throw errParamType(fun)
+ def check1Double(): Unit = if (param == null) throw
errParamNum(fun) else if (!isJDouble(param)) throw errParamType(fun)
def doTrim(): String = { check1String();
asString(param).strip() }
def doUppercase(): String = { check1String();
asString(param).toUpperCase() }
@@ -406,6 +455,7 @@ object NCIntentDslCompiler extends LazyLogging {
case "tan" ⇒
// Collection, statistical (incl. string) functions.
+ case "list" ⇒
case "avg" ⇒
case "max" ⇒
case "min" ⇒