start :
expression
;
expression
:
| dateOperatorExpression
| numberOperatorExpression
| stringOperatorExpression
| methodBooleanExpression
| doubleMethodOperatorExpression
| numberInExpression
| stringInExpression
| bracketExpression
| andExpression
| orExpression
| notExpression
;
numberInExpression:
| WS? METHOD WS? IN WS? '{' WS? NUMBER (WS? ',' WS? NUMBER)* '}' WS?
;
stringInExpression:
| WS? METHOD WS? IN WS? '{' WS? STRING (WS? ',' WS? STRING)* '}' WS?
;
dateOperatorExpression:
| WS? DATE WS? OPERATOR WS? DATE WS?
| WS? DATE WS? OPERATOR WS? METHOD WS?
| WS? METHOD WS? OPERATOR WS? DATE WS?
| WS? DATE WS? OPERATOR WS? NULLVALUE WS?
| WS? NULLVALUE WS? OPERATOR WS? DATE WS?
;
numberOperatorExpression:
| WS? NUMBER WS? OPERATOR WS? NUMBER WS?
| WS? NUMBER WS? OPERATOR WS? METHOD WS?
| WS? METHOD WS? OPERATOR WS? NUMBER WS?
| WS? NUMBER WS? OPERATOR WS? NULLVALUE WS?
| WS? NULLVALUE WS? OPERATOR WS? NUMBER WS?
;
stringOperatorExpression:
| WS? STRING WS? OPERATOR WS? STRING WS?
| WS? STRING WS? OPERATOR WS? METHOD WS?
| WS? METHOD WS? OPERATOR WS? STRING WS?
| WS? STRING WS? OPERATOR WS? NULLVALUE WS?
| WS? NULLVALUE WS? OPERATOR WS? STRING WS?
;
doubleMethodOperatorExpression:
| WS? METHOD WS? OPERATOR WS? METHOD WS?
| WS? METHOD WS? OPERATOR WS? NULLVALUE WS?
| WS? NULLVALUE WS? OPERATOR WS? METHOD WS?
;
methodBooleanExpression:
| WS? METHOD WS? OPERATOR WS? BOOLEAN WS?
| WS? BOOLEAN WS? OPERATOR WS? METHOD WS?
;
bracketExpression:
| '(' WS? expression WS? ')'
;
andExpression
:
| AND WS? '(' expression (',' expression)* WS? ')'
;
orExpression
:
| OR WS? '(' expression (',' expression)* WS? ')'
;
notExpression
:
| NOT WS? expression
;
WS: (' ' | '\t' | '\r' | '\n')+ -> skip;
AND: 'AND' | 'and';
OR: 'OR' | 'or';
NOT: 'NOT' | 'not' | '!';
IN: 'IN' | 'in';
OPERATOR: '==' | '!=' | '>' | '=' | '= 25), not(father.address.street != null)), firstName in {"John", "Pete"})
The parser only takes and((retired == true)) and ignores the rest. So, I thought about simply changing the grammar as follows, and then printing a warning of multiple expressions were parsed:
start :
(expression)+
;
But this gives the error: "rule start contains a closure with at least one alternative that can match an empty string". Why is that? How can (expression)+ match an empty string, if expression can't?
How can I achieve what I want?
Thanks,
0 comments:
Post a Comment
Thanks