Package org.antlr.works.visualization.fa

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


            }
        }
    }

    public FAState recursiveRenderPositionAlternative(FAState state, GPoint basePoint) {
        FAState alternativeEndState = alternativeEndState(state);

        // This point is used to position each transition
        GPoint point = new GPoint(basePoint);
        point.addX(GContext.NODE_WIDTH+GContext.EPSILON_WIDTH);
View Full Code Here


        }
        return dimension;
    }

    public GDimension recursiveRenderSizeAlternative(FAState state) {
        FAState alternativeEndState = alternativeEndState(state);

        GNode norigin = createNode(state);

        GDimension dimension = norigin.linkDimension;
        dimension.addWidth(GContext.EPSILON_WIDTH);
View Full Code Here

        return nodes.get(state);
    }

    public FAState alternativeEndState(FAState alt) {
        int counter = alt.getNumberOfTransitions()-1;
        FAState state = alt;
        while(true) {
            FATransition transition = state.getFirstTransition();
            if(transition == null)
                break;

            state = transition.target;

            // Note: a state can be both an end-of-alternative and an alternative itself ;-)
            if(analysis.numberOfIncomingTransition(state)>1) {
                counter -= analysis.numberOfIncomingTransition(state)-1;
                if(counter <= 0)
                    break;
            }

            if(state.isAlternative()) {
                counter += state.getNumberOfTransitions()-1;               
            }
        }
        return state;
    }
View Full Code Here

    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

        // 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

                if(nextNode == null) {
                    // A path can start from anywhere in the graph. It might happen
                    // that the starting state of the path has been skipped by
                    // the optimization in FAFactory. We use the skippedStates mapping
                    // to find out what is the parent state of the skipped state.
                    FAState parentState = skippedStates.get(nextState.stateNumber);
                    if(parentState == null) {
                        System.err.println("[GGraphGroup] Starting path state "+nextState.stateNumber+"["+nextState.enclosingRule.name+"] cannot be found in the graph");
                        return;
                    } else {
                        nextNode = findNodeForStateNumber(parentState.stateNumber);
                    }
                }
                continue;
            } else {
                state = nextState;
                node = nextNode;
            }

            nextState = (NFAState)path.get(getPathIndex());
            nextNode = findNodeForStateNumber(nextState.stateNumber);

            GNode externalNode = null;

            if(nextNode == null) {
                // The state has probably been skipped during the graphical rendering.
                // Find the next non-skipped state.
                FATransition t = getNodeTransitionToNextNonSkippedState(node, path);
                if(t == null) {
                    // No transition found. Look in the skipped states mapping because
                    // it might be possible that the next state is in another rule but
                    // cannot be found because it has been skipped.

                    FAState parentState = skippedStates.get(nextState.stateNumber);
                    if(parentState == null) {
                        //  OK. The node really does not exist. Continue by skipping it.
                        nextNode = node;
                        continue;
                    } else {
View Full Code Here

TOP

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

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.