I need to parse a boolean search string of keywords and operators into a SQL query to be executed from C# code. I think something like ANTLR is what I need for this task, but I'm not sure how to do it.
Are there any good tutorials on how to do this? Or maybe I need a different tool?
An example of what I mean is below. The only operators I need are AND and OR. I would also like to be able to use parenthesis.
input expression: (blue AND green) OR yellow
output:
SELECT * FROM table WHERE (CONTAINS(Description, "blue") AND CONTAINS(Description, "green")) OR >CONTAINS(Description, "yellow"
If possible I would also like to support implicit AND insertion. So the default operator if none is specified is AND.
input : green (blue OR yellow)
output: SELECT * FROM table WHERE CONTAINS(Description, "green") AND (CONTAINS(Description, "blue") OR >CONTAINS(Description, "yellow"))