I am struggling to follow PegJS traces, specifically to understand how the parser engine proceeds in testing for matches.
I understand the basics of a trace statement, eg. the text portion being matched, whether the rule passes of fails and the name of the function, as shown below.
4:1-4:1 rule.fail table_or_sub_sub
However whats confusing, is what happens when a rule fails and it proceeds to check the next condition.
I found that the backtrace (https://github.com/okaxaki/pegjs-backtrace) is useful but it is not accurate in some instances i.e. it doesn't show all functions that were called. This was verified against the standard tracer. I've also tried https://www.npmjs.com/package/better-peg-tracer but this takes too long and is too verbose.
In summary it would be great to have a guide that specifies:
- Best practices for reading traces and debugging failures
- An explanation of the Peg engine proceeds in its task of matching rules against a grammar, so that it would easier to follow a trace.
Aveer