001 /* Generated By:JJTree&JavaCC: Do not edit this line. JSSPParserTokenManager.java */
002 package org.descripter.js.ss.parse;
003 
004 /** Token Manager. */
005 public class JSSPParserTokenManager implements JSSPParserConstants
006 {
007 
008   /** Debug output. */
009   public  java.io.PrintStream debugStream = System.out;
010   /** Set debug output. */
011   public  void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
012 private int jjStopAtPos(int pos, int kind)
013 {
014    jjmatchedKind = kind;
015    jjmatchedPos = pos;
016    return pos + 1;
017 }
018 private int jjMoveStringLiteralDfa0_3()
019 {
020    switch(curChar)
021    {
022       case 39:
023          return jjStopAtPos(0, 10);
024       default :
025          return 1;
026    }
027 }
028 private int jjMoveStringLiteralDfa0_0()
029 {
030    switch(curChar)
031    {
032       case 10:
033          {
034          jjmatchedKind = 1;
035          jjmatchedPos = 0;
036          }
037          return jjMoveNfa_0(3, 0);
038       case 13:
039          {
040          jjmatchedKind = 2;
041          jjmatchedPos = 0;
042          }
043          return jjMoveNfa_0(3, 0);
044       case 34:
045          {
046          jjmatchedKind = 6;
047          jjmatchedPos = 0;
048          }
049          return jjMoveNfa_0(3, 0);
050       case 39:
051          {
052          jjmatchedKind = 7;
053          jjmatchedPos = 0;
054          }
055          return jjMoveNfa_0(3, 0);
056       case 60:
057          return jjMoveStringLiteralDfa1_0(0x20L);
058       case 8232:
059          {
060          jjmatchedKind = 3;
061          jjmatchedPos = 0;
062          }
063          return jjMoveNfa_0(3, 0);
064       case 8233:
065          {
066          jjmatchedKind = 4;
067          jjmatchedPos = 0;
068          }
069          return jjMoveNfa_0(3, 0);
070       default :
071          return jjMoveNfa_0(3, 0);
072    }
073 }
074 private int jjMoveStringLiteralDfa1_0(long active0)
075 {
076    try { curChar = input_stream.readChar(); }
077    catch(java.io.IOException e) {
078    return jjMoveNfa_0(3, 0);
079    }
080    switch(curChar)
081    {
082       case 37:
083          if ((active0 & 0x20L) != 0L)
084          {
085             jjmatchedKind = 5;
086             jjmatchedPos = 1;
087          }
088          break;
089       default :
090          break;
091    }
092    return jjMoveNfa_0(3, 1);
093 }
094 static final long[] jjbitVec0 = {
095    0xfffffffefffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
096 };
097 static final long[] jjbitVec2 = {
098    0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
099 };
100 static final long[] jjbitVec3 = {
101    0xfffffcffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
102 };
103 private int jjMoveNfa_0(int startState, int curPos)
104 {
105    int strKind = jjmatchedKind;
106    int strPos = jjmatchedPos;
107    int seenUpto;
108    input_stream.backup(seenUpto = curPos + 1);
109    try { curChar = input_stream.readChar(); }
110    catch(java.io.IOException e) { throw new Error("Internal Error"); }
111    curPos = 0;
112    int startsAt = 0;
113    jjnewStateCnt = 3;
114    int i = 1;
115    jjstateSet[0] = startState;
116    int kind = 0x7fffffff;
117    for (;;)
118    {
119       if (++jjround == 0x7fffffff)
120          ReInitRounds();
121       if (curChar < 64)
122       {
123          long l = 1L << curChar;
124          do
125          {
126             switch(jjstateSet[--i])
127             {
128                case 3:
129                   if ((0xefffff7bffffdbffL & l) != 0L)
130                   {
131                      if (kind > 11)
132                         kind = 11;
133                      jjCheckNAddTwoStates(0, 1);
134                   }
135                   else if (curChar == 60)
136                      jjstateSet[jjnewStateCnt++] = 2;
137                   break;
138                case 0:
139                   if ((0xefffff7bffffdbffL & l) == 0L)
140                      break;
141                   if (kind > 11)
142                      kind = 11;
143                   jjCheckNAddTwoStates(0, 1);
144                   break;
145                case 1:
146                   if (curChar == 60)
147                      jjstateSet[jjnewStateCnt++] = 2;
148                   break;
149                case 2:
150                   if ((0xffffff5bffffdbffL & l) == 0L)
151                      break;
152                   if (kind > 11)
153                      kind = 11;
154                   jjCheckNAddTwoStates(0, 1);
155                   break;
156                default : break;
157             }
158          } while(i != startsAt);
159       }
160       else if (curChar < 128)
161       {
162          long l = 1L << (curChar & 077);
163          do
164          {
165             switch(jjstateSet[--i])
166             {
167                case 3:
168                case 0:
169                case 2:
170                   if (kind > 11)
171                      kind = 11;
172                   jjCheckNAddTwoStates(0, 1);
173                   break;
174                default : break;
175             }
176          } while(i != startsAt);
177       }
178       else
179       {
180          int hiByte = (int)(curChar >> 8);
181          int i1 = hiByte >> 6;
182          long l1 = 1L << (hiByte & 077);
183          int i2 = (curChar & 0xff) >> 6;
184          long l2 = 1L << (curChar & 077);
185          do
186          {
187             switch(jjstateSet[--i])
188             {
189                case 3:
190                case 0:
191                case 2:
192                   if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
193                      break;
194                   if (kind > 11)
195                      kind = 11;
196                   jjCheckNAddTwoStates(0, 1);
197                   break;
198                default : break;
199             }
200          } while(i != startsAt);
201       }
202       if (kind != 0x7fffffff)
203       {
204          jjmatchedKind = kind;
205          jjmatchedPos = curPos;
206          kind = 0x7fffffff;
207       }
208       ++curPos;
209       if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
210          break;
211       try { curChar = input_stream.readChar(); }
212       catch(java.io.IOException e) { break; }
213    }
214    if (jjmatchedPos > strPos)
215       return curPos;
216 
217    int toRet = Math.max(curPos, seenUpto);
218 
219    if (curPos < toRet)
220       for (i = toRet - Math.min(curPos, seenUpto); i-- > 0; )
221          try { curChar = input_stream.readChar(); }
222          catch(java.io.IOException e) { throw new Error("Internal Error : Please send a bug report."); }
223 
224    if (jjmatchedPos < strPos)
225    {
226       jjmatchedKind = strKind;
227       jjmatchedPos = strPos;
228    }
229    else if (jjmatchedPos == strPos && jjmatchedKind > strKind)
230       jjmatchedKind = strKind;
231 
232    return toRet;
233 }
234 private int jjMoveStringLiteralDfa0_1()
235 {
236    switch(curChar)
237    {
238       case 37:
239          return jjMoveStringLiteralDfa1_1(0x100L);
240       default :
241          return 1;
242    }
243 }
244 private int jjMoveStringLiteralDfa1_1(long active0)
245 {
246    try { curChar = input_stream.readChar(); }
247    catch(java.io.IOException e) {
248       return 1;
249    }
250    switch(curChar)
251    {
252       case 62:
253          if ((active0 & 0x100L) != 0L)
254             return jjStopAtPos(1, 8);
255          break;
256       default :
257          return 2;
258    }
259    return 2;
260 }
261 private int jjMoveStringLiteralDfa0_2()
262 {
263    switch(curChar)
264    {
265       case 34:
266          return jjStopAtPos(0, 9);
267       default :
268          return 1;
269    }
270 }
271 static final int[] jjnextStates = {
272 };
273 private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
274 {
275    switch(hiByte)
276    {
277       case 0:
278          return ((jjbitVec2[i2] & l2) != 0L);
279       case 32:
280          return ((jjbitVec3[i2] & l2) != 0L);
281       default :
282          if ((jjbitVec0[i1] & l1) != 0L)
283             return true;
284          return false;
285    }
286 }
287 
288 /** Token literal values. */
289 public static final String[] jjstrLiteralImages = {
290 null, null, null, null, null, null, null, null, null, null, null, null, null, };
291 
292 /** Lexer state names. */
293 public static final String[] lexStateNames = {
294    "DEFAULT",
295    "IN_SCRIPT",
296    "IN_DOUBLE_STRING",
297    "IN_SINGLE_STRING",
298 };
299 
300 /** Lex State array. */
301 public static final int[] jjnewLexState = {
302    -1, -1, -1, -1, -1, 1, 2, 3, 0, 0, 0, -1, -1, 
303 };
304 static final long[] jjtoToken = {
305    0xf01L, 
306 };
307 static final long[] jjtoSkip = {
308    0x1eL, 
309 };
310 static final long[] jjtoSpecial = {
311    0x1eL, 
312 };
313 static final long[] jjtoMore = {
314    0x10e0L, 
315 };
316 protected JavaCharStream input_stream;
317 private final int[] jjrounds = new int[3];
318 private final int[] jjstateSet = new int[6];
319 private final StringBuilder jjimage = new StringBuilder();
320 private StringBuilder image = jjimage;
321 private int jjimageLen;
322 private int lengthOfMatch;
323 protected char curChar;
324 /** Constructor. */
325 public JSSPParserTokenManager(JavaCharStream stream){
326    if (JavaCharStream.staticFlag)
327       throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
328    input_stream = stream;
329 }
330 
331 /** Constructor. */
332 public JSSPParserTokenManager(JavaCharStream stream, int lexState){
333    this(stream);
334    SwitchTo(lexState);
335 }
336 
337 /** Reinitialise parser. */
338 public void ReInit(JavaCharStream stream)
339 {
340    jjmatchedPos = jjnewStateCnt = 0;
341    curLexState = defaultLexState;
342    input_stream = stream;
343    ReInitRounds();
344 }
345 private void ReInitRounds()
346 {
347    int i;
348    jjround = 0x80000001;
349    for (i = 3; i-- > 0;)
350       jjrounds[i] = 0x80000000;
351 }
352 
353 /** Reinitialise parser. */
354 public void ReInit(JavaCharStream stream, int lexState)
355 {
356    ReInit(stream);
357    SwitchTo(lexState);
358 }
359 
360 /** Switch to specified lex state. */
361 public void SwitchTo(int lexState)
362 {
363    if (lexState >= 4 || lexState < 0)
364       throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
365    else
366       curLexState = lexState;
367 }
368 
369 protected Token jjFillToken()
370 {
371    final Token t;
372    final String curTokenImage;
373    final int beginLine;
374    final int endLine;
375    final int beginColumn;
376    final int endColumn;
377    if (jjmatchedPos < 0)
378    {
379       if (image == null)
380          curTokenImage = "";
381       else
382          curTokenImage = image.toString();
383       beginLine = endLine = input_stream.getBeginLine();
384       beginColumn = endColumn = input_stream.getBeginColumn();
385    }
386    else
387    {
388       String im = jjstrLiteralImages[jjmatchedKind];
389       curTokenImage = (im == null) ? input_stream.GetImage() : im;
390       beginLine = input_stream.getBeginLine();
391       beginColumn = input_stream.getBeginColumn();
392       endLine = input_stream.getEndLine();
393       endColumn = input_stream.getEndColumn();
394    }
395    t = Token.newToken(jjmatchedKind, curTokenImage);
396 
397    t.beginLine = beginLine;
398    t.endLine = endLine;
399    t.beginColumn = beginColumn;
400    t.endColumn = endColumn;
401 
402    return t;
403 }
404 
405 int curLexState = 0;
406 int defaultLexState = 0;
407 int jjnewStateCnt;
408 int jjround;
409 int jjmatchedPos;
410 int jjmatchedKind;
411 
412 /** Get the next Token. */
413 public Token getNextToken() 
414 {
415   Token specialToken = null;
416   Token matchedToken;
417   int curPos = 0;
418 
419   EOFLoop :
420   for (;;)
421   {
422    try
423    {
424       curChar = input_stream.BeginToken();
425    }
426    catch(java.io.IOException e)
427    {
428       jjmatchedKind = 0;
429       matchedToken = jjFillToken();
430       matchedToken.specialToken = specialToken;
431       return matchedToken;
432    }
433    image = jjimage;
434    image.setLength(0);
435    jjimageLen = 0;
436 
437    for (;;)
438    {
439      switch(curLexState)
440      {
441        case 0:
442          jjmatchedKind = 11;
443          jjmatchedPos = -1;
444          curPos = 0;
445          curPos = jjMoveStringLiteralDfa0_0();
446          if (jjmatchedPos < 0 || (jjmatchedPos == 0 && jjmatchedKind > 12))
447          {
448             jjmatchedKind = 12;
449             jjmatchedPos = 0;
450          }
451          break;
452        case 1:
453          jjmatchedKind = 0x7fffffff;
454          jjmatchedPos = 0;
455          curPos = jjMoveStringLiteralDfa0_1();
456          if (jjmatchedPos == 0 && jjmatchedKind > 12)
457          {
458             jjmatchedKind = 12;
459          }
460          break;
461        case 2:
462          jjmatchedKind = 0x7fffffff;
463          jjmatchedPos = 0;
464          curPos = jjMoveStringLiteralDfa0_2();
465          if (jjmatchedPos == 0 && jjmatchedKind > 12)
466          {
467             jjmatchedKind = 12;
468          }
469          break;
470        case 3:
471          jjmatchedKind = 0x7fffffff;
472          jjmatchedPos = 0;
473          curPos = jjMoveStringLiteralDfa0_3();
474          if (jjmatchedPos == 0 && jjmatchedKind > 12)
475          {
476             jjmatchedKind = 12;
477          }
478          break;
479      }
480      if (jjmatchedKind != 0x7fffffff)
481      {
482         if (jjmatchedPos + 1 < curPos)
483            input_stream.backup(curPos - jjmatchedPos - 1);
484         if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
485         {
486            matchedToken = jjFillToken();
487            matchedToken.specialToken = specialToken;
488            TokenLexicalActions(matchedToken);
489        if (jjnewLexState[jjmatchedKind] != -1)
490          curLexState = jjnewLexState[jjmatchedKind];
491            return matchedToken;
492         }
493         else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
494         {
495            if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
496            {
497               matchedToken = jjFillToken();
498               if (specialToken == null)
499                  specialToken = matchedToken;
500               else
501               {
502                  matchedToken.specialToken = specialToken;
503                  specialToken = (specialToken.next = matchedToken);
504               }
505            }
506          if (jjnewLexState[jjmatchedKind] != -1)
507            curLexState = jjnewLexState[jjmatchedKind];
508            continue EOFLoop;
509         }
510         jjimageLen += jjmatchedPos + 1;
511       if (jjnewLexState[jjmatchedKind] != -1)
512         curLexState = jjnewLexState[jjmatchedKind];
513         curPos = 0;
514         jjmatchedKind = 0x7fffffff;
515         try {
516            curChar = input_stream.readChar();
517            continue;
518         }
519         catch (java.io.IOException e1) { }
520      }
521      int error_line = input_stream.getEndLine();
522      int error_column = input_stream.getEndColumn();
523      String error_after = null;
524      boolean EOFSeen = false;
525      try { input_stream.readChar(); input_stream.backup(1); }
526      catch (java.io.IOException e1) {
527         EOFSeen = true;
528         error_after = curPos <= 1 ? "" : input_stream.GetImage();
529         if (curChar == '\n' || curChar == '\r') {
530            error_line++;
531            error_column = 0;
532         }
533         else
534            error_column++;
535      }
536      if (!EOFSeen) {
537         input_stream.backup(1);
538         error_after = curPos <= 1 ? "" : input_stream.GetImage();
539      }
540      throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
541    }
542   }
543 }
544 
545 void TokenLexicalActions(Token matchedToken)
546 {
547    switch(jjmatchedKind)
548    {
549       default :
550          break;
551    }
552 }
553 private void jjCheckNAdd(int state)
554 {
555    if (jjrounds[state] != jjround)
556    {
557       jjstateSet[jjnewStateCnt++] = state;
558       jjrounds[state] = jjround;
559    }
560 }
561 private void jjAddStates(int start, int end)
562 {
563    do {
564       jjstateSet[jjnewStateCnt++] = jjnextStates[start];
565    } while (start++ != end);
566 }
567 private void jjCheckNAddTwoStates(int state1, int state2)
568 {
569    jjCheckNAdd(state1);
570    jjCheckNAdd(state2);
571 }
572 
573 }