Parse::RecDescent::FAQ is the official, authorized FAQ for Parse::RecDescent.
Is Parse::RecDescent LL(1)? LL(N)? LR(1)? LR(N)?
Answer by Yves Orton:
I have a data structure which is
a hash of entries where an entry is a list/array of sets
I have also a grammar that can parse the syntax of the text files that contain the data I want to fill this structure with. Until here everything is ok.
Problem: I cannot figure out how to actually FILL the parsed data into the structure. I can only decide if a string is grammatically correct or not.
Also see the "Left-recursion" section under "PARSER BEHAVIOR"
Flags you can set
Paraphrased from Yves Orton:
To understand more about why your parser is not behaving as it should take advantage of the follow variables:
$::RD_ERRORS # unless undefined, report fatal errors
$::RD_WARN # unless undefined, also report non-fatal problems
$::RD_HINT # if defined, also suggestion remedies
$::RD_TRACE # if defined, also trace parsers' behaviour
Making warning line numbers correspond to your grammar
How do I match the line numbers with the actual contents of my script?
At present, you can't (but that's on the ToDo list). Setting $::RD_TRACE can be useful though:
Once you've run with $RD_TRACE, do this:
perl -w RD_TRACE
Then go and examine the actual line numbers given for the error in the file RD_TRACE.
That will show you the actual generated code that's the problem.
That code will, in turn, give you a hint where the problem is in the grammar (e.g. find out which subroutine it's in, which will tell you the name of the offending rule).