Search in sources :

Example 1 with CodeGenerator

use of org.antlr.codegen.CodeGenerator 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);
}
Also used : DOTGenerator(org.antlr.tool.DOTGenerator) Grammar(org.antlr.tool.Grammar) CodeGenerator(org.antlr.codegen.CodeGenerator) DFA(org.antlr.analysis.DFA) Tool(org.antlr.Tool)

Aggregations

Tool (org.antlr.Tool)1 DFA (org.antlr.analysis.DFA)1 CodeGenerator (org.antlr.codegen.CodeGenerator)1 DOTGenerator (org.antlr.tool.DOTGenerator)1 Grammar (org.antlr.tool.Grammar)1