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