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