summaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/main/resources/antlr4
diff options
context:
space:
mode:
Diffstat (limited to 'aai-traversal/src/main/resources/antlr4')
-rw-r--r--aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g49
-rw-r--r--aai-traversal/src/main/resources/antlr4/org/onap/aai/dsl/v1/AAIDsl.g465
-rw-r--r--aai-traversal/src/main/resources/antlr4/org/onap/aai/dsl/v2/AAIDsl.g469
3 files changed, 140 insertions, 3 deletions
diff --git a/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4 b/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4
index 78162f5..3ba370c 100644
--- a/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4
+++ b/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4
@@ -13,11 +13,12 @@ vertex: label store? (filter)?;
traversal: (edge (vertex|unionVertex));
filter: (propertyFilter)* whereFilter?;
-propertyFilter: (not? '(' key (',' (key | num))* ')');
+propertyFilter: (not? '(' key (',' (key | num | bool))* ')');
+bool: BOOL;
whereFilter: (not? '(' edge nestedStatement ')' );
-unionVertex: '[' ( (edgeFilter)* nestedStatement ( comma ( (edgeFilter)* nestedStatement))*) ']';
+unionVertex: '[' ( (edgeFilter)* nestedStatement ( comma ( (edgeFilter)* nestedStatement))*) ']' store?;
comma: ',';
edge: TRAVERSE (edgeFilter)*;
@@ -31,11 +32,13 @@ key: KEY;
store: STORE;
not: NOT;
+BOOL: 'true'|'TRUE'|'false'|'FALSE';
LIMIT: 'LIMIT'|'limit';
NUM: (DIGIT)+;
/*NODE: (ID | NUM )+;*/
-KEY : '\'' ( ~['\r\n] )*? '\'';
+fragment ESCAPED_QUOTE : '\\' '\'';
+KEY : '\'' (ESCAPED_QUOTE | ~[\r\n] )*? '\'';
AND: [&];
diff --git a/aai-traversal/src/main/resources/antlr4/org/onap/aai/dsl/v1/AAIDsl.g4 b/aai-traversal/src/main/resources/antlr4/org/onap/aai/dsl/v1/AAIDsl.g4
new file mode 100644
index 0000000..3ba370c
--- /dev/null
+++ b/aai-traversal/src/main/resources/antlr4/org/onap/aai/dsl/v1/AAIDsl.g4
@@ -0,0 +1,65 @@
+/**
+ * Define a parser grammar called AAIDsl
+ */
+grammar AAIDsl;
+
+aaiquery: startStatement limit?;
+
+startStatement: (vertex ) (traversal)* ;
+nestedStatement: (vertex|unionVertex ) (traversal)* ;
+
+vertex: label store? (filter)?;
+
+traversal: (edge (vertex|unionVertex));
+
+filter: (propertyFilter)* whereFilter?;
+propertyFilter: (not? '(' key (',' (key | num | bool))* ')');
+bool: BOOL;
+
+whereFilter: (not? '(' edge nestedStatement ')' );
+
+unionVertex: '[' ( (edgeFilter)* nestedStatement ( comma ( (edgeFilter)* nestedStatement))*) ']' store?;
+
+comma: ',';
+edge: TRAVERSE (edgeFilter)*;
+edgeFilter: '(' key (',' key )* ')';
+
+num: NUM;
+limit: LIMIT num;
+label: (ID | NUM )+;
+key: KEY;
+
+store: STORE;
+not: NOT;
+
+BOOL: 'true'|'TRUE'|'false'|'FALSE';
+LIMIT: 'LIMIT'|'limit';
+NUM: (DIGIT)+;
+
+/*NODE: (ID | NUM )+;*/
+fragment ESCAPED_QUOTE : '\\' '\'';
+KEY : '\'' (ESCAPED_QUOTE | ~[\r\n] )*? '\'';
+
+AND: [&];
+
+STORE: [*];
+
+OR: [|];
+
+TRAVERSE: [>] ;
+
+EQUAL: [=];
+
+NOT: [!];
+
+fragment LOWERCASE : [a-z] ;
+fragment UPPERCASE : [A-Z] ;
+fragment DIGIT : [0-9] ;
+fragment ESC : '\\' . ;
+fragment ID_SPECIALS: [-:_];
+
+ID
+ : ( LOWERCASE | UPPERCASE | DIGIT | ID_SPECIALS)
+ ;
+
+WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
diff --git a/aai-traversal/src/main/resources/antlr4/org/onap/aai/dsl/v2/AAIDsl.g4 b/aai-traversal/src/main/resources/antlr4/org/onap/aai/dsl/v2/AAIDsl.g4
new file mode 100644
index 0000000..453c0fe
--- /dev/null
+++ b/aai-traversal/src/main/resources/antlr4/org/onap/aai/dsl/v2/AAIDsl.g4
@@ -0,0 +1,69 @@
+/**
+ * Define a parser grammar called AAIDsl
+ */
+grammar AAIDsl;
+
+aaiquery: startStatement limit?;
+
+startStatement: (vertex ) (traversal)* ;
+nestedStatement: (traversal)+ ;
+
+vertex: label store? (filter)?;
+
+//traversal: ( vertex|unionVertex edge);
+traversal: (edge* (vertex|unionVertex));
+
+filter: (selectFilter)* (propertyFilter)* whereFilter?;
+propertyFilter: (not? '(' key (',' (key | num | bool))* ')');
+selectFilter: (not? '{' key (',' key)* '}');
+bool: BOOL;
+
+whereFilter: (not? '(' nestedStatement ')' );
+
+unionVertex: '[' ( nestedStatement ( comma (nestedStatement))*) ']' store?;
+
+comma: ',';
+edge: ( TRAVERSE|DIRTRAVERSE) (edgeFilter)?;
+
+edgeFilter: '(' key (',' key )* ')';
+
+num: NUM;
+limit: LIMIT num;
+label: (ID | NUM )+;
+key: KEY;
+
+store: STORE | selectFilter;
+not: NOT;
+
+BOOL: 'true'|'TRUE'|'false'|'FALSE';
+LIMIT: 'LIMIT'|'limit';
+NUM: (DIGIT)+;
+
+/*NODE: (ID | NUM )+;*/
+fragment ESCAPED_QUOTE : '\\' '\'';
+KEY : '\'' (ESCAPED_QUOTE | ~[\r\n] )*? '\'';
+
+AND: [&];
+
+STORE: [*];
+
+OR: [|];
+DIRTRAVERSE: '>>' | '<<' ;
+
+TRAVERSE: '>' ;
+
+EQUAL: [=];
+
+NOT: [!];
+
+fragment LOWERCASE : [a-z] ;
+fragment UPPERCASE : [A-Z] ;
+fragment DIGIT : [0-9] ;
+fragment ESC : '\\' . ;
+fragment ID_SPECIALS: [-:_];
+
+ID
+ : ( LOWERCASE | UPPERCASE | DIGIT | ID_SPECIALS)
+ ;
+
+WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines