John
8/29/2008 1:42:00 PM
Lex Williams wrote:
> Parse::RecDescent has RD_TRACE , which when is set to 1 , tells you
> which rule the parser it's trying , what it matches , what part of the
> input consumes , and so on . Does treetop have an equivalent to this ?
Each SyntaxNode has "interval", which is the range of byte-offsets matched,
and text_value, which returns that interval from the input.
You seem to have missed some fine diagnostic methods:
SyntaxNode#inspect shows a wealth of information, including an indented
node hierarchy, what input that node matched (abbreviated) and what
accessor methods are added by the modules extended into each node.
Parser#failure_reason tells you where it got to, and what tokens would
have allowed it to get further.
If that isn't enough, try calling your grammar from a lower-level rule
and working up until you see where it's failing.
Also don't forget that there's a "tt" command you can use to generate
the grammar into a ruby file you can inspect.
As for your earlier query, it's a known bug.
Clifford Heath.