in reply to Re^6: Parsing Boolean expressions (hack)
in thread Parsing Boolean expressions

without commenting on your code ...

there is not only binary vs postfix, also operator precedence and associativity to be respected!

see perlop#Operator-Precedence-and-Associativity

e.g A+B*C must be A+(B*C)

I just presumed Perl rules for the interpretation and was lucky Perl has two level of logical ops allowing me to emulate the postfix negation with an xor.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

  • Comment on Re^7: Parsing Boolean expressions (hack)

Replies are listed 'Best First'.
Re^8: Parsing Boolean expressions (hack)
by Anonymous Monk on Apr 23, 2017 at 18:01 UTC
    (Back from walking the dog.) If you need to worry about and/or precedence, you can do essentially the same thing for ands (with left associativity if you scan from left to right). But sometimes formal logic people require expressions to be fully parenthesized (as the OP's are), so you might not need to. Yes, I see that you got precedence and associativity for free and I didn't.