1
/* Generated By:JavaCC: Do not edit this line. StandardSyntaxParserTokenManager.java */
2
package org.apache.lucene.queryParser.standard.parser;
4
* Licensed to the Apache Software Foundation (ASF) under one or more
5
* contributor license agreements. See the NOTICE file distributed with
6
* this work for additional information regarding copyright ownership.
7
* The ASF licenses this file to You under the Apache License, Version 2.0
8
* (the "License"); you may not use this file except in compliance with
9
* the License. You may obtain a copy of the License at
11
* http://www.apache.org/licenses/LICENSE-2.0
13
* Unless required by applicable law or agreed to in writing, software
14
* distributed under the License is distributed on an "AS IS" BASIS,
15
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
* See the License for the specific language governing permissions and
17
* limitations under the License.
20
import java.io.StringReader;
21
import java.util.ArrayList;
22
import java.util.List;
23
import java.util.Vector;
24
import org.apache.lucene.messages.Message;
25
import org.apache.lucene.messages.MessageImpl;
26
import org.apache.lucene.queryParser.core.QueryNodeError;
27
import org.apache.lucene.queryParser.core.QueryNodeException;
28
import org.apache.lucene.queryParser.core.QueryNodeParseException;
29
import org.apache.lucene.queryParser.core.messages.QueryParserMessages;
30
import org.apache.lucene.queryParser.core.nodes.AndQueryNode;
31
import org.apache.lucene.queryParser.core.nodes.BooleanQueryNode;
32
import org.apache.lucene.queryParser.core.nodes.BoostQueryNode;
33
import org.apache.lucene.queryParser.core.nodes.FieldQueryNode;
34
import org.apache.lucene.queryParser.core.nodes.FuzzyQueryNode;
35
import org.apache.lucene.queryParser.core.nodes.ModifierQueryNode;
36
import org.apache.lucene.queryParser.core.nodes.GroupQueryNode;
37
import org.apache.lucene.queryParser.core.nodes.OpaqueQueryNode;
38
import org.apache.lucene.queryParser.core.nodes.OrQueryNode;
39
import org.apache.lucene.queryParser.core.nodes.ParametricQueryNode;
40
import org.apache.lucene.queryParser.core.nodes.ParametricRangeQueryNode;
41
import org.apache.lucene.queryParser.core.nodes.SlopQueryNode;
42
import org.apache.lucene.queryParser.core.nodes.ProximityQueryNode;
43
import org.apache.lucene.queryParser.core.nodes.QueryNode;
44
import org.apache.lucene.queryParser.core.nodes.QueryNodeImpl;
45
import org.apache.lucene.queryParser.core.nodes.QuotedFieldQueryNode;
46
import org.apache.lucene.queryParser.core.parser.SyntaxParser;
49
public class StandardSyntaxParserTokenManager implements StandardSyntaxParserConstants
53
public java.io.PrintStream debugStream = System.out;
54
/** Set debug output. */
55
public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
56
private final int jjStopStringLiteralDfa_3(int pos, long active0)
64
private final int jjStartNfa_3(int pos, long active0)
66
return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0), pos + 1);
68
private int jjStopAtPos(int pos, int kind)
74
private int jjMoveStringLiteralDfa0_3()
79
return jjStopAtPos(0, 13);
81
return jjStopAtPos(0, 14);
83
return jjStopAtPos(0, 11);
85
return jjStopAtPos(0, 12);
87
return jjStopAtPos(0, 15);
89
return jjStopAtPos(0, 20);
91
return jjStopAtPos(0, 16);
93
return jjStopAtPos(0, 21);
95
return jjMoveNfa_3(0, 0);
98
static final long[] jjbitVec0 = {
99
0x1L, 0x0L, 0x0L, 0x0L
101
static final long[] jjbitVec1 = {
102
0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
104
static final long[] jjbitVec3 = {
105
0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
107
static final long[] jjbitVec4 = {
108
0xfffefffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
110
private int jjMoveNfa_3(int startState, int curPos)
115
jjstateSet[0] = startState;
116
int kind = 0x7fffffff;
119
if (++jjround == 0x7fffffff)
123
long l = 1L << curChar;
126
switch(jjstateSet[--i])
129
if ((0xfbffd4f8ffffd9ffL & l) != 0L)
133
jjCheckNAddTwoStates(20, 21);
135
else if ((0x100002600L & l) != 0L)
140
else if (curChar == 34)
141
jjCheckNAddStates(0, 2);
142
else if (curChar == 33)
148
jjstateSet[jjnewStateCnt++] = 4;
151
if (curChar == 38 && kind > 8)
156
jjstateSet[jjnewStateCnt++] = 4;
159
if (curChar == 33 && kind > 10)
164
jjCheckNAddStates(0, 2);
167
if ((0xfffffffbffffffffL & l) != 0L)
168
jjCheckNAddStates(0, 2);
171
jjCheckNAddStates(0, 2);
174
if (curChar == 34 && kind > 17)
178
if ((0xfbffd4f8ffffd9ffL & l) == 0L)
182
jjCheckNAddTwoStates(20, 21);
185
if ((0xfbfffcf8ffffd9ffL & l) == 0L)
189
jjCheckNAddTwoStates(20, 21);
194
jjCheckNAddTwoStates(20, 21);
197
if ((0x3ff000000000000L & l) == 0L)
208
if ((0x3ff000000000000L & l) == 0L)
216
} while(i != startsAt);
218
else if (curChar < 128)
220
long l = 1L << (curChar & 077);
223
switch(jjstateSet[--i])
226
if ((0x97ffffff87ffffffL & l) != 0L)
230
jjCheckNAddTwoStates(20, 21);
232
else if (curChar == 126)
236
jjstateSet[jjnewStateCnt++] = 25;
238
else if (curChar == 92)
241
jjstateSet[jjnewStateCnt++] = 11;
242
else if (curChar == 124)
243
jjstateSet[jjnewStateCnt++] = 8;
244
else if (curChar == 79)
245
jjstateSet[jjnewStateCnt++] = 6;
246
else if (curChar == 65)
247
jjstateSet[jjnewStateCnt++] = 2;
250
if (curChar == 68 && kind > 8)
255
jjstateSet[jjnewStateCnt++] = 1;
259
jjstateSet[jjnewStateCnt++] = 2;
262
if (curChar == 82 && kind > 9)
267
jjstateSet[jjnewStateCnt++] = 6;
270
if (curChar == 124 && kind > 9)
275
jjstateSet[jjnewStateCnt++] = 8;
278
if (curChar == 84 && kind > 10)
283
jjstateSet[jjnewStateCnt++] = 10;
287
jjstateSet[jjnewStateCnt++] = 11;
290
if ((0xffffffffefffffffL & l) != 0L)
291
jjCheckNAddStates(0, 2);
295
jjstateSet[jjnewStateCnt++] = 17;
298
jjCheckNAddStates(0, 2);
302
if ((0x97ffffff87ffffffL & l) == 0L)
306
jjCheckNAddTwoStates(20, 21);
310
jjCheckNAddTwoStates(22, 22);
315
jjCheckNAddTwoStates(20, 21);
326
jjstateSet[jjnewStateCnt++] = 25;
330
} while(i != startsAt);
334
int hiByte = (int)(curChar >> 8);
335
int i1 = hiByte >> 6;
336
long l1 = 1L << (hiByte & 077);
337
int i2 = (curChar & 0xff) >> 6;
338
long l2 = 1L << (curChar & 077);
341
switch(jjstateSet[--i])
344
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
349
if (jjCanMove_2(hiByte, i1, i2, l1, l2))
353
jjCheckNAddTwoStates(20, 21);
358
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
359
jjCheckNAddStates(0, 2);
363
if (!jjCanMove_2(hiByte, i1, i2, l1, l2))
367
jjCheckNAddTwoStates(20, 21);
370
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
374
jjCheckNAddTwoStates(20, 21);
378
} while(i != startsAt);
380
if (kind != 0x7fffffff)
382
jjmatchedKind = kind;
383
jjmatchedPos = curPos;
387
if ((i = jjnewStateCnt) == (startsAt = 28 - (jjnewStateCnt = startsAt)))
389
try { curChar = input_stream.readChar(); }
390
catch(java.io.IOException e) { return curPos; }
393
private final int jjStopStringLiteralDfa_1(int pos, long active0)
398
if ((active0 & 0x8000000L) != 0L)
408
private final int jjStartNfa_1(int pos, long active0)
410
return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1);
412
private int jjMoveStringLiteralDfa0_1()
417
return jjMoveStringLiteralDfa1_1(0x8000000L);
419
return jjStopAtPos(0, 28);
421
return jjMoveNfa_1(0, 0);
424
private int jjMoveStringLiteralDfa1_1(long active0)
426
try { curChar = input_stream.readChar(); }
427
catch(java.io.IOException e) {
428
jjStopStringLiteralDfa_1(0, active0);
434
if ((active0 & 0x8000000L) != 0L)
435
return jjStartNfaWithStates_1(1, 27, 6);
440
return jjStartNfa_1(0, active0);
442
private int jjStartNfaWithStates_1(int pos, int kind, int state)
444
jjmatchedKind = kind;
446
try { curChar = input_stream.readChar(); }
447
catch(java.io.IOException e) { return pos + 1; }
448
return jjMoveNfa_1(state, pos + 1);
450
private int jjMoveNfa_1(int startState, int curPos)
455
jjstateSet[0] = startState;
456
int kind = 0x7fffffff;
459
if (++jjround == 0x7fffffff)
463
long l = 1L << curChar;
466
switch(jjstateSet[--i])
469
if ((0xfffffffeffffffffL & l) != 0L)
475
if ((0x100002600L & l) != 0L)
480
else if (curChar == 34)
481
jjCheckNAddTwoStates(2, 4);
485
jjCheckNAddTwoStates(2, 4);
488
if ((0xfffffffbffffffffL & l) != 0L)
489
jjCheckNAddStates(5, 7);
493
jjCheckNAddStates(5, 7);
496
if (curChar == 34 && kind > 29)
500
if ((0xfffffffeffffffffL & l) == 0L)
508
} while(i != startsAt);
510
else if (curChar < 128)
512
long l = 1L << (curChar & 077);
515
switch(jjstateSet[--i])
519
if ((0xdfffffffffffffffL & l) == 0L)
530
jjstateSet[jjnewStateCnt++] = 3;
534
} while(i != startsAt);
538
int hiByte = (int)(curChar >> 8);
539
int i1 = hiByte >> 6;
540
long l1 = 1L << (hiByte & 077);
541
int i2 = (curChar & 0xff) >> 6;
542
long l2 = 1L << (curChar & 077);
545
switch(jjstateSet[--i])
548
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
553
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
561
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
565
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
573
} while(i != startsAt);
575
if (kind != 0x7fffffff)
577
jjmatchedKind = kind;
578
jjmatchedPos = curPos;
582
if ((i = jjnewStateCnt) == (startsAt = 7 - (jjnewStateCnt = startsAt)))
584
try { curChar = input_stream.readChar(); }
585
catch(java.io.IOException e) { return curPos; }
588
private int jjMoveStringLiteralDfa0_0()
590
return jjMoveNfa_0(0, 0);
592
private int jjMoveNfa_0(int startState, int curPos)
597
jjstateSet[0] = startState;
598
int kind = 0x7fffffff;
601
if (++jjround == 0x7fffffff)
605
long l = 1L << curChar;
608
switch(jjstateSet[--i])
611
if ((0x3ff000000000000L & l) == 0L)
622
if ((0x3ff000000000000L & l) == 0L)
630
} while(i != startsAt);
632
else if (curChar < 128)
634
long l = 1L << (curChar & 077);
637
switch(jjstateSet[--i])
641
} while(i != startsAt);
645
int hiByte = (int)(curChar >> 8);
646
int i1 = hiByte >> 6;
647
long l1 = 1L << (hiByte & 077);
648
int i2 = (curChar & 0xff) >> 6;
649
long l2 = 1L << (curChar & 077);
652
switch(jjstateSet[--i])
656
} while(i != startsAt);
658
if (kind != 0x7fffffff)
660
jjmatchedKind = kind;
661
jjmatchedPos = curPos;
665
if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
667
try { curChar = input_stream.readChar(); }
668
catch(java.io.IOException e) { return curPos; }
671
private final int jjStopStringLiteralDfa_2(int pos, long active0)
676
if ((active0 & 0x800000L) != 0L)
686
private final int jjStartNfa_2(int pos, long active0)
688
return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1);
690
private int jjMoveStringLiteralDfa0_2()
695
return jjMoveStringLiteralDfa1_2(0x800000L);
697
return jjStopAtPos(0, 24);
699
return jjMoveNfa_2(0, 0);
702
private int jjMoveStringLiteralDfa1_2(long active0)
704
try { curChar = input_stream.readChar(); }
705
catch(java.io.IOException e) {
706
jjStopStringLiteralDfa_2(0, active0);
712
if ((active0 & 0x800000L) != 0L)
713
return jjStartNfaWithStates_2(1, 23, 6);
718
return jjStartNfa_2(0, active0);
720
private int jjStartNfaWithStates_2(int pos, int kind, int state)
722
jjmatchedKind = kind;
724
try { curChar = input_stream.readChar(); }
725
catch(java.io.IOException e) { return pos + 1; }
726
return jjMoveNfa_2(state, pos + 1);
728
private int jjMoveNfa_2(int startState, int curPos)
733
jjstateSet[0] = startState;
734
int kind = 0x7fffffff;
737
if (++jjround == 0x7fffffff)
741
long l = 1L << curChar;
744
switch(jjstateSet[--i])
747
if ((0xfffffffeffffffffL & l) != 0L)
753
if ((0x100002600L & l) != 0L)
758
else if (curChar == 34)
759
jjCheckNAddTwoStates(2, 4);
763
jjCheckNAddTwoStates(2, 4);
766
if ((0xfffffffbffffffffL & l) != 0L)
767
jjCheckNAddStates(5, 7);
771
jjCheckNAddStates(5, 7);
774
if (curChar == 34 && kind > 25)
778
if ((0xfffffffeffffffffL & l) == 0L)
786
} while(i != startsAt);
788
else if (curChar < 128)
790
long l = 1L << (curChar & 077);
793
switch(jjstateSet[--i])
797
if ((0xffffffffdfffffffL & l) == 0L)
808
jjstateSet[jjnewStateCnt++] = 3;
812
} while(i != startsAt);
816
int hiByte = (int)(curChar >> 8);
817
int i1 = hiByte >> 6;
818
long l1 = 1L << (hiByte & 077);
819
int i2 = (curChar & 0xff) >> 6;
820
long l2 = 1L << (curChar & 077);
823
switch(jjstateSet[--i])
826
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
831
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
839
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
843
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
851
} while(i != startsAt);
853
if (kind != 0x7fffffff)
855
jjmatchedKind = kind;
856
jjmatchedPos = curPos;
860
if ((i = jjnewStateCnt) == (startsAt = 7 - (jjnewStateCnt = startsAt)))
862
try { curChar = input_stream.readChar(); }
863
catch(java.io.IOException e) { return curPos; }
866
static final int[] jjnextStates = {
867
15, 16, 18, 25, 26, 2, 4, 5, 0, 1,
869
private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
874
return ((jjbitVec0[i2] & l2) != 0L);
879
private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)
884
return ((jjbitVec3[i2] & l2) != 0L);
886
if ((jjbitVec1[i1] & l1) != 0L)
891
private static final boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, long l2)
896
return ((jjbitVec3[i2] & l2) != 0L);
898
return ((jjbitVec1[i2] & l2) != 0L);
900
if ((jjbitVec4[i1] & l1) != 0L)
906
/** Token literal values. */
907
public static final String[] jjstrLiteralImages = {
908
"", null, null, null, null, null, null, null, null, null, null, "\53", "\55",
909
"\50", "\51", "\72", "\136", null, null, null, "\133", "\173", null, "\124\117",
910
"\135", null, null, "\124\117", "\175", null, null, };
912
/** Lexer state names. */
913
public static final String[] lexStateNames = {
920
/** Lex State array. */
921
public static final int[] jjnewLexState = {
922
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, 2, 1, 3, -1, 3,
923
-1, -1, -1, 3, -1, -1,
925
static final long[] jjtoToken = {
928
static final long[] jjtoSkip = {
931
protected JavaCharStream input_stream;
932
private final int[] jjrounds = new int[28];
933
private final int[] jjstateSet = new int[56];
934
protected char curChar;
936
public StandardSyntaxParserTokenManager(JavaCharStream stream){
937
if (JavaCharStream.staticFlag)
938
throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
939
input_stream = stream;
943
public StandardSyntaxParserTokenManager(JavaCharStream stream, int lexState){
948
/** Reinitialise parser. */
949
public void ReInit(JavaCharStream stream)
951
jjmatchedPos = jjnewStateCnt = 0;
952
curLexState = defaultLexState;
953
input_stream = stream;
956
private void ReInitRounds()
959
jjround = 0x80000001;
960
for (i = 28; i-- > 0;)
961
jjrounds[i] = 0x80000000;
964
/** Reinitialise parser. */
965
public void ReInit(JavaCharStream stream, int lexState)
971
/** Switch to specified lex state. */
972
public void SwitchTo(int lexState)
974
if (lexState >= 4 || lexState < 0)
975
throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
977
curLexState = lexState;
980
protected Token jjFillToken()
983
final String curTokenImage;
986
final int beginColumn;
988
String im = jjstrLiteralImages[jjmatchedKind];
989
curTokenImage = (im == null) ? input_stream.GetImage() : im;
990
beginLine = input_stream.getBeginLine();
991
beginColumn = input_stream.getBeginColumn();
992
endLine = input_stream.getEndLine();
993
endColumn = input_stream.getEndColumn();
994
t = Token.newToken(jjmatchedKind, curTokenImage);
996
t.beginLine = beginLine;
998
t.beginColumn = beginColumn;
999
t.endColumn = endColumn;
1004
int curLexState = 3;
1005
int defaultLexState = 3;
1011
/** Get the next Token. */
1012
public Token getNextToken()
1022
curChar = input_stream.BeginToken();
1024
catch(java.io.IOException e)
1027
matchedToken = jjFillToken();
1028
return matchedToken;
1034
jjmatchedKind = 0x7fffffff;
1036
curPos = jjMoveStringLiteralDfa0_0();
1039
jjmatchedKind = 0x7fffffff;
1041
curPos = jjMoveStringLiteralDfa0_1();
1044
jjmatchedKind = 0x7fffffff;
1046
curPos = jjMoveStringLiteralDfa0_2();
1049
jjmatchedKind = 0x7fffffff;
1051
curPos = jjMoveStringLiteralDfa0_3();
1054
if (jjmatchedKind != 0x7fffffff)
1056
if (jjmatchedPos + 1 < curPos)
1057
input_stream.backup(curPos - jjmatchedPos - 1);
1058
if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
1060
matchedToken = jjFillToken();
1061
if (jjnewLexState[jjmatchedKind] != -1)
1062
curLexState = jjnewLexState[jjmatchedKind];
1063
return matchedToken;
1067
if (jjnewLexState[jjmatchedKind] != -1)
1068
curLexState = jjnewLexState[jjmatchedKind];
1072
int error_line = input_stream.getEndLine();
1073
int error_column = input_stream.getEndColumn();
1074
String error_after = null;
1075
boolean EOFSeen = false;
1076
try { input_stream.readChar(); input_stream.backup(1); }
1077
catch (java.io.IOException e1) {
1079
error_after = curPos <= 1 ? "" : input_stream.GetImage();
1080
if (curChar == '\n' || curChar == '\r') {
1088
input_stream.backup(1);
1089
error_after = curPos <= 1 ? "" : input_stream.GetImage();
1091
throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
1095
private void jjCheckNAdd(int state)
1097
if (jjrounds[state] != jjround)
1099
jjstateSet[jjnewStateCnt++] = state;
1100
jjrounds[state] = jjround;
1103
private void jjAddStates(int start, int end)
1106
jjstateSet[jjnewStateCnt++] = jjnextStates[start];
1107
} while (start++ != end);
1109
private void jjCheckNAddTwoStates(int state1, int state2)
1111
jjCheckNAdd(state1);
1112
jjCheckNAdd(state2);
1115
private void jjCheckNAddStates(int start, int end)
1118
jjCheckNAdd(jjnextStates[start]);
1119
} while (start++ != end);