use of org.antlr.tool.DOTGenerator in project antlrworks by antlr.
the class TokensDFA method getDOTString.
@Override
public String getDOTString() throws Exception {
ANTLRGrammarEngine eg = window.getGrammarEngine().getANTLRGrammarEngine();
eg.analyze();
Grammar g = eg.getLexerGrammar();
if (g == null) {
throw new Exception("Cannot show tokens DFA because there is no lexer grammar");
}
Rule r = g.getRule(Grammar.ARTIFICIAL_TOKENS_RULENAME);
NFAState s = (NFAState) r.startState.transition(0).target;
DFA dfa = g.getLookaheadDFA(s.getDecisionNumber());
DOTGenerator dg = new DOTGenerator(g);
dg.setArrowheadType("none");
// Left-to-right
dg.setRankdir("LR");
return dg.getDOT(dfa.startState);
}
use of org.antlr.tool.DOTGenerator in project antlrworks by antlr.
the class DecisionDFA method getDOTString.
@Override
public String getDOTString() throws Exception {
DecisionDFAEngine engine = window.decisionDFAEngine;
Grammar g;
int adjustedColumn = getDecisionColumn(g = engine.getDiscoveredParserGrammar());
if (adjustedColumn == -1)
adjustedColumn = getDecisionColumn(g = engine.getDiscoveredLexerGrammar());
if (adjustedColumn == -1)
throw new Exception("No decision in the current line");
CodeGenerator generator = new CodeGenerator(new Tool(), g, (String) g.getOption("language"));
DFA dfa = g.getLookaheadDFAFromPositionInFile(line, adjustedColumn);
decisionNumber = dfa.getDecisionNumber();
DOTGenerator dg = new DOTGenerator(g);
g.setCodeGenerator(generator);
dg.setArrowheadType("none");
// Left-to-right
dg.setRankdir("LR");
return dg.getDOT(dfa.startState);
}
Aggregations