Skip to content

Commit

Permalink
Updated AccumuloSyntaxParser to accept functions with no arguments
Browse files Browse the repository at this point in the history
Re-generated AccumuloSyntaxParser.java from AccumuloSyntaxParser.jj using
a verson of javacc 4.1 build from https://github.com/javacc/javacc/tree/release_41
  • Loading branch information
drewfarris authored and austin007008 committed Dec 6, 2024
1 parent e2a43e4 commit a6df86f
Show file tree
Hide file tree
Showing 4 changed files with 316 additions and 251 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/* Generated By:JavaCC: Do not edit this line. AccumuloSyntaxParser.java */
package datawave.query.language.parser.lucene;

import java.io.StringReader;
import java.util.Vector;

/**
* Licensed to the Apache Software Foundation (ASF) under one or more
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
Expand All @@ -20,6 +16,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.StringReader;
import java.util.Vector;

import org.apache.lucene.queryparser.flexible.core.QueryNodeParseException;
import org.apache.lucene.queryparser.flexible.core.messages.QueryParserMessages;
import org.apache.lucene.queryparser.flexible.core.nodes.AndQueryNode;
Expand All @@ -42,7 +41,7 @@
import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;

@SuppressWarnings("all")
public class AccumuloSyntaxParser implements SyntaxParser, AcumuloSyntaxParserConstants {
public class AccumuloSyntaxParser implements SyntaxParser, AccumuloSyntaxParserConstants {

private static final int CONJ_NONE = 0;
private static final int CONJ_AND = 2;
Expand Down Expand Up @@ -605,7 +604,7 @@ final public QueryNode Term(CharSequence field) throws ParseException {
throw new Error("Missing return statement in function");
}

final private boolean jj_2_1(int xla) {
private boolean jj_2_1(int xla) {
jj_la = xla;
jj_lastpos = jj_scanpos = token;
try {
Expand All @@ -617,43 +616,46 @@ final private boolean jj_2_1(int xla) {
}
}

final private boolean jj_3_1() {
private boolean jj_3_1() {
if (jj_scan_token(TERM))
return true;
if (jj_scan_token(OP_COLON))
return true;
return false;
}

/** Generated Token Manager. */
public AccumuloSyntaxParserTokenManager token_source;
public Token token, jj_nt;
/** Current token. */
public Token token;
/** Next token. */
public Token jj_nt;
private int jj_ntk;
private Token jj_scanpos, jj_lastpos;
private int jj_la;
public boolean lookingAhead = false;
private boolean jj_semLA;
private int jj_gen;
final private int[] jj_la1 = new int[21];
static private int[] jj_la1_0;
static private int[] jj_la1_1;
static {
jj_la1_0();
jj_la1_1();
jj_la1_init_0();
jj_la1_init_1();
}

private static void jj_la1_0() {
private static void jj_la1_init_0() {
jj_la1_0 = new int[] {0x6000, 0x6000, 0x8000, 0x4000, 0x2000, 0xf638000, 0x100000, 0xf638000, 0x9410000, 0x800000, 0x800000, 0x100000, 0x6000000,
0x80000000, 0x10000000, 0x80000000, 0x60000000, 0x100000, 0x800000, 0x100000, 0xf610000,};
}

private static void jj_la1_1() {
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, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0,};
}

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 AccumuloSyntaxParser(CharStream stream) {
token_source = new AccumuloSyntaxParserTokenManager(stream);
token = new Token();
Expand All @@ -665,6 +667,7 @@ public AccumuloSyntaxParser(CharStream stream) {
jj_2_rtns[i] = new JJCalls();
}

/** Reinitialise. */
public void ReInit(CharStream stream) {
token_source.ReInit(stream);
token = new Token();
Expand All @@ -676,6 +679,7 @@ public void ReInit(CharStream stream) {
jj_2_rtns[i] = new JJCalls();
}

/** Constructor with generated Token Manager. */
public AccumuloSyntaxParser(AccumuloSyntaxParserTokenManager tm) {
token_source = tm;
token = new Token();
Expand All @@ -687,6 +691,7 @@ public AccumuloSyntaxParser(AccumuloSyntaxParserTokenManager tm) {
jj_2_rtns[i] = new JJCalls();
}

/** Reinitialise. */
public void ReInit(AccumuloSyntaxParserTokenManager tm) {
token_source = tm;
token = new Token();
Expand All @@ -698,7 +703,7 @@ public void ReInit(AccumuloSyntaxParserTokenManager tm) {
jj_2_rtns[i] = new JJCalls();
}

final private Token jj_consume_token(int kind) throws ParseException {
private Token jj_consume_token(int kind) throws ParseException {
Token oldToken;
if ((oldToken = token).next != null)
token = token.next;
Expand Down Expand Up @@ -729,7 +734,7 @@ static private final class LookaheadSuccess extends java.lang.Error {}

final private LookaheadSuccess jj_ls = new LookaheadSuccess();

final private boolean jj_scan_token(int kind) {
private boolean jj_scan_token(int kind) {
if (jj_scanpos == jj_lastpos) {
jj_la--;
if (jj_scanpos.next == null) {
Expand Down Expand Up @@ -757,6 +762,7 @@ final private boolean jj_scan_token(int kind) {
return false;
}

/** Get the next Token. */
final public Token getNextToken() {
if (token.next != null)
token = token.next;
Expand All @@ -767,8 +773,9 @@ final public Token getNextToken() {
return token;
}

/** Get the specific Token. */
final public Token getToken(int index) {
Token t = lookingAhead ? jj_scanpos : token;
Token t = token;
for (int i = 0; i < index; i++) {
if (t.next != null)
t = t.next;
Expand All @@ -778,14 +785,14 @@ final public Token getToken(int index) {
return t;
}

final private int jj_ntk() {
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 java.util.Vector<int[]> jj_expentries = new java.util.Vector<int[]>();
private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
private int[] jj_expentry;
private int jj_kind = -1;
private int[] jj_lasttokens = new int[100];
Expand All @@ -801,34 +808,27 @@ private void jj_add_error_token(int kind, int pos) {
for (int i = 0; i < jj_endpos; i++) {
jj_expentry[i] = jj_lasttokens[i];
}
boolean exists = false;
for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) {
int[] oldentry = (int[]) (e.nextElement());
jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) {
int[] oldentry = (int[]) (it.next());
if (oldentry.length == jj_expentry.length) {
exists = true;
for (int i = 0; i < jj_expentry.length; i++) {
if (oldentry[i] != jj_expentry[i]) {
exists = false;
break;
continue jj_entries_loop;
}
}
if (exists)
break;
jj_expentries.add(jj_expentry);
break jj_entries_loop;
}
}
if (!exists)
jj_expentries.addElement(jj_expentry);
if (pos != 0)
jj_lasttokens[(jj_endpos = pos) - 1] = kind;
}
}

/** Generate ParseException. */
public ParseException generateParseException() {
jj_expentries.removeAllElements();
jj_expentries.clear();
boolean[] la1tokens = new boolean[33];
for (int i = 0; i < 33; i++) {
la1tokens[i] = false;
}
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
Expand All @@ -849,24 +849,26 @@ public ParseException generateParseException() {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
jj_expentries.addElement(jj_expentry);
jj_expentries.add(jj_expentry);
}
}
jj_endpos = 0;
jj_rescan_token();
jj_add_error_token(0, 0);
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = (int[]) jj_expentries.elementAt(i);
exptokseq[i] = jj_expentries.get(i);
}
return new ParseException(token, exptokseq, tokenImage);
}

/** Enable tracing. */
final public void enable_tracing() {}

/** Disable tracing. */
final public void disable_tracing() {}

final private void jj_rescan_token() {
private void jj_rescan_token() {
jj_rescan = true;
for (int i = 0; i < 1; i++) {
try {
Expand All @@ -888,7 +890,7 @@ final private void jj_rescan_token() {
jj_rescan = false;
}

final private void jj_save(int index, int xla) {
private void jj_save(int index, int xla) {
JJCalls p = jj_2_rtns[index];
while (p.gen > jj_gen) {
if (p.next == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Standard file is based on the TextParser.jj from lucene 2.3
* Standard file is based on the TextParser.f from lucene 2.3
*/

options {
Expand Down Expand Up @@ -127,7 +127,7 @@ PARSER_END(AccumuloSyntaxParser)
<AND: "AND" >
| <OR: "OR" >
| <NOT: "NOT" >
| <FUNCTION: "#" (<_TERM_START_CHAR>)+ "(" <_FUNCTION_ARG> ( (<_WHITESPACE>)* "," (<_WHITESPACE>)* <_FUNCTION_ARG> )* (<_WHITESPACE>)* ")" >
| <FUNCTION: "#" (<_TERM_START_CHAR>)+ "(" (<_FUNCTION_ARG> ( (<_WHITESPACE>)* "," (<_WHITESPACE>)* <_FUNCTION_ARG> )* (<_WHITESPACE>)*)* ")" >
| <LPAREN: "(" >
| <RPAREN: ")" >
| <OP_COLON: ":" >
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,84 @@
/* Generated By:JavaCC: Do not edit this line. AccumuloSyntaxParserConstants.java */
package datawave.query.language.parser.lucene;

public interface AcumuloSyntaxParserConstants {
/**
* Token literal values and constants. Generated by org.javacc.parser.OtherFilesGen#start()
*/
public interface AccumuloSyntaxParserConstants {

/** End of File. */
int EOF = 0;
/** RegularExpression Id. */
int _NUM_CHAR = 1;
/** RegularExpression Id. */
int _ESCAPED_CHAR = 2;
/** RegularExpression Id. */
int _TERM_START_CHAR = 3;
/** RegularExpression Id. */
int _TERM_CHAR = 4;
/** RegularExpression Id. */
int _FUNCTION_ARG_CHAR = 5;
/** RegularExpression Id. */
int _FUNCTION_ARG_BEGINEND_CHAR = 6;
/** RegularExpression Id. */
int _FUNCTION_ARG_ALL_CHAR1 = 7;
/** RegularExpression Id. */
int _FUNCTION_ARG_ALL_CHAR2 = 8;
/** RegularExpression Id. */
int _FUNCTION_ARG = 9;
/** RegularExpression Id. */
int _WHITESPACE = 10;
/** RegularExpression Id. */
int _QUOTED_CHAR = 11;
/** RegularExpression Id. */
int AND = 13;
/** RegularExpression Id. */
int OR = 14;
/** RegularExpression Id. */
int NOT = 15;
/** RegularExpression Id. */
int FUNCTION = 16;
/** RegularExpression Id. */
int LPAREN = 17;
/** RegularExpression Id. */
int RPAREN = 18;
/** RegularExpression Id. */
int OP_COLON = 19;
/** RegularExpression Id. */
int CARAT = 20;
/** RegularExpression Id. */
int QUOTED = 21;
/** RegularExpression Id. */
int TERM = 22;
/** RegularExpression Id. */
int FUZZY_SLOP = 23;
/** RegularExpression Id. */
int REGEXPTERM = 24;
/** RegularExpression Id. */
int RANGEIN_START = 25;
/** RegularExpression Id. */
int RANGEEX_START = 26;
/** RegularExpression Id. */
int NUMBER = 27;
/** RegularExpression Id. */
int RANGE_TO = 28;
/** RegularExpression Id. */
int RANGEIN_END = 29;
/** RegularExpression Id. */
int RANGEEX_END = 30;
/** RegularExpression Id. */
int RANGE_QUOTED = 31;
/** RegularExpression Id. */
int RANGE_GOOP = 32;

/** Lexical state. */
int Boost = 0;
/** Lexical state. */
int Range = 1;
/** Lexical state. */
int DEFAULT = 2;

/** Literal token values. */
String[] tokenImage = {"<EOF>", "<_NUM_CHAR>", "<_ESCAPED_CHAR>", "<_TERM_START_CHAR>", "<_TERM_CHAR>", "<_FUNCTION_ARG_CHAR>",
"<_FUNCTION_ARG_BEGINEND_CHAR>", "<_FUNCTION_ARG_ALL_CHAR1>", "<_FUNCTION_ARG_ALL_CHAR2>", "<_FUNCTION_ARG>", "<_WHITESPACE>", "<_QUOTED_CHAR>",
"<token of kind 12>", "\"AND\"", "\"OR\"", "\"NOT\"", "<FUNCTION>", "\"(\"", "\")\"", "\":\"", "\"^\"", "<QUOTED>", "<TERM>", "<FUZZY_SLOP>",
Expand Down
Loading

0 comments on commit a6df86f

Please sign in to comment.