I'm contacting you because I currently have the need to parse (what could be transcripted as) boolean expression in order to say which members have to be 1 or not.
To be clear with the topic here's an example. I have this equation:
equ = ((((SIPROT:1 INTERACT (((((((ACTIVE_drawing OR ACTIVE_hd) OR ACTIVE_dm) OR PDIFF_drawing) OR NDIFF_drawing) NOT polyact_sign_mkr) NOT ((COPY (NWELL_drawing OR NWELL_hd)) AND (((((ACTIVE_drawing OR ACTIVE_hd) OR ACTIVE_dm) OR PDIFF_drawing) OR NDIFF_drawing) NOT polyact_sign_mkr))) NOT ((COPY (PPLUS_drawing OR PPLUS_hd)) OR (COPY ((NPLUS_drawing OR NPLUS_dm) OR NPLUS_hd))))) INSIDE RHDMY_drawing) INTERACT ((((COPY ((NPLUS_drawing OR NPLUS_dm) OR NPLUS_hd)) AND (((((ACTIVE_drawing OR ACTIVE_hd) OR ACTIVE_dm) OR PDIFF_drawing) OR NDIFF_drawing) NOT polyact_sign_mkr)) INTERACT (N(((((ACTIVE_drawing OR ACTIVE_hd) OR ACTIVE_dm) OR PDIFF_drawing) OR NDIFF_drawing) NOT polyact_sign_mkr) INTERACT ((COPY (PPLUS_drawing OR PPLUS_hd)) AND (((((ACTIVE_drawing OR ACTIVE_hd) OR ACTIVE_dm) OR PDIFF_drawing) OR NDIFF_drawing) NOT polyact_sign_mkr)))) NOT NLDEMOS_FINAL)) OUTSIDE (COPY GO2_25_drawing))
This is describing the equation of a shape, involving the drawing of several others, drawn in different "colors".
So the inputs of my equation are the "colors", like ACTIVE_drawing
for example. My goal is to say, having this equation, what colors are mandatory, forbidden, or optional, to have equ=1
. That's why I'm talking about a truth table.
The equation is not really boolean, but can be processed to be. INTERACT
can be replaced by AND
, COPY
can be removed and maybe other operations might be needed.
So my question is not on the way to replace my equation in order to have a "real boolean" one, but on the algorithm to implement in order to correctly parse the boolean expression to have the corresponding truth table.
Do you guys have some hints about it? I'm working in Perl to generate the equation, so I'd like to keep it, but if you know another tool that could take my input to process it, why not.