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 1140038  WIP.
1140038 is described below

commit 11400385ae949e61142a9c95a0cf1cb9711a4e52
Author: Aaron Radzinzski <[email protected]>
AuthorDate: Sun Feb 21 22:14:04 2021 -0800

    WIP.
---
 .../org/apache/nlpcraft/common/makro/antlr4/NCMacroDsl.g4      | 10 +++++-----
 .../org/apache/nlpcraft/common/makro/NCMacroCompilerSpec.scala |  3 +++
 2 files changed, 8 insertions(+), 5 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 9a9f3fb..b230d43 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
@@ -17,17 +17,17 @@
 
 grammar NCMacroDsl;
 
-makro: line;
-line
+makro: expr;
+expr
     : (syn | group)
-    | line (syn | group)
+    | expr (syn | group)
     ;
 syn : (TXT | INT); // NOTE: since TXT and INT overlap - we catch them both 
here and resolve in compiler.
 group: LCURLY list RCURLY minMax?;
 minMax: LBR INT COMMA INT RBR;
 list
-    : syn
-    | list VERT (syn | UNDERSCORE)
+    : expr
+    | list VERT (expr | UNDERSCORE)
     ;
 LCURLY: '{';
 RCURLY: '}';
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/common/makro/NCMacroCompilerSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/common/makro/NCMacroCompilerSpec.scala
index 4a53da1..357e69a 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/common/makro/NCMacroCompilerSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/common/makro/NCMacroCompilerSpec.scala
@@ -46,6 +46,7 @@ class NCMacroCompilerSpec {
         checkEq("A B", Seq("A B"))
         checkEq("A           B", Seq("A B"))
         checkEq("{A}", Seq("A"))
+        checkEq("XX {A}", Seq("XX A"))
         checkEq("{A}[0,2]", Seq("", "A", "A A"))
         checkEq("{A  }   [0  ,2]", Seq("", "A", "A A"))
         checkEq("{A          }", Seq("A"))
@@ -54,5 +55,7 @@ class NCMacroCompilerSpec {
         checkEq(" {  A   }{B}", Seq("A B"))
         checkEq(" {  A   }      {B}", Seq("A B"))
         checkEq("A {B | C}", Seq("A B", "A C"))
+        checkEq("{A}[1,2]{B}[2, 2]", Seq("A B B", "A A B B"))
+//        checkEq("A {B| xxx {C|E}} D", Seq("A B D", "A xxx C D", "A xxx E D"))
     }
 }

Reply via email to