You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2021/02/20 18:24:20 UTC

[incubator-nlpcraft] branch NLPCRAFT-247 updated: Create NCMacroDsl.g4

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 10d364a  Create NCMacroDsl.g4
10d364a is described below

commit 10d364a9d1533a5fbfe3fb1eaee0aa34266cfd96
Author: Aaron Radzinski <ar...@apache.org>
AuthorDate: Sat Feb 20 10:24:08 2021 -0800

    Create NCMacroDsl.g4
---
 .../nlpcraft/common/makro/antlr4/NCMacroDsl.g4     | 113 +++++++++++++++++++++
 1 file changed, 113 insertions(+)

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
new file mode 100644
index 0000000..3742961
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/antlr4/NCMacroDsl.g4
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+grammar NCMacroDsl;
+
+line
+    : syn
+    | line syn
+    ;
+syn
+    :
+
+
+
+intent: intentId orderedDecl? flowDecl? terms EOF;
+intentId: 'intent' EQ ID;
+orderedDecl: 'ordered' EQ BOOL;
+flowDecl: 'flow' EQ qstring;
+terms: term | terms term;
+termEq: EQ | TILDA;
+term: 'term' termId? termEq LCURLY item RCURLY minMax?;
+termId: LPAREN ID RPAREN;
+item
+    : predicate
+    | LPAREN item RPAREN
+    | item (AND | OR) item
+    | EXCL item
+    ;
+predicate
+    : lval PRED_OP rval
+    | ID LPAREN lval RPAREN PRED_OP rval  // Function call.
+    ;
+lval: lvalQual? ('id' | 'aliases' | 'startidx' | 'endidx' | 'parent' | 'groups' | 'ancestors' | 'value' | meta);
+lvalQual: lvalPart | lvalQual lvalPart;
+lvalPart: ID DOT;
+rvalSingle
+    : 'null'
+    | MINUS? (INT | INT EXP)
+    | BOOL
+    | qstring
+    ;
+rval
+    : rvalSingle
+    | LPAREN rvalList RPAREN
+    ;
+rvalList
+    : rvalSingle
+    | rvalList COMMA rvalSingle
+    ;
+meta
+    : TILDA ID
+    | TILDA ID LBR INT RBR
+    | TILDA ID LBR qstring RBR
+    ;
+qstring: QSTRING;
+minMax: minMaxShortcut | minMaxRange;
+minMaxShortcut: PLUS | QUESTION | STAR;
+minMaxRange: LBR INT COMMA INT RBR;
+QSTRING: SQUOTE (~'\'')* SQUOTE;
+PRED_OP: '==' | '!=' | '>=' | '<=' | '>' | '<' | '@@' | '!@';
+AND: '&&';
+OR: '||';
+VERT: '|';
+EXCL: '!';
+LPAREN: '(';
+RPAREN: ')';
+LCURLY: '{';
+RCURLY: '}';
+SQUOTE: '\'';
+TILDA: '~';
+RIGHT: '>>';
+LBR: '[';
+RBR: ']';
+COMMA: ',';
+COLON: ':';
+MINUS: '-';
+DOT: '.';
+UNDERSCORE: '_';
+EQ: '=';
+PLUS: '+';
+QUESTION: '?';
+STAR: '*';
+DOLLAR: '$';
+POWER: '^';
+BOOL: 'true' | 'false';
+INT: '0' | [1-9][_0-9]*;
+EXP: DOT [0-9]+;
+ID: (UNDERSCORE|[a-z]|[A-Z])+([a-z]|[A-Z]|[0-9]|COLON|MINUS|UNDERSCORE)*;
+
+
+
+
+WORD: 
+
+WS: [ \r\t\u000C\n]+ -> skip ;
+
+ErrorCharacter
+  : .
+  ;