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

> You can almost parse the expression with the same technique.

not really, for a syntax tree you would need an [OP, arg1, arg2] format.

this

["B", "'", "+", ["C", "*", "D"], "'"]]

doesn't help without further parsing because precedence is still not resolved.

Rather

[ "or", [ "not" , "B" ] , [ "not", [ "and", "C", "D"] ] ]

without recursive parsing hard to achieve, I just delegated the hard part to Perl, deliberately ignoring what the OP didn't tell us yet.

edit

For instance if the = is not an assignment but a condition, he would want solutions for this equation system...

(which I could produce at least by brute force for small variable sets, if we had a guarantied format)

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

Replies are listed 'Best First'.
Re^4: Parsing Boolean expressions (hack)
by Anonymous Monk on Apr 23, 2017 at 16:00 UTC
    Yeah, that's why I said "almost." You need to postprocess it a bit to get a proper syntax tree.
      > 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.