Parrot Perl6Grammar compiler and parsers #14

Embedded PIR

Grammar:

regex integer { \d+
    {{ print "found an integer "
       say match }}
}

regex addop { [ '+' | '-' ]
    {{ print "found an addop "
       say match }}
}

Result:

$ ./calc --target=parse
> 3+4
found an integer 3
found an addop +
found an integer 4
"parse" => PMC 'Calc;Grammar' => "3+4" @ 0 {
...
Copyright © 2009
http://www.pmichaud.com/2009/pres/