I need an algorithm and the C code that:
(1) Parses/tokenizes an expression string
(2) Evaluates the expression (to true or false)
The expression string is simiilar to something that can appear in the WHERE clause of a simple SQL query, e.g. ((price<3) OR ( height> 4)) AND ( quality = 5 ). So both logical and relational operators need to be supported. No arithmetic operators (e.g. +, -, *, / )need to be supported.
Before tokenizing the string, I will have to scan it and replace all the variables with known values (e.g. replace price with 2) so that I have enough information to evaluate the experssion.
The standard solution is probably to parse the string, convert infix to postfix and then evaluate the postfix expression. What I need is the implementation.
Eventually, I need to add support for LIKE SQL construct.