Examples of buildNFA()


Examples of org.antlr.tool.Grammar.buildNFA()

    @Test public void testFiniteCommonLeftPrefixes() throws Exception {
        Grammar g = new Grammar(
                "lexer grammar t;\n"+
                "A : 'a' 'b' | 'a' 'c' | 'd' 'e' ;");
    g.buildNFA();
        g.createLookaheadDFAs(false);
        DFA dfa = g.getLookaheadDFA(1);
        checkPrediction(dfa,"ab",1);
        checkPrediction(dfa,"ac",2);
        checkPrediction(dfa,"de",3);
View Full Code Here

Examples of org.antlr.tool.Grammar.buildNFA()

    @Test public void testSimpleLoops() throws Exception {
        Grammar g = new Grammar(
                "lexer grammar t;\n"+
                "A : (DIGIT)+ '.' DIGIT | (DIGIT)+ ;\n" +
                "fragment DIGIT : '0'..'9' ;\n");
    g.buildNFA();
        g.createLookaheadDFAs(false);
        DFA dfa = g.getLookaheadDFA(3);
        checkPrediction(dfa,"32",2);
        checkPrediction(dfa,"999.2",1);
        checkPrediction(dfa,".2", NFA.INVALID_ALT_NUMBER);
View Full Code Here

Examples of org.antlr.tool.Grammar.buildNFA()

    public void testSimpleAltCharTest() throws Exception {
        Grammar g = new Grammar(
                "lexer grammar t;\n"+
                "A : {;}'a' | 'b' | 'c';");
    g.buildNFA();
    g.createLookaheadDFAs(false);
        DFA dfa = g.getLookaheadDFA(1);
        checkPrediction(dfa,"a",1);
        checkPrediction(dfa,"b",2);
        checkPrediction(dfa,"c",3);
View Full Code Here

Examples of org.antlr.tool.Grammar.buildNFA()

    public void testSets() throws Exception {
        Grammar g = new Grammar(
                "lexer grammar t;\n"+
                "A : {;}'a'..'z' | ';' | '0'..'9' ;");
    g.buildNFA();
        g.createLookaheadDFAs(false);
        DFA dfa = g.getLookaheadDFA(1);
        checkPrediction(dfa,"a",1);
        checkPrediction(dfa,"q",1);
        checkPrediction(dfa,"z",1);
View Full Code Here

Examples of org.antlr.tool.Grammar.buildNFA()

    public void testFiniteCommonLeftPrefixes() throws Exception {
        Grammar g = new Grammar(
                "lexer grammar t;\n"+
                "A : 'a' 'b' | 'a' 'c' | 'd' 'e' ;");
    g.buildNFA();
        g.createLookaheadDFAs(false);
        DFA dfa = g.getLookaheadDFA(1);
        checkPrediction(dfa,"ab",1);
        checkPrediction(dfa,"ac",2);
        checkPrediction(dfa,"de",3);
View Full Code Here

Examples of org.antlr.tool.Grammar.buildNFA()

    public void testSimpleLoops() throws Exception {
        Grammar g = new Grammar(
                "lexer grammar t;\n"+
                "A : (DIGIT)+ '.' DIGIT | (DIGIT)+ ;\n" +
                "fragment DIGIT : '0'..'9' ;\n");
    g.buildNFA();
        g.createLookaheadDFAs(false);
        DFA dfa = g.getLookaheadDFA(3);
        checkPrediction(dfa,"32",2);
        checkPrediction(dfa,"999.2",1);
        checkPrediction(dfa,".2", NFA.INVALID_ALT_NUMBER);
View Full Code Here

Examples of org.antlr.works.visualization.fa.FAFactory.buildNFA()

        // 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
TOP
Copyright © 2018 www.massapi.com. 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.