Re:Perl 6 Grammars – not only for parsing
by colomon on Tuesday November 23, 2010 @04:15PM
(#1935397)
Yes, using
Mysite.parse($req, :actions(Mysite::Actions.new))
says "Parse $req using grammar Mysite and actions Mysite::Actions.new." When a token is found, the action method with the same name is called. As I understand it, the idea with separating token and action like that is one grammar can be associated with more than one set of actions.
The grammar is something new in Perl 6, but it looks like there are a bunch of regexes that match different tokens. That makes me wonder how well it handles a buggy, ambiguous grammar, where the regexes overlap and something could be parsed as a token of two or more types. First rule wins?
Guess I should read some of chromatic's book over Thanksgiving so I'd understand more of this...