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