richard5mith has asked for the wisdom of the Perl Monks concerning the following question:
I've got a problem with Parse::RecDescent where it doesn't appear to be passing on subrule arguments. The grammar works fine otherwise, but the "parameter" rule does not seem to get any value for $arg[0], which should contain the name of the function matched in the "functiondefine" rule.
This is simplified example, but it is the basics of the problem...
use Parse::RecDescent; $grammar = << 'STOP'; functiondefine: /function/i name "(" parameter[ $item[2] ](s? /,/) +")" "{" name: /[A-Za-z][a-zA-Z0-9_]*/ parameter: name /as/i variabletype { warn $arg[0] } variabletype: /variant/i | /array/i | /keyarray/i STOP $parser = new Parse::RecDescent($grammar); $text = << 'STOP'; function myfunction(something as variant, somethingelse as array, foo +as keyarray) { } STOP $parser->functiondefine($text);
The result of which is...
Warning: something's wrong at (eval 15) line 168.
Warning: something's wrong at (eval 15) line 168.
Warning: something's wrong at (eval 15) line 168.
Meaning that $arg[0] isn't getting set.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with Parse::RecDescent and subrule arguments
by ikegami (Patriarch) on Aug 26, 2004 at 00:36 UTC | |
by richard5mith (Beadle) on Aug 26, 2004 at 17:04 UTC | |
|
Re: Problem with Parse::RecDescent and subrule arguments
by jryan (Vicar) on Aug 26, 2004 at 00:30 UTC |