in reply to Re^2: Parsing Boolean expressions
in thread Parsing Boolean expressions

> I think whatever output format that module uses will probably be fine.

well then ... taking output from Re: Parsing Boolean expressions (hack)

$ perl -MO=Terse -e ' $Y = ( $A or ($B^1 or ($C and $D)^1) );' LISTOP (0x8570520) leave [1] OP (0x85a2968) enter COP (0x856fff8) nextstate BINOP (0x8570500) sassign UNOP (0x85704e0) null LOGOP (0x85704c0) or UNOP (0x856ffb8) null [15] PADOP (0x8570050) gvsv GV (0x856a758) *A UNOP (0x85704a0) null LOGOP (0x8659ee0) or BINOP (0x856ff78) bit_xor [4] UNOP (0x856ff58) null [15] PADOP (0x856ff38) gvsv GV (0x856a7bc) + *B SVOP (0x856ff08) const [8] IV (0x856a71c) +1 BINOP (0x8659ec0) bit_xor [7] UNOP (0x8659e80) null LOGOP (0x8659e60) and UNOP (0x8570180) null [15] PADOP (0x85700c8) gvsv GV (0x +856a7a8) *C UNOP (0x8659e40) null [15] PADOP (0x859fd50) gvsv GV (0x +856a7e4) *D SVOP (0x8659ea0) const [9] IV (0x856a7d0) +1 UNOP (0x8570140) null [15] PADOP (0x856edd8) gvsv GV (0x856a730) *Y

et voila! ;-P

And see B::Concise for even more formating options.

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

Replies are listed 'Best First'.
Re^4: Parsing Boolean expressions
by Anonymous Monk on Apr 23, 2017 at 19:06 UTC
    Does B:: provide a way to look at the optree directly, or do you have to dump it to text and reparse?
      These modules like B::Deparse and B::Concise are implemented in Perl and use B to "walk" the optree and generate the text output.

      Just peek into the code to see how.

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

        Cool, thanks!