Top Description Fields Constructors Methods
org.antlr.tool

public Class DOTGenerator

extends Object
Class Inheritance
Imports
org.antlr.Tool, org.antlr.analysis.*, org.antlr.grammar.v3.ANTLRParser, org.antlr.misc.Utils, org.stringtemplate.v4.ST, .STGroup, .STGroupFile, java.util.*

The DOT (part of graphviz) generation aspect.

Field Summary

Modifier and TypeField and Description
protected String
protected Grammar
protected Set<Object>
markedStates

To prevent infinite recursion when walking state machines, record which states we've visited.

protected String
public static STGroup
stlib

Library of output templates; use <attrname> format

public static final boolean

Constructor Summary

AccessConstructor and Description
public
DOTGenerator(Grammar grammar)

This aspect is associated with a grammar

Method Summary

Modifier and TypeMethod and Description
public String
public String
getDOT(State startState)

Return a String containing a DOT description that, when displayed, will show the incoming state machine visually.

protected String
getEdgeLabel(Transition edge)

Fix edge strings so they print out in DOT properly; generate any gated predicates on edge too.

public String
protected String
public void
public void
setRankdir(String rankdir)

protected void
walkCreatingDFADOT(ST dot, DFAState s)

Do a depth-first walk of the state machine graph and fill a DOT description template.

protected void
walkRuleNFACreatingDOT(ST dot, State s)

Do a depth-first walk of the state machine graph and fill a DOT description template.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrowheadback to summary
protected String arrowhead
grammarback to summary
protected Grammar grammar
markedStatesback to summary
protected Set<Object> markedStates

To prevent infinite recursion when walking state machines, record which states we've visited. Make a new set every time you start walking in case you reuse this object.

rankdirback to summary
protected String rankdir
stlibback to summary
public static STGroup stlib

Library of output templates; use <attrname> format

STRIP_NONREDUCED_STATESback to summary
public static final boolean STRIP_NONREDUCED_STATES

Constructor Detail

DOTGeneratorback to summary
public DOTGenerator(Grammar grammar)

This aspect is associated with a grammar

Method Detail

getArrowheadTypeback to summary
public String getArrowheadType()
getDOTback to summary
public String getDOT(State startState)

Return a String containing a DOT description that, when displayed, will show the incoming state machine visually. All nodes reachable from startState will be included.

getEdgeLabelback to summary
protected String getEdgeLabel(Transition edge)

Fix edge strings so they print out in DOT properly; generate any gated predicates on edge too.

getRankdirback to summary
public String getRankdir()
getStateLabelback to summary
protected String getStateLabel(State s)
setArrowheadTypeback to summary
public void setArrowheadType(String arrowhead)
setRankdirback to summary
public void setRankdir(String rankdir)
walkCreatingDFADOTback to summary
protected void walkCreatingDFADOT(ST dot, DFAState s)

Do a depth-first walk of the state machine graph and fill a DOT description template. Keep filling the states and edges attributes.

walkRuleNFACreatingDOTback to summary
protected void walkRuleNFACreatingDOT(ST dot, State s)

Do a depth-first walk of the state machine graph and fill a DOT description template. Keep filling the states and edges attributes. We know this is an NFA for a rule so don't traverse edges to other rules and don't go past rule end state.