I am working with treetop in order to parse an SQL log. i was wondering if the parsing fails is there any way to know which rule(s) it was trying to match when it failed?
Thanks,
Josh
Because PEGs have unlimited backtracking, there is no clearly-defined meaning for "which rule failed".
The "failure_reason" is constructed from the terminal rules that failed at the *furthermost* point reached.
It's not hard to hack Treetop::Runtime::TerminalParseFailure#initialize to save the stack trace returned
by "caller" in an instance variable, which allows you to inspect what the stack trace was at the time of
each such failure. Hellishly expensive in memory, but it enables you to look back and see what the rule
nesting was.
Clifford Heath.