[antlr-interest] Feature Request - Visualize the Parse Graph for multiple rules by Rule Decisions and Tokens consumed

Douglas Godfrey douglasgodfrey at gmail.com
Mon May 9 21:58:01 PDT 2011

Feature Request:

A way to visualize the Parse Graph of a grammar by the sequence of Tokens
consumed by the rules.

The Parse Graph should be generated by selecting a rule or rule decision and
using the contextual menu
or the Grammar menu. The root of the Parse Graph should be the start of the
selected rule or decision.

The Parse Graph should visually represent the flow of control in the parser
generated by a grammar
starting from the selected rule or decision.

The Parse Graph should show the rules, rule decisions and the Tokens or user
provided Predicates that
determine which path is followed. A decision invoking a Sub-rule should be
inlined until a leading Token
or predicate is found.

Antlr generated predicates should list the Tokens in the follow set that
trigger that predicate.
If the set is more than 2-3 Tokens then do not list the tokens in the graph
node but instead have a label
that refers to a named list of tokens added to the bottom of the Parse Graph

User provided predicates should be shown as a node named by the predicate
function with a label
indicating the line number of the predicate in the grammar. Predicate Nodes
should distinguish between
Syntactic, Semantic and Gated Predicates

The graph generation should have an option to limit the depth of analysis so
the generated graph will be
small enough for a person to read. If analysis is terminated by the depth
limit, then that should be visually
indicated by adding an Ellipsis node as a terminal leaf node.

The graph generation should also honor the current printer page setup and
margins. If a diagram would be
wider than the current page margins it should be wrapped to another line.

The output should be a PS, PDF or Dot file with display and save options
like the existing Rule Dependency
and Syntax Diagram graphs.

The graph should be formatted like a Pascal Railroad Diagram similar to the
existing Syntax Diagrams
instead of free-form like the Rule-Dependency-Graph. The resulting graph
should be suitable for use as
formal language documentation for the language parsed by the grammar.

i.e. If the grammar was for the Pascal language, selecting the Program rule
would generate a railroad
      diagram for the Pascal Language that would look like a more detailed
version of the diagrams found
      in every elementary Pascal textbook.

More information about the antlr-interest mailing list