|go ahead... be a heretic|
Re: P6: Beginning grammarby moritz (Cardinal)
|on Jun 02, 2010 at 17:27 UTC||Need Help??|
The input string will be small; should I walk the string or walk the match object? As an exercise, treating the problem like a larger language appeals?
The idiomatic approach is not to iterate at all, but to define an action class with methods that generate the desired datastructures, and storing them in the ast attribute of the current match object.
The grammar chapter of our work-in-progress-book talks about this technique a bit
$match is supposed to work just like $/, yes?
Yes. And recent development versions of Rakudo also set $/ in Grammar.parse.
Since a few days Rakudo also supports the $/.perl method (Perl 6's built-in version of Data::Dumper), which shows you the structure of the match object.
Perl 6 - links to (nearly) everything that is Perl 6.