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