Till Westmann | 5b431ca | 2015-10-01 19:16:11 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 20 | options { |
| 21 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 22 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 23 | STATIC = false; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 24 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | |
| 28 | PARSER_BEGIN(AQLParser) |
| 29 | |
Ian Maxon | f18bba2 | 2015-08-21 12:35:14 -0700 | [diff] [blame] | 30 | package org.apache.asterix.aql.parser; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 31 | |
Eldon Carman | d2d78ad | 2015-05-07 16:23:41 -0700 | [diff] [blame] | 32 | // For AQLParserTokenManager |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 33 | import org.apache.xerces.util.IntStack; |
| 34 | |
Eldon Carman | d2d78ad | 2015-05-07 16:23:41 -0700 | [diff] [blame] | 35 | import java.io.BufferedReader; |
| 36 | import java.io.File; |
| 37 | import java.io.FileInputStream; |
| 38 | import java.io.FileNotFoundException; |
| 39 | import java.io.IOException; |
| 40 | import java.io.InputStreamReader; |
| 41 | import java.io.Reader; |
| 42 | import java.io.StringReader; |
| 43 | import java.util.ArrayList; |
| 44 | import java.util.HashMap; |
| 45 | import java.util.LinkedHashMap; |
| 46 | import java.util.List; |
| 47 | import java.util.Map; |
| 48 | |
Ian Maxon | f18bba2 | 2015-08-21 12:35:14 -0700 | [diff] [blame] | 49 | import org.apache.asterix.aql.base.Clause; |
| 50 | import org.apache.asterix.aql.base.Expression; |
| 51 | import org.apache.asterix.aql.base.Literal; |
| 52 | import org.apache.asterix.aql.base.Statement; |
| 53 | import org.apache.asterix.aql.context.RootScopeFactory; |
| 54 | import org.apache.asterix.aql.context.Scope; |
| 55 | import org.apache.asterix.aql.expression.AbstractAccessor; |
| 56 | import org.apache.asterix.aql.expression.CallExpr; |
| 57 | import org.apache.asterix.aql.expression.CompactStatement; |
| 58 | import org.apache.asterix.aql.expression.ConnectFeedStatement; |
| 59 | import org.apache.asterix.aql.expression.CreateFeedPolicyStatement; |
| 60 | import org.apache.asterix.aql.expression.CreatePrimaryFeedStatement; |
| 61 | import org.apache.asterix.aql.expression.CreateSecondaryFeedStatement; |
| 62 | import org.apache.asterix.aql.expression.CreateDataverseStatement; |
| 63 | import org.apache.asterix.aql.expression.CreateFeedStatement; |
| 64 | import org.apache.asterix.aql.expression.CreateFunctionStatement; |
| 65 | import org.apache.asterix.aql.expression.CreateIndexStatement; |
| 66 | import org.apache.asterix.aql.expression.DatasetDecl; |
| 67 | import org.apache.asterix.aql.expression.DataverseDecl; |
| 68 | import org.apache.asterix.aql.expression.DataverseDropStatement; |
| 69 | import org.apache.asterix.aql.expression.DeleteStatement; |
| 70 | import org.apache.asterix.aql.expression.DisconnectFeedStatement; |
| 71 | import org.apache.asterix.aql.expression.DistinctClause; |
| 72 | import org.apache.asterix.aql.expression.DropStatement; |
| 73 | import org.apache.asterix.aql.expression.ExternalDetailsDecl; |
| 74 | import org.apache.asterix.aql.expression.FLWOGRExpression; |
| 75 | import org.apache.asterix.aql.expression.FeedDropStatement; |
| 76 | import org.apache.asterix.aql.expression.FieldAccessor; |
| 77 | import org.apache.asterix.aql.expression.FieldBinding; |
| 78 | import org.apache.asterix.aql.expression.ForClause; |
| 79 | import org.apache.asterix.aql.expression.FunctionDecl; |
| 80 | import org.apache.asterix.aql.expression.FunctionDropStatement; |
| 81 | import org.apache.asterix.aql.expression.GbyVariableExpressionPair; |
| 82 | import org.apache.asterix.aql.expression.GroupbyClause; |
| 83 | import org.apache.asterix.aql.expression.Identifier; |
| 84 | import org.apache.asterix.aql.expression.IfExpr; |
| 85 | import org.apache.asterix.aql.expression.IndexAccessor; |
| 86 | import org.apache.asterix.aql.expression.IndexDropStatement; |
| 87 | import org.apache.asterix.aql.expression.InsertStatement; |
| 88 | import org.apache.asterix.aql.expression.InternalDetailsDecl; |
| 89 | import org.apache.asterix.aql.expression.LetClause; |
| 90 | import org.apache.asterix.aql.expression.LimitClause; |
| 91 | import org.apache.asterix.aql.expression.ListConstructor; |
| 92 | import org.apache.asterix.aql.expression.LiteralExpr; |
| 93 | import org.apache.asterix.aql.expression.LoadStatement; |
| 94 | import org.apache.asterix.aql.expression.NodeGroupDropStatement; |
| 95 | import org.apache.asterix.aql.expression.NodegroupDecl; |
| 96 | import org.apache.asterix.aql.expression.OperatorExpr; |
| 97 | import org.apache.asterix.aql.expression.OrderbyClause; |
| 98 | import org.apache.asterix.aql.expression.OrderedListTypeDefinition; |
| 99 | import org.apache.asterix.aql.expression.QuantifiedExpression; |
| 100 | import org.apache.asterix.aql.expression.QuantifiedPair; |
| 101 | import org.apache.asterix.aql.expression.Query; |
| 102 | import org.apache.asterix.aql.expression.RecordConstructor; |
| 103 | import org.apache.asterix.aql.expression.RecordTypeDefinition; |
| 104 | import org.apache.asterix.aql.expression.RefreshExternalDatasetStatement; |
| 105 | import org.apache.asterix.aql.expression.RunStatement; |
| 106 | import org.apache.asterix.aql.expression.SetStatement; |
| 107 | import org.apache.asterix.aql.expression.TypeDecl; |
| 108 | import org.apache.asterix.aql.expression.TypeDropStatement; |
| 109 | import org.apache.asterix.aql.expression.TypeExpression; |
| 110 | import org.apache.asterix.aql.expression.TypeReferenceExpression; |
| 111 | import org.apache.asterix.aql.expression.UnaryExpr; |
| 112 | import org.apache.asterix.aql.expression.UnaryExpr.Sign; |
| 113 | import org.apache.asterix.aql.expression.UnionExpr; |
| 114 | import org.apache.asterix.aql.expression.UnorderedListTypeDefinition; |
| 115 | import org.apache.asterix.aql.expression.UpdateClause; |
| 116 | import org.apache.asterix.aql.expression.UpdateStatement; |
| 117 | import org.apache.asterix.aql.expression.VarIdentifier; |
| 118 | import org.apache.asterix.aql.expression.VariableExpr; |
| 119 | import org.apache.asterix.aql.expression.WhereClause; |
| 120 | import org.apache.asterix.aql.expression.WriteStatement; |
| 121 | import org.apache.asterix.aql.literal.DoubleLiteral; |
| 122 | import org.apache.asterix.aql.literal.FalseLiteral; |
| 123 | import org.apache.asterix.aql.literal.FloatLiteral; |
| 124 | import org.apache.asterix.aql.literal.LongIntegerLiteral; |
| 125 | import org.apache.asterix.aql.literal.NullLiteral; |
| 126 | import org.apache.asterix.aql.literal.StringLiteral; |
| 127 | import org.apache.asterix.aql.literal.TrueLiteral; |
| 128 | import org.apache.asterix.aql.util.RangeMapBuilder; |
| 129 | import org.apache.asterix.common.annotations.AutoDataGen; |
| 130 | import org.apache.asterix.common.annotations.DateBetweenYearsDataGen; |
| 131 | import org.apache.asterix.common.annotations.DatetimeAddRandHoursDataGen; |
| 132 | import org.apache.asterix.common.annotations.DatetimeBetweenYearsDataGen; |
| 133 | import org.apache.asterix.common.annotations.FieldIntervalDataGen; |
| 134 | import org.apache.asterix.common.annotations.FieldValFileDataGen; |
| 135 | import org.apache.asterix.common.annotations.FieldValFileSameIndexDataGen; |
| 136 | import org.apache.asterix.common.annotations.IRecordFieldDataGen; |
| 137 | import org.apache.asterix.common.annotations.InsertRandIntDataGen; |
| 138 | import org.apache.asterix.common.annotations.ListDataGen; |
| 139 | import org.apache.asterix.common.annotations.ListValFileDataGen; |
| 140 | import org.apache.asterix.common.annotations.SkipSecondaryIndexSearchExpressionAnnotation; |
| 141 | import org.apache.asterix.common.annotations.TypeDataGen; |
| 142 | import org.apache.asterix.common.annotations.UndeclaredFieldsDataGen; |
| 143 | import org.apache.asterix.common.config.DatasetConfig.DatasetType; |
| 144 | import org.apache.asterix.common.config.DatasetConfig.IndexType; |
| 145 | import org.apache.asterix.common.exceptions.AsterixException; |
| 146 | import org.apache.asterix.common.functions.FunctionSignature; |
| 147 | import org.apache.asterix.metadata.bootstrap.MetadataConstants; |
| 148 | import org.apache.hyracks.algebricks.common.utils.Pair; |
| 149 | import org.apache.hyracks.algebricks.common.utils.Triple; |
| 150 | import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionAnnotation; |
| 151 | import org.apache.hyracks.algebricks.core.algebra.expressions.IndexedNLJoinExpressionAnnotation; |
| 152 | import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; |
| 153 | import org.apache.hyracks.dataflow.common.data.partition.range.IRangeMap; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 154 | |
| 155 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 156 | |
| 157 | |
| 158 | public class AQLParser extends ScopeChecker { |
| 159 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 160 | // optimizer hints |
Eldon Carman | d2d78ad | 2015-05-07 16:23:41 -0700 | [diff] [blame] | 161 | private static final String AUTO_HINT = "auto"; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 162 | private static final String BROADCAST_JOIN_HINT = "bcast"; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 163 | private static final String COMPOSE_VAL_FILES_HINT = "compose-val-files"; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 164 | private static final String DATE_BETWEEN_YEARS_HINT = "date-between-years"; |
| 165 | private static final String DATETIME_ADD_RAND_HOURS_HINT = "datetime-add-rand-hours"; |
Eldon Carman | d2d78ad | 2015-05-07 16:23:41 -0700 | [diff] [blame] | 166 | private static final String DATETIME_BETWEEN_YEARS_HINT = "datetime-between-years"; |
| 167 | private static final String HASH_GROUP_BY_HINT = "hash"; |
| 168 | private static final String INDEXED_NESTED_LOOP_JOIN_HINT = "indexnl"; |
| 169 | private static final String INMEMORY_HINT = "inmem"; |
| 170 | private static final String INSERT_RAND_INT_HINT = "insert-rand-int"; |
| 171 | private static final String INTERVAL_HINT = "interval"; |
| 172 | private static final String LIST_HINT = "list"; |
| 173 | private static final String LIST_VAL_FILE_HINT = "list-val-file"; |
| 174 | private static final String RANGE_HINT = "range"; |
| 175 | private static final String SKIP_SECONDARY_INDEX_SEARCH_HINT = "skip-index"; |
| 176 | private static final String VAL_FILE_HINT = "val-files"; |
| 177 | private static final String VAL_FILE_SAME_INDEX_HINT = "val-file-same-idx"; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 178 | |
| 179 | private static final String GEN_FIELDS_HINT = "gen-fields"; |
| 180 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 181 | // data generator hints |
| 182 | private static final String DGEN_HINT = "dgen"; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 183 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 184 | private static class IndexParams { |
| 185 | public IndexType type; |
| 186 | public int gramLength; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 187 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 188 | public IndexParams(IndexType type, int gramLength) { |
| 189 | this.type = type; |
| 190 | this.gramLength = gramLength; |
| 191 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 192 | }; |
| 193 | |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 194 | private static class FunctionName { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 195 | public String dataverse = null; |
| 196 | public String library = null; |
| 197 | public String function = null; |
| 198 | } |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 199 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 200 | private static String getHint(Token t) { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 201 | if (t.specialToken == null) { |
| 202 | return null; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 203 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 204 | String s = t.specialToken.image; |
| 205 | int n = s.length(); |
| 206 | if (n < 2) { |
| 207 | return null; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 208 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 209 | return s.substring(1).trim(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 210 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 211 | |
Till Westmann | 77cb2f4 | 2013-07-15 16:44:19 -0700 | [diff] [blame] | 212 | private static IRecordFieldDataGen parseFieldDataGen(String hint) throws ParseException { |
| 213 | IRecordFieldDataGen rfdg = null; |
| 214 | String splits[] = hint.split(" +"); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 215 | if (splits[0].equals(VAL_FILE_HINT)) { |
Till Westmann | 77cb2f4 | 2013-07-15 16:44:19 -0700 | [diff] [blame] | 216 | File[] valFiles = new File[splits.length - 1]; |
| 217 | for (int k=1; k<splits.length; k++) { |
| 218 | valFiles[k-1] = new File(splits[k]); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 219 | } |
Till Westmann | 77cb2f4 | 2013-07-15 16:44:19 -0700 | [diff] [blame] | 220 | rfdg = new FieldValFileDataGen(valFiles); |
| 221 | } else if (splits[0].equals(VAL_FILE_SAME_INDEX_HINT)) { |
| 222 | rfdg = new FieldValFileSameIndexDataGen(new File(splits[1]), splits[2]); |
| 223 | } else if (splits[0].equals(LIST_VAL_FILE_HINT)) { |
| 224 | rfdg = new ListValFileDataGen(new File(splits[1]), Integer.parseInt(splits[2]), Integer.parseInt(splits[3])); |
| 225 | } else if (splits[0].equals(LIST_HINT)) { |
| 226 | rfdg = new ListDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2])); |
| 227 | } else if (splits[0].equals(INTERVAL_HINT)) { |
| 228 | FieldIntervalDataGen.ValueType vt; |
| 229 | if (splits[1].equals("int")) { |
| 230 | vt = FieldIntervalDataGen.ValueType.INT; |
| 231 | } else if (splits[1].equals("long")) { |
| 232 | vt = FieldIntervalDataGen.ValueType.LONG; |
| 233 | } else if (splits[1].equals("float")) { |
| 234 | vt = FieldIntervalDataGen.ValueType.FLOAT; |
| 235 | } else if (splits[1].equals("double")) { |
| 236 | vt = FieldIntervalDataGen.ValueType.DOUBLE; |
| 237 | } else { |
| 238 | throw new ParseException("Unknown type for interval data gen: " + splits[1]); |
| 239 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 240 | rfdg = new FieldIntervalDataGen(vt, splits[2], splits[3]); |
Till Westmann | 77cb2f4 | 2013-07-15 16:44:19 -0700 | [diff] [blame] | 241 | } else if (splits[0].equals(INSERT_RAND_INT_HINT)) { |
| 242 | rfdg = new InsertRandIntDataGen(splits[1], splits[2]); |
| 243 | } else if (splits[0].equals(DATE_BETWEEN_YEARS_HINT)) { |
| 244 | rfdg = new DateBetweenYearsDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2])); |
| 245 | } else if (splits[0].equals(DATETIME_BETWEEN_YEARS_HINT)) { |
| 246 | rfdg = new DatetimeBetweenYearsDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2])); |
| 247 | } else if (splits[0].equals(DATETIME_ADD_RAND_HOURS_HINT)) { |
| 248 | rfdg = new DatetimeAddRandHoursDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]), splits[3]); |
| 249 | } else if (splits[0].equals(AUTO_HINT)) { |
| 250 | rfdg = new AutoDataGen(splits[1]); |
| 251 | } |
| 252 | return rfdg; |
| 253 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 254 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 255 | public AQLParser(String s){ |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 256 | this(new StringReader(s)); |
| 257 | super.setInput(s); |
| 258 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 259 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 260 | public static void main(String args[]) throws ParseException, TokenMgrError, IOException, FileNotFoundException, AsterixException { |
| 261 | File file = new File(args[0]); |
| 262 | Reader fis = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); |
| 263 | AQLParser parser = new AQLParser(fis); |
Till Westmann | e3e8ffa | 2014-08-02 17:51:23 -0700 | [diff] [blame] | 264 | List<Statement> st = parser.parse(); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 265 | //st.accept(new AQLPrintVisitor(), 0); |
| 266 | } |
Till Westmann | e3e8ffa | 2014-08-02 17:51:23 -0700 | [diff] [blame] | 267 | |
| 268 | public List<Statement> parse() throws ParseException { |
| 269 | try { |
| 270 | return Statement(); |
| 271 | } catch (Error e) { |
| 272 | // this is here as the JavaCharStream that's below the lexer somtimes throws Errors that are not handled |
| 273 | // by the ANTLR-generated lexer or parser (e.g it does this for invalid backslash u + 4 hex digits escapes) |
| 274 | throw new ParseException(e.getMessage()); |
| 275 | } |
| 276 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | PARSER_END(AQLParser) |
| 280 | |
| 281 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 282 | List<Statement> Statement() throws ParseException: |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 283 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 284 | scopeStack.push(RootScopeFactory.createRootScope(this)); |
| 285 | List<Statement> decls = new ArrayList<Statement>(); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 286 | Statement stmt = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 287 | } |
| 288 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 289 | ( stmt = SingleStatement() (";") ? |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 290 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 291 | decls.add(stmt); |
| 292 | } |
| 293 | )* |
| 294 | <EOF> |
| 295 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 296 | return decls; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | |
| 300 | Statement SingleStatement() throws ParseException: |
| 301 | { |
| 302 | Statement stmt = null; |
| 303 | } |
| 304 | { |
| 305 | ( |
| 306 | stmt = DataverseDeclaration() |
| 307 | | stmt = FunctionDeclaration() |
| 308 | | stmt = CreateStatement() |
| 309 | | stmt = LoadStatement() |
| 310 | | stmt = DropStatement() |
| 311 | | stmt = WriteStatement() |
| 312 | | stmt = SetStatement() |
| 313 | | stmt = InsertStatement() |
| 314 | | stmt = DeleteStatement() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 315 | | stmt = UpdateStatement() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 316 | | stmt = FeedStatement() |
salsubaiee | 0b423fa | 2013-09-19 19:16:48 -0700 | [diff] [blame] | 317 | | stmt = CompactStatement() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 318 | | stmt = Query() |
Abdullah Alamoudi | d905773 | 2014-06-12 13:38:27 -0700 | [diff] [blame] | 319 | | stmt = RefreshExternalDatasetStatement() |
Markus Holzemer | 52c568e | 2014-12-18 10:51:49 -0800 | [diff] [blame] | 320 | | stmt = RunStatement() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 321 | ) |
| 322 | { |
| 323 | return stmt; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | DataverseDecl DataverseDeclaration() throws ParseException: |
| 328 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 329 | String dvName = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 330 | } |
| 331 | { |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 332 | "use" "dataverse" dvName = Identifier() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 333 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 334 | defaultDataverse = dvName; |
| 335 | return new DataverseDecl(new Identifier(dvName)); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 336 | } |
| 337 | } |
| 338 | |
| 339 | Statement CreateStatement() throws ParseException: |
| 340 | { |
| 341 | String hint = null; |
| 342 | boolean dgen = false; |
| 343 | Statement stmt = null; |
| 344 | } |
| 345 | { |
| 346 | "create" |
| 347 | ( |
| 348 | { |
| 349 | hint = getHint(token); |
| 350 | if (hint != null && hint.startsWith(DGEN_HINT)) { |
| 351 | dgen = true; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 352 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 353 | } |
| 354 | stmt = TypeSpecification(hint, dgen) |
| 355 | | stmt = NodegroupSpecification() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 356 | | stmt = DatasetSpecification() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 357 | | stmt = IndexSpecification() |
| 358 | | stmt = DataverseSpecification() |
| 359 | | stmt = FunctionSpecification() |
ramangrover29 | a774ef2 | 2013-07-17 09:29:18 -0700 | [diff] [blame] | 360 | | stmt = FeedSpecification() |
ramangrover29 | ae85a1d | 2015-06-26 17:26:05 -0700 | [diff] [blame] | 361 | | stmt = FeedPolicySpecification() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 362 | ) |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 363 | { |
| 364 | return stmt; |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | TypeDecl TypeSpecification(String hint, boolean dgen) throws ParseException: |
| 369 | { |
| 370 | Pair<Identifier,Identifier> nameComponents = null; |
| 371 | boolean ifNotExists = false; |
| 372 | TypeExpression typeExpr = null; |
| 373 | } |
| 374 | { |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 375 | "type" nameComponents = TypeName() ifNotExists = IfNotExists() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 376 | "as" typeExpr = TypeExpr() |
| 377 | { |
| 378 | long numValues = -1; |
| 379 | String filename = null; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 380 | if (dgen) { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 381 | String splits[] = hint.split(" +"); |
| 382 | if (splits.length != 3) { |
| 383 | throw new ParseException("Expecting /*+ dgen <filename> <numberOfItems> */"); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 384 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 385 | filename = splits[1]; |
| 386 | numValues = Long.parseLong(splits[2]); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 387 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 388 | TypeDataGen tddg = new TypeDataGen(dgen, filename, numValues); |
| 389 | return new TypeDecl(nameComponents.first, nameComponents.second, typeExpr, tddg, ifNotExists); |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | |
| 394 | NodegroupDecl NodegroupSpecification() throws ParseException: |
| 395 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 396 | String name = null; |
| 397 | String tmp = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 398 | boolean ifNotExists = false; |
| 399 | List<Identifier>ncNames = null; |
| 400 | } |
| 401 | { |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 402 | "nodegroup" name = Identifier() |
| 403 | ifNotExists = IfNotExists() "on" tmp = Identifier() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 404 | { |
| 405 | ncNames = new ArrayList<Identifier>(); |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 406 | ncNames.add(new Identifier(tmp)); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 407 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 408 | ( <COMMA> tmp = Identifier() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 409 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 410 | ncNames.add(new Identifier(tmp)); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 411 | } |
| 412 | )* |
| 413 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 414 | return new NodegroupDecl(new Identifier(name), ncNames, ifNotExists); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 415 | } |
| 416 | } |
| 417 | |
| 418 | DatasetDecl DatasetSpecification() throws ParseException: |
| 419 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 420 | Pair<Identifier,Identifier> nameComponents = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 421 | boolean ifNotExists = false; |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 422 | String typeName = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 423 | String adapterName = null; |
| 424 | Map<String,String> properties = null; |
salsubaiee | 801bffe | 2013-09-22 23:42:35 -0700 | [diff] [blame] | 425 | Map<String,String> compactionPolicyProperties = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 426 | FunctionSignature appliedFunction = null; |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 427 | List<List<String>> primaryKeyFields = null; |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 428 | String nodeGroupName = null; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 429 | Map<String,String> hints = new HashMap<String,String>(); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 430 | DatasetDecl dsetDecl = null; |
zheilbron | 2467f2e | 2013-08-23 19:07:31 -0700 | [diff] [blame] | 431 | boolean autogenerated = false; |
salsubaiee | 0b423fa | 2013-09-19 19:16:48 -0700 | [diff] [blame] | 432 | String compactionPolicy = null; |
buyingyi | ccd67fe | 2015-05-19 11:53:39 -0700 | [diff] [blame] | 433 | boolean temp = false; |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 434 | List<String> filterField = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 435 | } |
| 436 | { |
| 437 | ( |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 438 | "external" <DATASET> nameComponents = QualifiedName() |
| 439 | <LEFTPAREN> typeName = Identifier() <RIGHTPAREN> |
| 440 | ifNotExists = IfNotExists() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 441 | "using" adapterName = AdapterName() properties = Configuration() |
Abdullah Alamoudi | d905773 | 2014-06-12 13:38:27 -0700 | [diff] [blame] | 442 | ("on" nodeGroupName = Identifier() )? |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 443 | ( "hints" hints = Properties() )? |
salsubaiee | 661b9c7 | 2014-07-17 17:19:45 -0700 | [diff] [blame] | 444 | ( "using" "compaction" "policy" compactionPolicy = CompactionPolicy() (compactionPolicyProperties = Configuration())? )? |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 445 | { |
| 446 | ExternalDetailsDecl edd = new ExternalDetailsDecl(); |
| 447 | edd.setAdapter(adapterName); |
| 448 | edd.setProperties(properties); |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 449 | dsetDecl = new DatasetDecl(nameComponents.first, |
| 450 | nameComponents.second, |
| 451 | new Identifier(typeName), |
Ildar Absalyamov | a589530 | 2015-08-17 23:15:41 -0700 | [diff] [blame] | 452 | nodeGroupName != null? new Identifier(nodeGroupName): null, |
| 453 | compactionPolicy, |
| 454 | compactionPolicyProperties, |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 455 | hints, |
| 456 | DatasetType.EXTERNAL, |
| 457 | edd, |
| 458 | ifNotExists); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 459 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 460 | |
buyingyi | ccd67fe | 2015-05-19 11:53:39 -0700 | [diff] [blame] | 461 | | ("internal" | "temporary" { |
| 462 | temp = token.image.toLowerCase().equals("temporary"); |
| 463 | } |
| 464 | )? |
| 465 | <DATASET> nameComponents = QualifiedName() |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 466 | <LEFTPAREN> typeName = Identifier() <RIGHTPAREN> |
| 467 | ifNotExists = IfNotExists() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 468 | primaryKeyFields = PrimaryKey() |
| 469 | ("autogenerated" { autogenerated = true; } )? |
zheilbron | 2467f2e | 2013-08-23 19:07:31 -0700 | [diff] [blame] | 470 | ("on" nodeGroupName = Identifier() )? |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 471 | ( "hints" hints = Properties() )? |
salsubaiee | 661b9c7 | 2014-07-17 17:19:45 -0700 | [diff] [blame] | 472 | ( "using" "compaction" "policy" compactionPolicy = CompactionPolicy() (compactionPolicyProperties = Configuration())? )? |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 473 | ( "with filter on" filterField = NestedField() )? |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 474 | { |
Ildar Absalyamov | a589530 | 2015-08-17 23:15:41 -0700 | [diff] [blame] | 475 | InternalDetailsDecl idd = new InternalDetailsDecl(primaryKeyFields, |
zheilbron | 9082e6c | 2013-10-24 12:25:21 -0700 | [diff] [blame] | 476 | autogenerated, |
buyingyi | ccd67fe | 2015-05-19 11:53:39 -0700 | [diff] [blame] | 477 | filterField, |
| 478 | temp); |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 479 | dsetDecl = new DatasetDecl(nameComponents.first, |
| 480 | nameComponents.second, |
| 481 | new Identifier(typeName), |
Ildar Absalyamov | a589530 | 2015-08-17 23:15:41 -0700 | [diff] [blame] | 482 | nodeGroupName != null ? new Identifier(nodeGroupName) : null, |
| 483 | compactionPolicy, |
| 484 | compactionPolicyProperties, |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 485 | hints, |
| 486 | DatasetType.INTERNAL, |
| 487 | idd, |
| 488 | ifNotExists); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 489 | } |
| 490 | ) |
| 491 | { |
| 492 | return dsetDecl; |
| 493 | } |
| 494 | } |
| 495 | |
Abdullah Alamoudi | d905773 | 2014-06-12 13:38:27 -0700 | [diff] [blame] | 496 | RefreshExternalDatasetStatement RefreshExternalDatasetStatement() throws ParseException: |
| 497 | { |
| 498 | RefreshExternalDatasetStatement redss = new RefreshExternalDatasetStatement(); |
| 499 | Pair<Identifier,Identifier> nameComponents = null; |
| 500 | String datasetName = null; |
| 501 | } |
| 502 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 503 | "refresh external" <DATASET> nameComponents = QualifiedName() |
| 504 | { |
| 505 | redss.setDataverseName(nameComponents.first); |
| 506 | redss.setDatasetName(nameComponents.second); |
| 507 | return redss; |
| 508 | } |
Abdullah Alamoudi | d905773 | 2014-06-12 13:38:27 -0700 | [diff] [blame] | 509 | } |
| 510 | |
Markus Holzemer | 52c568e | 2014-12-18 10:51:49 -0800 | [diff] [blame] | 511 | RunStatement RunStatement() throws ParseException: |
| 512 | { |
| 513 | String system = null; |
| 514 | String tmp; |
| 515 | ArrayList<String> parameters = new ArrayList<String>(); |
| 516 | Pair<Identifier,Identifier> nameComponentsFrom = null; |
| 517 | Pair<Identifier,Identifier> nameComponentsTo = null; |
| 518 | } |
| 519 | { |
| 520 | "run" system = Identifier()<LEFTPAREN> ( tmp = Identifier() [<COMMA>] |
| 521 | { |
| 522 | parameters.add(tmp); |
| 523 | } |
| 524 | )*<RIGHTPAREN> |
| 525 | <FROM> <DATASET> nameComponentsFrom = QualifiedName() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 526 | "to" <DATASET> nameComponentsTo = QualifiedName() |
Markus Holzemer | 52c568e | 2014-12-18 10:51:49 -0800 | [diff] [blame] | 527 | { |
| 528 | return new RunStatement(system, parameters, nameComponentsFrom.first, nameComponentsFrom.second, nameComponentsTo.first, nameComponentsTo.second); |
| 529 | } |
| 530 | } |
| 531 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 532 | CreateIndexStatement IndexSpecification() throws ParseException: |
| 533 | { |
| 534 | CreateIndexStatement cis = new CreateIndexStatement(); |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 535 | String indexName = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 536 | boolean ifNotExists = false; |
| 537 | Pair<Identifier,Identifier> nameComponents = null; |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 538 | Pair<List<String>, TypeExpression> fieldPair = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 539 | IndexParams indexType = null; |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 540 | boolean enforced = false; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 541 | } |
| 542 | { |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 543 | "index" indexName = Identifier() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 544 | ifNotExists = IfNotExists() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 545 | "on" nameComponents = QualifiedName() |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 546 | <LEFTPAREN> ( fieldPair = OpenField() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 547 | { |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 548 | cis.addFieldExprPair(fieldPair); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 549 | } |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 550 | ) (<COMMA> fieldPair = OpenField() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 551 | { |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 552 | cis.addFieldExprPair(fieldPair); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 553 | } |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 554 | )* <RIGHTPAREN> ( "type" indexType = IndexType() )? ( "enforced" { enforced = true; } )? |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 555 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 556 | cis.setIndexName(new Identifier(indexName)); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 557 | cis.setIfNotExists(ifNotExists); |
| 558 | cis.setDataverseName(nameComponents.first); |
| 559 | cis.setDatasetName(nameComponents.second); |
| 560 | if (indexType != null) { |
| 561 | cis.setIndexType(indexType.type); |
| 562 | cis.setGramLength(indexType.gramLength); |
| 563 | } |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 564 | cis.setEnforced(enforced); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 565 | return cis; |
| 566 | } |
| 567 | } |
| 568 | |
salsubaiee | 0b423fa | 2013-09-19 19:16:48 -0700 | [diff] [blame] | 569 | String CompactionPolicy() throws ParseException : |
| 570 | { |
| 571 | String compactionPolicy = null; |
| 572 | } |
| 573 | { |
| 574 | compactionPolicy = Identifier() |
| 575 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 576 | return compactionPolicy; |
salsubaiee | 0b423fa | 2013-09-19 19:16:48 -0700 | [diff] [blame] | 577 | } |
| 578 | } |
| 579 | |
salsubaiee | a5af4e0 | 2014-07-08 15:20:02 -0700 | [diff] [blame] | 580 | String FilterField() throws ParseException : |
| 581 | { |
| 582 | String filterField = null; |
| 583 | } |
| 584 | { |
| 585 | filterField = Identifier() |
| 586 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 587 | return filterField; |
salsubaiee | a5af4e0 | 2014-07-08 15:20:02 -0700 | [diff] [blame] | 588 | } |
| 589 | } |
| 590 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 591 | IndexParams IndexType() throws ParseException: |
| 592 | { |
| 593 | IndexType type = null; |
| 594 | int gramLength = 0; |
| 595 | } |
| 596 | { |
| 597 | ("btree" |
| 598 | { |
| 599 | type = IndexType.BTREE; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 600 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 601 | | "rtree" |
| 602 | { |
| 603 | type = IndexType.RTREE; |
| 604 | } |
| 605 | | "keyword" |
| 606 | { |
JIMAHN | b75446d | 2013-06-03 08:35:27 -0700 | [diff] [blame] | 607 | type = IndexType.LENGTH_PARTITIONED_WORD_INVIX; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 608 | } |
| 609 | | "ngram" <LEFTPAREN> <INTEGER_LITERAL> |
| 610 | { |
JIMAHN | b75446d | 2013-06-03 08:35:27 -0700 | [diff] [blame] | 611 | type = IndexType.LENGTH_PARTITIONED_NGRAM_INVIX; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 612 | gramLength = Integer.valueOf(token.image); |
| 613 | } |
| 614 | <RIGHTPAREN>) |
| 615 | { |
| 616 | return new IndexParams(type, gramLength); |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | CreateDataverseStatement DataverseSpecification() throws ParseException : |
| 621 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 622 | String dvName = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 623 | boolean ifNotExists = false; |
| 624 | String format = null; |
| 625 | } |
| 626 | { |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 627 | "dataverse" dvName = Identifier() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 628 | ifNotExists = IfNotExists() |
Till Westmann | 7d53532 | 2013-05-09 00:40:02 -0700 | [diff] [blame] | 629 | ( "with format" format = StringLiteral() )? |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 630 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 631 | return new CreateDataverseStatement(new Identifier(dvName), format, ifNotExists); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 632 | } |
| 633 | } |
| 634 | |
| 635 | CreateFunctionStatement FunctionSpecification() throws ParseException: |
| 636 | { |
| 637 | FunctionSignature signature; |
| 638 | boolean ifNotExists = false; |
| 639 | List<VarIdentifier> paramList = new ArrayList<VarIdentifier>(); |
| 640 | String functionBody; |
ramangrover29 | bdba1a8 | 2013-06-21 17:17:52 -0700 | [diff] [blame] | 641 | VarIdentifier var = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 642 | Expression functionBodyExpr; |
| 643 | Token beginPos; |
| 644 | Token endPos; |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 645 | FunctionName fctName = null; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 646 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 647 | createNewScope(); |
| 648 | } |
| 649 | { |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 650 | "function" fctName = FunctionName() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 651 | ifNotExists = IfNotExists() |
Till Westmann | d7dcb12 | 2013-05-16 13:19:09 -0700 | [diff] [blame] | 652 | paramList = ParameterList() |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 653 | <LEFTBRACE> |
Raman Grover | f6b4b29 | 2013-09-24 11:11:20 +0530 | [diff] [blame] | 654 | { |
| 655 | beginPos = token; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 656 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 657 | functionBodyExpr = Expression() <RIGHTBRACE> |
Till Westmann | d7dcb12 | 2013-05-16 13:19:09 -0700 | [diff] [blame] | 658 | { |
| 659 | endPos = token; |
| 660 | functionBody = extractFragment(beginPos.beginLine, beginPos.beginColumn, endPos.beginLine, endPos.beginColumn); |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 661 | // TODO use fctName.library |
| 662 | signature = new FunctionSignature(fctName.dataverse, fctName.function, paramList.size()); |
Till Westmann | d7dcb12 | 2013-05-16 13:19:09 -0700 | [diff] [blame] | 663 | getCurrentScope().addFunctionDescriptor(signature, false); |
Steven Jacobs | a84eee4 | 2014-12-16 13:55:08 -0800 | [diff] [blame] | 664 | removeCurrentScope(); |
Till Westmann | d7dcb12 | 2013-05-16 13:19:09 -0700 | [diff] [blame] | 665 | return new CreateFunctionStatement(signature, paramList, functionBody, ifNotExists); |
| 666 | } |
| 667 | } |
| 668 | |
ramangrover29 | a774ef2 | 2013-07-17 09:29:18 -0700 | [diff] [blame] | 669 | CreateFeedStatement FeedSpecification() throws ParseException: |
| 670 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 671 | Pair<Identifier,Identifier> nameComponents = null; |
ramangrover29 | a774ef2 | 2013-07-17 09:29:18 -0700 | [diff] [blame] | 672 | boolean ifNotExists = false; |
Chris Hillery | e64055d | 2014-10-11 00:14:39 -0700 | [diff] [blame] | 673 | String adapterName = null; |
ramangrover29 | a774ef2 | 2013-07-17 09:29:18 -0700 | [diff] [blame] | 674 | Map<String,String> properties = null; |
| 675 | FunctionSignature appliedFunction = null; |
| 676 | CreateFeedStatement cfs = null; |
ramangrover29 | ae85a1d | 2015-06-26 17:26:05 -0700 | [diff] [blame] | 677 | Pair<Identifier,Identifier> sourceNameComponents = null; |
| 678 | |
ramangrover29 | a774ef2 | 2013-07-17 09:29:18 -0700 | [diff] [blame] | 679 | } |
| 680 | { |
| 681 | ( |
ramangrover29 | ae85a1d | 2015-06-26 17:26:05 -0700 | [diff] [blame] | 682 | "secondary" "feed" nameComponents = QualifiedName() ifNotExists = IfNotExists() |
| 683 | <FROM> "feed" sourceNameComponents = QualifiedName() (appliedFunction = ApplyFunction())? |
ramangrover29 | a774ef2 | 2013-07-17 09:29:18 -0700 | [diff] [blame] | 684 | { |
ramangrover29 | ae85a1d | 2015-06-26 17:26:05 -0700 | [diff] [blame] | 685 | cfs = new CreateSecondaryFeedStatement(nameComponents, |
| 686 | sourceNameComponents, appliedFunction, ifNotExists); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 687 | } |
ramangrover29 | ae85a1d | 2015-06-26 17:26:05 -0700 | [diff] [blame] | 688 | | |
| 689 | ("primary")? "feed" nameComponents = QualifiedName() ifNotExists = IfNotExists() |
| 690 | "using" adapterName = AdapterName() properties = Configuration() (appliedFunction = ApplyFunction())? |
| 691 | { |
| 692 | cfs = new CreatePrimaryFeedStatement(nameComponents, |
| 693 | adapterName, properties, appliedFunction, ifNotExists); |
| 694 | } |
ramangrover29 | a774ef2 | 2013-07-17 09:29:18 -0700 | [diff] [blame] | 695 | ) |
| 696 | { |
| 697 | return cfs; |
| 698 | } |
| 699 | } |
| 700 | |
ramangrover29 | ae85a1d | 2015-06-26 17:26:05 -0700 | [diff] [blame] | 701 | CreateFeedPolicyStatement FeedPolicySpecification() throws ParseException: |
| 702 | { |
| 703 | String policyName = null; |
| 704 | String basePolicyName = null; |
| 705 | String sourcePolicyFile = null; |
| 706 | String definition = null; |
| 707 | boolean ifNotExists = false; |
| 708 | Map<String,String> properties = null; |
| 709 | CreateFeedPolicyStatement cfps = null; |
| 710 | } |
| 711 | { |
| 712 | ( |
| 713 | "ingestion" "policy" policyName = Identifier() ifNotExists = IfNotExists() |
| 714 | <FROM> |
| 715 | ("policy" basePolicyName = Identifier() properties = Configuration() ("definition" definition = StringLiteral())? |
| 716 | { |
| 717 | cfps = new CreateFeedPolicyStatement(policyName, |
| 718 | basePolicyName, properties, definition, ifNotExists); |
| 719 | } |
| 720 | | "path" sourcePolicyFile = Identifier() ("definition" definition = StringLiteral())? |
| 721 | { |
| 722 | cfps = new CreateFeedPolicyStatement(policyName, sourcePolicyFile, definition, ifNotExists); |
| 723 | } |
| 724 | ) |
| 725 | |
| 726 | ) |
| 727 | { |
| 728 | return cfps; |
| 729 | } |
| 730 | } |
| 731 | |
ramangrover29 | a774ef2 | 2013-07-17 09:29:18 -0700 | [diff] [blame] | 732 | |
| 733 | |
Till Westmann | d7dcb12 | 2013-05-16 13:19:09 -0700 | [diff] [blame] | 734 | List<VarIdentifier> ParameterList() throws ParseException: |
| 735 | { |
| 736 | List<VarIdentifier> paramList = new ArrayList<VarIdentifier>(); |
| 737 | VarIdentifier var = null; |
| 738 | } |
| 739 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 740 | <LEFTPAREN> (<VARIABLE> |
| 741 | { |
| 742 | var = new VarIdentifier(); |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 743 | var.setValue(token.image); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 744 | paramList.add(var); |
| 745 | getCurrentScope().addNewVarSymbolToScope(var); |
| 746 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 747 | (<COMMA> <VARIABLE> |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 748 | { |
| 749 | var = new VarIdentifier(); |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 750 | var.setValue(token.image); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 751 | paramList.add(var); |
| 752 | getCurrentScope().addNewVarSymbolToScope(var); |
| 753 | } |
Till Westmann | d7dcb12 | 2013-05-16 13:19:09 -0700 | [diff] [blame] | 754 | )*)? <RIGHTPAREN> |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 755 | { |
Till Westmann | d7dcb12 | 2013-05-16 13:19:09 -0700 | [diff] [blame] | 756 | return paramList; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 757 | } |
| 758 | } |
| 759 | |
| 760 | boolean IfNotExists() throws ParseException: |
| 761 | { |
| 762 | } |
| 763 | { |
| 764 | ( "if not exists" |
| 765 | { |
| 766 | return true; |
| 767 | } |
| 768 | )? |
| 769 | { |
| 770 | return false; |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | FunctionSignature ApplyFunction() throws ParseException: |
| 775 | { |
Raman Grover | 25a2b2e | 2013-09-27 18:22:23 +0530 | [diff] [blame] | 776 | FunctionName functioName = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 777 | FunctionSignature funcSig = null; |
| 778 | } |
| 779 | { |
Raman Grover | 25a2b2e | 2013-09-27 18:22:23 +0530 | [diff] [blame] | 780 | "apply" "function" functioName = FunctionName() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 781 | { |
Raman Grover | 25a2b2e | 2013-09-27 18:22:23 +0530 | [diff] [blame] | 782 | String fqFunctionName = functioName.library == null ? functioName.function : functioName.library + "#" + functioName.function; |
| 783 | return new FunctionSignature(functioName.dataverse, fqFunctionName, 1); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 784 | } |
| 785 | } |
| 786 | |
ramangrover29 | 566b3a9 | 2013-05-28 09:07:10 -0700 | [diff] [blame] | 787 | String GetPolicy() throws ParseException: |
| 788 | { |
| 789 | String policy = null; |
| 790 | } |
| 791 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 792 | "using" "policy" policy = Identifier() |
ramangrover29 | 566b3a9 | 2013-05-28 09:07:10 -0700 | [diff] [blame] | 793 | { |
| 794 | return policy; |
| 795 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 796 | |
| 797 | } |
ramangrover29 | 566b3a9 | 2013-05-28 09:07:10 -0700 | [diff] [blame] | 798 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 799 | FunctionSignature FunctionSignature() throws ParseException: |
| 800 | { |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 801 | FunctionName fctName = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 802 | int arity = 0; |
| 803 | } |
| 804 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 805 | fctName = FunctionName() "@" <INTEGER_LITERAL> |
| 806 | { |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 807 | arity = new Integer(token.image); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 808 | if (arity < 0 && arity != FunctionIdentifier.VARARGS) { |
| 809 | throw new ParseException(" invalid arity:" + arity); |
| 810 | } |
| 811 | |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 812 | // TODO use fctName.library |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 813 | String fqFunctionName = fctName.library == null ? fctName.function : fctName.library + "#" + fctName.function; |
ramangrover29 | 93dd823 | 2013-07-03 22:51:25 -0700 | [diff] [blame] | 814 | return new FunctionSignature(fctName.dataverse, fqFunctionName, arity); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 815 | } |
| 816 | } |
| 817 | |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 818 | List<List<String>> PrimaryKey() throws ParseException: |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 819 | { |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 820 | List<String> tmp = null; |
| 821 | List<List<String>> primaryKeyFields = new ArrayList<List<String>>(); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 822 | } |
| 823 | { |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 824 | "primary" "key" tmp = NestedField() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 825 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 826 | primaryKeyFields.add(tmp); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 827 | } |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 828 | ( <COMMA> tmp = NestedField() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 829 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 830 | primaryKeyFields.add(tmp); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 831 | } |
| 832 | )* |
| 833 | { |
| 834 | return primaryKeyFields; |
| 835 | } |
| 836 | } |
| 837 | |
| 838 | Statement DropStatement() throws ParseException: |
| 839 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 840 | String id = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 841 | Pair<Identifier,Identifier> pairId = null; |
| 842 | Triple<Identifier,Identifier,Identifier> tripleId = null; |
| 843 | FunctionSignature funcSig = null; |
| 844 | boolean ifExists = false; |
| 845 | Statement stmt = null; |
| 846 | } |
| 847 | { |
| 848 | "drop" |
| 849 | ( |
| 850 | <DATASET> pairId = QualifiedName() ifExists = IfExists() |
| 851 | { |
| 852 | stmt = new DropStatement(pairId.first, pairId.second, ifExists); |
| 853 | } |
| 854 | | "index" tripleId = DoubleQualifiedName() ifExists = IfExists() |
| 855 | { |
| 856 | stmt = new IndexDropStatement(tripleId.first, tripleId.second, tripleId.third, ifExists); |
| 857 | } |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 858 | | "nodegroup" id = Identifier() ifExists = IfExists() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 859 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 860 | stmt = new NodeGroupDropStatement(new Identifier(id), ifExists); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 861 | } |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 862 | | "type" pairId = TypeName() ifExists = IfExists() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 863 | { |
| 864 | stmt = new TypeDropStatement(pairId.first, pairId.second, ifExists); |
| 865 | } |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 866 | | "dataverse" id = Identifier() ifExists = IfExists() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 867 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 868 | stmt = new DataverseDropStatement(new Identifier(id), ifExists); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 869 | } |
| 870 | | "function" funcSig = FunctionSignature() ifExists = IfExists() |
| 871 | { |
| 872 | stmt = new FunctionDropStatement(funcSig, ifExists); |
| 873 | } |
ramangrover29 | a774ef2 | 2013-07-17 09:29:18 -0700 | [diff] [blame] | 874 | | "feed" pairId = QualifiedName() ifExists = IfExists() |
| 875 | { |
| 876 | stmt = new FeedDropStatement(pairId.first, pairId.second, ifExists); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 877 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 878 | ) |
| 879 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 880 | return stmt; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 881 | } |
| 882 | } |
| 883 | |
| 884 | boolean IfExists() throws ParseException : |
| 885 | { |
| 886 | } |
| 887 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 888 | ( <IF> "exists" |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 889 | { |
| 890 | return true; |
| 891 | } |
| 892 | )? |
| 893 | { |
| 894 | return false; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 895 | } |
| 896 | } |
| 897 | |
| 898 | InsertStatement InsertStatement() throws ParseException: |
| 899 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 900 | Pair<Identifier,Identifier> nameComponents = null; |
| 901 | Query query; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 902 | } |
| 903 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 904 | "insert" "into" <DATASET> nameComponents = QualifiedName() query = Query() |
| 905 | { |
| 906 | return new InsertStatement(nameComponents.first, nameComponents.second, query, getVarCounter()); |
| 907 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | DeleteStatement DeleteStatement() throws ParseException: |
| 911 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 912 | VariableExpr var = null; |
| 913 | Expression condition = null; |
| 914 | Pair<Identifier, Identifier> nameComponents; |
Abdullah Alamoudi | db37f66 | 2014-07-14 21:51:37 +0300 | [diff] [blame] | 915 | // This is related to the new metadata lock management |
| 916 | setDataverses(new ArrayList<String>()); |
| 917 | setDatasets(new ArrayList<String>()); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 918 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 919 | } |
| 920 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 921 | "delete" var = Variable() |
| 922 | { |
| 923 | getCurrentScope().addNewVarSymbolToScope(var.getVar()); |
| 924 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 925 | <FROM> <DATASET> nameComponents = QualifiedName() |
salsubaiee | df89fbc | 2013-12-21 19:51:42 -0800 | [diff] [blame] | 926 | (<WHERE> condition = Expression())? |
| 927 | { |
Abdullah Alamoudi | db37f66 | 2014-07-14 21:51:37 +0300 | [diff] [blame] | 928 | // First we get the dataverses and datasets that we want to lock |
| 929 | List<String> dataverses = getDataverses(); |
| 930 | List<String> datasets = getDatasets(); |
| 931 | // we remove the pointer to the dataverses and datasets |
| 932 | setDataverses(null); |
| 933 | setDatasets(null); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 934 | return new DeleteStatement(var, nameComponents.first, nameComponents.second, |
| 935 | condition, getVarCounter(), dataverses, datasets); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 936 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 937 | } |
| 938 | |
| 939 | UpdateStatement UpdateStatement() throws ParseException: |
| 940 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 941 | VariableExpr vars; |
| 942 | Expression target; |
| 943 | Expression condition; |
| 944 | UpdateClause uc; |
| 945 | List<UpdateClause> ucs = new ArrayList<UpdateClause>(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 946 | } |
| 947 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 948 | "update" vars = Variable() <IN> target = Expression() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 949 | <WHERE> condition = Expression() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 950 | <LEFTPAREN> (uc = UpdateClause() |
| 951 | { |
| 952 | ucs.add(uc); |
| 953 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 954 | (<COMMA> uc = UpdateClause() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 955 | { |
| 956 | ucs.add(uc); |
| 957 | } |
| 958 | )*) <RIGHTPAREN> |
| 959 | { |
| 960 | return new UpdateStatement(vars, target, condition, ucs); |
| 961 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 962 | } |
| 963 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 964 | UpdateClause UpdateClause() throws ParseException: |
| 965 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 966 | Expression target = null; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 967 | Expression value = null ; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 968 | InsertStatement is = null; |
| 969 | DeleteStatement ds = null; |
| 970 | UpdateStatement us = null; |
| 971 | Expression condition = null; |
| 972 | UpdateClause ifbranch = null; |
| 973 | UpdateClause elsebranch = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 974 | } |
| 975 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 976 | "set" target = Expression() <ASSIGN> value = Expression() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 977 | | is = InsertStatement() |
| 978 | | ds = DeleteStatement() |
| 979 | | us = UpdateStatement() |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 980 | | <IF> <LEFTPAREN> condition = Expression() <RIGHTPAREN> |
| 981 | <THEN> ifbranch = UpdateClause() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 982 | [LOOKAHEAD(1) <ELSE> elsebranch = UpdateClause()] |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 983 | { |
| 984 | return new UpdateClause(target, value, is, ds, us, condition, ifbranch, elsebranch); |
| 985 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 986 | } |
| 987 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 988 | Statement SetStatement() throws ParseException: |
| 989 | { |
| 990 | String pn = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 991 | String pv = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 992 | } |
| 993 | { |
Till Westmann | 7d53532 | 2013-05-09 00:40:02 -0700 | [diff] [blame] | 994 | "set" pn = Identifier() pv = StringLiteral() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 995 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 996 | return new SetStatement(pn, pv); |
| 997 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | Statement WriteStatement() throws ParseException: |
| 1001 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1002 | String nodeName = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1003 | String fileName = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1004 | Query query; |
| 1005 | String writerClass = null; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1006 | Pair<Identifier,Identifier> nameComponents = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1007 | } |
| 1008 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1009 | "write" "output" "to" nodeName = Identifier() <COLON> fileName = StringLiteral() |
Till Westmann | 7d53532 | 2013-05-09 00:40:02 -0700 | [diff] [blame] | 1010 | ( "using" writerClass = StringLiteral() )? |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1011 | { |
| 1012 | return new WriteStatement(new Identifier(nodeName), fileName, writerClass); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1013 | } |
| 1014 | } |
| 1015 | |
zheilbron | 28e026f | 2013-11-20 10:15:15 -0800 | [diff] [blame] | 1016 | LoadStatement LoadStatement() throws ParseException: |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1017 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1018 | Identifier dataverseName = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1019 | Identifier datasetName = null; |
| 1020 | boolean alreadySorted = false; |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 1021 | String adapterName; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1022 | Map<String,String> properties; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1023 | Pair<Identifier,Identifier> nameComponents = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1024 | } |
| 1025 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1026 | "load" <DATASET> nameComponents = QualifiedName() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1027 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1028 | dataverseName = nameComponents.first; |
| 1029 | datasetName = nameComponents.second; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1030 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1031 | "using" adapterName = AdapterName() properties = Configuration() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1032 | ("pre-sorted" |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1033 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1034 | alreadySorted = true; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1035 | } |
| 1036 | )? |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1037 | { |
zheilbron | 28e026f | 2013-11-20 10:15:15 -0800 | [diff] [blame] | 1038 | return new LoadStatement(dataverseName, datasetName, adapterName, properties, alreadySorted); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1039 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1040 | } |
| 1041 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1042 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1043 | String AdapterName() throws ParseException : |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1044 | { |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 1045 | String adapterName = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1046 | } |
| 1047 | { |
Till Westmann | 68d9965 | 2013-05-09 11:15:21 -0700 | [diff] [blame] | 1048 | adapterName = Identifier() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1049 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1050 | return adapterName; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1051 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1052 | } |
| 1053 | |
salsubaiee | 0b423fa | 2013-09-19 19:16:48 -0700 | [diff] [blame] | 1054 | Statement CompactStatement() throws ParseException: |
| 1055 | { |
| 1056 | Pair<Identifier,Identifier> nameComponents = null; |
| 1057 | Statement stmt = null; |
| 1058 | } |
| 1059 | { |
| 1060 | "compact" <DATASET> nameComponents = QualifiedName() |
| 1061 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1062 | stmt = new CompactStatement(nameComponents.first, nameComponents.second); |
salsubaiee | 0b423fa | 2013-09-19 19:16:48 -0700 | [diff] [blame] | 1063 | } |
| 1064 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1065 | return stmt; |
salsubaiee | 0b423fa | 2013-09-19 19:16:48 -0700 | [diff] [blame] | 1066 | } |
| 1067 | } |
| 1068 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1069 | Statement FeedStatement() throws ParseException: |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1070 | { |
ramangrover29 | a774ef2 | 2013-07-17 09:29:18 -0700 | [diff] [blame] | 1071 | Pair<Identifier,Identifier> feedNameComponents = null; |
| 1072 | Pair<Identifier,Identifier> datasetNameComponents = null; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1073 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1074 | Map<String,String> configuration = null; |
| 1075 | Statement stmt = null; |
ramangrover29 | 566b3a9 | 2013-05-28 09:07:10 -0700 | [diff] [blame] | 1076 | String policy = null; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1077 | } |
| 1078 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1079 | ( |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1080 | "connect" "feed" feedNameComponents = QualifiedName() "to" <DATASET> datasetNameComponents = QualifiedName() (policy = GetPolicy())? |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1081 | { |
ramangrover29 | a774ef2 | 2013-07-17 09:29:18 -0700 | [diff] [blame] | 1082 | stmt = new ConnectFeedStatement(feedNameComponents, datasetNameComponents, policy, getVarCounter()); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1083 | } |
buyingyi | 2fd7fa6 | 2014-11-24 19:31:55 -0800 | [diff] [blame] | 1084 | | "disconnect" "feed" feedNameComponents = QualifiedName() <FROM> <DATASET> datasetNameComponents = QualifiedName() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1085 | { |
ramangrover29 | a774ef2 | 2013-07-17 09:29:18 -0700 | [diff] [blame] | 1086 | stmt = new DisconnectFeedStatement(feedNameComponents, datasetNameComponents); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1087 | } |
| 1088 | ) |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1089 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1090 | return stmt; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1091 | } |
| 1092 | } |
| 1093 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1094 | Map<String,String> Configuration() throws ParseException : |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1095 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1096 | Map<String,String> configuration = new LinkedHashMap<String,String>(); |
| 1097 | Pair<String, String> keyValuePair = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1098 | } |
| 1099 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1100 | <LEFTPAREN> ( keyValuePair = KeyValuePair() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1101 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1102 | configuration.put(keyValuePair.first, keyValuePair.second); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1103 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1104 | ( <COMMA> keyValuePair = KeyValuePair() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1105 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1106 | configuration.put(keyValuePair.first, keyValuePair.second); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1107 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1108 | )* )? <RIGHTPAREN> |
| 1109 | { |
| 1110 | return configuration; |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | Pair<String, String> KeyValuePair() throws ParseException: |
| 1115 | { |
| 1116 | String key; |
| 1117 | String value; |
| 1118 | } |
| 1119 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1120 | <LEFTPAREN> key = StringLiteral() <EQ> value = StringLiteral() <RIGHTPAREN> |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1121 | { |
| 1122 | return new Pair<String, String>(key, value); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1123 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1124 | } |
| 1125 | |
| 1126 | Map<String,String> Properties() throws ParseException: |
| 1127 | { |
| 1128 | Map<String,String> properties = new HashMap<String,String>(); |
| 1129 | Pair<String, String> property; |
| 1130 | } |
| 1131 | { |
| 1132 | ( <LEFTPAREN> property = Property() |
| 1133 | { |
| 1134 | properties.put(property.first, property.second); |
| 1135 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1136 | ( <COMMA> property = Property() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1137 | { |
| 1138 | properties.put(property.first, property.second); |
| 1139 | } |
| 1140 | )* <RIGHTPAREN> )? |
| 1141 | { |
| 1142 | return properties; |
| 1143 | } |
| 1144 | } |
| 1145 | |
| 1146 | Pair<String, String> Property() throws ParseException: |
| 1147 | { |
| 1148 | String key; |
| 1149 | String value; |
| 1150 | } |
| 1151 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1152 | key = Identifier() <EQ> ( value = StringLiteral() | <INTEGER_LITERAL> |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1153 | { |
| 1154 | try { |
| 1155 | value = "" + Long.valueOf(token.image); |
| 1156 | } catch (NumberFormatException nfe) { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1157 | throw new ParseException("inapproriate value: " + token.image); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1158 | } |
| 1159 | } |
| 1160 | ) |
| 1161 | { |
| 1162 | return new Pair<String, String>(key.toUpperCase(), value); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1163 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1164 | } |
| 1165 | |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 1166 | TypeExpression IndexedTypeExpr() throws ParseException: |
| 1167 | { |
| 1168 | TypeExpression typeExpr = null; |
| 1169 | } |
| 1170 | { |
| 1171 | ( |
| 1172 | typeExpr = TypeReference() |
| 1173 | | typeExpr = OrderedListTypeDef() |
| 1174 | | typeExpr = UnorderedListTypeDef() |
| 1175 | ) |
| 1176 | { |
| 1177 | return typeExpr; |
| 1178 | } |
| 1179 | } |
| 1180 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1181 | TypeExpression TypeExpr() throws ParseException: |
| 1182 | { |
| 1183 | TypeExpression typeExpr = null; |
| 1184 | } |
| 1185 | { |
| 1186 | ( |
| 1187 | typeExpr = RecordTypeDef() |
| 1188 | | typeExpr = TypeReference() |
| 1189 | | typeExpr = OrderedListTypeDef() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1190 | | typeExpr = UnorderedListTypeDef() |
| 1191 | ) |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1192 | { |
| 1193 | return typeExpr; |
| 1194 | } |
| 1195 | } |
| 1196 | |
| 1197 | RecordTypeDefinition RecordTypeDef() throws ParseException: |
| 1198 | { |
| 1199 | RecordTypeDefinition recType = new RecordTypeDefinition(); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1200 | RecordTypeDefinition.RecordKind recordKind = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1201 | } |
| 1202 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1203 | ( "closed" { recordKind = RecordTypeDefinition.RecordKind.CLOSED; } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1204 | | "open" { recordKind = RecordTypeDefinition.RecordKind.OPEN; } )? |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1205 | <LEFTBRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1206 | { |
| 1207 | String hint = getHint(token); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1208 | if (hint != null) { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1209 | String splits[] = hint.split(" +"); |
| 1210 | if (splits[0].equals(GEN_FIELDS_HINT)) { |
| 1211 | if (splits.length != 5) { |
| 1212 | throw new ParseException("Expecting: /*+ gen-fields <type> <min> <max> <prefix>*/"); |
| 1213 | } |
| 1214 | if (!splits[1].equals("int")) { |
| 1215 | throw new ParseException("The only supported type for gen-fields is int."); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1216 | } |
| 1217 | UndeclaredFieldsDataGen ufdg = new UndeclaredFieldsDataGen(UndeclaredFieldsDataGen.Type.INT, |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1218 | Integer.parseInt(splits[2]), Integer.parseInt(splits[3]), splits[4]); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1219 | recType.setUndeclaredFieldsDataGen(ufdg); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1220 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1221 | } |
| 1222 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1223 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1224 | ( |
| 1225 | RecordField(recType) |
| 1226 | ( <COMMA> RecordField(recType) )* |
| 1227 | )? |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1228 | <RIGHTBRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1229 | { |
| 1230 | if (recordKind == null) { |
| 1231 | recordKind = RecordTypeDefinition.RecordKind.OPEN; |
| 1232 | } |
| 1233 | recType.setRecordKind(recordKind); |
| 1234 | return recType; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1235 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1236 | } |
| 1237 | |
| 1238 | void RecordField(RecordTypeDefinition recType) throws ParseException: |
| 1239 | { |
Till Westmann | 77cb2f4 | 2013-07-15 16:44:19 -0700 | [diff] [blame] | 1240 | String fieldName; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1241 | TypeExpression type = null; |
Till Westmann | 77cb2f4 | 2013-07-15 16:44:19 -0700 | [diff] [blame] | 1242 | boolean nullable = false; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1243 | } |
| 1244 | { |
Till Westmann | 77cb2f4 | 2013-07-15 16:44:19 -0700 | [diff] [blame] | 1245 | fieldName = Identifier() |
| 1246 | { |
| 1247 | String hint = getHint(token); |
| 1248 | IRecordFieldDataGen rfdg = hint != null ? parseFieldDataGen(hint) : null; |
| 1249 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1250 | <COLON> type = TypeExpr() (<QUES> { nullable = true; } )? |
Till Westmann | 77cb2f4 | 2013-07-15 16:44:19 -0700 | [diff] [blame] | 1251 | { |
| 1252 | recType.addField(fieldName, type, nullable, rfdg); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1253 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1254 | } |
| 1255 | |
| 1256 | TypeReferenceExpression TypeReference() throws ParseException: |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1257 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1258 | String id = null; |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1259 | } |
| 1260 | { |
| 1261 | id = Identifier() |
| 1262 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1263 | if (id.equalsIgnoreCase("int")) { |
| 1264 | id = "int64"; |
| 1265 | } |
| 1266 | |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1267 | return new TypeReferenceExpression(new Identifier(id)); |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1268 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1269 | } |
| 1270 | |
| 1271 | OrderedListTypeDefinition OrderedListTypeDef() throws ParseException: |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1272 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1273 | TypeExpression type = null; |
| 1274 | } |
| 1275 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1276 | <LEFTBRACKET> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1277 | ( type = TypeExpr() ) |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1278 | <RIGHTBRACKET> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1279 | { |
| 1280 | return new OrderedListTypeDefinition(type); |
| 1281 | } |
| 1282 | } |
| 1283 | |
| 1284 | |
| 1285 | UnorderedListTypeDefinition UnorderedListTypeDef() throws ParseException: |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1286 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1287 | TypeExpression type = null; |
| 1288 | } |
| 1289 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1290 | <LEFTDBLBRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1291 | ( type = TypeExpr() ) |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1292 | <RIGHTDBLBRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1293 | { |
| 1294 | return new UnorderedListTypeDefinition(type); |
| 1295 | } |
| 1296 | } |
| 1297 | |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 1298 | FunctionName FunctionName() throws ParseException: |
| 1299 | { |
| 1300 | String first = null; |
| 1301 | String second = null; |
| 1302 | String third = null; |
| 1303 | boolean secondAfterDot = false; |
| 1304 | } |
| 1305 | { |
zheilbron | 555dc9d | 2013-08-14 19:58:00 -0700 | [diff] [blame] | 1306 | first = Identifier() ( <DOT> second = Identifier() |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 1307 | { |
| 1308 | secondAfterDot = true; |
| 1309 | } |
| 1310 | ("#" third = Identifier())? | "#" second = Identifier() )? |
| 1311 | { |
| 1312 | FunctionName result = new FunctionName(); |
| 1313 | if (second == null) { |
| 1314 | result.dataverse = defaultDataverse; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1315 | result.library = null; |
| 1316 | result.function = first; |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 1317 | } else if (third == null) { |
| 1318 | if (secondAfterDot) { |
| 1319 | result.dataverse = first; |
| 1320 | result.library = null; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1321 | result.function = second; |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 1322 | } else { |
| 1323 | result.dataverse = defaultDataverse; |
| 1324 | result.library = first; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1325 | result.function = second; |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 1326 | } |
| 1327 | } else { |
| 1328 | result.dataverse = first; |
| 1329 | result.library = second; |
| 1330 | result.function = third; |
| 1331 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1332 | |
| 1333 | if (result.function.equalsIgnoreCase("int")) { |
| 1334 | result.function = "int64"; |
| 1335 | } |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 1336 | return result; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1337 | } |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 1338 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1339 | |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 1340 | |
| 1341 | Pair<Identifier,Identifier> TypeName() throws ParseException: |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1342 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1343 | Pair<Identifier,Identifier> name = null; |
| 1344 | } |
| 1345 | { |
| 1346 | name = QualifiedName() |
| 1347 | { |
| 1348 | if (name.first == null) { |
| 1349 | name.first = new Identifier(defaultDataverse); |
| 1350 | } |
| 1351 | return name; |
| 1352 | } |
| 1353 | } |
| 1354 | |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1355 | String Identifier() throws ParseException: |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1356 | { |
Till Westmann | 68d9965 | 2013-05-09 11:15:21 -0700 | [diff] [blame] | 1357 | String lit = null; |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1358 | } |
| 1359 | { |
| 1360 | <IDENTIFIER> |
| 1361 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1362 | return token.image; |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1363 | } |
Till Westmann | 68d9965 | 2013-05-09 11:15:21 -0700 | [diff] [blame] | 1364 | | lit = StringLiteral() |
| 1365 | { |
| 1366 | return lit; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1367 | } |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1368 | } |
| 1369 | |
Ildar Absalyamov | 04b2b77 | 2015-03-19 15:09:51 -0700 | [diff] [blame] | 1370 | Pair<List<String>, TypeExpression> OpenField() throws ParseException: |
| 1371 | { |
| 1372 | TypeExpression fieldType = null; |
| 1373 | List<String> fieldList = null; |
| 1374 | } |
| 1375 | { |
| 1376 | fieldList = NestedField() |
| 1377 | ( <COLON> fieldType = IndexedTypeExpr() )? |
| 1378 | { |
| 1379 | return new Pair<List<String>, TypeExpression>(fieldList, fieldType); |
| 1380 | } |
| 1381 | } |
| 1382 | |
| 1383 | List<String> NestedField() throws ParseException: |
| 1384 | { |
| 1385 | List<String> exprList = new ArrayList<String>(); |
| 1386 | String lit = null; |
| 1387 | } |
| 1388 | { |
| 1389 | lit = Identifier() |
| 1390 | { |
| 1391 | exprList.add(lit); |
| 1392 | } |
| 1393 | (<DOT> |
| 1394 | lit = Identifier() |
| 1395 | { |
| 1396 | exprList.add(lit); |
| 1397 | } |
| 1398 | )* |
| 1399 | { |
| 1400 | return exprList; |
| 1401 | } |
| 1402 | } |
| 1403 | |
| 1404 | |
| 1405 | |
Till Westmann | 7d53532 | 2013-05-09 00:40:02 -0700 | [diff] [blame] | 1406 | String StringLiteral() throws ParseException: |
| 1407 | { |
| 1408 | } |
| 1409 | { |
| 1410 | <STRING_LITERAL> |
| 1411 | { |
| 1412 | return removeQuotesAndEscapes(token.image); |
| 1413 | } |
| 1414 | } |
| 1415 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1416 | Pair<Identifier,Identifier> QualifiedName() throws ParseException: |
| 1417 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1418 | String first = null; |
| 1419 | String second = null; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1420 | } |
| 1421 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1422 | first = Identifier() (<DOT> second = Identifier())? |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1423 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1424 | Identifier id1 = null; |
| 1425 | Identifier id2 = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1426 | if (second == null) { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1427 | id2 = new Identifier(first); |
| 1428 | } else |
| 1429 | { |
| 1430 | id1 = new Identifier(first); |
| 1431 | id2 = new Identifier(second); |
| 1432 | } |
| 1433 | return new Pair<Identifier,Identifier>(id1, id2); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1434 | } |
| 1435 | } |
| 1436 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1437 | Triple<Identifier,Identifier,Identifier> DoubleQualifiedName() throws ParseException: |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1438 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1439 | String first = null; |
| 1440 | String second = null; |
| 1441 | String third = null; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1442 | } |
| 1443 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1444 | first = Identifier() <DOT> second = Identifier() (<DOT> third = Identifier())? |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1445 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1446 | Identifier id1 = null; |
| 1447 | Identifier id2 = null; |
| 1448 | Identifier id3 = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1449 | if (third == null) { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1450 | id2 = new Identifier(first); |
| 1451 | id3 = new Identifier(second); |
| 1452 | } else { |
| 1453 | id1 = new Identifier(first); |
| 1454 | id2 = new Identifier(second); |
| 1455 | id3 = new Identifier(third); |
| 1456 | } |
| 1457 | return new Triple<Identifier,Identifier,Identifier>(id1, id2, id3); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1458 | } |
| 1459 | } |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1460 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1461 | FunctionDecl FunctionDeclaration() throws ParseException: |
| 1462 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1463 | FunctionDecl funcDecl; |
| 1464 | FunctionSignature signature; |
ramangrover29 | a13f242 | 2012-03-15 23:01:27 +0000 | [diff] [blame] | 1465 | String functionName; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1466 | List<VarIdentifier> paramList = new ArrayList<VarIdentifier>(); |
| 1467 | Expression funcBody; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1468 | createNewScope(); |
| 1469 | } |
| 1470 | { |
Till Westmann | d7dcb12 | 2013-05-16 13:19:09 -0700 | [diff] [blame] | 1471 | "declare" "function" functionName = Identifier() |
| 1472 | paramList = ParameterList() |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1473 | <LEFTBRACE> funcBody = Expression() <RIGHTBRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1474 | { |
Till Westmann | d7dcb12 | 2013-05-16 13:19:09 -0700 | [diff] [blame] | 1475 | signature = new FunctionSignature(defaultDataverse, functionName, paramList.size()); |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1476 | getCurrentScope().addFunctionDescriptor(signature, false); |
| 1477 | funcDecl = new FunctionDecl(signature, paramList, funcBody); |
Till Westmann | c6c4a74 | 2013-05-20 17:59:21 -0700 | [diff] [blame] | 1478 | removeCurrentScope(); |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1479 | return funcDecl; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1480 | } |
| 1481 | } |
| 1482 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1483 | |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1484 | Query Query() throws ParseException: |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1485 | { |
| 1486 | Query query = new Query(); |
Abdullah Alamoudi | db37f66 | 2014-07-14 21:51:37 +0300 | [diff] [blame] | 1487 | // we set the pointers to the dataverses and datasets lists to fill them with entities to be locked |
| 1488 | setDataverses(query.getDataverses()); |
| 1489 | setDatasets(query.getDatasets()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1490 | Expression expr; |
| 1491 | } |
| 1492 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 1493 | expr = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1494 | { |
| 1495 | query.setBody(expr); |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1496 | query.setVarCounter(getVarCounter()); |
Abdullah Alamoudi | db37f66 | 2014-07-14 21:51:37 +0300 | [diff] [blame] | 1497 | // we remove the pointers to the locked entities before we return the query object |
| 1498 | setDataverses(null); |
| 1499 | setDatasets(null); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1500 | return query; |
| 1501 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1502 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1503 | } |
| 1504 | |
| 1505 | |
| 1506 | |
| 1507 | Expression Expression(): |
| 1508 | { |
| 1509 | Expression expr = null; |
| 1510 | Expression exprP = null; |
| 1511 | } |
| 1512 | { |
| 1513 | ( |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1514 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1515 | //OperatorExpr | IfThenElse | FLWOGRExpression | QuantifiedExpression |
| 1516 | expr = OperatorExpr() |
| 1517 | | expr = IfThenElse() |
| 1518 | | expr = FLWOGR() |
| 1519 | | expr = QuantifiedExpression() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1520 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1521 | |
| 1522 | ) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1523 | { |
| 1524 | return (exprP==null) ? expr : exprP; |
| 1525 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1526 | } |
| 1527 | |
| 1528 | |
| 1529 | |
| 1530 | Expression OperatorExpr()throws ParseException: |
| 1531 | { |
| 1532 | OperatorExpr op = null; |
| 1533 | Expression operand = null; |
| 1534 | } |
| 1535 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1536 | operand = AndExpr() |
| 1537 | ( |
| 1538 | |
| 1539 | <OR> |
| 1540 | { |
| 1541 | if (op == null) { |
| 1542 | op = new OperatorExpr(); |
| 1543 | op.addOperand(operand); |
| 1544 | op.setCurrentop(true); |
| 1545 | } |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1546 | op.addOperator(token.image); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1547 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1548 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1549 | operand = AndExpr() |
| 1550 | { |
| 1551 | op.addOperand(operand); |
| 1552 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1553 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1554 | )* |
| 1555 | |
| 1556 | { |
| 1557 | return op==null? operand: op; |
| 1558 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1559 | } |
| 1560 | |
| 1561 | Expression AndExpr()throws ParseException: |
| 1562 | { |
| 1563 | OperatorExpr op = null; |
| 1564 | Expression operand = null; |
| 1565 | } |
| 1566 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1567 | operand = RelExpr() |
| 1568 | ( |
| 1569 | |
| 1570 | <AND> |
| 1571 | { |
| 1572 | if (op == null) { |
| 1573 | op = new OperatorExpr(); |
| 1574 | op.addOperand(operand); |
| 1575 | op.setCurrentop(true); |
| 1576 | } |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1577 | op.addOperator(token.image); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1578 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1579 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1580 | operand = RelExpr() |
| 1581 | { |
| 1582 | op.addOperand(operand); |
| 1583 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1584 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1585 | )* |
| 1586 | |
| 1587 | { |
| 1588 | return op==null? operand: op; |
| 1589 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1590 | } |
| 1591 | |
| 1592 | |
| 1593 | |
| 1594 | Expression RelExpr()throws ParseException: |
| 1595 | { |
| 1596 | OperatorExpr op = null; |
| 1597 | Expression operand = null; |
| 1598 | boolean broadcast = false; |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1599 | IExpressionAnnotation annotation = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1600 | } |
| 1601 | { |
| 1602 | operand = AddExpr() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1603 | { |
| 1604 | if (operand instanceof VariableExpr) { |
| 1605 | String hint = getHint(token); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1606 | if (hint != null && hint.equals(BROADCAST_JOIN_HINT)) { |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1607 | broadcast = true; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1608 | } |
| 1609 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1610 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1611 | |
| 1612 | ( |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1613 | LOOKAHEAD(2)( <LT> | <GT> | <LE> | <GE> | <EQ> | <NE> |<SIMILAR>) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1614 | { |
| 1615 | String mhint = getHint(token); |
| 1616 | if (mhint != null) { |
| 1617 | if (mhint.equals(INDEXED_NESTED_LOOP_JOIN_HINT)) { |
salsubaiee | df89fbc | 2013-12-21 19:51:42 -0800 | [diff] [blame] | 1618 | annotation = IndexedNLJoinExpressionAnnotation.INSTANCE; |
| 1619 | } else if (mhint.equals(SKIP_SECONDARY_INDEX_SEARCH_HINT)) { |
| 1620 | annotation = SkipSecondaryIndexSearchExpressionAnnotation.INSTANCE; |
| 1621 | } |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1622 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1623 | if (op == null) { |
| 1624 | op = new OperatorExpr(); |
| 1625 | op.addOperand(operand, broadcast); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1626 | op.setCurrentop(true); |
| 1627 | broadcast = false; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1628 | } |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1629 | op.addOperator(token.image); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1630 | } |
| 1631 | |
| 1632 | operand = AddExpr() |
| 1633 | { |
| 1634 | broadcast = false; |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1635 | if (operand instanceof VariableExpr) { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1636 | String hint = getHint(token); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1637 | if (hint != null && hint.equals(BROADCAST_JOIN_HINT)) { |
| 1638 | broadcast = true; |
| 1639 | } |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1640 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1641 | op.addOperand(operand, broadcast); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1642 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1643 | )? |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1644 | |
| 1645 | { |
| 1646 | if (annotation != null) { |
| 1647 | op.addHint(annotation); |
| 1648 | } |
| 1649 | return op==null? operand: op; |
| 1650 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1651 | } |
| 1652 | |
| 1653 | Expression AddExpr()throws ParseException: |
| 1654 | { |
| 1655 | OperatorExpr op = null; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1656 | Expression operand = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1657 | } |
| 1658 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1659 | operand = MultExpr() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1660 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1661 | ( (<PLUS> | <MINUS>) |
| 1662 | { |
| 1663 | if (op == null) { |
| 1664 | op = new OperatorExpr(); |
| 1665 | op.addOperand(operand); |
| 1666 | op.setCurrentop(true); |
| 1667 | } |
| 1668 | ((OperatorExpr)op).addOperator(token.image); |
| 1669 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1670 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1671 | operand = MultExpr() |
| 1672 | { |
| 1673 | op.addOperand(operand); |
| 1674 | } |
| 1675 | )* |
| 1676 | |
| 1677 | { |
| 1678 | return op==null? operand: op; |
| 1679 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1680 | } |
| 1681 | |
| 1682 | Expression MultExpr()throws ParseException: |
| 1683 | { |
| 1684 | OperatorExpr op = null; |
| 1685 | Expression operand = null; |
| 1686 | } |
| 1687 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1688 | operand = UnionExpr() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1689 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1690 | (( <MUL> | <DIV> | <MOD> | <CARET> | <IDIV>) |
| 1691 | { |
| 1692 | if (op == null) { |
| 1693 | op = new OperatorExpr(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1694 | op.addOperand(operand); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1695 | op.setCurrentop(true); |
| 1696 | } |
| 1697 | op.addOperator(token.image); |
| 1698 | } |
| 1699 | operand = UnionExpr() |
| 1700 | { |
| 1701 | op.addOperand(operand); |
| 1702 | } |
| 1703 | )* |
| 1704 | |
| 1705 | { |
| 1706 | return op==null?operand:op; |
| 1707 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1708 | } |
| 1709 | |
| 1710 | Expression UnionExpr() throws ParseException: |
| 1711 | { |
| 1712 | UnionExpr union = null; |
| 1713 | Expression operand1 = null; |
| 1714 | Expression operand2 = null; |
| 1715 | } |
| 1716 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1717 | operand1 = UnaryExpr() |
| 1718 | (<UNION> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1719 | (operand2 = UnaryExpr()) { |
| 1720 | if (union == null) { |
| 1721 | union = new UnionExpr(); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1722 | union.addExpr(operand1); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1723 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1724 | union.addExpr(operand2); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1725 | } )* |
| 1726 | { |
| 1727 | return (union == null)? operand1: union; |
| 1728 | } |
| 1729 | } |
| 1730 | |
| 1731 | Expression UnaryExpr() throws ParseException: |
| 1732 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1733 | Expression uexpr = null; |
| 1734 | Expression expr = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1735 | } |
| 1736 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1737 | ( (<PLUS> | <MINUS>) |
| 1738 | { |
| 1739 | uexpr = new UnaryExpr(); |
| 1740 | if("+".equals(token.image)) |
| 1741 | ((UnaryExpr)uexpr).setSign(Sign.POSITIVE); |
| 1742 | else if("-".equals(token.image)) |
| 1743 | ((UnaryExpr)uexpr).setSign(Sign.NEGATIVE); |
| 1744 | else |
| 1745 | throw new ParseException(); |
| 1746 | } |
| 1747 | )? |
| 1748 | |
| 1749 | expr = ValueExpr() |
| 1750 | { |
| 1751 | if(uexpr!=null){ |
| 1752 | ((UnaryExpr)uexpr).setExpr(expr); |
| 1753 | return uexpr; |
| 1754 | } |
| 1755 | else{ |
| 1756 | return expr; |
| 1757 | } |
| 1758 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1759 | } |
| 1760 | |
Till Westmann | 04478e7 | 2013-05-13 23:01:34 -0700 | [diff] [blame] | 1761 | Expression ValueExpr()throws ParseException: |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1762 | { |
| 1763 | Expression expr = null; |
| 1764 | Identifier ident = null; |
| 1765 | AbstractAccessor fa = null; |
icetindil | a611ac7 | 2014-05-16 10:10:11 -0700 | [diff] [blame] | 1766 | Expression indexExpr = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1767 | } |
| 1768 | { |
Till Westmann | 04478e7 | 2013-05-13 23:01:34 -0700 | [diff] [blame] | 1769 | expr = PrimaryExpr() ( ident = Field() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1770 | { |
| 1771 | fa = (fa == null ? new FieldAccessor(expr, ident) |
Till Westmann | 04478e7 | 2013-05-13 23:01:34 -0700 | [diff] [blame] | 1772 | : new FieldAccessor(fa, ident)); |
| 1773 | } |
icetindil | a611ac7 | 2014-05-16 10:10:11 -0700 | [diff] [blame] | 1774 | | indexExpr = Index() |
Till Westmann | 04478e7 | 2013-05-13 23:01:34 -0700 | [diff] [blame] | 1775 | { |
icetindil | a611ac7 | 2014-05-16 10:10:11 -0700 | [diff] [blame] | 1776 | fa = (fa == null ? new IndexAccessor(expr, indexExpr) |
| 1777 | : new IndexAccessor(fa, indexExpr)); |
Till Westmann | 04478e7 | 2013-05-13 23:01:34 -0700 | [diff] [blame] | 1778 | } |
| 1779 | )* |
| 1780 | { |
| 1781 | return fa == null ? expr : fa; |
| 1782 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1783 | } |
| 1784 | |
| 1785 | Identifier Field() throws ParseException: |
| 1786 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1787 | String ident = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1788 | } |
| 1789 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1790 | <DOT> ident = Identifier() |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1791 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 1792 | return new Identifier(ident); |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1793 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1794 | } |
| 1795 | |
icetindil | a611ac7 | 2014-05-16 10:10:11 -0700 | [diff] [blame] | 1796 | Expression Index() throws ParseException: |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1797 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1798 | Expression expr = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1799 | } |
| 1800 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1801 | <LEFTBRACKET> ( expr = Expression() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1802 | { |
| 1803 | if(expr.getKind() == Expression.Kind.LITERAL_EXPRESSION) |
| 1804 | { |
| 1805 | Literal lit = ((LiteralExpr)expr).getValue(); |
| 1806 | if(lit.getLiteralType() != Literal.Type.INTEGER && |
| 1807 | lit.getLiteralType() != Literal.Type.LONG) { |
| 1808 | throw new ParseException("Index should be an INTEGER"); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1809 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1810 | } |
| 1811 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1812 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1813 | | <QUES> // ANY |
| 1814 | |
| 1815 | ) |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1816 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1817 | <RIGHTBRACKET> |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1818 | { |
| 1819 | return expr; |
| 1820 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1821 | } |
| 1822 | |
| 1823 | |
| 1824 | Expression PrimaryExpr()throws ParseException: |
| 1825 | { |
| 1826 | Expression expr = null; |
| 1827 | } |
| 1828 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1829 | ( LOOKAHEAD(2) |
Till Westmann | 68d9965 | 2013-05-09 11:15:21 -0700 | [diff] [blame] | 1830 | expr = FunctionCallExpr() |
| 1831 | | expr = Literal() |
| 1832 | | expr = DatasetAccessExpression() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1833 | | expr = VariableRef() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1834 | { |
| 1835 | if(((VariableExpr)expr).getIsNewVar() == true) |
Till Westmann | 68d9965 | 2013-05-09 11:15:21 -0700 | [diff] [blame] | 1836 | throw new ParseException("can't find variable " + ((VariableExpr)expr).getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1837 | } |
Till Westmann | 68d9965 | 2013-05-09 11:15:21 -0700 | [diff] [blame] | 1838 | | expr = ListConstructor() |
| 1839 | | expr = RecordConstructor() |
| 1840 | | expr = ParenthesizedExpression() |
| 1841 | ) |
| 1842 | { |
| 1843 | return expr; |
| 1844 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1845 | } |
| 1846 | |
| 1847 | Expression Literal() throws ParseException: |
| 1848 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1849 | LiteralExpr lit = new LiteralExpr(); |
Till Westmann | 7d53532 | 2013-05-09 00:40:02 -0700 | [diff] [blame] | 1850 | String str = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1851 | } |
| 1852 | { |
Till Westmann | 7d53532 | 2013-05-09 00:40:02 -0700 | [diff] [blame] | 1853 | ( str = StringLiteral() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1854 | { |
Till Westmann | 7d53532 | 2013-05-09 00:40:02 -0700 | [diff] [blame] | 1855 | lit.setValue(new StringLiteral(str)); |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1856 | } |
| 1857 | | <INTEGER_LITERAL> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1858 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1859 | lit.setValue(new LongIntegerLiteral(new Long(token.image))); |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1860 | } |
| 1861 | | <FLOAT_LITERAL> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1862 | { |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1863 | lit.setValue(new FloatLiteral(new Float(token.image))); |
| 1864 | } |
| 1865 | | <DOUBLE_LITERAL> |
| 1866 | { |
| 1867 | lit.setValue(new DoubleLiteral(new Double(token.image))); |
| 1868 | } |
| 1869 | | <NULL> |
| 1870 | { |
| 1871 | lit.setValue(NullLiteral.INSTANCE); |
| 1872 | } |
| 1873 | | <TRUE> |
| 1874 | { |
| 1875 | lit.setValue(TrueLiteral.INSTANCE); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1876 | } |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1877 | | <FALSE> |
| 1878 | { |
| 1879 | lit.setValue(FalseLiteral.INSTANCE); |
| 1880 | } |
| 1881 | ) |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1882 | { |
| 1883 | return lit; |
| 1884 | } |
| 1885 | } |
| 1886 | |
| 1887 | |
| 1888 | VariableExpr VariableRef() throws ParseException: |
| 1889 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1890 | VariableExpr varExp = new VariableExpr(); |
| 1891 | VarIdentifier var = new VarIdentifier(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1892 | } |
| 1893 | { |
Till Westmann | 4f58e1a | 2013-05-20 18:29:54 -0700 | [diff] [blame] | 1894 | <VARIABLE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1895 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1896 | String varName = token.image; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1897 | Identifier ident = lookupSymbol(varName); |
| 1898 | if (isInForbiddenScopes(varName)) { |
| 1899 | 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."); |
| 1900 | } |
| 1901 | if(ident != null) { // exist such ident |
| 1902 | varExp.setIsNewVar(false); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1903 | varExp.setVar((VarIdentifier)ident); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1904 | } else { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1905 | varExp.setVar(var); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1906 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1907 | var.setValue(varName); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1908 | return varExp; |
| 1909 | } |
| 1910 | } |
| 1911 | |
| 1912 | |
| 1913 | VariableExpr Variable() throws ParseException: |
| 1914 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1915 | VariableExpr varExp = new VariableExpr(); |
| 1916 | VarIdentifier var = new VarIdentifier(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1917 | } |
| 1918 | { |
Till Westmann | 4f58e1a | 2013-05-20 18:29:54 -0700 | [diff] [blame] | 1919 | <VARIABLE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1920 | { |
Till Westmann | a4242bc | 2013-05-08 17:49:55 -0700 | [diff] [blame] | 1921 | Identifier ident = lookupSymbol(token.image); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1922 | if(ident != null) { // exist such ident |
| 1923 | varExp.setIsNewVar(false); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1924 | } |
| 1925 | varExp.setVar(var); |
| 1926 | var.setValue(token.image); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1927 | return varExp; |
| 1928 | } |
| 1929 | } |
| 1930 | |
| 1931 | Expression ListConstructor() throws ParseException: |
| 1932 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1933 | Expression expr = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1934 | } |
| 1935 | { |
| 1936 | ( |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1937 | expr = OrderedListConstructor() | expr = UnorderedListConstructor() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1938 | ) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1939 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1940 | { |
| 1941 | return expr; |
| 1942 | } |
| 1943 | } |
| 1944 | |
| 1945 | |
| 1946 | ListConstructor OrderedListConstructor() throws ParseException: |
| 1947 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1948 | ListConstructor expr = new ListConstructor(); |
| 1949 | Expression tmp = null; |
| 1950 | List<Expression> exprList = new ArrayList<Expression>(); |
| 1951 | expr.setType(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1952 | } |
| 1953 | { |
| 1954 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1955 | <LEFTBRACKET> |
| 1956 | ( tmp = Expression() |
| 1957 | { |
| 1958 | exprList.add(tmp); |
| 1959 | } |
| 1960 | |
| 1961 | (<COMMA> tmp = Expression() { exprList.add(tmp); })* |
| 1962 | )? |
| 1963 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1964 | <RIGHTBRACKET> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1965 | |
| 1966 | { |
| 1967 | expr.setExprList(exprList); |
| 1968 | return expr; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1969 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1970 | } |
| 1971 | |
| 1972 | ListConstructor UnorderedListConstructor() throws ParseException: |
| 1973 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1974 | ListConstructor expr = new ListConstructor(); |
| 1975 | Expression tmp = null; |
| 1976 | List<Expression> exprList = new ArrayList<Expression>(); |
| 1977 | expr.setType(ListConstructor.Type.UNORDERED_LIST_CONSTRUCTOR); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1978 | } |
| 1979 | { |
| 1980 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1981 | <LEFTDBLBRACE> ( tmp = Expression() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1982 | { |
| 1983 | exprList.add(tmp); |
| 1984 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1985 | (<COMMA> tmp = Expression() { exprList.add(tmp); })*)? <RIGHTDBLBRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1986 | { |
| 1987 | expr.setExprList(exprList); |
| 1988 | return expr; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1989 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1990 | } |
| 1991 | |
| 1992 | RecordConstructor RecordConstructor() throws ParseException: |
| 1993 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1994 | RecordConstructor expr = new RecordConstructor(); |
| 1995 | FieldBinding tmp = null; |
| 1996 | List<FieldBinding> fbList = new ArrayList<FieldBinding>(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1997 | } |
| 1998 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 1999 | <LEFTBRACE> (tmp = FieldBinding() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2000 | { |
| 2001 | fbList.add(tmp); |
| 2002 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2003 | (<COMMA> tmp = FieldBinding() { fbList.add(tmp); })*)? <RIGHTBRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2004 | { |
| 2005 | expr.setFbList(fbList); |
| 2006 | return expr; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2007 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2008 | } |
| 2009 | |
| 2010 | FieldBinding FieldBinding() throws ParseException: |
| 2011 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2012 | FieldBinding fb = new FieldBinding(); |
| 2013 | Expression left, right; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2014 | } |
| 2015 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2016 | left = Expression() <COLON> right = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2017 | { |
| 2018 | fb.setLeftExpr(left); |
| 2019 | fb.setRightExpr(right); |
| 2020 | return fb; |
| 2021 | } |
| 2022 | } |
| 2023 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 2024 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2025 | Expression FunctionCallExpr() throws ParseException: |
| 2026 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 2027 | CallExpr callExpr; |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 2028 | List<Expression> argList = new ArrayList<Expression>(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2029 | Expression tmp; |
| 2030 | int arity = 0; |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 2031 | FunctionName funcName = null; |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 2032 | String hint = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2033 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2034 | { |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 2035 | funcName = FunctionName() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2036 | { |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 2037 | hint = getHint(token); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2038 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 2039 | <LEFTPAREN> (tmp = Expression() |
| 2040 | { |
| 2041 | argList.add(tmp); |
| 2042 | arity ++; |
| 2043 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2044 | (<COMMA> tmp = Expression() |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 2045 | { |
| 2046 | argList.add(tmp); |
| 2047 | arity++; |
| 2048 | } |
| 2049 | )*)? <RIGHTPAREN> |
| 2050 | { |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 2051 | // TODO use funcName.library |
ramangrover29 | bdba1a8 | 2013-06-21 17:17:52 -0700 | [diff] [blame] | 2052 | String fqFunctionName = funcName.library == null ? funcName.function : funcName.library + "#" + funcName.function; |
ramangrover29 | 9f76a5e | 2013-06-18 10:25:17 -0700 | [diff] [blame] | 2053 | FunctionSignature signature |
ramangrover29 | bdba1a8 | 2013-06-21 17:17:52 -0700 | [diff] [blame] | 2054 | = lookupFunctionSignature(funcName.dataverse, fqFunctionName, arity); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 2055 | if (signature == null) { |
ramangrover29 | bdba1a8 | 2013-06-21 17:17:52 -0700 | [diff] [blame] | 2056 | signature = new FunctionSignature(funcName.dataverse, fqFunctionName, arity); |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 2057 | } |
| 2058 | callExpr = new CallExpr(signature,argList); |
salsubaiee | df89fbc | 2013-12-21 19:51:42 -0800 | [diff] [blame] | 2059 | if (hint != null) { |
| 2060 | if (hint.startsWith(INDEXED_NESTED_LOOP_JOIN_HINT)) { |
| 2061 | callExpr.addHint(IndexedNLJoinExpressionAnnotation.INSTANCE); |
| 2062 | } else if (hint.startsWith(SKIP_SECONDARY_INDEX_SEARCH_HINT)) { |
| 2063 | callExpr.addHint(SkipSecondaryIndexSearchExpressionAnnotation.INSTANCE); |
| 2064 | } |
Till Westmann | 31c21f9 | 2013-05-08 09:21:53 -0700 | [diff] [blame] | 2065 | } |
| 2066 | return callExpr; |
| 2067 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2068 | } |
| 2069 | |
ramangrover29@gmail.com | 5f248e1 | 2013-04-11 01:03:09 +0000 | [diff] [blame] | 2070 | |
pouria.pirzadeh@gmail.com | fa89074 | 2013-03-07 23:59:21 +0000 | [diff] [blame] | 2071 | Expression DatasetAccessExpression() throws ParseException: |
| 2072 | { |
pouria.pirzadeh@gmail.com | fa89074 | 2013-03-07 23:59:21 +0000 | [diff] [blame] | 2073 | String funcName; |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 2074 | String arg1 = null; |
| 2075 | String arg2 = null; |
pouria.pirzadeh@gmail.com | fa89074 | 2013-03-07 23:59:21 +0000 | [diff] [blame] | 2076 | Expression nameArg; |
pouria.pirzadeh@gmail.com | fa89074 | 2013-03-07 23:59:21 +0000 | [diff] [blame] | 2077 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2078 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 2079 | <DATASET> |
| 2080 | { |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 2081 | funcName = token.image; |
| 2082 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2083 | ( ( arg1 = Identifier() ( <DOT> arg2 = Identifier() )? ) |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 2084 | { |
| 2085 | String name = arg2 == null ? arg1 : arg1 + "." + arg2; |
Till Westmann | 1f7a236 | 2013-05-24 08:43:40 -0700 | [diff] [blame] | 2086 | LiteralExpr ds = new LiteralExpr(); |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 2087 | ds.setValue( new StringLiteral(name) ); |
Till Westmann | 1f7a236 | 2013-05-24 08:43:40 -0700 | [diff] [blame] | 2088 | nameArg = ds; |
Abdullah Alamoudi | db37f66 | 2014-07-14 21:51:37 +0300 | [diff] [blame] | 2089 | if(arg2 != null){ |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2090 | addDataverse(arg1.toString()); |
| 2091 | addDataset(name); |
Abdullah Alamoudi | db37f66 | 2014-07-14 21:51:37 +0300 | [diff] [blame] | 2092 | } else { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2093 | addDataset(defaultDataverse + "." + name); |
Abdullah Alamoudi | db37f66 | 2014-07-14 21:51:37 +0300 | [diff] [blame] | 2094 | } |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 2095 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2096 | | ( <LEFTPAREN> nameArg = Expression() <RIGHTPAREN> ) ) |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 2097 | { |
Till Westmann | 1f7a236 | 2013-05-24 08:43:40 -0700 | [diff] [blame] | 2098 | String dataverse = MetadataConstants.METADATA_DATAVERSE_NAME; |
| 2099 | FunctionSignature signature = lookupFunctionSignature(dataverse, funcName, 1); |
| 2100 | if (signature == null) { |
| 2101 | signature = new FunctionSignature(dataverse, funcName, 1); |
| 2102 | } |
| 2103 | List<Expression> argList = new ArrayList<Expression>(); |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 2104 | argList.add(nameArg); |
Till Westmann | 1f7a236 | 2013-05-24 08:43:40 -0700 | [diff] [blame] | 2105 | return new CallExpr(signature, argList); |
Till Westmann | 14a20a7 | 2013-05-09 00:06:24 -0700 | [diff] [blame] | 2106 | } |
pouria.pirzadeh@gmail.com | fa89074 | 2013-03-07 23:59:21 +0000 | [diff] [blame] | 2107 | } |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 2108 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2109 | Expression ParenthesizedExpression() throws ParseException: |
| 2110 | { |
| 2111 | Expression expr; |
| 2112 | } |
| 2113 | { |
| 2114 | <LEFTPAREN> expr = Expression() <RIGHTPAREN> |
| 2115 | { |
| 2116 | return expr; |
| 2117 | } |
| 2118 | } |
| 2119 | |
| 2120 | Expression IfThenElse() throws ParseException: |
| 2121 | { |
| 2122 | Expression condExpr; |
| 2123 | Expression thenExpr; |
| 2124 | Expression elseExpr; |
| 2125 | IfExpr ifExpr = new IfExpr(); |
| 2126 | } |
| 2127 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2128 | <IF> <LEFTPAREN> condExpr = Expression() <RIGHTPAREN> <THEN> thenExpr = Expression() <ELSE> elseExpr = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2129 | |
| 2130 | { |
| 2131 | ifExpr.setCondExpr(condExpr); |
| 2132 | ifExpr.setThenExpr(thenExpr); |
| 2133 | ifExpr.setElseExpr(elseExpr); |
| 2134 | return ifExpr; |
| 2135 | } |
| 2136 | } |
| 2137 | |
| 2138 | Expression FLWOGR() throws ParseException: |
| 2139 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2140 | FLWOGRExpression flworg = new FLWOGRExpression(); |
| 2141 | List<Clause> clauseList = new ArrayList<Clause>(); |
| 2142 | Expression returnExpr; |
| 2143 | Clause tmp; |
| 2144 | createNewScope(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2145 | } |
| 2146 | { |
| 2147 | (tmp = ForClause() {clauseList.add(tmp);} | tmp = LetClause() {clauseList.add(tmp);}) |
buyingyi | 2fd7fa6 | 2014-11-24 19:31:55 -0800 | [diff] [blame] | 2148 | (tmp = Clause() {clauseList.add(tmp);})* (<RETURN>|<SELECT>) returnExpr = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2149 | |
| 2150 | { |
| 2151 | flworg.setClauseList(clauseList); |
| 2152 | flworg.setReturnExpr(returnExpr); |
| 2153 | removeCurrentScope(); |
| 2154 | return flworg; |
| 2155 | } |
| 2156 | } |
| 2157 | |
| 2158 | Clause Clause()throws ParseException : |
| 2159 | { |
| 2160 | Clause clause; |
| 2161 | } |
| 2162 | { |
| 2163 | ( |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2164 | clause = ForClause() |
| 2165 | | clause = LetClause() |
| 2166 | | clause = WhereClause() |
| 2167 | | clause = OrderbyClause() |
| 2168 | | clause = GroupClause() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2169 | | clause = LimitClause() |
| 2170 | | clause = DistinctClause() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2171 | ) |
| 2172 | { |
| 2173 | return clause; |
| 2174 | } |
| 2175 | } |
| 2176 | |
| 2177 | Clause ForClause()throws ParseException : |
| 2178 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2179 | ForClause fc = new ForClause(); |
| 2180 | VariableExpr varExp; |
| 2181 | VariableExpr varPos = null; |
| 2182 | Expression inExp; |
| 2183 | extendCurrentScope(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2184 | } |
| 2185 | { |
buyingyi | 2fd7fa6 | 2014-11-24 19:31:55 -0800 | [diff] [blame] | 2186 | (<FOR>|<FROM>) varExp = Variable() (<AT> varPos = Variable())? <IN> ( inExp = Expression() ) |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2187 | { |
| 2188 | fc.setVarExpr(varExp); |
Vinayak Borkar | 62e66c0 | 2013-05-28 13:56:11 -0700 | [diff] [blame] | 2189 | getCurrentScope().addNewVarSymbolToScope(varExp.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2190 | fc.setInExpr(inExp); |
| 2191 | if (varPos != null) { |
| 2192 | fc.setPosExpr(varPos); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2193 | getCurrentScope().addNewVarSymbolToScope(varPos.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2194 | } |
| 2195 | return fc; |
| 2196 | } |
| 2197 | } |
| 2198 | |
| 2199 | Clause LetClause() throws ParseException: |
| 2200 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2201 | LetClause lc = new LetClause(); |
| 2202 | VariableExpr varExp; |
| 2203 | Expression beExp; |
| 2204 | extendCurrentScope(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2205 | } |
| 2206 | { |
buyingyi | 2fd7fa6 | 2014-11-24 19:31:55 -0800 | [diff] [blame] | 2207 | (<LET>|<WITH>) varExp = Variable() <ASSIGN> beExp = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2208 | { |
| 2209 | getCurrentScope().addNewVarSymbolToScope(varExp.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2210 | lc.setVarExpr(varExp); |
| 2211 | lc.setBeExpr(beExp); |
| 2212 | return lc; |
| 2213 | } |
| 2214 | } |
| 2215 | |
| 2216 | Clause WhereClause()throws ParseException : |
| 2217 | { |
| 2218 | WhereClause wc = new WhereClause(); |
| 2219 | Expression whereExpr; |
| 2220 | } |
| 2221 | { |
salsubaiee | df89fbc | 2013-12-21 19:51:42 -0800 | [diff] [blame] | 2222 | <WHERE> whereExpr = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2223 | { |
| 2224 | wc.setWhereExpr(whereExpr); |
| 2225 | return wc; |
| 2226 | } |
| 2227 | } |
| 2228 | |
| 2229 | Clause OrderbyClause()throws ParseException : |
| 2230 | { |
Eldon Carman | d2d78ad | 2015-05-07 16:23:41 -0700 | [diff] [blame] | 2231 | OrderbyClause oc = new OrderbyClause(); |
| 2232 | Expression orderbyExpr; |
| 2233 | List<Expression> orderbyList = new ArrayList<Expression>(); |
| 2234 | List<OrderbyClause.OrderModifier> modifierList = new ArrayList<OrderbyClause.OrderModifier >(); |
| 2235 | int numOfOrderby = 0; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2236 | } |
| 2237 | { |
| 2238 | ( |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2239 | <ORDER> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2240 | { |
Eldon Carman | d2d78ad | 2015-05-07 16:23:41 -0700 | [diff] [blame] | 2241 | String hint = getHint(token); |
| 2242 | if (hint != null) { |
| 2243 | if (hint.startsWith(INMEMORY_HINT)) { |
| 2244 | String splits[] = hint.split(" +"); |
| 2245 | int numFrames = Integer.parseInt(splits[1]); |
| 2246 | int numTuples = Integer.parseInt(splits[2]); |
| 2247 | oc.setNumFrames(numFrames); |
| 2248 | oc.setNumTuples(numTuples); |
| 2249 | } |
| 2250 | if (hint.startsWith(RANGE_HINT)) { |
| 2251 | oc.setRangeMap(RangeMapBuilder.parseHint(hint.substring(RANGE_HINT.length()))); |
| 2252 | } |
| 2253 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2254 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2255 | <BY> orderbyExpr = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2256 | { |
| 2257 | orderbyList.add(orderbyExpr); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2258 | OrderbyClause.OrderModifier modif = OrderbyClause.OrderModifier.ASC; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2259 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2260 | ( (<ASC> { modif = OrderbyClause.OrderModifier.ASC; }) |
| 2261 | | (<DESC> { modif = OrderbyClause.OrderModifier.DESC; }))? |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2262 | { |
| 2263 | modifierList.add(modif); |
| 2264 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2265 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2266 | (<COMMA> orderbyExpr = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2267 | { |
| 2268 | orderbyList.add(orderbyExpr); |
| 2269 | modif = OrderbyClause.OrderModifier.ASC; |
| 2270 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2271 | ( (<ASC> { modif = OrderbyClause.OrderModifier.ASC; }) |
| 2272 | | (<DESC> { modif = OrderbyClause.OrderModifier.DESC; }))? |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2273 | { |
| 2274 | modifierList.add(modif); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2275 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2276 | )* |
| 2277 | ) |
| 2278 | { |
| 2279 | oc.setModifierList(modifierList); |
| 2280 | oc.setOrderbyList(orderbyList); |
| 2281 | return oc; |
| 2282 | } |
| 2283 | } |
| 2284 | Clause GroupClause()throws ParseException : |
| 2285 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2286 | GroupbyClause gbc = new GroupbyClause(); |
| 2287 | // GbyVariableExpressionPair pair = new GbyVariableExpressionPair(); |
| 2288 | List<GbyVariableExpressionPair> vePairList = new ArrayList<GbyVariableExpressionPair>(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2289 | List<GbyVariableExpressionPair> decorPairList = new ArrayList<GbyVariableExpressionPair>(); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2290 | List<VariableExpr> withVarList= new ArrayList<VariableExpr>(); |
| 2291 | VariableExpr var = null; |
| 2292 | VariableExpr withVar = null; |
| 2293 | Expression expr = null; |
| 2294 | VariableExpr decorVar = null; |
| 2295 | Expression decorExpr = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2296 | } |
| 2297 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2298 | { |
| 2299 | Scope newScope = extendCurrentScopeNoPush(true); |
| 2300 | // extendCurrentScope(true); |
| 2301 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2302 | <GROUP> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2303 | { |
| 2304 | String hint = getHint(token); |
| 2305 | if (hint != null && hint.equals(HASH_GROUP_BY_HINT)) { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2306 | gbc.setHashGroupByHint(true); |
| 2307 | } |
| 2308 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2309 | <BY> (LOOKAHEAD(2) var = Variable() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2310 | { |
| 2311 | newScope.addNewVarSymbolToScope(var.getVar()); |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2312 | } <ASSIGN>)? |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2313 | expr = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2314 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2315 | GbyVariableExpressionPair pair1 = new GbyVariableExpressionPair(var, expr); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2316 | vePairList.add(pair1); |
| 2317 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2318 | (<COMMA> ( LOOKAHEAD(2) var = Variable() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2319 | { |
| 2320 | newScope.addNewVarSymbolToScope(var.getVar()); |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2321 | } <ASSIGN>)? |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2322 | expr = Expression() |
| 2323 | { |
| 2324 | GbyVariableExpressionPair pair2 = new GbyVariableExpressionPair(var, expr); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2325 | vePairList.add(pair2); |
| 2326 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2327 | )* |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2328 | (<DECOR> decorVar = Variable() <ASSIGN> decorExpr = Expression() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2329 | { |
| 2330 | newScope.addNewVarSymbolToScope(decorVar.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2331 | GbyVariableExpressionPair pair3 = new GbyVariableExpressionPair(decorVar, decorExpr); |
| 2332 | decorPairList.add(pair3); |
| 2333 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2334 | (<COMMA> <DECOR> decorVar = Variable() <ASSIGN> decorExpr = Expression() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2335 | { |
| 2336 | newScope.addNewVarSymbolToScope(decorVar.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2337 | GbyVariableExpressionPair pair4 = new GbyVariableExpressionPair(decorVar, decorExpr); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2338 | decorPairList.add(pair4); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2339 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2340 | )* |
| 2341 | )? |
buyingyi | 3ca46d0 | 2015-01-27 23:22:09 -0800 | [diff] [blame] | 2342 | (<WITH>|<KEEPING>) withVar = VariableRef() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2343 | { |
| 2344 | if(withVar.getIsNewVar()==true) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2345 | throw new ParseException("can't find variable " + withVar.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2346 | withVarList.add(withVar); |
| 2347 | newScope.addNewVarSymbolToScope(withVar.getVar()); |
| 2348 | } |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2349 | (<COMMA> withVar = VariableRef() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2350 | { |
| 2351 | if(withVar.getIsNewVar()==true) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2352 | throw new ParseException("can't find variable " + withVar.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2353 | withVarList.add(withVar); |
| 2354 | newScope.addNewVarSymbolToScope(withVar.getVar()); |
| 2355 | })* |
| 2356 | { |
| 2357 | gbc.setGbyPairList(vePairList); |
| 2358 | gbc.setDecorPairList(decorPairList); |
| 2359 | gbc.setWithVarList(withVarList); |
| 2360 | replaceCurrentScope(newScope); |
| 2361 | return gbc; |
| 2362 | } |
| 2363 | } |
| 2364 | |
| 2365 | |
| 2366 | LimitClause LimitClause() throws ParseException: |
| 2367 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2368 | LimitClause lc = new LimitClause(); |
| 2369 | Expression expr; |
| 2370 | pushForbiddenScope(getCurrentScope()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2371 | } |
| 2372 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2373 | <LIMIT> expr = Expression() { lc.setLimitExpr(expr); } |
| 2374 | (<OFFSET> expr = Expression() { lc.setOffset(expr); })? |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2375 | |
| 2376 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2377 | popForbiddenScope(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2378 | return lc; |
| 2379 | } |
| 2380 | } |
| 2381 | |
| 2382 | DistinctClause DistinctClause() throws ParseException: |
| 2383 | { |
| 2384 | List<Expression> exprs = new ArrayList<Expression>(); |
| 2385 | Expression expr; |
| 2386 | } |
| 2387 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2388 | <DISTINCT> <BY> expr = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2389 | { |
| 2390 | exprs.add(expr); |
| 2391 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2392 | (<COMMA> expr = Expression() |
| 2393 | { |
| 2394 | exprs.add(expr); |
| 2395 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2396 | )* |
| 2397 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2398 | return new DistinctClause(exprs); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2399 | } |
| 2400 | } |
| 2401 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2402 | QuantifiedExpression QuantifiedExpression()throws ParseException: |
| 2403 | { |
| 2404 | QuantifiedExpression qc = new QuantifiedExpression(); |
| 2405 | List<QuantifiedPair> quantifiedList = new ArrayList<QuantifiedPair>(); |
| 2406 | Expression satisfiesExpr; |
| 2407 | VariableExpr var; |
| 2408 | Expression inExpr; |
| 2409 | QuantifiedPair pair; |
| 2410 | } |
| 2411 | { |
| 2412 | { |
| 2413 | createNewScope(); |
| 2414 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2415 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2416 | ( (<SOME> { qc.setQuantifier(QuantifiedExpression.Quantifier.SOME); }) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2417 | | (<EVERY> { qc.setQuantifier(QuantifiedExpression.Quantifier.EVERY); })) |
| 2418 | var = Variable() <IN> inExpr = Expression() |
| 2419 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2420 | pair = new QuantifiedPair(var, inExpr); |
| 2421 | getCurrentScope().addNewVarSymbolToScope(var.getVar()); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2422 | quantifiedList.add(pair); |
| 2423 | } |
| 2424 | ( |
| 2425 | <COMMA> var = Variable() <IN> inExpr = Expression() |
| 2426 | { |
| 2427 | pair = new QuantifiedPair(var, inExpr); |
| 2428 | getCurrentScope().addNewVarSymbolToScope(var.getVar()); |
| 2429 | quantifiedList.add(pair); |
| 2430 | } |
| 2431 | )* |
| 2432 | <SATISFIES> satisfiesExpr = Expression() |
| 2433 | { |
| 2434 | qc.setSatisfiesExpr(satisfiesExpr); |
| 2435 | qc.setQuantifiedList(quantifiedList); |
| 2436 | removeCurrentScope(); |
| 2437 | return qc; |
| 2438 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2439 | } |
| 2440 | |
| 2441 | TOKEN_MGR_DECLS: |
| 2442 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2443 | public int commentDepth = 0; |
| 2444 | public IntStack lexerStateStack = new IntStack(); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2445 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2446 | public void pushState() { |
| 2447 | lexerStateStack.push( curLexState ); |
| 2448 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2449 | |
Till Westmann | fd733ee | 2014-07-10 00:57:37 -0700 | [diff] [blame] | 2450 | public void popState(String token) { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2451 | if (lexerStateStack.size() > 0) { |
| 2452 | SwitchTo( lexerStateStack.pop() ); |
| 2453 | } else { |
Till Westmann | fd733ee | 2014-07-10 00:57:37 -0700 | [diff] [blame] | 2454 | int errorLine = input_stream.getEndLine(); |
| 2455 | int errorColumn = input_stream.getEndColumn(); |
| 2456 | String msg = "Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered \"" + token |
| 2457 | + "\" but state stack is empty."; |
| 2458 | throw new TokenMgrError(msg, -1); |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2459 | } |
| 2460 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2461 | } |
| 2462 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2463 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2464 | TOKEN : |
| 2465 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2466 | <ASC : "asc"> |
| 2467 | | <AT : "at"> |
| 2468 | | <BY : "by"> |
| 2469 | | <DATASET : "dataset"> |
| 2470 | | <DECOR : "decor"> |
| 2471 | | <DESC : "desc"> |
| 2472 | | <DISTINCT : "distinct"> |
| 2473 | | <ELSE : "else"> |
| 2474 | | <EVERY : "every"> |
| 2475 | | <FOR : "for"> |
buyingyi | 2fd7fa6 | 2014-11-24 19:31:55 -0800 | [diff] [blame] | 2476 | | <FROM : "from"> |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2477 | | <GROUP : "group"> |
| 2478 | | <IF : "if"> |
| 2479 | | <IN : "in"> |
| 2480 | | <LET : "let"> |
| 2481 | | <LIMIT : "limit"> |
| 2482 | | <OFFSET : "offset"> |
| 2483 | | <ORDER : "order"> |
| 2484 | | <RETURN : "return"> |
| 2485 | | <SATISFIES : "satisfies"> |
buyingyi | 2fd7fa6 | 2014-11-24 19:31:55 -0800 | [diff] [blame] | 2486 | | <SELECT : "select"> |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2487 | | <SOME : "some"> |
| 2488 | | <THEN : "then"> |
| 2489 | | <UNION : "union"> |
| 2490 | | <WHERE : "where"> |
| 2491 | | <WITH : "with"> |
buyingyi | 3ca46d0 | 2015-01-27 23:22:09 -0800 | [diff] [blame] | 2492 | | <KEEPING : "keeping"> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2493 | } |
| 2494 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2495 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2496 | TOKEN : |
| 2497 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2498 | <CARET : "^"> |
| 2499 | | <DIV : "/"> |
| 2500 | | <IDIV : "idiv"> |
| 2501 | | <MINUS : "-"> |
| 2502 | | <MOD : "%"> |
| 2503 | | <MUL : "*"> |
| 2504 | | <PLUS : "+"> |
| 2505 | |
| 2506 | | <LEFTPAREN : "("> |
| 2507 | | <RIGHTPAREN : ")"> |
| 2508 | | <LEFTBRACKET : "["> |
| 2509 | | <RIGHTBRACKET : "]"> |
| 2510 | |
| 2511 | | <COLON : ":"> |
| 2512 | | <COMMA : ","> |
| 2513 | | <DOT : "."> |
| 2514 | | <QUES : "?"> |
| 2515 | |
| 2516 | | <LT : "<"> |
| 2517 | | <GT : ">"> |
| 2518 | | <LE : "<="> |
| 2519 | | <GE : ">="> |
| 2520 | | <EQ : "="> |
| 2521 | | <NE : "!="> |
| 2522 | | <SIMILAR : "~="> |
| 2523 | | <ASSIGN : ":="> |
| 2524 | |
| 2525 | | <AND : "and"> |
| 2526 | | <OR : "or"> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2527 | } |
| 2528 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2529 | <DEFAULT,IN_DBL_BRACE> |
| 2530 | TOKEN : |
| 2531 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2532 | <LEFTBRACE : "{"> { pushState(); } : DEFAULT |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2533 | } |
| 2534 | |
| 2535 | <DEFAULT> |
| 2536 | TOKEN : |
| 2537 | { |
Till Westmann | fd733ee | 2014-07-10 00:57:37 -0700 | [diff] [blame] | 2538 | <RIGHTBRACE : "}"> { popState("}"); } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2539 | } |
| 2540 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2541 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2542 | TOKEN : |
| 2543 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2544 | <LEFTDBLBRACE : "{{"> { pushState(); } : IN_DBL_BRACE |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2545 | } |
| 2546 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2547 | <IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2548 | TOKEN : |
| 2549 | { |
Till Westmann | fd733ee | 2014-07-10 00:57:37 -0700 | [diff] [blame] | 2550 | <RIGHTDBLBRACE : "}}"> { popState("}}"); } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2551 | } |
| 2552 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2553 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2554 | TOKEN : |
| 2555 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2556 | <INTEGER_LITERAL : (<DIGIT>)+ > |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2557 | } |
| 2558 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2559 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2560 | TOKEN : |
| 2561 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2562 | <NULL : "null"> |
| 2563 | | <TRUE : "true"> |
| 2564 | | <FALSE : "false"> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2565 | } |
| 2566 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2567 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2568 | TOKEN : |
| 2569 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2570 | <#DIGIT : ["0" - "9"]> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2571 | } |
| 2572 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2573 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2574 | TOKEN: |
| 2575 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2576 | < DOUBLE_LITERAL: <DIGITS> |
Till Westmann | af0551c | 2013-07-23 14:53:31 -0700 | [diff] [blame] | 2577 | | <DIGITS> ( "." <DIGITS> )? |
| 2578 | | "." <DIGITS> |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2579 | > |
| 2580 | | < FLOAT_LITERAL: <DIGITS> ( "f" | "F" ) |
Till Westmann | af0551c | 2013-07-23 14:53:31 -0700 | [diff] [blame] | 2581 | | <DIGITS> ( "." <DIGITS> ( "f" | "F" ) )? |
| 2582 | | "." <DIGITS> ( "f" | "F" ) |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2583 | > |
| 2584 | | <DIGITS : (<DIGIT>)+ > |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2585 | } |
| 2586 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2587 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2588 | TOKEN : |
| 2589 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2590 | <#LETTER : ["A" - "Z", "a" - "z"]> |
| 2591 | | <SPECIALCHARS : ["$", "_", "-"]> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2592 | } |
| 2593 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2594 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2595 | TOKEN : |
| 2596 | { |
Till Westmann | e3e8ffa | 2014-08-02 17:51:23 -0700 | [diff] [blame] | 2597 | // backslash u + 4 hex digits escapes are handled in the underlying JavaCharStream |
| 2598 | <STRING_LITERAL : ("\"" ( |
| 2599 | <EscapeQuot> |
| 2600 | | <EscapeBslash> |
| 2601 | | <EscapeSlash> |
| 2602 | | <EscapeBspace> |
| 2603 | | <EscapeFormf> |
| 2604 | | <EscapeNl> |
| 2605 | | <EscapeCr> |
| 2606 | | <EscapeTab> |
| 2607 | | ~["\"","\\"])* "\"") |
| 2608 | | ("\'"( |
| 2609 | <EscapeApos> |
| 2610 | | <EscapeBslash> |
| 2611 | | <EscapeSlash> |
| 2612 | | <EscapeBspace> |
| 2613 | | <EscapeFormf> |
| 2614 | | <EscapeNl> |
| 2615 | | <EscapeCr> |
| 2616 | | <EscapeTab> |
| 2617 | | ~["\'","\\"])* "\'")> |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2618 | | < #EscapeQuot: "\\\"" > |
| 2619 | | < #EscapeApos: "\\\'" > |
Till Westmann | e0cc01c | 2014-03-31 10:26:10 -0700 | [diff] [blame] | 2620 | | < #EscapeBslash: "\\\\" > |
Till Westmann | e3e8ffa | 2014-08-02 17:51:23 -0700 | [diff] [blame] | 2621 | | < #EscapeSlash: "\\/" > |
| 2622 | | < #EscapeBspace: "\\b" > |
| 2623 | | < #EscapeFormf: "\\f" > |
| 2624 | | < #EscapeNl: "\\n" > |
| 2625 | | < #EscapeCr: "\\r" > |
| 2626 | | < #EscapeTab: "\\t" > |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2627 | } |
| 2628 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2629 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2630 | TOKEN : |
| 2631 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2632 | <IDENTIFIER : <LETTER> (<LETTER> | <DIGIT> | <SPECIALCHARS>)*> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2633 | } |
| 2634 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2635 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2636 | TOKEN : |
| 2637 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2638 | <VARIABLE : "$" <LETTER> (<LETTER> | <DIGIT> | "_")*> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2639 | } |
| 2640 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2641 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2642 | SKIP: |
| 2643 | { |
| 2644 | " " |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2645 | | "\t" |
| 2646 | | "\r" |
| 2647 | | "\n" |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2648 | } |
| 2649 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2650 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2651 | SKIP: |
| 2652 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2653 | <"//" (~["\n"])* "\n"> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2654 | } |
| 2655 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2656 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2657 | SKIP: |
| 2658 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 2659 | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")?> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2660 | } |
| 2661 | |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2662 | <DEFAULT,IN_DBL_BRACE> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2663 | SKIP: |
| 2664 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2665 | <"/*"> { pushState(); } : INSIDE_COMMENT |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2666 | } |
| 2667 | |
| 2668 | <INSIDE_COMMENT> |
| 2669 | SPECIAL_TOKEN: |
| 2670 | { |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2671 | <"+"(" ")*(~["*"])*> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2672 | } |
| 2673 | |
| 2674 | <INSIDE_COMMENT> |
| 2675 | SKIP: |
| 2676 | { |
Till Westmann | 96c1f17 | 2013-08-01 02:05:48 -0700 | [diff] [blame] | 2677 | <"/*"> { pushState(); } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2678 | } |
| 2679 | |
| 2680 | <INSIDE_COMMENT> |
| 2681 | SKIP: |
| 2682 | { |
Till Westmann | fd733ee | 2014-07-10 00:57:37 -0700 | [diff] [blame] | 2683 | <"*/"> { popState("*/"); } |
Till Westmann | 5df7b45 | 2013-08-02 13:07:16 -0700 | [diff] [blame] | 2684 | | <~[]> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2685 | } |