Package net.sourceforge.chaperon.common

Examples of net.sourceforge.chaperon.common.SortedCharSet


    return set;
  }

  public char[] getLimits()
  {
    SortedCharSet limits = new SortedCharSet();
    for (int i = 0; i<characters.length; i++)
      limits.addChar(characters[i].getLimits());

    for (int i = 0; i<intervals.length; i++)
      limits.addChar(intervals[i].getLimits());

    return limits.getChar();
  }
View Full Code Here


    super(name);
  }

  public void testCharSet()
  {
    SortedCharSet set = new SortedCharSet();

    set.addChar('A');
    set.addChar('Z');
    set.addChar('%');
    set.addChar('a');
    set.addChar('%');
    set.addChar('z');

    assertEquals("Test count of chars", 5, set.getCharCount());

    assertEquals("Test char", '%', set.getChar(0));
    assertEquals("Test char", 'A', set.getChar(1));
    assertEquals("Test char", 'Z', set.getChar(2));
    assertEquals("Test char", 'a', set.getChar(3));
    assertEquals("Test char", 'z', set.getChar(4));
  }
View Full Code Here

    for (State state = first; state!=null; state = state.next)
    {
      //State state = getState(i);
      //System.out.println("\nState "+i+"\n"+state);
      SortedCharSet limits = new SortedCharSet();
      StringSet nonterminals = new StringSet();
      PatternSet gotoPattern = new PatternSet();

      for (Item item = state.first; item!=null; item = item.next)
      {
        if (item.position==Item.SHIFT)
        {
          if (item.pattern.getSymbol()!=null)
            nonterminals.addString(item.pattern.getSymbol());

          limits.addChar(item.pattern.getLimits());
        }
        else if (item.position==Item.GOTO)
          gotoPattern.addPattern(item.pattern);

        limits.addChar(item.lookahead.getLimits());
      }

//      System.out.println("limits="+limits);
//      System.out.println("nonterminals="+nonterminals);
//      System.out.println("gotoPattern="+gotoPattern);
      // for all other characters from the begin
      if ((limits.getCharCount()>=1) && (limits.getChar(0)>'\u0000'))
      {
        addShiftAction(state, '\u0000', (char)(limits.getChar(0)-1));
        addReduceAction(state, '\u0000', (char)(limits.getChar(0)-1));
      }

      // for each character
      for (int j = 0; j<limits.getCharCount(); j++)
      {
        if ((j>0) && ((limits.getChar(j)-limits.getChar(j-1))>1))
        {
          addShiftAction(state, (char)(limits.getChar(j-1)+1), (char)(limits.getChar(j)-1));
          addReduceAction(state, (char)(limits.getChar(j-1)+1), (char)(limits.getChar(j)-1));
        }

        addShiftAction(state, limits.getChar(j), limits.getChar(j));
        addReduceAction(state, limits.getChar(j), limits.getChar(j));
      }

      // for all other characters to the end
      if (limits.getCharCount()>=1)
      {
        addShiftAction(state, (char)(limits.getChar(limits.getCharCount()-1)+1), '\u4000');
        addReduceAction(state, (char)(limits.getChar(limits.getCharCount()-1)+1), '\u4000');
      }

      // for universal characters
      if (limits.getCharCount()==0)
      {
        addShiftAction(state, '\u0000', '\u4000');
        addReduceAction(state, '\u0000', '\u4000');
      }
View Full Code Here

TOP

Related Classes of net.sourceforge.chaperon.common.SortedCharSet

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.