Home » openjdk-7 » net.bonzoun » cocodonkey » [javadoc | source]

    1   /* Generated By: CamlParser.jj,v 1.1 2002/08/21 21&JavaCC: Do not edit this line. CamlParserTokenManager.java */
    2   package net.bonzoun.cocodonkey;
    3   import java.io;
    4   import java.util;
    5   
    6   public class CamlParserTokenManager implements CamlParserConstants
    7   {
    8   private final int jjStopStringLiteralDfa_0(int pos, long active0)
    9   {
   10      switch (pos)
   11      {
   12         default :
   13            return -1;
   14      }
   15   }
   16   private final int jjStartNfa_0(int pos, long active0)
   17   {
   18      return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
   19   }
   20   private final int jjStopAtPos(int pos, int kind)
   21   {
   22      jjmatchedKind = kind;
   23      jjmatchedPos = pos;
   24      return pos + 1;
   25   }
   26   private final int jjStartNfaWithStates_0(int pos, int kind, int state)
   27   {
   28      jjmatchedKind = kind;
   29      jjmatchedPos = pos;
   30      try { curChar = input_stream.readChar(); }
   31      catch(java.io.IOException e) { return pos + 1; }
   32      return jjMoveNfa_0(state, pos + 1);
   33   }
   34   private final int jjMoveStringLiteralDfa0_0()
   35   {
   36      switch(curChar)
   37      {
   38         case 40:
   39            jjmatchedKind = 9;
   40            return jjMoveStringLiteralDfa1_0(0x4000L);
   41         case 41:
   42            return jjStopAtPos(0, 10);
   43         case 44:
   44            return jjStopAtPos(0, 12);
   45         case 59:
   46            return jjStopAtPos(0, 11);
   47         case 61:
   48            return jjStopAtPos(0, 13);
   49         case 91:
   50            return jjStopAtPos(0, 7);
   51         case 93:
   52            return jjStopAtPos(0, 8);
   53         case 123:
   54            return jjStopAtPos(0, 5);
   55         case 125:
   56            return jjStopAtPos(0, 6);
   57         default :
   58            return jjMoveNfa_0(0, 0);
   59      }
   60   }
   61   private final int jjMoveStringLiteralDfa1_0(long active0)
   62   {
   63      try { curChar = input_stream.readChar(); }
   64      catch(java.io.IOException e) {
   65         jjStopStringLiteralDfa_0(0, active0);
   66         return 1;
   67      }
   68      switch(curChar)
   69      {
   70         case 42:
   71            if ((active0 & 0x4000L) != 0L)
   72               return jjStopAtPos(1, 14);
   73            break;
   74         default :
   75            break;
   76      }
   77      return jjStartNfa_0(0, active0);
   78   }
   79   private final void jjCheckNAdd(int state)
   80   {
   81      if (jjrounds[state] != jjround)
   82      {
   83         jjstateSet[jjnewStateCnt++] = state;
   84         jjrounds[state] = jjround;
   85      }
   86   }
   87   private final void jjAddStates(int start, int end)
   88   {
   89      do {
   90         jjstateSet[jjnewStateCnt++] = jjnextStates[start];
   91      } while (start++ != end);
   92   }
   93   private final void jjCheckNAddTwoStates(int state1, int state2)
   94   {
   95      jjCheckNAdd(state1);
   96      jjCheckNAdd(state2);
   97   }
   98   private final void jjCheckNAddStates(int start, int end)
   99   {
  100      do {
  101         jjCheckNAdd(jjnextStates[start]);
  102      } while (start++ != end);
  103   }
  104   private final void jjCheckNAddStates(int start)
  105   {
  106      jjCheckNAdd(jjnextStates[start]);
  107      jjCheckNAdd(jjnextStates[start + 1]);
  108   }
  109   static final long[] jjbitVec0 = {
  110      0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
  111   };
  112   private final int jjMoveNfa_0(int startState, int curPos)
  113   {
  114      int[] nextStates;
  115      int startsAt = 0;
  116      jjnewStateCnt = 15;
  117      int i = 1;
  118      jjstateSet[0] = startState;
  119      int j, kind = 0x7fffffff;
  120      for (;;)
  121      {
  122         if (++jjround == 0x7fffffff)
  123            ReInitRounds();
  124         if (curChar < 64)
  125         {
  126            long l = 1L << curChar;
  127            MatchLoop: do
  128            {
  129               switch(jjstateSet[--i])
  130               {
  131                  case 0:
  132                     if ((0x3ff000000000000L & l) != 0L)
  133                     {
  134                        if (kind > 2)
  135                           kind = 2;
  136                        jjCheckNAddStates(0, 2);
  137                     }
  138                     else if (curChar == 45)
  139                        jjCheckNAddTwoStates(10, 11);
  140                     else if (curChar == 34)
  141                        jjCheckNAddStates(3, 5);
  142                     else if (curChar == 46)
  143                        jjCheckNAdd(3);
  144                     break;
  145                  case 1:
  146                     if ((0x3ff200000000000L & l) == 0L)
  147                        break;
  148                     if (kind > 1)
  149                        kind = 1;
  150                     jjstateSet[jjnewStateCnt++] = 1;
  151                     break;
  152                  case 2:
  153                     if (curChar == 46)
  154                        jjCheckNAdd(3);
  155                     break;
  156                  case 3:
  157                     if ((0x3ff000000000000L & l) == 0L)
  158                        break;
  159                     if (kind > 3)
  160                        kind = 3;
  161                     jjCheckNAdd(3);
  162                     break;
  163                  case 4:
  164                     if (curChar == 34)
  165                        jjCheckNAddStates(3, 5);
  166                     break;
  167                  case 6:
  168                     jjCheckNAddStates(3, 5);
  169                     break;
  170                  case 7:
  171                     if ((0xfffffffbffffffffL & l) != 0L)
  172                        jjCheckNAddStates(3, 5);
  173                     break;
  174                  case 8:
  175                     if (curChar == 34 && kind > 4)
  176                        kind = 4;
  177                     break;
  178                  case 9:
  179                     if (curChar == 45)
  180                        jjCheckNAddTwoStates(10, 11);
  181                     break;
  182                  case 10:
  183                     if ((0x3ff000000000000L & l) == 0L)
  184                        break;
  185                     if (kind > 2)
  186                        kind = 2;
  187                     jjCheckNAdd(10);
  188                     break;
  189                  case 11:
  190                     if ((0x3ff000000000000L & l) != 0L)
  191                        jjCheckNAddTwoStates(11, 12);
  192                     break;
  193                  case 12:
  194                     if (curChar != 46)
  195                        break;
  196                     if (kind > 3)
  197                        kind = 3;
  198                     jjCheckNAdd(13);
  199                     break;
  200                  case 13:
  201                     if ((0x3ff000000000000L & l) == 0L)
  202                        break;
  203                     if (kind > 3)
  204                        kind = 3;
  205                     jjCheckNAdd(13);
  206                     break;
  207                  case 14:
  208                     if ((0x3ff000000000000L & l) == 0L)
  209                        break;
  210                     if (kind > 2)
  211                        kind = 2;
  212                     jjCheckNAddStates(0, 2);
  213                     break;
  214                  default : break;
  215               }
  216            } while(i != startsAt);
  217         }
  218         else if (curChar < 128)
  219         {
  220            long l = 1L << (curChar & 077);
  221            MatchLoop: do
  222            {
  223               switch(jjstateSet[--i])
  224               {
  225                  case 0:
  226                     if ((0x7fffffe07fffffeL & l) == 0L)
  227                        break;
  228                     if (kind > 1)
  229                        kind = 1;
  230                     jjCheckNAdd(1);
  231                     break;
  232                  case 1:
  233                     if ((0x7fffffe87fffffeL & l) == 0L)
  234                        break;
  235                     if (kind > 1)
  236                        kind = 1;
  237                     jjCheckNAdd(1);
  238                     break;
  239                  case 5:
  240                     if (curChar == 92)
  241                        jjstateSet[jjnewStateCnt++] = 6;
  242                     break;
  243                  case 6:
  244                     jjCheckNAddStates(3, 5);
  245                     break;
  246                  case 7:
  247                     if ((0xffffffffefffffffL & l) != 0L)
  248                        jjCheckNAddStates(3, 5);
  249                     break;
  250                  default : break;
  251               }
  252            } while(i != startsAt);
  253         }
  254         else
  255         {
  256            int i2 = (curChar & 0xff) >> 6;
  257            long l2 = 1L << (curChar & 077);
  258            MatchLoop: do
  259            {
  260               switch(jjstateSet[--i])
  261               {
  262                  case 6:
  263                  case 7:
  264                     if ((jjbitVec0[i2] & l2) != 0L)
  265                        jjCheckNAddStates(3, 5);
  266                     break;
  267                  default : break;
  268               }
  269            } while(i != startsAt);
  270         }
  271         if (kind != 0x7fffffff)
  272         {
  273            jjmatchedKind = kind;
  274            jjmatchedPos = curPos;
  275            kind = 0x7fffffff;
  276         }
  277         ++curPos;
  278         if ((i = jjnewStateCnt) == (startsAt = 15 - (jjnewStateCnt = startsAt)))
  279            return curPos;
  280         try { curChar = input_stream.readChar(); }
  281         catch(java.io.IOException e) { return curPos; }
  282      }
  283   }
  284   private final int jjMoveStringLiteralDfa0_1()
  285   {
  286      switch(curChar)
  287      {
  288         case 42:
  289            return jjMoveStringLiteralDfa1_1(0x10000L);
  290         default :
  291            return 1;
  292      }
  293   }
  294   private final int jjMoveStringLiteralDfa1_1(long active0)
  295   {
  296      try { curChar = input_stream.readChar(); }
  297      catch(java.io.IOException e) {
  298         return 1;
  299      }
  300      switch(curChar)
  301      {
  302         case 41:
  303            if ((active0 & 0x10000L) != 0L)
  304               return jjStopAtPos(1, 16);
  305            break;
  306         default :
  307            return 2;
  308      }
  309      return 2;
  310   }
  311   static final int[] jjnextStates = {
  312      10, 11, 12, 5, 7, 8, 
  313   };
  314   public static final String[] jjstrLiteralImages = {
  315   "", null, null, null, null, "\173", "\175", "\133", "\135", "\50", "\51", 
  316   "\73", "\54", "\75", null, null, null, null, null, null, null, null, };
  317   public static final String[] lexStateNames = {
  318      "DEFAULT", 
  319      "IN_COMMENT", 
  320   };
  321   public static final int[] jjnewLexState = {
  322      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 0, -1, -1, -1, -1, -1, 
  323   };
  324   static final long[] jjtoToken = {
  325      0x3fffL, 
  326   };
  327   static final long[] jjtoSkip = {
  328      0x3f0000L, 
  329   };
  330   static final long[] jjtoSpecial = {
  331      0x10000L, 
  332   };
  333   static final long[] jjtoMore = {
  334      0xc000L, 
  335   };
  336   private ASCII_CharStream input_stream;
  337   private final int[] jjrounds = new int[15];
  338   private final int[] jjstateSet = new int[30];
  339   StringBuffer image;
  340   int jjimageLen;
  341   int lengthOfMatch;
  342   protected char curChar;
  343   public CamlParserTokenManager(ASCII_CharStream stream)
  344   {
  345      if (ASCII_CharStream.staticFlag)
  346         throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
  347      input_stream = stream;
  348   }
  349   public CamlParserTokenManager(ASCII_CharStream stream, int lexState)
  350   {
  351      this(stream);
  352      SwitchTo(lexState);
  353   }
  354   public void ReInit(ASCII_CharStream stream)
  355   {
  356      jjmatchedPos = jjnewStateCnt = 0;
  357      curLexState = defaultLexState;
  358      input_stream = stream;
  359      ReInitRounds();
  360   }
  361   private final void ReInitRounds()
  362   {
  363      int i;
  364      jjround = 0x80000001;
  365      for (i = 15; i-- > 0;)
  366         jjrounds[i] = 0x80000000;
  367   }
  368   public void ReInit(ASCII_CharStream stream, int lexState)
  369   {
  370      ReInit(stream);
  371      SwitchTo(lexState);
  372   }
  373   public void SwitchTo(int lexState)
  374   {
  375      if (lexState >= 2 || lexState < 0)
  376         throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
  377      else
  378         curLexState = lexState;
  379   }
  380   
  381   private final Token jjFillToken()
  382   {
  383      Token t = Token.newToken(jjmatchedKind);
  384      t.kind = jjmatchedKind;
  385      String im = jjstrLiteralImages[jjmatchedKind];
  386      t.image = (im == null) ? input_stream.GetImage() : im;
  387      t.beginLine = input_stream.getBeginLine();
  388      t.beginColumn = input_stream.getBeginColumn();
  389      t.endLine = input_stream.getEndLine();
  390      t.endColumn = input_stream.getEndColumn();
  391      return t;
  392   }
  393   
  394   int curLexState = 0;
  395   int defaultLexState = 0;
  396   int jjnewStateCnt;
  397   int jjround;
  398   int jjmatchedPos;
  399   int jjmatchedKind;
  400   
  401   public final Token getNextToken() 
  402   {
  403     int kind;
  404     Token specialToken = null;
  405     Token matchedToken;
  406     int curPos = 0;
  407   
  408     EOFLoop :
  409     for (;;)
  410     {   
  411      try   
  412      {     
  413         curChar = input_stream.BeginToken();
  414      }     
  415      catch(java.io.IOException e)
  416      {        
  417         jjmatchedKind = 0;
  418         matchedToken = jjFillToken();
  419         matchedToken.specialToken = specialToken;
  420         return matchedToken;
  421      }
  422      image = null;
  423      jjimageLen = 0;
  424   
  425      for (;;)
  426      {
  427        switch(curLexState)
  428        {
  429          case 0:
  430            try { input_stream.backup(0);
  431               while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L)
  432                  curChar = input_stream.BeginToken();
  433            }
  434            catch (java.io.IOException e1) { continue EOFLoop; }
  435            jjmatchedKind = 0x7fffffff;
  436            jjmatchedPos = 0;
  437            curPos = jjMoveStringLiteralDfa0_0();
  438            break;
  439          case 1:
  440            jjmatchedKind = 0x7fffffff;
  441            jjmatchedPos = 0;
  442            curPos = jjMoveStringLiteralDfa0_1();
  443            if (jjmatchedPos == 0 && jjmatchedKind > 15)
  444            {
  445               jjmatchedKind = 15;
  446            }
  447            break;
  448        }
  449        if (jjmatchedKind != 0x7fffffff)
  450        {
  451           if (jjmatchedPos + 1 < curPos)
  452              input_stream.backup(curPos - jjmatchedPos - 1);
  453           if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
  454           {
  455              matchedToken = jjFillToken();
  456              matchedToken.specialToken = specialToken;
  457          if (jjnewLexState[jjmatchedKind] != -1)
  458            curLexState = jjnewLexState[jjmatchedKind];
  459              return matchedToken;
  460           }
  461           else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
  462           {
  463              if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
  464              {
  465                 matchedToken = jjFillToken();
  466                 if (specialToken == null)
  467                    specialToken = matchedToken;
  468                 else
  469                 {
  470                    matchedToken.specialToken = specialToken;
  471                    specialToken = (specialToken.next = matchedToken);
  472                 }
  473                 SkipLexicalActions(matchedToken);
  474              }
  475              else 
  476                 SkipLexicalActions(null);
  477            if (jjnewLexState[jjmatchedKind] != -1)
  478              curLexState = jjnewLexState[jjmatchedKind];
  479              continue EOFLoop;
  480           }
  481           jjimageLen += jjmatchedPos + 1;
  482         if (jjnewLexState[jjmatchedKind] != -1)
  483           curLexState = jjnewLexState[jjmatchedKind];
  484           curPos = 0;
  485           jjmatchedKind = 0x7fffffff;
  486           try {
  487              curChar = input_stream.readChar();
  488              continue;
  489           }
  490           catch (java.io.IOException e1) { }
  491        }
  492        int error_line = input_stream.getEndLine();
  493        int error_column = input_stream.getEndColumn();
  494        String error_after = null;
  495        boolean EOFSeen = false;
  496        try { input_stream.readChar(); input_stream.backup(1); }
  497        catch (java.io.IOException e1) {
  498           EOFSeen = true;
  499           error_after = curPos <= 1 ? "" : input_stream.GetImage();
  500           if (curChar == '\n' || curChar == '\r') {
  501              error_line++;
  502              error_column = 0;
  503           }
  504           else
  505              error_column++;
  506        }
  507        if (!EOFSeen) {
  508           input_stream.backup(1);
  509           error_after = curPos <= 1 ? "" : input_stream.GetImage();
  510        }
  511        throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
  512      }
  513     }
  514   }
  515   
  516   final void SkipLexicalActions(Token matchedToken)
  517   {
  518      switch(jjmatchedKind)
  519      {
  520         default :
  521            break;
  522      }
  523   }
  524   }

Home » openjdk-7 » net.bonzoun » cocodonkey » [javadoc | source]