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