Reverse Polish boolean operations with stack size of one.

326 Views Asked by At

I'd like to evaluate a boolean expression:

$AB + CD + ... + YZ$

But the engine with which I can evaluate expressions operates in reverse polish with a stack size of one. For example, I can evaluate $AB + C$ as:

$((\text{A B and}) \text{ C or})$

But for $AB + CD$ and other more complex statements, I'm not sure whether or not it is possible to evaluate with a single stack slot.

So my questions are: What are the limits of a stack size of one when evaluating arbitrary AND/OR boolean expressions? Is it possible to re-factor my original expression into single serial operations?