Suppose I have a string such as this in a text file:
(((var1 AND var2 AND var3) OR var4) AND ((var5 OR var6) AND var7))
After parsing this into the C program and the vars are handled and set correctly it will end up looking something like this:
(((1 AND 0 AND 0) OR 1) AND ((0 OR 1) AND 1))
Are there any useful libraries out there for evaluating expressions that are represented as one string like this? I was thinking I could just call a Perl program with the string as an argument that would be able to return the result easily, but I wasn't sure if there was a library in C that did this, or if there are any known algorithms for solving such expressions?
What I'm actually looking for is something that would spit out an answer to this expression (maybe parse was a bad word) i.e. 1 or 0.
In a nutshell, it's a file containing a bunch of random expressions (already known to be in the right format) that need to be evaluated to either 0 or 1. (The example above evaluates to 1 because it results in (1 AND 1)).
You can embed lua in your program and then invoke it's interpreter to evaluate the expression.