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

Well, yeah. The postfix quote is the biggest irritation, but you can just run
for my $i (reverse 1 .. $#$e) { splice @$e, $i-1, 2, ["'", $e->[$i-1]] if $e->[$i] eq "'"; }
over each of the arrayrefs.

Replies are listed 'Best First'.
Re^7: Parsing Boolean expressions (hack)
by LanX (Saint) on Apr 23, 2017 at 16:40 UTC
    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!

      (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.