2 ms·
I only know Perl 5, but I can figure out enough of it to give an educated guess. It seems like he's using the token returned by the grammar to select a method
by Natsu 16y ago
I only know Perl 5, but I can figure out enough of it to give an educated guess. It seems like he's using the token returned by the grammar to select a method of the same name. So when he gets the token e404, he'll call the method e404 which does a make "404: Not found"
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...
- colomon 16y agoYes, 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.