| | -/* Relational eXpression Map |
| | - */ |
| | +/* Relational eXpression Map */ |
| | grammar Query ; |
| | |
| | -query: start line ; |
| | -/*query: start line where? EOF ;*/ |
| | +/* Define the keywords first (otherwise T_ID would match first). */ |
| | +T_ROOT : 'root' ; |
| | +T_IMPORT: 'import' ; |
| | +T_MODULE: 'module' ; |
| | + |
| | +/* Define the symbols. */ |
| | +T_POP : '^' ; |
| | +T_GLOB : '.*' ; |
| | +T_MAP : '>' ; |
| | +T_INNER : '+>' ; |
| | +T_OUTER : '->' ; |
| | +T_SEP : ',' ; |
| | +T_WHERE : ';' ; |
| | + |
| | +/* Define the table and path symbols. */ |
| | +T_PERIOD: '.' ; |
| | +T_AT : '@' ; |
| | +T_SLASH : '/' ; |
| | + |
| | +/* Define the identifier. */ |
| | +T_ID : [A-Za-z0-9_]+ ; |
| | + |
| | +/* Define skippable tokens. */ |
| | +T_EOL : [\r\n]+ -> skip; |
| | +T_WS : [ \t\r\n]+ -> skip ; |
| | + |
| | +/* Define the WHERE clause symbols. */ |
| | +T_COMP_EQ : '=' ; |
| | +T_COMP_INEQ : '<>' ; |
| | +T_COMP_LT : '<' ; |
| | +T_COMP_GT : '>' ; |
| | +T_COMP_LTE : '<=' ; |
| | +T_COMP_GTE : '>=' ; |
| | + |
| | +T_LOGIC_AND : '&&' ; |
| | +T_LOGIC_OR : '||' ; |
| | + |
| | +T_EXPR_OPEN : '(' ; |
| | +T_EXPR_CLOSE: ')' ; |
| | + |
| | +query: start line where? EOF ; |
| | |
| | /* Define the root, line map, and JOIN clauses. |
| | */ |
| | -start: (root | module) TOKEN_TERM ; |
| | -root : TOKEN_ROOT TOKEN_MAP element ; |
| | +start: (root | module) T_SEP ; |
| | +root : T_ROOT T_MAP element ; |
| | line : statement+ ; |
| | |
| | -statement: (TOKEN_POP | TOKEN_GLOB | map | iJoin | oJoin | include) TOKEN_TERM ; |
| | -map : entity TOKEN_MAP node ; |
| | -iJoin : tableColumn TOKEN_INNER tableColumn ; |
| | -oJoin : tableColumn TOKEN_OUTER tableColumn ; |
| | -include : TOKEN_IMPORT TOKEN_ID ; |
| | -module : TOKEN_MODULE TOKEN_ID ; |
| | +statement: (T_POP | T_GLOB | map | iJoin | oJoin | include) T_SEP ; |
| | +map : entity T_MAP node ; |
| | +iJoin : tableColumn T_INNER tableColumn ; |
| | +oJoin : tableColumn T_OUTER tableColumn ; |
| | +include : T_IMPORT T_ID ; |
| | +module : T_MODULE T_ID ; |
| | |
| | -table : TOKEN_ID ; |
| | -column : TOKEN_PERIOD TOKEN_ID ; |
| | +table : T_ID ; |
| | +column : T_PERIOD T_ID ; |
| | tableColumn: table column ; |
| | |
| | -attribute : TOKEN_AT TOKEN_ID ; |
| | -element : TOKEN_ID ; |
| | -path : element TOKEN_SLASH element ; |
| | +attribute : T_AT T_ID ; |
| | +element : T_ID ; |
| | +path : element T_SLASH element ; |
| | + |
| | entity : table | column ; |
| | -node : element | attribute ; |
| | +node : element | attribute | path ; |
| | |
| | -/* Define the tokens. |
| | +/* Define the WHERE clause. |
| | */ |
| | -TOKEN_ID : [A-Za-z0-9_]+ ; |
| | -TOKEN_EOL : [\r\n]+ -> skip; |
| | -TOKEN_WS : [ \t\r\n]+ -> skip ; |
| | -TOKEN_POP : '^' ; |
| | -TOKEN_GLOB : '.*' ; |
| | -TOKEN_ROOT : 'root' ; |
| | -TOKEN_MAP : '>' ; |
| | -TOKEN_INNER : '+>' ; |
| | -TOKEN_OUTER : '->' ; |
| | -TOKEN_IMPORT: 'import' ; |
| | -TOKEN_MODULE: 'module' ; |
| | -TOKEN_TERM : ',' ; |
| | +where : T_WHERE ; |
| | |
| | -TOKEN_PERIOD : '.' ; |
| | -TOKEN_AT : '@' ; |
| | -TOKEN_SLASH : '/' ; |
| | +/* |
| | +expression : tableColumn () tableColumn ; |
| | + |
| | + |
| | +WEmpty. Where : Where ; |
| | +WEq. Where : TableColumn ComparatorOperatorEquality AllValues ; |
| | +WComp. Where : TableColumn ComparatorOperator Value ; |
| | +WLogic. Where : Where LogicalOp Where ; |
| | +WParen. Where : "(" Where ")" ; |
| | +*/ |
| | |
| | |