Package org.antlr.misc

Examples of org.antlr.misc.IntSet


        "reachableLabels="+reachableLabels.toString());
        */
    if ( reachableLabels.contains(label) ) { // exact label present
            return;
        }
        IntSet t = label.getSet();
        IntSet remainder = t; // remainder starts out as whole set to add
        int n = reachableLabels.size(); // only look at initial elements
        // walk the existing list looking for the collision
        for (int i=0; i<n; i++) {
      Label rl = reachableLabels.get(i);
            /*
      System.out.println("comparing ["+i+"]: "+label.toString(dfa.nfa.grammar)+" & "+
                    rl.toString(dfa.nfa.grammar)+"="+
                    intersection.toString(dfa.nfa.grammar));
            */
      if ( !Label.intersect(label, rl) ) {
                continue;
            }
      //System.out.println(label+" collides with "+rl);

      // For any (s_i, t) with s_i&t!=nil replace with (s_i-t, s_i&t)
            // (ignoring s_i-t if nil; don't put in list)

            // Replace existing s_i with intersection since we
            // know that will always be a non nil character class
      IntSet s_i = rl.getSet();
      IntSet intersection = s_i.and(t);
            reachableLabels.set(i, new Label(intersection));

            // Compute s_i-t to see what is in current set and not in incoming
            IntSet existingMinusNewElements = s_i.subtract(t);
      //System.out.println(s_i+"-"+t+"="+existingMinusNewElements);
            if ( !existingMinusNewElements.isNil() ) {
                // found a new character class, add to the end (doesn't affect
                // outer loop duration due to n computation a priori.
                Label newLabel = new Label(existingMinusNewElements);
                reachableLabels.add(newLabel);
            }
View Full Code Here


    if ( transition0.label.isAtom() ) {
      int atom = transition0.label.getAtom();
      return new LookaheadSet(atom);
    }
    if ( transition0.label.isSet() ) {
      IntSet sl = transition0.label.getSet();
      return new LookaheadSet(sl);
    }

    // compute FIRST of transition 0
    LookaheadSet tset = null;
View Full Code Here

  public boolean member(int a) {
    return tokenTypeSet.member(a);
  }

  public LookaheadSet intersection(LookaheadSet s) {
    IntSet i = this.tokenTypeSet.and(s.tokenTypeSet);
    LookaheadSet intersection = new LookaheadSet(i);
    return intersection;
  }
View Full Code Here

      List<Set<NFAState>> nfaStates, List<IntSet> labels) {
    List<Token> tokens = new ArrayList<Token>();
    for (int i = 0; i < nfaStates.size() - 1; i++) {
      Set<NFAState> cur = nfaStates.get(i);
      Set<NFAState> next = nfaStates.get(i + 1);
      IntSet label = labels.get(i);
      // find NFA state with edge whose label matches labels[i]
      nfaConfigLoop:
     
      for (NFAState p : cur) {
        // walk p's transitions, looking for label
View Full Code Here

   */
  public IntSet getAllCharValues() {
    if ( charVocabulary!=null ) {
      return charVocabulary;
    }
    IntSet allChar = IntervalSet.of(Label.MIN_CHAR_VALUE, getMaxCharValue());
    return allChar;
  }
View Full Code Here

   *  from MIN_TOKEN_TYPE to last valid token type or char value.
   */
  public IntSet complement(IntSet set) {
    //System.out.println("complement "+set.toString(this));
    //System.out.println("vocabulary "+getTokenTypes().toString(this));
    IntSet c = set.complement(getTokenTypes());
    //System.out.println("result="+c.toString(this));
    return c;
  }
View Full Code Here

  {
    Rule r = getRule(ruleName);
    if ( r==null ) {
      return null;
    }
    IntSet elements;
    //System.out.println("parsed tree: "+r.tree.toStringTree());
    elements = nfabuilder.setRule(r.tree);
    //System.out.println("elements="+elements);
    return elements;
  }
View Full Code Here

  public boolean member(int a) {
    return tokenTypeSet.member(a);
  }

  public LookaheadSet intersection(LookaheadSet s) {
    IntSet i = this.tokenTypeSet.and(s.tokenTypeSet);
    LookaheadSet intersection = new LookaheadSet(i);
    return intersection;
  }
View Full Code Here

        "reachableLabels="+reachableLabels.toString());
        */
    if ( reachableLabels.contains(label) ) { // exact label present
            return;
        }
        IntSet t = label.getSet();
        IntSet remainder = t; // remainder starts out as whole set to add
        int n = reachableLabels.size(); // only look at initial elements
        // walk the existing list looking for the collision
        for (int i=0; i<n; i++) {
      Label rl = reachableLabels.get(i);
            /*
      System.out.println("comparing ["+i+"]: "+label.toString(dfa.nfa.grammar)+" & "+
                    rl.toString(dfa.nfa.grammar)+"="+
                    intersection.toString(dfa.nfa.grammar));
            */
      if ( !Label.intersect(label, rl) ) {
                continue;
            }
      //System.out.println(label+" collides with "+rl);

      // For any (s_i, t) with s_i&t!=nil replace with (s_i-t, s_i&t)
            // (ignoring s_i-t if nil; don't put in list)

            // Replace existing s_i with intersection since we
            // know that will always be a non nil character class
      IntSet s_i = rl.getSet();
      IntSet intersection = s_i.and(t);
            reachableLabels.set(i, new Label(intersection));

            // Compute s_i-t to see what is in current set and not in incoming
            IntSet existingMinusNewElements = s_i.subtract(t);
      //System.out.println(s_i+"-"+t+"="+existingMinusNewElements);
            if ( !existingMinusNewElements.isNil() ) {
                // found a new character class, add to the end (doesn't affect
                // outer loop duration due to n computation a priori.
                Label newLabel = new Label(existingMinusNewElements);
                reachableLabels.add(newLabel);
            }
View Full Code Here

    if ( transition0.label.isAtom() ) {
      int atom = transition0.label.getAtom();
      return new LookaheadSet(atom);
    }
    if ( transition0.label.isSet() ) {
      IntSet sl = transition0.label.getSet();
      return new LookaheadSet(sl);
    }

    // compute FIRST of transition 0
    LookaheadSet tset = null;
View Full Code Here

TOP

Related Classes of org.antlr.misc.IntSet

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.