aboutsummaryrefslogtreecommitdiffstats
path: root/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4
diff options
context:
space:
mode:
Diffstat (limited to 'sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4')
-rwxr-xr-xsli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g466
1 files changed, 66 insertions, 0 deletions
diff --git a/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4 b/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4
new file mode 100755
index 0000000..51f4016
--- /dev/null
+++ b/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4
@@ -0,0 +1,66 @@
+grammar ExprGrammar;
+
+options {
+ language = Java;
+}
+
+
+COMPAREOP : '==' | '!=' | '>' | '<' | '>=' | '<=';
+
+RELOP : 'and' | 'or';
+
+ADDOP : '+' | '-';
+
+MULTOP : '/' | '*';
+
+NUMBER : ('0'..'9')+;
+
+STRING : '\'' ~[\']* '\'';
+
+IDENTIFIER : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'-')*;
+
+// CONTEXT_VAR : '$' IDENTIFIER;
+
+WS: [ \n\t\r]+ -> skip;
+
+constant : NUMBER | STRING ;
+
+variableLead : ('$')? variableTerm ;
+
+variableTerm : IDENTIFIER ('[' expr ']')? ;
+
+variable : variableLead ('.' variableTerm)* ('.')?;
+
+// variable : CONTEXT_VAR ( '[' expr ']' )? ('.' IDENTIFIER )? ;
+
+atom : constant | variable;
+
+
+expr : atom
+ | parenExpr
+ | multExpr
+ | addExpr
+ | compareExpr
+ | relExpr
+ | funcExpr;
+
+parenExpr : '(' expr ')';
+
+term : atom | parenExpr | funcExpr;
+
+multExpr : term (MULTOP term)*;
+
+addExpr : multExpr (ADDOP multExpr)*;
+
+compareExpr : addExpr COMPAREOP addExpr;
+
+relExpr : compareExpr (RELOP expr)*;
+
+funcExpr : IDENTIFIER '(' expr (',' expr)* ')';
+
+
+
+
+
+
+