I have string boolean queries like this
queryString= """And(
OR(abc,xyz,wxy),
AND(AND(xyz,wxy),xzy),
XOR(x1,y1, AND(xy,zz))
)"""
At current it is hard for me to modify the above query string, as I want to
- Add another
OR(x3,y3)
in the lastXOR
- Remove entire
OR(abc,xyz,wxy)
with desired output
resultQueryString= """And(
AND(AND(xyz,wxy),xzy),
XOR(x1,y1, AND(xy,zz),OR(x3,y3))
)"""
I think I cannot easily do it unless I come up with a sophisticated regex for each different query.
I am trying to write a python function which would take above string boolean query as input and output a tree data structure.
So that I can traverse the tree and evaluate or change whatever portion of query I want to change.
In above example, if I had it as a tree, I can easily see the root is AND
and traverse/modify other branches so on.