org.apache.asterix.aqlplus.parser.AQLPlusParser Maven / Gradle / Ivy
/* Generated By:JavaCC: Do not edit this line. AQLPlusParser.java */
package org.apache.asterix.aqlplus.parser;
import java.io.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Stack;
import java.util.Map;
import java.util.HashMap;
import org.apache.asterix.aql.literal.FloatLiteral;
import org.apache.asterix.aql.literal.DoubleLiteral;
import org.apache.asterix.aql.literal.FalseLiteral;
import org.apache.asterix.aql.base.Literal;
import org.apache.asterix.aql.literal.IntegerLiteral;
import org.apache.asterix.aql.literal.LongIntegerLiteral;
import org.apache.asterix.aql.literal.NullLiteral;
import org.apache.asterix.aql.literal.StringLiteral;
import org.apache.asterix.aql.literal.TrueLiteral;
import org.apache.asterix.aql.parser.ScopeChecker;
import org.apache.asterix.aql.base.*;
import org.apache.asterix.aql.expression.*;
import org.apache.asterix.aql.expression.visitor.AQLPrintVisitor;
import org.apache.asterix.aql.expression.UnaryExpr.Sign;
import org.apache.asterix.aql.expression.TypeExpression.TypeExprKind;
import org.apache.asterix.aql.base.Statement.Kind;
import org.apache.asterix.aql.context.Scope;
import org.apache.asterix.aql.context.RootScopeFactory;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.om.functions.AsterixFunction;
import org.apache.asterix.common.functions.FunctionSignature;
import org.apache.asterix.metadata.bootstrap.MetadataConstants;
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionAnnotation;
import org.apache.hyracks.algebricks.core.algebra.expressions.IndexedNLJoinExpressionAnnotation;
import org.apache.hyracks.algebricks.common.utils.Pair;
public class AQLPlusParser extends ScopeChecker implements AQLPlusParserConstants {
/*
private void printHints(Token t) {
//System.err.println("token="+t.image+"\t special="+t.specialToken);
if (t.specialToken == null) return;
Token tmp_t = t.specialToken;
while (tmp_t.specialToken != null) tmp_t = tmp_t.specialToken;
while (tmp_t != null) {
System.out.println(tmp_t.image);
tmp_t = tmp_t.next;
}
}
*/
private static final String HASH_GROUP_BY_HINT = "hash";
private static final String BROADCAST_JOIN_HINT = "bcast";
private static final String INMEMORY_HINT = "inmem";
private static final String INDEXED_NESTED_LOOP_JOIN_HINT = "indexnl";
private static String getHint(Token t) {
if (t.specialToken == null) {
return null;
}
String s = t.specialToken.image;
int n = s.length();
if (n < 2) {
return null;
}
return s.substring(1).trim();
}
public static void main(String args[]) throws ParseException, TokenMgrError, IOException, FileNotFoundException, AsterixException {
File file = new File(args[0]);
Reader fis = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
AQLPlusParser parser = new AQLPlusParser(fis);
List st = parser.Statement();
}
public void initScope() {
scopeStack.push(RootScopeFactory.createRootScope(this));
}
final public List Statement() throws ParseException, ParseException {
Query query = null;
// scopeStack.push(RootScopeFactory.createRootScope(this));
initScope();
List decls = new ArrayList();
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 1:
case 2:
case 5:
case 6:
case 7:
case 8:
;
break;
default:
jj_la1[0] = jj_gen;
break label_1;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 1:
jj_consume_token(1);
decls.add(DataverseDeclaration());
break;
case 2:
jj_consume_token(2);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 3:
jj_consume_token(3);
decls.add(FunctionDeclaration());
break;
case 4:
jj_consume_token(4);
decls.add(TypeDeclaration());
break;
default:
jj_la1[1] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
case 5:
jj_consume_token(5);
decls.add(LoadStatement());
break;
case 6:
jj_consume_token(6);
decls.add(WriteStatement());
break;
case 7:
jj_consume_token(7);
decls.add(SetStatement());
break;
case 8:
decls.add(Query()) ;
jj_consume_token(8);
break;
default:
jj_la1[2] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
jj_consume_token(0);
{if (true) return decls;}
throw new Error("Missing return statement in function");
}
final public Statement SetStatement() throws ParseException, ParseException {
String pn = null;
Statement stmt = null;
jj_consume_token(IDENTIFIER);
pn = token.image;
jj_consume_token(STRING_LITERAL);
String pv = removeQuotesAndEscapes(token.image);
jj_consume_token(8);
{if (true) return new SetStatement(pn, pv);}
throw new Error("Missing return statement in function");
}
final public Statement WriteStatement() throws ParseException, ParseException {
Identifier nodeName = null;
String fileName = null;
Identifier datasetName = null;
Statement stmt = null;
Query query;
jj_consume_token(9);
jj_consume_token(10);
jj_consume_token(IDENTIFIER);
nodeName = new Identifier(token.image);
jj_consume_token(11);
jj_consume_token(STRING_LITERAL);
fileName = removeQuotesAndEscapes(token.image);
stmt = new WriteStatement(nodeName, fileName, null);
jj_consume_token(8);
{if (true) return stmt;}
throw new Error("Missing return statement in function");
}
final public DataverseDecl DataverseDeclaration() throws ParseException, ParseException {
Identifier dvName = null;
jj_consume_token(12);
jj_consume_token(IDENTIFIER);
defaultDataverse = token.image;
jj_consume_token(8);
{if (true) return new DataverseDecl(new Identifier(defaultDataverse));}
throw new Error("Missing return statement in function");
}
final public LoadStatement LoadStatement() throws ParseException, ParseException {
Identifier datasetName = null;
boolean alreadySorted = false;
String adapter;
Map properties = new HashMap();
String name;
String value;
jj_consume_token(DATASET);
jj_consume_token(IDENTIFIER);
datasetName = new Identifier(token.image);
jj_consume_token(13);
jj_consume_token(STRING_LITERAL);
adapter = removeQuotesAndEscapes(token.image);
jj_consume_token(LEFTPAREN);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case LEFTPAREN:
jj_consume_token(LEFTPAREN);
jj_consume_token(STRING_LITERAL);
name = removeQuotesAndEscapes(token.image);
jj_consume_token(14);
jj_consume_token(STRING_LITERAL);
value = removeQuotesAndEscapes(token.image);
jj_consume_token(RIGHTPAREN);
properties.put(name, value);
label_2:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[3] = jj_gen;
break label_2;
}
jj_consume_token(15);
jj_consume_token(LEFTPAREN);
jj_consume_token(STRING_LITERAL);
name = removeQuotesAndEscapes(token.image);
jj_consume_token(14);
jj_consume_token(STRING_LITERAL);
value = removeQuotesAndEscapes(token.image);
jj_consume_token(RIGHTPAREN);
properties.put(name, value);
}
break;
default:
jj_la1[4] = jj_gen;
;
}
jj_consume_token(RIGHTPAREN);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 16:
jj_consume_token(16);
alreadySorted = true;
break;
default:
jj_la1[5] = jj_gen;
;
}
jj_consume_token(8);
{if (true) return new LoadStatement(null, datasetName, adapter, properties, alreadySorted);}
throw new Error("Missing return statement in function");
}
final public TypeDecl TypeDeclaration() throws ParseException, ParseException {
Identifier ident;
TypeExpression typeExpr;
jj_consume_token(IDENTIFIER);
ident = new Identifier(token.image.toString());
jj_consume_token(17);
typeExpr = TypeExpr();
{if (true) return new TypeDecl(null, ident, typeExpr);}
throw new Error("Missing return statement in function");
}
final public TypeExpression TypeExpr() throws ParseException, ParseException {
TypeExpression typeExpr = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 18:
case 19:
case 20:
typeExpr = RecordTypeDef();
break;
case IDENTIFIER:
typeExpr = TypeReference();
break;
case 23:
typeExpr = OrderedListTypeDef();
break;
case 25:
typeExpr = UnorderedListTypeDef();
break;
default:
jj_la1[6] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return typeExpr;}
throw new Error("Missing return statement in function");
}
final public RecordTypeDefinition RecordTypeDef() throws ParseException, ParseException {
RecordTypeDefinition recType = new RecordTypeDefinition();
RecordTypeDefinition.RecordKind recordKind = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 18:
case 19:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 18:
jj_consume_token(18);
recordKind = RecordTypeDefinition.RecordKind.CLOSED;
break;
case 19:
jj_consume_token(19);
recordKind = RecordTypeDefinition.RecordKind.OPEN;
break;
default:
jj_la1[7] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
jj_la1[8] = jj_gen;
;
}
jj_consume_token(20);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case IDENTIFIER:
RecordField(recType);
label_3:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[9] = jj_gen;
break label_3;
}
jj_consume_token(15);
RecordField(recType);
}
break;
default:
jj_la1[10] = jj_gen;
;
}
jj_consume_token(21);
if (recordKind == null) {
recordKind = RecordTypeDefinition.RecordKind.OPEN;
}
recType.setRecordKind(recordKind);
{if (true) return recType;}
throw new Error("Missing return statement in function");
}
final public void RecordField(RecordTypeDefinition recType) throws ParseException, ParseException {
String fieldName;
TypeExpression type = null;
boolean nullable = false;
jj_consume_token(IDENTIFIER);
Token t = getToken(0);
fieldName = t.toString();
jj_consume_token(11);
type = TypeExpr();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 22:
jj_consume_token(22);
nullable = true;
break;
default:
jj_la1[11] = jj_gen;
;
}
recType.addField(fieldName, type, nullable);
}
final public TypeReferenceExpression TypeReference() throws ParseException, ParseException {
jj_consume_token(IDENTIFIER);
Token t = getToken(0);
Identifier id;
if (t.toString().equalsIgnoreCase("int")) {
id = new Identifier("int64");
} else {
id = new Identifier(t.toString());
}
{if (true) return new TypeReferenceExpression(id);}
throw new Error("Missing return statement in function");
}
final public OrderedListTypeDefinition OrderedListTypeDef() throws ParseException, ParseException {
TypeExpression type = null;
jj_consume_token(23);
type = TypeExpr();
jj_consume_token(24);
{if (true) return new OrderedListTypeDefinition(type);}
throw new Error("Missing return statement in function");
}
final public UnorderedListTypeDefinition UnorderedListTypeDef() throws ParseException, ParseException {
TypeExpression type = null;
jj_consume_token(25);
type = TypeExpr();
jj_consume_token(26);
{if (true) return new UnorderedListTypeDefinition(type);}
throw new Error("Missing return statement in function");
}
final public FunctionDecl FunctionDeclaration() throws ParseException, ParseException {
FunctionDecl funcDecl;
FunctionSignature signature;
String functionName;
int arity = 0;
List paramList = new ArrayList();
Expression funcBody;
VarIdentifier var = null;
createNewScope();
jj_consume_token(IDENTIFIER);
Token t = getToken(0);
functionName = t.toString();
if (functionName.equalsIgnoreCase("int")) {
functionName = "int64";
}
jj_consume_token(LEFTPAREN);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case VARIABLE:
jj_consume_token(VARIABLE);
var = new VarIdentifier();
var.setValue(getToken(0).toString());
paramList.add(var);
getCurrentScope().addNewVarSymbolToScope(var);
arity++;
label_4:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[12] = jj_gen;
break label_4;
}
jj_consume_token(15);
jj_consume_token(VARIABLE);
var = new VarIdentifier();
var.setValue(getToken(0).toString());
paramList.add(var);
getCurrentScope().addNewVarSymbolToScope(var);
arity++;
}
break;
default:
jj_la1[13] = jj_gen;
;
}
jj_consume_token(RIGHTPAREN);
jj_consume_token(20);
funcBody = Expression();
jj_consume_token(21);
signature = new FunctionSignature(defaultDataverse, functionName, arity);
getCurrentScope().addFunctionDescriptor(signature, false);
funcDecl = new FunctionDecl(signature, paramList, funcBody);
{if (true) return funcDecl;}
throw new Error("Missing return statement in function");
}
final public Query Query() throws ParseException, ParseException {
Query query = new Query();
Expression expr;
expr = Expression();
query.setBody(expr);
{if (true) return query;}
throw new Error("Missing return statement in function");
}
final public Expression Expression() throws ParseException {
Expression expr = null;
Expression exprP = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 20:
case 23:
case 33:
case 34:
case 41:
case DATASET:
case LEFTPAREN:
case INTEGER_LITERAL:
case NULL:
case TRUE:
case FALSE:
case DOUBLE_LITERAL:
case FLOAT_LITERAL:
case STRING_LITERAL:
case IDENTIFIER:
case VARIABLE:
case METAVARIABLE:
//OperatorExpr | IfThenElse | FLWOGRExpression | QuantifiedExpression
expr = OperatorExpr();
break;
case 43:
expr = IfThenElse();
break;
case 49:
case 52:
case METAVARIABLECLAUSE:
expr = FLWOGR();
break;
case 65:
case 66:
expr = QuantifiedExpression();
break;
default:
jj_la1[14] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return (exprP==null) ? expr : exprP;}
throw new Error("Missing return statement in function");
}
final public Expression OperatorExpr() throws ParseException, ParseException {
OperatorExpr op = null;
Expression operand = null;
operand = AndExpr();
label_5:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 27:
;
break;
default:
jj_la1[15] = jj_gen;
break label_5;
}
jj_consume_token(27);
if (op == null) {
op = new OperatorExpr();
op.addOperand(operand);
op.setCurrentop(true);
}
Token t = getToken(0);
op.addOperator(t.toString());
operand = AndExpr();
op.addOperand(operand);
}
{if (true) return op==null? operand: op;}
throw new Error("Missing return statement in function");
}
final public Expression AndExpr() throws ParseException, ParseException {
OperatorExpr op = null;
Expression operand = null;
operand = RelExpr();
label_6:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 28:
;
break;
default:
jj_la1[16] = jj_gen;
break label_6;
}
jj_consume_token(28);
if (op == null) {
op = new OperatorExpr();
op.addOperand(operand);
op.setCurrentop(true);
}
Token t = getToken(0);
op.addOperator(t.toString());
operand = RelExpr();
op.addOperand(operand);
}
{if (true) return op==null? operand: op;}
throw new Error("Missing return statement in function");
}
final public Expression RelExpr() throws ParseException, ParseException {
OperatorExpr op = null;
Expression operand = null;
boolean broadcast = false;
operand = AddExpr();
if (operand instanceof VariableExpr) {
String hint = getHint(token);
if (hint != null && hint.equals(BROADCAST_JOIN_HINT)) {
broadcast = true;
}
}
if (jj_2_1(2)) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 25:
jj_consume_token(25);
break;
case 26:
jj_consume_token(26);
break;
case 29:
jj_consume_token(29);
break;
case 30:
jj_consume_token(30);
break;
case 14:
jj_consume_token(14);
break;
case 31:
jj_consume_token(31);
break;
case 32:
jj_consume_token(32);
break;
default:
jj_la1[17] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
if (op == null) {
op = new OperatorExpr();
op.addOperand(operand, broadcast);
op.setCurrentop(true);
broadcast = false;
}
Token t = getToken(0);
op.addOperator(t.toString());
operand = AddExpr();
broadcast = false;
if (operand instanceof VariableExpr) {
String hint = getHint(token);
if (hint != null && hint.equals(BROADCAST_JOIN_HINT)) {
broadcast = true;
}
}
op.addOperand(operand, broadcast);
} else {
;
}
{if (true) return op==null? operand: op;}
throw new Error("Missing return statement in function");
}
final public Expression AddExpr() throws ParseException, ParseException {
OperatorExpr op = null;
Expression operand = null;
operand = MultExpr();
label_7:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 33:
case 34:
;
break;
default:
jj_la1[18] = jj_gen;
break label_7;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 33:
jj_consume_token(33);
break;
case 34:
jj_consume_token(34);
break;
default:
jj_la1[19] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
if (op == null) {
op = new OperatorExpr();
op.addOperand(operand);
op.setCurrentop(true);
}
Token t = getToken(0);
((OperatorExpr)op).addOperator(t.toString());
operand = MultExpr();
op.addOperand(operand);
}
{if (true) return op==null? operand: op;}
throw new Error("Missing return statement in function");
}
final public Expression MultExpr() throws ParseException, ParseException {
OperatorExpr op = null;
Expression operand = null;
operand = UnionExpr();
label_8:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 35:
case 36:
case 37:
case 38:
case CARET:
;
break;
default:
jj_la1[20] = jj_gen;
break label_8;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 35:
jj_consume_token(35);
break;
case 36:
jj_consume_token(36);
break;
case 37:
jj_consume_token(37);
break;
case CARET:
jj_consume_token(CARET);
break;
case 38:
jj_consume_token(38);
break;
default:
jj_la1[21] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
if (op == null) {
op = new OperatorExpr();
op.addOperand(operand);
op.setCurrentop(true);
}
Token t = getToken(0);
op.addOperator(t.toString());
operand = UnionExpr();
op.addOperand(operand);
}
{if (true) return op==null?operand:op;}
throw new Error("Missing return statement in function");
}
final public Expression UnionExpr() throws ParseException, ParseException {
UnionExpr union = null;
Expression operand1 = null;
Expression operand2 = null;
operand1 = UnaryExpr();
label_9:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 39:
;
break;
default:
jj_la1[22] = jj_gen;
break label_9;
}
jj_consume_token(39);
operand2 = UnaryExpr();
if (union == null) {
union = new UnionExpr();
union.addExpr(operand1);
}
union.addExpr(operand2);
}
{if (true) return (union == null)? operand1: union;}
throw new Error("Missing return statement in function");
}
final public Expression UnaryExpr() throws ParseException, ParseException {
Expression uexpr = null;
Expression expr = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 33:
case 34:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 33:
jj_consume_token(33);
break;
case 34:
jj_consume_token(34);
break;
default:
jj_la1[23] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
uexpr = new UnaryExpr();
Token t = getToken(0);
if("+".equals(t.toString()))
((UnaryExpr)uexpr).setSign(Sign.POSITIVE);
else if("-".equals(t.toString()))
((UnaryExpr)uexpr).setSign(Sign.NEGATIVE);
else
{if (true) throw new ParseException();}
break;
default:
jj_la1[24] = jj_gen;
;
}
expr = ValueExpr();
if(uexpr!=null){
((UnaryExpr)uexpr).setExpr(expr);
{if (true) return uexpr;}
}
else{
{if (true) return expr;}
}
throw new Error("Missing return statement in function");
}
final public Expression ValueExpr() throws ParseException, ParseException {
Expression expr;
expr = FieldOrIndexAccessor();
{if (true) return expr;}
throw new Error("Missing return statement in function");
}
final public Expression FieldOrIndexAccessor() throws ParseException, ParseException {
Expression expr = null;
Identifier ident = null;
AbstractAccessor fa = null;
Expression indexExpr = null;
expr = PrimaryExpr();
label_10:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 23:
case 40:
;
break;
default:
jj_la1[25] = jj_gen;
break label_10;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 40:
ident = Field();
if(fa == null)
fa = new FieldAccessor(expr, ident);
else
fa = new FieldAccessor(fa, ident);
break;
case 23:
indexExpr = Index();
if(fa == null)
fa = new IndexAccessor(expr, indexExpr);
else
fa = new IndexAccessor(fa, indexExpr);
break;
default:
jj_la1[26] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
{if (true) return fa==null?expr:fa;}
throw new Error("Missing return statement in function");
}
final public Identifier Field() throws ParseException, ParseException {
Identifier ident = null;
jj_consume_token(40);
jj_consume_token(IDENTIFIER);
ident = new Identifier();
ident.setValue(getToken(0).toString());
{if (true) return ident;}
throw new Error("Missing return statement in function");
}
final public Expression Index() throws ParseException, ParseException {
Expression expr = null;
jj_consume_token(23);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 20:
case 23:
case 33:
case 34:
case 41:
case 43:
case 49:
case 52:
case 65:
case 66:
case DATASET:
case LEFTPAREN:
case INTEGER_LITERAL:
case NULL:
case TRUE:
case FALSE:
case DOUBLE_LITERAL:
case FLOAT_LITERAL:
case STRING_LITERAL:
case IDENTIFIER:
case VARIABLE:
case METAVARIABLECLAUSE:
case METAVARIABLE:
expr = Expression();
if(expr.getKind() == Expression.Kind.LITERAL_EXPRESSION)
{
Literal lit = ((LiteralExpr)expr).getValue();
if(lit.getLiteralType() != Literal.Type.INTEGER &&
lit.getLiteralType() != Literal.Type.LONG) {
{if (true) throw new ParseException("Index should be an INTEGER");}
}
}
break;
case 22:
jj_consume_token(22);
break;
default:
jj_la1[27] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
jj_consume_token(24);
{if (true) return expr;}
throw new Error("Missing return statement in function");
}
final public Expression PrimaryExpr() throws ParseException, ParseException {
Expression expr = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case INTEGER_LITERAL:
case NULL:
case TRUE:
case FALSE:
case DOUBLE_LITERAL:
case FLOAT_LITERAL:
case STRING_LITERAL:
expr = Literal();
break;
case DATASET:
case IDENTIFIER:
expr = FunctionCallExpr();
break;
case VARIABLE:
expr = VariableRef();
if(((VariableExpr)expr).getIsNewVar() == true)
{if (true) throw new ParseException("can't find variable " + ((VariableExpr)expr).getVar());}
break;
case 23:
case 41:
expr = ListConstructor();
break;
case 20:
expr = RecordConstructor();
break;
case LEFTPAREN:
expr = ParenthesizedExpression();
break;
case METAVARIABLE:
expr = MetaVariableRef();
break;
default:
jj_la1[28] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return expr;}
throw new Error("Missing return statement in function");
}
final public Expression Literal() throws ParseException, ParseException {
LiteralExpr lit = new LiteralExpr();
Token t;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STRING_LITERAL:
jj_consume_token(STRING_LITERAL);
t= getToken(0);
lit.setValue( new StringLiteral(removeQuotesAndEscapes(t.image)));
break;
case INTEGER_LITERAL:
jj_consume_token(INTEGER_LITERAL);
t= getToken(0);
try {
lit.setValue(new IntegerLiteral(new Integer(t.image)));
} catch(NumberFormatException ex) {
lit.setValue(new LongIntegerLiteral(new Long(t.image)));
}
break;
case FLOAT_LITERAL:
jj_consume_token(FLOAT_LITERAL);
t= getToken(0);
lit.setValue(new FloatLiteral(new Float(t.image)));
break;
case DOUBLE_LITERAL:
jj_consume_token(DOUBLE_LITERAL);
t= getToken(0);
lit.setValue(new DoubleLiteral(new Double(t.image)));
break;
case NULL:
jj_consume_token(NULL);
t= getToken(0);
lit.setValue(NullLiteral.INSTANCE);
break;
case TRUE:
jj_consume_token(TRUE);
t= getToken(0);
lit.setValue(TrueLiteral.INSTANCE);
break;
case FALSE:
jj_consume_token(FALSE);
t= getToken(0);
lit.setValue(FalseLiteral.INSTANCE);
break;
default:
jj_la1[29] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return lit;}
throw new Error("Missing return statement in function");
}
final public VariableExpr VariableRef() throws ParseException, ParseException {
VariableExpr varExp = new VariableExpr();
VarIdentifier var = new VarIdentifier();
Token t;
jj_consume_token(VARIABLE);
t = getToken(0);//get current token
String varName = t.toString();
Identifier ident = lookupSymbol(varName);
if (isInForbiddenScopes(varName)) {
{if (true) throw new ParseException("Inside limit clauses, it is disallowed to reference a variable having the same name as any variable bound in the same scope as the limit clause.");}
}
if(ident != null) { // exist such ident
varExp.setIsNewVar(false);
varExp.setVar((VarIdentifier)ident);
} else {
varExp.setVar(var);
}
var.setValue(t.toString());
{if (true) return varExp;}
throw new Error("Missing return statement in function");
}
final public VariableExpr Variable() throws ParseException, ParseException {
VariableExpr varExp = new VariableExpr();
VarIdentifier var = new VarIdentifier();
Token t;
jj_consume_token(VARIABLE);
t = getToken(0);//get current token
Identifier ident = lookupSymbol(t.toString());
if(ident != null) { // exist such ident
varExp.setIsNewVar(false);
}
varExp.setVar(var);
var.setValue(t.toString());
{if (true) return varExp;}
throw new Error("Missing return statement in function");
}
final public MetaVariableExpr MetaVariableRef() throws ParseException, ParseException {
MetaVariableExpr metaVarExp = new MetaVariableExpr();
VarIdentifier var = new VarIdentifier();
Token t;
jj_consume_token(METAVARIABLE);
t = getToken(0);//get current token
metaVarExp.setVar(var);
var.setValue(t.toString());
{if (true) return metaVarExp;}
throw new Error("Missing return statement in function");
}
final public Expression ListConstructor() throws ParseException, ParseException {
Expression expr = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 23:
expr = OrderedListConstructor();
break;
case 41:
expr = UnorderedListConstructor();
break;
default:
jj_la1[30] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return expr;}
throw new Error("Missing return statement in function");
}
final public ListConstructor OrderedListConstructor() throws ParseException, ParseException {
ListConstructor expr = new ListConstructor();
Expression tmp = null;
List exprList = new ArrayList();
expr.setType(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR);
jj_consume_token(23);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 20:
case 23:
case 33:
case 34:
case 41:
case 43:
case 49:
case 52:
case 65:
case 66:
case DATASET:
case LEFTPAREN:
case INTEGER_LITERAL:
case NULL:
case TRUE:
case FALSE:
case DOUBLE_LITERAL:
case FLOAT_LITERAL:
case STRING_LITERAL:
case IDENTIFIER:
case VARIABLE:
case METAVARIABLECLAUSE:
case METAVARIABLE:
tmp = Expression();
exprList.add(tmp);
label_11:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[31] = jj_gen;
break label_11;
}
jj_consume_token(15);
tmp = Expression();
exprList.add(tmp);
}
break;
default:
jj_la1[32] = jj_gen;
;
}
jj_consume_token(24);
expr.setExprList(exprList);
{if (true) return expr;}
throw new Error("Missing return statement in function");
}
final public ListConstructor UnorderedListConstructor() throws ParseException, ParseException {
ListConstructor expr = new ListConstructor();
Expression tmp = null;
List exprList = new ArrayList();
expr.setType(ListConstructor.Type.UNORDERED_LIST_CONSTRUCTOR);
jj_consume_token(41);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 20:
case 23:
case 33:
case 34:
case 41:
case 43:
case 49:
case 52:
case 65:
case 66:
case DATASET:
case LEFTPAREN:
case INTEGER_LITERAL:
case NULL:
case TRUE:
case FALSE:
case DOUBLE_LITERAL:
case FLOAT_LITERAL:
case STRING_LITERAL:
case IDENTIFIER:
case VARIABLE:
case METAVARIABLECLAUSE:
case METAVARIABLE:
tmp = Expression();
exprList.add(tmp);
label_12:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[33] = jj_gen;
break label_12;
}
jj_consume_token(15);
tmp = Expression();
exprList.add(tmp);
}
break;
default:
jj_la1[34] = jj_gen;
;
}
jj_consume_token(42);
expr.setExprList(exprList);
{if (true) return expr;}
throw new Error("Missing return statement in function");
}
final public RecordConstructor RecordConstructor() throws ParseException, ParseException {
RecordConstructor expr = new RecordConstructor();
FieldBinding tmp = null;
List fbList = new ArrayList();
jj_consume_token(20);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 20:
case 23:
case 33:
case 34:
case 41:
case 43:
case 49:
case 52:
case 65:
case 66:
case DATASET:
case LEFTPAREN:
case INTEGER_LITERAL:
case NULL:
case TRUE:
case FALSE:
case DOUBLE_LITERAL:
case FLOAT_LITERAL:
case STRING_LITERAL:
case IDENTIFIER:
case VARIABLE:
case METAVARIABLECLAUSE:
case METAVARIABLE:
tmp = FieldBinding();
fbList.add(tmp);
label_13:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[35] = jj_gen;
break label_13;
}
jj_consume_token(15);
tmp = FieldBinding();
fbList.add(tmp);
}
break;
default:
jj_la1[36] = jj_gen;
;
}
jj_consume_token(21);
expr.setFbList(fbList);
{if (true) return expr;}
throw new Error("Missing return statement in function");
}
final public FieldBinding FieldBinding() throws ParseException, ParseException {
FieldBinding fb = new FieldBinding();
Expression left, right;
left = Expression();
jj_consume_token(11);
right = Expression();
fb.setLeftExpr(left);
fb.setRightExpr(right);
{if (true) return fb;}
throw new Error("Missing return statement in function");
}
final public Expression FunctionCallExpr() throws ParseException, ParseException {
CallExpr callExpr;
List argList = new ArrayList();
Expression tmp;
int arity = 0;
String funcName;
String dataverse;
String hint=null;
String id1=null;
String id2=null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case IDENTIFIER:
jj_consume_token(IDENTIFIER);
dataverse = defaultDataverse; funcName = token.image;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 40:
jj_consume_token(40);
jj_consume_token(IDENTIFIER);
dataverse = funcName; funcName = token.image;
break;
default:
jj_la1[37] = jj_gen;
;
}
break;
case DATASET:
jj_consume_token(DATASET);
dataverse = MetadataConstants.METADATA_DATAVERSE_NAME; funcName = getToken(0).toString();
break;
default:
jj_la1[38] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
hint=getHint(token);
jj_consume_token(LEFTPAREN);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 20:
case 23:
case 33:
case 34:
case 41:
case 43:
case 49:
case 52:
case 65:
case 66:
case DATASET:
case LEFTPAREN:
case INTEGER_LITERAL:
case NULL:
case TRUE:
case FALSE:
case DOUBLE_LITERAL:
case FLOAT_LITERAL:
case STRING_LITERAL:
case IDENTIFIER:
case VARIABLE:
case METAVARIABLECLAUSE:
case METAVARIABLE:
tmp = Expression();
argList.add(tmp);
arity ++;
label_14:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[39] = jj_gen;
break label_14;
}
jj_consume_token(15);
tmp = Expression();
argList.add(tmp); arity++;
}
break;
default:
jj_la1[40] = jj_gen;
;
}
jj_consume_token(RIGHTPAREN);
FunctionSignature signature = lookupFunctionSignature(dataverse, funcName.toString(), arity);
if(signature == null)
{
signature = new FunctionSignature(dataverse, funcName.toString(), arity);
}
callExpr = new CallExpr(signature,argList);
if (hint != null && hint.startsWith(INDEXED_NESTED_LOOP_JOIN_HINT)) {
callExpr.addHint(IndexedNLJoinExpressionAnnotation.INSTANCE);
}
{if (true) return callExpr;}
throw new Error("Missing return statement in function");
}
final public Expression ParenthesizedExpression() throws ParseException, ParseException {
Expression expr;
jj_consume_token(LEFTPAREN);
expr = Expression();
jj_consume_token(RIGHTPAREN);
{if (true) return expr;}
throw new Error("Missing return statement in function");
}
final public Expression IfThenElse() throws ParseException, ParseException {
Expression condExpr;
Expression thenExpr;
Expression elseExpr;
IfExpr ifExpr = new IfExpr();
jj_consume_token(43);
jj_consume_token(LEFTPAREN);
condExpr = Expression();
jj_consume_token(RIGHTPAREN);
jj_consume_token(44);
thenExpr = Expression();
jj_consume_token(45);
elseExpr = Expression();
ifExpr.setCondExpr(condExpr);
ifExpr.setThenExpr(thenExpr);
ifExpr.setElseExpr(elseExpr);
{if (true) return ifExpr;}
throw new Error("Missing return statement in function");
}
final public Expression FLWOGR() throws ParseException, ParseException {
FLWOGRExpression flworg = new FLWOGRExpression();
List clauseList = new ArrayList();
Expression returnExpr;
Clause tmp;
createNewScope();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 49:
tmp = ForClause();
clauseList.add(tmp);
break;
case 52:
tmp = LetClause();
clauseList.add(tmp);
break;
case METAVARIABLECLAUSE:
tmp = MetaVariableClause();
clauseList.add(tmp);
break;
default:
jj_la1[41] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
label_15:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 47:
case 48:
case 49:
case 52:
case 54:
case 55:
case 59:
case 62:
case 64:
case METAVARIABLECLAUSE:
;
break;
default:
jj_la1[42] = jj_gen;
break label_15;
}
tmp = Clause();
clauseList.add(tmp);
}
jj_consume_token(46);
returnExpr = Expression();
flworg.setClauseList(clauseList);
flworg.setReturnExpr(returnExpr);
removeCurrentScope();
{if (true) return flworg;}
throw new Error("Missing return statement in function");
}
final public List Clauses() throws ParseException, ParseException {
List clauses = new ArrayList();
Clause c = null;
label_16:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 47:
case 48:
case 49:
case 52:
case 54:
case 55:
case 59:
case 62:
case 64:
case METAVARIABLECLAUSE:
;
break;
default:
jj_la1[43] = jj_gen;
break label_16;
}
c = Clause();
clauses.add(c);
}
{if (true) return clauses;}
throw new Error("Missing return statement in function");
}
final public Clause Clause() throws ParseException, ParseException {
Clause clause;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 49:
clause = ForClause();
break;
case 52:
clause = LetClause();
break;
case 54:
clause = WhereClause();
break;
case 55:
clause = OrderbyClause();
break;
case 59:
clause = GroupClause();
break;
case 62:
clause = LimitClause();
break;
case 64:
clause = DistinctClause();
break;
case METAVARIABLECLAUSE:
clause = MetaVariableClause();
break;
case 47:
case 48:
clause = JoinClause();
break;
default:
jj_la1[44] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return clause;}
throw new Error("Missing return statement in function");
}
final public Clause MetaVariableClause() throws ParseException, ParseException {
MetaVariableClause mc = new MetaVariableClause();
VarIdentifier var = new VarIdentifier();
Token t;
jj_consume_token(METAVARIABLECLAUSE);
t = getToken(0);
mc.setVar(var);
var.setValue(t.toString());
{if (true) return mc;}
throw new Error("Missing return statement in function");
}
final public Clause JoinClause() throws ParseException, ParseException {
Expression whereExpr;
List leftClauses, rightClauses;
JoinClause.JoinKind kind = JoinClause.JoinKind.INNER;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 47:
jj_consume_token(47);
break;
case 48:
jj_consume_token(48);
kind = JoinClause.JoinKind.LEFT_OUTER;
break;
default:
jj_la1[45] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
jj_consume_token(LEFTPAREN);
jj_consume_token(LEFTPAREN);
leftClauses = Clauses();
jj_consume_token(RIGHTPAREN);
jj_consume_token(15);
jj_consume_token(LEFTPAREN);
rightClauses = Clauses();
jj_consume_token(RIGHTPAREN);
jj_consume_token(15);
whereExpr = Expression();
jj_consume_token(RIGHTPAREN);
JoinClause jc = new JoinClause(kind);
jc.setLeftClauses(leftClauses);
jc.setRightClauses(rightClauses);
jc.setWhereExpr(whereExpr);
{if (true) return jc;}
throw new Error("Missing return statement in function");
}
final public Clause ForClause() throws ParseException, ParseException {
ForClause fc = new ForClause();
VariableExpr varExp;
VariableExpr varPos = null;
Expression inExp;
extendCurrentScope();
jj_consume_token(49);
varExp = Variable();
getCurrentScope().addNewVarSymbolToScope(varExp.getVar());
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 50:
jj_consume_token(50);
varPos = Variable();
getCurrentScope().addNewVarSymbolToScope(varPos.getVar());
break;
default:
jj_la1[46] = jj_gen;
;
}
jj_consume_token(51);
inExp = Expression();
fc.setVarExpr(varExp);
fc.setInExpr(inExp);
if (varPos != null) {
fc.setPosExpr(varPos);
}
{if (true) return fc;}
throw new Error("Missing return statement in function");
}
final public Clause LetClause() throws ParseException, ParseException {
LetClause lc = new LetClause();
VariableExpr varExp;
Expression beExp;
extendCurrentScope();
jj_consume_token(52);
varExp = Variable();
jj_consume_token(53);
beExp = Expression();
getCurrentScope().addNewVarSymbolToScope(varExp.getVar());
lc.setVarExpr(varExp);
lc.setBeExpr(beExp);
{if (true) return lc;}
throw new Error("Missing return statement in function");
}
final public Clause WhereClause() throws ParseException, ParseException {
WhereClause wc = new WhereClause();
Expression whereExpr;
jj_consume_token(54);
whereExpr = Expression();
wc.setWhereExpr(whereExpr);
{if (true) return wc;}
throw new Error("Missing return statement in function");
}
final public Clause OrderbyClause() throws ParseException, ParseException {
OrderbyClause oc = new OrderbyClause();
Expression orderbyExpr;
List orderbyList = new ArrayList();
List modifierList = new ArrayList();
int numOfOrderby = 0;
jj_consume_token(55);
String hint = getHint(token);
if (hint != null && hint.startsWith(INMEMORY_HINT)) {
String splits[] = hint.split(" +");
int numFrames = Integer.parseInt(splits[1]);
int numTuples = Integer.parseInt(splits[2]);
oc.setNumFrames(numFrames);
oc.setNumTuples(numTuples);
}
jj_consume_token(56);
orderbyExpr = Expression();
orderbyList.add(orderbyExpr);
OrderbyClause.OrderModifier modif = OrderbyClause.OrderModifier.ASC;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 57:
case 58:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 57:
jj_consume_token(57);
modif = OrderbyClause.OrderModifier.ASC;
break;
case 58:
jj_consume_token(58);
modif = OrderbyClause.OrderModifier.DESC;
break;
default:
jj_la1[47] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
jj_la1[48] = jj_gen;
;
}
modifierList.add(modif);
label_17:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[49] = jj_gen;
break label_17;
}
jj_consume_token(15);
orderbyExpr = Expression();
orderbyList.add(orderbyExpr);
modif = OrderbyClause.OrderModifier.ASC;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 57:
case 58:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 57:
jj_consume_token(57);
modif = OrderbyClause.OrderModifier.ASC;
break;
case 58:
jj_consume_token(58);
modif = OrderbyClause.OrderModifier.DESC;
break;
default:
jj_la1[50] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
jj_la1[51] = jj_gen;
;
}
modifierList.add(modif);
}
oc.setModifierList(modifierList);
oc.setOrderbyList(orderbyList);
{if (true) return oc;}
throw new Error("Missing return statement in function");
}
final public Clause GroupClause() throws ParseException, ParseException {
GroupbyClause gbc = new GroupbyClause();
// GbyVariableExpressionPair pair = new GbyVariableExpressionPair();
List vePairList = new ArrayList();
List decorPairList = new ArrayList();
List withVarList= new ArrayList();
VariableExpr var = null;
VariableExpr withVar = null;
Expression expr = null;
VariableExpr decorVar = null;
Expression decorExpr = null;
Scope newScope = extendCurrentScopeNoPush(true);
// extendCurrentScope(true);
jj_consume_token(59);
String hint = getHint(token);
if (hint != null && hint.equals(HASH_GROUP_BY_HINT)) {
gbc.setHashGroupByHint(true);
}
jj_consume_token(56);
if (jj_2_2(2)) {
var = Variable();
newScope.addNewVarSymbolToScope(var.getVar());
jj_consume_token(53);
} else {
;
}
expr = Expression();
GbyVariableExpressionPair pair1 = new GbyVariableExpressionPair(var, expr);
vePairList.add(pair1);
label_18:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[52] = jj_gen;
break label_18;
}
jj_consume_token(15);
if (jj_2_3(2)) {
var = Variable();
newScope.addNewVarSymbolToScope(var.getVar());
jj_consume_token(53);
} else {
;
}
expr = Expression();
GbyVariableExpressionPair pair2 = new GbyVariableExpressionPair(var, expr);
vePairList.add(pair2);
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 60:
jj_consume_token(60);
decorVar = Variable();
jj_consume_token(53);
decorExpr = Expression();
newScope.addNewVarSymbolToScope(decorVar.getVar());
GbyVariableExpressionPair pair3 = new GbyVariableExpressionPair(decorVar, decorExpr);
decorPairList.add(pair3);
label_19:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[53] = jj_gen;
break label_19;
}
jj_consume_token(15);
jj_consume_token(60);
decorVar = Variable();
jj_consume_token(53);
decorExpr = Expression();
newScope.addNewVarSymbolToScope(decorVar.getVar());
GbyVariableExpressionPair pair4 = new GbyVariableExpressionPair(decorVar, decorExpr);
decorPairList.add(pair4);
}
break;
default:
jj_la1[54] = jj_gen;
;
}
jj_consume_token(61);
withVar = VariableRef();
if(withVar.getIsNewVar()==true)
{if (true) throw new ParseException("can't find variable " + withVar.getVar());}
withVarList.add(withVar);
newScope.addNewVarSymbolToScope(withVar.getVar());
label_20:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[55] = jj_gen;
break label_20;
}
jj_consume_token(15);
withVar = VariableRef();
if(withVar.getIsNewVar()==true)
{if (true) throw new ParseException("can't find variable " + withVar.getVar());}
withVarList.add(withVar);
newScope.addNewVarSymbolToScope(withVar.getVar());
}
gbc.setGbyPairList(vePairList);
gbc.setDecorPairList(decorPairList);
gbc.setWithVarList(withVarList);
replaceCurrentScope(newScope);
{if (true) return gbc;}
throw new Error("Missing return statement in function");
}
final public LimitClause LimitClause() throws ParseException, ParseException {
LimitClause lc = new LimitClause();
Expression expr;
pushForbiddenScope(getCurrentScope());
jj_consume_token(62);
expr = Expression();
lc.setLimitExpr(expr);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 63:
jj_consume_token(63);
expr = Expression();
lc.setOffset(expr);
break;
default:
jj_la1[56] = jj_gen;
;
}
popForbiddenScope();
{if (true) return lc;}
throw new Error("Missing return statement in function");
}
final public DistinctClause DistinctClause() throws ParseException, ParseException {
List exprs = new ArrayList();
Expression expr;
jj_consume_token(64);
jj_consume_token(56);
expr = Expression();
exprs.add(expr);
label_21:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[57] = jj_gen;
break label_21;
}
jj_consume_token(15);
expr = Expression();
exprs.add(expr);
}
{if (true) return new DistinctClause(exprs);}
throw new Error("Missing return statement in function");
}
final public QuantifiedExpression QuantifiedExpression() throws ParseException, ParseException {
QuantifiedExpression qc = new QuantifiedExpression();
List quantifiedList = new ArrayList();
Expression satisfiesExpr;
VariableExpr var;
Expression inExpr;
QuantifiedPair pair;
createNewScope();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 65:
jj_consume_token(65);
qc.setQuantifier(QuantifiedExpression.Quantifier.SOME);
break;
case 66:
jj_consume_token(66);
qc.setQuantifier(QuantifiedExpression.Quantifier.EVERY);
break;
default:
jj_la1[58] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
var = Variable();
jj_consume_token(51);
inExpr = Expression();
pair = new QuantifiedPair(var, inExpr);
getCurrentScope().addNewVarSymbolToScope(var.getVar());
quantifiedList.add(pair);
label_22:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[59] = jj_gen;
break label_22;
}
jj_consume_token(15);
var = Variable();
jj_consume_token(51);
inExpr = Expression();
pair = new QuantifiedPair(var, inExpr);
getCurrentScope().addNewVarSymbolToScope(var.getVar());
quantifiedList.add(pair);
}
jj_consume_token(67);
satisfiesExpr = Expression();
qc.setSatisfiesExpr(satisfiesExpr);
qc.setQuantifiedList(quantifiedList);
removeCurrentScope();
{if (true) return qc;}
throw new Error("Missing return statement in function");
}
private boolean jj_2_1(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_1(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(0, xla); }
}
private boolean jj_2_2(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_2(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(1, xla); }
}
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_46() {
if (jj_scan_token(STRING_LITERAL)) return true;
return false;
}
private boolean jj_3R_39() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_46()) {
jj_scanpos = xsp;
if (jj_3R_47()) {
jj_scanpos = xsp;
if (jj_3R_48()) {
jj_scanpos = xsp;
if (jj_3R_49()) {
jj_scanpos = xsp;
if (jj_3R_50()) {
jj_scanpos = xsp;
if (jj_3R_51()) {
jj_scanpos = xsp;
if (jj_3R_52()) return true;
}
}
}
}
}
}
return false;
}
private boolean jj_3R_35() {
if (jj_3R_42()) return true;
return false;
}
private boolean jj_3R_38() {
if (jj_3R_45()) return true;
return false;
}
private boolean jj_3R_37() {
if (jj_3R_44()) return true;
return false;
}
private boolean jj_3R_36() {
if (jj_3R_43()) return true;
return false;
}
private boolean jj_3R_24() {
if (jj_scan_token(VARIABLE)) return true;
return false;
}
private boolean jj_3R_43() {
if (jj_scan_token(20)) return true;
return false;
}
private boolean jj_3R_30() {
if (jj_3R_31()) return true;
return false;
}
private boolean jj_3R_25() {
if (jj_3R_26()) return true;
return false;
}
private boolean jj_3R_34() {
if (jj_3R_41()) return true;
return false;
}
private boolean jj_3R_33() {
if (jj_3R_40()) return true;
return false;
}
private boolean jj_3R_32() {
if (jj_3R_39()) return true;
return false;
}
private boolean jj_3R_31() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_32()) {
jj_scanpos = xsp;
if (jj_3R_33()) {
jj_scanpos = xsp;
if (jj_3R_34()) {
jj_scanpos = xsp;
if (jj_3R_35()) {
jj_scanpos = xsp;
if (jj_3R_36()) {
jj_scanpos = xsp;
if (jj_3R_37()) {
jj_scanpos = xsp;
if (jj_3R_38()) return true;
}
}
}
}
}
}
return false;
}
private boolean jj_3R_58() {
if (jj_scan_token(41)) return true;
return false;
}
private boolean jj_3R_29() {
if (jj_3R_30()) return true;
return false;
}
private boolean jj_3R_44() {
if (jj_scan_token(LEFTPAREN)) return true;
return false;
}
private boolean jj_3R_56() {
if (jj_3R_58()) return true;
return false;
}
private boolean jj_3R_41() {
if (jj_scan_token(VARIABLE)) return true;
return false;
}
private boolean jj_3R_23() {
if (jj_3R_25()) return true;
return false;
}
private boolean jj_3_3() {
if (jj_3R_24()) return true;
if (jj_scan_token(53)) return true;
return false;
}
private boolean jj_3R_52() {
if (jj_scan_token(FALSE)) return true;
return false;
}
private boolean jj_3R_57() {
if (jj_scan_token(23)) return true;
return false;
}
private boolean jj_3R_28() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(33)) {
jj_scanpos = xsp;
if (jj_scan_token(34)) return true;
}
return false;
}
private boolean jj_3R_51() {
if (jj_scan_token(TRUE)) 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()) return true;
return false;
}
private boolean jj_3_2() {
if (jj_3R_24()) return true;
if (jj_scan_token(53)) return true;
return false;
}
private boolean jj_3R_54() {
if (jj_scan_token(DATASET)) return true;
return false;
}
private boolean jj_3R_50() {
if (jj_scan_token(NULL)) return true;
return false;
}
private boolean jj_3R_53() {
if (jj_scan_token(IDENTIFIER)) return true;
return false;
}
private boolean jj_3R_40() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_53()) {
jj_scanpos = xsp;
if (jj_3R_54()) return true;
}
return false;
}
private boolean jj_3R_55() {
if (jj_3R_57()) return true;
return false;
}
private boolean jj_3R_49() {
if (jj_scan_token(DOUBLE_LITERAL)) return true;
return false;
}
private boolean jj_3R_42() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_55()) {
jj_scanpos = xsp;
if (jj_3R_56()) return true;
}
return false;
}
private boolean jj_3R_48() {
if (jj_scan_token(FLOAT_LITERAL)) return true;
return false;
}
private boolean jj_3_1() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(25)) {
jj_scanpos = xsp;
if (jj_scan_token(26)) {
jj_scanpos = xsp;
if (jj_scan_token(29)) {
jj_scanpos = xsp;
if (jj_scan_token(30)) {
jj_scanpos = xsp;
if (jj_scan_token(14)) {
jj_scanpos = xsp;
if (jj_scan_token(31)) {
jj_scanpos = xsp;
if (jj_scan_token(32)) return true;
}
}
}
}
}
}
if (jj_3R_23()) return true;
return false;
}
private boolean jj_3R_26() {
if (jj_3R_27()) return true;
return false;
}
private boolean jj_3R_47() {
if (jj_scan_token(INTEGER_LITERAL)) return true;
return false;
}
private boolean jj_3R_45() {
if (jj_scan_token(METAVARIABLE)) return true;
return false;
}
/** Generated Token Manager. */
public AQLPlusParserTokenManager token_source;
SimpleCharStream jj_input_stream;
/** 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;
private int jj_gen;
final private int[] jj_la1 = new int[60];
static private int[] jj_la1_0;
static private int[] jj_la1_1;
static private int[] jj_la1_2;
static private int[] jj_la1_3;
static {
jj_la1_init_0();
jj_la1_init_1();
jj_la1_init_2();
jj_la1_init_3();
}
private static void jj_la1_init_0() {
jj_la1_0 = new int[] {0x1e6,0x18,0x1e6,0x8000,0x0,0x10000,0x29c0000,0xc0000,0xc0000,0x8000,0x0,0x400000,0x8000,0x0,0x900000,0x8000000,0x10000000,0xe6004000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x800000,0x800000,0xd00000,0x900000,0x0,0x800000,0x8000,0x900000,0x8000,0x900000,0x8000,0x900000,0x0,0x0,0x8000,0x900000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8000,0x0,0x0,0x8000,0x8000,0x0,0x8000,0x0,0x8000,0x0,0x8000,};
}
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,0x120a06,0x0,0x0,0x1,0x6,0x6,0x78,0x78,0x80,0x6,0x6,0x100,0x100,0x120a06,0x200,0x0,0x200,0x0,0x120a06,0x0,0x120a06,0x0,0x120a06,0x100,0x0,0x0,0x120a06,0x120000,0x48d38000,0x48d38000,0x48d38000,0x18000,0x40000,0x6000000,0x6000000,0x0,0x6000000,0x6000000,0x0,0x0,0x10000000,0x0,0x80000000,0x0,0x0,0x0,};
}
private static void jj_la1_init_2() {
jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x40,0x0,0x200000,0x0,0x0,0x0,0x200000,0x0,0x0,0x400000,0x1e46f66,0x0,0x0,0x0,0x0,0x0,0x10,0x10,0x0,0x0,0x0,0x0,0x0,0x1e46f66,0x1646f60,0x46f00,0x0,0x0,0x1e46f66,0x0,0x1e46f66,0x0,0x1e46f66,0x0,0x200020,0x0,0x1e46f66,0x800000,0x800001,0x800001,0x800001,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,};
}
private static void jj_la1_init_3() {
jj_la1_3 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,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 InputStream. */
public AQLPlusParser(java.io.InputStream stream) {
this(stream, null);
}
/** Constructor with InputStream and supplied encoding */
public AQLPlusParser(java.io.InputStream stream, String encoding) {
try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source = new AQLPlusParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 60; 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(java.io.InputStream stream) {
ReInit(stream, null);
}
/** Reinitialise. */
public void ReInit(java.io.InputStream stream, String encoding) {
try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 60; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
/** Constructor. */
public AQLPlusParser(java.io.Reader stream) {
jj_input_stream = new SimpleCharStream(stream, 1, 1);
token_source = new AQLPlusParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 60; 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(java.io.Reader stream) {
jj_input_stream.ReInit(stream, 1, 1);
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 60; 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 AQLPlusParser(AQLPlusParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 60; 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(AQLPlusParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 60; 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();
}
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;
}
/** 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;
}
/** 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;
}
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.List jj_expentries = new java.util.ArrayList();
private int[] jj_expentry;
private int jj_kind = -1;
private int[] jj_lasttokens = new int[100];
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;
}
}
/** Generate ParseException. */
public ParseException generateParseException() {
jj_expentries.clear();
boolean[] la1tokens = new boolean[100];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 60; 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;
}
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;
}
static final class JJCalls {
int gen;
Token first;
int arg;
JJCalls next;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy