Examples of LL1DFA


Examples of org.antlr.analysis.LL1DFA

    if ( decisionIsLL_1 && !foundConfoundingPredicate ) {
      // build an LL(1) optimized DFA with edge for each altLook[i]
      if ( NFAToDFAConverter.debug ) {
        System.out.println("decision "+decision+" is simple LL(1)");
      }
      DFA lookaheadDFA = new LL1DFA(decision, decisionStartState, altLook);
      setLookaheadDFA(decision, lookaheadDFA);
      updateLineColumnToLookaheadDFAMap(lookaheadDFA);
      return lookaheadDFA;
    }

    // not LL(1) but perhaps we can solve with simplified predicate search
    // even if k=1 set manually, only resolve here if we have preds; i.e.,
    // don't resolve etc...

    /*
    SemanticContext visiblePredicates =
      ll1Analyzer.getPredicates(decisionStartState);
    boolean foundConfoundingPredicate =
      ll1Analyzer.detectConfoundingPredicates(decisionStartState);
      */

    // exit if not forced k=1 or we found a predicate situation we
    // can't handle: predicates in rules invoked from this decision.
    if ( getUserMaxLookahead(decision)!=1 || // not manually set to k=1
       !getAutoBacktrackMode(decision) ||
       foundConfoundingPredicate )
    {
      //System.out.println("trying LL(*)");
      return null;
    }

    List<IntervalSet> edges = new ArrayList<IntervalSet>();
    for (int i = 1; i < altLook.length; i++) {
      LookaheadSet s = altLook[i];
      edges.add(s.tokenTypeSet);
    }
    List<IntervalSet> disjoint = makeEdgeSetsDisjoint(edges);
    //System.out.println("disjoint="+disjoint);

    MultiMap<IntervalSet, Integer> edgeMap = new MultiMap<IntervalSet, Integer>();
    for (int i = 0; i < disjoint.size(); i++) {
      IntervalSet ds = disjoint.get(i);
      for (int alt = 1; alt < altLook.length; alt++) {
        LookaheadSet look = altLook[alt];
        if ( !ds.and(look.tokenTypeSet).isNil() ) {
          edgeMap.map(ds, alt);
        }
      }
    }
    //System.out.println("edge map: "+edgeMap);

    // TODO: how do we know we covered stuff?

    // build an LL(1) optimized DFA with edge for each altLook[i]
    DFA lookaheadDFA = new LL1DFA(decision, decisionStartState, edgeMap);
    setLookaheadDFA(decision, lookaheadDFA);

    // create map from line:col to decision DFA (for ANTLRWorks)
    updateLineColumnToLookaheadDFAMap(lookaheadDFA);

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.