LUCENE-9527: upgrade javacc to 7.0.4 (#1884)

This commit is contained in:
Dawid Weiss 2020-09-17 13:29:18 +02:00 committed by GitHub
parent 515608a087
commit 6c9d7adf79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 2929 additions and 2195 deletions

View File

@ -86,7 +86,7 @@ ext {
scriptDepVersions = [
"apache-rat": "0.11",
"ecj": "3.19.0",
"javacc": "5.0",
"javacc": "7.0.4",
"jflex": "1.7.0",
"jgit": "5.3.0.201903130848-r",
"flexmark": "0.61.24",

View File

@ -61,9 +61,10 @@ def commonCleanups = { FileTree generatedFiles ->
})
}
// Side-effect of this is that all files have normalized EOLs
generatedFiles.each {file ->
modifyFile(file, { text ->
// Normalize EOLs and tabs (EOLs are a side-effect of modifyFile).
text = text.replace("\t", " ");
text = text.replaceAll("JavaCC - OriginalChecksum=[^*]+", "(filtered)")
text = text.replace("StringBuffer", "StringBuilder")
return text

View File

@ -132,6 +132,7 @@ Improvements
"after". Also redesign numeric comparators to provide skipping functionality
by default. (Mayya Sharipova, Jim Ferenczi)
* LUCENE-9527: Upgrade javacc to 7.0.4, regenerate query parsers. (Dawid Weiss)
Bug fixes

View File

@ -1,4 +1,4 @@
/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 5.0 */
/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 7.0 */
/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.apache.lucene.queryparser.classic;
@ -111,5 +111,10 @@ interface CharStream {
*/
void Done();
void setTabSize(int i);
int getTabSize();
boolean getTrackLineColumn();
void setTrackLineColumn(boolean trackLineColumn);
}
/* (filtered)*/

View File

@ -138,4 +138,24 @@ public final class FastCharStream implements CharStream {
public final int getBeginLine() {
return 1;
}
@Override
public void setTabSize(int i) {
throw new RuntimeException("Tab size not implemented.");
}
@Override
public int getTabSize() {
throw new RuntimeException("Tab size not implemented.");
}
@Override
public boolean getTrackLineColumn() {
return false;
}
@Override
public void setTrackLineColumn(boolean trackLineColumn) {
throw new RuntimeException("Line/Column tracking not implemented.");
}
}

View File

@ -1,5 +1,5 @@
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
/* JavaCCOptions:KEEP_LINE_COL=null */
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 7.0 */
/* JavaCCOptions:KEEP_LINE_COLUMN=true */
package org.apache.lucene.queryparser.classic;
/**
@ -20,6 +20,11 @@ public class ParseException extends Exception {
*/
private static final long serialVersionUID = 1L;
/**
* The end of line string for this machine.
*/
protected static String EOL = System.getProperty("line.separator", "\n");
/**
* This constructor is used by the method "generateParseException"
* in the generated parser. Calling this constructor generates
@ -88,7 +93,7 @@ public class ParseException extends Exception {
private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuilder expected = new StringBuilder();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
@ -101,7 +106,7 @@ public class ParseException extends Exception {
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected.append("...");
}
expected.append(eol).append(" ");
expected.append(EOL).append(" ");
}
String retval = "Encountered \"";
Token tok = currentToken.next;
@ -118,20 +123,23 @@ public class ParseException extends Exception {
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
retval += "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
retval += "." + EOL;
if (expectedTokenSequences.length == 0) {
// Nothing to add here
} else {
retval += "Was expecting one of:" + eol + " ";
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + EOL + " ";
} else {
retval += "Was expecting one of:" + EOL + " ";
}
retval += expected.toString();
}
retval += expected.toString();
return retval;
}
/**
* The end of line string for this machine.
*/
protected String eol = System.getProperty("line.separator", "\n");
/**
* Used to convert raw characters to their escaped version
@ -144,8 +152,6 @@ public class ParseException extends Exception {
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;

View File

@ -1,3 +1,4 @@
/* QueryParserTokenManager.java */
/* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */
package org.apache.lucene.queryparser.classic;
@ -14,23 +15,20 @@ package org.apache.lucene.queryparser.classic;
/** Token Manager. */
public class QueryParserTokenManager implements QueryParserConstants
{
public class QueryParserTokenManager implements QueryParserConstants {
/** Debug output. */
// (debugStream omitted).
/** Set debug output. */
// (setDebugStream omitted).
private final int jjStopStringLiteralDfa_2(int pos, long active0)
{
private final int jjStopStringLiteralDfa_2(int pos, long active0){
switch (pos)
{
default :
return -1;
}
}
private final int jjStartNfa_2(int pos, long active0)
{
private final int jjStartNfa_2(int pos, long active0){
return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1);
}
private int jjStopAtPos(int pos, int kind)
@ -39,8 +37,7 @@ private int jjStopAtPos(int pos, int kind)
jjmatchedPos = pos;
return pos + 1;
}
private int jjMoveStringLiteralDfa0_2()
{
private int jjMoveStringLiteralDfa0_2(){
switch(curChar)
{
case 40:
@ -109,14 +106,14 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
break;
case 0:
if ((0xfbff54f8ffffd9ffL & l) != 0L)
{
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
}
else if ((0x100002600L & l) != 0L)
{
@ -126,14 +123,14 @@ private int jjMoveNfa_2(int startState, int curPos)
else if ((0x280200000000L & l) != 0L)
jjstateSet[jjnewStateCnt++] = 15;
else if (curChar == 47)
jjCheckNAddStates(0, 2);
{ jjCheckNAddStates(0, 2); }
else if (curChar == 34)
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
if ((0x7bff50f8ffffd9ffL & l) != 0L)
{
if (kind > 20)
kind = 20;
jjCheckNAddStates(6, 10);
{ jjCheckNAddStates(6, 10); }
}
else if (curChar == 42)
{
@ -170,14 +167,14 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
case 16:
if (curChar == 34)
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
break;
case 17:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
break;
case 19:
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
break;
case 20:
if (curChar == 34 && kind > 19)
@ -188,42 +185,42 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
if (kind > 21)
kind = 21;
jjCheckNAddStates(11, 14);
{ jjCheckNAddStates(11, 14); }
break;
case 23:
if (curChar == 46)
jjCheckNAdd(24);
{ jjCheckNAdd(24); }
break;
case 24:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 21)
kind = 21;
jjCheckNAddStates(15, 17);
{ jjCheckNAddStates(15, 17); }
break;
case 25:
if ((0x7bff78f8ffffd9ffL & l) == 0L)
break;
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(25, 26);
{ jjCheckNAddTwoStates(25, 26); }
break;
case 27:
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(25, 26);
{ jjCheckNAddTwoStates(25, 26); }
break;
case 28:
if ((0x7bff78f8ffffd9ffL & l) == 0L)
break;
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(28, 29);
{ jjCheckNAddTwoStates(28, 29); }
break;
case 30:
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(28, 29);
{ jjCheckNAddTwoStates(28, 29); }
break;
case 31:
if (curChar == 42 && kind > 22)
@ -234,21 +231,21 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
break;
case 35:
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
break;
case 36:
case 38:
if (curChar == 47)
jjCheckNAddStates(0, 2);
{ jjCheckNAddStates(0, 2); }
break;
case 37:
if ((0xffff7fffffffffffL & l) != 0L)
jjCheckNAddStates(0, 2);
{ jjCheckNAddStates(0, 2); }
break;
case 40:
if (curChar == 47 && kind > 24)
@ -259,26 +256,26 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
if (kind > 20)
kind = 20;
jjCheckNAddStates(6, 10);
{ jjCheckNAddStates(6, 10); }
break;
case 42:
if ((0x7bff78f8ffffd9ffL & l) == 0L)
break;
if (kind > 20)
kind = 20;
jjCheckNAddTwoStates(42, 43);
{ jjCheckNAddTwoStates(42, 43); }
break;
case 44:
if (kind > 20)
kind = 20;
jjCheckNAddTwoStates(42, 43);
{ jjCheckNAddTwoStates(42, 43); }
break;
case 45:
if ((0x7bff78f8ffffd9ffL & l) != 0L)
jjCheckNAddStates(18, 20);
{ jjCheckNAddStates(18, 20); }
break;
case 47:
jjCheckNAddStates(18, 20);
{ jjCheckNAddStates(18, 20); }
break;
default : break;
}
@ -296,31 +293,31 @@ private int jjMoveNfa_2(int startState, int curPos)
{
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
}
else if (curChar == 92)
jjCheckNAdd(35);
{ jjCheckNAdd(35); }
break;
case 0:
if ((0x97ffffff87ffffffL & l) != 0L)
{
if (kind > 20)
kind = 20;
jjCheckNAddStates(6, 10);
{ jjCheckNAddStates(6, 10); }
}
else if (curChar == 92)
jjCheckNAddStates(21, 23);
{ jjCheckNAddStates(21, 23); }
else if (curChar == 126)
{
if (kind > 21)
kind = 21;
jjCheckNAddStates(24, 26);
{ jjCheckNAddStates(24, 26); }
}
if ((0x97ffffff87ffffffL & l) != 0L)
{
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
}
if (curChar == 78)
jjstateSet[jjnewStateCnt++] = 11;
@ -373,28 +370,28 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
case 17:
if ((0xffffffffefffffffL & l) != 0L)
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
break;
case 18:
if (curChar == 92)
jjstateSet[jjnewStateCnt++] = 19;
break;
case 19:
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
break;
case 21:
if (curChar != 126)
break;
if (kind > 21)
kind = 21;
jjCheckNAddStates(24, 26);
{ jjCheckNAddStates(24, 26); }
break;
case 25:
if ((0x97ffffff87ffffffL & l) == 0L)
break;
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(25, 26);
{ jjCheckNAddTwoStates(25, 26); }
break;
case 26:
if (curChar == 92)
@ -403,14 +400,14 @@ private int jjMoveNfa_2(int startState, int curPos)
case 27:
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(25, 26);
{ jjCheckNAddTwoStates(25, 26); }
break;
case 28:
if ((0x97ffffff87ffffffL & l) == 0L)
break;
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(28, 29);
{ jjCheckNAddTwoStates(28, 29); }
break;
case 29:
if (curChar == 92)
@ -419,33 +416,33 @@ private int jjMoveNfa_2(int startState, int curPos)
case 30:
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(28, 29);
{ jjCheckNAddTwoStates(28, 29); }
break;
case 32:
if ((0x97ffffff87ffffffL & l) == 0L)
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
break;
case 33:
if ((0x97ffffff87ffffffL & l) == 0L)
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
break;
case 34:
if (curChar == 92)
jjCheckNAdd(35);
{ jjCheckNAdd(35); }
break;
case 35:
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
break;
case 37:
jjAddStates(0, 2);
{ jjAddStates(0, 2); }
break;
case 39:
if (curChar == 92)
@ -456,38 +453,38 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
if (kind > 20)
kind = 20;
jjCheckNAddStates(6, 10);
{ jjCheckNAddStates(6, 10); }
break;
case 42:
if ((0x97ffffff87ffffffL & l) == 0L)
break;
if (kind > 20)
kind = 20;
jjCheckNAddTwoStates(42, 43);
{ jjCheckNAddTwoStates(42, 43); }
break;
case 43:
if (curChar == 92)
jjCheckNAdd(44);
{ jjCheckNAdd(44); }
break;
case 44:
if (kind > 20)
kind = 20;
jjCheckNAddTwoStates(42, 43);
{ jjCheckNAddTwoStates(42, 43); }
break;
case 45:
if ((0x97ffffff87ffffffL & l) != 0L)
jjCheckNAddStates(18, 20);
{ jjCheckNAddStates(18, 20); }
break;
case 46:
if (curChar == 92)
jjCheckNAdd(47);
{ jjCheckNAdd(47); }
break;
case 47:
jjCheckNAddStates(18, 20);
{ jjCheckNAddStates(18, 20); }
break;
case 48:
if (curChar == 92)
jjCheckNAddStates(21, 23);
{ jjCheckNAddStates(21, 23); }
break;
default : break;
}
@ -495,7 +492,7 @@ private int jjMoveNfa_2(int startState, int curPos)
}
else
{
int hiByte = curChar >> 8;
int hiByte = (curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
@ -510,7 +507,7 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
break;
case 0:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
@ -522,13 +519,13 @@ private int jjMoveNfa_2(int startState, int curPos)
{
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
}
if (jjCanMove_2(hiByte, i1, i2, l1, l2))
{
if (kind > 20)
kind = 20;
jjCheckNAddStates(6, 10);
{ jjCheckNAddStates(6, 10); }
}
break;
case 15:
@ -538,84 +535,84 @@ private int jjMoveNfa_2(int startState, int curPos)
case 17:
case 19:
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
break;
case 25:
if (!jjCanMove_2(hiByte, i1, i2, l1, l2))
break;
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(25, 26);
{ jjCheckNAddTwoStates(25, 26); }
break;
case 27:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(25, 26);
{ jjCheckNAddTwoStates(25, 26); }
break;
case 28:
if (!jjCanMove_2(hiByte, i1, i2, l1, l2))
break;
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(28, 29);
{ jjCheckNAddTwoStates(28, 29); }
break;
case 30:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(28, 29);
{ jjCheckNAddTwoStates(28, 29); }
break;
case 32:
if (!jjCanMove_2(hiByte, i1, i2, l1, l2))
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
break;
case 35:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(33, 34);
{ jjCheckNAddTwoStates(33, 34); }
break;
case 37:
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
jjAddStates(0, 2);
{ jjAddStates(0, 2); }
break;
case 41:
if (!jjCanMove_2(hiByte, i1, i2, l1, l2))
break;
if (kind > 20)
kind = 20;
jjCheckNAddStates(6, 10);
{ jjCheckNAddStates(6, 10); }
break;
case 42:
if (!jjCanMove_2(hiByte, i1, i2, l1, l2))
break;
if (kind > 20)
kind = 20;
jjCheckNAddTwoStates(42, 43);
{ jjCheckNAddTwoStates(42, 43); }
break;
case 44:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 20)
kind = 20;
jjCheckNAddTwoStates(42, 43);
{ jjCheckNAddTwoStates(42, 43); }
break;
case 45:
if (jjCanMove_2(hiByte, i1, i2, l1, l2))
jjCheckNAddStates(18, 20);
{ jjCheckNAddStates(18, 20); }
break;
case 47:
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
jjCheckNAddStates(18, 20);
{ jjCheckNAddStates(18, 20); }
break;
default : break;
default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
}
} while(i != startsAt);
}
@ -659,18 +656,18 @@ private int jjMoveNfa_0(int startState, int curPos)
break;
if (kind > 27)
kind = 27;
jjAddStates(27, 28);
{ jjAddStates(27, 28); }
break;
case 1:
if (curChar == 46)
jjCheckNAdd(2);
{ jjCheckNAdd(2); }
break;
case 2:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 27)
kind = 27;
jjCheckNAdd(2);
{ jjCheckNAdd(2); }
break;
default : break;
}
@ -689,7 +686,7 @@ private int jjMoveNfa_0(int startState, int curPos)
}
else
{
int hiByte = curChar >> 8;
int hiByte = (curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
@ -698,7 +695,7 @@ private int jjMoveNfa_0(int startState, int curPos)
{
switch(jjstateSet[--i])
{
default : break;
default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
}
} while(i != startsAt);
}
@ -715,8 +712,7 @@ private int jjMoveNfa_0(int startState, int curPos)
catch(java.io.IOException e) { return curPos; }
}
}
private final int jjStopStringLiteralDfa_1(int pos, long active0)
{
private final int jjStopStringLiteralDfa_1(int pos, long active0){
switch (pos)
{
case 0:
@ -730,12 +726,10 @@ private final int jjStopStringLiteralDfa_1(int pos, long active0)
return -1;
}
}
private final int jjStartNfa_1(int pos, long active0)
{
private final int jjStartNfa_1(int pos, long active0){
return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1);
}
private int jjMoveStringLiteralDfa0_1()
{
private int jjMoveStringLiteralDfa0_1(){
switch(curChar)
{
case 84:
@ -748,8 +742,7 @@ private int jjMoveStringLiteralDfa0_1()
return jjMoveNfa_1(0, 0);
}
}
private int jjMoveStringLiteralDfa1_1(long active0)
{
private int jjMoveStringLiteralDfa1_1(long active0){
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_1(0, active0);
@ -797,7 +790,7 @@ private int jjMoveNfa_1(int startState, int curPos)
{
if (kind > 32)
kind = 32;
jjCheckNAdd(6);
{ jjCheckNAdd(6); }
}
if ((0x100002600L & l) != 0L)
{
@ -805,19 +798,19 @@ private int jjMoveNfa_1(int startState, int curPos)
kind = 7;
}
else if (curChar == 34)
jjCheckNAddTwoStates(2, 4);
{ jjCheckNAddTwoStates(2, 4); }
break;
case 1:
if (curChar == 34)
jjCheckNAddTwoStates(2, 4);
{ jjCheckNAddTwoStates(2, 4); }
break;
case 2:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddStates(29, 31);
{ jjCheckNAddStates(29, 31); }
break;
case 3:
if (curChar == 34)
jjCheckNAddStates(29, 31);
{ jjCheckNAddStates(29, 31); }
break;
case 5:
if (curChar == 34 && kind > 31)
@ -828,7 +821,7 @@ private int jjMoveNfa_1(int startState, int curPos)
break;
if (kind > 32)
kind = 32;
jjCheckNAdd(6);
{ jjCheckNAdd(6); }
break;
default : break;
}
@ -847,10 +840,10 @@ private int jjMoveNfa_1(int startState, int curPos)
break;
if (kind > 32)
kind = 32;
jjCheckNAdd(6);
{ jjCheckNAdd(6); }
break;
case 2:
jjAddStates(29, 31);
{ jjAddStates(29, 31); }
break;
case 4:
if (curChar == 92)
@ -862,7 +855,7 @@ private int jjMoveNfa_1(int startState, int curPos)
}
else
{
int hiByte = curChar >> 8;
int hiByte = (curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
@ -881,21 +874,21 @@ private int jjMoveNfa_1(int startState, int curPos)
{
if (kind > 32)
kind = 32;
jjCheckNAdd(6);
{ jjCheckNAdd(6); }
}
break;
case 2:
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
jjAddStates(29, 31);
{ jjAddStates(29, 31); }
break;
case 6:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 32)
kind = 32;
jjCheckNAdd(6);
{ jjCheckNAdd(6); }
break;
default : break;
default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
}
} while(i != startsAt);
}
@ -912,6 +905,37 @@ private int jjMoveNfa_1(int startState, int curPos)
catch(java.io.IOException e) { return curPos; }
}
}
/** Token literal values. */
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, null, null, null, null, null, null, "\53", "\55",
null, "\50", "\51", "\72", "\52", "\136", null, null, null, null, null, null,
"\133", "\173", null, "\124\117", "\135", "\175", null, null, };
protected Token jjFillToken()
{
final Token t;
final String curTokenImage;
final int beginLine;
final int endLine;
final int beginColumn;
final int endColumn;
String im = jjstrLiteralImages[jjmatchedKind];
curTokenImage = (im == null) ? input_stream.GetImage() : im;
beginLine = input_stream.getBeginLine();
beginColumn = input_stream.getBeginColumn();
endLine = input_stream.getEndLine();
endColumn = input_stream.getEndColumn();
t = Token.newToken(jjmatchedKind);
t.kind = jjmatchedKind;
t.image = curTokenImage;
t.beginLine = beginLine;
t.endLine = endLine;
t.beginColumn = beginColumn;
t.endColumn = endColumn;
return t;
}
static final int[] jjnextStates = {
37, 39, 40, 17, 18, 20, 42, 43, 45, 46, 31, 22, 23, 25, 26, 24,
25, 26, 45, 46, 31, 44, 47, 35, 22, 28, 29, 0, 1, 2, 4, 5,
@ -953,101 +977,6 @@ private static final boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, lo
}
}
/** Token literal values. */
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, null, null, null, null, null, null, "\53", "\55",
null, "\50", "\51", "\72", "\52", "\136", null, null, null, null, null, null,
"\133", "\173", null, "\124\117", "\135", "\175", null, null, };
/** Lexer state names. */
public static final String[] lexStateNames = {
"Boost",
"Range",
"DEFAULT",
};
/** Lex State array. */
public static final int[] jjnewLexState = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1,
1, 1, 2, -1, 2, 2, -1, -1,
};
static final long[] jjtoToken = {
0x1ffffff01L,
};
static final long[] jjtoSkip = {
0x80L,
};
protected CharStream input_stream;
private final int[] jjrounds = new int[49];
private final int[] jjstateSet = new int[98];
protected char curChar;
/** Constructor. */
public QueryParserTokenManager(CharStream stream){
input_stream = stream;
}
/** Constructor. */
public QueryParserTokenManager(CharStream stream, int lexState){
this(stream);
SwitchTo(lexState);
}
/** Reinitialise parser. */
public void ReInit(CharStream stream)
{
jjmatchedPos = jjnewStateCnt = 0;
curLexState = defaultLexState;
input_stream = stream;
ReInitRounds();
}
private void ReInitRounds()
{
int i;
jjround = 0x80000001;
for (i = 49; i-- > 0;)
jjrounds[i] = 0x80000000;
}
/** Reinitialise parser. */
public void ReInit(CharStream stream, int lexState)
{
ReInit(stream);
SwitchTo(lexState);
}
/** Switch to specified lex state. */
public void SwitchTo(int lexState)
{
if (lexState >= 3 || lexState < 0)
throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
else
curLexState = lexState;
}
protected Token jjFillToken()
{
final Token t;
final String curTokenImage;
final int beginLine;
final int endLine;
final int beginColumn;
final int endColumn;
String im = jjstrLiteralImages[jjmatchedKind];
curTokenImage = (im == null) ? input_stream.GetImage() : im;
beginLine = input_stream.getBeginLine();
beginColumn = input_stream.getBeginColumn();
endLine = input_stream.getEndLine();
endColumn = input_stream.getEndColumn();
t = Token.newToken(jjmatchedKind, curTokenImage);
t.beginLine = beginLine;
t.endLine = endLine;
t.beginColumn = beginColumn;
t.endColumn = endColumn;
return t;
}
int curLexState = 2;
int defaultLexState = 2;
int jjnewStateCnt;
@ -1068,9 +997,10 @@ public Token getNextToken()
{
curChar = input_stream.BeginToken();
}
catch(java.io.IOException e)
catch(Exception e)
{
jjmatchedKind = 0;
jjmatchedPos = -1;
matchedToken = jjFillToken();
return matchedToken;
}
@ -1134,6 +1064,31 @@ public Token getNextToken()
}
}
void SkipLexicalActions(Token matchedToken)
{
switch(jjmatchedKind)
{
default :
break;
}
}
void MoreLexicalActions()
{
jjimageLen += (lengthOfMatch = jjmatchedPos + 1);
switch(jjmatchedKind)
{
default :
break;
}
}
void TokenLexicalActions(Token matchedToken)
{
switch(jjmatchedKind)
{
default :
break;
}
}
private void jjCheckNAdd(int state)
{
if (jjrounds[state] != jjround)
@ -1161,4 +1116,90 @@ private void jjCheckNAddStates(int start, int end)
} while (start++ != end);
}
/** Constructor. */
public QueryParserTokenManager(CharStream stream){
input_stream = stream;
}
/** Constructor. */
public QueryParserTokenManager (CharStream stream, int lexState){
ReInit(stream);
SwitchTo(lexState);
}
/** Reinitialise parser. */
public void ReInit(CharStream stream)
{
jjmatchedPos =
jjnewStateCnt =
0;
curLexState = defaultLexState;
input_stream = stream;
ReInitRounds();
}
private void ReInitRounds()
{
int i;
jjround = 0x80000001;
for (i = 49; i-- > 0;)
jjrounds[i] = 0x80000000;
}
/** Reinitialise parser. */
public void ReInit(CharStream stream, int lexState)
{
ReInit(stream);
SwitchTo(lexState);
}
/** Switch to specified lex state. */
public void SwitchTo(int lexState)
{
if (lexState >= 3 || lexState < 0)
throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
else
curLexState = lexState;
}
/** Lexer state names. */
public static final String[] lexStateNames = {
"Boost",
"Range",
"DEFAULT",
};
/** Lex State array. */
public static final int[] jjnewLexState = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1,
1, 1, 2, -1, 2, 2, -1, -1,
};
static final long[] jjtoToken = {
0x1ffffff01L,
};
static final long[] jjtoSkip = {
0x80L,
};
static final long[] jjtoSpecial = {
0x0L,
};
static final long[] jjtoMore = {
0x0L,
};
protected CharStream input_stream;
private final int[] jjrounds = new int[49];
private final int[] jjstateSet = new int[2 * 49];
private final StringBuilder jjimage = new StringBuilder();
private StringBuilder image = jjimage;
private int jjimageLen;
private int lengthOfMatch;
protected int curChar;
}

View File

@ -1,5 +1,5 @@
/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
/* Generated By:JavaCC: Do not edit this line. Token.java Version 7.0 */
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.apache.lucene.queryparser.classic;
/**
@ -97,6 +97,7 @@ public class Token implements java.io.Serializable {
/**
* Returns the image.
*/
@Override
public String toString()
{
return image;

View File

@ -1,4 +1,4 @@
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 7.0 */
/* JavaCCOptions: */
package org.apache.lucene.queryparser.classic;
@ -20,22 +20,22 @@ public class TokenMgrError extends Error
/**
* Lexical error occurred.
*/
static final int LEXICAL_ERROR = 0;
public static final int LEXICAL_ERROR = 0;
/**
* An attempt was made to create a second instance of a static token manager.
*/
static final int STATIC_LEXER_ERROR = 1;
public static final int STATIC_LEXER_ERROR = 1;
/**
* Tried to change to an invalid lexical state.
*/
static final int INVALID_LEXICAL_STATE = 2;
public static final int INVALID_LEXICAL_STATE = 2;
/**
* Detected (and bailed out of) an infinite loop in the token manager.
*/
static final int LOOP_DETECTED = 3;
public static final int LOOP_DETECTED = 3;
/**
* Indicates the reason why the exception is thrown. It will have
@ -53,8 +53,6 @@ public class TokenMgrError extends Error
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
@ -104,11 +102,12 @@ public class TokenMgrError extends Error
* curchar : the offending character
* Note: You can customize the lexical error message by modifying this method.
*/
protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
protected static String LexicalErr(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar) {
char curChar1 = (char)curChar;
return("Lexical error at line " +
errorLine + ", column " +
errorColumn + ". Encountered: " +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar1)) + "\"") + " (" + curChar + "), ") +
"after : \"" + addEscapes(errorAfter) + "\"");
}
@ -121,6 +120,7 @@ public class TokenMgrError extends Error
*
* from this method for such cases in the release version of your parser.
*/
@Override
public String getMessage() {
return super.getMessage();
}
@ -140,8 +140,8 @@ public class TokenMgrError extends Error
}
/** Full Constructor. */
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) {
this(LexicalErr(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
/* (filtered)*/

View File

@ -1,4 +1,4 @@
/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 5.0 */
/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 7.0 */
/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.apache.lucene.queryparser.flexible.standard.parser;
@ -111,5 +111,10 @@ interface CharStream {
*/
void Done();
void setTabSize(int i);
int getTabSize();
boolean getTrackLineColumn();
void setTrackLineColumn(boolean trackLineColumn);
}
/* (filtered)*/

View File

@ -138,4 +138,24 @@ public final class FastCharStream implements CharStream {
public final int getBeginLine() {
return 1;
}
@Override
public void setTabSize(int i) {
throw new RuntimeException("Tab size not implemented.");
}
@Override
public int getTabSize() {
throw new RuntimeException("Tab size not implemented.");
}
@Override
public boolean getTrackLineColumn() {
return false;
}
@Override
public void setTrackLineColumn(boolean trackLineColumn) {
throw new RuntimeException("Line/Column tracking not implemented.");
}
}

View File

@ -1,5 +1,5 @@
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
/* JavaCCOptions:KEEP_LINE_COL=null */
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 7.0 */
/* JavaCCOptions:KEEP_LINE_COLUMN=true */
package org.apache.lucene.queryparser.flexible.standard.parser;
import org.apache.lucene.queryparser.flexible.messages.*;
@ -25,6 +25,11 @@ public class ParseException extends QueryNodeParseException {
*/
private static final long serialVersionUID = 1L;
/**
* The end of line string for this machine.
*/
protected static String EOL = System.getProperty("line.separator", "\n");
/**
* This constructor is used by the method "generateParseException"
* in the generated parser. Calling this constructor generates
@ -97,7 +102,7 @@ public class ParseException extends QueryNodeParseException {
private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuilder expected = new StringBuilder();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
@ -110,7 +115,7 @@ public class ParseException extends QueryNodeParseException {
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected.append("...");
}
expected.append(eol).append(" ");
expected.append(EOL).append(" ");
}
String retval = "Encountered \"";
Token tok = currentToken.next;
@ -127,20 +132,23 @@ public class ParseException extends QueryNodeParseException {
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
retval += "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
retval += "." + EOL;
if (expectedTokenSequences.length == 0) {
// Nothing to add here
} else {
retval += "Was expecting one of:" + eol + " ";
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + EOL + " ";
} else {
retval += "Was expecting one of:" + EOL + " ";
}
retval += expected.toString();
}
retval += expected.toString();
return retval;
}
/**
* The end of line string for this machine.
*/
protected String eol = System.getProperty("line.separator", "\n");
/**
* Used to convert raw characters to their escaped version
@ -153,8 +161,6 @@ public class ParseException extends QueryNodeParseException {
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;

View File

@ -205,7 +205,7 @@ QueryNode Query(CharSequence field) :
if (first instanceof ModifierQueryNode) {
ModifierQueryNode m = (ModifierQueryNode) first;
if (m.getModifier() == ModifierQueryNode.Modifier.MOD_NOT) {
return new BooleanQueryNode(Arrays.<QueryNode> asList(m));
return new BooleanQueryNode(Arrays.asList(m));
}
}
return first;
@ -325,8 +325,7 @@ QueryNode Clause(CharSequence field) : {
}
{
(
LOOKAHEAD(3)
fieldToken=<TERM> (
LOOKAHEAD(3) fieldToken=<TERM> (
( <OP_COLON> | <OP_EQUAL> ) {field=EscapeQuerySyntaxImpl.discardEscapeChar(fieldToken.image);} q=Term(field)
| ( operator=<OP_LESSTHAN> | operator=<OP_LESSTHANEQ> | operator=<OP_MORETHAN> | operator=<OP_MORETHANEQ> ) {field=EscapeQuerySyntaxImpl.discardEscapeChar(fieldToken.image);}( term=<TERM> | term=<QUOTED> | term=<NUMBER> )
{
@ -377,14 +376,14 @@ QueryNode Clause(CharSequence field) : {
q = new TermRangeQueryNode(qLower, qUpper, lowerInclusive, upperInclusive);
}
)
| [
LOOKAHEAD(2)
| LOOKAHEAD(3) [
LOOKAHEAD(3)
fieldToken=<TERM>
( <OP_COLON> | <OP_EQUAL> ) {field=EscapeQuerySyntaxImpl.discardEscapeChar(fieldToken.image);}
]
(
q=Term(field)
| <LPAREN> q=Query(field) <RPAREN> (<CARAT> boost=<NUMBER>)? {group=true;}
(q=Term(field))
| (<LPAREN> q=Query(field) <RPAREN> (<CARAT> boost=<NUMBER>)? {group=true;})
)
)
{

View File

@ -1,3 +1,4 @@
/* StandardSyntaxParserTokenManager.java */
/* Generated By:JavaCC: Do not edit this line. StandardSyntaxParserTokenManager.java */
package org.apache.lucene.queryparser.flexible.standard.parser;
/*
@ -40,23 +41,20 @@ package org.apache.lucene.queryparser.flexible.standard.parser;
/** Token Manager. */
public class StandardSyntaxParserTokenManager implements StandardSyntaxParserConstants
{
public class StandardSyntaxParserTokenManager implements StandardSyntaxParserConstants {
/** Debug output. */
// (debugStream omitted).
/** Set debug output. */
// (setDebugStream omitted).
private final int jjStopStringLiteralDfa_2(int pos, long active0)
{
private final int jjStopStringLiteralDfa_2(int pos, long active0){
switch (pos)
{
default :
return -1;
}
}
private final int jjStartNfa_2(int pos, long active0)
{
private final int jjStartNfa_2(int pos, long active0){
return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1);
}
private int jjStopAtPos(int pos, int kind)
@ -65,8 +63,7 @@ private int jjStopAtPos(int pos, int kind)
jjmatchedPos = pos;
return pos + 1;
}
private int jjMoveStringLiteralDfa0_2()
{
private int jjMoveStringLiteralDfa0_2(){
switch(curChar)
{
case 40:
@ -97,8 +94,7 @@ private int jjMoveStringLiteralDfa0_2()
return jjMoveNfa_2(0, 0);
}
}
private int jjMoveStringLiteralDfa1_2(long active0)
{
private int jjMoveStringLiteralDfa1_2(long active0){
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_2(0, active0);
@ -152,7 +148,7 @@ private int jjMoveNfa_2(int startState, int curPos)
{
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(20, 21);
{ jjCheckNAddTwoStates(20, 21); }
}
else if ((0x100002600L & l) != 0L)
{
@ -160,9 +156,9 @@ private int jjMoveNfa_2(int startState, int curPos)
kind = 7;
}
else if (curChar == 47)
jjCheckNAddStates(0, 2);
{ jjCheckNAddStates(0, 2); }
else if (curChar == 34)
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
else if (curChar == 33)
{
if (kind > 10)
@ -185,14 +181,14 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
case 14:
if (curChar == 34)
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
break;
case 15:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
break;
case 17:
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
break;
case 18:
if (curChar == 34 && kind > 22)
@ -203,46 +199,46 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(20, 21);
{ jjCheckNAddTwoStates(20, 21); }
break;
case 20:
if ((0x8bff7cf8ffffd9ffL & l) == 0L)
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(20, 21);
{ jjCheckNAddTwoStates(20, 21); }
break;
case 22:
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(20, 21);
{ jjCheckNAddTwoStates(20, 21); }
break;
case 25:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 24)
kind = 24;
jjAddStates(6, 7);
{ jjAddStates(6, 7); }
break;
case 26:
if (curChar == 46)
jjCheckNAdd(27);
{ jjCheckNAdd(27); }
break;
case 27:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 24)
kind = 24;
jjCheckNAdd(27);
{ jjCheckNAdd(27); }
break;
case 28:
case 30:
if (curChar == 47)
jjCheckNAddStates(0, 2);
{ jjCheckNAddStates(0, 2); }
break;
case 29:
if ((0xffff7fffffffffffL & l) != 0L)
jjCheckNAddStates(0, 2);
{ jjCheckNAddStates(0, 2); }
break;
case 32:
if (curChar == 47 && kind > 25)
@ -264,7 +260,7 @@ private int jjMoveNfa_2(int startState, int curPos)
{
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(20, 21);
{ jjCheckNAddTwoStates(20, 21); }
}
else if (curChar == 126)
{
@ -273,7 +269,7 @@ private int jjMoveNfa_2(int startState, int curPos)
jjstateSet[jjnewStateCnt++] = 25;
}
else if (curChar == 92)
jjCheckNAdd(22);
{ jjCheckNAdd(22); }
if (curChar == 78)
jjstateSet[jjnewStateCnt++] = 11;
else if (curChar == 124)
@ -325,14 +321,14 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
case 15:
if ((0xffffffffefffffffL & l) != 0L)
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
break;
case 16:
if (curChar == 92)
jjstateSet[jjnewStateCnt++] = 17;
break;
case 17:
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
break;
case 19:
case 20:
@ -340,20 +336,20 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(20, 21);
{ jjCheckNAddTwoStates(20, 21); }
break;
case 21:
if (curChar == 92)
jjCheckNAddTwoStates(22, 22);
{ jjCheckNAddTwoStates(22, 22); }
break;
case 22:
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(20, 21);
{ jjCheckNAddTwoStates(20, 21); }
break;
case 23:
if (curChar == 92)
jjCheckNAdd(22);
{ jjCheckNAdd(22); }
break;
case 24:
if (curChar != 126)
@ -363,7 +359,7 @@ private int jjMoveNfa_2(int startState, int curPos)
jjstateSet[jjnewStateCnt++] = 25;
break;
case 29:
jjAddStates(0, 2);
{ jjAddStates(0, 2); }
break;
case 31:
if (curChar == 92)
@ -375,7 +371,7 @@ private int jjMoveNfa_2(int startState, int curPos)
}
else
{
int hiByte = curChar >> 8;
int hiByte = (curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
@ -394,13 +390,13 @@ private int jjMoveNfa_2(int startState, int curPos)
{
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(20, 21);
{ jjCheckNAddTwoStates(20, 21); }
}
break;
case 15:
case 17:
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
jjCheckNAddStates(3, 5);
{ jjCheckNAddStates(3, 5); }
break;
case 19:
case 20:
@ -408,20 +404,20 @@ private int jjMoveNfa_2(int startState, int curPos)
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(20, 21);
{ jjCheckNAddTwoStates(20, 21); }
break;
case 22:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 23)
kind = 23;
jjCheckNAddTwoStates(20, 21);
{ jjCheckNAddTwoStates(20, 21); }
break;
case 29:
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
jjAddStates(0, 2);
{ jjAddStates(0, 2); }
break;
default : break;
default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
}
} while(i != startsAt);
}
@ -465,18 +461,18 @@ private int jjMoveNfa_0(int startState, int curPos)
break;
if (kind > 28)
kind = 28;
jjAddStates(8, 9);
{ jjAddStates(8, 9); }
break;
case 1:
if (curChar == 46)
jjCheckNAdd(2);
{ jjCheckNAdd(2); }
break;
case 2:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 28)
kind = 28;
jjCheckNAdd(2);
{ jjCheckNAdd(2); }
break;
default : break;
}
@ -495,7 +491,7 @@ private int jjMoveNfa_0(int startState, int curPos)
}
else
{
int hiByte = curChar >> 8;
int hiByte = (curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
@ -504,7 +500,7 @@ private int jjMoveNfa_0(int startState, int curPos)
{
switch(jjstateSet[--i])
{
default : break;
default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
}
} while(i != startsAt);
}
@ -521,8 +517,7 @@ private int jjMoveNfa_0(int startState, int curPos)
catch(java.io.IOException e) { return curPos; }
}
}
private final int jjStopStringLiteralDfa_1(int pos, long active0)
{
private final int jjStopStringLiteralDfa_1(int pos, long active0){
switch (pos)
{
case 0:
@ -536,12 +531,10 @@ private final int jjStopStringLiteralDfa_1(int pos, long active0)
return -1;
}
}
private final int jjStartNfa_1(int pos, long active0)
{
private final int jjStartNfa_1(int pos, long active0){
return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1);
}
private int jjMoveStringLiteralDfa0_1()
{
private int jjMoveStringLiteralDfa0_1(){
switch(curChar)
{
case 84:
@ -554,8 +547,7 @@ private int jjMoveStringLiteralDfa0_1()
return jjMoveNfa_1(0, 0);
}
}
private int jjMoveStringLiteralDfa1_1(long active0)
{
private int jjMoveStringLiteralDfa1_1(long active0){
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_1(0, active0);
@ -603,7 +595,7 @@ private int jjMoveNfa_1(int startState, int curPos)
{
if (kind > 33)
kind = 33;
jjCheckNAdd(6);
{ jjCheckNAdd(6); }
}
if ((0x100002600L & l) != 0L)
{
@ -611,19 +603,19 @@ private int jjMoveNfa_1(int startState, int curPos)
kind = 7;
}
else if (curChar == 34)
jjCheckNAddTwoStates(2, 4);
{ jjCheckNAddTwoStates(2, 4); }
break;
case 1:
if (curChar == 34)
jjCheckNAddTwoStates(2, 4);
{ jjCheckNAddTwoStates(2, 4); }
break;
case 2:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddStates(10, 12);
{ jjCheckNAddStates(10, 12); }
break;
case 3:
if (curChar == 34)
jjCheckNAddStates(10, 12);
{ jjCheckNAddStates(10, 12); }
break;
case 5:
if (curChar == 34 && kind > 32)
@ -634,7 +626,7 @@ private int jjMoveNfa_1(int startState, int curPos)
break;
if (kind > 33)
kind = 33;
jjCheckNAdd(6);
{ jjCheckNAdd(6); }
break;
default : break;
}
@ -653,10 +645,10 @@ private int jjMoveNfa_1(int startState, int curPos)
break;
if (kind > 33)
kind = 33;
jjCheckNAdd(6);
{ jjCheckNAdd(6); }
break;
case 2:
jjAddStates(10, 12);
{ jjAddStates(10, 12); }
break;
case 4:
if (curChar == 92)
@ -668,7 +660,7 @@ private int jjMoveNfa_1(int startState, int curPos)
}
else
{
int hiByte = curChar >> 8;
int hiByte = (curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
@ -687,21 +679,21 @@ private int jjMoveNfa_1(int startState, int curPos)
{
if (kind > 33)
kind = 33;
jjCheckNAdd(6);
{ jjCheckNAdd(6); }
}
break;
case 2:
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
jjAddStates(10, 12);
{ jjAddStates(10, 12); }
break;
case 6:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 33)
kind = 33;
jjCheckNAdd(6);
{ jjCheckNAdd(6); }
break;
default : break;
default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
}
} while(i != startsAt);
}
@ -718,6 +710,37 @@ private int jjMoveNfa_1(int startState, int curPos)
catch(java.io.IOException e) { return curPos; }
}
}
/** Token literal values. */
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, null, null, null, null, null, null, "\53", "\55",
"\50", "\51", "\72", "\75", "\74", "\74\75", "\76", "\76\75", "\136", null, null,
null, null, "\133", "\173", null, "\124\117", "\135", "\175", null, null, };
protected Token jjFillToken()
{
final Token t;
final String curTokenImage;
final int beginLine;
final int endLine;
final int beginColumn;
final int endColumn;
String im = jjstrLiteralImages[jjmatchedKind];
curTokenImage = (im == null) ? input_stream.GetImage() : im;
beginLine = input_stream.getBeginLine();
beginColumn = input_stream.getBeginColumn();
endLine = input_stream.getEndLine();
endColumn = input_stream.getEndColumn();
t = Token.newToken(jjmatchedKind);
t.kind = jjmatchedKind;
t.image = curTokenImage;
t.beginLine = beginLine;
t.endLine = endLine;
t.beginColumn = beginColumn;
t.endColumn = endColumn;
return t;
}
static final int[] jjnextStates = {
29, 31, 32, 15, 16, 18, 25, 26, 0, 1, 2, 4, 5,
};
@ -758,101 +781,6 @@ private static final boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, lo
}
}
/** Token literal values. */
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, null, null, null, null, null, null, "\53", "\55",
"\50", "\51", "\72", "\75", "\74", "\74\75", "\76", "\76\75", "\136", null, null,
null, null, "\133", "\173", null, "\124\117", "\135", "\175", null, null, };
/** Lexer state names. */
public static final String[] lexStateNames = {
"Boost",
"Range",
"DEFAULT",
};
/** Lex State array. */
public static final int[] jjnewLexState = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1,
-1, 1, 1, 2, -1, 2, 2, -1, -1,
};
static final long[] jjtoToken = {
0x3ffffff01L,
};
static final long[] jjtoSkip = {
0x80L,
};
protected CharStream input_stream;
private final int[] jjrounds = new int[33];
private final int[] jjstateSet = new int[66];
protected char curChar;
/** Constructor. */
public StandardSyntaxParserTokenManager(CharStream stream){
input_stream = stream;
}
/** Constructor. */
public StandardSyntaxParserTokenManager(CharStream stream, int lexState){
this(stream);
SwitchTo(lexState);
}
/** Reinitialise parser. */
public void ReInit(CharStream stream)
{
jjmatchedPos = jjnewStateCnt = 0;
curLexState = defaultLexState;
input_stream = stream;
ReInitRounds();
}
private void ReInitRounds()
{
int i;
jjround = 0x80000001;
for (i = 33; i-- > 0;)
jjrounds[i] = 0x80000000;
}
/** Reinitialise parser. */
public void ReInit(CharStream stream, int lexState)
{
ReInit(stream);
SwitchTo(lexState);
}
/** Switch to specified lex state. */
public void SwitchTo(int lexState)
{
if (lexState >= 3 || lexState < 0)
throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
else
curLexState = lexState;
}
protected Token jjFillToken()
{
final Token t;
final String curTokenImage;
final int beginLine;
final int endLine;
final int beginColumn;
final int endColumn;
String im = jjstrLiteralImages[jjmatchedKind];
curTokenImage = (im == null) ? input_stream.GetImage() : im;
beginLine = input_stream.getBeginLine();
beginColumn = input_stream.getBeginColumn();
endLine = input_stream.getEndLine();
endColumn = input_stream.getEndColumn();
t = Token.newToken(jjmatchedKind, curTokenImage);
t.beginLine = beginLine;
t.endLine = endLine;
t.beginColumn = beginColumn;
t.endColumn = endColumn;
return t;
}
int curLexState = 2;
int defaultLexState = 2;
int jjnewStateCnt;
@ -873,9 +801,10 @@ public Token getNextToken()
{
curChar = input_stream.BeginToken();
}
catch(java.io.IOException e)
catch(Exception e)
{
jjmatchedKind = 0;
jjmatchedPos = -1;
matchedToken = jjFillToken();
return matchedToken;
}
@ -939,6 +868,31 @@ public Token getNextToken()
}
}
void SkipLexicalActions(Token matchedToken)
{
switch(jjmatchedKind)
{
default :
break;
}
}
void MoreLexicalActions()
{
jjimageLen += (lengthOfMatch = jjmatchedPos + 1);
switch(jjmatchedKind)
{
default :
break;
}
}
void TokenLexicalActions(Token matchedToken)
{
switch(jjmatchedKind)
{
default :
break;
}
}
private void jjCheckNAdd(int state)
{
if (jjrounds[state] != jjround)
@ -966,4 +920,90 @@ private void jjCheckNAddStates(int start, int end)
} while (start++ != end);
}
/** Constructor. */
public StandardSyntaxParserTokenManager(CharStream stream){
input_stream = stream;
}
/** Constructor. */
public StandardSyntaxParserTokenManager (CharStream stream, int lexState){
ReInit(stream);
SwitchTo(lexState);
}
/** Reinitialise parser. */
public void ReInit(CharStream stream)
{
jjmatchedPos =
jjnewStateCnt =
0;
curLexState = defaultLexState;
input_stream = stream;
ReInitRounds();
}
private void ReInitRounds()
{
int i;
jjround = 0x80000001;
for (i = 33; i-- > 0;)
jjrounds[i] = 0x80000000;
}
/** Reinitialise parser. */
public void ReInit(CharStream stream, int lexState)
{
ReInit(stream);
SwitchTo(lexState);
}
/** Switch to specified lex state. */
public void SwitchTo(int lexState)
{
if (lexState >= 3 || lexState < 0)
throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
else
curLexState = lexState;
}
/** Lexer state names. */
public static final String[] lexStateNames = {
"Boost",
"Range",
"DEFAULT",
};
/** Lex State array. */
public static final int[] jjnewLexState = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1,
-1, 1, 1, 2, -1, 2, 2, -1, -1,
};
static final long[] jjtoToken = {
0x3ffffff01L,
};
static final long[] jjtoSkip = {
0x80L,
};
static final long[] jjtoSpecial = {
0x0L,
};
static final long[] jjtoMore = {
0x0L,
};
protected CharStream input_stream;
private final int[] jjrounds = new int[33];
private final int[] jjstateSet = new int[2 * 33];
private final StringBuilder jjimage = new StringBuilder();
private StringBuilder image = jjimage;
private int jjimageLen;
private int lengthOfMatch;
protected int curChar;
}

View File

@ -1,5 +1,5 @@
/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
/* Generated By:JavaCC: Do not edit this line. Token.java Version 7.0 */
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.apache.lucene.queryparser.flexible.standard.parser;
/**
@ -97,6 +97,7 @@ public class Token implements java.io.Serializable {
/**
* Returns the image.
*/
@Override
public String toString()
{
return image;

View File

@ -1,4 +1,4 @@
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 7.0 */
/* JavaCCOptions: */
package org.apache.lucene.queryparser.flexible.standard.parser;
@ -20,22 +20,22 @@ public class TokenMgrError extends Error
/**
* Lexical error occurred.
*/
static final int LEXICAL_ERROR = 0;
public static final int LEXICAL_ERROR = 0;
/**
* An attempt was made to create a second instance of a static token manager.
*/
static final int STATIC_LEXER_ERROR = 1;
public static final int STATIC_LEXER_ERROR = 1;
/**
* Tried to change to an invalid lexical state.
*/
static final int INVALID_LEXICAL_STATE = 2;
public static final int INVALID_LEXICAL_STATE = 2;
/**
* Detected (and bailed out of) an infinite loop in the token manager.
*/
static final int LOOP_DETECTED = 3;
public static final int LOOP_DETECTED = 3;
/**
* Indicates the reason why the exception is thrown. It will have
@ -53,8 +53,6 @@ public class TokenMgrError extends Error
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
@ -104,11 +102,12 @@ public class TokenMgrError extends Error
* curchar : the offending character
* Note: You can customize the lexical error message by modifying this method.
*/
protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
protected static String LexicalErr(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar) {
char curChar1 = (char)curChar;
return("Lexical error at line " +
errorLine + ", column " +
errorColumn + ". Encountered: " +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar1)) + "\"") + " (" + curChar + "), ") +
"after : \"" + addEscapes(errorAfter) + "\"");
}
@ -121,6 +120,7 @@ public class TokenMgrError extends Error
*
* from this method for such cases in the release version of your parser.
*/
@Override
public String getMessage() {
return super.getMessage();
}
@ -140,8 +140,8 @@ public class TokenMgrError extends Error
}
/** Full Constructor. */
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) {
this(LexicalErr(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
/* (filtered)*/

View File

@ -1,4 +1,4 @@
/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 5.0 */
/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 7.0 */
/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.apache.lucene.queryparser.surround.parser;
@ -111,5 +111,10 @@ interface CharStream {
*/
void Done();
void setTabSize(int i);
int getTabSize();
boolean getTrackLineColumn();
void setTrackLineColumn(boolean trackLineColumn);
}
/* (filtered)*/

View File

@ -137,4 +137,24 @@ public final class FastCharStream implements CharStream {
public final int getBeginLine() {
return 1;
}
@Override
public void setTabSize(int i) {
throw new RuntimeException("Tab size not implemented.");
}
@Override
public int getTabSize() {
throw new RuntimeException("Tab size not implemented.");
}
@Override
public boolean getTrackLineColumn() {
return false;
}
@Override
public void setTrackLineColumn(boolean trackLineColumn) {
throw new RuntimeException("Line/Column tracking not implemented.");
}
}

View File

@ -1,5 +1,5 @@
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
/* JavaCCOptions:KEEP_LINE_COL=null */
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 7.0 */
/* JavaCCOptions:KEEP_LINE_COLUMN=true */
package org.apache.lucene.queryparser.surround.parser;
/**
@ -20,6 +20,11 @@ public class ParseException extends Exception {
*/
private static final long serialVersionUID = 1L;
/**
* The end of line string for this machine.
*/
protected static String EOL = System.getProperty("line.separator", "\n");
/**
* This constructor is used by the method "generateParseException"
* in the generated parser. Calling this constructor generates
@ -88,7 +93,7 @@ public class ParseException extends Exception {
private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuilder expected = new StringBuilder();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
@ -101,7 +106,7 @@ public class ParseException extends Exception {
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected.append("...");
}
expected.append(eol).append(" ");
expected.append(EOL).append(" ");
}
String retval = "Encountered \"";
Token tok = currentToken.next;
@ -118,20 +123,23 @@ public class ParseException extends Exception {
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
retval += "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
retval += "." + EOL;
if (expectedTokenSequences.length == 0) {
// Nothing to add here
} else {
retval += "Was expecting one of:" + eol + " ";
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + EOL + " ";
} else {
retval += "Was expecting one of:" + EOL + " ";
}
retval += expected.toString();
}
retval += expected.toString();
return retval;
}
/**
* The end of line string for this machine.
*/
protected String eol = System.getProperty("line.separator", "\n");
/**
* Used to convert raw characters to their escaped version
@ -144,8 +152,6 @@ public class ParseException extends Exception {
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;

View File

@ -1,3 +1,4 @@
/* QueryParser.java */
/* Generated By:JavaCC: Do not edit this line. QueryParser.java */
package org.apache.lucene.queryparser.surround.parser;
@ -151,25 +152,22 @@ public class QueryParser implements QueryParserConstants {
return new SrndTruncQuery(truncated, TRUNCATOR, ANY_CHAR);
}
final public SrndQuery TopSrndQuery() throws ParseException {
SrndQuery q;
final public SrndQuery TopSrndQuery() throws ParseException {SrndQuery q;
q = FieldsQuery();
jj_consume_token(0);
{if (true) return q;}
{if ("" != null) return q;}
throw new Error("Missing return statement in function");
}
}
final public SrndQuery FieldsQuery() throws ParseException {
SrndQuery q;
final public SrndQuery FieldsQuery() throws ParseException {SrndQuery q;
ArrayList<String> fieldNames;
fieldNames = OptionalFields();
q = OrQuery();
{if (true) return (fieldNames == null) ? q : getFieldsQuery(q, fieldNames);}
{if ("" != null) return (fieldNames == null) ? q : getFieldsQuery(q, fieldNames);}
throw new Error("Missing return statement in function");
}
}
final public ArrayList<String> OptionalFields() throws ParseException {
Token fieldName;
final public ArrayList<String> OptionalFields() throws ParseException {Token fieldName;
ArrayList<String> fieldNames = null;
label_1:
while (true) {
@ -181,304 +179,313 @@ public class QueryParser implements QueryParserConstants {
// to the colon
fieldName = jj_consume_token(TERM);
jj_consume_token(COLON);
if (fieldNames == null) {
if (fieldNames == null) {
fieldNames = new ArrayList<String>();
}
fieldNames.add(fieldName.image);
}
{if (true) return fieldNames;}
{if ("" != null) return fieldNames;}
throw new Error("Missing return statement in function");
}
}
final public SrndQuery OrQuery() throws ParseException {
SrndQuery q;
final public SrndQuery OrQuery() throws ParseException {SrndQuery q;
ArrayList<SrndQuery> queries = null;
Token oprt = null;
q = AndQuery();
label_2:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case OR:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case OR:{
;
break;
}
default:
jj_la1[0] = jj_gen;
break label_2;
}
oprt = jj_consume_token(OR);
/* keep only last used operator */
/* keep only last used operator */
if (queries == null) {
queries = new ArrayList<SrndQuery>();
queries.add(q);
}
q = AndQuery();
queries.add(q);
queries.add(q);
}
{if (true) return (queries == null) ? q : getOrQuery(queries, true /* infix */, oprt);}
{if ("" != null) return (queries == null) ? q : getOrQuery(queries, true /* infix */, oprt);}
throw new Error("Missing return statement in function");
}
}
final public SrndQuery AndQuery() throws ParseException {
SrndQuery q;
final public SrndQuery AndQuery() throws ParseException {SrndQuery q;
ArrayList<SrndQuery> queries = null;
Token oprt = null;
q = NotQuery();
label_3:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case AND:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case AND:{
;
break;
}
default:
jj_la1[1] = jj_gen;
break label_3;
}
oprt = jj_consume_token(AND);
/* keep only last used operator */
/* keep only last used operator */
if (queries == null) {
queries = new ArrayList<SrndQuery>();
queries.add(q);
}
q = NotQuery();
queries.add(q);
queries.add(q);
}
{if (true) return (queries == null) ? q : getAndQuery(queries, true /* infix */, oprt);}
{if ("" != null) return (queries == null) ? q : getAndQuery(queries, true /* infix */, oprt);}
throw new Error("Missing return statement in function");
}
}
final public SrndQuery NotQuery() throws ParseException {
SrndQuery q;
final public SrndQuery NotQuery() throws ParseException {SrndQuery q;
ArrayList<SrndQuery> queries = null;
Token oprt = null;
q = NQuery();
label_4:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NOT:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case NOT:{
;
break;
}
default:
jj_la1[2] = jj_gen;
break label_4;
}
oprt = jj_consume_token(NOT);
/* keep only last used operator */
/* keep only last used operator */
if (queries == null) {
queries = new ArrayList<SrndQuery>();
queries.add(q);
}
q = NQuery();
queries.add(q);
queries.add(q);
}
{if (true) return (queries == null) ? q : getNotQuery(queries, oprt);}
{if ("" != null) return (queries == null) ? q : getNotQuery(queries, oprt);}
throw new Error("Missing return statement in function");
}
}
final public SrndQuery NQuery() throws ParseException {
SrndQuery q;
final public SrndQuery NQuery() throws ParseException {SrndQuery q;
ArrayList<SrndQuery> queries;
Token dt;
q = WQuery();
label_5:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case N:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case N:{
;
break;
}
default:
jj_la1[3] = jj_gen;
break label_5;
}
dt = jj_consume_token(N);
queries = new ArrayList<SrndQuery>();
queries = new ArrayList<SrndQuery>();
queries.add(q); /* left associative */
q = WQuery();
queries.add(q);
queries.add(q);
q = getDistanceQuery(queries, true /* infix */, dt, false /* not ordered */);
}
{if (true) return q;}
{if ("" != null) return q;}
throw new Error("Missing return statement in function");
}
}
final public SrndQuery WQuery() throws ParseException {
SrndQuery q;
final public SrndQuery WQuery() throws ParseException {SrndQuery q;
ArrayList<SrndQuery> queries;
Token wt;
q = PrimaryQuery();
label_6:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case W:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case W:{
;
break;
}
default:
jj_la1[4] = jj_gen;
break label_6;
}
wt = jj_consume_token(W);
queries = new ArrayList<SrndQuery>();
queries = new ArrayList<SrndQuery>();
queries.add(q); /* left associative */
q = PrimaryQuery();
queries.add(q);
queries.add(q);
q = getDistanceQuery(queries, true /* infix */, wt, true /* ordered */);
}
{if (true) return q;}
{if ("" != null) return q;}
throw new Error("Missing return statement in function");
}
}
final public SrndQuery PrimaryQuery() throws ParseException {
/* bracketed weighted query or weighted term */
final public SrndQuery PrimaryQuery() throws ParseException {/* bracketed weighted query or weighted term */
SrndQuery q;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case LPAREN:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case LPAREN:{
jj_consume_token(LPAREN);
q = FieldsQuery();
jj_consume_token(RPAREN);
break;
}
case OR:
case AND:
case W:
case N:
case N:{
q = PrefixOperatorQuery();
break;
}
case TRUNCQUOTED:
case QUOTED:
case SUFFIXTERM:
case TRUNCTERM:
case TERM:
case TERM:{
q = SimpleTerm();
break;
}
default:
jj_la1[5] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
OptionalWeights(q);
{if (true) return q;}
{if ("" != null) return q;}
throw new Error("Missing return statement in function");
}
}
final public SrndQuery PrefixOperatorQuery() throws ParseException {
Token oprt;
final public SrndQuery PrefixOperatorQuery() throws ParseException {Token oprt;
List<SrndQuery> queries;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case OR:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case OR:{
oprt = jj_consume_token(OR);
/* prefix OR */
queries = FieldsQueryList();
{if (true) return getOrQuery(queries, false /* not infix */, oprt);}
{if ("" != null) return getOrQuery(queries, false /* not infix */, oprt);}
break;
case AND:
}
case AND:{
oprt = jj_consume_token(AND);
/* prefix AND */
queries = FieldsQueryList();
{if (true) return getAndQuery(queries, false /* not infix */, oprt);}
{if ("" != null) return getAndQuery(queries, false /* not infix */, oprt);}
break;
case N:
}
case N:{
oprt = jj_consume_token(N);
/* prefix N */
queries = FieldsQueryList();
{if (true) return getDistanceQuery(queries, false /* not infix */, oprt, false /* not ordered */);}
{if ("" != null) return getDistanceQuery(queries, false /* not infix */, oprt, false /* not ordered */);}
break;
case W:
}
case W:{
oprt = jj_consume_token(W);
/* prefix W */
queries = FieldsQueryList();
{if (true) return getDistanceQuery(queries, false /* not infix */, oprt, true /* ordered */);}
{if ("" != null) return getDistanceQuery(queries, false /* not infix */, oprt, true /* ordered */);}
break;
}
default:
jj_la1[6] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
throw new Error("Missing return statement in function");
}
}
final public List<SrndQuery> FieldsQueryList() throws ParseException {
SrndQuery q;
final public List<SrndQuery> FieldsQueryList() throws ParseException {SrndQuery q;
ArrayList<SrndQuery> queries = new ArrayList<SrndQuery>();
jj_consume_token(LPAREN);
q = FieldsQuery();
queries.add(q);
queries.add(q);
label_7:
while (true) {
jj_consume_token(COMMA);
q = FieldsQuery();
queries.add(q);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
queries.add(q);
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case COMMA:{
;
break;
}
default:
jj_la1[7] = jj_gen;
break label_7;
}
}
jj_consume_token(RPAREN);
{if (true) return queries;}
{if ("" != null) return queries;}
throw new Error("Missing return statement in function");
}
}
final public SrndQuery SimpleTerm() throws ParseException {
Token term;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TERM:
final public SrndQuery SimpleTerm() throws ParseException {Token term;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case TERM:{
term = jj_consume_token(TERM);
{if (true) return getTermQuery(term.image, false /* not quoted */);}
{if ("" != null) return getTermQuery(term.image, false /* not quoted */);}
break;
case QUOTED:
}
case QUOTED:{
term = jj_consume_token(QUOTED);
{if (true) return getTermQuery(term.image.substring(1, term.image.length()-1), true /* quoted */);}
{if ("" != null) return getTermQuery(term.image.substring(1, term.image.length()-1), true /* quoted */);}
break;
case SUFFIXTERM:
}
case SUFFIXTERM:{
term = jj_consume_token(SUFFIXTERM);
/* ending in * */
/* ending in * */
if (! allowedSuffix(term.image)) {
{if (true) throw new ParseException(TRUNCATION_ERROR_MESSAGE + term.image);}
}
{if (true) return getPrefixQuery(term.image.substring(0, term.image.length()-1), false /* not quoted */);}
{if ("" != null) return getPrefixQuery(term.image.substring(0, term.image.length()-1), false /* not quoted */);}
break;
case TRUNCTERM:
}
case TRUNCTERM:{
term = jj_consume_token(TRUNCTERM);
/* with at least one * or ? */
/* with at least one * or ? */
if (! allowedTruncation(term.image)) {
{if (true) throw new ParseException(TRUNCATION_ERROR_MESSAGE + term.image);}
}
{if (true) return getTruncQuery(term.image);}
{if ("" != null) return getTruncQuery(term.image);}
break;
case TRUNCQUOTED:
}
case TRUNCQUOTED:{
term = jj_consume_token(TRUNCQUOTED);
/* eg. "9b-b,m"* */
/* eg. "9b-b,m"* */
if ((term.image.length() - 3) < MINIMUM_PREFIX_LENGTH) {
{if (true) throw new ParseException(TRUNCATION_ERROR_MESSAGE + term.image);}
}
{if (true) return getPrefixQuery(term.image.substring(1, term.image.length()-2), true /* quoted */);}
{if ("" != null) return getPrefixQuery(term.image.substring(1, term.image.length()-2), true /* quoted */);}
break;
}
default:
jj_la1[8] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
throw new Error("Missing return statement in function");
}
}
final public void OptionalWeights(SrndQuery q) throws ParseException {
Token weight=null;
final public void OptionalWeights(SrndQuery q) throws ParseException {Token weight=null;
label_8:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case CARAT:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case CARAT:{
;
break;
}
default:
jj_la1[9] = jj_gen;
break label_8;
}
jj_consume_token(CARAT);
weight = jj_consume_token(NUMBER);
float f;
float f;
try {
f = Float.parseFloat(weight.image);
} catch (Exception floatExc) {
@ -490,16 +497,18 @@ public class QueryParser implements QueryParserConstants {
q.setWeight(f * q.getWeight()); /* left associative, fwiw */
}
}
}
private boolean jj_2_1(int xla) {
private boolean jj_2_1(int xla)
{
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_1(); }
try { return (!jj_3_1()); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(0, xla); }
}
private boolean jj_3_1() {
private boolean jj_3_1()
{
if (jj_scan_token(TERM)) return true;
if (jj_scan_token(COLON)) return true;
return false;
@ -518,127 +527,128 @@ public class QueryParser implements QueryParserConstants {
final private int[] jj_la1 = new int[10];
static private int[] jj_la1_0;
static {
jj_la1_init_0();
}
private static void jj_la1_init_0() {
jj_la1_0 = new int[] {0x100,0x200,0x400,0x1000,0x800,0x7c3b00,0x1b00,0x8000,0x7c0000,0x20000,};
}
jj_la1_init_0();
}
private static void jj_la1_init_0() {
jj_la1_0 = new int[] {0x100,0x200,0x400,0x1000,0x800,0x7c3b00,0x1b00,0x8000,0x7c0000,0x20000,};
}
final private JJCalls[] jj_2_rtns = new JJCalls[1];
private boolean jj_rescan = false;
private int jj_gc = 0;
/** Constructor with user supplied CharStream. */
public QueryParser(CharStream stream) {
token_source = new QueryParserTokenManager(stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
token_source = new QueryParserTokenManager(stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
/** Reinitialise. */
public void ReInit(CharStream stream) {
token_source.ReInit(stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
token_source.ReInit(stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
/** Constructor with generated Token Manager. */
public QueryParser(QueryParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
/** Reinitialise. */
public void ReInit(QueryParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 10; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
private Token jj_consume_token(int kind) throws ParseException {
Token oldToken;
if ((oldToken = token).next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
if (token.kind == kind) {
jj_gen++;
if (++jj_gc > 100) {
jj_gc = 0;
for (int i = 0; i < jj_2_rtns.length; i++) {
JJCalls c = jj_2_rtns[i];
while (c != null) {
if (c.gen < jj_gen) c.first = null;
c = c.next;
}
}
}
return token;
}
token = oldToken;
jj_kind = kind;
throw generateParseException();
Token oldToken;
if ((oldToken = token).next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
if (token.kind == kind) {
jj_gen++;
if (++jj_gc > 100) {
jj_gc = 0;
for (int i = 0; i < jj_2_rtns.length; i++) {
JJCalls c = jj_2_rtns[i];
while (c != null) {
if (c.gen < jj_gen) c.first = null;
c = c.next;
}
}
}
return token;
}
token = oldToken;
jj_kind = kind;
throw generateParseException();
}
@SuppressWarnings("serial")
static private final class LookaheadSuccess extends java.lang.Error { }
final private LookaheadSuccess jj_ls = new LookaheadSuccess();
private boolean jj_scan_token(int kind) {
if (jj_scanpos == jj_lastpos) {
jj_la--;
if (jj_scanpos.next == null) {
jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
} else {
jj_lastpos = jj_scanpos = jj_scanpos.next;
}
} else {
jj_scanpos = jj_scanpos.next;
}
if (jj_rescan) {
int i = 0; Token tok = token;
while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
if (tok != null) jj_add_error_token(kind, i);
}
if (jj_scanpos.kind != kind) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
return false;
if (jj_scanpos == jj_lastpos) {
jj_la--;
if (jj_scanpos.next == null) {
jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
} else {
jj_lastpos = jj_scanpos = jj_scanpos.next;
}
} else {
jj_scanpos = jj_scanpos.next;
}
if (jj_rescan) {
int i = 0; Token tok = token;
while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
if (tok != null) jj_add_error_token(kind, i);
}
if (jj_scanpos.kind != kind) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
return false;
}
/** Get the next Token. */
final public Token getNextToken() {
if (token.next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
jj_gen++;
return token;
if (token.next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
jj_gen++;
return token;
}
/** Get the specific Token. */
final public Token getToken(int index) {
Token t = token;
for (int i = 0; i < index; i++) {
if (t.next != null) t = t.next;
else t = t.next = token_source.getNextToken();
}
return t;
Token t = token;
for (int i = 0; i < index; i++) {
if (t.next != null) t = t.next;
else t = t.next = token_source.getNextToken();
}
return t;
}
private int jj_ntk() {
if ((jj_nt=token.next) == null)
return (jj_ntk = (token.next=token_source.getNextToken()).kind);
else
return (jj_ntk = jj_nt.kind);
private int jj_ntk_f() {
if ((jj_nt=token.next) == null)
return (jj_ntk = (token.next=token_source.getNextToken()).kind);
else
return (jj_ntk = jj_nt.kind);
}
private java.util.List<int[]> jj_expentries = new java.util.ArrayList<>();
@ -648,62 +658,83 @@ public class QueryParser implements QueryParserConstants {
private int jj_endpos;
private void jj_add_error_token(int kind, int pos) {
if (pos >= 100) return;
if (pos == jj_endpos + 1) {
jj_lasttokens[jj_endpos++] = kind;
} else if (jj_endpos != 0) {
jj_expentry = new int[jj_endpos];
for (int i = 0; i < jj_endpos; i++) {
jj_expentry[i] = jj_lasttokens[i];
}
jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {
int[] oldentry = (int[])(it.next());
if (oldentry.length == jj_expentry.length) {
for (int i = 0; i < jj_expentry.length; i++) {
if (oldentry[i] != jj_expentry[i]) {
continue jj_entries_loop;
}
}
jj_expentries.add(jj_expentry);
break jj_entries_loop;
}
}
if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
}
if (pos >= 100) {
return;
}
if (pos == jj_endpos + 1) {
jj_lasttokens[jj_endpos++] = kind;
} else if (jj_endpos != 0) {
jj_expentry = new int[jj_endpos];
for (int i = 0; i < jj_endpos; i++) {
jj_expentry[i] = jj_lasttokens[i];
}
for (int[] oldentry : jj_expentries) {
if (oldentry.length == jj_expentry.length) {
boolean isMatched = true;
for (int i = 0; i < jj_expentry.length; i++) {
if (oldentry[i] != jj_expentry[i]) {
isMatched = false;
break;
}
}
if (isMatched) {
jj_expentries.add(jj_expentry);
break;
}
}
}
if (pos != 0) {
jj_lasttokens[(jj_endpos = pos) - 1] = kind;
}
}
}
/** Generate ParseException. */
public ParseException generateParseException() {
jj_expentries.clear();
boolean[] la1tokens = new boolean[24];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 10; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
la1tokens[j] = true;
}
}
}
}
for (int i = 0; i < 24; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
jj_expentries.add(jj_expentry);
}
}
jj_endpos = 0;
jj_rescan_token();
jj_add_error_token(0, 0);
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = jj_expentries.get(i);
}
return new ParseException(token, exptokseq, tokenImage);
jj_expentries.clear();
boolean[] la1tokens = new boolean[24];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 10; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
la1tokens[j] = true;
}
}
}
}
for (int i = 0; i < 24; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
jj_expentries.add(jj_expentry);
}
}
jj_endpos = 0;
jj_rescan_token();
jj_add_error_token(0, 0);
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = jj_expentries.get(i);
}
return new ParseException(token, exptokseq, tokenImage);
}
private int trace_indent = 0;
private boolean trace_enabled;
/** Trace enabled. */
final public boolean trace_enabled() {
return trace_enabled;
}
/** Enable tracing. */
@ -715,38 +746,43 @@ public class QueryParser implements QueryParserConstants {
}
private void jj_rescan_token() {
jj_rescan = true;
for (int i = 0; i < 1; i++) {
try {
JJCalls p = jj_2_rtns[i];
do {
if (p.gen > jj_gen) {
jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
switch (i) {
case 0: jj_3_1(); break;
}
}
p = p.next;
} while (p != null);
} catch(LookaheadSuccess ls) { }
}
jj_rescan = false;
jj_rescan = true;
for (int i = 0; i < 1; i++) {
try {
JJCalls p = jj_2_rtns[i];
do {
if (p.gen > jj_gen) {
jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
switch (i) {
case 0: jj_3_1(); break;
}
}
p = p.next;
} while (p != null);
} catch(LookaheadSuccess ls) { }
}
jj_rescan = false;
}
private void jj_save(int index, int xla) {
JJCalls p = jj_2_rtns[index];
while (p.gen > jj_gen) {
if (p.next == null) { p = p.next = new JJCalls(); break; }
p = p.next;
}
p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
JJCalls p = jj_2_rtns[index];
while (p.gen > jj_gen) {
if (p.next == null) { p = p.next = new JJCalls(); break; }
p = p.next;
}
p.gen = jj_gen + xla - jj_la;
p.first = token;
p.arg = xla;
}
static final class JJCalls {
int gen;
Token first;
int arg;
JJCalls next;
int gen;
Token first;
int arg;
JJCalls next;
}
}

View File

@ -1,3 +1,4 @@
/* QueryParserTokenManager.java */
/* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */
package org.apache.lucene.queryparser.surround.parser;
@ -15,23 +16,20 @@ package org.apache.lucene.queryparser.surround.parser;
/** Token Manager. */
public class QueryParserTokenManager implements QueryParserConstants
{
public class QueryParserTokenManager implements QueryParserConstants {
/** Debug output. */
// (debugStream omitted).
/** Set debug output. */
// (setDebugStream omitted).
private final int jjStopStringLiteralDfa_1(int pos, long active0)
{
private final int jjStopStringLiteralDfa_1(int pos, long active0){
switch (pos)
{
default :
return -1;
}
}
private final int jjStartNfa_1(int pos, long active0)
{
private final int jjStartNfa_1(int pos, long active0){
return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1);
}
private int jjStopAtPos(int pos, int kind)
@ -40,8 +38,7 @@ private int jjStopAtPos(int pos, int kind)
jjmatchedPos = pos;
return pos + 1;
}
private int jjMoveStringLiteralDfa0_1()
{
private int jjMoveStringLiteralDfa0_1(){
switch(curChar)
{
case 40:
@ -87,7 +84,7 @@ private int jjMoveNfa_1(int startState, int curPos)
{
if (kind > 22)
kind = 22;
jjCheckNAddStates(0, 4);
{ jjCheckNAddStates(0, 4); }
}
else if ((0x100002600L & l) != 0L)
{
@ -95,35 +92,35 @@ private int jjMoveNfa_1(int startState, int curPos)
kind = 7;
}
else if (curChar == 34)
jjCheckNAddStates(5, 7);
{ jjCheckNAddStates(5, 7); }
if ((0x3fc000000000000L & l) != 0L)
jjCheckNAddStates(8, 11);
{ jjCheckNAddStates(8, 11); }
else if (curChar == 49)
jjCheckNAddTwoStates(20, 21);
{ jjCheckNAddTwoStates(20, 21); }
break;
case 19:
if ((0x3fc000000000000L & l) != 0L)
jjCheckNAddStates(8, 11);
{ jjCheckNAddStates(8, 11); }
break;
case 20:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAdd(17);
{ jjCheckNAdd(17); }
break;
case 21:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAdd(18);
{ jjCheckNAdd(18); }
break;
case 22:
if (curChar == 49)
jjCheckNAddTwoStates(20, 21);
{ jjCheckNAddTwoStates(20, 21); }
break;
case 23:
if (curChar == 34)
jjCheckNAddStates(5, 7);
{ jjCheckNAddStates(5, 7); }
break;
case 24:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddTwoStates(24, 25);
{ jjCheckNAddTwoStates(24, 25); }
break;
case 25:
if (curChar == 34)
@ -135,11 +132,11 @@ private int jjMoveNfa_1(int startState, int curPos)
break;
case 27:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddStates(12, 14);
{ jjCheckNAddStates(12, 14); }
break;
case 29:
if (curChar == 34)
jjCheckNAddStates(12, 14);
{ jjCheckNAddStates(12, 14); }
break;
case 30:
if (curChar == 34 && kind > 19)
@ -150,11 +147,11 @@ private int jjMoveNfa_1(int startState, int curPos)
break;
if (kind > 22)
kind = 22;
jjCheckNAddStates(0, 4);
{ jjCheckNAddStates(0, 4); }
break;
case 32:
if ((0x7bffe8faffffd9ffL & l) != 0L)
jjCheckNAddTwoStates(32, 33);
{ jjCheckNAddTwoStates(32, 33); }
break;
case 33:
if (curChar == 42 && kind > 20)
@ -162,28 +159,28 @@ private int jjMoveNfa_1(int startState, int curPos)
break;
case 34:
if ((0x7bffe8faffffd9ffL & l) != 0L)
jjCheckNAddTwoStates(34, 35);
{ jjCheckNAddTwoStates(34, 35); }
break;
case 35:
if ((0x8000040000000000L & l) == 0L)
break;
if (kind > 21)
kind = 21;
jjCheckNAddTwoStates(35, 36);
{ jjCheckNAddTwoStates(35, 36); }
break;
case 36:
if ((0xfbffecfaffffd9ffL & l) == 0L)
break;
if (kind > 21)
kind = 21;
jjCheckNAdd(36);
{ jjCheckNAdd(36); }
break;
case 37:
if ((0x7bffe8faffffd9ffL & l) == 0L)
break;
if (kind > 22)
kind = 22;
jjCheckNAdd(37);
{ jjCheckNAdd(37); }
break;
default : break;
}
@ -201,7 +198,7 @@ private int jjMoveNfa_1(int startState, int curPos)
{
if (kind > 22)
kind = 22;
jjCheckNAddStates(0, 4);
{ jjCheckNAddStates(0, 4); }
}
if ((0x400000004000L & l) != 0L)
{
@ -299,11 +296,11 @@ private int jjMoveNfa_1(int startState, int curPos)
kind = 12;
break;
case 24:
jjAddStates(15, 16);
{ jjAddStates(15, 16); }
break;
case 27:
if ((0xffffffffefffffffL & l) != 0L)
jjCheckNAddStates(12, 14);
{ jjCheckNAddStates(12, 14); }
break;
case 28:
if (curChar == 92)
@ -311,22 +308,22 @@ private int jjMoveNfa_1(int startState, int curPos)
break;
case 29:
if (curChar == 92)
jjCheckNAddStates(12, 14);
{ jjCheckNAddStates(12, 14); }
break;
case 31:
if ((0xffffffffbfffffffL & l) == 0L)
break;
if (kind > 22)
kind = 22;
jjCheckNAddStates(0, 4);
{ jjCheckNAddStates(0, 4); }
break;
case 32:
if ((0xffffffffbfffffffL & l) != 0L)
jjCheckNAddTwoStates(32, 33);
{ jjCheckNAddTwoStates(32, 33); }
break;
case 34:
if ((0xffffffffbfffffffL & l) != 0L)
jjCheckNAddTwoStates(34, 35);
{ jjCheckNAddTwoStates(34, 35); }
break;
case 36:
if ((0xffffffffbfffffffL & l) == 0L)
@ -340,7 +337,7 @@ private int jjMoveNfa_1(int startState, int curPos)
break;
if (kind > 22)
kind = 22;
jjCheckNAdd(37);
{ jjCheckNAdd(37); }
break;
default : break;
}
@ -348,7 +345,7 @@ private int jjMoveNfa_1(int startState, int curPos)
}
else
{
int hiByte = curChar >> 8;
int hiByte = (curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
@ -362,23 +359,23 @@ private int jjMoveNfa_1(int startState, int curPos)
break;
if (kind > 22)
kind = 22;
jjCheckNAddStates(0, 4);
{ jjCheckNAddStates(0, 4); }
break;
case 24:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(15, 16);
{ jjAddStates(15, 16); }
break;
case 27:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(12, 14);
{ jjAddStates(12, 14); }
break;
case 32:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjCheckNAddTwoStates(32, 33);
{ jjCheckNAddTwoStates(32, 33); }
break;
case 34:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjCheckNAddTwoStates(34, 35);
{ jjCheckNAddTwoStates(34, 35); }
break;
case 36:
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
@ -392,9 +389,9 @@ private int jjMoveNfa_1(int startState, int curPos)
break;
if (kind > 22)
kind = 22;
jjCheckNAdd(37);
{ jjCheckNAdd(37); }
break;
default : break;
default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
}
} while(i != startsAt);
}
@ -438,18 +435,18 @@ private int jjMoveNfa_0(int startState, int curPos)
break;
if (kind > 23)
kind = 23;
jjAddStates(17, 18);
{ jjAddStates(17, 18); }
break;
case 1:
if (curChar == 46)
jjCheckNAdd(2);
{ jjCheckNAdd(2); }
break;
case 2:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 23)
kind = 23;
jjCheckNAdd(2);
{ jjCheckNAdd(2); }
break;
default : break;
}
@ -468,7 +465,7 @@ private int jjMoveNfa_0(int startState, int curPos)
}
else
{
int hiByte = curChar >> 8;
int hiByte = (curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
@ -477,7 +474,7 @@ private int jjMoveNfa_0(int startState, int curPos)
{
switch(jjstateSet[--i])
{
default : break;
default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
}
} while(i != startsAt);
}
@ -494,6 +491,36 @@ private int jjMoveNfa_0(int startState, int curPos)
catch(java.io.IOException e) { return curPos; }
}
}
/** Token literal values. */
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, null, null, null, null, null, null, null, null,
"\50", "\51", "\54", "\72", "\136", null, null, null, null, null, null, };
protected Token jjFillToken()
{
final Token t;
final String curTokenImage;
final int beginLine;
final int endLine;
final int beginColumn;
final int endColumn;
String im = jjstrLiteralImages[jjmatchedKind];
curTokenImage = (im == null) ? input_stream.GetImage() : im;
beginLine = input_stream.getBeginLine();
beginColumn = input_stream.getBeginColumn();
endLine = input_stream.getEndLine();
endColumn = input_stream.getEndColumn();
t = Token.newToken(jjmatchedKind);
t.kind = jjmatchedKind;
t.image = curTokenImage;
t.beginLine = beginLine;
t.endLine = endLine;
t.beginColumn = beginColumn;
t.endColumn = endColumn;
return t;
}
static final int[] jjnextStates = {
32, 33, 34, 35, 37, 24, 27, 28, 20, 17, 21, 18, 27, 28, 30, 24,
25, 0, 1,
@ -511,98 +538,6 @@ private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, lo
}
}
/** Token literal values. */
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, null, null, null, null, null, null, null, null,
"\50", "\51", "\54", "\72", "\136", null, null, null, null, null, null, };
/** Lexer state names. */
public static final String[] lexStateNames = {
"Boost",
"DEFAULT",
};
/** Lex State array. */
public static final int[] jjnewLexState = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, 1,
};
static final long[] jjtoToken = {
0xffff01L,
};
static final long[] jjtoSkip = {
0x80L,
};
protected CharStream input_stream;
private final int[] jjrounds = new int[38];
private final int[] jjstateSet = new int[76];
protected char curChar;
/** Constructor. */
public QueryParserTokenManager(CharStream stream){
input_stream = stream;
}
/** Constructor. */
public QueryParserTokenManager(CharStream stream, int lexState){
this(stream);
SwitchTo(lexState);
}
/** Reinitialise parser. */
public void ReInit(CharStream stream)
{
jjmatchedPos = jjnewStateCnt = 0;
curLexState = defaultLexState;
input_stream = stream;
ReInitRounds();
}
private void ReInitRounds()
{
int i;
jjround = 0x80000001;
for (i = 38; i-- > 0;)
jjrounds[i] = 0x80000000;
}
/** Reinitialise parser. */
public void ReInit(CharStream stream, int lexState)
{
ReInit(stream);
SwitchTo(lexState);
}
/** Switch to specified lex state. */
public void SwitchTo(int lexState)
{
if (lexState >= 2 || lexState < 0)
throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
else
curLexState = lexState;
}
protected Token jjFillToken()
{
final Token t;
final String curTokenImage;
final int beginLine;
final int endLine;
final int beginColumn;
final int endColumn;
String im = jjstrLiteralImages[jjmatchedKind];
curTokenImage = (im == null) ? input_stream.GetImage() : im;
beginLine = input_stream.getBeginLine();
beginColumn = input_stream.getBeginColumn();
endLine = input_stream.getEndLine();
endColumn = input_stream.getEndColumn();
t = Token.newToken(jjmatchedKind, curTokenImage);
t.beginLine = beginLine;
t.endLine = endLine;
t.beginColumn = beginColumn;
t.endColumn = endColumn;
return t;
}
int curLexState = 1;
int defaultLexState = 1;
int jjnewStateCnt;
@ -623,9 +558,10 @@ public Token getNextToken()
{
curChar = input_stream.BeginToken();
}
catch(java.io.IOException e)
catch(Exception e)
{
jjmatchedKind = 0;
jjmatchedPos = -1;
matchedToken = jjFillToken();
return matchedToken;
}
@ -684,6 +620,31 @@ public Token getNextToken()
}
}
void SkipLexicalActions(Token matchedToken)
{
switch(jjmatchedKind)
{
default :
break;
}
}
void MoreLexicalActions()
{
jjimageLen += (lengthOfMatch = jjmatchedPos + 1);
switch(jjmatchedKind)
{
default :
break;
}
}
void TokenLexicalActions(Token matchedToken)
{
switch(jjmatchedKind)
{
default :
break;
}
}
private void jjCheckNAdd(int state)
{
if (jjrounds[state] != jjround)
@ -711,4 +672,88 @@ private void jjCheckNAddStates(int start, int end)
} while (start++ != end);
}
/** Constructor. */
public QueryParserTokenManager(CharStream stream){
input_stream = stream;
}
/** Constructor. */
public QueryParserTokenManager (CharStream stream, int lexState){
ReInit(stream);
SwitchTo(lexState);
}
/** Reinitialise parser. */
public void ReInit(CharStream stream)
{
jjmatchedPos =
jjnewStateCnt =
0;
curLexState = defaultLexState;
input_stream = stream;
ReInitRounds();
}
private void ReInitRounds()
{
int i;
jjround = 0x80000001;
for (i = 38; i-- > 0;)
jjrounds[i] = 0x80000000;
}
/** Reinitialise parser. */
public void ReInit(CharStream stream, int lexState)
{
ReInit(stream);
SwitchTo(lexState);
}
/** Switch to specified lex state. */
public void SwitchTo(int lexState)
{
if (lexState >= 2 || lexState < 0)
throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
else
curLexState = lexState;
}
/** Lexer state names. */
public static final String[] lexStateNames = {
"Boost",
"DEFAULT",
};
/** Lex State array. */
public static final int[] jjnewLexState = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, 1,
};
static final long[] jjtoToken = {
0xffff01L,
};
static final long[] jjtoSkip = {
0x80L,
};
static final long[] jjtoSpecial = {
0x0L,
};
static final long[] jjtoMore = {
0x0L,
};
protected CharStream input_stream;
private final int[] jjrounds = new int[38];
private final int[] jjstateSet = new int[2 * 38];
private final StringBuilder jjimage = new StringBuilder();
private StringBuilder image = jjimage;
private int jjimageLen;
private int lengthOfMatch;
protected int curChar;
}

View File

@ -1,5 +1,5 @@
/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
/* Generated By:JavaCC: Do not edit this line. Token.java Version 7.0 */
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.apache.lucene.queryparser.surround.parser;
/**
@ -97,6 +97,7 @@ public class Token implements java.io.Serializable {
/**
* Returns the image.
*/
@Override
public String toString()
{
return image;

View File

@ -1,4 +1,4 @@
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 7.0 */
/* JavaCCOptions: */
package org.apache.lucene.queryparser.surround.parser;
@ -20,22 +20,22 @@ public class TokenMgrError extends Error
/**
* Lexical error occurred.
*/
static final int LEXICAL_ERROR = 0;
public static final int LEXICAL_ERROR = 0;
/**
* An attempt was made to create a second instance of a static token manager.
*/
static final int STATIC_LEXER_ERROR = 1;
public static final int STATIC_LEXER_ERROR = 1;
/**
* Tried to change to an invalid lexical state.
*/
static final int INVALID_LEXICAL_STATE = 2;
public static final int INVALID_LEXICAL_STATE = 2;
/**
* Detected (and bailed out of) an infinite loop in the token manager.
*/
static final int LOOP_DETECTED = 3;
public static final int LOOP_DETECTED = 3;
/**
* Indicates the reason why the exception is thrown. It will have
@ -53,8 +53,6 @@ public class TokenMgrError extends Error
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
@ -104,11 +102,12 @@ public class TokenMgrError extends Error
* curchar : the offending character
* Note: You can customize the lexical error message by modifying this method.
*/
protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
protected static String LexicalErr(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar) {
char curChar1 = (char)curChar;
return("Lexical error at line " +
errorLine + ", column " +
errorColumn + ". Encountered: " +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar1)) + "\"") + " (" + curChar + "), ") +
"after : \"" + addEscapes(errorAfter) + "\"");
}
@ -121,6 +120,7 @@ public class TokenMgrError extends Error
*
* from this method for such cases in the release version of your parser.
*/
@Override
public String getMessage() {
return super.getMessage();
}
@ -140,8 +140,8 @@ public class TokenMgrError extends Error
}
/** Full Constructor. */
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) {
this(LexicalErr(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
/* (filtered)*/

View File

@ -17,6 +17,7 @@
package org.apache.lucene.queryparser.flexible.standard;
import java.io.IOException;
import java.io.StringReader;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
@ -53,6 +54,9 @@ import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessor
import org.apache.lucene.queryparser.flexible.messages.MessageImpl;
import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryparser.flexible.standard.nodes.WildcardQueryNode;
import org.apache.lucene.queryparser.flexible.standard.parser.FastCharStream;
import org.apache.lucene.queryparser.flexible.standard.parser.ParseException;
import org.apache.lucene.queryparser.flexible.standard.parser.StandardSyntaxParser;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
@ -494,7 +498,12 @@ public class TestQPHelper extends LuceneTestCase {
"+(apple \"steve jobs\") -(foo bar baz)");
assertQueryEquals("+title:(dog OR cat) -author:\"bob dole\"", null,
"+(title:dog title:cat) -author:\"bob dole\"");
}
public void testParse() throws ParseException {
StandardSyntaxParser p = new StandardSyntaxParser(new FastCharStream(new StringReader("")));
p.ReInit(new FastCharStream(new StringReader("title:(dog OR cat)")));
System.out.println(p.TopLevelQuery("_fld_"));
}
public void testPunct() throws Exception {

View File

@ -1,4 +1,4 @@
/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 5.0 */
/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 7.0 */
/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.apache.solr.parser;
@ -111,5 +111,10 @@ interface CharStream {
*/
void Done();
void setTabSize(int i);
int getTabSize();
boolean getTrackLineColumn();
void setTrackLineColumn(boolean trackLineColumn);
}
/* (filtered)*/

View File

@ -145,4 +145,24 @@ public final class FastCharStream implements CharStream {
public final int getBeginLine() {
return 1;
}
@Override
public void setTabSize(int i) {
throw new RuntimeException("Tab size not implemented.");
}
@Override
public int getTabSize() {
throw new RuntimeException("Tab size not implemented.");
}
@Override
public boolean getTrackLineColumn() {
return false;
}
@Override
public void setTrackLineColumn(boolean trackLineColumn) {
throw new RuntimeException("Line/Column tracking not implemented.");
}
}

View File

@ -1,5 +1,5 @@
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
/* JavaCCOptions:KEEP_LINE_COL=null */
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 7.0 */
/* JavaCCOptions:KEEP_LINE_COLUMN=true */
package org.apache.solr.parser;
/**
@ -20,6 +20,11 @@ public class ParseException extends Exception {
*/
private static final long serialVersionUID = 1L;
/**
* The end of line string for this machine.
*/
protected static String EOL = System.getProperty("line.separator", "\n");
/**
* This constructor is used by the method "generateParseException"
* in the generated parser. Calling this constructor generates
@ -88,7 +93,7 @@ public class ParseException extends Exception {
private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuilder expected = new StringBuilder();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
@ -101,7 +106,7 @@ public class ParseException extends Exception {
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected.append("...");
}
expected.append(eol).append(" ");
expected.append(EOL).append(" ");
}
String retval = "Encountered \"";
Token tok = currentToken.next;
@ -118,20 +123,23 @@ public class ParseException extends Exception {
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
retval += "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
retval += "." + EOL;
if (expectedTokenSequences.length == 0) {
// Nothing to add here
} else {
retval += "Was expecting one of:" + eol + " ";
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + EOL + " ";
} else {
retval += "Was expecting one of:" + EOL + " ";
}
retval += expected.toString();
}
retval += expected.toString();
return retval;
}
/**
* The end of line string for this machine.
*/
protected String eol = System.getProperty("line.separator", "\n");
/**
* Used to convert raw characters to their escaped version
@ -144,8 +152,6 @@ public class ParseException extends Exception {
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
/* Generated By:JavaCC: Do not edit this line. Token.java Version 7.0 */
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.apache.solr.parser;
/**
@ -97,6 +97,7 @@ public class Token implements java.io.Serializable {
/**
* Returns the image.
*/
@Override
public String toString()
{
return image;

View File

@ -1,4 +1,4 @@
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 7.0 */
/* JavaCCOptions: */
package org.apache.solr.parser;
@ -20,22 +20,22 @@ public class TokenMgrError extends Error
/**
* Lexical error occurred.
*/
static final int LEXICAL_ERROR = 0;
public static final int LEXICAL_ERROR = 0;
/**
* An attempt was made to create a second instance of a static token manager.
*/
static final int STATIC_LEXER_ERROR = 1;
public static final int STATIC_LEXER_ERROR = 1;
/**
* Tried to change to an invalid lexical state.
*/
static final int INVALID_LEXICAL_STATE = 2;
public static final int INVALID_LEXICAL_STATE = 2;
/**
* Detected (and bailed out of) an infinite loop in the token manager.
*/
static final int LOOP_DETECTED = 3;
public static final int LOOP_DETECTED = 3;
/**
* Indicates the reason why the exception is thrown. It will have
@ -53,8 +53,6 @@ public class TokenMgrError extends Error
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
@ -104,11 +102,12 @@ public class TokenMgrError extends Error
* curchar : the offending character
* Note: You can customize the lexical error message by modifying this method.
*/
protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
protected static String LexicalErr(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar) {
char curChar1 = (char)curChar;
return("Lexical error at line " +
errorLine + ", column " +
errorColumn + ". Encountered: " +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar1)) + "\"") + " (" + curChar + "), ") +
"after : \"" + addEscapes(errorAfter) + "\"");
}
@ -121,6 +120,7 @@ public class TokenMgrError extends Error
*
* from this method for such cases in the release version of your parser.
*/
@Override
public String getMessage() {
return super.getMessage();
}
@ -140,8 +140,8 @@ public class TokenMgrError extends Error
}
/** Full Constructor. */
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) {
this(LexicalErr(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
/* (filtered)*/