has anybody ever written a procedure that is able to receive a string and split it by logical precedence?
E.g.
Code: Select all
string.s = "(k1 != 2 OR ((m1 = 5 AND x1 = 7) OR extension = gif))"
k1, m1, x1 and extension are real variables.
They need to be resolved into their real value after splitting.
This would result in 3 necessary comparisons (in reality more are necessary, like m1 = 5, x1 = 7, etc.)
1. m1 = 5 AND x1 = 7
2. <boolean #True/#False result from 1.> OR extension = gif
3. k1 != 2 OR <boolean #True/#False result from 2.>
Every comparison leads to a #True / #False state (after the belonging variables have been resolved)
The comparison chain would exit once a single #False is one of the results.
E.g.
m1 -> Resolved to 5: 5 = 5 -> #True
x1 -> Resolved to 6: 6 = 7 -> #False
At this point the logical chain can be ended with a break.
If x1 would have been 7, the next comparison would have been:
#True OR extension = gif
Etc.
Any idea how to accomplish something like this with a generic approach?
Merci beaucoup!