Grammar debugging

Compilation log

The Hime Parser Generator outputs a log as an MHTML file for the grammar compilation process (-l option in the command line). This log will report grammar conflicts that are still unresolved. The log gives useful information regarding the conflicts, helping you solve them.

log_conflict_small.png

As shown in the picture above, for each conflict the log will report:
  • The state where the conflict is occuring, so that you can look it up in the generated grammar documentation (-d option in the command line)
  • The conflictuous lookahead
  • The list of conflictuous items
  • Examples of input which are ambiguous according to this conflict

Grammar documentation

The Hime Parser Generator outputs a documentation as HTML files for the grammar that is being compiler (use the -d option in the command line). This documentation contains:
  • The complete set of "flat" grammar rules with syntax highlighting.
  • The generated LR graph in the form of a network of hyperlinked web pages containing for each state a detailed description of the state's items.

The picture hereafter shows an example of what is obtained with the grammar of the ANSI C language:

doc_grammar.png

Hereafter is shown an example of a generated web page for a given state in the LR graph:
As can be seen in the picture, each item of the state is detailed with:
  • The action (SHIFT or REDUCE) for the item. An hyperlink to the next state is given in the case of SHIFT actions.
  • The grammar rule with the dot position.
  • The lookaheads (collapsed in this capture).
  • The conflictuous lookaheads if any. If the item is confluctous it is colored in red.
  • The states from which this item comes from (collapsed in this picture). This is useful to quickly traverse the automaton and see from where a conflict comes from.
state.png

Last edited May 14, 2013 at 3:15 PM by lwouters, version 2

Comments

No comments yet.