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