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

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


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

commit 178497f7623ff08a6fc1c61efb8dc5802cfda581
Author: Aaron Radzinski <[email protected]>
AuthorDate: Sat Feb 20 21:23:11 2021 -0800

    WIP.
---
 .../nlpcraft/common/makro/antlr4/NCMacroDsl.g4     |  5 +-
 .../nlpcraft/common/makro/antlr4/NCMacroDsl.interp |  2 +-
 .../common/makro/antlr4/NCMacroDslLexer.interp     |  2 +-
 .../common/makro/antlr4/NCMacroDslLexer.java       | 32 ++++----
 .../common/makro/antlr4/NCMacroDslParser.java      | 86 +++++++++++-----------
 5 files changed, 64 insertions(+), 63 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDsl.g4 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDsl.g4
index df477f2..a8951c7 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDsl.g4
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDsl.g4
@@ -22,8 +22,7 @@ line
     | line syn
     ;
 syn
-    : TXT
-    | INT // NOTE: since TXT and INT overlap - we catch them both here and 
resolve in compiler.
+    : (TXT | INT) // NOTE: since TXT and INT overlap - we catch them both here 
and resolve in compiler.
     | group
     ;
 group: LCURLY list RCURLY minMax?;
@@ -59,7 +58,7 @@ fragment TXT_CHAR
     | '\uF900'..'\uFDCF'
     | '\uFDF0'..'\uFFFD'
     ; // Ignoring ['\u10000-'\uEFFFF].
-fragment ESC: '\\' . ;
+fragment ESC: '\\' [{}\\<>_[\]|,] ;
 INT: '0' | [1-9][_0-9]*;
 TXT: (TXT_CHAR | ESC)+;
 WS: [ \r\t\u000C\n]+ -> skip ;
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDsl.interp
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDsl.interp
index b6beaa5..121ec4a 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDsl.interp
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDsl.interp
@@ -35,4 +35,4 @@ list
 
 
 atn:
-[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 13, 54, 4, 2, 
9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 3, 2, 3, 2, 3, 2, 3, 2, 
3, 2, 7, 2, 18, 10, 2, 12, 2, 14, 2, 21, 11, 2, 3, 3, 3, 3, 3, 3, 5, 3, 26, 10, 
3, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 32, 10, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 
3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 47, 10, 6, 7, 6, 49, 10, 6, 12, 
6, 14, 6, 52, 11, 6, 3, 6, 2, 4, 2, 10, 7, 2, 4, 6, 8, 10, 2, 2, 2, 54, 2, 12, 
3, 2, 2, 2, 4, 25, [...]
\ No newline at end of file
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 13, 53, 4, 2, 
9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 3, 2, 3, 2, 3, 2, 3, 2, 
3, 2, 7, 2, 18, 10, 2, 12, 2, 14, 2, 21, 11, 2, 3, 3, 3, 3, 5, 3, 25, 10, 3, 3, 
4, 3, 4, 3, 4, 3, 4, 5, 4, 31, 10, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 
3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 46, 10, 6, 7, 6, 48, 10, 6, 12, 6, 
14, 6, 51, 11, 6, 3, 6, 2, 4, 2, 10, 7, 2, 4, 6, 8, 10, 2, 3, 3, 2, 10, 11, 2, 
52, 2, 12, 3, 2, 2, 2 [...]
\ No newline at end of file
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDslLexer.interp
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDslLexer.interp
index 17a658c..1852ceb 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDslLexer.interp
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDslLexer.interp
@@ -49,4 +49,4 @@ mode names:
 DEFAULT_MODE
 
 atn:
-[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 13, 74, 8, 1, 
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, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 
7, 3, 8, 3, 8, 3, 9, 5, 9, 45, 10, 9, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 
7, 11, 53, 10, 11, 12, 11, 14, 11, 56, 11, 11, 5, 11, 58, 10, 11, 3, 12, 3, 12, 
6, 12, 62, 10, 12, 1 [...]
\ No newline at end of file
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 13, 74, 8, 1, 
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, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 
7, 3, 8, 3, 8, 3, 9, 5, 9, 45, 10, 9, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 
7, 11, 53, 10, 11, 12, 11, 14, 11, 56, 11, 11, 5, 11, 58, 10, 11, 3, 12, 3, 12, 
6, 12, 62, 10, 12, 1 [...]
\ No newline at end of file
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDslLexer.java
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDslLexer.java
index cae6418..1a45648 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDslLexer.java
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDslLexer.java
@@ -112,23 +112,23 @@ public class NCMacroDslLexer extends Lexer {
                
"\3\7\3\7\3\b\3\b\3\t\5\t-\n\t\3\n\3\n\3\n\3\13\3\13\3\13\7\13\65\n\13"+
                
"\f\13\16\138\13\13\5\13:\n\13\3\f\3\f\6\f>\n\f\r\f\16\f?\3\r\6\rC\n\r"+
                
"\r\r\16\rD\3\r\3\r\3\16\3\16\2\2\17\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\2"+
-               
"\23\2\25\n\27\13\31\f\33\r\3\2\6\30\2#%(),-/\60\62<>>@@C\\``c|\u00b9\u00b9"+
+               
"\23\2\25\n\27\13\31\f\33\r\3\2\7\30\2#%(),-/\60\62<>>@@C\\``c|\u00b9\u00b9"+
                
"\u00c2\u00d8\u00da\u00f8\u00fa\u037f\u0381\u2001\u200e\u200f\u2041\u2042"+
-               
"\u2072\u2191\u2c02\u2ff1\u3003\ud801\uf902\ufdd1\ufdf2\uffff\3\2\63;\4"+
-               
"\2\62;aa\5\2\13\f\16\17\"\"\2L\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t"+
-               
"\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2"+
-               
"\2\2\31\3\2\2\2\2\33\3\2\2\2\3\35\3\2\2\2\5\37\3\2\2\2\7!\3\2\2\2\t#\3"+
-               
"\2\2\2\13%\3\2\2\2\r\'\3\2\2\2\17)\3\2\2\2\21,\3\2\2\2\23.\3\2\2\2\25"+
-               
"9\3\2\2\2\27=\3\2\2\2\31B\3\2\2\2\33H\3\2\2\2\35\36\7}\2\2\36\4\3\2\2"+
-               "\2\37 \7\177\2\2 
\6\3\2\2\2!\"\7]\2\2\"\b\3\2\2\2#$\7_\2\2$\n\3\2\2\2"+
-               
"%&\7~\2\2&\f\3\2\2\2\'(\7.\2\2(\16\3\2\2\2)*\7a\2\2*\20\3\2\2\2+-\t\2"+
-               
"\2\2,+\3\2\2\2-\22\3\2\2\2./\7^\2\2/\60\13\2\2\2\60\24\3\2\2\2\61:\7\62"+
-               
"\2\2\62\66\t\3\2\2\63\65\t\4\2\2\64\63\3\2\2\2\658\3\2\2\2\66\64\3\2\2"+
-               
"\2\66\67\3\2\2\2\67:\3\2\2\28\66\3\2\2\29\61\3\2\2\29\62\3\2\2\2:\26\3"+
-               
"\2\2\2;>\5\21\t\2<>\5\23\n\2=;\3\2\2\2=<\3\2\2\2>?\3\2\2\2?=\3\2\2\2?"+
-               
"@\3\2\2\2@\30\3\2\2\2AC\t\5\2\2BA\3\2\2\2CD\3\2\2\2DB\3\2\2\2DE\3\2\2"+
-               
"\2EF\3\2\2\2FG\b\r\2\2G\32\3\2\2\2HI\13\2\2\2I\34\3\2\2\2\t\2,\669=?D"+
-               "\3\b\2\2";
+               
"\u2072\u2191\u2c02\u2ff1\u3003\ud801\uf902\ufdd1\ufdf2\uffff\b\2..>>@"+
+               
"@]_aa}\177\3\2\63;\4\2\62;aa\5\2\13\f\16\17\"\"\2L\2\3\3\2\2\2\2\5\3\2"+
+               
"\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\25"+
+               
"\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\3\35\3\2\2\2\5\37\3\2"+
+               
"\2\2\7!\3\2\2\2\t#\3\2\2\2\13%\3\2\2\2\r\'\3\2\2\2\17)\3\2\2\2\21,\3\2"+
+               
"\2\2\23.\3\2\2\2\259\3\2\2\2\27=\3\2\2\2\31B\3\2\2\2\33H\3\2\2\2\35\36"+
+               "\7}\2\2\36\4\3\2\2\2\37 \7\177\2\2 
\6\3\2\2\2!\"\7]\2\2\"\b\3\2\2\2#$"+
+               
"\7_\2\2$\n\3\2\2\2%&\7~\2\2&\f\3\2\2\2\'(\7.\2\2(\16\3\2\2\2)*\7a\2\2"+
+               
"*\20\3\2\2\2+-\t\2\2\2,+\3\2\2\2-\22\3\2\2\2./\7^\2\2/\60\t\3\2\2\60\24"+
+               
"\3\2\2\2\61:\7\62\2\2\62\66\t\4\2\2\63\65\t\5\2\2\64\63\3\2\2\2\658\3"+
+               
"\2\2\2\66\64\3\2\2\2\66\67\3\2\2\2\67:\3\2\2\28\66\3\2\2\29\61\3\2\2\2"+
+               
"9\62\3\2\2\2:\26\3\2\2\2;>\5\21\t\2<>\5\23\n\2=;\3\2\2\2=<\3\2\2\2>?\3"+
+               
"\2\2\2?=\3\2\2\2?@\3\2\2\2@\30\3\2\2\2AC\t\6\2\2BA\3\2\2\2CD\3\2\2\2D"+
+               
"B\3\2\2\2DE\3\2\2\2EF\3\2\2\2FG\b\r\2\2G\32\3\2\2\2HI\13\2\2\2I\34\3\2"+
+               "\2\2\t\2,\669=?D\3\b\2\2";
        public static final ATN _ATN =
                new ATNDeserializer().deserialize(_serializedATN.toCharArray());
        static {
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDslParser.java
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDslParser.java
index 22219d0..9b051d7 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDslParser.java
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDslParser.java
@@ -190,28 +190,31 @@ public class NCMacroDslParser extends Parser {
        public final SynContext syn() throws RecognitionException {
                SynContext _localctx = new SynContext(_ctx, getState());
                enterRule(_localctx, 2, RULE_syn);
+               int _la;
                try {
-                       setState(23);
+                       setState(22);
                        _errHandler.sync(this);
                        switch (_input.LA(1)) {
+                       case INT:
                        case TXT:
                                enterOuterAlt(_localctx, 1);
                                {
                                setState(20);
-                               match(TXT);
+                               _la = _input.LA(1);
+                               if ( !(_la==INT || _la==TXT) ) {
+                               _errHandler.recoverInline(this);
+                               }
+                               else {
+                                       if ( _input.LA(1)==Token.EOF ) 
matchedEOF = true;
+                                       _errHandler.reportMatch(this);
+                                       consume();
                                }
-                               break;
-                       case INT:
-                               enterOuterAlt(_localctx, 2);
-                               {
-                               setState(21);
-                               match(INT);
                                }
                                break;
                        case LCURLY:
-                               enterOuterAlt(_localctx, 3);
+                               enterOuterAlt(_localctx, 2);
                                {
-                               setState(22);
+                               setState(21);
                                group();
                                }
                                break;
@@ -259,18 +262,18 @@ public class NCMacroDslParser extends Parser {
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(25);
+                       setState(24);
                        match(LCURLY);
-                       setState(26);
+                       setState(25);
                        list(0);
-                       setState(27);
+                       setState(26);
                        match(RCURLY);
-                       setState(29);
+                       setState(28);
                        _errHandler.sync(this);
                        switch ( 
getInterpreter().adaptivePredict(_input,2,_ctx) ) {
                        case 1:
                                {
-                               setState(28);
+                               setState(27);
                                minMax();
                                }
                                break;
@@ -316,15 +319,15 @@ public class NCMacroDslParser extends Parser {
                try {
                        enterOuterAlt(_localctx, 1);
                        {
-                       setState(31);
+                       setState(30);
                        match(LBR);
-                       setState(32);
+                       setState(31);
                        match(INT);
-                       setState(33);
+                       setState(32);
                        match(COMMA);
-                       setState(34);
+                       setState(33);
                        match(INT);
-                       setState(35);
+                       setState(34);
                        match(RBR);
                        }
                }
@@ -378,11 +381,11 @@ public class NCMacroDslParser extends Parser {
                        enterOuterAlt(_localctx, 1);
                        {
                        {
-                       setState(38);
+                       setState(37);
                        syn();
                        }
                        _ctx.stop = _input.LT(-1);
-                       setState(48);
+                       setState(47);
                        _errHandler.sync(this);
                        _alt = getInterpreter().adaptivePredict(_input,4,_ctx);
                        while ( _alt!=2 && 
_alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
@@ -393,24 +396,24 @@ public class NCMacroDslParser extends Parser {
                                        {
                                        _localctx = new ListContext(_parentctx, 
_parentState);
                                        pushNewRecursionContext(_localctx, 
_startState, RULE_list);
-                                       setState(40);
+                                       setState(39);
                                        if (!(precpred(_ctx, 1))) throw new 
FailedPredicateException(this, "precpred(_ctx, 1)");
-                                       setState(41);
+                                       setState(40);
                                        match(VERT);
-                                       setState(44);
+                                       setState(43);
                                        _errHandler.sync(this);
                                        switch (_input.LA(1)) {
                                        case LCURLY:
                                        case INT:
                                        case TXT:
                                                {
-                                               setState(42);
+                                               setState(41);
                                                syn();
                                                }
                                                break;
                                        case UNDERSCORE:
                                                {
-                                               setState(43);
+                                               setState(42);
                                                match(UNDERSCORE);
                                                }
                                                break;
@@ -420,7 +423,7 @@ public class NCMacroDslParser extends Parser {
                                        }
                                        } 
                                }
-                               setState(50);
+                               setState(49);
                                _errHandler.sync(this);
                                _alt = 
getInterpreter().adaptivePredict(_input,4,_ctx);
                        }
@@ -462,21 +465,20 @@ public class NCMacroDslParser extends Parser {
        }
 
        public static final String _serializedATN =
-               
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\r\66\4\2\t\2\4\3"+
+               
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\r\65\4\2\t\2\4\3"+
                
"\t\3\4\4\t\4\4\5\t\5\4\6\t\6\3\2\3\2\3\2\3\2\3\2\7\2\22\n\2\f\2\16\2\25"+
-               "\13\2\3\3\3\3\3\3\5\3\32\n\3\3\4\3\4\3\4\3\4\5\4 
\n\4\3\5\3\5\3\5\3\5"+
-               
"\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\6\3\6\5\6/\n\6\7\6\61\n\6\f\6\16\6\64\13"+
-               
"\6\3\6\2\4\2\n\7\2\4\6\b\n\2\2\2\66\2\f\3\2\2\2\4\31\3\2\2\2\6\33\3\2"+
-               
"\2\2\b!\3\2\2\2\n\'\3\2\2\2\f\r\b\2\1\2\r\16\5\4\3\2\16\23\3\2\2\2\17"+
-               
"\20\f\3\2\2\20\22\5\4\3\2\21\17\3\2\2\2\22\25\3\2\2\2\23\21\3\2\2\2\23"+
-               
"\24\3\2\2\2\24\3\3\2\2\2\25\23\3\2\2\2\26\32\7\13\2\2\27\32\7\n\2\2\30"+
-               
"\32\5\6\4\2\31\26\3\2\2\2\31\27\3\2\2\2\31\30\3\2\2\2\32\5\3\2\2\2\33"+
-               "\34\7\3\2\2\34\35\5\n\6\2\35\37\7\4\2\2\36 
\5\b\5\2\37\36\3\2\2\2\37 "+
-               "\3\2\2\2 
\7\3\2\2\2!\"\7\5\2\2\"#\7\n\2\2#$\7\b\2\2$%\7\n\2\2%&\7\6\2"+
-               
"\2&\t\3\2\2\2\'(\b\6\1\2()\5\4\3\2)\62\3\2\2\2*+\f\3\2\2+.\7\7\2\2,/\5"+
-               
"\4\3\2-/\7\t\2\2.,\3\2\2\2.-\3\2\2\2/\61\3\2\2\2\60*\3\2\2\2\61\64\3\2"+
-               
"\2\2\62\60\3\2\2\2\62\63\3\2\2\2\63\13\3\2\2\2\64\62\3\2\2\2\7\23\31\37"+
-               ".\62";
+               
"\13\2\3\3\3\3\5\3\31\n\3\3\4\3\4\3\4\3\4\5\4\37\n\4\3\5\3\5\3\5\3\5\3"+
+               
"\5\3\5\3\6\3\6\3\6\3\6\3\6\3\6\3\6\5\6.\n\6\7\6\60\n\6\f\6\16\6\63\13"+
+               
"\6\3\6\2\4\2\n\7\2\4\6\b\n\2\3\3\2\n\13\2\64\2\f\3\2\2\2\4\30\3\2\2\2"+
+               "\6\32\3\2\2\2\b 
\3\2\2\2\n&\3\2\2\2\f\r\b\2\1\2\r\16\5\4\3\2\16\23\3\2"+
+               
"\2\2\17\20\f\3\2\2\20\22\5\4\3\2\21\17\3\2\2\2\22\25\3\2\2\2\23\21\3\2"+
+               
"\2\2\23\24\3\2\2\2\24\3\3\2\2\2\25\23\3\2\2\2\26\31\t\2\2\2\27\31\5\6"+
+               
"\4\2\30\26\3\2\2\2\30\27\3\2\2\2\31\5\3\2\2\2\32\33\7\3\2\2\33\34\5\n"+
+               
"\6\2\34\36\7\4\2\2\35\37\5\b\5\2\36\35\3\2\2\2\36\37\3\2\2\2\37\7\3\2"+
+               "\2\2 
!\7\5\2\2!\"\7\n\2\2\"#\7\b\2\2#$\7\n\2\2$%\7\6\2\2%\t\3\2\2\2&\'"+
+               
"\b\6\1\2\'(\5\4\3\2(\61\3\2\2\2)*\f\3\2\2*-\7\7\2\2+.\5\4\3\2,.\7\t\2"+
+               
"\2-+\3\2\2\2-,\3\2\2\2.\60\3\2\2\2/)\3\2\2\2\60\63\3\2\2\2\61/\3\2\2\2"+
+               "\61\62\3\2\2\2\62\13\3\2\2\2\63\61\3\2\2\2\7\23\30\36-\61";
        public static final ATN _ATN =
                new ATNDeserializer().deserialize(_serializedATN.toCharArray());
        static {

Reply via email to