001: /* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */
002: package org.apache.lucene.queryParser.surround.parser;
003:
004: import java.util.ArrayList;
005: import java.util.List;
006: import java.io.StringReader;
007: import org.apache.lucene.analysis.TokenStream;
008: import org.apache.lucene.queryParser.surround.query.SrndQuery;
009: import org.apache.lucene.queryParser.surround.query.FieldsQuery;
010: import org.apache.lucene.queryParser.surround.query.OrQuery;
011: import org.apache.lucene.queryParser.surround.query.AndQuery;
012: import org.apache.lucene.queryParser.surround.query.NotQuery;
013: import org.apache.lucene.queryParser.surround.query.DistanceQuery;
014: import org.apache.lucene.queryParser.surround.query.SrndTermQuery;
015: import org.apache.lucene.queryParser.surround.query.SrndPrefixQuery;
016: import org.apache.lucene.queryParser.surround.query.SrndTruncQuery;
017:
018: public class QueryParserTokenManager implements QueryParserConstants {
019: public java.io.PrintStream debugStream = System.out;
020:
021: public void setDebugStream(java.io.PrintStream ds) {
022: debugStream = ds;
023: }
024:
025: private final int jjStopStringLiteralDfa_1(int pos, long active0) {
026: switch (pos) {
027: default:
028: return -1;
029: }
030: }
031:
032: private final int jjStartNfa_1(int pos, long active0) {
033: return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0),
034: pos + 1);
035: }
036:
037: private final int jjStopAtPos(int pos, int kind) {
038: jjmatchedKind = kind;
039: jjmatchedPos = pos;
040: return pos + 1;
041: }
042:
043: private final int jjStartNfaWithStates_1(int pos, int kind,
044: int state) {
045: jjmatchedKind = kind;
046: jjmatchedPos = pos;
047: try {
048: curChar = input_stream.readChar();
049: } catch (java.io.IOException e) {
050: return pos + 1;
051: }
052: return jjMoveNfa_1(state, pos + 1);
053: }
054:
055: private final int jjMoveStringLiteralDfa0_1() {
056: switch (curChar) {
057: case 40:
058: return jjStopAtPos(0, 13);
059: case 41:
060: return jjStopAtPos(0, 14);
061: case 44:
062: return jjStopAtPos(0, 15);
063: case 58:
064: return jjStopAtPos(0, 16);
065: case 94:
066: return jjStopAtPos(0, 17);
067: default:
068: return jjMoveNfa_1(0, 0);
069: }
070: }
071:
072: private final void jjCheckNAdd(int state) {
073: if (jjrounds[state] != jjround) {
074: jjstateSet[jjnewStateCnt++] = state;
075: jjrounds[state] = jjround;
076: }
077: }
078:
079: private final void jjAddStates(int start, int end) {
080: do {
081: jjstateSet[jjnewStateCnt++] = jjnextStates[start];
082: } while (start++ != end);
083: }
084:
085: private final void jjCheckNAddTwoStates(int state1, int state2) {
086: jjCheckNAdd(state1);
087: jjCheckNAdd(state2);
088: }
089:
090: private final void jjCheckNAddStates(int start, int end) {
091: do {
092: jjCheckNAdd(jjnextStates[start]);
093: } while (start++ != end);
094: }
095:
096: private final void jjCheckNAddStates(int start) {
097: jjCheckNAdd(jjnextStates[start]);
098: jjCheckNAdd(jjnextStates[start + 1]);
099: }
100:
101: static final long[] jjbitVec0 = { 0xfffffffffffffffeL,
102: 0xffffffffffffffffL, 0xffffffffffffffffL,
103: 0xffffffffffffffffL };
104: static final long[] jjbitVec2 = { 0x0L, 0x0L, 0xffffffffffffffffL,
105: 0xffffffffffffffffL };
106:
107: private final int jjMoveNfa_1(int startState, int curPos) {
108: int[] nextStates;
109: int startsAt = 0;
110: jjnewStateCnt = 38;
111: int i = 1;
112: jjstateSet[0] = startState;
113: int j, kind = 0x7fffffff;
114: for (;;) {
115: if (++jjround == 0x7fffffff)
116: ReInitRounds();
117: if (curChar < 64) {
118: long l = 1L << curChar;
119: MatchLoop: do {
120: switch (jjstateSet[--i]) {
121: case 0:
122: if ((0x7bffe8faffffd9ffL & l) != 0L) {
123: if (kind > 22)
124: kind = 22;
125: jjCheckNAddStates(0, 4);
126: } else if ((0x100002600L & l) != 0L) {
127: if (kind > 7)
128: kind = 7;
129: } else if (curChar == 34)
130: jjCheckNAddStates(5, 7);
131: if ((0x3fc000000000000L & l) != 0L)
132: jjCheckNAddStates(8, 11);
133: else if (curChar == 49)
134: jjCheckNAddTwoStates(20, 21);
135: break;
136: case 19:
137: if ((0x3fc000000000000L & l) != 0L)
138: jjCheckNAddStates(8, 11);
139: break;
140: case 20:
141: if ((0x3ff000000000000L & l) != 0L)
142: jjCheckNAdd(17);
143: break;
144: case 21:
145: if ((0x3ff000000000000L & l) != 0L)
146: jjCheckNAdd(18);
147: break;
148: case 22:
149: if (curChar == 49)
150: jjCheckNAddTwoStates(20, 21);
151: break;
152: case 23:
153: if (curChar == 34)
154: jjCheckNAddStates(5, 7);
155: break;
156: case 24:
157: if ((0xfffffffbffffffffL & l) != 0L)
158: jjCheckNAddTwoStates(24, 25);
159: break;
160: case 25:
161: if (curChar == 34)
162: jjstateSet[jjnewStateCnt++] = 26;
163: break;
164: case 26:
165: if (curChar == 42 && kind > 18)
166: kind = 18;
167: break;
168: case 27:
169: if ((0xfffffffbffffffffL & l) != 0L)
170: jjCheckNAddStates(12, 14);
171: break;
172: case 29:
173: if (curChar == 34)
174: jjCheckNAddStates(12, 14);
175: break;
176: case 30:
177: if (curChar == 34 && kind > 19)
178: kind = 19;
179: break;
180: case 31:
181: if ((0x7bffe8faffffd9ffL & l) == 0L)
182: break;
183: if (kind > 22)
184: kind = 22;
185: jjCheckNAddStates(0, 4);
186: break;
187: case 32:
188: if ((0x7bffe8faffffd9ffL & l) != 0L)
189: jjCheckNAddTwoStates(32, 33);
190: break;
191: case 33:
192: if (curChar == 42 && kind > 20)
193: kind = 20;
194: break;
195: case 34:
196: if ((0x7bffe8faffffd9ffL & l) != 0L)
197: jjCheckNAddTwoStates(34, 35);
198: break;
199: case 35:
200: if ((0x8000040000000000L & l) == 0L)
201: break;
202: if (kind > 21)
203: kind = 21;
204: jjCheckNAddTwoStates(35, 36);
205: break;
206: case 36:
207: if ((0xfbffecfaffffd9ffL & l) == 0L)
208: break;
209: if (kind > 21)
210: kind = 21;
211: jjCheckNAdd(36);
212: break;
213: case 37:
214: if ((0x7bffe8faffffd9ffL & l) == 0L)
215: break;
216: if (kind > 22)
217: kind = 22;
218: jjCheckNAdd(37);
219: break;
220: default:
221: break;
222: }
223: } while (i != startsAt);
224: } else if (curChar < 128) {
225: long l = 1L << (curChar & 077);
226: MatchLoop: do {
227: switch (jjstateSet[--i]) {
228: case 0:
229: if ((0xffffffffbfffffffL & l) != 0L) {
230: if (kind > 22)
231: kind = 22;
232: jjCheckNAddStates(0, 4);
233: }
234: if ((0x400000004000L & l) != 0L) {
235: if (kind > 12)
236: kind = 12;
237: } else if ((0x80000000800000L & l) != 0L) {
238: if (kind > 11)
239: kind = 11;
240: } else if (curChar == 97)
241: jjstateSet[jjnewStateCnt++] = 9;
242: else if (curChar == 65)
243: jjstateSet[jjnewStateCnt++] = 6;
244: else if (curChar == 111)
245: jjstateSet[jjnewStateCnt++] = 3;
246: else if (curChar == 79)
247: jjstateSet[jjnewStateCnt++] = 1;
248: if (curChar == 110)
249: jjstateSet[jjnewStateCnt++] = 15;
250: else if (curChar == 78)
251: jjstateSet[jjnewStateCnt++] = 12;
252: break;
253: case 1:
254: if (curChar == 82 && kind > 8)
255: kind = 8;
256: break;
257: case 2:
258: if (curChar == 79)
259: jjstateSet[jjnewStateCnt++] = 1;
260: break;
261: case 3:
262: if (curChar == 114 && kind > 8)
263: kind = 8;
264: break;
265: case 4:
266: if (curChar == 111)
267: jjstateSet[jjnewStateCnt++] = 3;
268: break;
269: case 5:
270: if (curChar == 68 && kind > 9)
271: kind = 9;
272: break;
273: case 6:
274: if (curChar == 78)
275: jjstateSet[jjnewStateCnt++] = 5;
276: break;
277: case 7:
278: if (curChar == 65)
279: jjstateSet[jjnewStateCnt++] = 6;
280: break;
281: case 8:
282: if (curChar == 100 && kind > 9)
283: kind = 9;
284: break;
285: case 9:
286: if (curChar == 110)
287: jjstateSet[jjnewStateCnt++] = 8;
288: break;
289: case 10:
290: if (curChar == 97)
291: jjstateSet[jjnewStateCnt++] = 9;
292: break;
293: case 11:
294: if (curChar == 84 && kind > 10)
295: kind = 10;
296: break;
297: case 12:
298: if (curChar == 79)
299: jjstateSet[jjnewStateCnt++] = 11;
300: break;
301: case 13:
302: if (curChar == 78)
303: jjstateSet[jjnewStateCnt++] = 12;
304: break;
305: case 14:
306: if (curChar == 116 && kind > 10)
307: kind = 10;
308: break;
309: case 15:
310: if (curChar == 111)
311: jjstateSet[jjnewStateCnt++] = 14;
312: break;
313: case 16:
314: if (curChar == 110)
315: jjstateSet[jjnewStateCnt++] = 15;
316: break;
317: case 17:
318: if ((0x80000000800000L & l) != 0L && kind > 11)
319: kind = 11;
320: break;
321: case 18:
322: if ((0x400000004000L & l) != 0L && kind > 12)
323: kind = 12;
324: break;
325: case 24:
326: jjAddStates(15, 16);
327: break;
328: case 27:
329: if ((0xffffffffefffffffL & l) != 0L)
330: jjCheckNAddStates(12, 14);
331: break;
332: case 28:
333: if (curChar == 92)
334: jjstateSet[jjnewStateCnt++] = 29;
335: break;
336: case 29:
337: if (curChar == 92)
338: jjCheckNAddStates(12, 14);
339: break;
340: case 31:
341: if ((0xffffffffbfffffffL & l) == 0L)
342: break;
343: if (kind > 22)
344: kind = 22;
345: jjCheckNAddStates(0, 4);
346: break;
347: case 32:
348: if ((0xffffffffbfffffffL & l) != 0L)
349: jjCheckNAddTwoStates(32, 33);
350: break;
351: case 34:
352: if ((0xffffffffbfffffffL & l) != 0L)
353: jjCheckNAddTwoStates(34, 35);
354: break;
355: case 36:
356: if ((0xffffffffbfffffffL & l) == 0L)
357: break;
358: if (kind > 21)
359: kind = 21;
360: jjstateSet[jjnewStateCnt++] = 36;
361: break;
362: case 37:
363: if ((0xffffffffbfffffffL & l) == 0L)
364: break;
365: if (kind > 22)
366: kind = 22;
367: jjCheckNAdd(37);
368: break;
369: default:
370: break;
371: }
372: } while (i != startsAt);
373: } else {
374: int hiByte = (int) (curChar >> 8);
375: int i1 = hiByte >> 6;
376: long l1 = 1L << (hiByte & 077);
377: int i2 = (curChar & 0xff) >> 6;
378: long l2 = 1L << (curChar & 077);
379: MatchLoop: do {
380: switch (jjstateSet[--i]) {
381: case 0:
382: if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
383: break;
384: if (kind > 22)
385: kind = 22;
386: jjCheckNAddStates(0, 4);
387: break;
388: case 24:
389: if (jjCanMove_0(hiByte, i1, i2, l1, l2))
390: jjAddStates(15, 16);
391: break;
392: case 27:
393: if (jjCanMove_0(hiByte, i1, i2, l1, l2))
394: jjAddStates(12, 14);
395: break;
396: case 32:
397: if (jjCanMove_0(hiByte, i1, i2, l1, l2))
398: jjCheckNAddTwoStates(32, 33);
399: break;
400: case 34:
401: if (jjCanMove_0(hiByte, i1, i2, l1, l2))
402: jjCheckNAddTwoStates(34, 35);
403: break;
404: case 36:
405: if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
406: break;
407: if (kind > 21)
408: kind = 21;
409: jjstateSet[jjnewStateCnt++] = 36;
410: break;
411: case 37:
412: if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
413: break;
414: if (kind > 22)
415: kind = 22;
416: jjCheckNAdd(37);
417: break;
418: default:
419: break;
420: }
421: } while (i != startsAt);
422: }
423: if (kind != 0x7fffffff) {
424: jjmatchedKind = kind;
425: jjmatchedPos = curPos;
426: kind = 0x7fffffff;
427: }
428: ++curPos;
429: if ((i = jjnewStateCnt) == (startsAt = 38 - (jjnewStateCnt = startsAt)))
430: return curPos;
431: try {
432: curChar = input_stream.readChar();
433: } catch (java.io.IOException e) {
434: return curPos;
435: }
436: }
437: }
438:
439: private final int jjMoveStringLiteralDfa0_0() {
440: return jjMoveNfa_0(0, 0);
441: }
442:
443: private final int jjMoveNfa_0(int startState, int curPos) {
444: int[] nextStates;
445: int startsAt = 0;
446: jjnewStateCnt = 3;
447: int i = 1;
448: jjstateSet[0] = startState;
449: int j, kind = 0x7fffffff;
450: for (;;) {
451: if (++jjround == 0x7fffffff)
452: ReInitRounds();
453: if (curChar < 64) {
454: long l = 1L << curChar;
455: MatchLoop: do {
456: switch (jjstateSet[--i]) {
457: case 0:
458: if ((0x3ff000000000000L & l) == 0L)
459: break;
460: if (kind > 23)
461: kind = 23;
462: jjAddStates(17, 18);
463: break;
464: case 1:
465: if (curChar == 46)
466: jjCheckNAdd(2);
467: break;
468: case 2:
469: if ((0x3ff000000000000L & l) == 0L)
470: break;
471: if (kind > 23)
472: kind = 23;
473: jjCheckNAdd(2);
474: break;
475: default:
476: break;
477: }
478: } while (i != startsAt);
479: } else if (curChar < 128) {
480: long l = 1L << (curChar & 077);
481: MatchLoop: do {
482: switch (jjstateSet[--i]) {
483: default:
484: break;
485: }
486: } while (i != startsAt);
487: } else {
488: int hiByte = (int) (curChar >> 8);
489: int i1 = hiByte >> 6;
490: long l1 = 1L << (hiByte & 077);
491: int i2 = (curChar & 0xff) >> 6;
492: long l2 = 1L << (curChar & 077);
493: MatchLoop: do {
494: switch (jjstateSet[--i]) {
495: default:
496: break;
497: }
498: } while (i != startsAt);
499: }
500: if (kind != 0x7fffffff) {
501: jjmatchedKind = kind;
502: jjmatchedPos = curPos;
503: kind = 0x7fffffff;
504: }
505: ++curPos;
506: if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
507: return curPos;
508: try {
509: curChar = input_stream.readChar();
510: } catch (java.io.IOException e) {
511: return curPos;
512: }
513: }
514: }
515:
516: static final int[] jjnextStates = { 32, 33, 34, 35, 37, 24, 27, 28,
517: 20, 17, 21, 18, 27, 28, 30, 24, 25, 0, 1, };
518:
519: private static final boolean jjCanMove_0(int hiByte, int i1,
520: int i2, long l1, long l2) {
521: switch (hiByte) {
522: case 0:
523: return ((jjbitVec2[i2] & l2) != 0L);
524: default:
525: if ((jjbitVec0[i1] & l1) != 0L)
526: return true;
527: return false;
528: }
529: }
530:
531: public static final String[] jjstrLiteralImages = { "", null, null,
532: null, null, null, null, null, null, null, null, null, null,
533: "\50", "\51", "\54", "\72", "\136", null, null, null, null,
534: null, null, };
535: public static final String[] lexStateNames = { "Boost", "DEFAULT", };
536: public static final int[] jjnewLexState = { -1, -1, -1, -1, -1, -1,
537: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1,
538: -1, -1, 1, };
539: static final long[] jjtoToken = { 0xffff01L, };
540: static final long[] jjtoSkip = { 0x80L, };
541: protected CharStream input_stream;
542: private final int[] jjrounds = new int[38];
543: private final int[] jjstateSet = new int[76];
544: protected char curChar;
545:
546: public QueryParserTokenManager(CharStream stream) {
547: input_stream = stream;
548: }
549:
550: public QueryParserTokenManager(CharStream stream, int lexState) {
551: this (stream);
552: SwitchTo(lexState);
553: }
554:
555: public void ReInit(CharStream stream) {
556: jjmatchedPos = jjnewStateCnt = 0;
557: curLexState = defaultLexState;
558: input_stream = stream;
559: ReInitRounds();
560: }
561:
562: private final void ReInitRounds() {
563: int i;
564: jjround = 0x80000001;
565: for (i = 38; i-- > 0;)
566: jjrounds[i] = 0x80000000;
567: }
568:
569: public void ReInit(CharStream stream, int lexState) {
570: ReInit(stream);
571: SwitchTo(lexState);
572: }
573:
574: public void SwitchTo(int lexState) {
575: if (lexState >= 2 || lexState < 0)
576: throw new TokenMgrError(
577: "Error: Ignoring invalid lexical state : "
578: + lexState + ". State unchanged.",
579: TokenMgrError.INVALID_LEXICAL_STATE);
580: else
581: curLexState = lexState;
582: }
583:
584: protected Token jjFillToken() {
585: Token t = Token.newToken(jjmatchedKind);
586: t.kind = jjmatchedKind;
587: String im = jjstrLiteralImages[jjmatchedKind];
588: t.image = (im == null) ? input_stream.GetImage() : im;
589: t.beginLine = input_stream.getBeginLine();
590: t.beginColumn = input_stream.getBeginColumn();
591: t.endLine = input_stream.getEndLine();
592: t.endColumn = input_stream.getEndColumn();
593: return t;
594: }
595:
596: int curLexState = 1;
597: int defaultLexState = 1;
598: int jjnewStateCnt;
599: int jjround;
600: int jjmatchedPos;
601: int jjmatchedKind;
602:
603: public Token getNextToken() {
604: int kind;
605: Token specialToken = null;
606: Token matchedToken;
607: int curPos = 0;
608:
609: EOFLoop: for (;;) {
610: try {
611: curChar = input_stream.BeginToken();
612: } catch (java.io.IOException e) {
613: jjmatchedKind = 0;
614: matchedToken = jjFillToken();
615: return matchedToken;
616: }
617:
618: switch (curLexState) {
619: case 0:
620: jjmatchedKind = 0x7fffffff;
621: jjmatchedPos = 0;
622: curPos = jjMoveStringLiteralDfa0_0();
623: break;
624: case 1:
625: jjmatchedKind = 0x7fffffff;
626: jjmatchedPos = 0;
627: curPos = jjMoveStringLiteralDfa0_1();
628: break;
629: }
630: if (jjmatchedKind != 0x7fffffff) {
631: if (jjmatchedPos + 1 < curPos)
632: input_stream.backup(curPos - jjmatchedPos - 1);
633: if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
634: matchedToken = jjFillToken();
635: if (jjnewLexState[jjmatchedKind] != -1)
636: curLexState = jjnewLexState[jjmatchedKind];
637: return matchedToken;
638: } else {
639: if (jjnewLexState[jjmatchedKind] != -1)
640: curLexState = jjnewLexState[jjmatchedKind];
641: continue EOFLoop;
642: }
643: }
644: int error_line = input_stream.getEndLine();
645: int error_column = input_stream.getEndColumn();
646: String error_after = null;
647: boolean EOFSeen = false;
648: try {
649: input_stream.readChar();
650: input_stream.backup(1);
651: } catch (java.io.IOException e1) {
652: EOFSeen = true;
653: error_after = curPos <= 1 ? "" : input_stream
654: .GetImage();
655: if (curChar == '\n' || curChar == '\r') {
656: error_line++;
657: error_column = 0;
658: } else
659: error_column++;
660: }
661: if (!EOFSeen) {
662: input_stream.backup(1);
663: error_after = curPos <= 1 ? "" : input_stream
664: .GetImage();
665: }
666: throw new TokenMgrError(EOFSeen, curLexState, error_line,
667: error_column, error_after, curChar,
668: TokenMgrError.LEXICAL_ERROR);
669: }
670: }
671:
672: }
|