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