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

Yeah, that's why I said "almost." You need to postprocess it a bit to get a proper syntax tree.
  • Comment on Re^4: Parsing Boolean expressions (hack)

Replies are listed 'Best First'.
Re^5: Parsing Boolean expressions (hack)
by LanX (Saint) on Apr 23, 2017 at 16:04 UTC
    > You need to postprocess it a bit to get a proper syntax tree.

    well ... a bit

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

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