I'm using antlr for parse sql condition queries like:
[where] Field1 = "Param1" and Field2 = "Param2"
for this case I have an antlr condition:
andExpr
: inExpr
(
AND^
inExpr
)*
;
inExpr
: (eqcompareExpr)
(
IN^
args
)?
;
eqcompareExpr
: (compareExpr)
(
(EQUAL^|NOTEQ^|IS^|LIKE^)
(compareExpr)
)?
;
compareExpr
: addExpr
(
(LESS^|MORE^|LESSEQ^|MOREEQ^)
addExpr
)?
;
and tokens like:
LIKE : "like"
;
AND : "and"
;
OR : "or"
How do I change the antlr code for add combined conditions with 'contains' like:
[where] Field1 = "Param1" and Contains (Field2, "Param2")
Also the queries can be like this:
[where] Contains (Field2, "Param2")
or
[where] Field1 = "Param1" or Contains (Field2, "Param2")
^
operators), and in your lexer rules you're using double quotes (OR : "or";
), which suggests ANTLR v2. Which version are you using, and why not go for the most recent version, v4?