I have a black box processing system that accepts boolean expressions but does not support parentheses. I want to input a boolean expression like this:
A && (B || C)
However, when I input it as:
A && B || C
it evaluates expressions as if I had entered:
(A && B) || C
Is there any way to rewrite my expression to get the desired behavior of A && (B || C) without parentheses? Thanks!
There's a relation between precedence but, you can use associative and distributive laws to resolve this.
A && B || A && C
Truth tables match.
Be careful when implementing this. Not all compilers and languages use the same precedence and evaluation order.