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