Package org.antlr.analysis

Examples of org.antlr.analysis.NFAState


        int firstAlt = 0;

        for (Object nonDetAlt : nonDetAlts) {
            Integer displayAltI = (Integer) nonDetAlt;
            NFAState nfaStart = message.probe.dfa.getNFADecisionStartState();

            int tracePathAlt = nfaStart.translateDisplayAltToWalkAlt(displayAltI);
            if (firstAlt == 0)
                firstAlt = tracePathAlt;

            List path =
                    message.probe.getNFAPathStatesForAlt(firstAlt,
                            tracePathAlt,
                            error.getLabels());

            error.addPath(path, disabledAlts.contains(displayAltI));
            error.addStates(path);

            // Find all rules enclosing each state (because a path can extend over multiple rules)
            for (Object aPath : path) {
                NFAState state = (NFAState) aPath;
                error.addRule(state.enclosingRule.name);
            }
        }
    }
View Full Code Here


            }
        }
    }

    private void computeRuleError(GrammarError error, GrammarUnreachableAltsMessage message) {
        NFAState state = message.probe.dfa.getNFADecisionStartState();
        for (Object alt : message.alts) {
            error.addUnreachableAlt(state, (Integer) alt);
            error.addStates(state);
            error.addRule(state.enclosingRule.name);
        }
View Full Code Here

            error.addRule(state.enclosingRule.name);
        }
    }

    private void computeRuleError(GrammarError error, NonRegularDecisionMessage message) {
        NFAState state = message.probe.dfa.getNFADecisionStartState();
        for (Object alt : message.altsWithRecursion) {
            // Use currently the unreachable alt for display purpose only
            error.addUnreachableAlt(state, (Integer) alt);
            error.addStates(state);
            error.addRule(state.enclosingRule.name);
View Full Code Here

                }

                Grammar g = discoveredLexerGrammar;
                if(g != null) {
                    Rule r = g.getRule(Grammar.ARTIFICIAL_TOKENS_RULENAME);
                    NFAState s = (NFAState)r.startState.transition(0).target;
                    if(s == null) {
                        System.err.println("NFAState s is null for rule "+r.name);
                        continue;
                    }
                    // Ignore tokens DFA
                    if(dfa.getDecisionNumber() == s.getDecisionNumber()) continue;
                }

                Color c = new Color(0, 128, 64);
                String title = "DFA decision "+dfa.getDecisionNumber();
                String info = "";
View Full Code Here

   
    public String toString() {
        StringBuilder s = new StringBuilder();
        Iterator iterator = stateIncomingTransitionCount.keySet().iterator();
        while(iterator.hasNext()) {
            NFAState key = (NFAState)iterator.next();
            Integer count = (Integer)stateIncomingTransitionCount.get(key);
            s.append(key.stateNumber+" = "+count.intValue()+"\n");
        }
        return s.toString();
    }
View Full Code Here

        String error = null;

        ErrorListener.getThreadInstance().setPrintToConsole(false);

        if(syntaxDiagramTab.getEngineGrammar().hasGrammar()) {
            NFAState startState = null;
            try {
                startState = syntaxDiagramTab.getEngineGrammar().getRuleStartState(threadRule.name);
            } catch (Exception e) {
                // ignore
            }
View Full Code Here

        else
            return buildGraphsForErrors(antlrEngineGrammar, rule, errors);
    }

    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);
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);
View Full Code Here

        for(int t=0; t<state.getNumberOfTransitions(); t++) {
            FAState parentState = js;

            Transition transition = state.transition(t);
            NFAState target = (NFAState)transition.target;
            if(targetStateIsInAnotherRule(transition)) {
                target = targetStateOfTransition(transition);
                parentState = createRuleReferenceState(parentState, transition, null);
            }
View Full Code Here

            skippedStatesMap.put(skippedState, parentState);

            for(int t=0; t<state.getNumberOfTransitions(); t++) {
                Transition transition = state.transition(t);
                if(targetStateIsInAnotherRule(transition)) {
                    NFAState target = targetStateOfTransition(transition);
                    FAState ruleRefState = createRuleReferenceState(parentState, transition, skippedStates);
                    buildRecursiveSkipState(ruleRefState, target, currentPath, new ArrayList<Integer>(skippedStates));
                } else
                    buildRecursiveSkipState(parentState, (NFAState)transition.target, currentPath, new ArrayList<Integer>(skippedStates));
            }
View Full Code Here

TOP

Related Classes of org.antlr.analysis.NFAState

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.