diff --git a/build.gradle b/build.gradle index 25a61854cf5..c677384e1d8 100644 --- a/build.gradle +++ b/build.gradle @@ -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", diff --git a/gradle/generation/javacc.gradle b/gradle/generation/javacc.gradle index 8261da3b4c1..90eed8de0cf 100644 --- a/gradle/generation/javacc.gradle +++ b/gradle/generation/javacc.gradle @@ -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 diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 6ced13f93b9..b18091da166 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -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 diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/CharStream.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/CharStream.java index 9dc2c377b69..81567ff98cf 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/CharStream.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/CharStream.java @@ -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)*/ diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/FastCharStream.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/FastCharStream.java index 9439bc08ba1..e01b90a60ea 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/FastCharStream.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/FastCharStream.java @@ -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."); + } } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java index d367eb7b309..54a2d35b599 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java @@ -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; diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java index dcdfa6e8de0..f7da7e01889 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java @@ -1,3 +1,4 @@ +/* QueryParser.java */ /* Generated By:JavaCC: Do not edit this line. QueryParser.java */ package org.apache.lucene.queryparser.classic; @@ -148,84 +149,88 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants // * Query ::= ( Clause )* // * Clause ::= ["+", "-"] [ ":"] ( | "(" Query ")" ) - final public int Conjunction() throws ParseException { - int ret = CONJ_NONE; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + final public +int Conjunction() throws ParseException {int ret = CONJ_NONE; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case AND: - case OR: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case AND: + case OR:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case AND:{ jj_consume_token(AND); - ret = CONJ_AND; +ret = CONJ_AND; break; - case OR: + } + case OR:{ jj_consume_token(OR); - ret = CONJ_OR; +ret = CONJ_OR; break; + } default: jj_la1[0] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; + } default: jj_la1[1] = jj_gen; ; } - {if (true) return ret;} +{if ("" != null) return ret;} throw new Error("Missing return statement in function"); - } +} - final public int Modifiers() throws ParseException { - int ret = MOD_NONE; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + final public int Modifiers() throws ParseException {int ret = MOD_NONE; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case NOT: case PLUS: - case MINUS: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS: + case MINUS:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case PLUS:{ jj_consume_token(PLUS); - ret = MOD_REQ; +ret = MOD_REQ; break; - case MINUS: + } + case MINUS:{ jj_consume_token(MINUS); - ret = MOD_NOT; +ret = MOD_NOT; break; - case NOT: + } + case NOT:{ jj_consume_token(NOT); - ret = MOD_NOT; +ret = MOD_NOT; break; + } default: jj_la1[2] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; + } default: jj_la1[3] = jj_gen; ; } - {if (true) return ret;} +{if ("" != null) return ret;} throw new Error("Missing return statement in function"); - } +} // This makes sure that there is no garbage after the query string - final public Query TopLevelQuery(String field) throws ParseException { - Query q; + final public Query TopLevelQuery(String field) throws ParseException {Query q; q = Query(field); jj_consume_token(0); - {if (true) return q;} +{if ("" != null) return q;} throw new Error("Missing return statement in function"); - } +} - final public Query Query(String field) throws ParseException { - List clauses = new ArrayList(); + final public Query Query(String field) throws ParseException {List clauses = new ArrayList(); Query q, firstQuery=null; int conj, mods; if (jj_2_1(2)) { firstQuery = MultiTerm(field, clauses); } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case NOT: case PLUS: case MINUS: @@ -239,14 +244,15 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants case REGEXPTERM: case RANGEIN_START: case RANGEEX_START: - case NUMBER: + case NUMBER:{ mods = Modifiers(); q = Clause(field); - addClause(clauses, CONJ_NONE, mods, q); +addClause(clauses, CONJ_NONE, mods, q); if (mods == MOD_NONE) { firstQuery = q; } break; + } default: jj_la1[4] = jj_gen; jj_consume_token(-1); @@ -255,7 +261,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants } label_1: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case AND: case OR: case NOT: @@ -271,9 +277,10 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants case REGEXPTERM: case RANGEIN_START: case RANGEEX_START: - case NUMBER: + case NUMBER:{ ; break; + } default: jj_la1[5] = jj_gen; break label_1; @@ -281,7 +288,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants if (jj_2_2(2)) { MultiTerm(field, clauses); } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case AND: case OR: case NOT: @@ -297,12 +304,13 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants case REGEXPTERM: case RANGEIN_START: case RANGEEX_START: - case NUMBER: + case NUMBER:{ conj = Conjunction(); mods = Modifiers(); q = Clause(field); - addClause(clauses, conj, mods, q); +addClause(clauses, conj, mods, q); break; + } default: jj_la1[6] = jj_gen; jj_consume_token(-1); @@ -310,29 +318,30 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants } } } - if (clauses.size() == 1 && firstQuery != null) { - {if (true) return firstQuery;} +if (clauses.size() == 1 && firstQuery != null) { + {if ("" != null) return firstQuery;} } else { - {if (true) return getBooleanQuery(clauses);} + {if ("" != null) return getBooleanQuery(clauses);} } throw new Error("Missing return statement in function"); - } +} - final public Query Clause(String field) throws ParseException { - Query q; + final public Query Clause(String field) throws ParseException {Query q; Token fieldToken=null, boost=null; if (jj_2_3(2)) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case TERM: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case TERM:{ fieldToken = jj_consume_token(TERM); jj_consume_token(COLON); - field=discardEscapeChar(fieldToken.image); +field=discardEscapeChar(fieldToken.image); break; - case STAR: + } + case STAR:{ jj_consume_token(STAR); jj_consume_token(COLON); - field="*"; +field="*"; break; + } default: jj_la1[7] = jj_gen; jj_consume_token(-1); @@ -341,7 +350,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants } else { ; } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case BAREOPER: case STAR: case QUOTED: @@ -351,34 +360,36 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants case REGEXPTERM: case RANGEIN_START: case RANGEEX_START: - case NUMBER: + case NUMBER:{ q = Term(field); break; - case LPAREN: + } + case LPAREN:{ jj_consume_token(LPAREN); q = Query(field); jj_consume_token(RPAREN); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); break; + } default: jj_la1[8] = jj_gen; ; } break; + } default: jj_la1[9] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - {if (true) return handleBoost(q, boost);} +{if ("" != null) return handleBoost(q, boost);} throw new Error("Missing return statement in function"); - } +} - final public Query Term(String field) throws ParseException { - Token term, boost=null, fuzzySlop=null, goop1, goop2; + final public Query Term(String field) throws ParseException {Token term, boost=null, fuzzySlop=null, goop1, goop2; boolean prefix = false; boolean wildcard = false; boolean fuzzy = false; @@ -386,157 +397,181 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants boolean startInc=false; boolean endInc=false; Query q; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case BAREOPER: case STAR: case TERM: case PREFIXTERM: case WILDTERM: case REGEXPTERM: - case NUMBER: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case TERM: + case NUMBER:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case TERM:{ term = jj_consume_token(TERM); break; - case STAR: + } + case STAR:{ term = jj_consume_token(STAR); - wildcard=true; +wildcard=true; break; - case PREFIXTERM: + } + case PREFIXTERM:{ term = jj_consume_token(PREFIXTERM); - prefix=true; +prefix=true; break; - case WILDTERM: + } + case WILDTERM:{ term = jj_consume_token(WILDTERM); - wildcard=true; +wildcard=true; break; - case REGEXPTERM: + } + case REGEXPTERM:{ term = jj_consume_token(REGEXPTERM); - regexp=true; +regexp=true; break; - case NUMBER: + } + case NUMBER:{ term = jj_consume_token(NUMBER); break; - case BAREOPER: + } + case BAREOPER:{ term = jj_consume_token(BAREOPER); - term.image = term.image.substring(0,1); +term.image = term.image.substring(0,1); break; + } default: jj_la1[10] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case CARAT: - case FUZZY_SLOP: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: + case FUZZY_SLOP:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case FUZZY_SLOP: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case FUZZY_SLOP:{ fuzzySlop = jj_consume_token(FUZZY_SLOP); - fuzzy=true; +fuzzy=true; break; + } default: jj_la1[11] = jj_gen; ; } break; - case FUZZY_SLOP: + } + case FUZZY_SLOP:{ fuzzySlop = jj_consume_token(FUZZY_SLOP); - fuzzy=true; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: +fuzzy=true; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); break; + } default: jj_la1[12] = jj_gen; ; } break; + } default: jj_la1[13] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; + } default: jj_la1[14] = jj_gen; ; } - q = handleBareTokenQuery(field, term, fuzzySlop, prefix, wildcard, fuzzy, regexp); +q = handleBareTokenQuery(field, term, fuzzySlop, prefix, wildcard, fuzzy, regexp); break; + } case RANGEIN_START: - case RANGEEX_START: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case RANGEIN_START: + case RANGEEX_START:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case RANGEIN_START:{ jj_consume_token(RANGEIN_START); - startInc = true; +startInc = true; break; - case RANGEEX_START: + } + case RANGEEX_START:{ jj_consume_token(RANGEEX_START); break; + } default: jj_la1[15] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case RANGE_GOOP: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case RANGE_GOOP:{ goop1 = jj_consume_token(RANGE_GOOP); break; - case RANGE_QUOTED: + } + case RANGE_QUOTED:{ goop1 = jj_consume_token(RANGE_QUOTED); break; - case RANGE_TO: + } + case RANGE_TO:{ goop1 = jj_consume_token(RANGE_TO); break; + } default: jj_la1[16] = jj_gen; jj_consume_token(-1); throw new ParseException(); } jj_consume_token(RANGE_TO); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case RANGE_GOOP: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case RANGE_GOOP:{ goop2 = jj_consume_token(RANGE_GOOP); break; - case RANGE_QUOTED: + } + case RANGE_QUOTED:{ goop2 = jj_consume_token(RANGE_QUOTED); break; - case RANGE_TO: + } + case RANGE_TO:{ goop2 = jj_consume_token(RANGE_TO); break; + } default: jj_la1[17] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case RANGEIN_END: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case RANGEIN_END:{ jj_consume_token(RANGEIN_END); - endInc = true; +endInc = true; break; - case RANGEEX_END: + } + case RANGEEX_END:{ jj_consume_token(RANGEEX_END); break; + } default: jj_la1[18] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); break; + } default: jj_la1[19] = jj_gen; ; } - boolean startOpen=false; +boolean startOpen=false; boolean endOpen=false; if (goop1.kind == RANGE_QUOTED) { goop1.image = goop1.image.substring(1, goop1.image.length()-1); @@ -550,65 +585,71 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants } q = getRangeQuery(field, startOpen ? null : discardEscapeChar(goop1.image), endOpen ? null : discardEscapeChar(goop2.image), startInc, endInc); break; - case QUOTED: + } + case QUOTED:{ term = jj_consume_token(QUOTED); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case CARAT: - case FUZZY_SLOP: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: + case FUZZY_SLOP:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case FUZZY_SLOP: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case FUZZY_SLOP:{ fuzzySlop = jj_consume_token(FUZZY_SLOP); - fuzzy=true; +fuzzy=true; break; + } default: jj_la1[20] = jj_gen; ; } break; - case FUZZY_SLOP: + } + case FUZZY_SLOP:{ fuzzySlop = jj_consume_token(FUZZY_SLOP); - fuzzy=true; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: +fuzzy=true; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); break; + } default: jj_la1[21] = jj_gen; ; } break; + } default: jj_la1[22] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; + } default: jj_la1[23] = jj_gen; ; } - q = handleQuotedTerm(field, term, fuzzySlop); +q = handleQuotedTerm(field, term, fuzzySlop); break; + } default: jj_la1[24] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - {if (true) return handleBoost(q, boost);} +{if ("" != null) return handleBoost(q, boost);} throw new Error("Missing return statement in function"); - } +} /** Returns the first query if splitOnWhitespace=true or otherwise the entire produced query */ - final public Query MultiTerm(String field, List clauses) throws ParseException { - Token text, whitespace, followingText; + final public Query MultiTerm(String field, List clauses) throws ParseException {Token text, whitespace, followingText; Query firstQuery = null; text = jj_consume_token(TERM); - if (splitOnWhitespace) { +if (splitOnWhitespace) { firstQuery = getFieldQuery(field, discardEscapeChar(text.image), false); addClause(clauses, CONJ_NONE, MOD_NONE, firstQuery); } @@ -621,7 +662,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants label_2: while (true) { followingText = jj_consume_token(TERM); - if (splitOnWhitespace) { +if (splitOnWhitespace) { Query q = getFieldQuery(field, discardEscapeChar(followingText.image), false); addClause(clauses, CONJ_NONE, MOD_NONE, q); } else { // build up the text to send to analysis @@ -633,36 +674,40 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants break label_2; } } - if (splitOnWhitespace == false) { +if (splitOnWhitespace == false) { firstQuery = getFieldQuery(field, discardEscapeChar(text.image), false); addMultiTermClauses(clauses, firstQuery); } - {if (true) return firstQuery;} + {if ("" != null) return firstQuery;} throw new Error("Missing return statement in function"); - } +} - 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_2_2(int xla) { + private boolean jj_2_2(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_2(); } + try { return (!jj_3_2()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(1, xla); } } - private boolean jj_2_3(int xla) { + private boolean jj_2_3(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_3(); } + try { return (!jj_3_3()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(2, xla); } } - private boolean jj_3R_3() { + private boolean jj_3R_3() + { if (jj_scan_token(TERM)) return true; jj_lookingAhead = true; jj_semLA = getToken(1).kind == TERM && allowedPostMultiTerm(getToken(2).kind); @@ -677,38 +722,45 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants return false; } - private boolean jj_3R_6() { + private boolean jj_3R_6() + { return false; } - private boolean jj_3R_5() { + private boolean jj_3R_5() + { if (jj_scan_token(STAR)) return true; if (jj_scan_token(COLON)) return true; return false; } - private boolean jj_3R_4() { + private boolean jj_3R_4() + { if (jj_scan_token(TERM)) return true; if (jj_scan_token(COLON)) return true; return false; } - private boolean jj_3_2() { + private boolean jj_3_2() + { if (jj_3R_3()) return true; return false; } - private boolean jj_3_1() { + private boolean jj_3_1() + { if (jj_3R_3()) return true; return false; } - private boolean jj_3R_7() { + private boolean jj_3R_7() + { if (jj_scan_token(TERM)) return true; return false; } - private boolean jj_3_3() { + private boolean jj_3_3() + { Token xsp; xsp = jj_scanpos; if (jj_3R_4()) { @@ -735,132 +787,133 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants static private int[] jj_la1_0; static private int[] jj_la1_1; static { - jj_la1_init_0(); - jj_la1_init_1(); - } - private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0x300,0x300,0x1c00,0x1c00,0xfda7c00,0xfda7f00,0xfda7f00,0x120000,0x40000,0xfda6000,0x9d22000,0x200000,0x40000,0x240000,0x240000,0x6000000,0x90000000,0x90000000,0x60000000,0x40000,0x200000,0x40000,0x240000,0x240000,0xfda2000,}; - } - private static void jj_la1_init_1() { - jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; - } + jj_la1_init_0(); + jj_la1_init_1(); + } + private static void jj_la1_init_0() { + jj_la1_0 = new int[] {0x300,0x300,0x1c00,0x1c00,0xfda7c00,0xfda7f00,0xfda7f00,0x120000,0x40000,0xfda6000,0x9d22000,0x200000,0x40000,0x240000,0x240000,0x6000000,0x90000000,0x90000000,0x60000000,0x40000,0x200000,0x40000,0x240000,0x240000,0xfda2000,}; + } + private static void jj_la1_init_1() { + jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; + } final private JJCalls[] jj_2_rtns = new JJCalls[3]; private boolean jj_rescan = false; private int jj_gc = 0; /** Constructor with user supplied CharStream. */ protected QueryParser(CharStream stream) { - token_source = new QueryParserTokenManager(stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 25; 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 < 25; 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_lookingAhead = false; - jj_gen = 0; - for (int i = 0; i < 25; 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_lookingAhead = false; + jj_gen = 0; + for (int i = 0; i < 25; 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. */ protected QueryParser(QueryParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 25; 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 < 25; 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 < 25; 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 < 25; 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 = jj_lookingAhead ? jj_scanpos : 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 = jj_lookingAhead ? jj_scanpos : 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 jj_expentries = new java.util.ArrayList<>(); @@ -870,65 +923,86 @@ public class QueryParser extends QueryParserBase 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[33]; - if (jj_kind >= 0) { - la1tokens[jj_kind] = true; - jj_kind = -1; - } - for (int i = 0; i < 25; i++) { - if (jj_la1[i] == jj_gen) { - for (int j = 0; j < 32; j++) { - if ((jj_la1_0[i] & (1<= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 25; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1< jj_gen) { - jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; - switch (i) { - case 0: jj_3_1(); break; - case 1: jj_3_2(); break; - case 2: jj_3_3(); break; - } - } - p = p.next; - } while (p != null); - } catch(LookaheadSuccess ls) { } - } - jj_rescan = false; + jj_rescan = true; + for (int i = 0; i < 3; 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; + case 1: jj_3_2(); break; + case 2: jj_3_3(); 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; } } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java index e62a14f8243..db84cc7d006 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java @@ -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; } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/Token.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/Token.java index e394a8126ec..1b9ccd8538e 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/Token.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/Token.java @@ -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; diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/TokenMgrError.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/TokenMgrError.java index 71d134fabbd..4f07f361b9e 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/TokenMgrError.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/TokenMgrError.java @@ -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 ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + + (EOFSeen ? " " : ("\"" + 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)*/ diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/CharStream.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/CharStream.java index 440db59bc5f..575be8e49aa 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/CharStream.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/CharStream.java @@ -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)*/ diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/FastCharStream.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/FastCharStream.java index df273561a91..7b206fc1155 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/FastCharStream.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/FastCharStream.java @@ -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."); + } } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java index cc0f70e8c8d..a782e8b234a 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java @@ -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; diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java index 57d72315970..66500fac40d 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java @@ -1,3 +1,4 @@ +/* StandardSyntaxParser.java */ /* Generated By:JavaCC: Do not edit this line. StandardSyntaxParser.java */ package org.apache.lucene.queryparser.flexible.standard.parser; @@ -75,47 +76,49 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC } } - final public ModifierQueryNode.Modifier Modifiers() throws ParseException { - ModifierQueryNode.Modifier ret = ModifierQueryNode.Modifier.MOD_NONE; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + final public ModifierQueryNode.Modifier Modifiers() throws ParseException {ModifierQueryNode.Modifier ret = ModifierQueryNode.Modifier.MOD_NONE; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case NOT: case PLUS: - case MINUS: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS: + case MINUS:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case PLUS:{ jj_consume_token(PLUS); - ret = ModifierQueryNode.Modifier.MOD_REQ; +ret = ModifierQueryNode.Modifier.MOD_REQ; break; - case MINUS: + } + case MINUS:{ jj_consume_token(MINUS); - ret = ModifierQueryNode.Modifier.MOD_NOT; +ret = ModifierQueryNode.Modifier.MOD_NOT; break; - case NOT: + } + case NOT:{ jj_consume_token(NOT); - ret = ModifierQueryNode.Modifier.MOD_NOT; +ret = ModifierQueryNode.Modifier.MOD_NOT; break; + } default: jj_la1[0] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; + } default: jj_la1[1] = jj_gen; ; } - {if (true) return ret;} +{if ("" != null) return ret;} throw new Error("Missing return statement in function"); - } +} // This makes sure that there is no garbage after the query string - final public QueryNode TopLevelQuery(CharSequence field) throws ParseException { - QueryNode q; + final public QueryNode TopLevelQuery(CharSequence field) throws ParseException {QueryNode q; q = Query(field); jj_consume_token(0); - {if (true) return q;} +{if ("" != null) return q;} throw new Error("Missing return statement in function"); - } +} // These changes were made to introduce operator precedence: // - Clause() now returns a QueryNode. @@ -127,13 +130,14 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC // DisjQuery ::= ConjQuery ( OR ConjQuery )* // ConjQuery ::= Clause ( AND Clause )* // Clause ::= [ Modifier ] ... - final public QueryNode Query(CharSequence field) throws ParseException { - Vector clauses = null; + final public + +QueryNode Query(CharSequence field) throws ParseException {Vector clauses = null; QueryNode c, first=null; first = DisjQuery(field); label_1: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case NOT: case PLUS: case MINUS: @@ -143,22 +147,23 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC case REGEXPTERM: case RANGEIN_START: case RANGEEX_START: - case NUMBER: + case NUMBER:{ ; break; + } default: jj_la1[2] = jj_gen; break label_1; } c = DisjQuery(field); - if (clauses == null) { +if (clauses == null) { clauses = new Vector(); clauses.addElement(first); } clauses.addElement(c); } - if (clauses != null) { - {if (true) return new BooleanQueryNode(clauses);} +if (clauses != null) { + {if ("" != null) return new BooleanQueryNode(clauses);} } else { // Handle the case of a "pure" negation query which // needs to be wrapped as a boolean query, otherwise @@ -166,73 +171,73 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC if (first instanceof ModifierQueryNode) { ModifierQueryNode m = (ModifierQueryNode) first; if (m.getModifier() == ModifierQueryNode.Modifier.MOD_NOT) { - {if (true) return new BooleanQueryNode(Arrays. asList(m));} + {if ("" != null) return new BooleanQueryNode(Arrays.asList(m));} } } - {if (true) return first;} + {if ("" != null) return first;} } throw new Error("Missing return statement in function"); - } +} - final public QueryNode DisjQuery(CharSequence field) throws ParseException { - QueryNode first, c; + final public QueryNode DisjQuery(CharSequence field) throws ParseException {QueryNode first, c; Vector clauses = null; first = ConjQuery(field); 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[3] = jj_gen; break label_2; } jj_consume_token(OR); c = ConjQuery(field); - if (clauses == null) { +if (clauses == null) { clauses = new Vector(); clauses.addElement(first); } clauses.addElement(c); } - if (clauses != null) { - {if (true) return new OrQueryNode(clauses);} +if (clauses != null) { + {if ("" != null) return new OrQueryNode(clauses);} } else { - {if (true) return first;} + {if ("" != null) return first;} } throw new Error("Missing return statement in function"); - } +} - final public QueryNode ConjQuery(CharSequence field) throws ParseException { - QueryNode first, c; + final public QueryNode ConjQuery(CharSequence field) throws ParseException {QueryNode first, c; Vector clauses = null; first = ModClause(field); 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[4] = jj_gen; break label_3; } jj_consume_token(AND); c = ModClause(field); - if (clauses == null) { +if (clauses == null) { clauses = new Vector(); clauses.addElement(first); } clauses.addElement(c); } - if (clauses != null) { - {if (true) return new AndQueryNode(clauses);} +if (clauses != null) { + {if ("" != null) return new AndQueryNode(clauses);} } else { - {if (true) return first;} + {if ("" != null) return first;} } throw new Error("Missing return statement in function"); - } +} // QueryNode Query(CharSequence field) : // { @@ -272,20 +277,19 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC // } // } // } - final public QueryNode ModClause(CharSequence field) throws ParseException { - QueryNode q; + final public +QueryNode ModClause(CharSequence field) throws ParseException {QueryNode q; ModifierQueryNode.Modifier mods; mods = Modifiers(); q = Clause(field); - if (mods != ModifierQueryNode.Modifier.MOD_NONE) { +if (mods != ModifierQueryNode.Modifier.MOD_NONE) { q = new ModifierQueryNode(q, mods); } - {if (true) return q;} + {if ("" != null) return q;} throw new Error("Missing return statement in function"); - } +} - final public QueryNode Clause(CharSequence field) throws ParseException { - QueryNode q; + final public QueryNode Clause(CharSequence field) throws ParseException {QueryNode q; Token fieldToken=null, boost=null, operator=null, term=null; FieldQueryNode qLower, qUpper; boolean lowerInclusive, upperInclusive; @@ -293,63 +297,73 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC boolean group = false; if (jj_2_2(3)) { fieldToken = jj_consume_token(TERM); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case OP_COLON: - case OP_EQUAL: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case OP_COLON: + case OP_EQUAL:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case OP_COLON:{ jj_consume_token(OP_COLON); break; - case OP_EQUAL: + } + case OP_EQUAL:{ jj_consume_token(OP_EQUAL); break; + } default: jj_la1[5] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - field=EscapeQuerySyntaxImpl.discardEscapeChar(fieldToken.image); +field=EscapeQuerySyntaxImpl.discardEscapeChar(fieldToken.image); q = Term(field); break; + } case OP_LESSTHAN: case OP_LESSTHANEQ: case OP_MORETHAN: - case OP_MORETHANEQ: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case OP_LESSTHAN: + case OP_MORETHANEQ:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case OP_LESSTHAN:{ operator = jj_consume_token(OP_LESSTHAN); break; - case OP_LESSTHANEQ: + } + case OP_LESSTHANEQ:{ operator = jj_consume_token(OP_LESSTHANEQ); break; - case OP_MORETHAN: + } + case OP_MORETHAN:{ operator = jj_consume_token(OP_MORETHAN); break; - case OP_MORETHANEQ: + } + case OP_MORETHANEQ:{ operator = jj_consume_token(OP_MORETHANEQ); break; + } default: jj_la1[6] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - field=EscapeQuerySyntaxImpl.discardEscapeChar(fieldToken.image); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case TERM: +field=EscapeQuerySyntaxImpl.discardEscapeChar(fieldToken.image); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case TERM:{ term = jj_consume_token(TERM); break; - case QUOTED: + } + case QUOTED:{ term = jj_consume_token(QUOTED); break; - case NUMBER: + } + case NUMBER:{ term = jj_consume_token(NUMBER); break; + } default: jj_la1[7] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - if (term.kind == QUOTED) { +if (term.kind == QUOTED) { term.image = term.image.substring(1, term.image.length()-1); } switch (operator.kind) { @@ -395,75 +409,70 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC } q = new TermRangeQueryNode(qLower, qUpper, lowerInclusive, upperInclusive); break; + } default: jj_la1[8] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case LPAREN: + } else if (jj_2_3(3)) { + if (jj_2_1(3)) { + fieldToken = jj_consume_token(TERM); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case OP_COLON:{ + jj_consume_token(OP_COLON); + break; + } + case OP_EQUAL:{ + jj_consume_token(OP_EQUAL); + break; + } + default: + jj_la1[9] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +field=EscapeQuerySyntaxImpl.discardEscapeChar(fieldToken.image); + } else { + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case QUOTED: case TERM: case REGEXPTERM: case RANGEIN_START: case RANGEEX_START: - case NUMBER: - if (jj_2_1(2)) { - fieldToken = jj_consume_token(TERM); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case OP_COLON: - jj_consume_token(OP_COLON); - break; - case OP_EQUAL: - jj_consume_token(OP_EQUAL); - break; - default: - jj_la1[9] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); + case NUMBER:{ + q = Term(field); + break; + } + case LPAREN:{ + jj_consume_token(LPAREN); + q = Query(field); + jj_consume_token(RPAREN); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ + jj_consume_token(CARAT); + boost = jj_consume_token(NUMBER); + break; } - field=EscapeQuerySyntaxImpl.discardEscapeChar(fieldToken.image); - } else { + default: + jj_la1[10] = jj_gen; ; } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case QUOTED: - case TERM: - case REGEXPTERM: - case RANGEIN_START: - case RANGEEX_START: - case NUMBER: - q = Term(field); - break; - case LPAREN: - jj_consume_token(LPAREN); - q = Query(field); - jj_consume_token(RPAREN); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: - jj_consume_token(CARAT); - boost = jj_consume_token(NUMBER); - break; - default: - jj_la1[10] = jj_gen; - ; - } - group=true; - break; - default: - jj_la1[11] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } +group=true; break; + } default: - jj_la1[12] = jj_gen; + jj_la1[11] = jj_gen; jj_consume_token(-1); throw new ParseException(); } + } else { + jj_consume_token(-1); + throw new ParseException(); } - if (boost != null) { +if (boost != null) { float f = (float)1.0; try { f = Float.parseFloat(boost.image); @@ -478,12 +487,11 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC } } if (group) { q = new GroupQueryNode(q);} - {if (true) return q;} + {if ("" != null) return q;} throw new Error("Missing return statement in function"); - } +} - final public QueryNode Term(CharSequence field) throws ParseException { - Token term, boost=null, fuzzySlop=null, goop1, goop2; + final public QueryNode Term(CharSequence field) throws ParseException {Token term, boost=null, fuzzySlop=null, goop1, goop2; boolean fuzzy = false; boolean regexp = false; boolean startInc=false; @@ -491,55 +499,61 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC QueryNode q =null; FieldQueryNode qLower, qUpper; float defaultMinSimilarity = org.apache.lucene.search.FuzzyQuery.defaultMaxEdits; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case TERM: case REGEXPTERM: - case NUMBER: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case TERM: + case NUMBER:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case TERM:{ term = jj_consume_token(TERM); - q = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); +q = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); break; - case REGEXPTERM: + } + case REGEXPTERM:{ term = jj_consume_token(REGEXPTERM); - regexp=true; +regexp=true; break; - case NUMBER: + } + case NUMBER:{ term = jj_consume_token(NUMBER); break; + } default: - jj_la1[13] = jj_gen; + jj_la1[12] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case FUZZY_SLOP: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case FUZZY_SLOP:{ fuzzySlop = jj_consume_token(FUZZY_SLOP); - fuzzy=true; +fuzzy=true; break; + } default: - jj_la1[14] = jj_gen; + jj_la1[13] = jj_gen; ; } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case FUZZY_SLOP: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case FUZZY_SLOP:{ fuzzySlop = jj_consume_token(FUZZY_SLOP); - fuzzy=true; +fuzzy=true; break; + } default: - jj_la1[15] = jj_gen; + jj_la1[14] = jj_gen; ; } break; + } default: - jj_la1[16] = jj_gen; + jj_la1[15] = jj_gen; ; } - if (fuzzy) { +if (fuzzy) { float fms = defaultMinSimilarity; try { fms = Float.parseFloat(fuzzySlop.image.substring(1)); @@ -555,75 +569,87 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC q = new RegexpQueryNode(field, re, 0, re.length()); } break; + } case RANGEIN_START: - case RANGEEX_START: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case RANGEIN_START: + case RANGEEX_START:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case RANGEIN_START:{ jj_consume_token(RANGEIN_START); - startInc=true; +startInc=true; break; - case RANGEEX_START: + } + case RANGEEX_START:{ jj_consume_token(RANGEEX_START); break; + } + default: + jj_la1[16] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case RANGE_GOOP:{ + goop1 = jj_consume_token(RANGE_GOOP); + break; + } + case RANGE_QUOTED:{ + goop1 = jj_consume_token(RANGE_QUOTED); + break; + } + case RANGE_TO:{ + goop1 = jj_consume_token(RANGE_TO); + break; + } default: jj_la1[17] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case RANGE_GOOP: - goop1 = jj_consume_token(RANGE_GOOP); + jj_consume_token(RANGE_TO); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case RANGE_GOOP:{ + goop2 = jj_consume_token(RANGE_GOOP); break; - case RANGE_QUOTED: - goop1 = jj_consume_token(RANGE_QUOTED); + } + case RANGE_QUOTED:{ + goop2 = jj_consume_token(RANGE_QUOTED); break; - case RANGE_TO: - goop1 = jj_consume_token(RANGE_TO); + } + case RANGE_TO:{ + goop2 = jj_consume_token(RANGE_TO); break; + } default: jj_la1[18] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - jj_consume_token(RANGE_TO); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case RANGE_GOOP: - goop2 = jj_consume_token(RANGE_GOOP); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case RANGEIN_END:{ + jj_consume_token(RANGEIN_END); +endInc=true; break; - case RANGE_QUOTED: - goop2 = jj_consume_token(RANGE_QUOTED); - break; - case RANGE_TO: - goop2 = jj_consume_token(RANGE_TO); + } + case RANGEEX_END:{ + jj_consume_token(RANGEEX_END); break; + } default: jj_la1[19] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case RANGEIN_END: - jj_consume_token(RANGEIN_END); - endInc=true; - break; - case RANGEEX_END: - jj_consume_token(RANGEEX_END); - break; - default: - jj_la1[20] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); break; + } default: - jj_la1[21] = jj_gen; + jj_la1[20] = jj_gen; ; } - if (goop1.kind == RANGE_QUOTED) { +if (goop1.kind == RANGE_QUOTED) { goop1.image = goop1.image.substring(1, goop1.image.length()-1); } if (goop2.kind == RANGE_QUOTED) { @@ -636,27 +662,30 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC EscapeQuerySyntaxImpl.discardEscapeChar(goop2.image), goop2.beginColumn, goop2.endColumn); q = new TermRangeQueryNode(qLower, qUpper, startInc ? true : false, endInc ? true : false); break; - case QUOTED: + } + case QUOTED:{ term = jj_consume_token(QUOTED); - q = new QuotedFieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image.substring(1, term.image.length()-1)), term.beginColumn + 1, term.endColumn - 1); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case FUZZY_SLOP: +q = new QuotedFieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image.substring(1, term.image.length()-1)), term.beginColumn + 1, term.endColumn - 1); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case FUZZY_SLOP:{ fuzzySlop = jj_consume_token(FUZZY_SLOP); break; + } + default: + jj_la1[21] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ + jj_consume_token(CARAT); + boost = jj_consume_token(NUMBER); + break; + } default: jj_la1[22] = jj_gen; ; } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: - jj_consume_token(CARAT); - boost = jj_consume_token(NUMBER); - break; - default: - jj_la1[23] = jj_gen; - ; - } - int phraseSlop = 0; +int phraseSlop = 0; if (fuzzySlop != null) { try { @@ -670,12 +699,13 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC } } break; + } default: - jj_la1[24] = jj_gen; + jj_la1[23] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - if (boost != null) { +if (boost != null) { float f = (float)1.0; try { f = Float.parseFloat(boost.image); @@ -689,35 +719,187 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC */ } } - {if (true) return q;} + {if ("" != null) return q;} throw new Error("Missing return statement in function"); - } +} - 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_2_2(int xla) { + private boolean jj_2_2(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_2(); } + try { return (!jj_3_2()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(1, xla); } } - private boolean jj_3R_12() { + private boolean jj_2_3(int xla) + { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return (!jj_3_3()); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(2, xla); } + } + + private boolean jj_3R_26() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3_2()) { + jj_scanpos = xsp; + if (jj_3_3()) return true; + } + return false; + } + + private boolean jj_3R_22() + { + if (jj_scan_token(OR)) return true; + return false; + } + + private boolean jj_3R_13() + { + if (jj_3R_21()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_22()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_17() + { if (jj_scan_token(RANGEIN_START)) return true; return false; } - private boolean jj_3R_11() { + private boolean jj_3R_23() + { + if (jj_3R_25()) return true; + if (jj_3R_26()) return true; + return false; + } + + private boolean jj_3R_11() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_17()) { + jj_scanpos = xsp; + if (jj_scan_token(27)) return true; + } + xsp = jj_scanpos; + if (jj_scan_token(33)) { + jj_scanpos = xsp; + if (jj_scan_token(32)) { + jj_scanpos = xsp; + if (jj_scan_token(29)) return true; + } + } + if (jj_scan_token(RANGE_TO)) return true; + return false; + } + + private boolean jj_3R_30() + { + if (jj_scan_token(NOT)) return true; + return false; + } + + private boolean jj_3R_29() + { + if (jj_scan_token(MINUS)) return true; + return false; + } + + private boolean jj_3R_24() + { + if (jj_scan_token(AND)) return true; + return false; + } + + private boolean jj_3R_7() + { + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_9()) return true; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_28() + { + if (jj_scan_token(PLUS)) return true; + return false; + } + + private boolean jj_3R_27() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_28()) { + jj_scanpos = xsp; + if (jj_3R_29()) { + jj_scanpos = xsp; + if (jj_3R_30()) return true; + } + } + return false; + } + + private boolean jj_3R_21() + { + if (jj_3R_23()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_24()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_19() + { + if (jj_scan_token(CARAT)) return true; + if (jj_scan_token(NUMBER)) return true; + return false; + } + + private boolean jj_3R_6() + { + if (jj_3R_8()) return true; + return false; + } + + private boolean jj_3R_18() + { + if (jj_scan_token(FUZZY_SLOP)) return true; + return false; + } + + private boolean jj_3R_25() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_27()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_16() + { if (jj_scan_token(REGEXPTERM)) return true; return false; } - private boolean jj_3_1() { + private boolean jj_3_1() + { if (jj_scan_token(TERM)) return true; Token xsp; xsp = jj_scanpos; @@ -728,40 +910,40 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC return false; } - private boolean jj_3R_8() { + private boolean jj_3R_20() + { + if (jj_scan_token(CARAT)) return true; + if (jj_scan_token(NUMBER)) return true; + return false; + } + + private boolean jj_3_3() + { Token xsp; xsp = jj_scanpos; - if (jj_3R_12()) { + if (jj_3_1()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_6()) { jj_scanpos = xsp; - if (jj_scan_token(27)) return true; + if (jj_3R_7()) return true; } return false; } - private boolean jj_3R_10() { + private boolean jj_3R_15() + { if (jj_scan_token(TERM)) return true; return false; } - private boolean jj_3R_7() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_10()) { - jj_scanpos = xsp; - if (jj_3R_11()) { - jj_scanpos = xsp; - if (jj_scan_token(28)) return true; - } - } + private boolean jj_3R_14() + { + if (jj_3R_13()) return true; return false; } - private boolean jj_3R_9() { - if (jj_scan_token(QUOTED)) return true; - return false; - } - - private boolean jj_3R_5() { + private boolean jj_3R_5() + { Token xsp; xsp = jj_scanpos; if (jj_scan_token(17)) { @@ -785,31 +967,60 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC return false; } - private boolean jj_3R_4() { + private boolean jj_3R_4() + { Token xsp; xsp = jj_scanpos; if (jj_scan_token(15)) { jj_scanpos = xsp; if (jj_scan_token(16)) return true; } - if (jj_3R_6()) return true; + if (jj_3R_8()) return true; return false; } - private boolean jj_3R_6() { + private boolean jj_3R_10() + { Token xsp; xsp = jj_scanpos; - if (jj_3R_7()) { + if (jj_3R_15()) { jj_scanpos = xsp; - if (jj_3R_8()) { + if (jj_3R_16()) { jj_scanpos = xsp; - if (jj_3R_9()) return true; + if (jj_scan_token(28)) return true; } } + xsp = jj_scanpos; + if (jj_3R_18()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_19()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_12() + { + if (jj_scan_token(QUOTED)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(24)) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_20()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_9() + { + if (jj_3R_13()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_14()) { jj_scanpos = xsp; break; } + } return false; } - private boolean jj_3_2() { + private boolean jj_3_2() + { if (jj_scan_token(TERM)) return true; Token xsp; xsp = jj_scanpos; @@ -820,6 +1031,20 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC return false; } + private boolean jj_3R_8() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_10()) { + jj_scanpos = xsp; + if (jj_3R_11()) { + jj_scanpos = xsp; + if (jj_3R_12()) return true; + } + } + return false; + } + /** Generated Token Manager. */ public StandardSyntaxParserTokenManager token_source; /** Current token. */ @@ -830,135 +1055,136 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC private Token jj_scanpos, jj_lastpos; private int jj_la; private int jj_gen; - final private int[] jj_la1 = new int[25]; + final private int[] jj_la1 = new int[24]; static private int[] jj_la1_0; static private int[] jj_la1_1; static { - jj_la1_init_0(); - jj_la1_init_1(); - } - private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0x1c00,0x1c00,0x1ec03c00,0x200,0x100,0x18000,0x1e0000,0x10c00000,0x1f8000,0x18000,0x200000,0x1ec02000,0x1ec02000,0x12800000,0x1000000,0x1000000,0x200000,0xc000000,0x20000000,0x20000000,0xc0000000,0x200000,0x1000000,0x200000,0x1ec00000,}; - } - private static void jj_la1_init_1() { - jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x3,0x0,0x0,0x0,0x0,0x0,}; - } - final private JJCalls[] jj_2_rtns = new JJCalls[2]; + jj_la1_init_0(); + jj_la1_init_1(); + } + private static void jj_la1_init_0() { + jj_la1_0 = new int[] {0x1c00,0x1c00,0x1ec03c00,0x200,0x100,0x18000,0x1e0000,0x10c00000,0x1f8000,0x18000,0x200000,0x1ec02000,0x12800000,0x1000000,0x1000000,0x200000,0xc000000,0x20000000,0x20000000,0xc0000000,0x200000,0x1000000,0x200000,0x1ec00000,}; + } + private static void jj_la1_init_1() { + jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x3,0x0,0x0,0x0,0x0,0x0,}; + } + final private JJCalls[] jj_2_rtns = new JJCalls[3]; private boolean jj_rescan = false; private int jj_gc = 0; /** Constructor with user supplied CharStream. */ public StandardSyntaxParser(CharStream stream) { - token_source = new StandardSyntaxParserTokenManager(stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 25; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + token_source = new StandardSyntaxParserTokenManager(stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 24; 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 < 25; 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 < 24; 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 StandardSyntaxParser(StandardSyntaxParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 25; 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 < 24; 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(StandardSyntaxParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 25; 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 < 24; 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 jj_expentries = new java.util.ArrayList<>(); @@ -968,65 +1194,86 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC 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[34]; - if (jj_kind >= 0) { - la1tokens[jj_kind] = true; - jj_kind = -1; - } - for (int i = 0; i < 25; i++) { - if (jj_la1[i] == jj_gen) { - for (int j = 0; j < 32; j++) { - if ((jj_la1_0[i] & (1<= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 24; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1< jj_gen) { - jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; - switch (i) { - case 0: jj_3_1(); break; - case 1: jj_3_2(); break; - } - } - p = p.next; - } while (p != null); - } catch(LookaheadSuccess ls) { } - } - jj_rescan = false; + jj_rescan = true; + for (int i = 0; i < 3; 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; + case 1: jj_3_2(); break; + case 2: jj_3_3(); 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; } } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj index 0a60490b695..69d10847a79 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj @@ -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. asList(m)); + return new BooleanQueryNode(Arrays.asList(m)); } } return first; @@ -325,8 +325,7 @@ QueryNode Clause(CharSequence field) : { } { ( - LOOKAHEAD(3) - fieldToken= ( + LOOKAHEAD(3) fieldToken= ( ( | ) {field=EscapeQuerySyntaxImpl.discardEscapeChar(fieldToken.image);} q=Term(field) | ( operator= | operator= | operator= | operator= ) {field=EscapeQuerySyntaxImpl.discardEscapeChar(fieldToken.image);}( term= | term= | term= ) { @@ -377,14 +376,14 @@ QueryNode Clause(CharSequence field) : { q = new TermRangeQueryNode(qLower, qUpper, lowerInclusive, upperInclusive); } ) -| [ - LOOKAHEAD(2) + | LOOKAHEAD(3) [ + LOOKAHEAD(3) fieldToken= ( | ) {field=EscapeQuerySyntaxImpl.discardEscapeChar(fieldToken.image);} ] ( - q=Term(field) - | q=Query(field) ( boost=)? {group=true;} + (q=Term(field)) + | ( q=Query(field) ( boost=)? {group=true;}) ) ) { diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java index 9507a38ca7a..bbfa11f0e01 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java @@ -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; } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java index 9c49b3d3051..55c47b3ba03 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java @@ -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; diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java index 96d95ed8cb4..5109a03269d 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java @@ -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 ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + + (EOFSeen ? " " : ("\"" + 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)*/ diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/CharStream.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/CharStream.java index 836d80893cd..4481de6c663 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/CharStream.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/CharStream.java @@ -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)*/ diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/FastCharStream.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/FastCharStream.java index ddd2b738872..c49548b04a2 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/FastCharStream.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/FastCharStream.java @@ -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."); + } } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java index 6a61aa3fcec..731cc92bf84 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java @@ -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; diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java index 4e067f364f2..34397d215b8 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java @@ -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 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 OptionalFields() throws ParseException { - Token fieldName; + final public ArrayList OptionalFields() throws ParseException {Token fieldName; ArrayList 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(); } 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 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(); 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 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(); 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 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(); 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 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(); +queries = new ArrayList(); 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 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(); +queries = new ArrayList(); 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 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 FieldsQueryList() throws ParseException { - SrndQuery q; + final public List FieldsQueryList() throws ParseException {SrndQuery q; ArrayList queries = new ArrayList(); 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 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<= 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< 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; } } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java index 16a351642cb..0f0d30c13ac 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java @@ -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; } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/Token.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/Token.java index 22915999b1c..f92493822a5 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/Token.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/Token.java @@ -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; diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java index 1b197c1c69b..80f818849a4 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java @@ -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 ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + + (EOFSeen ? " " : ("\"" + 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)*/ diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java index 717a01368eb..1f9fd91e956 100644 --- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java +++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java @@ -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 { diff --git a/solr/core/src/java/org/apache/solr/parser/CharStream.java b/solr/core/src/java/org/apache/solr/parser/CharStream.java index 38e1d4a24d2..2e295cf2443 100644 --- a/solr/core/src/java/org/apache/solr/parser/CharStream.java +++ b/solr/core/src/java/org/apache/solr/parser/CharStream.java @@ -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)*/ diff --git a/solr/core/src/java/org/apache/solr/parser/FastCharStream.java b/solr/core/src/java/org/apache/solr/parser/FastCharStream.java index 9bb4a03882b..19ecade0284 100644 --- a/solr/core/src/java/org/apache/solr/parser/FastCharStream.java +++ b/solr/core/src/java/org/apache/solr/parser/FastCharStream.java @@ -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."); + } } diff --git a/solr/core/src/java/org/apache/solr/parser/ParseException.java b/solr/core/src/java/org/apache/solr/parser/ParseException.java index 5148210089e..e36fdba2876 100644 --- a/solr/core/src/java/org/apache/solr/parser/ParseException.java +++ b/solr/core/src/java/org/apache/solr/parser/ParseException.java @@ -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; diff --git a/solr/core/src/java/org/apache/solr/parser/QueryParser.java b/solr/core/src/java/org/apache/solr/parser/QueryParser.java index f2b792e46b0..4293879da94 100644 --- a/solr/core/src/java/org/apache/solr/parser/QueryParser.java +++ b/solr/core/src/java/org/apache/solr/parser/QueryParser.java @@ -1,3 +1,4 @@ +/* QueryParser.java */ /* Generated By:JavaCC: Do not edit this line. QueryParser.java */ package org.apache.solr.parser; @@ -66,84 +67,88 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst // * Query ::= ( Clause )* // * Clause ::= ["+", "-"] [ ":"] ( | "(" Query ")" ) - final public int Conjunction() throws ParseException { - int ret = CONJ_NONE; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + final public +int Conjunction() throws ParseException {int ret = CONJ_NONE; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case AND: - case OR: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case AND: + case OR:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case AND:{ jj_consume_token(AND); - ret = CONJ_AND; +ret = CONJ_AND; break; - case OR: + } + case OR:{ jj_consume_token(OR); - ret = CONJ_OR; +ret = CONJ_OR; break; + } default: jj_la1[0] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; + } default: jj_la1[1] = jj_gen; ; } - {if (true) return ret;} +{if ("" != null) return ret;} throw new Error("Missing return statement in function"); - } +} - final public int Modifiers() throws ParseException { - int ret = MOD_NONE; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + final public int Modifiers() throws ParseException {int ret = MOD_NONE; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case NOT: case PLUS: - case MINUS: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS: + case MINUS:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case PLUS:{ jj_consume_token(PLUS); - ret = MOD_REQ; +ret = MOD_REQ; break; - case MINUS: + } + case MINUS:{ jj_consume_token(MINUS); - ret = MOD_NOT; +ret = MOD_NOT; break; - case NOT: + } + case NOT:{ jj_consume_token(NOT); - ret = MOD_NOT; +ret = MOD_NOT; break; + } default: jj_la1[2] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; + } default: jj_la1[3] = jj_gen; ; } - {if (true) return ret;} +{if ("" != null) return ret;} throw new Error("Missing return statement in function"); - } +} // This makes sure that there is no garbage after the query string - final public Query TopLevelQuery(String field) throws ParseException, SyntaxError { - Query q; + final public Query TopLevelQuery(String field) throws ParseException, SyntaxError {Query q; q = Query(field); jj_consume_token(0); - {if (true) return q;} +{if ("" != null) return q;} throw new Error("Missing return statement in function"); - } +} - final public Query Query(String field) throws ParseException, SyntaxError { - List clauses = new ArrayList(); + final public Query Query(String field) throws ParseException, SyntaxError {List clauses = new ArrayList(); Query q; int conj, mods; if (jj_2_1(2)) { MultiTerm(field, clauses); } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case NOT: case PLUS: case MINUS: @@ -159,11 +164,12 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst case RANGEEX_START: case LPARAMS: case FILTER: - case NUMBER: + case NUMBER:{ mods = Modifiers(); q = Clause(field); - addClause(clauses, CONJ_NONE, mods, q); +addClause(clauses, CONJ_NONE, mods, q); break; + } default: jj_la1[4] = jj_gen; jj_consume_token(-1); @@ -172,7 +178,7 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst } label_1: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case AND: case OR: case NOT: @@ -190,9 +196,10 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst case RANGEEX_START: case LPARAMS: case FILTER: - case NUMBER: + case NUMBER:{ ; break; + } default: jj_la1[5] = jj_gen; break label_1; @@ -200,7 +207,7 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst if (jj_2_2(2)) { MultiTerm(field, clauses); } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case AND: case OR: case NOT: @@ -218,12 +225,13 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst case RANGEEX_START: case LPARAMS: case FILTER: - case NUMBER: + case NUMBER:{ conj = Conjunction(); mods = Modifiers(); q = Clause(field); - addClause(clauses, conj, mods, q); +addClause(clauses, conj, mods, q); break; + } default: jj_la1[6] = jj_gen; jj_consume_token(-1); @@ -231,33 +239,34 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst } } } - if (clauses.size() == 1 && clauses.get(0).getOccur() == BooleanClause.Occur.SHOULD) { +if (clauses.size() == 1 && clauses.get(0).getOccur() == BooleanClause.Occur.SHOULD) { Query firstQuery = clauses.get(0).getQuery(); if ( ! (firstQuery instanceof RawQuery) || ((RawQuery)firstQuery).getTermCount() == 1) { - {if (true) return rawToNormal(firstQuery);} + {if ("" != null) return rawToNormal(firstQuery);} } } - {if (true) return getBooleanQuery(clauses);} + {if ("" != null) return getBooleanQuery(clauses);} throw new Error("Missing return statement in function"); - } +} - final public Query Clause(String field) throws ParseException, SyntaxError { - Query q; + final public Query Clause(String field) throws ParseException, SyntaxError {Query q; Token fieldToken=null, boost=null; Token localParams=null; int flags = 0; if (jj_2_3(2)) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case TERM: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case TERM:{ fieldToken = jj_consume_token(TERM); jj_consume_token(COLON); - field = discardEscapeChar(fieldToken.image); +field = discardEscapeChar(fieldToken.image); break; - case STAR: + } + case STAR:{ jj_consume_token(STAR); jj_consume_token(COLON); - field = "*"; +field = "*"; break; + } default: jj_la1[7] = jj_gen; jj_consume_token(-1); @@ -266,7 +275,7 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst } else { ; } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case BAREOPER: case STAR: case QUOTED: @@ -276,63 +285,69 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst case REGEXPTERM: case RANGEIN_START: case RANGEEX_START: - case NUMBER: + case NUMBER:{ q = Term(field); break; - case LPAREN: + } + case LPAREN:{ jj_consume_token(LPAREN); q = Query(field); jj_consume_token(RPAREN); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); break; + } default: jj_la1[8] = jj_gen; ; } break; - case FILTER: + } + case FILTER:{ jj_consume_token(FILTER); - flags=startFilter(); +flags=startFilter(); q = Query(field); jj_consume_token(RPAREN); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); break; + } default: jj_la1[9] = jj_gen; ; } - q=getFilter(q); restoreFlags(flags); +q=getFilter(q); restoreFlags(flags); break; - case LPARAMS: + } + case LPARAMS:{ localParams = jj_consume_token(LPARAMS); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); break; + } default: jj_la1[10] = jj_gen; ; } - q=getLocalParams(field, localParams.image); +q=getLocalParams(field, localParams.image); break; + } default: jj_la1[11] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - {if (true) return handleBoost(q, boost);} +{if ("" != null) return handleBoost(q, boost);} throw new Error("Missing return statement in function"); - } +} - final public Query Term(String field) throws ParseException, SyntaxError { - Token term, boost=null, fuzzySlop=null, goop1, goop2; + final public Query Term(String field) throws ParseException, SyntaxError {Token term, boost=null, fuzzySlop=null, goop1, goop2; boolean prefix = false; boolean wildcard = false; boolean fuzzy = false; @@ -340,157 +355,181 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst boolean startInc=false; boolean endInc=false; Query q; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case BAREOPER: case STAR: case TERM: case PREFIXTERM: case WILDTERM: case REGEXPTERM: - case NUMBER: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case TERM: + case NUMBER:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case TERM:{ term = jj_consume_token(TERM); break; - case STAR: + } + case STAR:{ term = jj_consume_token(STAR); - wildcard=true; +wildcard=true; break; - case PREFIXTERM: + } + case PREFIXTERM:{ term = jj_consume_token(PREFIXTERM); - prefix=true; +prefix=true; break; - case WILDTERM: + } + case WILDTERM:{ term = jj_consume_token(WILDTERM); - wildcard=true; +wildcard=true; break; - case REGEXPTERM: + } + case REGEXPTERM:{ term = jj_consume_token(REGEXPTERM); - regexp=true; +regexp=true; break; - case NUMBER: + } + case NUMBER:{ term = jj_consume_token(NUMBER); break; - case BAREOPER: + } + case BAREOPER:{ term = jj_consume_token(BAREOPER); - term.image = term.image.substring(0,1); +term.image = term.image.substring(0,1); break; + } default: jj_la1[12] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case CARAT: - case FUZZY_SLOP: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: + case FUZZY_SLOP:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case FUZZY_SLOP: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case FUZZY_SLOP:{ fuzzySlop = jj_consume_token(FUZZY_SLOP); - fuzzy=true; +fuzzy=true; break; + } default: jj_la1[13] = jj_gen; ; } break; - case FUZZY_SLOP: + } + case FUZZY_SLOP:{ fuzzySlop = jj_consume_token(FUZZY_SLOP); - fuzzy=true; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: +fuzzy=true; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); break; + } default: jj_la1[14] = jj_gen; ; } break; + } default: jj_la1[15] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; + } default: jj_la1[16] = jj_gen; ; } - q = handleBareTokenQuery(getField(field), term, fuzzySlop, prefix, wildcard, fuzzy, regexp); +q = handleBareTokenQuery(getField(field), term, fuzzySlop, prefix, wildcard, fuzzy, regexp); break; + } case RANGEIN_START: - case RANGEEX_START: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case RANGEIN_START: + case RANGEEX_START:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case RANGEIN_START:{ jj_consume_token(RANGEIN_START); - startInc = true; +startInc = true; break; - case RANGEEX_START: + } + case RANGEEX_START:{ jj_consume_token(RANGEEX_START); break; + } default: jj_la1[17] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case RANGE_GOOP: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case RANGE_GOOP:{ goop1 = jj_consume_token(RANGE_GOOP); break; - case RANGE_QUOTED: + } + case RANGE_QUOTED:{ goop1 = jj_consume_token(RANGE_QUOTED); break; - case RANGE_TO: + } + case RANGE_TO:{ goop1 = jj_consume_token(RANGE_TO); break; + } default: jj_la1[18] = jj_gen; jj_consume_token(-1); throw new ParseException(); } jj_consume_token(RANGE_TO); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case RANGE_GOOP: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case RANGE_GOOP:{ goop2 = jj_consume_token(RANGE_GOOP); break; - case RANGE_QUOTED: + } + case RANGE_QUOTED:{ goop2 = jj_consume_token(RANGE_QUOTED); break; - case RANGE_TO: + } + case RANGE_TO:{ goop2 = jj_consume_token(RANGE_TO); break; + } default: jj_la1[19] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case RANGEIN_END: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case RANGEIN_END:{ jj_consume_token(RANGEIN_END); - endInc = true; +endInc = true; break; - case RANGEEX_END: + } + case RANGEEX_END:{ jj_consume_token(RANGEEX_END); break; + } default: jj_la1[20] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); break; + } default: jj_la1[21] = jj_gen; ; } - boolean startOpen=false; +boolean startOpen=false; boolean endOpen=false; if (goop1.kind == RANGE_QUOTED) { goop1.image = goop1.image.substring(1, goop1.image.length()-1); @@ -506,64 +545,70 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst startOpen ? null : discardEscapeChar(goop1.image), endOpen ? null : discardEscapeChar(goop2.image), startInc, endInc); break; - case QUOTED: + } + case QUOTED:{ term = jj_consume_token(QUOTED); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case CARAT: - case FUZZY_SLOP: - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: + case FUZZY_SLOP:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case FUZZY_SLOP: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case FUZZY_SLOP:{ fuzzySlop = jj_consume_token(FUZZY_SLOP); - fuzzy=true; +fuzzy=true; break; + } default: jj_la1[22] = jj_gen; ; } break; - case FUZZY_SLOP: + } + case FUZZY_SLOP:{ fuzzySlop = jj_consume_token(FUZZY_SLOP); - fuzzy=true; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CARAT: +fuzzy=true; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CARAT:{ jj_consume_token(CARAT); boost = jj_consume_token(NUMBER); break; + } default: jj_la1[23] = jj_gen; ; } break; + } default: jj_la1[24] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; + } default: jj_la1[25] = jj_gen; ; } - q = handleQuotedTerm(getField(field), term, fuzzySlop); +q = handleQuotedTerm(getField(field), term, fuzzySlop); break; + } default: jj_la1[26] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - {if (true) return handleBoost(q, boost);} +{if ("" != null) return handleBoost(q, boost);} throw new Error("Missing return statement in function"); - } +} - final public void MultiTerm(String field, List clauses) throws ParseException, SyntaxError { - Token text; + final public void MultiTerm(String field, List clauses) throws ParseException, SyntaxError {Token text; List terms = null; text = jj_consume_token(TERM); - if (splitOnWhitespace) { +if (splitOnWhitespace) { Query q = getFieldQuery(getField(field), discardEscapeChar(text.image), false, true); addClause(clauses, CONJ_NONE, MOD_NONE, q); } else { @@ -579,7 +624,7 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst label_2: while (true) { text = jj_consume_token(TERM); - if (splitOnWhitespace) { +if (splitOnWhitespace) { Query q = getFieldQuery(getField(field), discardEscapeChar(text.image), false, true); addClause(clauses, CONJ_NONE, MOD_NONE, q); } else { @@ -591,38 +636,43 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst break label_2; } } - if (splitOnWhitespace == false) { +if (splitOnWhitespace == false) { Query q = getFieldQuery(getField(field), terms, true); addMultiTermClause(clauses, q); } - } +} - 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_2_2(int xla) { + private boolean jj_2_2(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_2(); } + try { return (!jj_3_2()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(1, xla); } } - private boolean jj_2_3(int xla) { + private boolean jj_2_3(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_3(); } + try { return (!jj_3_3()); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(2, xla); } } - private boolean jj_3R_6() { + private boolean jj_3R_6() + { return false; } - private boolean jj_3R_3() { + private boolean jj_3R_3() + { if (jj_scan_token(TERM)) return true; jj_lookingAhead = true; jj_semLA = getToken(1).kind == TERM && allowedPostMultiTerm(getToken(2).kind); @@ -637,7 +687,8 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst return false; } - private boolean jj_3_3() { + private boolean jj_3_3() + { Token xsp; xsp = jj_scanpos; if (jj_3R_4()) { @@ -647,29 +698,34 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst return false; } - private boolean jj_3_2() { + private boolean jj_3_2() + { if (jj_3R_3()) return true; return false; } - private boolean jj_3R_5() { + private boolean jj_3R_5() + { if (jj_scan_token(STAR)) return true; if (jj_scan_token(COLON)) return true; return false; } - private boolean jj_3R_7() { + private boolean jj_3R_7() + { if (jj_scan_token(TERM)) return true; return false; } - private boolean jj_3R_4() { + private boolean jj_3R_4() + { if (jj_scan_token(TERM)) return true; if (jj_scan_token(COLON)) return true; return false; } - private boolean jj_3_1() { + private boolean jj_3_1() + { if (jj_3R_3()) return true; return false; } @@ -691,132 +747,133 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst static private int[] jj_la1_0; static private int[] jj_la1_1; static { - jj_la1_init_0(); - jj_la1_init_1(); - } - private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0x6000,0x6000,0x38000,0x38000,0xfb4f8000,0xfb4fe000,0xfb4fe000,0x2400000,0x800000,0x800000,0x800000,0xfb4c0000,0x3a440000,0x4000000,0x800000,0x4800000,0x4800000,0xc0000000,0x0,0x0,0x0,0x800000,0x4000000,0x800000,0x4800000,0x4800000,0xfb440000,}; - } - private static void jj_la1_init_1() { - jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x7,0x7,0x7,0x0,0x0,0x0,0x0,0x7,0x4,0x0,0x0,0x0,0x0,0x0,0xc8,0xc8,0x30,0x0,0x0,0x0,0x0,0x0,0x4,}; - } + jj_la1_init_0(); + jj_la1_init_1(); + } + private static void jj_la1_init_0() { + jj_la1_0 = new int[] {0x6000,0x6000,0x38000,0x38000,0xfb4f8000,0xfb4fe000,0xfb4fe000,0x2400000,0x800000,0x800000,0x800000,0xfb4c0000,0x3a440000,0x4000000,0x800000,0x4800000,0x4800000,0xc0000000,0x0,0x0,0x0,0x800000,0x4000000,0x800000,0x4800000,0x4800000,0xfb440000,}; + } + private static void jj_la1_init_1() { + jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x7,0x7,0x7,0x0,0x0,0x0,0x0,0x7,0x4,0x0,0x0,0x0,0x0,0x0,0xc8,0xc8,0x30,0x0,0x0,0x0,0x0,0x0,0x4,}; + } final private JJCalls[] jj_2_rtns = new JJCalls[3]; private boolean jj_rescan = false; private int jj_gc = 0; /** Constructor with user supplied CharStream. */ protected QueryParser(CharStream stream) { - token_source = new QueryParserTokenManager(stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 27; 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 < 27; 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_lookingAhead = false; - jj_gen = 0; - for (int i = 0; i < 27; 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_lookingAhead = false; + jj_gen = 0; + for (int i = 0; i < 27; 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. */ protected QueryParser(QueryParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 27; 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 < 27; 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 < 27; 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 < 27; 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 { } static 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 = jj_lookingAhead ? jj_scanpos : 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 = jj_lookingAhead ? jj_scanpos : 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 jj_expentries = new java.util.ArrayList(); @@ -826,65 +883,86 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst 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[40]; - if (jj_kind >= 0) { - la1tokens[jj_kind] = true; - jj_kind = -1; - } - for (int i = 0; i < 27; i++) { - if (jj_la1[i] == jj_gen) { - for (int j = 0; j < 32; j++) { - if ((jj_la1_0[i] & (1<= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 27; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1< jj_gen) { - jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; - switch (i) { - case 0: jj_3_1(); break; - case 1: jj_3_2(); break; - case 2: jj_3_3(); break; - } - } - p = p.next; - } while (p != null); - } catch(LookaheadSuccess ls) { } - } - jj_rescan = false; + jj_rescan = true; + for (int i = 0; i < 3; 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; + case 1: jj_3_2(); break; + case 2: jj_3_3(); 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; } } diff --git a/solr/core/src/java/org/apache/solr/parser/QueryParserTokenManager.java b/solr/core/src/java/org/apache/solr/parser/QueryParserTokenManager.java index e97f14b32cc..c717057fae8 100644 --- a/solr/core/src/java/org/apache/solr/parser/QueryParserTokenManager.java +++ b/solr/core/src/java/org/apache/solr/parser/QueryParserTokenManager.java @@ -1,3 +1,4 @@ +/* QueryParserTokenManager.java */ /* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */ package org.apache.solr.parser; @@ -13,16 +14,14 @@ package org.apache.solr.parser; /** Token Manager. */ -public class QueryParserTokenManager implements QueryParserConstants -{ +public class QueryParserTokenManager implements QueryParserConstants { int commentNestingDepth ; /** Debug output. */ // (debugStream omitted). /** Set debug output. */ // (setDebugStream omitted). -private final int jjStopStringLiteralDfa_3(int pos, long active0) -{ +private final int jjStopStringLiteralDfa_3(int pos, long active0){ switch (pos) { case 0: @@ -84,8 +83,7 @@ private final int jjStopStringLiteralDfa_3(int pos, long active0) return -1; } } -private final int jjStartNfa_3(int pos, long active0) -{ +private final int jjStartNfa_3(int pos, long active0){ return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0), pos + 1); } private int jjStopAtPos(int pos, int kind) @@ -94,8 +92,7 @@ private int jjStopAtPos(int pos, int kind) jjmatchedPos = pos; return pos + 1; } -private int jjMoveStringLiteralDfa0_3() -{ +private int jjMoveStringLiteralDfa0_3(){ switch(curChar) { case 40: @@ -124,8 +121,7 @@ private int jjMoveStringLiteralDfa0_3() return jjMoveNfa_3(0, 0); } } -private int jjMoveStringLiteralDfa1_3(long active0) -{ +private int jjMoveStringLiteralDfa1_3(long active0){ try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_3(0, active0); @@ -144,8 +140,7 @@ private int jjMoveStringLiteralDfa1_3(long active0) } return jjStartNfa_3(0, active0); } -private int jjMoveStringLiteralDfa2_3(long old0, long active0) -{ +private int jjMoveStringLiteralDfa2_3(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjStartNfa_3(0, old0); try { curChar = input_stream.readChar(); } @@ -162,8 +157,7 @@ private int jjMoveStringLiteralDfa2_3(long old0, long active0) } return jjStartNfa_3(1, active0); } -private int jjMoveStringLiteralDfa3_3(long old0, long active0) -{ +private int jjMoveStringLiteralDfa3_3(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjStartNfa_3(1, old0); try { curChar = input_stream.readChar(); } @@ -180,8 +174,7 @@ private int jjMoveStringLiteralDfa3_3(long old0, long active0) } return jjStartNfa_3(2, active0); } -private int jjMoveStringLiteralDfa4_3(long old0, long active0) -{ +private int jjMoveStringLiteralDfa4_3(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjStartNfa_3(2, old0); try { curChar = input_stream.readChar(); } @@ -198,8 +191,7 @@ private int jjMoveStringLiteralDfa4_3(long old0, long active0) } return jjStartNfa_3(3, active0); } -private int jjMoveStringLiteralDfa5_3(long old0, long active0) -{ +private int jjMoveStringLiteralDfa5_3(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjStartNfa_3(3, old0); try { curChar = input_stream.readChar(); } @@ -216,8 +208,7 @@ private int jjMoveStringLiteralDfa5_3(long old0, long active0) } return jjStartNfa_3(4, active0); } -private int jjMoveStringLiteralDfa6_3(long old0, long active0) -{ +private int jjMoveStringLiteralDfa6_3(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjStartNfa_3(4, old0); try { curChar = input_stream.readChar(); } @@ -280,18 +271,18 @@ private int jjMoveNfa_3(int startState, int curPos) break; if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } break; case 31: if ((0xffff7bffffffffffL & l) != 0L) - jjCheckNAddStates(0, 2); + { jjCheckNAddStates(0, 2); } break; case 0: if ((0xfbff54f8ffffd9ffL & l) != 0L) { if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } } else if ((0x100002600L & l) != 0L) { @@ -301,14 +292,14 @@ private int jjMoveNfa_3(int startState, int curPos) else if ((0x280200000000L & l) != 0L) jjstateSet[jjnewStateCnt++] = 15; else if (curChar == 47) - jjAddStates(3, 4); + { jjAddStates(3, 4); } else if (curChar == 34) - jjCheckNAddStates(5, 7); + { jjCheckNAddStates(5, 7); } if ((0x7bff50f8ffffd9ffL & l) != 0L) { if (kind > 25) kind = 25; - jjCheckNAddStates(8, 12); + { jjCheckNAddStates(8, 12); } } else if (curChar == 42) { @@ -328,10 +319,10 @@ private int jjMoveNfa_3(int startState, int curPos) { if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } } if ((0x7bfff8faffffd9ffL & l) != 0L) - jjCheckNAddStates(13, 15); + { jjCheckNAddStates(13, 15); } else if (curChar == 42) { if (kind > 27) @@ -341,7 +332,7 @@ private int jjMoveNfa_3(int startState, int curPos) { if (kind > 25) kind = 25; - jjCheckNAddTwoStates(56, 57); + { jjCheckNAddTwoStates(56, 57); } } break; case 4: @@ -366,14 +357,14 @@ private int jjMoveNfa_3(int startState, int curPos) break; case 16: if (curChar == 34) - jjCheckNAddStates(5, 7); + { jjCheckNAddStates(5, 7); } break; case 17: if ((0xfffffffbffffffffL & l) != 0L) - jjCheckNAddStates(5, 7); + { jjCheckNAddStates(5, 7); } break; case 19: - jjCheckNAddStates(5, 7); + { jjCheckNAddStates(5, 7); } break; case 20: if (curChar == 34 && kind > 24) @@ -384,18 +375,18 @@ private int jjMoveNfa_3(int startState, int curPos) break; if (kind > 26) kind = 26; - jjAddStates(16, 17); + { jjAddStates(16, 17); } break; case 23: if (curChar == 46) - jjCheckNAdd(24); + { jjCheckNAdd(24); } break; case 24: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 26) kind = 26; - jjCheckNAdd(24); + { jjCheckNAdd(24); } break; case 25: if (curChar == 42 && kind > 27) @@ -406,24 +397,24 @@ private int jjMoveNfa_3(int startState, int curPos) break; if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } break; case 29: if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } break; case 30: if (curChar == 47) - jjAddStates(3, 4); + { jjAddStates(3, 4); } break; case 32: if ((0xffff7fffffffffffL & l) != 0L) - jjCheckNAddStates(0, 2); + { jjCheckNAddStates(0, 2); } break; case 33: if (curChar == 47) - jjCheckNAddStates(0, 2); + { jjCheckNAddStates(0, 2); } break; case 35: if (curChar == 47 && kind > 29) @@ -431,34 +422,34 @@ private int jjMoveNfa_3(int startState, int curPos) break; case 37: if (curChar == 33) - jjCheckNAddStates(18, 20); + { jjCheckNAddStates(18, 20); } break; case 38: if ((0x100002600L & l) != 0L) - jjCheckNAddTwoStates(38, 39); + { jjCheckNAddTwoStates(38, 39); } break; case 39: if ((0xdfffffffffffffffL & l) != 0L) - jjCheckNAddStates(21, 24); + { jjCheckNAddStates(21, 24); } break; case 40: if (curChar == 61) - jjCheckNAddStates(25, 30); + { jjCheckNAddStates(25, 30); } break; case 41: if (curChar == 34) - jjCheckNAddStates(31, 33); + { jjCheckNAddStates(31, 33); } break; case 42: if ((0xfffffffbffffffffL & l) != 0L) - jjCheckNAddStates(31, 33); + { jjCheckNAddStates(31, 33); } break; case 44: - jjCheckNAddStates(31, 33); + { jjCheckNAddStates(31, 33); } break; case 45: if (curChar == 34) - jjCheckNAddStates(18, 20); + { jjCheckNAddStates(18, 20); } break; case 48: if ((0xfffffdfefffff9ffL & l) == 0L) @@ -469,48 +460,48 @@ private int jjMoveNfa_3(int startState, int curPos) break; case 49: if (curChar == 39) - jjCheckNAddStates(34, 36); + { jjCheckNAddStates(34, 36); } break; case 50: if ((0xffffff7fffffffffL & l) != 0L) - jjCheckNAddStates(34, 36); + { jjCheckNAddStates(34, 36); } break; case 52: - jjCheckNAddStates(34, 36); + { jjCheckNAddStates(34, 36); } break; case 53: if (curChar == 39) - jjCheckNAddStates(18, 20); + { jjCheckNAddStates(18, 20); } break; case 54: if ((0xfffffffeffffffffL & l) != 0L) - jjCheckNAddStates(37, 40); + { jjCheckNAddStates(37, 40); } break; case 55: if ((0x7bff50f8ffffd9ffL & l) == 0L) break; if (kind > 25) kind = 25; - jjCheckNAddStates(8, 12); + { jjCheckNAddStates(8, 12); } break; case 56: if ((0x7bfff8faffffd9ffL & l) == 0L) break; if (kind > 25) kind = 25; - jjCheckNAddTwoStates(56, 57); + { jjCheckNAddTwoStates(56, 57); } break; case 58: if (kind > 25) kind = 25; - jjCheckNAddTwoStates(56, 57); + { jjCheckNAddTwoStates(56, 57); } break; case 59: if ((0x7bfff8faffffd9ffL & l) != 0L) - jjCheckNAddStates(13, 15); + { jjCheckNAddStates(13, 15); } break; case 61: - jjCheckNAddStates(13, 15); + { jjCheckNAddStates(13, 15); } break; default : break; } @@ -528,25 +519,25 @@ private int jjMoveNfa_3(int startState, int curPos) { if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } } else if (curChar == 92) - jjCheckNAddTwoStates(29, 29); + { jjCheckNAddTwoStates(29, 29); } break; case 31: - jjCheckNAddStates(0, 2); + { jjCheckNAddStates(0, 2); } if (curChar == 92) - jjCheckNAdd(33); + { jjCheckNAdd(33); } break; case 0: if ((0x97ffffff87ffffffL & l) != 0L) { if (kind > 25) kind = 25; - jjCheckNAddStates(8, 12); + { jjCheckNAddStates(8, 12); } } else if (curChar == 92) - jjCheckNAddStates(41, 43); + { jjCheckNAddStates(41, 43); } else if (curChar == 123) jjstateSet[jjnewStateCnt++] = 37; else if (curChar == 126) @@ -559,7 +550,7 @@ private int jjMoveNfa_3(int startState, int curPos) { if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } } if (curChar == 78) jjstateSet[jjnewStateCnt++] = 11; @@ -575,22 +566,22 @@ private int jjMoveNfa_3(int startState, int curPos) { if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } } else if (curChar == 92) - jjCheckNAddTwoStates(58, 58); + { jjCheckNAddTwoStates(58, 58); } if ((0x97ffffff87ffffffL & l) != 0L) - jjCheckNAddStates(13, 15); + { jjCheckNAddStates(13, 15); } else if (curChar == 92) - jjCheckNAddTwoStates(61, 61); + { jjCheckNAddTwoStates(61, 61); } if ((0x97ffffff87ffffffL & l) != 0L) { if (kind > 25) kind = 25; - jjCheckNAddTwoStates(56, 57); + { jjCheckNAddTwoStates(56, 57); } } else if (curChar == 92) - jjCheckNAddTwoStates(29, 29); + { jjCheckNAddTwoStates(29, 29); } break; case 1: if (curChar == 68 && kind > 13) @@ -634,14 +625,14 @@ private int jjMoveNfa_3(int startState, int curPos) break; case 17: if ((0xffffffffefffffffL & l) != 0L) - jjCheckNAddStates(5, 7); + { jjCheckNAddStates(5, 7); } break; case 18: if (curChar == 92) jjstateSet[jjnewStateCnt++] = 19; break; case 19: - jjCheckNAddStates(5, 7); + { jjCheckNAddStates(5, 7); } break; case 21: if (curChar != 126) @@ -655,56 +646,56 @@ private int jjMoveNfa_3(int startState, int curPos) break; if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } break; case 27: if ((0x97ffffff87ffffffL & l) == 0L) break; if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } break; case 28: if (curChar == 92) - jjCheckNAddTwoStates(29, 29); + { jjCheckNAddTwoStates(29, 29); } break; case 29: if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } break; case 32: - jjCheckNAddStates(0, 2); + { jjCheckNAddStates(0, 2); } break; case 34: if (curChar == 92) - jjCheckNAdd(33); + { jjCheckNAdd(33); } break; case 36: if (curChar == 92) - jjCheckNAdd(33); + { jjCheckNAdd(33); } break; case 39: if ((0xdfffffffffffffffL & l) != 0L) - jjCheckNAddStates(21, 24); + { jjCheckNAddStates(21, 24); } break; case 42: if ((0xffffffffefffffffL & l) != 0L) - jjCheckNAddStates(31, 33); + { jjCheckNAddStates(31, 33); } break; case 43: if (curChar == 92) jjstateSet[jjnewStateCnt++] = 44; break; case 44: - jjCheckNAddStates(31, 33); + { jjCheckNAddStates(31, 33); } break; case 46: if (curChar != 125) break; if (kind > 32) kind = 32; - jjCheckNAddTwoStates(47, 48); + { jjCheckNAddTwoStates(47, 48); } break; case 47: if (curChar == 123) @@ -715,60 +706,60 @@ private int jjMoveNfa_3(int startState, int curPos) break; if (kind > 32) kind = 32; - jjCheckNAdd(48); + { jjCheckNAdd(48); } break; case 50: if ((0xffffffffefffffffL & l) != 0L) - jjCheckNAddStates(34, 36); + { jjCheckNAddStates(34, 36); } break; case 51: if (curChar == 92) jjstateSet[jjnewStateCnt++] = 52; break; case 52: - jjCheckNAddStates(34, 36); + { jjCheckNAddStates(34, 36); } break; case 54: if ((0xdfffffffffffffffL & l) != 0L) - jjCheckNAddStates(37, 40); + { jjCheckNAddStates(37, 40); } break; case 55: if ((0x97ffffff87ffffffL & l) == 0L) break; if (kind > 25) kind = 25; - jjCheckNAddStates(8, 12); + { jjCheckNAddStates(8, 12); } break; case 56: if ((0x97ffffff87ffffffL & l) == 0L) break; if (kind > 25) kind = 25; - jjCheckNAddTwoStates(56, 57); + { jjCheckNAddTwoStates(56, 57); } break; case 57: if (curChar == 92) - jjCheckNAddTwoStates(58, 58); + { jjCheckNAddTwoStates(58, 58); } break; case 58: if (kind > 25) kind = 25; - jjCheckNAddTwoStates(56, 57); + { jjCheckNAddTwoStates(56, 57); } break; case 59: if ((0x97ffffff87ffffffL & l) != 0L) - jjCheckNAddStates(13, 15); + { jjCheckNAddStates(13, 15); } break; case 60: if (curChar == 92) - jjCheckNAddTwoStates(61, 61); + { jjCheckNAddTwoStates(61, 61); } break; case 61: - jjCheckNAddStates(13, 15); + { jjCheckNAddStates(13, 15); } break; case 62: if (curChar == 92) - jjCheckNAddStates(41, 43); + { jjCheckNAddStates(41, 43); } break; default : break; } @@ -776,7 +767,7 @@ private int jjMoveNfa_3(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; @@ -791,12 +782,12 @@ private int jjMoveNfa_3(int startState, int curPos) break; if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } break; case 31: case 32: if (jjCanMove_1(hiByte, i1, i2, l1, l2)) - jjCheckNAddStates(0, 2); + { jjCheckNAddStates(0, 2); } break; case 0: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) @@ -808,13 +799,13 @@ private int jjMoveNfa_3(int startState, int curPos) { if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } } if (jjCanMove_2(hiByte, i1, i2, l1, l2)) { if (kind > 25) kind = 25; - jjCheckNAddStates(8, 12); + { jjCheckNAddStates(8, 12); } } break; case 63: @@ -822,15 +813,15 @@ private int jjMoveNfa_3(int startState, int curPos) { if (kind > 25) kind = 25; - jjCheckNAddTwoStates(56, 57); + { jjCheckNAddTwoStates(56, 57); } } if (jjCanMove_2(hiByte, i1, i2, l1, l2)) - jjCheckNAddStates(13, 15); + { jjCheckNAddStates(13, 15); } if (jjCanMove_2(hiByte, i1, i2, l1, l2)) { if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } } break; case 15: @@ -840,34 +831,34 @@ private int jjMoveNfa_3(int startState, int curPos) case 17: case 19: if (jjCanMove_1(hiByte, i1, i2, l1, l2)) - jjCheckNAddStates(5, 7); + { jjCheckNAddStates(5, 7); } break; case 26: if (!jjCanMove_2(hiByte, i1, i2, l1, l2)) break; if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } break; case 29: if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) break; if (kind > 28) kind = 28; - jjCheckNAddTwoStates(27, 28); + { jjCheckNAddTwoStates(27, 28); } break; case 38: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) - jjCheckNAddTwoStates(38, 39); + { jjCheckNAddTwoStates(38, 39); } break; case 39: if (jjCanMove_1(hiByte, i1, i2, l1, l2)) - jjCheckNAddStates(21, 24); + { jjCheckNAddStates(21, 24); } break; case 42: case 44: if (jjCanMove_1(hiByte, i1, i2, l1, l2)) - jjCheckNAddStates(31, 33); + { jjCheckNAddStates(31, 33); } break; case 48: if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) @@ -879,42 +870,42 @@ private int jjMoveNfa_3(int startState, int curPos) case 50: case 52: if (jjCanMove_1(hiByte, i1, i2, l1, l2)) - jjCheckNAddStates(34, 36); + { jjCheckNAddStates(34, 36); } break; case 54: if (jjCanMove_1(hiByte, i1, i2, l1, l2)) - jjCheckNAddStates(37, 40); + { jjCheckNAddStates(37, 40); } break; case 55: if (!jjCanMove_2(hiByte, i1, i2, l1, l2)) break; if (kind > 25) kind = 25; - jjCheckNAddStates(8, 12); + { jjCheckNAddStates(8, 12); } break; case 56: if (!jjCanMove_2(hiByte, i1, i2, l1, l2)) break; if (kind > 25) kind = 25; - jjCheckNAddTwoStates(56, 57); + { jjCheckNAddTwoStates(56, 57); } break; case 58: if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) break; if (kind > 25) kind = 25; - jjCheckNAddTwoStates(56, 57); + { jjCheckNAddTwoStates(56, 57); } break; case 59: if (jjCanMove_2(hiByte, i1, i2, l1, l2)) - jjCheckNAddStates(13, 15); + { jjCheckNAddStates(13, 15); } break; case 61: if (jjCanMove_1(hiByte, i1, i2, l1, l2)) - jjCheckNAddStates(13, 15); + { jjCheckNAddStates(13, 15); } break; - default : break; + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; } } while(i != startsAt); } @@ -931,20 +922,17 @@ private int jjMoveNfa_3(int startState, int curPos) catch(java.io.IOException e) { return curPos; } } } -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 jjMoveStringLiteralDfa0_2() -{ +private int jjMoveStringLiteralDfa0_2(){ switch(curChar) { case 42: @@ -955,8 +943,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); @@ -1016,7 +1003,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; @@ -1029,7 +1016,7 @@ private int jjMoveNfa_2(int startState, int curPos) if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 8) kind = 8; break; - default : break; + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; } } while(i != startsAt); } @@ -1073,34 +1060,34 @@ private int jjMoveNfa_0(int startState, int curPos) { if (kind > 34) kind = 34; - jjCheckNAddTwoStates(2, 3); + { jjCheckNAddTwoStates(2, 3); } } else if (curChar == 45) - jjCheckNAdd(2); + { jjCheckNAdd(2); } else if (curChar == 61) - jjCheckNAddTwoStates(1, 2); + { jjCheckNAddTwoStates(1, 2); } break; case 1: if (curChar == 45) - jjCheckNAdd(2); + { jjCheckNAdd(2); } break; case 2: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 34) kind = 34; - jjCheckNAddTwoStates(2, 3); + { jjCheckNAddTwoStates(2, 3); } break; case 3: if (curChar == 46) - jjCheckNAdd(4); + { jjCheckNAdd(4); } break; case 4: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 34) kind = 34; - jjCheckNAdd(4); + { jjCheckNAdd(4); } break; default : break; } @@ -1119,7 +1106,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; @@ -1128,7 +1115,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); } @@ -1145,8 +1132,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: @@ -1160,12 +1146,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: @@ -1178,8 +1162,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); @@ -1227,7 +1210,7 @@ private int jjMoveNfa_1(int startState, int curPos) { if (kind > 39) kind = 39; - jjCheckNAdd(6); + { jjCheckNAdd(6); } } if ((0x100002600L & l) != 0L) { @@ -1235,19 +1218,19 @@ private int jjMoveNfa_1(int startState, int curPos) kind = 12; } 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(44, 46); + { jjCheckNAddStates(44, 46); } break; case 3: if (curChar == 34) - jjCheckNAddStates(44, 46); + { jjCheckNAddStates(44, 46); } break; case 5: if (curChar == 34 && kind > 38) @@ -1258,7 +1241,7 @@ private int jjMoveNfa_1(int startState, int curPos) break; if (kind > 39) kind = 39; - jjCheckNAdd(6); + { jjCheckNAdd(6); } break; default : break; } @@ -1277,10 +1260,10 @@ private int jjMoveNfa_1(int startState, int curPos) break; if (kind > 39) kind = 39; - jjCheckNAdd(6); + { jjCheckNAdd(6); } break; case 2: - jjAddStates(44, 46); + { jjAddStates(44, 46); } break; case 4: if (curChar == 92) @@ -1292,7 +1275,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; @@ -1311,21 +1294,21 @@ private int jjMoveNfa_1(int startState, int curPos) { if (kind > 39) kind = 39; - jjCheckNAdd(6); + { jjCheckNAdd(6); } } break; case 2: if (jjCanMove_1(hiByte, i1, i2, l1, l2)) - jjAddStates(44, 46); + { jjAddStates(44, 46); } break; case 6: if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) break; if (kind > 39) kind = 39; - jjCheckNAdd(6); + { jjCheckNAdd(6); } break; - default : break; + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; } } while(i != startsAt); } @@ -1342,6 +1325,38 @@ 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, null, null, +null, null, null, "\53", "\55", null, "\50", "\51", "\72", "\52", "\136", null, null, +null, null, null, null, "\133", "\173", null, "\146\151\154\164\145\162\50", 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 = { 32, 34, 35, 31, 36, 17, 18, 20, 56, 59, 25, 60, 57, 59, 25, 60, 22, 23, 38, 39, 46, 38, 39, 40, 46, 38, 39, 41, 49, 54, 46, 42, @@ -1384,107 +1399,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, null, null, -null, null, null, "\53", "\55", null, "\50", "\51", "\72", "\52", "\136", null, null, -null, null, null, null, "\133", "\173", null, "\146\151\154\164\145\162\50", null, -"\124\117", "\135", "\175", null, null, }; - -/** Lexer state names. */ -public static final String[] lexStateNames = { - "Boost", - "Range", - "COMMENT", - "DEFAULT", -}; - -/** Lex State array. */ -public static final int[] jjnewLexState = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, - -1, -1, -1, -1, -1, 1, 1, -1, -1, 3, -1, 3, 3, -1, -1, -}; -static final long[] jjtoToken = { - 0xffffffe001L, -}; -static final long[] jjtoSkip = { - 0x1f00L, -}; -protected CharStream input_stream; -private final int[] jjrounds = new int[63]; -private final int[] jjstateSet = new int[126]; -private final StringBuilder jjimage = new StringBuilder(); -private StringBuilder image = jjimage; -private int jjimageLen; -private int lengthOfMatch; -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 = 63; 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 >= 4 || 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 = 3; int defaultLexState = 3; int jjnewStateCnt; @@ -1505,9 +1419,10 @@ public Token getNextToken() { curChar = input_stream.BeginToken(); } - catch(java.io.IOException e) + catch(Exception e) { jjmatchedKind = 0; + jjmatchedPos = -1; matchedToken = jjFillToken(); return matchedToken; } @@ -1600,6 +1515,23 @@ void SkipLexicalActions(Token matchedToken) 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) @@ -1627,4 +1559,91 @@ 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 = 63; 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 >= 4 || 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", + "COMMENT", + "DEFAULT", +}; + +/** Lex State array. */ +public static final int[] jjnewLexState = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, + -1, -1, -1, -1, -1, 1, 1, -1, -1, 3, -1, 3, 3, -1, -1, +}; +static final long[] jjtoToken = { + 0xffffffe001L, +}; +static final long[] jjtoSkip = { + 0x1f00L, +}; +static final long[] jjtoSpecial = { + 0x0L, +}; +static final long[] jjtoMore = { + 0x0L, +}; + protected CharStream input_stream; + + private final int[] jjrounds = new int[63]; + private final int[] jjstateSet = new int[2 * 63]; + private final StringBuilder jjimage = new StringBuilder(); + private StringBuilder image = jjimage; + private int jjimageLen; + private int lengthOfMatch; + protected int curChar; } diff --git a/solr/core/src/java/org/apache/solr/parser/Token.java b/solr/core/src/java/org/apache/solr/parser/Token.java index f341d8fe30c..db6ffd04ecb 100644 --- a/solr/core/src/java/org/apache/solr/parser/Token.java +++ b/solr/core/src/java/org/apache/solr/parser/Token.java @@ -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; diff --git a/solr/core/src/java/org/apache/solr/parser/TokenMgrError.java b/solr/core/src/java/org/apache/solr/parser/TokenMgrError.java index bb2d8f74dc5..609c572de27 100644 --- a/solr/core/src/java/org/apache/solr/parser/TokenMgrError.java +++ b/solr/core/src/java/org/apache/solr/parser/TokenMgrError.java @@ -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 ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + + (EOFSeen ? " " : ("\"" + 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)*/