Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A9A06200B6B for ; Fri, 9 Sep 2016 22:41:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A82FC160AC2; Fri, 9 Sep 2016 20:41:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3C1FE160ADA for ; Fri, 9 Sep 2016 22:41:43 +0200 (CEST) Received: (qmail 65081 invoked by uid 500); 9 Sep 2016 20:41:42 -0000 Mailing-List: contact commits-help@asterixdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.apache.org Delivered-To: mailing list commits@asterixdb.apache.org Received: (qmail 64766 invoked by uid 99); 9 Sep 2016 20:41:41 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Sep 2016 20:41:41 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B8A41EEE1C; Fri, 9 Sep 2016 20:41:40 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sjaco002@apache.org To: commits@asterixdb.apache.org Date: Fri, 09 Sep 2016 20:41:46 -0000 Message-Id: <4bfac04c581a46f289e15eb90fd78a5a@git.apache.org> In-Reply-To: <76a1cf3d484e48789247beba48deb69c@git.apache.org> References: <76a1cf3d484e48789247beba48deb69c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [07/12] asterixdb-bad git commit: Initial commit archived-at: Fri, 09 Sep 2016 20:41:45 -0000 http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/bdba1b86/target/generated-resources/javacc/grammar.jj ---------------------------------------------------------------------- diff --git a/target/generated-resources/javacc/grammar.jj b/target/generated-resources/javacc/grammar.jj new file mode 100644 index 0000000..ad77885 --- /dev/null +++ b/target/generated-resources/javacc/grammar.jj @@ -0,0 +1,2949 @@ +options{ + + + STATIC = false; + +} +PARSER_BEGIN(BADAQLParser) + +package org.apache.asterix.bad.lang; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.apache.asterix.bad.lang.statement.BrokerDropStatement; +import org.apache.asterix.bad.lang.statement.ChannelDropStatement; +import org.apache.asterix.bad.lang.statement.ChannelSubscribeStatement; +import org.apache.asterix.bad.lang.statement.ChannelUnsubscribeStatement; +import org.apache.asterix.bad.lang.statement.CreateBrokerStatement; +import org.apache.asterix.bad.lang.statement.CreateChannelStatement; +import org.apache.asterix.common.annotations.AutoDataGen; +import org.apache.asterix.common.annotations.DateBetweenYearsDataGen; +import org.apache.asterix.common.annotations.DatetimeAddRandHoursDataGen; +import org.apache.asterix.common.annotations.DatetimeBetweenYearsDataGen; +import org.apache.asterix.common.annotations.FieldIntervalDataGen; +import org.apache.asterix.common.annotations.FieldValFileDataGen; +import org.apache.asterix.common.annotations.FieldValFileSameIndexDataGen; +import org.apache.asterix.common.annotations.IRecordFieldDataGen; +import org.apache.asterix.common.annotations.InsertRandIntDataGen; +import org.apache.asterix.common.annotations.ListDataGen; +import org.apache.asterix.common.annotations.ListValFileDataGen; +import org.apache.asterix.common.annotations.SkipSecondaryIndexSearchExpressionAnnotation; +import org.apache.asterix.common.annotations.TypeDataGen; +import org.apache.asterix.common.annotations.UndeclaredFieldsDataGen; +import org.apache.asterix.common.config.DatasetConfig.DatasetType; +import org.apache.asterix.common.config.DatasetConfig.IndexType; +import org.apache.asterix.common.exceptions.AsterixException; +import org.apache.asterix.common.functions.FunctionSignature; +import org.apache.asterix.lang.aql.clause.DistinctClause; +import org.apache.asterix.lang.aql.clause.ForClause; +import org.apache.asterix.lang.aql.expression.FLWOGRExpression; +import org.apache.asterix.lang.aql.expression.UnionExpr; +import org.apache.asterix.lang.aql.util.RangeMapBuilder; +import org.apache.asterix.lang.common.base.Clause; +import org.apache.asterix.lang.common.base.Expression; +import org.apache.asterix.lang.common.base.IParser; +import org.apache.asterix.lang.common.base.Literal; +import org.apache.asterix.lang.common.base.Statement; +import org.apache.asterix.lang.common.clause.GroupbyClause; +import org.apache.asterix.lang.common.clause.LetClause; +import org.apache.asterix.lang.common.clause.LimitClause; +import org.apache.asterix.lang.common.clause.OrderbyClause; +import org.apache.asterix.lang.common.clause.UpdateClause; +import org.apache.asterix.lang.common.clause.WhereClause; +import org.apache.asterix.lang.common.context.RootScopeFactory; +import org.apache.asterix.lang.common.context.Scope; +import org.apache.asterix.lang.common.expression.AbstractAccessor; +import org.apache.asterix.lang.common.expression.CallExpr; +import org.apache.asterix.lang.common.expression.FieldAccessor; +import org.apache.asterix.lang.common.expression.FieldBinding; +import org.apache.asterix.lang.common.expression.GbyVariableExpressionPair; +import org.apache.asterix.lang.common.expression.IfExpr; +import org.apache.asterix.lang.common.expression.IndexAccessor; +import org.apache.asterix.lang.common.expression.ListConstructor; +import org.apache.asterix.lang.common.expression.LiteralExpr; +import org.apache.asterix.lang.common.expression.OperatorExpr; +import org.apache.asterix.lang.common.expression.OrderedListTypeDefinition; +import org.apache.asterix.lang.common.expression.QuantifiedExpression; +import org.apache.asterix.lang.common.expression.RecordConstructor; +import org.apache.asterix.lang.common.expression.RecordTypeDefinition; +import org.apache.asterix.lang.common.expression.TypeExpression; +import org.apache.asterix.lang.common.expression.TypeReferenceExpression; +import org.apache.asterix.lang.common.expression.UnaryExpr; +import org.apache.asterix.lang.common.expression.UnorderedListTypeDefinition; +import org.apache.asterix.lang.common.expression.VariableExpr; +import org.apache.asterix.lang.common.literal.DoubleLiteral; +import org.apache.asterix.lang.common.literal.FalseLiteral; +import org.apache.asterix.lang.common.literal.FloatLiteral; +import org.apache.asterix.lang.common.literal.LongIntegerLiteral; +import org.apache.asterix.lang.common.literal.MissingLiteral; +import org.apache.asterix.lang.common.literal.NullLiteral; +import org.apache.asterix.lang.common.literal.StringLiteral; +import org.apache.asterix.lang.common.literal.TrueLiteral; +import org.apache.asterix.lang.common.parser.ScopeChecker; +import org.apache.asterix.lang.common.statement.CompactStatement; +import org.apache.asterix.lang.common.statement.ConnectFeedStatement; +import org.apache.asterix.lang.common.statement.CreateDataverseStatement; +import org.apache.asterix.lang.common.statement.CreateFeedPolicyStatement; +import org.apache.asterix.lang.common.statement.CreateFeedStatement; +import org.apache.asterix.lang.common.statement.CreateFunctionStatement; +import org.apache.asterix.lang.common.statement.CreateIndexStatement; +import org.apache.asterix.lang.common.statement.CreatePrimaryFeedStatement; +import org.apache.asterix.lang.common.statement.CreateSecondaryFeedStatement; +import org.apache.asterix.lang.common.statement.DatasetDecl; +import org.apache.asterix.lang.common.statement.DataverseDecl; +import org.apache.asterix.lang.common.statement.DataverseDropStatement; +import org.apache.asterix.lang.common.statement.DeleteStatement; +import org.apache.asterix.lang.common.statement.DisconnectFeedStatement; +import org.apache.asterix.lang.common.statement.DropDatasetStatement; +import org.apache.asterix.lang.common.statement.ExternalDetailsDecl; +import org.apache.asterix.lang.common.statement.FeedDropStatement; +import org.apache.asterix.lang.common.statement.FeedPolicyDropStatement; +import org.apache.asterix.lang.common.statement.FunctionDecl; +import org.apache.asterix.lang.common.statement.FunctionDropStatement; +import org.apache.asterix.lang.common.statement.IndexDropStatement; +import org.apache.asterix.lang.common.statement.InsertStatement; +import org.apache.asterix.lang.common.statement.InternalDetailsDecl; +import org.apache.asterix.lang.common.statement.LoadStatement; +import org.apache.asterix.lang.common.statement.NodeGroupDropStatement; +import org.apache.asterix.lang.common.statement.NodegroupDecl; +import org.apache.asterix.lang.common.statement.Query; +import org.apache.asterix.lang.common.statement.RefreshExternalDatasetStatement; +import org.apache.asterix.lang.common.statement.RunStatement; +import org.apache.asterix.lang.common.statement.SetStatement; +import org.apache.asterix.lang.common.statement.TypeDecl; +import org.apache.asterix.lang.common.statement.TypeDropStatement; +import org.apache.asterix.lang.common.statement.UpdateStatement; +import org.apache.asterix.lang.common.statement.UpsertStatement; +import org.apache.asterix.lang.common.statement.WriteStatement; +import org.apache.asterix.lang.common.struct.Identifier; +import org.apache.asterix.lang.common.struct.QuantifiedPair; +import org.apache.asterix.lang.common.struct.VarIdentifier; +import org.apache.asterix.metadata.utils.MetadataConstants; +import org.apache.hyracks.algebricks.common.utils.Pair; +import org.apache.hyracks.algebricks.common.utils.Triple; +import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionAnnotation; +import org.apache.hyracks.algebricks.core.algebra.expressions.IndexedNLJoinExpressionAnnotation; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.xerces.util.IntStack; + +class BADAQLParser extends ScopeChecker implements IParser { + + // optimizer hints + private static final String AUTO_HINT = "auto"; + private static final String BROADCAST_JOIN_HINT = "bcast"; + private static final String COMPOSE_VAL_FILES_HINT = "compose-val-files"; + private static final String DATE_BETWEEN_YEARS_HINT = "date-between-years"; + private static final String DATETIME_ADD_RAND_HOURS_HINT = "datetime-add-rand-hours"; + private static final String DATETIME_BETWEEN_YEARS_HINT = "datetime-between-years"; + private static final String HASH_GROUP_BY_HINT = "hash"; + private static final String INDEXED_NESTED_LOOP_JOIN_HINT = "indexnl"; + private static final String INMEMORY_HINT = "inmem"; + private static final String INSERT_RAND_INT_HINT = "insert-rand-int"; + private static final String INTERVAL_HINT = "interval"; + private static final String LIST_HINT = "list"; + private static final String LIST_VAL_FILE_HINT = "list-val-file"; + private static final String RANGE_HINT = "range"; + private static final String SKIP_SECONDARY_INDEX_SEARCH_HINT = "skip-index"; + private static final String VAL_FILE_HINT = "val-files"; + private static final String VAL_FILE_SAME_INDEX_HINT = "val-file-same-idx"; + private static final String GEN_FIELDS_HINT = "gen-fields"; + // data generator hints + private static final String DGEN_HINT = "dgen"; + + private static class IndexParams { + public IndexType type; + public int gramLength; + + public IndexParams(IndexType type, int gramLength) { + this.type = type; + this.gramLength = gramLength; + } + }; + + private static class FunctionName { + public String dataverse = null; + public String library = null; + public String function = null; + public String hint = null; + } + + 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(); + } + + private static IRecordFieldDataGen parseFieldDataGen(String hint) throws ParseException { + IRecordFieldDataGen rfdg = null; + String splits[] = hint.split(" +"); + if (splits[0].equals(VAL_FILE_HINT)) { + File[] valFiles = new File[splits.length - 1]; + for (int k=1; k st = parser.parse(); + //st.accept(new AQLPrintVisitor(), 0); + } + + public List parse() throws AsterixException { + try { + return Statement(); + } catch (Error e) { + // this is here as the JavaCharStream that's below the lexer somtimes throws Errors that are not handled + // by the ANTLR-generated lexer or parser (e.g it does this for invalid backslash u + 4 hex digits escapes) + throw new AsterixException(new ParseException(e.getMessage())); + } catch (ParseException e){ + throw new AsterixException(e.getMessage()); + } + } +} + +PARSER_END(BADAQLParser) + + +LimitClause LimitClause() throws ParseException: +{ + LimitClause lc = new LimitClause(); + Expression expr; + pushForbiddenScope(getCurrentScope()); +} +{ + expr = Expression() { lc.setLimitExpr(expr); } + ( expr = Expression() { lc.setOffset(expr); })? + + { + popForbiddenScope(); + return lc; + } +} + +String StringLiteral() throws ParseException: +{ +} +{ + + { + return removeQuotesAndEscapes(token.image); + } +} + +RefreshExternalDatasetStatement RefreshExternalDatasetStatement() throws ParseException: +{ + RefreshExternalDatasetStatement redss = new RefreshExternalDatasetStatement(); + Pair nameComponents = null; + String datasetName = null; +} +{ + ( + nameComponents = QualifiedName() + { + redss.setDataverseName(nameComponents.first); + redss.setDatasetName(nameComponents.second); + return redss; + } + ) +} + +Statement CompactStatement() throws ParseException: +{ + Pair nameComponents = null; + Statement stmt = null; +} +{ + nameComponents = QualifiedName() + { + stmt = new CompactStatement(nameComponents.first, nameComponents.second); + } + { + return stmt; + } +} + +Expression AndExpr() throws ParseException: +{ + OperatorExpr op = null; + Expression operand = null; +} +{ + operand = RelExpr() + ( + + + { + if (op == null) { + op = new OperatorExpr(); + op.addOperand(operand); + op.setCurrentop(true); + } + try{ + op.addOperator(token.image); + } catch (AsterixException e){ + throw new ParseException(e.getMessage()); + } + } + + operand = RelExpr() + { + op.addOperand(operand); + } + + )* + + { + return op==null? operand: op; + } +} + +TypeDecl TypeSpecification(String hint, boolean dgen) throws ParseException: +{ + Pair nameComponents = null; + boolean ifNotExists = false; + TypeExpression typeExpr = null; +} +{ + nameComponents = TypeName() ifNotExists = IfNotExists() + typeExpr = TypeExpr() + { + long numValues = -1; + String filename = null; + if (dgen) { + String splits[] = hint.split(" +"); + if (splits.length != 3) { + throw new ParseException("Expecting /*+ dgen */"); + } + filename = splits[1]; + numValues = Long.parseLong(splits[2]); + } + TypeDataGen tddg = new TypeDataGen(dgen, filename, numValues); + return new TypeDecl(nameComponents.first, nameComponents.second, typeExpr, tddg, ifNotExists); + } +} + +TOKEN_MGR_DECLS: +{ + public int commentDepth = 0; + public IntStack lexerStateStack = new IntStack(); + + public void pushState() { + lexerStateStack.push( curLexState ); + } + + public void popState(String token) { + if (lexerStateStack.size() > 0) { + SwitchTo( lexerStateStack.pop() ); + } else { + int errorLine = input_stream.getEndLine(); + int errorColumn = input_stream.getEndColumn(); + String msg = "Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered \"" + token + + "\" but state stack is empty."; + throw new TokenMgrError(msg, -1); + } + } +} + +Statement WriteStatement() throws ParseException: +{ + String nodeName = null; + String fileName = null; + Query query; + String writerClass = null; + Pair nameComponents = null; +} +{ + nodeName = Identifier() fileName = StringLiteral() + ( writerClass = StringLiteral() )? + { + return new WriteStatement(new Identifier(nodeName), fileName, writerClass); + } +} + +Pair, TypeExpression>>OpenField() throws ParseException: +{ + TypeExpression fieldType = null; + Pair> fieldList = null; +} +{ + fieldList = NestedField() + ( fieldType = IndexedTypeExpr() )? + { + return new Pair, TypeExpression>> + (fieldList.first, new Pair, TypeExpression>(fieldList.second, fieldType)); + } +} + +boolean IfExists() throws ParseException: +{ +} +{ + ( + LOOKAHEAD(1) + + { + return true; + } + )? + { + return false; + } +} + +Expression Index() throws ParseException: +{ + Expression expr = null; +} +{ + ( 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) { + throw new ParseException("Index should be an INTEGER"); + } + } + } + + | // ANY + + ) + + + { + return expr; + } +} + +IndexParams IndexType() throws ParseException: +{ + IndexType type = null; + int gramLength = 0; +} +{ + ( + + { + type = IndexType.BTREE; + } + | + { + type = IndexType.RTREE; + } + | + { + type = IndexType.LENGTH_PARTITIONED_WORD_INVIX; + } + | + { + type = IndexType.LENGTH_PARTITIONED_NGRAM_INVIX; + gramLength = Integer.valueOf(token.image); + } + + ) + { + return new IndexParams(type, gramLength); + } +} + +CreateBrokerStatement BrokerSpecification() throws ParseException: +{ + CreateBrokerStatement cbs = null; + Pair name = null; + String endPoint = null; +} +{ + ( + name = QualifiedName() + endPoint = StringLiteral() + { + cbs = new CreateBrokerStatement(name.first, name.second,endPoint); + } + ) + { + return cbs; + } +} + +FunctionDecl FunctionDeclaration() throws ParseException: +{ + FunctionDecl funcDecl; + FunctionSignature signature; + String functionName; + List paramList = new ArrayList(); + Expression funcBody; + createNewScope(); +} +{ + functionName = Identifier() + paramList = ParameterList() + funcBody = Expression() + { + signature = new FunctionSignature(defaultDataverse, functionName, paramList.size()); + getCurrentScope().addFunctionDescriptor(signature, false); + funcDecl = new FunctionDecl(signature, paramList, funcBody); + removeCurrentScope(); + return funcDecl; + } +} + +TripleDoubleQualifiedName() throws ParseException: +{ + String first = null; + String second = null; + String third = null; +} +{ + first = Identifier() second = Identifier() ( third = Identifier())? + { + Identifier id1 = null; + Identifier id2 = null; + Identifier id3 = null; + if (third == null) { + id2 = new Identifier(first); + id3 = new Identifier(second); + } else { + id1 = new Identifier(first); + id2 = new Identifier(second); + id3 = new Identifier(third); + } + return new Triple(id1, id2, id3); + } +} + +Expression MultExpr() throws ParseException: +{ + OperatorExpr op = null; + Expression operand = null; +} +{ + operand = ExponentExpr() + + (( |
| | ) + { + if (op == null) { + op = new OperatorExpr(); + op.addOperand(operand); + op.setCurrentop(true); + } + try{ + op.addOperator(token.image); + } catch (AsterixException e){ + throw new ParseException(e.getMessage()); + } + } + operand = ExponentExpr() + { + op.addOperand(operand); + } + )* + + { + return op==null?operand:op; + } +} + +InsertStatement InsertStatement() throws ParseException: +{ + Pair nameComponents = null; + Pair> returnField = new Pair>(0, null); + boolean returnRecord = false; + Query query; + boolean upsert = false; +} +{ + (|{ upsert = true; }) nameComponents = QualifiedName() + query = Query() ( "records"{returnRecord = true;} | "returning" returnField = NestedField())? + { + query.setTopLevel(true); + if(upsert){ + return new UpsertStatement(nameComponents.first, nameComponents.second, query, getVarCounter()); + } else{ + return new InsertStatement(nameComponents.first, nameComponents.second, query, getVarCounter(), + returnRecord, returnField.second); + } + } +} + +Expression FunctionCallExpr() throws ParseException: +{ + CallExpr callExpr; + List argList = new ArrayList(); + Expression tmp; + int arity = 0; + FunctionName funcName = null; + String hint = null; +} +{ + funcName = FunctionName() + { + hint = funcName.hint; + } + (tmp = Expression() + { + argList.add(tmp); + arity ++; + } + ( tmp = Expression() + { + argList.add(tmp); + arity++; + } + )*)? + { + // TODO use funcName.library + String fqFunctionName = funcName.library == null ? funcName.function : funcName.library + "#" + funcName.function; + FunctionSignature signature + = lookupFunctionSignature(funcName.dataverse, fqFunctionName, arity); + if (signature == null) { + signature = new FunctionSignature(funcName.dataverse, fqFunctionName, arity); + } + callExpr = new CallExpr(signature,argList); + if (hint != null) { + if (hint.startsWith(INDEXED_NESTED_LOOP_JOIN_HINT)) { + callExpr.addHint(IndexedNLJoinExpressionAnnotation.INSTANCE); + } else if (hint.startsWith(SKIP_SECONDARY_INDEX_SEARCH_HINT)) { + callExpr.addHint(SkipSecondaryIndexSearchExpressionAnnotation.INSTANCE); + } + } + return callExpr; + } +} + +Clause Clause() throws ParseException: +{ + Clause clause; +} +{ + ( + clause = ForClause() + | clause = LetClause() + | clause = WhereClause() + | clause = OrderbyClause() + | clause = GroupClause() + | clause = LimitClause() + | clause = DistinctClause() + ) + { + return clause; + } +} + +Pair>NestedField() throws ParseException: +{ + List exprList = new ArrayList(); + String lit = null; + int source = 0; +} +{ + lit = Identifier() + { + boolean meetParens = false; + } + ( + LOOKAHEAD(1) + + { + if(!lit.equals("meta")){ + throw new ParseException("The string before () has to be \"meta\"."); + } + meetParens = true; + source = 1; + } + )? + { + if(!meetParens){ + exprList.add(lit); + } + } + ( + lit = Identifier() + { + exprList.add(lit); + } + )* + { + return new Pair>(source, exprList); + } +} + +Expression Literal() throws ParseException: +{ + LiteralExpr lit = new LiteralExpr(); + String str = null; +} +{ + ( str = StringLiteral() + { + lit.setValue(new StringLiteral(str)); + } + | + { + lit.setValue(new LongIntegerLiteral(new Long(token.image))); + } + | + { + lit.setValue(new FloatLiteral(new Float(token.image))); + } + | + { + lit.setValue(new DoubleLiteral(new Double(token.image))); + } + | + { + lit.setValue(MissingLiteral.INSTANCE); + } + | + { + lit.setValue(NullLiteral.INSTANCE); + } + | + { + lit.setValue(TrueLiteral.INSTANCE); + } + | + { + lit.setValue(FalseLiteral.INSTANCE); + } + ) + { + return lit; + } +} + +Expression OperatorExpr() throws ParseException: +{ + OperatorExpr op = null; + Expression operand = null; +} +{ + operand = AndExpr() + ( + + + { + if (op == null) { + op = new OperatorExpr(); + op.addOperand(operand); + op.setCurrentop(true); + } + try{ + op.addOperator(token.image); + } catch (AsterixException e){ + throw new ParseException(e.getMessage()); + } + } + + operand = AndExpr() + { + op.addOperand(operand); + } + + )* + + { + return op==null? operand: op; + } +} + +Expression AddExpr() throws ParseException: +{ + OperatorExpr op = null; + Expression operand = null; +} +{ + operand = MultExpr() + + ( ( | ) + { + if (op == null) { + op = new OperatorExpr(); + op.addOperand(operand); + op.setCurrentop(true); + } + try{ + ((OperatorExpr)op).addOperator(token.image); + } catch (AsterixException e){ + throw new ParseException(e.getMessage()); + } + } + + operand = MultExpr() + { + op.addOperand(operand); + } + )* + + { + return op==null? operand: op; + } +} + +Statement SetStatement() throws ParseException: +{ + String pn = null; + String pv = null; +} +{ + pn = Identifier() pv = StringLiteral() + { + return new SetStatement(pn, pv); + } +} + +RunStatement RunStatement() throws ParseException: +{ + String system = null; + String tmp; + ArrayList parameters = new ArrayList(); + Pair nameComponentsFrom = null; + Pair nameComponentsTo = null; +} +{ + system = Identifier() ( tmp = Identifier() [] + { + parameters.add(tmp); + } + )* + nameComponentsFrom = QualifiedName() + nameComponentsTo = QualifiedName() + { + return new RunStatement(system, parameters, nameComponentsFrom.first, nameComponentsFrom.second, nameComponentsTo.first, nameComponentsTo.second); + } +} + +ListStatement() throws ParseException: +{ + scopeStack.push(RootScopeFactory.createRootScope(this)); + List decls = new ArrayList(); + Statement stmt = null; +} +{ + ( stmt = SingleStatement() (";") ? + { + decls.add(stmt); + } + )* + + { + return decls; + } +} + +String GetPolicy() throws ParseException: +{ + String policy = null; +} +{ + policy = Identifier() + { + return policy; + } + +} + +Expression FLWOGR() throws ParseException: +{ + FLWOGRExpression flworg = new FLWOGRExpression(); + List clauseList = new ArrayList(); + Expression returnExpr; + Clause tmp; + createNewScope(); +} +{ + (tmp = ForClause() {clauseList.add(tmp);} | tmp = LetClause() {clauseList.add(tmp);}) + (tmp = Clause() {clauseList.add(tmp);})* (| + | + | + | + | + | + | + | + | + | + | + | + | + | + | +} +< DEFAULT,IN_DBL_BRACE > + TOKEN : +{ + + |
+ | + | + | + | + | + + | + | + | + | + + | + | + | + | + + | + | "> + | ="> + | + | + + | + | +} +< DEFAULT,IN_DBL_BRACE > + TOKEN : +{ + { pushState(); } : DEFAULT +} +< DEFAULT > + TOKEN : +{ + { popState("}"); } +} +< DEFAULT,IN_DBL_BRACE > + TOKEN : +{ + { pushState(); } : IN_DBL_BRACE +} +< IN_DBL_BRACE > + TOKEN : +{ + { popState("}}"); } +} +< DEFAULT,IN_DBL_BRACE > + TOKEN : +{ + )+ > +} +< DEFAULT,IN_DBL_BRACE > + TOKEN : +{ + < MISSING : "missing"> + | + | + | +} +< DEFAULT,IN_DBL_BRACE > + TOKEN : +{ + <#DIGIT : ["0" - "9"]> +} +< DEFAULT,IN_DBL_BRACE > + TOKEN : +{ + < DOUBLE_LITERAL: + | ( "." )? + | "." + > + | < FLOAT_LITERAL: ( "f" | "F" ) + | ( "." ( "f" | "F" ) )? + | "." ( "f" | "F" ) + > + | )+ > +} +< DEFAULT,IN_DBL_BRACE > + TOKEN : +{ + <#LETTER : ["A" - "Z", "a" - "z"]> + | +} +< DEFAULT,IN_DBL_BRACE > + TOKEN : +{ + // backslash u + 4 hex digits escapes are handled in the underlying JavaCharStream + + | + | + | + | + | + | + | + | ~["\"","\\"])* "\"") + | ("\'"( + + | + | + | + | + | + | + | + | ~["\'","\\"])* "\'")> + | < #EscapeQuot: "\\\"" > + | < #EscapeApos: "\\\'" > + | < #EscapeBslash: "\\\\" > + | < #EscapeSlash: "\\/" > + | < #EscapeBspace: "\\b" > + | < #EscapeFormf: "\\f" > + | < #EscapeNl: "\\n" > + | < #EscapeCr: "\\r" > + | < #EscapeTab: "\\t" > +} +< DEFAULT,IN_DBL_BRACE > + TOKEN : +{ + ( | | )*> +} +< DEFAULT,IN_DBL_BRACE > + TOKEN : +{ + ( | | "_")*> +} +< DEFAULT,IN_DBL_BRACE > + SKIP : +{ + " " + | "\t" + | "\r" + | "\n" +} +< DEFAULT,IN_DBL_BRACE > + SKIP : +{ + <"//" (~["\n"])* "\n"> +} +< DEFAULT,IN_DBL_BRACE > + SKIP : +{ + <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")?> +} +< DEFAULT,IN_DBL_BRACE > + SKIP : +{ + <"/*"> { pushState(); } : INSIDE_COMMENT +} +< INSIDE_COMMENT > + SPECIAL_TOKEN : +{ + <"+"(" ")*(~["*"])*> +} +< INSIDE_COMMENT > + SKIP : +{ + <"/*"> { pushState(); } +} +< INSIDE_COMMENT > + SKIP : +{ + <"*/"> { popState("*/"); } + | <~[]> +}