Parrot Parrot Compiler Toolkit #47

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 © 2008 Patrick R. Michaud
http://www.pmichaud.com/2008/pres/