Perl 6 Compiler Design and Implementation of the Perl 6 Compiler #23

Results of operator precedence parsing

$P0 = p6rule("<opparse>")

$P1 = $P0("a + b * 4")
$P1."dump"("$/")

produces

$/: <a + b * 4 @ 0> 
$/<opparse>: <a + b * 4 @ 0> opname=infix:+
$/<opparse><token>: <+ @ 2> 
$/<opparse><args>[0]: <a @ 0> 
$/<opparse><args>[1]: <b * 4 @ 4> opname=infix:*
$/<opparse><args>[1]<token>: <* @ 6> 
$/<opparse><args>[1]<args>[0]: <b @ 4> 
$/<opparse><args>[1]<args>[1]: <4 @ 8> 
Copyright © 2005 Patrick R. Michaud