I don't have a compilers background so I am not sure if this is a commmon thing in that area. Are there any standard techniques to parse expressions like this? (Say, tab indicates the depth)
And
A + B = 1
C + D = 1
Or
P + Q = 1
K = 1
And
Q = 1
R = 2
Should be parsed as:
((A+B=1) AND (C+D=1) AND ((P+Q=1) OR (K=1)) AND ((Q=1) AND (R=2)))
I am not sure if I should resort to a stack based evaluation? I am currently trying out one and I'll post a working code if I can get it running.
Any suggestions on a simple way to achieve this?
eval()
or similar? For example,((A+B==1) and (C+D==1))
is Python syntax. – Turncoat((A+B=1) AND (C+D=1)...
a "string representation of the input" already? – Turncoat