Parrot Perl6Grammar compiler and parsers #27

Rules

Grammar:

rule  TOP     { <integer> <addop> <integer> {*} }
token integer { \d+ {*} }
token addop   { [ '+' | '-' ] {*} }

Result:

$ ./calc --target=parse
> 12 + 45
"parse" => PMC 'Calc;Grammar' => "12 + 45\n" @ 0 {
    <integer> => ResizablePMCArray (size:2) [
        PMC 'Calc;Grammar' => "12" @ 0,
        PMC 'Calc;Grammar' => "45" @ 5
    ]
    <addop> => PMC 'Calc;Grammar' => "+" @ 3
}
Copyright © 2009
http://www.pmichaud.com/2009/pres/