2 * Copyright 2004 The Apache Software Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */
20 using Lucene
.Net
.Analysis
;
21 using Lucene
.Net
.Documents
;
22 using Term
= Lucene
.Net
.Index
.Term
;
23 using Lucene
.Net
.Search
;
24 using Searchable
= Lucene
.Net
.Search
.Searchable
;
25 using Parameter
= Lucene
.Net
.Util
.Parameter
;
27 namespace Lucene
.Net
.QueryParsers
30 public class QueryParserTokenManager
: QueryParserConstants
32 private void InitBlock()
35 private int JjStopStringLiteralDfa_3(int pos
, long active0
)
45 private int JjStartNfa_3(int pos
, long active0
)
47 return JjMoveNfa_3(JjStopStringLiteralDfa_3(pos
, active0
), pos
+ 1);
49 private int JjStopAtPos(int pos
, int kind
)
55 private int JjStartNfaWithStates_3(int pos
, int kind
, int state
)
61 curChar
= input_stream
.ReadChar();
63 catch (System
.IO
.IOException
)
67 return JjMoveNfa_3(state
, pos
+ 1);
69 private int JjMoveStringLiteralDfa0_3()
75 return JjStopAtPos(0, 12);
78 return JjStopAtPos(0, 13);
81 return JjStopAtPos(0, 10);
84 return JjStopAtPos(0, 11);
87 return JjStopAtPos(0, 14);
90 return JjStopAtPos(0, 21);
93 return JjStopAtPos(0, 15);
96 return JjStopAtPos(0, 22);
99 return JjMoveNfa_3(0, 0);
103 private void JjCheckNAdd(int state
)
105 if (jjrounds
[state
] != jjround
)
107 jjstateSet
[jjnewStateCnt
++] = state
;
108 jjrounds
[state
] = jjround
;
111 private void JjAddStates(int start
, int end
)
115 jjstateSet
[jjnewStateCnt
++] = jjnextStates
[start
];
117 while (start
++ != end
);
119 private void JjCheckNAddTwoStates(int state1
, int state2
)
124 private void JjCheckNAddStates(int start
, int end
)
128 JjCheckNAdd(jjnextStates
[start
]);
130 while (start
++ != end
);
132 private void JjCheckNAddStates(int start
)
134 JjCheckNAdd(jjnextStates
[start
]);
135 JjCheckNAdd(jjnextStates
[start
+ 1]);
137 internal static readonly ulong[] jjbitVec0
= new ulong[]{0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL}
;
138 internal static readonly ulong[] jjbitVec2
= new ulong[]{0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL}
;
139 private int JjMoveNfa_3(int startState
, int curPos
)
145 jjstateSet
[0] = startState
;
146 int j
, kind
= 0x7fffffff;
149 if (++jjround
== 0x7fffffff)
153 ulong l
= ((ulong) 1L) << curChar
;
157 switch (jjstateSet
[--i
])
161 if ((0x7bffd0f8ffffd9ffL
& l
) != (ulong) 0L)
165 JjCheckNAddStates(0, 6);
167 else if ((0x100002600L
& l
) != (ulong) 0L)
172 else if (curChar
== 34)
174 else if (curChar
== 33)
180 jjstateSet
[jjnewStateCnt
++] = 4;
184 if (curChar
== 38 && kind
> 7)
190 jjstateSet
[jjnewStateCnt
++] = 4;
194 if (curChar
== 33 && kind
> 9)
204 if ((0xfffffffbffffffffL
& l
) != (ulong) 0L)
205 JjCheckNAddTwoStates(15, 16);
209 if (curChar
== 34 && kind
> 16)
214 if ((0x3ff000000000000L
& l
) == (ulong) 0L)
227 if ((0x3ff000000000000L
& l
) == (ulong) 0L)
235 if ((0x7bffd0f8ffffd9ffL
& l
) == (ulong) 0L)
239 JjCheckNAddStates(0, 6);
243 if ((0x7bfff8f8ffffd9ffL
& l
) == (ulong) 0L)
247 JjCheckNAddTwoStates(22, 23);
251 if ((0x84002f0600000000L
& l
) == (ulong) 0L)
255 JjCheckNAddTwoStates(22, 23);
259 if ((0x7bfff8f8ffffd9ffL
& l
) != (ulong) 0L)
260 JjCheckNAddStates(9, 11);
264 if (curChar
== 42 && kind
> 19)
269 if ((0x84002f0600000000L
& l
) != (ulong) 0L)
270 JjCheckNAddStates(9, 11);
274 if ((0xfbfffcf8ffffd9ffL
& l
) == (ulong) 0L)
278 JjCheckNAddTwoStates(29, 30);
282 if ((0x84002f0600000000L
& l
) == (ulong) 0L)
286 JjCheckNAddTwoStates(29, 30);
293 while (i
!= startsAt
);
295 else if (curChar
< 128)
297 ulong l
= ((ulong) 1L) << (curChar
& 63);
301 switch (jjstateSet
[--i
])
305 if ((0x97ffffff97ffffffL
& l
) != (ulong) 0L)
309 JjCheckNAddStates(0, 6);
311 else if (curChar
== 126)
315 jjstateSet
[jjnewStateCnt
++] = 18;
318 JjCheckNAddStates(12, 14);
319 else if (curChar
== 78)
320 jjstateSet
[jjnewStateCnt
++] = 11;
321 else if (curChar
== 124)
322 jjstateSet
[jjnewStateCnt
++] = 8;
323 else if (curChar
== 79)
324 jjstateSet
[jjnewStateCnt
++] = 6;
325 else if (curChar
== 65)
326 jjstateSet
[jjnewStateCnt
++] = 2;
330 if (curChar
== 68 && kind
> 7)
336 jjstateSet
[jjnewStateCnt
++] = 1;
341 jjstateSet
[jjnewStateCnt
++] = 2;
345 if (curChar
== 82 && kind
> 8)
351 jjstateSet
[jjnewStateCnt
++] = 6;
355 if (curChar
== 124 && kind
> 8)
361 jjstateSet
[jjnewStateCnt
++] = 8;
365 if (curChar
== 84 && kind
> 9)
371 jjstateSet
[jjnewStateCnt
++] = 10;
376 jjstateSet
[jjnewStateCnt
++] = 11;
388 jjstateSet
[jjnewStateCnt
++] = 18;
392 if ((0x97ffffff97ffffffL
& l
) == (ulong) 0L)
396 JjCheckNAddStates(0, 6);
400 if ((0x97ffffff97ffffffL
& l
) == (ulong) 0L)
404 JjCheckNAddTwoStates(22, 23);
409 JjCheckNAddTwoStates(24, 24);
413 if ((0x6800000078000000L
& l
) == (ulong) 0L)
417 JjCheckNAddTwoStates(22, 23);
421 if ((0x97ffffff97ffffffL
& l
) != (ulong) 0L)
422 JjCheckNAddStates(9, 11);
427 JjCheckNAddTwoStates(28, 28);
431 if ((0x6800000078000000L
& l
) != (ulong) 0L)
432 JjCheckNAddStates(9, 11);
436 if ((0x97ffffff97ffffffL
& l
) == (ulong) 0L)
440 JjCheckNAddTwoStates(29, 30);
445 JjCheckNAddTwoStates(31, 31);
449 if ((0x6800000078000000L
& l
) == (ulong) 0L)
453 JjCheckNAddTwoStates(29, 30);
458 JjCheckNAddStates(12, 14);
465 while (i
!= startsAt
);
469 int hiByte
= (int) (curChar
>> 8);
470 int i1
= hiByte
>> 6;
471 ulong l1
= ((ulong) 1L) << (hiByte
& 63);
472 int i2
= (curChar
& 0xff) >> 6;
473 ulong l2
= ((ulong) 1L) << (curChar
& 63);
477 switch (jjstateSet
[--i
])
481 if (!JjCanMove_0(hiByte
, i1
, i2
, (ulong) l1
, (ulong) l2
))
485 JjCheckNAddStates(0, 6);
489 if (JjCanMove_0(hiByte
, i1
, i2
, (ulong) l1
, (ulong) l2
))
494 if (!JjCanMove_0(hiByte
, i1
, i2
, (ulong) l1
, (ulong) l2
))
498 JjCheckNAddTwoStates(22, 23);
502 if (JjCanMove_0(hiByte
, i1
, i2
, (ulong) l1
, (ulong) l2
))
503 JjCheckNAddStates(9, 11);
507 if (!JjCanMove_0(hiByte
, i1
, i2
, (ulong) l1
, (ulong) l2
))
511 JjCheckNAddTwoStates(29, 30);
518 while (i
!= startsAt
);
520 if (kind
!= 0x7fffffff)
522 jjmatchedKind
= kind
;
523 jjmatchedPos
= curPos
;
527 if ((i
= jjnewStateCnt
) == (startsAt
= 33 - (jjnewStateCnt
= startsAt
)))
531 curChar
= input_stream
.ReadChar();
533 catch (System
.IO
.IOException e
)
539 private int JjStopStringLiteralDfa_1(int pos
, ulong active0
)
545 if ((active0
& 0x10000000L
) != 0L)
557 private int JjStartNfa_1(int pos
, ulong active0
)
559 return JjMoveNfa_1(JjStopStringLiteralDfa_1(pos
, (ulong) active0
), pos
+ 1);
561 private int JjStartNfaWithStates_1(int pos
, int kind
, int state
)
563 jjmatchedKind
= kind
;
567 curChar
= input_stream
.ReadChar();
569 catch (System
.IO
.IOException
)
573 return JjMoveNfa_1(state
, pos
+ 1);
575 private int JjMoveStringLiteralDfa0_1()
581 return JjMoveStringLiteralDfa1_1((ulong) 0x10000000L
);
584 return JjStopAtPos(0, 29);
587 return JjMoveNfa_1(0, 0);
591 private int JjMoveStringLiteralDfa1_1(ulong active0
)
595 curChar
= input_stream
.ReadChar();
597 catch (System
.IO
.IOException
)
599 JjStopStringLiteralDfa_1(0, (ulong) active0
);
606 if ((active0
& 0x10000000L
) != 0L)
607 return JjStartNfaWithStates_1(1, 28, 4);
614 return JjStartNfa_1(0, (ulong) active0
);
616 private int JjMoveNfa_1(int startState
, int curPos
)
622 jjstateSet
[0] = startState
;
623 int j
, kind
= 0x7fffffff;
626 if (++jjround
== 0x7fffffff)
630 ulong l
= ((ulong) 1L) << curChar
;
634 switch (jjstateSet
[--i
])
638 if ((0xfffffffeffffffffL
& l
) != (ulong) 0L)
644 if ((0x100002600L
& l
) != (ulong) 0L)
649 else if (curChar
== 34)
659 if ((0xfffffffbffffffffL
& l
) != (ulong) 0L)
660 JjCheckNAddTwoStates(2, 3);
664 if (curChar
== 34 && kind
> 30)
669 if ((0xfffffffeffffffffL
& l
) == (ulong) 0L)
680 while (i
!= startsAt
);
682 else if (curChar
< 128)
684 ulong l
= ((ulong) 1L) << (curChar
& 63);
688 switch (jjstateSet
[--i
])
693 if ((0xdfffffffffffffffL
& l
) == (ulong) 0L)
708 while (i
!= startsAt
);
712 int hiByte
= (int) (curChar
>> 8);
713 int i1
= hiByte
>> 6;
714 ulong l1
= ((ulong) 1L) << (hiByte
& 63);
715 int i2
= (curChar
& 0xff) >> 6;
716 ulong l2
= ((ulong) 1L) << (curChar
& 63);
720 switch (jjstateSet
[--i
])
725 if (!JjCanMove_0(hiByte
, i1
, i2
, (ulong) l1
, (ulong) l2
))
733 if (JjCanMove_0(hiByte
, i1
, i2
, (ulong) l1
, (ulong) l2
))
741 while (i
!= startsAt
);
743 if (kind
!= 0x7fffffff)
745 jjmatchedKind
= kind
;
746 jjmatchedPos
= curPos
;
750 if ((i
= jjnewStateCnt
) == (startsAt
= 5 - (jjnewStateCnt
= startsAt
)))
754 curChar
= input_stream
.ReadChar();
756 catch (System
.IO
.IOException
)
762 private int JjMoveStringLiteralDfa0_0()
764 return JjMoveNfa_0(0, 0);
766 private int JjMoveNfa_0(int startState
, int curPos
)
772 jjstateSet
[0] = startState
;
773 int j
, kind
= 0x7fffffff;
776 if (++jjround
== 0x7fffffff)
780 ulong l
= ((ulong) 1L) << curChar
;
784 switch (jjstateSet
[--i
])
788 if ((0x3ff000000000000L
& l
) == (ulong) 0L)
801 if ((0x3ff000000000000L
& l
) == (ulong) 0L)
812 while (i
!= startsAt
);
814 else if (curChar
< 128)
816 ulong l
= ((ulong) 1L) << (curChar
& 63);
820 switch (jjstateSet
[--i
])
827 while (i
!= startsAt
);
831 int hiByte
= (int) (curChar
>> 8);
832 int i1
= hiByte
>> 6;
833 ulong l1
= ((ulong) 1L) << (hiByte
& 63);
834 int i2
= (curChar
& 0xff) >> 6;
835 ulong l2
= ((ulong) 1L) << (curChar
& 63);
839 switch (jjstateSet
[--i
])
846 while (i
!= startsAt
);
848 if (kind
!= 0x7fffffff)
850 jjmatchedKind
= kind
;
851 jjmatchedPos
= curPos
;
855 if ((i
= jjnewStateCnt
) == (startsAt
= 3 - (jjnewStateCnt
= startsAt
)))
859 curChar
= input_stream
.ReadChar();
861 catch (System
.IO
.IOException e
)
867 private int JjStopStringLiteralDfa_2(int pos
, ulong active0
)
873 if ((active0
& 0x1000000L
) != (ulong) 0L)
885 private int JjStartNfa_2(int pos
, ulong active0
)
887 return JjMoveNfa_2(JjStopStringLiteralDfa_2(pos
, (ulong) active0
), pos
+ 1);
889 private int JjStartNfaWithStates_2(int pos
, int kind
, int state
)
891 jjmatchedKind
= kind
;
895 curChar
= input_stream
.ReadChar();
897 catch (System
.IO
.IOException e
)
901 return JjMoveNfa_2(state
, pos
+ 1);
903 private int JjMoveStringLiteralDfa0_2()
909 return JjMoveStringLiteralDfa1_2((ulong) 0x1000000L
);
912 return JjStopAtPos(0, 25);
915 return JjMoveNfa_2(0, 0);
919 private int JjMoveStringLiteralDfa1_2(ulong active0
)
923 curChar
= input_stream
.ReadChar();
925 catch (System
.IO
.IOException e
)
927 JjStopStringLiteralDfa_2(0, (ulong) active0
);
934 if ((active0
& 0x1000000L
) != (ulong) 0L)
935 return JjStartNfaWithStates_2(1, 24, 4);
942 return JjStartNfa_2(0, (ulong) active0
);
944 private int JjMoveNfa_2(int startState
, int curPos
)
950 jjstateSet
[0] = startState
;
951 int j
, kind
= 0x7fffffff;
954 if (++jjround
== 0x7fffffff)
958 ulong l
= ((ulong) 1L) << curChar
;
962 switch (jjstateSet
[--i
])
966 if ((0xfffffffeffffffffL
& l
) != (ulong) 0L)
972 if ((0x100002600L
& l
) != (ulong) 0L)
977 else if (curChar
== 34)
987 if ((0xfffffffbffffffffL
& l
) != (ulong) 0L)
988 JjCheckNAddTwoStates(2, 3);
992 if (curChar
== 34 && kind
> 26)
997 if ((0xfffffffeffffffffL
& l
) == (ulong) 0L)
1008 while (i
!= startsAt
);
1010 else if (curChar
< 128)
1012 ulong l
= ((ulong) 1L) << (curChar
& 63);
1016 switch (jjstateSet
[--i
])
1021 if ((0xffffffffdfffffffL
& l
) == (ulong) 0L)
1029 JjAddStates(17, 18);
1036 while (i
!= startsAt
);
1040 int hiByte
= (int) (curChar
>> 8);
1041 int i1
= hiByte
>> 6;
1042 ulong l1
= ((ulong) 1L) << (hiByte
& 63);
1043 int i2
= (curChar
& 0xff) >> 6;
1044 ulong l2
= ((ulong) 1L) << (curChar
& 63);
1048 switch (jjstateSet
[--i
])
1053 if (!JjCanMove_0(hiByte
, i1
, i2
, (ulong) l1
, (ulong) l2
))
1061 if (JjCanMove_0(hiByte
, i1
, i2
, (ulong) l1
, (ulong) l2
))
1062 JjAddStates(17, 18);
1069 while (i
!= startsAt
);
1071 if (kind
!= 0x7fffffff)
1073 jjmatchedKind
= kind
;
1074 jjmatchedPos
= curPos
;
1078 if ((i
= jjnewStateCnt
) == (startsAt
= 5 - (jjnewStateCnt
= startsAt
)))
1082 curChar
= input_stream
.ReadChar();
1084 catch (System
.IO
.IOException e
)
1090 internal static readonly int[] jjnextStates
= new int[]{22, 25, 26, 29, 30, 27, 23, 18, 19, 25, 26, 27, 24, 28, 31, 15, 16, 2, 3, 0, 1}
;
1091 private static bool JjCanMove_0(int hiByte
, int i1
, int i2
, ulong l1
, ulong l2
)
1097 return ((jjbitVec2
[i2
] & l2
) != (ulong) 0L);
1100 if ((jjbitVec0
[i1
] & l1
) != (ulong) 0L)
1106 public static readonly System
.String
[] jjstrLiteralImages
= new System
.String
[]{"", null, null, null, null, null, null, null, null, null, "\x002B", "\x002D", "\x0028", "\x0029", "\x003A", "\x005E", null, null, null, null, null, "\x005B", "\x007B", null, "\x0054\x004F", "\x005D", null, null, "\x0054\x004F", "\x007D", null, null}
;
1107 public static readonly System
.String
[] lexStateNames
= new System
.String
[]{"Boost", "RangeEx", "RangeIn", "DEFAULT"}
;
1108 public static readonly int[] jjnewLexState
= new int[]{- 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, 0, - 1, - 1, - 1, - 1, - 1, 2, 1, 3, - 1, 3, - 1, - 1, - 1, 3, - 1, - 1}
;
1109 internal static readonly ulong[] jjtoToken
= new ulong[]{0xffffff81L}
;
1110 internal static readonly long[] jjtoSkip
= new long[]{0x40L}
;
1111 protected internal CharStream input_stream
;
1112 private uint[] jjrounds
= new uint[33];
1113 private int[] jjstateSet
= new int[66];
1114 protected internal char curChar
;
1115 public QueryParserTokenManager(CharStream stream
)
1118 input_stream
= stream
;
1120 public QueryParserTokenManager(CharStream stream
, int lexState
) : this(stream
)
1124 public virtual void ReInit(CharStream stream
)
1126 jjmatchedPos
= jjnewStateCnt
= 0;
1127 curLexState
= defaultLexState
;
1128 input_stream
= stream
;
1131 private void ReInitRounds()
1134 jjround
= 0x80000001;
1135 for (i
= 33; i
-- > 0; )
1136 jjrounds
[i
] = 0x80000000;
1138 public virtual void ReInit(CharStream stream
, int lexState
)
1143 public virtual void SwitchTo(int lexState
)
1145 if (lexState
>= 4 || lexState
< 0)
1146 throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState
+ ". State unchanged.", TokenMgrError
.INVALID_LEXICAL_STATE
);
1148 curLexState
= lexState
;
1151 protected internal virtual Token
JjFillToken()
1153 Token t
= Token
.NewToken(jjmatchedKind
);
1154 t
.kind
= jjmatchedKind
;
1155 System
.String im
= jjstrLiteralImages
[jjmatchedKind
];
1156 t
.image
= (im
== null) ? input_stream
.GetImage() : im
;
1157 t
.beginLine
= input_stream
.GetBeginLine();
1158 t
.beginColumn
= input_stream
.GetBeginColumn();
1159 t
.endLine
= input_stream
.GetEndLine();
1160 t
.endColumn
= input_stream
.GetEndColumn();
1164 internal int curLexState
= 3;
1165 internal int defaultLexState
= 3;
1166 internal int jjnewStateCnt
;
1167 internal uint jjround
;
1168 internal int jjmatchedPos
;
1169 internal int jjmatchedKind
;
1171 public virtual Token
GetNextToken()
1174 Token specialToken
= null;
1182 curChar
= input_stream
.BeginToken();
1184 catch (System
.IO
.IOException e
)
1187 matchedToken
= JjFillToken();
1188 return matchedToken
;
1191 switch (curLexState
)
1195 jjmatchedKind
= 0x7fffffff;
1197 curPos
= JjMoveStringLiteralDfa0_0();
1201 jjmatchedKind
= 0x7fffffff;
1203 curPos
= JjMoveStringLiteralDfa0_1();
1207 jjmatchedKind
= 0x7fffffff;
1209 curPos
= JjMoveStringLiteralDfa0_2();
1213 jjmatchedKind
= 0x7fffffff;
1215 curPos
= JjMoveStringLiteralDfa0_3();
1218 if (jjmatchedKind
!= 0x7fffffff)
1220 if (jjmatchedPos
+ 1 < curPos
)
1221 input_stream
.Backup(curPos
- jjmatchedPos
- 1);
1222 if ((jjtoToken
[jjmatchedKind
>> 6] & ((ulong) (1L << (jjmatchedKind
& 63)))) != (ulong) 0L)
1224 matchedToken
= JjFillToken();
1225 if (jjnewLexState
[jjmatchedKind
] != - 1)
1226 curLexState
= jjnewLexState
[jjmatchedKind
];
1227 return matchedToken
;
1231 if (jjnewLexState
[jjmatchedKind
] != - 1)
1232 curLexState
= jjnewLexState
[jjmatchedKind
];
1236 int error_line
= input_stream
.GetEndLine();
1237 int error_column
= input_stream
.GetEndColumn();
1238 System
.String error_after
= null;
1239 bool EOFSeen
= false;
1242 input_stream
.ReadChar(); input_stream
.Backup(1);
1244 catch (System
.IO
.IOException e1
)
1247 error_after
= curPos
<= 1?"":input_stream
.GetImage();
1248 if (curChar
== '\n' || curChar
== '\r')
1258 input_stream
.Backup(1);
1259 error_after
= curPos
<= 1?"":input_stream
.GetImage();
1261 throw new TokenMgrError(EOFSeen
, curLexState
, error_line
, error_column
, error_after
, curChar
, TokenMgrError
.LEXICAL_ERROR
);