Package net.sourceforge.chaperon.common

Examples of net.sourceforge.chaperon.common.StringSet


    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');
      }

      // for each nonterminal
      for (int j = 0; j<nonterminals.getStringCount(); j++)
        addGotoAction(state, nonterminals.getString(j));

      for (PatternIterator pattern = gotoPattern.getPattern(); pattern.hasNext();)
        addGotoAction(state, pattern.next());

      addReduceAction(state);
View Full Code Here

TOP

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

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.