-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathEventRule.g4
More file actions
51 lines (47 loc) · 1.69 KB
/
EventRule.g4
File metadata and controls
51 lines (47 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
grammar EventRule;
// Tokens
AND: 'and';
OR: 'or';
NOT: 'not' | '!';
EQU: '=' | '==';
NEQ: '!=';
GT: '>';
LT: '<';
GTE: '>=';
LTE: '<=';
CONTAINS: 'contains';
NOTCONTAINS: 'not contains';
IN: 'in';
NOTIN: 'not in';
LIKE: 'like';
NOTLIKE: 'not like';
REGEX: 'regex';
NOTREGEX: 'not regex';
EXISTS: 'exists';
NOTEXISTS: 'not exists';
COMMA: ',';
NUMBER: [-]?[0-9]+('.'[0-9]+)?;
BOOLEAN: 'True'|'TRUE'|'true'|'False'|'FALSE'|'false';
STRING: '"' (ESC|.)*? '"';
//VAR: [a-zA-Z0-9_.-]+;
VAR: [a-zA-Z_][a-zA-Z0-9_-]*('['('*'|[0-9]+|(([0-9]+)?':'([0-9]+)?))']')?('.'[a-zA-Z_][a-zA-Z0-9_-]*('['('*'|[0-9]+|(([0-9]+)?':'([0-9]+)?))']')?('.')?)*;
WHITESPACE: [ \t\r\n] ->skip;
fragment
ESC: '\\"' | '\\\\';
// Rules
start
: expression EOF
;
expression
: expression op=(AND|OR) expression # AndOr
| NOT expression # Not
| '(' expression ')' # Parenthesis
| VAR op=(EQU|NEQ|GT|LT|GTE|LTE) (STRING|NUMBER) # Compare
| VAR op=(EQU|NEQ) BOOLEAN # BoolCompare
| VAR op=(CONTAINS|NOTCONTAINS) (STRING|NUMBER) # ContainsOrNot
| VAR op=(IN|NOTIN) '(' (NUMBER|STRING) (COMMA (NUMBER|STRING))* ')' # InOrNot
| VAR op=(REGEX|NOTREGEX|LIKE|NOTLIKE) STRING # RegexOrNot
| VAR op=(EXISTS|NOTEXISTS) # ExistsOrNot
| VAR # Variable
| NOT VAR # NotVariable
;