2021-06-10 22:08:22 +07:00
|
|
|
grammar SimpleBoolean;
|
|
|
|
@header {
|
|
|
|
package org.idempiere.expression.logic;
|
|
|
|
}
|
|
|
|
parse
|
|
|
|
: expression EOF
|
|
|
|
;
|
|
|
|
|
|
|
|
expression
|
|
|
|
: LPAREN expression RPAREN #parenExpression
|
|
|
|
| NOT expression #notExpression
|
|
|
|
| left=expression op=comparator right=expression #comparatorExpression
|
|
|
|
| left=expression op=binary right=expression #binaryExpression
|
|
|
|
| bool #boolExpression
|
|
|
|
| VARIABLE #contextVariables
|
2022-08-05 18:21:50 +07:00
|
|
|
| QCSVTEXT #quotedCSVText
|
2021-06-10 22:08:22 +07:00
|
|
|
| QTEXT #quotedText
|
2022-08-05 18:21:50 +07:00
|
|
|
| DQCSVTEXT #doubleQuotedCSVText
|
2021-06-10 22:08:22 +07:00
|
|
|
| DQTEXT #doubleQuotedText
|
|
|
|
| TEXT #text
|
|
|
|
| DECIMAL #decimalExpression
|
|
|
|
;
|
|
|
|
|
|
|
|
comparator
|
|
|
|
: GT | GE | LT | LE | EQ | NE | RE
|
|
|
|
;
|
|
|
|
|
|
|
|
binary
|
|
|
|
: AND | OR
|
|
|
|
;
|
|
|
|
|
|
|
|
bool
|
|
|
|
: TRUE | FALSE
|
|
|
|
;
|
|
|
|
|
|
|
|
AND : '&' ;
|
|
|
|
OR : '|' ;
|
|
|
|
NOT : '$!';
|
|
|
|
TRUE : 'true' ;
|
|
|
|
FALSE : 'false' ;
|
|
|
|
GT : '>' ;
|
|
|
|
GE : '>=' ;
|
|
|
|
LT : '<' ;
|
|
|
|
LE : '<=' ;
|
|
|
|
EQ : '=' ;
|
|
|
|
NE : [!^] ;
|
|
|
|
RE : '~' ;
|
|
|
|
LPAREN : '(' ;
|
|
|
|
RPAREN : ')' ;
|
|
|
|
DECIMAL : '-'? [0-9]+ ( '.' [0-9]+ )? ;
|
|
|
|
VARIABLE : '@'(.*?)'@' ;
|
2022-08-05 18:21:50 +07:00
|
|
|
COMMA : ',' ;
|
|
|
|
QCOMMA : '\',' ;
|
2021-06-10 22:08:22 +07:00
|
|
|
QTEXT : ['](.*?)['] ;
|
2022-08-05 18:21:50 +07:00
|
|
|
QCSVTEXT : [']~(['])*(QCOMMA)(QTEXT)(COMMA QTEXT)* ;
|
|
|
|
DQCOMMA : '",';
|
2021-06-10 22:08:22 +07:00
|
|
|
DQTEXT : ["](.*?)["] ;
|
2022-08-05 18:21:50 +07:00
|
|
|
DQCSVTEXT : ["]~(["])*(DQCOMMA)(DQTEXT)(COMMA DQTEXT)* ;
|
2021-06-10 22:08:22 +07:00
|
|
|
TEXT : [a-zA-Z_0-9,]+ ;
|
|
|
|
WS : [ \r\t\u000C\n]+ -> skip;
|