I have a grammar of RQL adapted for my work and it differs from the Oracle grammar. The main difference is that string literals are not surrounded by double quotes.
Model:
operands+=HoOperand ( (','|'&') HoOperand )*
;
And: '&' HoOperand;
Or: (';'|'|') HoOperand;
HoOperand:
WSP* ( HigherOrderCall | Comparison ) WSP*
;
HigherOrderCall:
LogicalOpAliases WSP* '(' ( HoOperand ( ',' HoOperand )* ) ')'
;
CompOps : ('!='|'='|'<'|'<='|'>'|'>=');
Comparison : Strval WSP* ( CompOps ) Strval;
Nchar: (ALPHA|DIGIT|'-'|'.'|'_'|'~'|'$'|':'|'*'|'+'|'?'|'/'|'@');
Pct_encoded: '%' XDIGIT XDIGIT;
Strval: (Nchar|Pct_encoded)+;
LogicalOpAliases: ('or'|'and'|'not');
terminal DIGIT: ('0'..'9');
terminal XDIGIT: (DIGIT|'A'..'F');
terminal ALPHA: ('A'..'Z'|'a'..'z');
terminal WSP: (' '|'\t');
I've encountered such a problem: because of the difference noticed earlier entries like or=a and or(a=a) match the different rules, the first matches Comparison and the second matches HigherOrderCall. Accordingly to this the first or matches Strval and the second matches LogicalOpAliases in those rules they are the different terminals and I need lexer to backtrack.
I've already read a similar question and the answer to it. I tried to include LogicalOpAliases in Strval, it solved this issue partially (entries like anf=a are considered to be mistaken because of the lexer greediness, it tries to consume and and doesn't backtrack).
How can I resolve this problem?
And the second question is about highlighting. In the entry or= where or matches string literal or is highlighted. I tried to make rule LogicalOpAliases terminal rule, but highlighting disappeared at all. How can I resolve this?