001 /* Generated By:JavaCC: Do not edit this line. WirthParserTokenManager.java */ 002 package net.hydromatic.clapham.parser.wirth; 003 import java.util.*; 004 import net.hydromatic.clapham.parser.*; 005 006 public class WirthParserTokenManager implements WirthParserConstants 007 { 008 public java.io.PrintStream debugStream = System.out; 009 public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } 010 private final int jjStopStringLiteralDfa_0(int pos, long active0) 011 { 012 switch (pos) 013 { 014 default : 015 return -1; 016 } 017 } 018 private final int jjStartNfa_0(int pos, long active0) 019 { 020 return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); 021 } 022 private final int jjStopAtPos(int pos, int kind) 023 { 024 jjmatchedKind = kind; 025 jjmatchedPos = pos; 026 return pos + 1; 027 } 028 private final int jjStartNfaWithStates_0(int pos, int kind, int state) 029 { 030 jjmatchedKind = kind; 031 jjmatchedPos = pos; 032 try { curChar = input_stream.readChar(); } 033 catch(java.io.IOException e) { return pos + 1; } 034 return jjMoveNfa_0(state, pos + 1); 035 } 036 private final int jjMoveStringLiteralDfa0_0() 037 { 038 switch(curChar) 039 { 040 case 34: 041 return jjStartNfaWithStates_0(0, 14, 5); 042 case 40: 043 return jjStopAtPos(0, 5); 044 case 41: 045 return jjStopAtPos(0, 6); 046 case 46: 047 return jjStopAtPos(0, 11); 048 case 61: 049 return jjStopAtPos(0, 12); 050 case 91: 051 return jjStopAtPos(0, 9); 052 case 93: 053 return jjStopAtPos(0, 10); 054 case 123: 055 return jjStopAtPos(0, 7); 056 case 124: 057 return jjStopAtPos(0, 13); 058 case 125: 059 return jjStopAtPos(0, 8); 060 default : 061 return jjMoveNfa_0(3, 0); 062 } 063 } 064 private final void jjCheckNAdd(int state) 065 { 066 if (jjrounds[state] != jjround) 067 { 068 jjstateSet[jjnewStateCnt++] = state; 069 jjrounds[state] = jjround; 070 } 071 } 072 private final void jjAddStates(int start, int end) 073 { 074 do { 075 jjstateSet[jjnewStateCnt++] = jjnextStates[start]; 076 } while (start++ != end); 077 } 078 private final void jjCheckNAddTwoStates(int state1, int state2) 079 { 080 jjCheckNAdd(state1); 081 jjCheckNAdd(state2); 082 } 083 private final void jjCheckNAddStates(int start, int end) 084 { 085 do { 086 jjCheckNAdd(jjnextStates[start]); 087 } while (start++ != end); 088 } 089 private final void jjCheckNAddStates(int start) 090 { 091 jjCheckNAdd(jjnextStates[start]); 092 jjCheckNAdd(jjnextStates[start + 1]); 093 } 094 static final long[] jjbitVec0 = { 095 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL 096 }; 097 static final long[] jjbitVec2 = { 098 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL 099 }; 100 static final long[] jjbitVec3 = { 101 0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L 102 }; 103 static final long[] jjbitVec4 = { 104 0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL 105 }; 106 static final long[] jjbitVec5 = { 107 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL 108 }; 109 static final long[] jjbitVec6 = { 110 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L 111 }; 112 static final long[] jjbitVec7 = { 113 0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L 114 }; 115 static final long[] jjbitVec8 = { 116 0x3fffffffffffL, 0x0L, 0x0L, 0x0L 117 }; 118 private final int jjMoveNfa_0(int startState, int curPos) 119 { 120 int[] nextStates; 121 int startsAt = 0; 122 jjnewStateCnt = 5; 123 int i = 1; 124 jjstateSet[0] = startState; 125 int j, kind = 0x7fffffff; 126 for (;;) 127 { 128 if (++jjround == 0x7fffffff) 129 ReInitRounds(); 130 if (curChar < 64) 131 { 132 long l = 1L << curChar; 133 MatchLoop: do 134 { 135 switch(jjstateSet[--i]) 136 { 137 case 3: 138 if (curChar == 36) 139 { 140 if (kind > 2) 141 kind = 2; 142 jjCheckNAdd(4); 143 } 144 else if (curChar == 34) 145 jjCheckNAddTwoStates(1, 2); 146 break; 147 case 5: 148 if ((0xfffffffbffffffffL & l) != 0L) 149 jjCheckNAddTwoStates(1, 2); 150 else if (curChar == 34) 151 { 152 if (kind > 1) 153 kind = 1; 154 jjstateSet[jjnewStateCnt++] = 0; 155 } 156 break; 157 case 0: 158 if (curChar == 34) 159 jjCheckNAddTwoStates(1, 2); 160 break; 161 case 1: 162 if ((0xfffffffbffffffffL & l) != 0L) 163 jjCheckNAddTwoStates(1, 2); 164 break; 165 case 2: 166 if (curChar != 34) 167 break; 168 if (kind > 1) 169 kind = 1; 170 jjstateSet[jjnewStateCnt++] = 0; 171 break; 172 case 4: 173 if ((0x3ff001000000000L & l) == 0L) 174 break; 175 if (kind > 2) 176 kind = 2; 177 jjCheckNAdd(4); 178 break; 179 default : break; 180 } 181 } while(i != startsAt); 182 } 183 else if (curChar < 128) 184 { 185 long l = 1L << (curChar & 077); 186 MatchLoop: do 187 { 188 switch(jjstateSet[--i]) 189 { 190 case 3: 191 case 4: 192 if ((0x7fffffe87fffffeL & l) == 0L) 193 break; 194 if (kind > 2) 195 kind = 2; 196 jjCheckNAdd(4); 197 break; 198 case 5: 199 case 1: 200 jjCheckNAddTwoStates(1, 2); 201 break; 202 default : break; 203 } 204 } while(i != startsAt); 205 } 206 else 207 { 208 int hiByte = (int)(curChar >> 8); 209 int i1 = hiByte >> 6; 210 long l1 = 1L << (hiByte & 077); 211 int i2 = (curChar & 0xff) >> 6; 212 long l2 = 1L << (curChar & 077); 213 MatchLoop: do 214 { 215 switch(jjstateSet[--i]) 216 { 217 case 3: 218 case 4: 219 if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) 220 break; 221 if (kind > 2) 222 kind = 2; 223 jjCheckNAdd(4); 224 break; 225 case 5: 226 case 1: 227 if (jjCanMove_0(hiByte, i1, i2, l1, l2)) 228 jjCheckNAddTwoStates(1, 2); 229 break; 230 default : break; 231 } 232 } while(i != startsAt); 233 } 234 if (kind != 0x7fffffff) 235 { 236 jjmatchedKind = kind; 237 jjmatchedPos = curPos; 238 kind = 0x7fffffff; 239 } 240 ++curPos; 241 if ((i = jjnewStateCnt) == (startsAt = 5 - (jjnewStateCnt = startsAt))) 242 return curPos; 243 try { curChar = input_stream.readChar(); } 244 catch(java.io.IOException e) { return curPos; } 245 } 246 } 247 static final int[] jjnextStates = { 248 }; 249 private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) 250 { 251 switch(hiByte) 252 { 253 case 0: 254 return ((jjbitVec2[i2] & l2) != 0L); 255 default : 256 if ((jjbitVec0[i1] & l1) != 0L) 257 return true; 258 return false; 259 } 260 } 261 private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2) 262 { 263 switch(hiByte) 264 { 265 case 0: 266 return ((jjbitVec4[i2] & l2) != 0L); 267 case 48: 268 return ((jjbitVec5[i2] & l2) != 0L); 269 case 49: 270 return ((jjbitVec6[i2] & l2) != 0L); 271 case 51: 272 return ((jjbitVec7[i2] & l2) != 0L); 273 case 61: 274 return ((jjbitVec8[i2] & l2) != 0L); 275 default : 276 if ((jjbitVec3[i1] & l1) != 0L) 277 return true; 278 return false; 279 } 280 } 281 public static final String[] jjstrLiteralImages = { 282 "", null, null, null, null, "\50", "\51", "\173", "\175", "\133", "\135", 283 "\56", "\75", "\174", "\42", null, null, null, null, null, }; 284 public static final String[] lexStateNames = { 285 "DEFAULT", 286 }; 287 static final long[] jjtoToken = { 288 0x7fe7L, 289 }; 290 static final long[] jjtoSkip = { 291 0xf8000L, 292 }; 293 protected SimpleCharStream input_stream; 294 private final int[] jjrounds = new int[5]; 295 private final int[] jjstateSet = new int[10]; 296 protected char curChar; 297 public WirthParserTokenManager(SimpleCharStream stream){ 298 if (SimpleCharStream.staticFlag) 299 throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); 300 input_stream = stream; 301 } 302 public WirthParserTokenManager(SimpleCharStream stream, int lexState){ 303 this(stream); 304 SwitchTo(lexState); 305 } 306 public void ReInit(SimpleCharStream stream) 307 { 308 jjmatchedPos = jjnewStateCnt = 0; 309 curLexState = defaultLexState; 310 input_stream = stream; 311 ReInitRounds(); 312 } 313 private final void ReInitRounds() 314 { 315 int i; 316 jjround = 0x80000001; 317 for (i = 5; i-- > 0;) 318 jjrounds[i] = 0x80000000; 319 } 320 public void ReInit(SimpleCharStream stream, int lexState) 321 { 322 ReInit(stream); 323 SwitchTo(lexState); 324 } 325 public void SwitchTo(int lexState) 326 { 327 if (lexState >= 1 || lexState < 0) 328 throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); 329 else 330 curLexState = lexState; 331 } 332 333 protected Token jjFillToken() 334 { 335 Token t = Token.newToken(jjmatchedKind); 336 t.kind = jjmatchedKind; 337 String im = jjstrLiteralImages[jjmatchedKind]; 338 t.image = (im == null) ? input_stream.GetImage() : im; 339 t.beginLine = input_stream.getBeginLine(); 340 t.beginColumn = input_stream.getBeginColumn(); 341 t.endLine = input_stream.getEndLine(); 342 t.endColumn = input_stream.getEndColumn(); 343 return t; 344 } 345 346 int curLexState = 0; 347 int defaultLexState = 0; 348 int jjnewStateCnt; 349 int jjround; 350 int jjmatchedPos; 351 int jjmatchedKind; 352 353 public Token getNextToken() 354 { 355 int kind; 356 Token specialToken = null; 357 Token matchedToken; 358 int curPos = 0; 359 360 EOFLoop : 361 for (;;) 362 { 363 try 364 { 365 curChar = input_stream.BeginToken(); 366 } 367 catch(java.io.IOException e) 368 { 369 jjmatchedKind = 0; 370 matchedToken = jjFillToken(); 371 return matchedToken; 372 } 373 374 try { input_stream.backup(0); 375 while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L) 376 curChar = input_stream.BeginToken(); 377 } 378 catch (java.io.IOException e1) { continue EOFLoop; } 379 jjmatchedKind = 0x7fffffff; 380 jjmatchedPos = 0; 381 curPos = jjMoveStringLiteralDfa0_0(); 382 if (jjmatchedKind != 0x7fffffff) 383 { 384 if (jjmatchedPos + 1 < curPos) 385 input_stream.backup(curPos - jjmatchedPos - 1); 386 if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) 387 { 388 matchedToken = jjFillToken(); 389 return matchedToken; 390 } 391 else 392 { 393 continue EOFLoop; 394 } 395 } 396 int error_line = input_stream.getEndLine(); 397 int error_column = input_stream.getEndColumn(); 398 String error_after = null; 399 boolean EOFSeen = false; 400 try { input_stream.readChar(); input_stream.backup(1); } 401 catch (java.io.IOException e1) { 402 EOFSeen = true; 403 error_after = curPos <= 1 ? "" : input_stream.GetImage(); 404 if (curChar == '\n' || curChar == '\r') { 405 error_line++; 406 error_column = 0; 407 } 408 else 409 error_column++; 410 } 411 if (!EOFSeen) { 412 input_stream.backup(1); 413 error_after = curPos <= 1 ? "" : input_stream.GetImage(); 414 } 415 throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); 416 } 417 } 418 419 }