|
|
| The stupid question is the question not asked | |
| PerlMonks |
Re^3: P6: Beginning grammarby moritz (Cardinal) |
| on Jun 08, 2010 at 06:47 UTC ( #843621=note: print w/ replies, xml ) | Need Help?? |
|
I forgot to mention, some of the features of Match objects need the latest Rakudo development version, the release lags behind. Is the string eval reasonable here? Yes, though you can easily avoid it with a hash:
Again, hash slices on Match objects likely require a new version of Rakudo built from source. Can the expression rule be handled without the separate naming of the lhs and rhs? Is there a way to access each numeric in something like: rule expression { <numeric> <op> <numeric> } First of all you can do the renaming inline:
I'd prefer this solution for clarity. However you can also use <numeric> twice in the same regex, in which case $<numeric> becomes and array. Then you can access the left and right side as $<numeric>[0] and $<numeric>[1]. rule expression { <lhs> ( <op> <rhs> )+ } The corresponding action method might look like this:
I hope this helps. Update: Here's a complete, working example that also passes the action down as an AST:
Perl 6 - links to (nearly) everything that is Perl 6.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||