diff options
author | 2020-04-17 16:46:13 -0400 | |
---|---|---|
committer | 2020-04-20 09:10:49 -0400 | |
commit | 87f84fdb2df41aa7c00de94018fe606939d4d6f7 (patch) | |
tree | 0badd3a0d4bde6c899b3ea51286d0799dda05487 /aai-traversal/src/main/resources/antlr4/org | |
parent | 5cf32ed7941231f55819a6f5e39e7f674d174009 (diff) |
update traversal processing for v19
Issue-ID: AAI-2866
Change-Id: I344e095e6f1d3b117971c1c78e50ae58bebf27e4
Signed-off-by: LaMont, William(wl2432) <wl2432@att.com>
Diffstat (limited to 'aai-traversal/src/main/resources/antlr4/org')
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 |