Package org.antlr.works.visualization.fa

Examples of org.antlr.works.visualization.fa.FAFactory


    public GGraph buildGraphsForRule(ANTLRGrammarEngine antlrEngineGrammar, String rule) throws Exception {
        NFAState startState = antlrEngineGrammar.getRuleStartState(rule);
        if(startState == null)
            return null;

        FAState state = new FAFactory(antlrEngineGrammar.getGrammarForRule(rule)).buildNFA(startState, optimize);
        GGraph graph = renderer.render(state);
        graph.setName(rule);

        return graph;
    }
View Full Code Here


    }

    private GGraphGroup buildGraphGroup(Grammar grammar, GrammarError error) {
        // Create one GGraph for each error rules
        List<GGraph> graphs = new ArrayList<GGraph>();
        FAFactory factory = new FAFactory(grammar);
        for (String rule : error.rules) {
            NFAState startState = grammar.getRuleStartState(rule);
            FAState state = factory.buildNFA(startState, optimize);

            GGraph graph = renderer.render(state);
            graph.setName(rule);
            graphs.add(graph);
        }

        // Add only graphs that are referenced by at least one error path.
        // For example, the statement rule of the java.g grammar produces
        // states that do not exist in the graph (they are after the accepted state
        // and are ignored by the FAFactory)
        GGraphGroup gg = new GGraphGroup();
        for (GGraph graph : graphs) {
            if (graph.containsAtLeastOneState(error.states))
                gg.add(graph);
        }

        // Attach all error paths to the GGraphGroup
        for(int i=0; i<error.paths.size(); i++) {
            List states = error.paths.get(i);
            Boolean disabled = error.pathsDisabled.get(i);
            try {
                gg.addPath(states, disabled, factory.getSkippedStatesMap());
            } catch(Exception e) {
                if(console == null)
                    e.printStackTrace();
                else
                    console.println(e);
View Full Code Here

TOP

Related Classes of org.antlr.works.visualization.fa.FAFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.