1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-16 11:37:36 +02:00
ferret/pkg/parser/antlr/FqlLexer.g4
Tim Voronov 5620be211c
Next (#214)
* Renamed DOCUMENT to PAGE

* Added PageLoadParams

* Added PageLoadParams

* Renamed LoadPageParams -> PageLoadParams

* Added support for context.Done() (#201)

* Bug/#189 operators precedence (#202)

* Fixed math operators precedence

* Fixed logical operators precedence

* Fixed array operator

* Added support for parentheses to enforce a different operator evaluation order

* Feature/#200 drivers (#209)

* Added new interfaces

* Renamed dynamic to cdp driver

* Renamed drivers

* Added ELEMENT_EXISTS function (#210)

* Renamed back PAGE to DOCUMENT (#211)

* Added Getter and Setter interfaces
2018-12-21 23:14:41 -05:00

108 lines
2.0 KiB
ANTLR

lexer grammar FqlLexer;
// Skip
MultiLineComment: '/*' .*? '*/' -> channel(HIDDEN);
SingleLineComment: '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN);
WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN);
LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN);
// Punctuation
Colon: ':';
SemiColon: ';';
Dot: '.';
Comma: ',';
OpenBracket: '[';
CloseBracket: ']';
OpenParen: '(';
CloseParen: ')';
OpenBrace: '{';
CloseBrace: '}';
// Comparison operators
Gt: '>';
Lt: '<';
Eq: '==';
Gte: '>=';
Lte: '<=';
Neq: '!=';
// Arithmetic operators
Multi: '*';
Div: '/';
Mod: '%';
Plus: '+';
Minus: '-';
MinusMinus: '--';
PlusPlus: '++';
// Logical operators
And: 'AND' | '&&';
Or: 'OR' | '||';
// Other operators
Range: Dot Dot;
Assign: '=';
QuestionMark: '?';
RegexNotMatch: '!~';
RegexMatch: '=~';
// Keywords
// Common Keywords
For: 'FOR';
Return: 'RETURN';
Distinct: 'DISTINCT';
Filter: 'FILTER';
Sort: 'SORT';
Limit: 'LIMIT';
Let: 'LET';
Collect: 'COLLECT';
SortDirection: 'ASC' | 'DESC';
None: 'NONE';
Null: 'NULL';
BooleanLiteral: 'TRUE' | 'true' | 'FALSE' | 'false';
// Group operators
Into: 'INTO';
Keep: 'KEEP';
With: 'WITH';
Count: 'COUNT';
All: 'ALL';
Any: 'ANY';
Aggregate: 'AGGREGATE';
// Unary operators
Like: 'LIKE';
Not: 'NOT' | '!';
In: 'IN';
// Literals
Param: '@';
Identifier: Letter+ (Symbols (Identifier)*)* (Digit (Identifier)*)*;
StringLiteral: SQString | DQSring;
TemplateStringLiteral: '`' ('\\`' | ~'`')* '`';
IntegerLiteral: [0-9]+;
FloatLiteral
: DecimalIntegerLiteral Dot [0-9]+ ExponentPart?
| DecimalIntegerLiteral ExponentPart?
;
// Fragments
fragment HexDigit
: [0-9a-fA-F]
;
fragment DecimalIntegerLiteral
: '0'
| [1-9] [0-9]*
;
fragment ExponentPart
: [eE] [+-]? [0-9]+
;
fragment Letter
: 'A'..'Z' | 'a'..'z'
;
fragment Symbols: '_';
fragment Digit
: '0'..'9'
;
fragment DQSring: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"';
fragment SQString: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\'';