Assuming this does what I think it does, you're throwing away the function signature and body by only returning $item[2]. You might try this instead...function_method: 'function' identifier paren_statement brace { $return = $item[2]; }
function_method: 'function' identifier paren_statement brace { $return = \@item; }
The power of writting Parsers like this is that you can build your data structures as you parse the file. By flattening out the results from your parser, you're throwing away a lot of the functionality you could have. Considering your goal, you might want to make all of your handlers just return \@item, that should cause your parser to build "a complete parse tree" of your javascript files. Then you can walk it and do whatever you want with it.
Update: Don't try \@item. On a whim
I installed Parse::RecDescent to see if I was right, and
ran into a deep recursion problem. Evidently
@item is a more complicated array then I
thought (i figured it was just the individual tokens
... now i'm curios to go read the docs and understand
how this module works).
Bottom line: dmmiller2k
is probably right, your grammer seems very specific in
some ways and very general in others -- you should try
to make it more specific about the things you care about,
and more general about the things you don't.
In reply to Re: Rec::Descent Woes - Parsing JavaScript Files and Other Issues
by hossman
in thread Rec::Descent Woes - Parsing JavaScript Files and Other Issues
by Incognito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |