Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grammar fql;
- options {
- backtrack = false;
- }
- tokens {
- IMPORT = 'IMPORT';
- DEF = 'DEF';
- SELECT = 'SELECT';
- AND = 'AND';
- OR = 'OR';
- NOT = 'NOT';
- IF = 'IF';
- THEN = 'THEN';
- ELSE = 'ELSE';
- CASE = 'CASE';
- MATCH = 'MATCH';
- SWITCH = 'SWITCH';
- AS = 'AS';
- FROM = 'FROM';
- IN = 'IN';
- EXIT = 'EXIT';
- MODULE = 'MODULE';
- PUBLIC = 'PUBLIC';
- TRY = 'TRY';
- CATCH = 'CATCH';
- FILTER = 'FILTER';
- // Operators
- ASSIGN_OP = ':=';
- EQUAL_OP = '=';
- GREATER_OP = '>';
- GREATER_OR_EQUAL_OP = '>=';
- LESS_OP = '<';
- LESS_OR_EQUAL_OP = '<=';
- PLUS_OP = '+';
- INCREMENT_OP = '++';
- MINUS_OP = '-';
- DECREMENT_OP = '--';
- MULTIPLY_OP = '*';
- DIVIDE_OP = '/';
- }
- compilation_unit
- : module_def
- | function_def+ ;
- module_def
- : MODULE ident '(' function_def+ ')' ;
- function_def
- : PUBLIC DEF ident '=' function_decl ';'
- | DEF ident '=' function_decl ';' ;
- function_decl
- : select_statement
- | filter_statement ;
- select_statement
- : SELECT field_list FROM source ;
- filter_statement
- : FILTER ident '(' filter_list ')';
- field_list
- : ident ( ',' ident )* ;
- filter_list
- : 'FILTERLIST' ;
- source : ident ;
- // ---------------------------------------------------------------------------
- // L E X E R G R A M M A R
- // ---------------------------------------------------------------------------
- WHITESPACE : ( ' ' | '\t' | '\r' | '\n' )+ { $channel = HIDDEN; };
- ident : LETTER ( LETTER | DIGIT )* ;
- fragment LETTER : 'A'..'Z' | 'a'..'z' ;
- fragment DIGIT : '0'..'9';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement