Perl 6 / Parrot Parrot Compiler Toolkit #24

Defining a bottom-up parser

1. Use Perl 6-like proto subs to define tokens

##  terms
token term { <value> {*} }
proto term: is parsed(&term) is precedence('=') { ... }

##  multiplicative
proto infix:<*> is looser('term:')      { ... }
proto infix:</> is equiv(infix:<*>)     { ... }

##  additive
proto infix:<+> is looser(infix:<*>)    { ... }
proto infix:<-> is equiv(infix:<+>)     { ... }

2. Add 'is optable' to entry rule for bottom-up parsing

rule expression is optable { ... }
Copyright © 2009
http://www.pmichaud.com/2009/pres/