troubleshooting Question

How do I Evaluation Parenthesized Relational and Logical Expressions in C (I need both the C Code & the Algorithm)

Avatar of ChairmanOfTheBored
ChairmanOfTheBored asked on
Programming Languages-OtherEditors IDEs
2 Comments1 Solution371 ViewsLast Modified:
Dear Experts,
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.

Thank you!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros