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