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