When I need to debug a grammar I often add print statments to visualize the parser activity. Now with TPG 3 it is possible to print such information automatically.
Normal parsers inherit from tpg.Parser. If you need a more verbose parser you can use tpg.VerboseParser instead. This parser prints information about the current token each time the lexer is called. The debugging information has currently two level of details.
The level is defined by the attribute verbose. Its default value is 1.
|
The information displayed by verbose parsers has the following format:
[eat counter][stack depth]callers: (line,row) <current token> == <expected token>
|