Examples of DFA


Examples of org.antlr.analysis.DFA

      g.setCodeGenerator(generator);
      g.buildNFA();
      g.createLookaheadDFAs(false);
    }

    DFA dfa = g.getLookaheadDFA(decision);
    assertNotNull("unknown decision #"+decision, dfa);
    FASerializer serializer = new FASerializer(g);
    String result = serializer.serialize(dfa.startState);
    //System.out.print(result);
    List<Integer> nonDetAlts = dfa.getUnreachableAlts();
    //System.out.println("alts w/o predict state="+nonDetAlts);

    // first make sure nondeterministic alts are as expected
    if ( expectingUnreachableAlts==null ) {
      if ( nonDetAlts!=null && !nonDetAlts.isEmpty() ) {
View Full Code Here

Examples of org.antlr.analysis.DFA

    }

    assertEquals("unexpected number of expected problems",
           expectingNumWarnings, equeue.size());

    DFA dfa = g.getLookaheadDFA(decision);
    assertNotNull("no DFA for decision "+decision, dfa);
    FASerializer serializer = new FASerializer(g);
    String result = serializer.serialize(dfa.startState);

    List<Integer> unreachableAlts = dfa.getUnreachableAlts();

    // make sure unreachable alts are as expected
    if ( expectingUnreachableAlts!=null ) {
      BitSet s = new BitSet();
      s.addAll(expectingUnreachableAlts);
View Full Code Here

Examples of org.antlr.analysis.DFA

        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);
        checkPrediction(dfa,"d", NFA.INVALID_ALT_NUMBER);
    }
View Full Code Here

Examples of org.antlr.analysis.DFA

        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);
        checkPrediction(dfa,";",2);
        checkPrediction(dfa,"9",3);
View Full Code Here

Examples of org.antlr.analysis.DFA

        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);
        checkPrediction(dfa,"q", NFA.INVALID_ALT_NUMBER);
    }
View Full Code Here

Examples of org.antlr.analysis.DFA

                "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.analysis.DFA

    if ( g.getNumberOfDecisions()==0 ) {
      g.buildNFA();
      g.createLookaheadDFAs(false);
    }

    DFA dfa = g.getLookaheadDFA(1);
    assertEquals(null, dfa); // can't analyze.

    /*
    String result = serializer.serialize(dfa.startState);
    assertEquals(expecting, result);
View Full Code Here

Examples of org.antlr.analysis.DFA

    }

    assertEquals("unexpected number of expected problems",
           expectingNumWarnings, equeue.size());

    DFA dfa = g.getLookaheadDFA(decision);
    FASerializer serializer = new FASerializer(g);
    String result = serializer.serialize(dfa.startState);
    //System.out.print(result);
    List<Integer> unreachableAlts = dfa.getUnreachableAlts();

    // make sure unreachable alts are as expected
    if ( expectingUnreachableAlts!=null ) {
      BitSet s = new BitSet();
      s.addAll(expectingUnreachableAlts);
View Full Code Here

Examples of org.antlr.analysis.DFA

  protected String getDFALocations(Set dfas) {
    Set decisions = new HashSet();
    StringBuffer buf = new StringBuffer();
    Iterator it = dfas.iterator();
    while ( it.hasNext() ) {
      DFA dfa = (DFA) it.next();
      // if we aborted a DFA and redid with k=1, the backtrackin
      if ( decisions.contains(Utils.integer(dfa.decisionNumber)) ) {
        continue;
      }
      decisions.add(Utils.integer(dfa.decisionNumber));
View Full Code Here

Examples of org.antlr.analysis.DFA

    if ( g.getNumberOfDecisions()==0 ) {
      g.buildNFA();
      g.createLookaheadDFAs(false);
    }

    DFA dfa = g.getLookaheadDFA(1);
    assertEquals(null, dfa); // can't analyze.

    /*
    String result = serializer.serialize(dfa.startState);
    assertEquals(expecting, result);
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.