diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2019-11-04 10:27:29 +0100 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2019-11-04 10:27:29 +0100 |
commit | 900fb0aee0b68cbb88f578f20019738b4416f436 (patch) | |
tree | 9ac25ac14f2b8eaac7bbd152e4ae567de6b63e16 | |
parent | 362310157373eef80f49ea6023b1666b3883f4b1 (diff) |
Add query language interpreter code
82 files changed, 6337 insertions, 0 deletions
diff --git a/build.gradle b/build.gradle index 1ee577b..0a1bc57 100644 --- a/build.gradle +++ b/build.gradle @@ -28,6 +28,10 @@ dependencies { testImplementation 'junit:junit:4.12' implementation 'com.esotericsoftware:kryo:4.0.2' + + // For query language parser + implementation files('./lib/JLex.jar') + implementation files('./lib/cup.jar') } application { diff --git a/lib/JLex.jar b/lib/JLex.jar Binary files differnew file mode 100644 index 0000000..d2dc065 --- /dev/null +++ b/lib/JLex.jar diff --git a/lib/cup.jar b/lib/cup.jar Binary files differnew file mode 100644 index 0000000..8acbdb7 --- /dev/null +++ b/lib/cup.jar diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Environment.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Environment.java new file mode 100644 index 0000000..d45b600 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Environment.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import pl.edu.mimuw.cloudatlas.model.ValueNull; + +class Environment { + private final TableRow row; + private final Map<String, Integer> columns = new HashMap<String, Integer>(); + + public Environment(TableRow row, List<String> columns) { + this.row = row; + int i = 0; + for(String c : columns) + this.columns.put(c, i++); + } + + public Result getIdent(String ident) { + try { + return new ResultSingle(row.getIth(columns.get(ident))); + } catch(NullPointerException exception) { + return new ResultSingle(ValueNull.getInstance()); + } + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Functions.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Functions.java new file mode 100644 index 0000000..dde84fe --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Functions.java @@ -0,0 +1,428 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import pl.edu.mimuw.cloudatlas.interpreter.Result.AggregationOperation; +import pl.edu.mimuw.cloudatlas.interpreter.Result.TransformOperation; +import pl.edu.mimuw.cloudatlas.interpreter.Result.UnaryOperation; +import pl.edu.mimuw.cloudatlas.model.Type; +import pl.edu.mimuw.cloudatlas.model.Type.PrimaryType; +import pl.edu.mimuw.cloudatlas.model.TypeCollection; +import pl.edu.mimuw.cloudatlas.model.TypePrimitive; +import pl.edu.mimuw.cloudatlas.model.Value; +import pl.edu.mimuw.cloudatlas.model.ValueBoolean; +import pl.edu.mimuw.cloudatlas.model.ValueDouble; +import pl.edu.mimuw.cloudatlas.model.ValueInt; +import pl.edu.mimuw.cloudatlas.model.ValueList; +import pl.edu.mimuw.cloudatlas.model.ValueNull; +import pl.edu.mimuw.cloudatlas.model.ValueSet; +import pl.edu.mimuw.cloudatlas.model.ValueTime; + +class Functions { + private static Functions instance = null; + + private static final UnaryOperation ROUND = new UnaryOperation() { + @Override + public Value perform(Value v) { + if(v.getType().isCompatible(TypePrimitive.DOUBLE)) { + if(v.isNull()) + return new ValueDouble(null); + return new ValueDouble((double)Math.round(((ValueDouble)v).getValue())); + } + throw new IllegalArgumentException("Value must have type " + TypePrimitive.DOUBLE + "."); + } + }; + + private static final UnaryOperation FLOOR = new UnaryOperation() { + @Override + public Value perform(Value v) { + if(v.getType().isCompatible(TypePrimitive.DOUBLE)) { + if(v.isNull()) + return new ValueDouble(null); + return new ValueDouble((double)Math.floor(((ValueDouble)v).getValue())); + } + throw new IllegalArgumentException("Value must have type " + TypePrimitive.DOUBLE + "."); + } + }; + + private static final UnaryOperation CEIL = new UnaryOperation() { + @Override + public Value perform(Value v) { + // TODO + throw new UnsupportedOperationException("Not yet implemented"); + } + }; + + private static final AggregationOperation COUNT = new AggregationOperation() { + @Override + public ValueInt perform(ValueList values) { + ValueList nlist = Result.filterNullsList(values); + if(nlist.getValue() == null) { + return new ValueInt(null); + } + return new ValueInt((long)nlist.size()); + } + }; + + private static final AggregationOperation SUM = new AggregationOperation() { + @Override + public Value perform(ValueList values) { + // TODO + throw new UnsupportedOperationException("Not yet implemented"); + } + }; + + private static final AggregationOperation AVERAGE = new AggregationOperation() { + @Override + public Value perform(ValueList values) { + Type elementType = ((TypeCollection)values.getType()).getElementType(); + PrimaryType primaryType = elementType.getPrimaryType(); + + if(primaryType != PrimaryType.INT && primaryType != PrimaryType.DOUBLE && primaryType != PrimaryType.DURATION + && primaryType != PrimaryType.NULL) { + throw new IllegalArgumentException("Aggregation doesn't support type: " + elementType + "."); + } + + ValueList nlist = Result.filterNullsList(values); + if(nlist.getValue() == null || nlist.isEmpty()) { + return ValueNull.getInstance(); + } + + Value result = nlist.get(0).getDefaultValue(); + + for(Value v : nlist) { + result = result.addValue(v); + } + Value size = primaryType == PrimaryType.DOUBLE? new ValueDouble((double)nlist.size()) : new ValueInt( + (long)nlist.size()); + return result.divide(size); + } + }; + + private static final AggregationOperation AND = new AggregationOperation() { + @Override + public ValueBoolean perform(ValueList values) { // lazy + ValueList nlist = Result.filterNullsList(values); + if(nlist.getValue() == null) { + return new ValueBoolean(null); + } else if(values.isEmpty()) { + return new ValueBoolean(true); + } + for(Value v : nlist) { + if(v.getType().isCompatible(TypePrimitive.BOOLEAN)) { + if(v.isNull() || !((ValueBoolean)v).getValue()) + return new ValueBoolean(false); + } else + throw new IllegalArgumentException("Aggregation doesn't support type: " + v.getType() + "."); + } + return new ValueBoolean(true); + } + }; + + private static final AggregationOperation OR = new AggregationOperation() { + @Override + public ValueBoolean perform(ValueList values) { // lazy + // TODO + throw new UnsupportedOperationException("Not yet implemented"); + } + }; + + private static final AggregationOperation MIN = new AggregationOperation() { + @Override + public Value perform(ValueList values) { + ValueList nlist = Result.filterNullsList(values); + if(nlist.getValue() == null || nlist.isEmpty()) { + return ValueNull.getInstance(); + } + Value result = nlist.get(0); + for(Value v : nlist) { + if(((ValueBoolean)v.isLowerThan(result)).getValue()) { + result = v; + } + } + return result; + } + }; + + private static final AggregationOperation MAX = new AggregationOperation() { + @Override + public Value perform(ValueList values) { + ValueList nlist = Result.filterNullsList(values); + if(nlist.getValue() == null || nlist.isEmpty()) { + return ValueNull.getInstance(); + } + Value result = nlist.get(0); + for(Value v : nlist) { + if(((ValueBoolean)v.isLowerThan(result)).negate().and(v.isEqual(result).negate()).getValue()) { + result = v; + } + } + return result; + } + }; + + private static final TransformOperation UNFOLD = new TransformOperation() { + @Override + public ValueList perform(ValueList values) { + if(!((TypeCollection)values.getType()).getElementType().isCollection()) { + throw new IllegalArgumentException("All elements must have a collection compatible type."); + } + ValueList nlist = Result.filterNullsList(values); + if(nlist.getValue() == null) { + return new ValueList(null, + ((TypeCollection)((TypeCollection)values.getType()).getElementType()).getElementType()); + } else if(nlist.isEmpty()) { + return new ValueList( + ((TypeCollection)((TypeCollection)values.getType()).getElementType()).getElementType()); + } + List<Value> ret = new ArrayList<Value>(); + for(Value v : nlist) { + if(v.getType().getPrimaryType() == Type.PrimaryType.SET) { + ret.addAll((ValueSet)v); + } else if(v.getType().getPrimaryType() == Type.PrimaryType.LIST) { + ret.addAll((ValueList)v); + } + } + return new ValueList(ret, + ((TypeCollection)((TypeCollection)values.getType()).getElementType()).getElementType()); + } + }; + + private static final TransformOperation DISTINCT = new TransformOperation() { + @Override + public ValueList perform(ValueList values) { + if(values.isEmpty()) + return new ValueList(((TypeCollection)values.getType()).getElementType()); + List<Value> ret = new ArrayList<Value>(); + for(Value v : values) { + if(!ret.contains(v)) { + ret.add(v); + } + } + return new ValueList(ret, ((TypeCollection)values.getType()).getElementType()); + } + }; + + private static final TransformOperation SORT = new TransformOperation() { + @Override + public ValueList perform(ValueList values) { + if(values.isEmpty()) + return new ValueList(((TypeCollection)values.getType()).getElementType()); + List<Value> ret = new ArrayList<Value>(); + ret.addAll(values); + Collections.sort(ret, new Comparator<Value>() { + public int compare(Value v1, Value v2) { + if(((ValueBoolean)v1.isLowerThan(v2)).getValue()) { + return -1; + } else if(((ValueBoolean)v1.isEqual(v2)).getValue()) { + return 0; + } else { + return 1; + } + } + }); + return new ValueList(ret, ((TypeCollection)values.getType()).getElementType()); + } + }; + + private final ValueTime EPOCH; + + private Functions() { + try { + EPOCH = new ValueTime("2000/01/01 00:00:00.000"); + } catch(ParseException exception) { + throw new InternalInterpreterException("Cannot parse time when creating an EPOCH object.\n" + + exception.getMessage()); + } + } + + public static Functions getInstance() { + if(instance == null) + instance = new Functions(); + return instance; + } + + public Result evaluate(String name, List<Result> arguments) { + switch(name) { + case "round": + if(arguments.size() == 1) + return arguments.get(0).unaryOperation(ROUND); + break; + case "floor": + if(arguments.size() == 1) + return arguments.get(0).unaryOperation(FLOOR); + break; + case "ceil": + if(arguments.size() == 1) + return arguments.get(0).unaryOperation(CEIL); + break; + case "now": + if(arguments.size() == 0) + return new ResultSingle(new ValueTime(Calendar.getInstance().getTimeInMillis())); + break; + case "epoch": + if(arguments.size() == 0) + return new ResultSingle(EPOCH); + break; + case "count": + if(arguments.size() == 1) + return arguments.get(0).aggregationOperation(COUNT); + break; + case "size": + if(arguments.size() == 1) + return arguments.get(0).valueSize(); + break; + case "sum": + if(arguments.size() == 1) + return arguments.get(0).aggregationOperation(SUM); + break; + case "avg": + if(arguments.size() == 1) + return arguments.get(0).aggregationOperation(AVERAGE); + break; + case "land": + if(arguments.size() == 1) + return arguments.get(0).aggregationOperation(AND); + break; + case "lor": + if(arguments.size() == 1) + return arguments.get(0).aggregationOperation(OR); + break; + case "min": + if(arguments.size() == 1) + return arguments.get(0).aggregationOperation(MIN); + break; + case "max": + if(arguments.size() == 1) + return arguments.get(0).aggregationOperation(MAX); + break; + case "unfold": + if(arguments.size() == 1) + return arguments.get(0).transformOperation(UNFOLD); + break; + case "distinct": + if(arguments.size() == 1) + return arguments.get(0).transformOperation(DISTINCT); + break; + case "sort": + if(arguments.size() == 1) + return arguments.get(0).transformOperation(SORT); + break; + case "filterNulls": + if(arguments.size() == 1) + return arguments.get(0).filterNulls(); + break; + case "first": + if(arguments.size() == 2) { + Value size = arguments.get(0).getValue(); + if(size.getType().isCompatible(TypePrimitive.INTEGER) && ((ValueInt)size).getValue().intValue() >= 0) + return arguments.get(1).first(((ValueInt)size).getValue().intValue()); + throw new IllegalArgumentException("First argument must have type " + TypePrimitive.INTEGER + + " and be >= 0."); + } + break; + case "last": + if(arguments.size() == 2) { + Value size = arguments.get(0).getValue(); + if(size.getType().isCompatible(TypePrimitive.INTEGER) && ((ValueInt)size).getValue().intValue() >= 0) + return arguments.get(1).last(((ValueInt)size).getValue().intValue()); + throw new IllegalArgumentException("First argument must have type " + TypePrimitive.INTEGER + + " and be >= 0."); + } + break; + case "random": + if(arguments.size() == 2) { + Value size = arguments.get(0).getValue(); + if(size.getType().isCompatible(TypePrimitive.INTEGER) && ((ValueInt)size).getValue().intValue() >= 0) + return arguments.get(1).random(((ValueInt)size).getValue().intValue()); + throw new IllegalArgumentException("First argument must have type " + TypePrimitive.INTEGER + + " and be >= 0."); + } + break; + case "to_boolean": + if(arguments.size() == 1) + return arguments.get(0).convertTo(TypePrimitive.BOOLEAN); + break; + case "to_contact": + if(arguments.size() == 1) + return arguments.get(0).convertTo(TypePrimitive.CONTACT); + break; + case "to_double": + if(arguments.size() == 1) + return arguments.get(0).convertTo(TypePrimitive.DOUBLE); + break; + case "to_duration": + if(arguments.size() == 1) + return arguments.get(0).convertTo(TypePrimitive.DURATION); + break; + case "to_integer": + if(arguments.size() == 1) + return arguments.get(0).convertTo(TypePrimitive.INTEGER); + break; + case "to_string": + if(arguments.size() == 1) + return arguments.get(0).convertTo(TypePrimitive.STRING); + break; + case "to_time": + if(arguments.size() == 1) + return arguments.get(0).convertTo(TypePrimitive.TIME); + break; + case "to_set": + if(arguments.size() == 1) { + Type t = arguments.get(0).getType(); + if(t.isCollection()) { + Type elementType = ((TypeCollection)t).getElementType(); + return arguments.get(0).convertTo(new TypeCollection(Type.PrimaryType.SET, elementType)); + } + throw new IllegalArgumentException("First argument must be a collection."); + } + break; + case "to_list": + if(arguments.size() == 1) { + Type t = arguments.get(0).getType(); + if(t.isCollection()) { + Type elementType = ((TypeCollection)t).getElementType(); + return arguments.get(0).convertTo(new TypeCollection(Type.PrimaryType.LIST, elementType)); + } + throw new IllegalArgumentException("First argument must be a collection."); + } + break; + case "isNull": + if(arguments.size() == 1) + return arguments.get(0).isNull(); + break; + default: + throw new IllegalArgumentException("Illegal function name."); + } + throw new IllegalArgumentException("Illegal number of arguments."); + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/InsideQueryException.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/InsideQueryException.java new file mode 100644 index 0000000..d591c35 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/InsideQueryException.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +@SuppressWarnings("serial") +public class InsideQueryException extends InterpreterException { + private final String fragment; + private final Exception exception; + + protected InsideQueryException(String fragment, Exception exception) { + super(exception.getMessage() + "\nin: " + fragment); + this.fragment = fragment; + this.exception = exception; + } + + public String getFragment() { + return fragment; + } + + public Exception getException() { + return exception; + } + + @Override + public StackTraceElement[] getStackTrace() { + return exception.getStackTrace(); + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/InternalInterpreterException.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/InternalInterpreterException.java new file mode 100644 index 0000000..8010df2 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/InternalInterpreterException.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +@SuppressWarnings("serial") +public class InternalInterpreterException extends InterpreterException { + protected InternalInterpreterException(String message) { + super(message); + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Interpreter.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Interpreter.java new file mode 100644 index 0000000..4634459 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Interpreter.java @@ -0,0 +1,493 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +import pl.edu.mimuw.cloudatlas.interpreter.query.PrettyPrinter; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AliasedSelItemC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AscOrderC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprAddC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprDivC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprModC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprMulC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprNegC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprSubC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprBasicExprC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprCmpC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprRegExpC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprAndC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprBoolExprC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprNotC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprOrC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.DescOrderC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EBoolC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ECondExprC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EDblC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EFunC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIdentC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIntC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStmtC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStrC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoNullsC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoOrderByC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoOrderC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoWhereC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NullFirstsC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NullsLastC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderBy; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderByC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItem; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItemC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ProgramC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpEqC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpGeC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpGtC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpLeC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpLtC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpNeC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItemC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.StatementC; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Where; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.WhereC; +import pl.edu.mimuw.cloudatlas.model.Attribute; +import pl.edu.mimuw.cloudatlas.model.TypePrimitive; +import pl.edu.mimuw.cloudatlas.model.Value; +import pl.edu.mimuw.cloudatlas.model.ValueBoolean; +import pl.edu.mimuw.cloudatlas.model.ValueDouble; +import pl.edu.mimuw.cloudatlas.model.ValueInt; +import pl.edu.mimuw.cloudatlas.model.ValueString; +import pl.edu.mimuw.cloudatlas.model.ZMI; + +public class Interpreter { + private static class ValuesPair { + public final Result left; + public final Result right; + + public ValuesPair(Result left, Result right) { + this.left = left; + this.right = right; + } + } + + private final ZMI zmi; + + public Interpreter(ZMI zmi) { + this.zmi = zmi; + } + + private static Boolean getBoolean(Value value) { + if(value.getType().isCompatible(TypePrimitive.BOOLEAN)) { + Boolean b = ((ValueBoolean)value).getValue(); + return b == null? false : b.booleanValue(); + } + throw new InvalidTypeException(TypePrimitive.BOOLEAN, value.getType()); + } + + public List<QueryResult> interpretProgram(Program program) { + return program.accept(new ProgramInterpreter(), zmi); + } + + public List<QueryResult> interpretStatement(Statement statement) { + return statement.accept(new StatementInterpreter(), zmi); + } + + public class ProgramInterpreter implements Program.Visitor<List<QueryResult>, ZMI> { + public List<QueryResult> visit(ProgramC program, ZMI zmi) { + List<QueryResult> results = new ArrayList<QueryResult>(); + for(Statement s : program.liststatement_) { + try { + List<QueryResult> l = s.accept(new StatementInterpreter(), zmi); + for(QueryResult qr : l) + if(qr.getName() == null) + throw new IllegalArgumentException("All items in top-level SELECT must be aliased."); + results.addAll(l); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(s), exception); + } + } + return results; + } + } + + public class StatementInterpreter implements Statement.Visitor<List<QueryResult>, ZMI> { + public List<QueryResult> visit(StatementC statement, ZMI zmi) { + Table table = new Table(zmi); + try { + table = statement.where_.accept(new WhereInterpreter(), table); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(statement.where_), exception); + } + try { + table = statement.orderby_.accept(new OrderByInterpreter(), table); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(statement.orderby_), exception); + } + List<QueryResult> ret = new ArrayList<QueryResult>(); + + for(SelItem selItem : statement.listselitem_) { + try { + QueryResult qr = selItem.accept(new SelItemInterpreter(), table); + if(qr.getName() != null) { + for(QueryResult qrRet : ret) + if(qr.getName().getName().equals(qrRet.getName().getName())) + throw new IllegalArgumentException("Alias collision."); + } + ret.add(qr); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(selItem), exception); + } + } + + return ret; + } + } + + public class WhereInterpreter implements Where.Visitor<Table, Table> { + public Table visit(NoWhereC where, Table table) { + return table; + } + + public Table visit(WhereC where, Table table) { + Table result = new Table(table); + for(TableRow row : table) { + Environment env = new Environment(row, table.getColumns()); + Value value = where.condexpr_.accept(new CondExprInterpreter(), env).getValue(); + if(getBoolean(value)) + result.appendRow(row); + } + return result; + } + } + + public class OrderByInterpreter implements OrderBy.Visitor<Table, Table> { + public Table visit(NoOrderByC orderBy, Table table) { + return table; + } + + public Table visit(OrderByC orderBy, Table table) { + for(OrderItem item : orderBy.listorderitem_) { + try { + table = item.accept(new OrderItemInterpreter(), table); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(item), exception); + } + } + return table; + } + } + + public class OrderItemInterpreter implements OrderItem.Visitor<Table, Table> { + public Table visit(final OrderItemC orderItem, final Table table) { + Comparator<TableRow> comparator = new Comparator<TableRow>() { + @Override + public int compare(TableRow row1, TableRow row2) { + Environment env1 = new Environment(row1, table.getColumns()); + Result expr1 = orderItem.condexpr_.accept(new CondExprInterpreter(), env1); + Environment env2 = new Environment(row2, table.getColumns()); + Result expr2 = orderItem.condexpr_.accept(new CondExprInterpreter(), env2); + ValuesPair pair = new ValuesPair(expr1, expr2); + int result = orderItem.nulls_.accept(new NullsInterpreter(), pair); + if(result == 0) + result = orderItem.order_.accept(new OrderInterpreter(), pair); + return result; + } + }; + table.sort(comparator); + return table; + } + } + + public class OrderInterpreter implements Order.Visitor<Integer, ValuesPair> { + private int compareAsc(ValuesPair pair) { + if(getBoolean(pair.left.isEqual(pair.right).getValue())) + return 0; + if(getBoolean(pair.left.isLowerThan(pair.right).getValue())) + return -1; + return 1; + } + + public Integer visit(AscOrderC order, ValuesPair pair) { + return compareAsc(pair); + } + + public Integer visit(DescOrderC order, ValuesPair pair) { + return -compareAsc(pair); + } + + public Integer visit(NoOrderC order, ValuesPair pair) { + return compareAsc(pair); + } + } + + public class NullsInterpreter implements Nulls.Visitor<Integer, ValuesPair> { + private Integer nullsFirst(ValuesPair pair) { + if(pair.left.getValue().isNull()) { + if(pair.right.getValue().isNull()) + return 0; + return -1; + } + if(pair.right.getValue().isNull()) + return 1; + return 0; + } + + public Integer visit(NoNullsC nulls, ValuesPair pair) { + return nullsFirst(pair); + } + + public Integer visit(NullFirstsC nulls, ValuesPair pair) { + return nullsFirst(pair); + } + + public Integer visit(NullsLastC nulls, ValuesPair pair) { + return -nullsFirst(pair); + } + } + + public class SelItemInterpreter implements SelItem.Visitor<QueryResult, Table> { + public QueryResult visit(SelItemC selItem, Table table) { + Environment env = null; // TODO + Result result = selItem.condexpr_.accept(new CondExprInterpreter(), env); + return new QueryResult(result.getValue()); + } + + public QueryResult visit(AliasedSelItemC selItem, Table table) { + Environment env = null; // TODO + Result result = selItem.condexpr_.accept(new CondExprInterpreter(), env); + return new QueryResult(new Attribute(selItem.qident_), result.getValue()); + } + } + + public class BoolExprInterpreter implements BoolExpr.Visitor<Result, Environment> { + public Result visit(BoolExprCmpC expr, Environment env) { + try { + Result left = expr.basicexpr_1.accept(new BasicExprInterpreter(), env); + Result right = expr.basicexpr_2.accept(new BasicExprInterpreter(), env); + return expr.relop_.accept(new RelOpInterpreter(), new ValuesPair(left, right)); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(expr), exception); + } + } + + public Result visit(BoolExprRegExpC expr, Environment env) { + try { + Result left = expr.basicexpr_.accept(new BasicExprInterpreter(), env); + return (new ResultSingle(new ValueString(expr.string_))).regExpr(left); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(expr), exception); + } + } + + public Result visit(BoolExprBasicExprC expr, Environment env) { + return expr.basicexpr_.accept(new BasicExprInterpreter(), env); + } + } + + public class CondExprInterpreter implements CondExpr.Visitor<Result, Environment> { + public Result visit(CondExprOrC expr, Environment env) { + try { + Result left = expr.condexpr_1.accept(new CondExprInterpreter(), env); + Result right = expr.condexpr_2.accept(new CondExprInterpreter(), env); + return left.or(right); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(expr), exception); + } + } + + public Result visit(CondExprAndC expr, Environment env) { + // TODO + throw new UnsupportedOperationException("Not yet implemented"); + } + + public Result visit(CondExprNotC expr, Environment env) { + try { + return expr.condexpr_.accept(new CondExprInterpreter(), env).negate(); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(expr), exception); + } + } + + public Result visit(CondExprBoolExprC expr, Environment env) { + return expr.boolexpr_.accept(new BoolExprInterpreter(), env); + } + } + + public class BasicExprInterpreter implements BasicExpr.Visitor<Result, Environment> { + public Result visit(BasicExprAddC expr, Environment env) { + try { + Result left = expr.basicexpr_1.accept(new BasicExprInterpreter(), env); + Result right = expr.basicexpr_2.accept(new BasicExprInterpreter(), env); + return left.addValue(right); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(expr), exception); + } + } + + public Result visit(BasicExprSubC expr, Environment env) { + try { + Result left = expr.basicexpr_1.accept(new BasicExprInterpreter(), env); + Result right = expr.basicexpr_2.accept(new BasicExprInterpreter(), env); + return left.subtract(right); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(expr), exception); + } + } + + public Result visit(BasicExprMulC expr, Environment env) { + // TODO + throw new UnsupportedOperationException("Not yet implemented"); + } + + public Result visit(BasicExprDivC expr, Environment env) { + try { + Result left = expr.basicexpr_1.accept(new BasicExprInterpreter(), env); + Result right = expr.basicexpr_2.accept(new BasicExprInterpreter(), env); + return left.divide(right); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(expr), exception); + } + } + + public Result visit(BasicExprModC expr, Environment env) { + try { + Result left = expr.basicexpr_1.accept(new BasicExprInterpreter(), env); + Result right = expr.basicexpr_2.accept(new BasicExprInterpreter(), env); + return left.modulo(right); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(expr), exception); + } + } + + public Result visit(BasicExprNegC expr, Environment env) { + try { + return expr.basicexpr_.accept(new BasicExprInterpreter(), env).negate(); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(expr), exception); + } + } + + public Result visit(EIdentC expr, Environment env) { + return env.getIdent(expr.qident_); + } + + public Result visit(EFunC expr, Environment env) { + try { + List<Result> arguments = new ArrayList<Result>(expr.listcondexpr_.size()); + for(CondExpr arg : expr.listcondexpr_) + arguments.add(arg.accept(new CondExprInterpreter(), env)); + + return Functions.getInstance().evaluate(expr.qident_, arguments); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(expr), exception); + } + } + + public ResultSingle visit(EStrC expr, Environment env) { + return new ResultSingle(new ValueString(expr.string_)); + } + + public ResultSingle visit(EBoolC expr, Environment env) { + ValueBoolean value; + if(expr.qbool_.compareTo("true") == 0) + value = new ValueBoolean(true); + else if(expr.qbool_.compareTo("false") == 0) + value = new ValueBoolean(false); + else + throw new InternalInterpreterException("Incorrect boolean constant: " + PrettyPrinter.print(expr)); + return new ResultSingle(value); + } + + public ResultSingle visit(EIntC expr, Environment env) { + try { + return new ResultSingle(new ValueInt(Long.parseLong(expr.qinteger_))); + } catch(NumberFormatException exception) { + throw new InternalInterpreterException(exception.getMessage()); + } + } + + public ResultSingle visit(EDblC expr, Environment env) { + try { + return new ResultSingle(new ValueDouble(Double.parseDouble(expr.qdouble_))); + } catch(NumberFormatException exception) { + throw new InternalInterpreterException(exception.getMessage()); + } + } + + public Result visit(ECondExprC expr, Environment env) { + return expr.condexpr_.accept(new CondExprInterpreter(), env); + } + + public ResultSingle visit(EStmtC expr, Environment env) { + try { + List<QueryResult> l = expr.statement_.accept(new StatementInterpreter(), zmi); + if(l.size() != 1) + throw new IllegalArgumentException("Nested queries must SELECT exactly one item."); + return new ResultSingle(l.get(0).getValue()); + } catch(Exception exception) { + throw new InsideQueryException(PrettyPrinter.print(expr), exception); + } + } + } + + public class RelOpInterpreter implements RelOp.Visitor<Result, ValuesPair> { + public Result visit(RelOpGtC op, ValuesPair pair) { + return pair.left.isLowerThan(pair.right).negate().and(pair.left.isEqual(pair.right).negate()); + } + + public Result visit(RelOpEqC op, ValuesPair pair) { + // TODO + throw new UnsupportedOperationException("Not yet implemented"); + } + + public Result visit(RelOpNeC op, ValuesPair pair) { + return pair.left.isEqual(pair.right).negate(); + } + + public Result visit(RelOpLtC op, ValuesPair pair) { + return pair.left.isLowerThan(pair.right); + } + + public Result visit(RelOpLeC op, ValuesPair pair) { + // TODO + throw new UnsupportedOperationException("Not yet implemented"); + } + + public Result visit(RelOpGeC op, ValuesPair pair) { + return pair.left.isLowerThan(pair.right).negate(); + } + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterException.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterException.java new file mode 100644 index 0000000..5dbe921 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterException.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +@SuppressWarnings("serial") +public abstract class InterpreterException extends RuntimeException { + protected InterpreterException(String message) { + super(message); + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/InvalidTypeException.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/InvalidTypeException.java new file mode 100644 index 0000000..23a325f --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/InvalidTypeException.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +import pl.edu.mimuw.cloudatlas.model.Type; + +@SuppressWarnings("serial") +public class InvalidTypeException extends InterpreterException { + private final Type expected; + private final Type got; + + protected InvalidTypeException(Type expected, Type got) { + super("Invalid type. Expected " + expected + ", got " + got + "."); + this.expected = expected; + this.got = got; + } + + public Type getExpected() { + return expected; + } + + public Type getGot() { + return got; + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java new file mode 100644 index 0000000..a9857ed --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Main.java @@ -0,0 +1,247 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +import java.io.ByteArrayInputStream; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.text.ParseException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Scanner; + +import pl.edu.mimuw.cloudatlas.interpreter.query.Yylex; +import pl.edu.mimuw.cloudatlas.interpreter.query.parser; +import pl.edu.mimuw.cloudatlas.model.PathName; +import pl.edu.mimuw.cloudatlas.model.TypePrimitive; +import pl.edu.mimuw.cloudatlas.model.Value; +import pl.edu.mimuw.cloudatlas.model.ValueBoolean; +import pl.edu.mimuw.cloudatlas.model.ValueContact; +import pl.edu.mimuw.cloudatlas.model.ValueDouble; +import pl.edu.mimuw.cloudatlas.model.ValueDuration; +import pl.edu.mimuw.cloudatlas.model.ValueInt; +import pl.edu.mimuw.cloudatlas.model.ValueList; +import pl.edu.mimuw.cloudatlas.model.ValueSet; +import pl.edu.mimuw.cloudatlas.model.ValueString; +import pl.edu.mimuw.cloudatlas.model.ValueTime; +import pl.edu.mimuw.cloudatlas.model.ZMI; + +public class Main { + private static ZMI root; + + public static void main(String[] args) throws Exception { + root = createTestHierarchy(); + Scanner scanner = new Scanner(System.in); + scanner.useDelimiter("\\n"); + while(scanner.hasNext()) + executeQueries(root, scanner.next()); + scanner.close(); + } + + private static PathName getPathName(ZMI zmi) { + String name = ((ValueString)zmi.getAttributes().get("name")).getValue(); + return zmi.getFather() == null? PathName.ROOT : getPathName(zmi.getFather()).levelDown(name); + } + + private static void executeQueries(ZMI zmi, String query) throws Exception { + if(!zmi.getSons().isEmpty()) { + for(ZMI son : zmi.getSons()) + executeQueries(son, query); + Interpreter interpreter = new Interpreter(zmi); + Yylex lex = new Yylex(new ByteArrayInputStream(query.getBytes())); + try { + List<QueryResult> result = interpreter.interpretProgram((new parser(lex)).pProgram()); + PathName zone = getPathName(zmi); + for(QueryResult r : result) { + System.out.println(zone + ": " + r); + zmi.getAttributes().addOrChange(r.getName(), r.getValue()); + } + } catch(InterpreterException exception) {} + } + } + + private static ValueContact createContact(String path, byte ip1, byte ip2, byte ip3, byte ip4) + throws UnknownHostException { + return new ValueContact(new PathName(path), InetAddress.getByAddress(new byte[] { + ip1, ip2, ip3, ip4 + })); + } + + private static ZMI createTestHierarchy() throws ParseException, UnknownHostException { + ValueContact violet07Contact = createContact("/uw/violet07", (byte)10, (byte)1, (byte)1, (byte)10); + ValueContact khaki13Contact = createContact("/uw/khaki13", (byte)10, (byte)1, (byte)1, (byte)38); + ValueContact khaki31Contact = createContact("/uw/khaki31", (byte)10, (byte)1, (byte)1, (byte)39); + ValueContact whatever01Contact = createContact("/uw/whatever01", (byte)82, (byte)111, (byte)52, (byte)56); + ValueContact whatever02Contact = createContact("/uw/whatever02", (byte)82, (byte)111, (byte)52, (byte)57); + + List<Value> list; + + root = new ZMI(); + root.getAttributes().add("level", new ValueInt(0l)); + root.getAttributes().add("name", new ValueString(null)); + root.getAttributes().add("owner", new ValueString("/uw/violet07")); + root.getAttributes().add("timestamp", new ValueTime("2012/11/09 20:10:17.342")); + root.getAttributes().add("contacts", new ValueSet(TypePrimitive.CONTACT)); + root.getAttributes().add("cardinality", new ValueInt(0l)); + + ZMI uw = new ZMI(root); + root.addSon(uw); + uw.getAttributes().add("level", new ValueInt(1l)); + uw.getAttributes().add("name", new ValueString("uw")); + uw.getAttributes().add("owner", new ValueString("/uw/violet07")); + uw.getAttributes().add("timestamp", new ValueTime("2012/11/09 20:8:13.123")); + uw.getAttributes().add("contacts", new ValueSet(TypePrimitive.CONTACT)); + uw.getAttributes().add("cardinality", new ValueInt(0l)); + + ZMI pjwstk = new ZMI(root); + root.addSon(pjwstk); + pjwstk.getAttributes().add("level", new ValueInt(1l)); + pjwstk.getAttributes().add("name", new ValueString("pjwstk")); + pjwstk.getAttributes().add("owner", new ValueString("/pjwstk/whatever01")); + pjwstk.getAttributes().add("timestamp", new ValueTime("2012/11/09 20:8:13.123")); + pjwstk.getAttributes().add("contacts", new ValueSet(TypePrimitive.CONTACT)); + pjwstk.getAttributes().add("cardinality", new ValueInt(0l)); + + ZMI violet07 = new ZMI(uw); + uw.addSon(violet07); + violet07.getAttributes().add("level", new ValueInt(2l)); + violet07.getAttributes().add("name", new ValueString("violet07")); + violet07.getAttributes().add("owner", new ValueString("/uw/violet07")); + violet07.getAttributes().add("timestamp", new ValueTime("2012/11/09 18:00:00.000")); + list = Arrays.asList(new Value[] { + khaki31Contact, whatever01Contact + }); + violet07.getAttributes().add("contacts", new ValueSet(new HashSet<Value>(list), TypePrimitive.CONTACT)); + violet07.getAttributes().add("cardinality", new ValueInt(1l)); + list = Arrays.asList(new Value[] { + violet07Contact, + }); + violet07.getAttributes().add("members", new ValueSet(new HashSet<Value>(list), TypePrimitive.CONTACT)); + violet07.getAttributes().add("creation", new ValueTime("2011/11/09 20:8:13.123")); + violet07.getAttributes().add("cpu_usage", new ValueDouble(0.9)); + violet07.getAttributes().add("num_cores", new ValueInt(3l)); + violet07.getAttributes().add("has_ups", new ValueBoolean(null)); + list = Arrays.asList(new Value[] { + new ValueString("tola"), new ValueString("tosia"), + }); + violet07.getAttributes().add("some_names", new ValueList(list, TypePrimitive.STRING)); + violet07.getAttributes().add("expiry", new ValueDuration(13l, 12l, 0l, 0l, 0l)); + + ZMI khaki31 = new ZMI(uw); + uw.addSon(khaki31); + khaki31.getAttributes().add("level", new ValueInt(2l)); + khaki31.getAttributes().add("name", new ValueString("khaki31")); + khaki31.getAttributes().add("owner", new ValueString("/uw/khaki31")); + khaki31.getAttributes().add("timestamp", new ValueTime("2012/11/09 20:03:00.000")); + list = Arrays.asList(new Value[] { + violet07Contact, whatever02Contact, + }); + khaki31.getAttributes().add("contacts", new ValueSet(new HashSet<Value>(list), TypePrimitive.CONTACT)); + khaki31.getAttributes().add("cardinality", new ValueInt(1l)); + list = Arrays.asList(new Value[] { + khaki31Contact + }); + khaki31.getAttributes().add("members", new ValueSet(new HashSet<Value>(list), TypePrimitive.CONTACT)); + khaki31.getAttributes().add("creation", new ValueTime("2011/11/09 20:12:13.123")); + khaki31.getAttributes().add("cpu_usage", new ValueDouble(null)); + khaki31.getAttributes().add("num_cores", new ValueInt(3l)); + khaki31.getAttributes().add("has_ups", new ValueBoolean(false)); + list = Arrays.asList(new Value[] { + new ValueString("agatka"), new ValueString("beatka"), new ValueString("celina"), + }); + khaki31.getAttributes().add("some_names", new ValueList(list, TypePrimitive.STRING)); + khaki31.getAttributes().add("expiry", new ValueDuration(-13l, -11l, 0l, 0l, 0l)); + + ZMI khaki13 = new ZMI(uw); + uw.addSon(khaki13); + khaki13.getAttributes().add("level", new ValueInt(2l)); + khaki13.getAttributes().add("name", new ValueString("khaki13")); + khaki13.getAttributes().add("owner", new ValueString("/uw/khaki13")); + khaki13.getAttributes().add("timestamp", new ValueTime("2012/11/09 21:03:00.000")); + list = Arrays.asList(new Value[] {}); + khaki13.getAttributes().add("contacts", new ValueSet(new HashSet<Value>(list), TypePrimitive.CONTACT)); + khaki13.getAttributes().add("cardinality", new ValueInt(1l)); + list = Arrays.asList(new Value[] { + khaki13Contact, + }); + khaki13.getAttributes().add("members", new ValueSet(new HashSet<Value>(list), TypePrimitive.CONTACT)); + khaki13.getAttributes().add("creation", new ValueTime((Long)null)); + khaki13.getAttributes().add("cpu_usage", new ValueDouble(0.1)); + khaki13.getAttributes().add("num_cores", new ValueInt(null)); + khaki13.getAttributes().add("has_ups", new ValueBoolean(true)); + list = Arrays.asList(new Value[] {}); + khaki13.getAttributes().add("some_names", new ValueList(list, TypePrimitive.STRING)); + khaki13.getAttributes().add("expiry", new ValueDuration((Long)null)); + + ZMI whatever01 = new ZMI(pjwstk); + pjwstk.addSon(whatever01); + whatever01.getAttributes().add("level", new ValueInt(2l)); + whatever01.getAttributes().add("name", new ValueString("whatever01")); + whatever01.getAttributes().add("owner", new ValueString("/uw/whatever01")); + whatever01.getAttributes().add("timestamp", new ValueTime("2012/11/09 21:12:00.000")); + list = Arrays.asList(new Value[] { + violet07Contact, whatever02Contact, + }); + whatever01.getAttributes().add("contacts", new ValueSet(new HashSet<Value>(list), TypePrimitive.CONTACT)); + whatever01.getAttributes().add("cardinality", new ValueInt(1l)); + list = Arrays.asList(new Value[] { + whatever01Contact, + }); + whatever01.getAttributes().add("members", new ValueSet(new HashSet<Value>(list), TypePrimitive.CONTACT)); + whatever01.getAttributes().add("creation", new ValueTime("2012/10/18 07:03:00.000")); + whatever01.getAttributes().add("cpu_usage", new ValueDouble(0.1)); + whatever01.getAttributes().add("num_cores", new ValueInt(7l)); + list = Arrays.asList(new Value[] { + new ValueString("rewrite") + }); + whatever01.getAttributes().add("php_modules", new ValueList(list, TypePrimitive.STRING)); + + ZMI whatever02 = new ZMI(pjwstk); + pjwstk.addSon(whatever02); + whatever02.getAttributes().add("level", new ValueInt(2l)); + whatever02.getAttributes().add("name", new ValueString("whatever02")); + whatever02.getAttributes().add("owner", new ValueString("/uw/whatever02")); + whatever02.getAttributes().add("timestamp", new ValueTime("2012/11/09 21:13:00.000")); + list = Arrays.asList(new Value[] { + khaki31Contact, whatever01Contact, + }); + whatever02.getAttributes().add("contacts", new ValueSet(new HashSet<Value>(list), TypePrimitive.CONTACT)); + whatever02.getAttributes().add("cardinality", new ValueInt(1l)); + list = Arrays.asList(new Value[] { + whatever02Contact, + }); + whatever02.getAttributes().add("members", new ValueSet(new HashSet<Value>(list), TypePrimitive.CONTACT)); + whatever02.getAttributes().add("creation", new ValueTime("2012/10/18 07:04:00.000")); + whatever02.getAttributes().add("cpu_usage", new ValueDouble(0.4)); + whatever02.getAttributes().add("num_cores", new ValueInt(13l)); + list = Arrays.asList(new Value[] { + new ValueString("odbc") + }); + whatever02.getAttributes().add("php_modules", new ValueList(list, TypePrimitive.STRING)); + + return root; + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/NoSuchAttributeException.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/NoSuchAttributeException.java new file mode 100644 index 0000000..b85438c --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/NoSuchAttributeException.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +@SuppressWarnings("serial") +public class NoSuchAttributeException extends InterpreterException { + private final String attribute; + + protected NoSuchAttributeException(String attribute) { + super("Attribute " + attribute + " does not exist."); + this.attribute = attribute; + } + + public String getAttribute() { + return attribute; + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/QueryResult.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/QueryResult.java new file mode 100644 index 0000000..2fc0cce --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/QueryResult.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +import pl.edu.mimuw.cloudatlas.model.Attribute; +import pl.edu.mimuw.cloudatlas.model.Value; + +// immutable +public class QueryResult { + private final Attribute name; + private final Value value; + + public QueryResult(Attribute name, Value value) { + this.name = name; + this.value = value; + } + + public QueryResult(Value value) { + this(null, value); + } + + public Attribute getName() { + return name; + } + + public Value getValue() { + return value; + } + + public String toString() { + return name + ": " + value; + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Result.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Result.java new file mode 100644 index 0000000..5afbe65 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Result.java @@ -0,0 +1,265 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import pl.edu.mimuw.cloudatlas.model.Type; +import pl.edu.mimuw.cloudatlas.model.TypeCollection; +import pl.edu.mimuw.cloudatlas.model.Value; +import pl.edu.mimuw.cloudatlas.model.ValueList; + +abstract class Result { + public interface BinaryOperation { + public Value perform(Value v1, Value v2); + } + + public interface UnaryOperation { + public Value perform(Value v); + } + + public interface AggregationOperation { + public Value perform(ValueList values); + } + + public interface TransformOperation { + public ValueList perform(ValueList values); + } + + private static final BinaryOperation IS_EQUAL = new BinaryOperation() { + @Override + public Value perform(Value v1, Value v2) { + return v1.isEqual(v2); + } + }; + + private static final BinaryOperation IS_LOWER_THAN = new BinaryOperation() { + @Override + public Value perform(Value v1, Value v2) { + return v1.isLowerThan(v2); + } + }; + + private static final BinaryOperation ADD_VALUE = new BinaryOperation() { + @Override + public Value perform(Value v1, Value v2) { + return v1.addValue(v2); + } + }; + + private static final BinaryOperation SUBTRACT = new BinaryOperation() { + @Override + public Value perform(Value v1, Value v2) { + return v1.subtract(v2); + } + }; + + private static final BinaryOperation MULTIPLY = new BinaryOperation() { + @Override + public Value perform(Value v1, Value v2) { + return v1.multiply(v2); + } + }; + + private static final BinaryOperation DIVIDE = new BinaryOperation() { + @Override + public Value perform(Value v1, Value v2) { + return v1.divide(v2); + } + }; + + private static final BinaryOperation MODULO = new BinaryOperation() { + @Override + public Value perform(Value v1, Value v2) { + return v1.modulo(v2); + } + }; + + private static final BinaryOperation AND = new BinaryOperation() { + @Override + public Value perform(Value v1, Value v2) { + return v1.and(v2); + } + }; + + private static final BinaryOperation OR = new BinaryOperation() { + @Override + public Value perform(Value v1, Value v2) { + return v1.or(v2); + } + }; + + private static final BinaryOperation REG_EXPR = new BinaryOperation() { + @Override + public Value perform(Value v1, Value v2) { + return v1.regExpr(v2); + } + }; + + private static final UnaryOperation NEGATE = new UnaryOperation() { + @Override + public Value perform(Value v) { + return v.negate(); + } + }; + + private static final UnaryOperation VALUE_SIZE = new UnaryOperation() { + @Override + public Value perform(Value v) { + return v.valueSize(); + } + }; + + protected abstract Result binaryOperationTyped(BinaryOperation operation, ResultSingle right); + + public Result binaryOperation(BinaryOperation operation, Result right) { + return right.callMe(operation, this); + } + + public abstract Result unaryOperation(UnaryOperation operation); + + protected abstract Result callMe(BinaryOperation operation, Result left); + + public abstract Value getValue(); + + public abstract ValueList getList(); + + public abstract ValueList getColumn(); + + public ResultSingle aggregationOperation(AggregationOperation operation) { + // TODO + throw new UnsupportedOperationException("Not yet implemented"); + } + + public Result transformOperation(TransformOperation operation) { + // TODO + throw new UnsupportedOperationException("Not yet implemented"); + } + + public Result isEqual(Result right) { + return right.callMe(IS_EQUAL, this); + } + + public Result isLowerThan(Result right) { + return right.callMe(IS_LOWER_THAN, this); + } + + public Result addValue(Result right) { + return right.callMe(ADD_VALUE, this); + } + + public Result subtract(Result right) { + return right.callMe(SUBTRACT, this); + } + + public Result multiply(Result right) { + return right.callMe(MULTIPLY, this); + } + + public Result divide(Result right) { + return right.callMe(DIVIDE, this); + } + + public Result modulo(Result right) { + return right.callMe(MODULO, this); + } + + public Result and(Result right) { + return right.callMe(AND, this); + } + + public Result or(Result right) { + return right.callMe(OR, this); + } + + public Result regExpr(Result right) { + return right.callMe(REG_EXPR, this); + } + + public Result negate() { + return unaryOperation(NEGATE); + } + + public Result valueSize() { + return unaryOperation(VALUE_SIZE); + } + + protected static ValueList filterNullsList(ValueList list) { + List<Value> result = new ArrayList<Value>(); + if(list.isEmpty()) + return new ValueList(result, ((TypeCollection)list.getType()).getElementType()); + for(Value v : list) + if(!v.isNull()) + result.add(v); + return new ValueList(result.isEmpty()? null : result, ((TypeCollection)list.getType()).getElementType()); + } + + public abstract Result filterNulls(); + + protected static ValueList firstList(ValueList list, int size) { + ValueList nlist = filterNullsList(list); + if(nlist.getValue() == null) + return nlist; + List<Value> result = new ArrayList<Value>(size); + int i = 0; + for(Value v : nlist) { + result.add(v); + if(++i == size) + break; + } + return new ValueList(result, ((TypeCollection)list.getType()).getElementType()); + } + + public abstract Result first(int size); + + protected static ValueList lastList(ValueList list, int size) { + ValueList nlist = filterNullsList(list); + if(nlist.getValue() == null) + return nlist; + List<Value> result = new ArrayList<Value>(size); + for(int i = Math.max(0, list.size() - size); i < list.size(); ++i) + result.add(list.get(i)); + return new ValueList(result, ((TypeCollection)list.getType()).getElementType()); + } + + public abstract Result last(int size); + + protected static ValueList randomList(ValueList list, int size) { + ValueList nlist = filterNullsList(list); + if(nlist.getValue() == null || list.size() <= size) + return nlist; + Collections.shuffle(nlist); + return new ValueList(nlist.getValue().subList(0, size), ((TypeCollection)list.getType()).getElementType()); + } + + public abstract Result random(int size); + + public abstract Result convertTo(Type to); + + public abstract ResultSingle isNull(); + + public abstract Type getType(); +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/ResultSingle.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/ResultSingle.java new file mode 100644 index 0000000..ada8f93 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/ResultSingle.java @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +import pl.edu.mimuw.cloudatlas.model.Type; +import pl.edu.mimuw.cloudatlas.model.Value; +import pl.edu.mimuw.cloudatlas.model.ValueBoolean; +import pl.edu.mimuw.cloudatlas.model.ValueList; + +class ResultSingle extends Result { + private final Value value; + + public ResultSingle(Value value) { + this.value = value; + } + + @Override + protected ResultSingle binaryOperationTyped(BinaryOperation operation, ResultSingle right) { + return new ResultSingle(operation.perform(value, right.value)); + } + + @Override + public ResultSingle unaryOperation(UnaryOperation operation) { + return new ResultSingle(operation.perform(value)); + } + + @Override + protected Result callMe(BinaryOperation operation, Result left) { + return left.binaryOperationTyped(operation, this); + } + + @Override + public Value getValue() { + return value; + } + + @Override + public ValueList getList() { + throw new UnsupportedOperationException("Not a ResultList."); + } + + @Override + public ValueList getColumn() { + throw new UnsupportedOperationException("Not a ResultColumn."); + } + + @Override + public Result filterNulls() { + throw new UnsupportedOperationException("Operation filterNulls not supported on ResultSingle."); + } + + @Override + public Result first(int size) { + throw new UnsupportedOperationException("Operation first not supported on ResultSingle."); + } + + @Override + public Result last(int size) { + throw new UnsupportedOperationException("Operation last not supported on ResultSingle."); + } + + @Override + public Result random(int size) { + throw new UnsupportedOperationException("Operation random not supported on ResultSingle."); + } + + @Override + public ResultSingle convertTo(Type to) { + return new ResultSingle(value.convertTo(to)); + } + + @Override + public ResultSingle isNull() { + return new ResultSingle(new ValueBoolean(value.isNull())); + } + + @Override + public Type getType() { + return value.getType(); + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Table.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Table.java new file mode 100644 index 0000000..9f2e1d9 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Table.java @@ -0,0 +1,123 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; + +import pl.edu.mimuw.cloudatlas.model.Attribute; +import pl.edu.mimuw.cloudatlas.model.Type; +import pl.edu.mimuw.cloudatlas.model.TypeCollection; +import pl.edu.mimuw.cloudatlas.model.Value; +import pl.edu.mimuw.cloudatlas.model.ValueList; +import pl.edu.mimuw.cloudatlas.model.ValueNull; +import pl.edu.mimuw.cloudatlas.model.ZMI; + +public class Table implements Iterable<TableRow> { + private final List<String> columns = new ArrayList<String>(); + private final Map<String, Integer> headersMap = new HashMap<String, Integer>(); + private final List<TableRow> rows = new ArrayList<TableRow>(); + + // creates whole table based on a given ZMI + public Table(ZMI zmi) { + Set<String> allColumns = new HashSet<String>(); + for(ZMI z : zmi.getSons()) + for(Entry<Attribute, Value> e : z.getAttributes()) + allColumns.add(e.getKey().getName()); + + columns.addAll(allColumns); + int i = 0; + for(String c : columns) + headersMap.put(c, i++); + for(ZMI z : zmi.getSons()) { + Value[] row = new Value[columns.size()]; + for(int j = 0; j < row.length; ++j) + row[j] = ValueNull.getInstance(); + for(Entry<Attribute, Value> e : z.getAttributes()) + row[getColumnIndex(e.getKey().getName())] = e.getValue(); + appendRow(new TableRow(row)); + } + } + + // creates an empty table with same columns as given + public Table(Table table) { + this.columns.addAll(table.columns); + this.headersMap.putAll(table.headersMap); + } + + public List<String> getColumns() { + return Collections.unmodifiableList(columns); + } + + public void appendRow(TableRow row) { + if(row.getSize() != columns.size()) + throw new InternalInterpreterException("Cannot append row. Length expected: " + columns.size() + ", got: " + + row.getSize() + "."); + rows.add(row); + } + + public int getColumnIndex(String column) { + try { + return headersMap.get(column).intValue(); + } catch(NullPointerException exception) { + throw new NoSuchAttributeException(column); + } + } + + public ValueList getColumn(String column) { + if(column.startsWith("&")) { + throw new NoSuchAttributeException(column); + } + try { + int position = headersMap.get(column); + List<Value> result = new ArrayList<Value>(); + for(TableRow row : rows) { + Value v = row.getIth(position); + result.add(v); + } + Type elementType = TypeCollection.computeElementType(result); + return new ValueList(result, elementType); + } catch(NullPointerException exception) { + throw new NoSuchAttributeException(column); + } + } + + @Override + public Iterator<TableRow> iterator() { + return rows.iterator(); + } + + public void sort(Comparator<TableRow> comparator) { + Collections.sort(rows, comparator); + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/TableRow.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/TableRow.java new file mode 100644 index 0000000..23fd2dd --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/TableRow.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2014, University of Warsaw + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY + * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package pl.edu.mimuw.cloudatlas.interpreter; + +import java.util.Arrays; + +import pl.edu.mimuw.cloudatlas.model.Value; + +// immutable +public class TableRow { + private final Value[] columns; + + public TableRow(Value[] values) { + this.columns = Arrays.copyOf(values, values.length); + } + + public int getSize() { + return columns.length; + } + + public Value getIth(int i) { + return columns[i]; + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/AliasedSelItemC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/AliasedSelItemC.java new file mode 100644 index 0000000..f1f1b5a --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/AliasedSelItemC.java @@ -0,0 +1,25 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class AliasedSelItemC extends SelItem { + public final CondExpr condexpr_; + public final String qident_; + + public AliasedSelItemC(CondExpr p1, String p2) { condexpr_ = p1; qident_ = p2; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AliasedSelItemC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AliasedSelItemC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AliasedSelItemC)o; + return this.condexpr_.equals(x.condexpr_) && this.qident_.equals(x.qident_); + } + return false; + } + + public int hashCode() { + return 37*(this.condexpr_.hashCode())+this.qident_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/AscOrderC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/AscOrderC.java new file mode 100644 index 0000000..80163bb --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/AscOrderC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class AscOrderC extends Order { + + public AscOrderC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AscOrderC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExpr.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExpr.java new file mode 100644 index 0000000..c098b14 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExpr.java @@ -0,0 +1,23 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public abstract class BasicExpr implements java.io.Serializable { + public abstract <R,A> R accept(BasicExpr.Visitor<R,A> v, A arg); + public interface Visitor <R,A> { + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprAddC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprSubC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprMulC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprDivC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprModC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprNegC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EBoolC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIdentC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EFunC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStrC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIntC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EDblC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ECondExprC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStmtC p, A arg); + + } + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprAddC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprAddC.java new file mode 100644 index 0000000..754839a --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprAddC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class BasicExprAddC extends BasicExpr { + public final BasicExpr basicexpr_1, basicexpr_2; + + public BasicExprAddC(BasicExpr p1, BasicExpr p2) { basicexpr_1 = p1; basicexpr_2 = p2; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprAddC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprAddC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprAddC)o; + return this.basicexpr_1.equals(x.basicexpr_1) && this.basicexpr_2.equals(x.basicexpr_2); + } + return false; + } + + public int hashCode() { + return 37*(this.basicexpr_1.hashCode())+this.basicexpr_2.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprDivC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprDivC.java new file mode 100644 index 0000000..8abd22a --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprDivC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class BasicExprDivC extends BasicExpr { + public final BasicExpr basicexpr_1, basicexpr_2; + + public BasicExprDivC(BasicExpr p1, BasicExpr p2) { basicexpr_1 = p1; basicexpr_2 = p2; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprDivC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprDivC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprDivC)o; + return this.basicexpr_1.equals(x.basicexpr_1) && this.basicexpr_2.equals(x.basicexpr_2); + } + return false; + } + + public int hashCode() { + return 37*(this.basicexpr_1.hashCode())+this.basicexpr_2.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprModC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprModC.java new file mode 100644 index 0000000..db90b89 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprModC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class BasicExprModC extends BasicExpr { + public final BasicExpr basicexpr_1, basicexpr_2; + + public BasicExprModC(BasicExpr p1, BasicExpr p2) { basicexpr_1 = p1; basicexpr_2 = p2; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprModC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprModC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprModC)o; + return this.basicexpr_1.equals(x.basicexpr_1) && this.basicexpr_2.equals(x.basicexpr_2); + } + return false; + } + + public int hashCode() { + return 37*(this.basicexpr_1.hashCode())+this.basicexpr_2.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprMulC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprMulC.java new file mode 100644 index 0000000..369c545 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprMulC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class BasicExprMulC extends BasicExpr { + public final BasicExpr basicexpr_1, basicexpr_2; + + public BasicExprMulC(BasicExpr p1, BasicExpr p2) { basicexpr_1 = p1; basicexpr_2 = p2; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprMulC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprMulC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprMulC)o; + return this.basicexpr_1.equals(x.basicexpr_1) && this.basicexpr_2.equals(x.basicexpr_2); + } + return false; + } + + public int hashCode() { + return 37*(this.basicexpr_1.hashCode())+this.basicexpr_2.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprNegC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprNegC.java new file mode 100644 index 0000000..6abb7c4 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprNegC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class BasicExprNegC extends BasicExpr { + public final BasicExpr basicexpr_; + + public BasicExprNegC(BasicExpr p1) { basicexpr_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprNegC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprNegC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprNegC)o; + return this.basicexpr_.equals(x.basicexpr_); + } + return false; + } + + public int hashCode() { + return this.basicexpr_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprSubC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprSubC.java new file mode 100644 index 0000000..7f3bc58 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BasicExprSubC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class BasicExprSubC extends BasicExpr { + public final BasicExpr basicexpr_1, basicexpr_2; + + public BasicExprSubC(BasicExpr p1, BasicExpr p2) { basicexpr_1 = p1; basicexpr_2 = p2; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprSubC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprSubC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprSubC)o; + return this.basicexpr_1.equals(x.basicexpr_1) && this.basicexpr_2.equals(x.basicexpr_2); + } + return false; + } + + public int hashCode() { + return 37*(this.basicexpr_1.hashCode())+this.basicexpr_2.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BoolExpr.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BoolExpr.java new file mode 100644 index 0000000..b470b34 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BoolExpr.java @@ -0,0 +1,12 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public abstract class BoolExpr implements java.io.Serializable { + public abstract <R,A> R accept(BoolExpr.Visitor<R,A> v, A arg); + public interface Visitor <R,A> { + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprCmpC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprRegExpC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprBasicExprC p, A arg); + + } + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BoolExprBasicExprC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BoolExprBasicExprC.java new file mode 100644 index 0000000..eb08bcf --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BoolExprBasicExprC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class BoolExprBasicExprC extends BoolExpr { + public final BasicExpr basicexpr_; + + public BoolExprBasicExprC(BasicExpr p1) { basicexpr_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprBasicExprC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprBasicExprC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprBasicExprC)o; + return this.basicexpr_.equals(x.basicexpr_); + } + return false; + } + + public int hashCode() { + return this.basicexpr_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BoolExprCmpC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BoolExprCmpC.java new file mode 100644 index 0000000..f8a2f21 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BoolExprCmpC.java @@ -0,0 +1,25 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class BoolExprCmpC extends BoolExpr { + public final BasicExpr basicexpr_1, basicexpr_2; + public final RelOp relop_; + + public BoolExprCmpC(BasicExpr p1, RelOp p2, BasicExpr p3) { basicexpr_1 = p1; relop_ = p2; basicexpr_2 = p3; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprCmpC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprCmpC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprCmpC)o; + return this.basicexpr_1.equals(x.basicexpr_1) && this.relop_.equals(x.relop_) && this.basicexpr_2.equals(x.basicexpr_2); + } + return false; + } + + public int hashCode() { + return 37*(37*(this.basicexpr_1.hashCode())+this.relop_.hashCode())+this.basicexpr_2.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BoolExprRegExpC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BoolExprRegExpC.java new file mode 100644 index 0000000..31af2d2 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/BoolExprRegExpC.java @@ -0,0 +1,25 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class BoolExprRegExpC extends BoolExpr { + public final BasicExpr basicexpr_; + public final String string_; + + public BoolExprRegExpC(BasicExpr p1, String p2) { basicexpr_ = p1; string_ = p2; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprRegExpC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprRegExpC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprRegExpC)o; + return this.basicexpr_.equals(x.basicexpr_) && this.string_.equals(x.string_); + } + return false; + } + + public int hashCode() { + return 37*(this.basicexpr_.hashCode())+this.string_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExpr.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExpr.java new file mode 100644 index 0000000..73136e7 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExpr.java @@ -0,0 +1,13 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public abstract class CondExpr implements java.io.Serializable { + public abstract <R,A> R accept(CondExpr.Visitor<R,A> v, A arg); + public interface Visitor <R,A> { + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprOrC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprAndC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprNotC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprBoolExprC p, A arg); + + } + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExprAndC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExprAndC.java new file mode 100644 index 0000000..094affb --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExprAndC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class CondExprAndC extends CondExpr { + public final CondExpr condexpr_1, condexpr_2; + + public CondExprAndC(CondExpr p1, CondExpr p2) { condexpr_1 = p1; condexpr_2 = p2; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprAndC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprAndC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprAndC)o; + return this.condexpr_1.equals(x.condexpr_1) && this.condexpr_2.equals(x.condexpr_2); + } + return false; + } + + public int hashCode() { + return 37*(this.condexpr_1.hashCode())+this.condexpr_2.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExprBoolExprC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExprBoolExprC.java new file mode 100644 index 0000000..d102a29 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExprBoolExprC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class CondExprBoolExprC extends CondExpr { + public final BoolExpr boolexpr_; + + public CondExprBoolExprC(BoolExpr p1) { boolexpr_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprBoolExprC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprBoolExprC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprBoolExprC)o; + return this.boolexpr_.equals(x.boolexpr_); + } + return false; + } + + public int hashCode() { + return this.boolexpr_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExprNotC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExprNotC.java new file mode 100644 index 0000000..1e84219 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExprNotC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class CondExprNotC extends CondExpr { + public final CondExpr condexpr_; + + public CondExprNotC(CondExpr p1) { condexpr_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprNotC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprNotC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprNotC)o; + return this.condexpr_.equals(x.condexpr_); + } + return false; + } + + public int hashCode() { + return this.condexpr_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExprOrC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExprOrC.java new file mode 100644 index 0000000..08e7484 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/CondExprOrC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class CondExprOrC extends CondExpr { + public final CondExpr condexpr_1, condexpr_2; + + public CondExprOrC(CondExpr p1, CondExpr p2) { condexpr_1 = p1; condexpr_2 = p2; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprOrC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprOrC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprOrC)o; + return this.condexpr_1.equals(x.condexpr_1) && this.condexpr_2.equals(x.condexpr_2); + } + return false; + } + + public int hashCode() { + return 37*(this.condexpr_1.hashCode())+this.condexpr_2.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/DescOrderC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/DescOrderC.java new file mode 100644 index 0000000..a08cc61 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/DescOrderC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class DescOrderC extends Order { + + public DescOrderC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.DescOrderC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EBoolC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EBoolC.java new file mode 100644 index 0000000..da55dd5 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EBoolC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class EBoolC extends BasicExpr { + public final String qbool_; + + public EBoolC(String p1) { qbool_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EBoolC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EBoolC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EBoolC)o; + return this.qbool_.equals(x.qbool_); + } + return false; + } + + public int hashCode() { + return this.qbool_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ECondExprC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ECondExprC.java new file mode 100644 index 0000000..db4e9f1 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ECondExprC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class ECondExprC extends BasicExpr { + public final CondExpr condexpr_; + + public ECondExprC(CondExpr p1) { condexpr_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ECondExprC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ECondExprC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ECondExprC)o; + return this.condexpr_.equals(x.condexpr_); + } + return false; + } + + public int hashCode() { + return this.condexpr_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EDblC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EDblC.java new file mode 100644 index 0000000..f07e616 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EDblC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class EDblC extends BasicExpr { + public final String qdouble_; + + public EDblC(String p1) { qdouble_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EDblC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EDblC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EDblC)o; + return this.qdouble_.equals(x.qdouble_); + } + return false; + } + + public int hashCode() { + return this.qdouble_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EFunC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EFunC.java new file mode 100644 index 0000000..93af7e9 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EFunC.java @@ -0,0 +1,25 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class EFunC extends BasicExpr { + public final String qident_; + public final ListCondExpr listcondexpr_; + + public EFunC(String p1, ListCondExpr p2) { qident_ = p1; listcondexpr_ = p2; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EFunC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EFunC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EFunC)o; + return this.qident_.equals(x.qident_) && this.listcondexpr_.equals(x.listcondexpr_); + } + return false; + } + + public int hashCode() { + return 37*(this.qident_.hashCode())+this.listcondexpr_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EIdentC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EIdentC.java new file mode 100644 index 0000000..7c4119d --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EIdentC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class EIdentC extends BasicExpr { + public final String qident_; + + public EIdentC(String p1) { qident_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIdentC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIdentC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIdentC)o; + return this.qident_.equals(x.qident_); + } + return false; + } + + public int hashCode() { + return this.qident_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EIntC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EIntC.java new file mode 100644 index 0000000..069ecdb --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EIntC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class EIntC extends BasicExpr { + public final String qinteger_; + + public EIntC(String p1) { qinteger_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIntC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIntC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIntC)o; + return this.qinteger_.equals(x.qinteger_); + } + return false; + } + + public int hashCode() { + return this.qinteger_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EStmtC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EStmtC.java new file mode 100644 index 0000000..4157f1e --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EStmtC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class EStmtC extends BasicExpr { + public final Statement statement_; + + public EStmtC(Statement p1) { statement_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStmtC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStmtC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStmtC)o; + return this.statement_.equals(x.statement_); + } + return false; + } + + public int hashCode() { + return this.statement_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EStrC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EStrC.java new file mode 100644 index 0000000..3bf4a75 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/EStrC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class EStrC extends BasicExpr { + public final String string_; + + public EStrC(String p1) { string_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStrC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStrC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStrC)o; + return this.string_.equals(x.string_); + } + return false; + } + + public int hashCode() { + return this.string_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ListCondExpr.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ListCondExpr.java new file mode 100644 index 0000000..929ff07 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ListCondExpr.java @@ -0,0 +1,4 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class ListCondExpr extends java.util.LinkedList<CondExpr> { +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ListOrderItem.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ListOrderItem.java new file mode 100644 index 0000000..47ba4a8 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ListOrderItem.java @@ -0,0 +1,4 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class ListOrderItem extends java.util.LinkedList<OrderItem> { +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ListSelItem.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ListSelItem.java new file mode 100644 index 0000000..5392851 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ListSelItem.java @@ -0,0 +1,4 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class ListSelItem extends java.util.LinkedList<SelItem> { +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ListStatement.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ListStatement.java new file mode 100644 index 0000000..fa5070a --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ListStatement.java @@ -0,0 +1,4 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class ListStatement extends java.util.LinkedList<Statement> { +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NoNullsC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NoNullsC.java new file mode 100644 index 0000000..c7f54c9 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NoNullsC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class NoNullsC extends Nulls { + + public NoNullsC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoNullsC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NoOrderByC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NoOrderByC.java new file mode 100644 index 0000000..d357bcd --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NoOrderByC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class NoOrderByC extends OrderBy { + + public NoOrderByC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderBy.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoOrderByC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NoOrderC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NoOrderC.java new file mode 100644 index 0000000..0888840 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NoOrderC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class NoOrderC extends Order { + + public NoOrderC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoOrderC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NoWhereC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NoWhereC.java new file mode 100644 index 0000000..725fe03 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NoWhereC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class NoWhereC extends Where { + + public NoWhereC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Where.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoWhereC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NullFirstsC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NullFirstsC.java new file mode 100644 index 0000000..fa837b1 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NullFirstsC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class NullFirstsC extends Nulls { + + public NullFirstsC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NullFirstsC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Nulls.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Nulls.java new file mode 100644 index 0000000..fbd153b --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Nulls.java @@ -0,0 +1,12 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public abstract class Nulls implements java.io.Serializable { + public abstract <R,A> R accept(Nulls.Visitor<R,A> v, A arg); + public interface Visitor <R,A> { + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoNullsC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NullFirstsC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NullsLastC p, A arg); + + } + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NullsLastC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NullsLastC.java new file mode 100644 index 0000000..fcf0e74 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/NullsLastC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class NullsLastC extends Nulls { + + public NullsLastC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NullsLastC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Order.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Order.java new file mode 100644 index 0000000..bd7094c --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Order.java @@ -0,0 +1,12 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public abstract class Order implements java.io.Serializable { + public abstract <R,A> R accept(Order.Visitor<R,A> v, A arg); + public interface Visitor <R,A> { + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AscOrderC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.DescOrderC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoOrderC p, A arg); + + } + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/OrderBy.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/OrderBy.java new file mode 100644 index 0000000..c136dc4 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/OrderBy.java @@ -0,0 +1,11 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public abstract class OrderBy implements java.io.Serializable { + public abstract <R,A> R accept(OrderBy.Visitor<R,A> v, A arg); + public interface Visitor <R,A> { + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoOrderByC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderByC p, A arg); + + } + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/OrderByC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/OrderByC.java new file mode 100644 index 0000000..e599401 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/OrderByC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class OrderByC extends OrderBy { + public final ListOrderItem listorderitem_; + + public OrderByC(ListOrderItem p1) { listorderitem_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderBy.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderByC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderByC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderByC)o; + return this.listorderitem_.equals(x.listorderitem_); + } + return false; + } + + public int hashCode() { + return this.listorderitem_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/OrderItem.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/OrderItem.java new file mode 100644 index 0000000..3ea76ff --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/OrderItem.java @@ -0,0 +1,10 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public abstract class OrderItem implements java.io.Serializable { + public abstract <R,A> R accept(OrderItem.Visitor<R,A> v, A arg); + public interface Visitor <R,A> { + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItemC p, A arg); + + } + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/OrderItemC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/OrderItemC.java new file mode 100644 index 0000000..2d6228b --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/OrderItemC.java @@ -0,0 +1,26 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class OrderItemC extends OrderItem { + public final CondExpr condexpr_; + public final Order order_; + public final Nulls nulls_; + + public OrderItemC(CondExpr p1, Order p2, Nulls p3) { condexpr_ = p1; order_ = p2; nulls_ = p3; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItem.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItemC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItemC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItemC)o; + return this.condexpr_.equals(x.condexpr_) && this.order_.equals(x.order_) && this.nulls_.equals(x.nulls_); + } + return false; + } + + public int hashCode() { + return 37*(37*(this.condexpr_.hashCode())+this.order_.hashCode())+this.nulls_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Program.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Program.java new file mode 100644 index 0000000..4332025 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Program.java @@ -0,0 +1,10 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public abstract class Program implements java.io.Serializable { + public abstract <R,A> R accept(Program.Visitor<R,A> v, A arg); + public interface Visitor <R,A> { + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ProgramC p, A arg); + + } + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ProgramC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ProgramC.java new file mode 100644 index 0000000..6b7e999 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/ProgramC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class ProgramC extends Program { + public final ListStatement liststatement_; + + public ProgramC(ListStatement p1) { liststatement_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ProgramC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ProgramC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ProgramC)o; + return this.liststatement_.equals(x.liststatement_); + } + return false; + } + + public int hashCode() { + return this.liststatement_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOp.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOp.java new file mode 100644 index 0000000..f35b2dd --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOp.java @@ -0,0 +1,15 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public abstract class RelOp implements java.io.Serializable { + public abstract <R,A> R accept(RelOp.Visitor<R,A> v, A arg); + public interface Visitor <R,A> { + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpGtC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpEqC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpNeC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpLtC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpLeC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpGeC p, A arg); + + } + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpEqC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpEqC.java new file mode 100644 index 0000000..f0fe3a2 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpEqC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class RelOpEqC extends RelOp { + + public RelOpEqC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpEqC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpGeC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpGeC.java new file mode 100644 index 0000000..e0498bc --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpGeC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class RelOpGeC extends RelOp { + + public RelOpGeC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpGeC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpGtC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpGtC.java new file mode 100644 index 0000000..45c10b6 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpGtC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class RelOpGtC extends RelOp { + + public RelOpGtC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpGtC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpLeC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpLeC.java new file mode 100644 index 0000000..a0de97a --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpLeC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class RelOpLeC extends RelOp { + + public RelOpLeC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpLeC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpLtC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpLtC.java new file mode 100644 index 0000000..0407ab6 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpLtC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class RelOpLtC extends RelOp { + + public RelOpLtC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpLtC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpNeC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpNeC.java new file mode 100644 index 0000000..fc19670 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/RelOpNeC.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class RelOpNeC extends RelOp { + + public RelOpNeC() { } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpNeC) { + return true; + } + return false; + } + + public int hashCode() { + return 37; + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/SelItem.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/SelItem.java new file mode 100644 index 0000000..d1c5552 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/SelItem.java @@ -0,0 +1,11 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public abstract class SelItem implements java.io.Serializable { + public abstract <R,A> R accept(SelItem.Visitor<R,A> v, A arg); + public interface Visitor <R,A> { + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItemC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AliasedSelItemC p, A arg); + + } + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/SelItemC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/SelItemC.java new file mode 100644 index 0000000..f8fc8a4 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/SelItemC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class SelItemC extends SelItem { + public final CondExpr condexpr_; + + public SelItemC(CondExpr p1) { condexpr_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItemC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItemC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItemC)o; + return this.condexpr_.equals(x.condexpr_); + } + return false; + } + + public int hashCode() { + return this.condexpr_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Statement.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Statement.java new file mode 100644 index 0000000..8f6e252 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Statement.java @@ -0,0 +1,10 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public abstract class Statement implements java.io.Serializable { + public abstract <R,A> R accept(Statement.Visitor<R,A> v, A arg); + public interface Visitor <R,A> { + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.StatementC p, A arg); + + } + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/StatementC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/StatementC.java new file mode 100644 index 0000000..fd097fd --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/StatementC.java @@ -0,0 +1,26 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class StatementC extends Statement { + public final ListSelItem listselitem_; + public final Where where_; + public final OrderBy orderby_; + + public StatementC(ListSelItem p1, Where p2, OrderBy p3) { listselitem_ = p1; where_ = p2; orderby_ = p3; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.StatementC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.StatementC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.StatementC)o; + return this.listselitem_.equals(x.listselitem_) && this.where_.equals(x.where_) && this.orderby_.equals(x.orderby_); + } + return false; + } + + public int hashCode() { + return 37*(37*(this.listselitem_.hashCode())+this.where_.hashCode())+this.orderby_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Where.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Where.java new file mode 100644 index 0000000..0c21d98 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/Where.java @@ -0,0 +1,11 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public abstract class Where implements java.io.Serializable { + public abstract <R,A> R accept(Where.Visitor<R,A> v, A arg); + public interface Visitor <R,A> { + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoWhereC p, A arg); + public R visit(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.WhereC p, A arg); + + } + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/WhereC.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/WhereC.java new file mode 100644 index 0000000..c068881 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Absyn/WhereC.java @@ -0,0 +1,24 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query.Absyn; // Java Package generated by the BNF Converter. + +public class WhereC extends Where { + public final CondExpr condexpr_; + + public WhereC(CondExpr p1) { condexpr_ = p1; } + + public <R,A> R accept(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Where.Visitor<R,A> v, A arg) { return v.visit(this, arg); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.WhereC) { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.WhereC x = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.WhereC)o; + return this.condexpr_.equals(x.condexpr_); + } + return false; + } + + public int hashCode() { + return this.condexpr_.hashCode(); + } + + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/PrettyPrinter.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/PrettyPrinter.java new file mode 100644 index 0000000..ed1276d --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/PrettyPrinter.java @@ -0,0 +1,1142 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query; +import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.*; + +public class PrettyPrinter +{ + //For certain applications increasing the initial size of the buffer may improve performance. + private static final int INITIAL_BUFFER_SIZE = 128; + //You may wish to change the parentheses used in precedence. + private static final String _L_PAREN = new String("("); + private static final String _R_PAREN = new String(")"); + //You may wish to change render + private static void render(String s) + { + if (s.equals("{")) + { + buf_.append("\n"); + indent(); + buf_.append(s); + _n_ = _n_ + 2; + buf_.append("\n"); + indent(); + } + else if (s.equals("(") || s.equals("[")) + buf_.append(s); + else if (s.equals(")") || s.equals("]")) + { + backup(); + buf_.append(s); + buf_.append(" "); + } + else if (s.equals("}")) + { + _n_ = _n_ - 2; + backup(); + backup(); + buf_.append(s); + buf_.append("\n"); + indent(); + } + else if (s.equals(",")) + { + backup(); + buf_.append(s); + buf_.append(" "); + } + else if (s.equals(";")) + { + backup(); + buf_.append(s); + buf_.append("\n"); + indent(); + } + else if (s.equals("")) return; + else + { + buf_.append(s); + buf_.append(" "); + } + } + + + // print and show methods are defined for each category. + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListStatement foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListStatement foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListOrderItem foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListOrderItem foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListSelItem foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListSelItem foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Where foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Where foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderBy foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderBy foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItem foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItem foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String print(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp foo) + { + pp(foo, 0); + trim(); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + public static String show(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp foo) + { + sh(foo); + String temp = buf_.toString(); + buf_.delete(0,buf_.length()); + return temp; + } + /*** You shouldn't need to change anything beyond this point. ***/ + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListStatement foo, int _i_) + { + for (java.util.Iterator<Statement> it = foo.iterator(); it.hasNext();) + { + pp(it.next(), 0); + if (it.hasNext()) { + render(";"); + } else { + render(""); + } + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListOrderItem foo, int _i_) + { + for (java.util.Iterator<OrderItem> it = foo.iterator(); it.hasNext();) + { + pp(it.next(), 0); + if (it.hasNext()) { + render(","); + } else { + render(""); + } + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListSelItem foo, int _i_) + { + for (java.util.Iterator<SelItem> it = foo.iterator(); it.hasNext();) + { + pp(it.next(), 0); + if (it.hasNext()) { + render(","); + } else { + render(""); + } + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr foo, int _i_) + { + for (java.util.Iterator<CondExpr> it = foo.iterator(); it.hasNext();) + { + pp(it.next(), 0); + if (it.hasNext()) { + render(","); + } else { + render(""); + } + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program foo, int _i_) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ProgramC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ProgramC _programc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ProgramC) foo; + if (_i_ > 0) render(_L_PAREN); + pp(_programc.liststatement_, 0); + if (_i_ > 0) render(_R_PAREN); + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement foo, int _i_) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.StatementC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.StatementC _statementc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.StatementC) foo; + if (_i_ > 0) render(_L_PAREN); + render("SELECT"); + pp(_statementc.listselitem_, 0); + pp(_statementc.where_, 0); + pp(_statementc.orderby_, 0); + if (_i_ > 0) render(_R_PAREN); + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Where foo, int _i_) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoWhereC) + { + if (_i_ > 0) render(_L_PAREN); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.WhereC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.WhereC _wherec = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.WhereC) foo; + if (_i_ > 0) render(_L_PAREN); + render("WHERE"); + pp(_wherec.condexpr_, 0); + if (_i_ > 0) render(_R_PAREN); + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderBy foo, int _i_) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoOrderByC) + { + if (_i_ > 0) render(_L_PAREN); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderByC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderByC _orderbyc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderByC) foo; + if (_i_ > 0) render(_L_PAREN); + render("ORDER"); + render("BY"); + pp(_orderbyc.listorderitem_, 0); + if (_i_ > 0) render(_R_PAREN); + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItem foo, int _i_) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItemC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItemC _orderitemc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItemC) foo; + if (_i_ > 0) render(_L_PAREN); + pp(_orderitemc.condexpr_, 0); + pp(_orderitemc.order_, 0); + pp(_orderitemc.nulls_, 0); + if (_i_ > 0) render(_R_PAREN); + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order foo, int _i_) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AscOrderC) + { + if (_i_ > 0) render(_L_PAREN); + render("ASC"); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.DescOrderC) + { + if (_i_ > 0) render(_L_PAREN); + render("DESC"); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoOrderC) + { + if (_i_ > 0) render(_L_PAREN); + if (_i_ > 0) render(_R_PAREN); + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls foo, int _i_) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoNullsC) + { + if (_i_ > 0) render(_L_PAREN); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NullFirstsC) + { + if (_i_ > 0) render(_L_PAREN); + render("NULLS"); + render("FIRST"); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NullsLastC) + { + if (_i_ > 0) render(_L_PAREN); + render("NULLS"); + render("LAST"); + if (_i_ > 0) render(_R_PAREN); + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem foo, int _i_) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItemC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItemC _selitemc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItemC) foo; + if (_i_ > 0) render(_L_PAREN); + pp(_selitemc.condexpr_, 0); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AliasedSelItemC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AliasedSelItemC _aliasedselitemc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AliasedSelItemC) foo; + if (_i_ > 0) render(_L_PAREN); + pp(_aliasedselitemc.condexpr_, 0); + render("AS"); + pp(_aliasedselitemc.qident_, 0); + if (_i_ > 0) render(_R_PAREN); + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr foo, int _i_) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprCmpC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprCmpC _boolexprcmpc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprCmpC) foo; + if (_i_ > 0) render(_L_PAREN); + pp(_boolexprcmpc.basicexpr_1, 0); + pp(_boolexprcmpc.relop_, 0); + pp(_boolexprcmpc.basicexpr_2, 0); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprRegExpC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprRegExpC _boolexprregexpc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprRegExpC) foo; + if (_i_ > 0) render(_L_PAREN); + pp(_boolexprregexpc.basicexpr_, 0); + render("REGEXP"); + printQuoted(_boolexprregexpc.string_); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprBasicExprC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprBasicExprC _boolexprbasicexprc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprBasicExprC) foo; + if (_i_ > 0) render(_L_PAREN); + pp(_boolexprbasicexprc.basicexpr_, 0); + if (_i_ > 0) render(_R_PAREN); + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr foo, int _i_) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprOrC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprOrC _condexprorc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprOrC) foo; + if (_i_ > 0) render(_L_PAREN); + pp(_condexprorc.condexpr_1, 0); + render("OR"); + pp(_condexprorc.condexpr_2, 1); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprAndC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprAndC _condexprandc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprAndC) foo; + if (_i_ > 1) render(_L_PAREN); + pp(_condexprandc.condexpr_1, 1); + render("AND"); + pp(_condexprandc.condexpr_2, 2); + if (_i_ > 1) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprNotC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprNotC _condexprnotc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprNotC) foo; + if (_i_ > 2) render(_L_PAREN); + render("NOT"); + pp(_condexprnotc.condexpr_, 2); + if (_i_ > 2) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprBoolExprC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprBoolExprC _condexprboolexprc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprBoolExprC) foo; + if (_i_ > 2) render(_L_PAREN); + pp(_condexprboolexprc.boolexpr_, 0); + if (_i_ > 2) render(_R_PAREN); + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr foo, int _i_) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprAddC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprAddC _basicexpraddc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprAddC) foo; + if (_i_ > 0) render(_L_PAREN); + pp(_basicexpraddc.basicexpr_1, 0); + render("+"); + pp(_basicexpraddc.basicexpr_2, 1); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprSubC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprSubC _basicexprsubc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprSubC) foo; + if (_i_ > 0) render(_L_PAREN); + pp(_basicexprsubc.basicexpr_1, 0); + render("-"); + pp(_basicexprsubc.basicexpr_2, 1); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprMulC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprMulC _basicexprmulc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprMulC) foo; + if (_i_ > 1) render(_L_PAREN); + pp(_basicexprmulc.basicexpr_1, 1); + render("*"); + pp(_basicexprmulc.basicexpr_2, 2); + if (_i_ > 1) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprDivC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprDivC _basicexprdivc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprDivC) foo; + if (_i_ > 1) render(_L_PAREN); + pp(_basicexprdivc.basicexpr_1, 1); + render("/"); + pp(_basicexprdivc.basicexpr_2, 2); + if (_i_ > 1) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprModC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprModC _basicexprmodc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprModC) foo; + if (_i_ > 1) render(_L_PAREN); + pp(_basicexprmodc.basicexpr_1, 1); + render("%"); + pp(_basicexprmodc.basicexpr_2, 2); + if (_i_ > 1) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprNegC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprNegC _basicexprnegc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprNegC) foo; + if (_i_ > 2) render(_L_PAREN); + render("-"); + pp(_basicexprnegc.basicexpr_, 2); + if (_i_ > 2) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EBoolC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EBoolC _eboolc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EBoolC) foo; + if (_i_ > 3) render(_L_PAREN); + pp(_eboolc.qbool_, 0); + if (_i_ > 3) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIdentC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIdentC _eidentc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIdentC) foo; + if (_i_ > 3) render(_L_PAREN); + pp(_eidentc.qident_, 0); + if (_i_ > 3) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EFunC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EFunC _efunc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EFunC) foo; + if (_i_ > 3) render(_L_PAREN); + pp(_efunc.qident_, 0); + render("("); + pp(_efunc.listcondexpr_, 0); + render(")"); + if (_i_ > 3) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStrC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStrC _estrc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStrC) foo; + if (_i_ > 3) render(_L_PAREN); + printQuoted(_estrc.string_); + if (_i_ > 3) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIntC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIntC _eintc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIntC) foo; + if (_i_ > 3) render(_L_PAREN); + pp(_eintc.qinteger_, 0); + if (_i_ > 3) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EDblC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EDblC _edblc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EDblC) foo; + if (_i_ > 3) render(_L_PAREN); + pp(_edblc.qdouble_, 0); + if (_i_ > 3) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ECondExprC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ECondExprC _econdexprc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ECondExprC) foo; + if (_i_ > 3) render(_L_PAREN); + render("("); + pp(_econdexprc.condexpr_, 0); + render(")"); + if (_i_ > 3) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStmtC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStmtC _estmtc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStmtC) foo; + if (_i_ > 3) render(_L_PAREN); + render("("); + pp(_estmtc.statement_, 0); + render(")"); + if (_i_ > 3) render(_R_PAREN); + } + } + + private static void pp(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp foo, int _i_) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpGtC) + { + if (_i_ > 0) render(_L_PAREN); + render(">"); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpEqC) + { + if (_i_ > 0) render(_L_PAREN); + render("="); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpNeC) + { + if (_i_ > 0) render(_L_PAREN); + render("<>"); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpLtC) + { + if (_i_ > 0) render(_L_PAREN); + render("<"); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpLeC) + { + if (_i_ > 0) render(_L_PAREN); + render("<="); + if (_i_ > 0) render(_R_PAREN); + } + else if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpGeC) + { + if (_i_ > 0) render(_L_PAREN); + render(">="); + if (_i_ > 0) render(_R_PAREN); + } + } + + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListStatement foo) + { + for (java.util.Iterator<Statement> it = foo.iterator(); it.hasNext();) + { + sh(it.next()); + if (it.hasNext()) + render(","); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListOrderItem foo) + { + for (java.util.Iterator<OrderItem> it = foo.iterator(); it.hasNext();) + { + sh(it.next()); + if (it.hasNext()) + render(","); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListSelItem foo) + { + for (java.util.Iterator<SelItem> it = foo.iterator(); it.hasNext();) + { + sh(it.next()); + if (it.hasNext()) + render(","); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr foo) + { + for (java.util.Iterator<CondExpr> it = foo.iterator(); it.hasNext();) + { + sh(it.next()); + if (it.hasNext()) + render(","); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program foo) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ProgramC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ProgramC _programc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ProgramC) foo; + render("("); + render("ProgramC"); + render("["); + sh(_programc.liststatement_); + render("]"); + render(")"); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement foo) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.StatementC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.StatementC _statementc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.StatementC) foo; + render("("); + render("StatementC"); + render("["); + sh(_statementc.listselitem_); + render("]"); + sh(_statementc.where_); + sh(_statementc.orderby_); + render(")"); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Where foo) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoWhereC) + { + render("NoWhereC"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.WhereC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.WhereC _wherec = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.WhereC) foo; + render("("); + render("WhereC"); + sh(_wherec.condexpr_); + render(")"); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderBy foo) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoOrderByC) + { + render("NoOrderByC"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderByC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderByC _orderbyc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderByC) foo; + render("("); + render("OrderByC"); + render("["); + sh(_orderbyc.listorderitem_); + render("]"); + render(")"); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItem foo) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItemC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItemC _orderitemc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItemC) foo; + render("("); + render("OrderItemC"); + sh(_orderitemc.condexpr_); + sh(_orderitemc.order_); + sh(_orderitemc.nulls_); + render(")"); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order foo) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AscOrderC) + { + render("AscOrderC"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.DescOrderC) + { + render("DescOrderC"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoOrderC) + { + render("NoOrderC"); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls foo) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoNullsC) + { + render("NoNullsC"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NullFirstsC) + { + render("NullFirstsC"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NullsLastC) + { + render("NullsLastC"); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem foo) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItemC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItemC _selitemc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItemC) foo; + render("("); + render("SelItemC"); + sh(_selitemc.condexpr_); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AliasedSelItemC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AliasedSelItemC _aliasedselitemc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AliasedSelItemC) foo; + render("("); + render("AliasedSelItemC"); + sh(_aliasedselitemc.condexpr_); + sh(_aliasedselitemc.qident_); + render(")"); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr foo) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprCmpC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprCmpC _boolexprcmpc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprCmpC) foo; + render("("); + render("BoolExprCmpC"); + sh(_boolexprcmpc.basicexpr_1); + sh(_boolexprcmpc.relop_); + sh(_boolexprcmpc.basicexpr_2); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprRegExpC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprRegExpC _boolexprregexpc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprRegExpC) foo; + render("("); + render("BoolExprRegExpC"); + sh(_boolexprregexpc.basicexpr_); + sh(_boolexprregexpc.string_); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprBasicExprC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprBasicExprC _boolexprbasicexprc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprBasicExprC) foo; + render("("); + render("BoolExprBasicExprC"); + sh(_boolexprbasicexprc.basicexpr_); + render(")"); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr foo) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprOrC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprOrC _condexprorc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprOrC) foo; + render("("); + render("CondExprOrC"); + sh(_condexprorc.condexpr_1); + sh(_condexprorc.condexpr_2); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprAndC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprAndC _condexprandc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprAndC) foo; + render("("); + render("CondExprAndC"); + sh(_condexprandc.condexpr_1); + sh(_condexprandc.condexpr_2); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprNotC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprNotC _condexprnotc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprNotC) foo; + render("("); + render("CondExprNotC"); + sh(_condexprnotc.condexpr_); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprBoolExprC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprBoolExprC _condexprboolexprc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprBoolExprC) foo; + render("("); + render("CondExprBoolExprC"); + sh(_condexprboolexprc.boolexpr_); + render(")"); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr foo) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprAddC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprAddC _basicexpraddc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprAddC) foo; + render("("); + render("BasicExprAddC"); + sh(_basicexpraddc.basicexpr_1); + sh(_basicexpraddc.basicexpr_2); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprSubC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprSubC _basicexprsubc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprSubC) foo; + render("("); + render("BasicExprSubC"); + sh(_basicexprsubc.basicexpr_1); + sh(_basicexprsubc.basicexpr_2); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprMulC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprMulC _basicexprmulc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprMulC) foo; + render("("); + render("BasicExprMulC"); + sh(_basicexprmulc.basicexpr_1); + sh(_basicexprmulc.basicexpr_2); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprDivC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprDivC _basicexprdivc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprDivC) foo; + render("("); + render("BasicExprDivC"); + sh(_basicexprdivc.basicexpr_1); + sh(_basicexprdivc.basicexpr_2); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprModC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprModC _basicexprmodc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprModC) foo; + render("("); + render("BasicExprModC"); + sh(_basicexprmodc.basicexpr_1); + sh(_basicexprmodc.basicexpr_2); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprNegC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprNegC _basicexprnegc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprNegC) foo; + render("("); + render("BasicExprNegC"); + sh(_basicexprnegc.basicexpr_); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EBoolC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EBoolC _eboolc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EBoolC) foo; + render("("); + render("EBoolC"); + sh(_eboolc.qbool_); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIdentC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIdentC _eidentc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIdentC) foo; + render("("); + render("EIdentC"); + sh(_eidentc.qident_); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EFunC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EFunC _efunc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EFunC) foo; + render("("); + render("EFunC"); + sh(_efunc.qident_); + render("["); + sh(_efunc.listcondexpr_); + render("]"); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStrC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStrC _estrc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStrC) foo; + render("("); + render("EStrC"); + sh(_estrc.string_); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIntC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIntC _eintc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIntC) foo; + render("("); + render("EIntC"); + sh(_eintc.qinteger_); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EDblC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EDblC _edblc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EDblC) foo; + render("("); + render("EDblC"); + sh(_edblc.qdouble_); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ECondExprC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ECondExprC _econdexprc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ECondExprC) foo; + render("("); + render("ECondExprC"); + sh(_econdexprc.condexpr_); + render(")"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStmtC) + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStmtC _estmtc = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStmtC) foo; + render("("); + render("EStmtC"); + sh(_estmtc.statement_); + render(")"); + } + } + + private static void sh(pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp foo) + { + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpGtC) + { + render("RelOpGtC"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpEqC) + { + render("RelOpEqC"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpNeC) + { + render("RelOpNeC"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpLtC) + { + render("RelOpLtC"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpLeC) + { + render("RelOpLeC"); + } + if (foo instanceof pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpGeC) + { + render("RelOpGeC"); + } + } + + + private static void pp(String s, int _i_) { buf_.append(s); buf_.append(" "); } + private static void sh(String s) { printQuoted(s); } + private static void printQuoted(String s) { render("\"" + s + "\""); } + private static void indent() + { + int n = _n_; + while (n > 0) + { + buf_.append(" "); + n--; + } + } + private static void backup() + { + if (buf_.charAt(buf_.length() - 1) == ' ') { + buf_.setLength(buf_.length() - 1); + } + } + private static void trim() + { + while (buf_.length() > 0 && buf_.charAt(0) == ' ') + buf_.deleteCharAt(0); + while (buf_.length() > 0 && buf_.charAt(buf_.length()-1) == ' ') + buf_.deleteCharAt(buf_.length()-1); + } + private static int _n_ = 0; + private static StringBuilder buf_ = new StringBuilder(INITIAL_BUFFER_SIZE); +} + diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Test.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Test.java new file mode 100644 index 0000000..57ac1f8 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Test.java @@ -0,0 +1,46 @@ +package pl.edu.mimuw.cloudatlas.interpreter.query; +import java.io.FileNotFoundException; +import java.io.FileReader; + +public class Test +{ + public static void main(String args[]) throws Exception + { + Yylex l = null; + parser p; + try + { + if (args.length == 0) l = new Yylex(System.in); + else l = new Yylex(new FileReader(args[0])); + } + catch(FileNotFoundException e) + { + System.err.println("Error: File not found: " + args[0]); + System.exit(1); + } + p = new parser(l); + /* The default parser is the first-defined entry point. */ + /* You may want to change this. Other options are: */ + /* */ + try + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program parse_tree = p.pProgram(); + System.out.println(); + System.out.println("Parse Succesful!"); + System.out.println(); + System.out.println("[Abstract Syntax]"); + System.out.println(); + System.out.println(PrettyPrinter.show(parse_tree)); + System.out.println(); + System.out.println("[Linearized Tree]"); + System.out.println(); + System.out.println(PrettyPrinter.print(parse_tree)); + } + catch(Throwable e) + { + System.err.println("At line " + String.valueOf(l.line_num()) + ", near \"" + l.buff() + "\" :"); + System.err.println(" " + e.getMessage()); + System.exit(1); + } + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex new file mode 100644 index 0000000..4dd8029 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex @@ -0,0 +1,76 @@ +// This JLex file was machine-generated by the BNF converter +package pl.edu.mimuw.mmws.cloudatlas.query; + +import java_cup.runtime.*; +%% +%cup +%unicode +%line +%public +%{ + String pstring = new String(); + public int line_num() { return (yyline+1); } + public String buff() { return new String(yy_buffer,yy_buffer_index,10).trim(); } +%} +LETTER = ({CAPITAL}|{SMALL}) +CAPITAL = [A-Z\xC0-\xD6\xD8-\xDE] +SMALL = [a-z\xDF-\xF6\xF8-\xFF] +DIGIT = [0-9] +IDENT = ({LETTER}|{DIGIT}|['_]) +%state COMMENT +%state CHAR +%state CHARESC +%state CHAREND +%state STRING +%state ESCAPED +%% +<YYINITIAL>; { return new Symbol(sym._SYMB_0); } +<YYINITIAL>, { return new Symbol(sym._SYMB_1); } +<YYINITIAL>\+ { return new Symbol(sym._SYMB_2); } +<YYINITIAL>- { return new Symbol(sym._SYMB_3); } +<YYINITIAL>\* { return new Symbol(sym._SYMB_4); } +<YYINITIAL>/ { return new Symbol(sym._SYMB_5); } +<YYINITIAL>% { return new Symbol(sym._SYMB_6); } +<YYINITIAL>\( { return new Symbol(sym._SYMB_7); } +<YYINITIAL>\) { return new Symbol(sym._SYMB_8); } +<YYINITIAL>> { return new Symbol(sym._SYMB_9); } +<YYINITIAL>= { return new Symbol(sym._SYMB_10); } +<YYINITIAL><> { return new Symbol(sym._SYMB_11); } +<YYINITIAL>< { return new Symbol(sym._SYMB_12); } +<YYINITIAL><= { return new Symbol(sym._SYMB_13); } +<YYINITIAL>>= { return new Symbol(sym._SYMB_14); } +<YYINITIAL>AND { return new Symbol(sym._SYMB_15); } +<YYINITIAL>AS { return new Symbol(sym._SYMB_16); } +<YYINITIAL>ASC { return new Symbol(sym._SYMB_17); } +<YYINITIAL>BY { return new Symbol(sym._SYMB_18); } +<YYINITIAL>DESC { return new Symbol(sym._SYMB_19); } +<YYINITIAL>FIRST { return new Symbol(sym._SYMB_20); } +<YYINITIAL>LAST { return new Symbol(sym._SYMB_21); } +<YYINITIAL>NOT { return new Symbol(sym._SYMB_22); } +<YYINITIAL>NULLS { return new Symbol(sym._SYMB_23); } +<YYINITIAL>OR { return new Symbol(sym._SYMB_24); } +<YYINITIAL>ORDER { return new Symbol(sym._SYMB_25); } +<YYINITIAL>REGEXP { return new Symbol(sym._SYMB_26); } +<YYINITIAL>SELECT { return new Symbol(sym._SYMB_27); } +<YYINITIAL>WHERE { return new Symbol(sym._SYMB_28); } + +<YYINITIAL>true|false { return new Symbol(sym.QBool, yytext().intern()); } +<YYINITIAL>({LETTER}|&)({LETTER}|{DIGIT}|_)* { return new Symbol(sym.QIdent, yytext().intern()); } +<YYINITIAL>{DIGIT}*\.{DIGIT}+([eE]-?{DIGIT}+)?|{DIGIT}+([eE]-?{DIGIT}+) { return new Symbol(sym.QDouble, yytext().intern()); } +<YYINITIAL>0|[123456789]{DIGIT}* { return new Symbol(sym.QInteger, yytext().intern()); } + +<YYINITIAL>"\"" { yybegin(STRING); } +<STRING>\\ { yybegin(ESCAPED); } +<STRING>\" { String foo = pstring; pstring = new String(); yybegin(YYINITIAL); return new Symbol(sym._STRING_, foo.intern()); } +<STRING>. { pstring += yytext(); } +<ESCAPED>n { pstring += "\n"; yybegin(STRING); } +<ESCAPED>\" { pstring += "\""; yybegin(STRING); } +<ESCAPED>\\ { pstring += "\\"; yybegin(STRING); } +<ESCAPED>t { pstring += "\t"; yybegin(STRING); } +<ESCAPED>. { pstring += yytext(); yybegin(STRING); } + + + + + +<YYINITIAL>[ \t\r\n\f] { /* ignore white space. */ } diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex.java new file mode 100644 index 0000000..2fb69d7 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex.java @@ -0,0 +1,763 @@ +// This JLex file was machine-generated by the BNF converter +package pl.edu.mimuw.cloudatlas.interpreter.query; +import java_cup.runtime.*; + + +public class Yylex implements java_cup.runtime.Scanner { + private final int YY_BUFFER_SIZE = 512; + private final int YY_F = -1; + private final int YY_NO_STATE = -1; + private final int YY_NOT_ACCEPT = 0; + private final int YY_END = 2; + private final int YY_NO_ANCHOR = 4; + private final int YY_BOL = 65536; + private final int YY_EOF = 65537; + + String pstring = new String(); + public int line_num() { return (yyline+1); } + public String buff() { return new String(yy_buffer,yy_buffer_index,10).trim(); } + private java.io.BufferedReader yy_reader; + private int yy_buffer_index; + private int yy_buffer_read; + private int yy_buffer_start; + private int yy_buffer_end; + private char yy_buffer[]; + private int yyline; + private boolean yy_at_bol; + private int yy_lexical_state; + + public Yylex (java.io.Reader reader) { + this (); + if (null == reader) { + throw (new Error("Error: Bad input stream initializer.")); + } + yy_reader = new java.io.BufferedReader(reader); + } + + public Yylex (java.io.InputStream instream) { + this (); + if (null == instream) { + throw (new Error("Error: Bad input stream initializer.")); + } + yy_reader = new java.io.BufferedReader(new java.io.InputStreamReader(instream)); + } + + private Yylex () { + yy_buffer = new char[YY_BUFFER_SIZE]; + yy_buffer_read = 0; + yy_buffer_index = 0; + yy_buffer_start = 0; + yy_buffer_end = 0; + yyline = 0; + yy_at_bol = true; + yy_lexical_state = YYINITIAL; + } + + private final int STRING = 5; + private final int ESCAPED = 6; + private final int YYINITIAL = 0; + private final int yy_state_dtrans[] = { + 0, + 57, + 57, + 57, + 57, + 59, + 61 + }; + private void yybegin (int state) { + yy_lexical_state = state; + } + private int yy_advance () + throws java.io.IOException { + int next_read; + int i; + int j; + + if (yy_buffer_index < yy_buffer_read) { + return yy_buffer[yy_buffer_index++]; + } + + if (0 != yy_buffer_start) { + i = yy_buffer_start; + j = 0; + while (i < yy_buffer_read) { + yy_buffer[j] = yy_buffer[i]; + ++i; + ++j; + } + yy_buffer_end = yy_buffer_end - yy_buffer_start; + yy_buffer_start = 0; + yy_buffer_read = j; + yy_buffer_index = j; + next_read = yy_reader.read(yy_buffer, + yy_buffer_read, + yy_buffer.length - yy_buffer_read); + if (-1 == next_read) { + return YY_EOF; + } + yy_buffer_read = yy_buffer_read + next_read; + } + + while (yy_buffer_index >= yy_buffer_read) { + if (yy_buffer_index >= yy_buffer.length) { + yy_buffer = yy_double(yy_buffer); + } + next_read = yy_reader.read(yy_buffer, + yy_buffer_read, + yy_buffer.length - yy_buffer_read); + if (-1 == next_read) { + return YY_EOF; + } + yy_buffer_read = yy_buffer_read + next_read; + } + return yy_buffer[yy_buffer_index++]; + } + private void yy_move_end () { + if (yy_buffer_end > yy_buffer_start && + '\n' == yy_buffer[yy_buffer_end-1]) + yy_buffer_end--; + if (yy_buffer_end > yy_buffer_start && + '\r' == yy_buffer[yy_buffer_end-1]) + yy_buffer_end--; + } + private boolean yy_last_was_cr=false; + private void yy_mark_start () { + int i; + for (i = yy_buffer_start; i < yy_buffer_index; ++i) { + if ('\n' == yy_buffer[i] && !yy_last_was_cr) { + ++yyline; + } + if ('\r' == yy_buffer[i]) { + ++yyline; + yy_last_was_cr=true; + } else yy_last_was_cr=false; + } + yy_buffer_start = yy_buffer_index; + } + private void yy_mark_end () { + yy_buffer_end = yy_buffer_index; + } + private void yy_to_mark () { + yy_buffer_index = yy_buffer_end; + yy_at_bol = (yy_buffer_end > yy_buffer_start) && + ('\r' == yy_buffer[yy_buffer_end-1] || + '\n' == yy_buffer[yy_buffer_end-1] || + 2028/*LS*/ == yy_buffer[yy_buffer_end-1] || + 2029/*PS*/ == yy_buffer[yy_buffer_end-1]); + } + private java.lang.String yytext () { + return (new java.lang.String(yy_buffer, + yy_buffer_start, + yy_buffer_end - yy_buffer_start)); + } + private char[] yy_double (char buf[]) { + int i; + char newbuf[]; + newbuf = new char[2*buf.length]; + for (i = 0; i < buf.length; ++i) { + newbuf[i] = buf[i]; + } + return newbuf; + } + private final int YY_E_INTERNAL = 0; + private java.lang.String yy_error_string[] = { + "Error: Internal error.\n", + "Error: Unmatched input.\n" + }; + private void yy_error (int code,boolean fatal) { + java.lang.System.out.print(yy_error_string[code]); + java.lang.System.out.flush(); + if (fatal) { + throw new Error("Fatal Error.\n"); + } + } + private int[][] unpackFromString(int size1, int size2, String st) { + int colonIndex = -1; + String lengthString; + int sequenceLength = 0; + int sequenceInteger = 0; + + int commaIndex; + String workString; + + int res[][] = new int[size1][size2]; + for (int i= 0; i < size1; i++) { + for (int j= 0; j < size2; j++) { + if (sequenceLength != 0) { + res[i][j] = sequenceInteger; + sequenceLength--; + continue; + } + commaIndex = st.indexOf(','); + workString = (commaIndex==-1) ? st : + st.substring(0, commaIndex); + st = st.substring(commaIndex+1); + colonIndex = workString.indexOf(':'); + if (colonIndex == -1) { + res[i][j]=Integer.parseInt(workString); + continue; + } + lengthString = + workString.substring(colonIndex+1); + sequenceLength=Integer.parseInt(lengthString); + workString=workString.substring(0,colonIndex); + sequenceInteger=Integer.parseInt(workString); + res[i][j] = sequenceInteger; + sequenceLength--; + } + } + return res; + } + private int yy_acpt[] = { + /* 0 */ YY_NOT_ACCEPT, + /* 1 */ YY_NO_ANCHOR, + /* 2 */ YY_NO_ANCHOR, + /* 3 */ YY_NO_ANCHOR, + /* 4 */ YY_NO_ANCHOR, + /* 5 */ YY_NO_ANCHOR, + /* 6 */ YY_NO_ANCHOR, + /* 7 */ YY_NO_ANCHOR, + /* 8 */ YY_NO_ANCHOR, + /* 9 */ YY_NO_ANCHOR, + /* 10 */ YY_NO_ANCHOR, + /* 11 */ YY_NO_ANCHOR, + /* 12 */ YY_NO_ANCHOR, + /* 13 */ YY_NO_ANCHOR, + /* 14 */ YY_NO_ANCHOR, + /* 15 */ YY_NO_ANCHOR, + /* 16 */ YY_NO_ANCHOR, + /* 17 */ YY_NO_ANCHOR, + /* 18 */ YY_NO_ANCHOR, + /* 19 */ YY_NO_ANCHOR, + /* 20 */ YY_NO_ANCHOR, + /* 21 */ YY_NO_ANCHOR, + /* 22 */ YY_NO_ANCHOR, + /* 23 */ YY_NO_ANCHOR, + /* 24 */ YY_NO_ANCHOR, + /* 25 */ YY_NO_ANCHOR, + /* 26 */ YY_NO_ANCHOR, + /* 27 */ YY_NO_ANCHOR, + /* 28 */ YY_NO_ANCHOR, + /* 29 */ YY_NO_ANCHOR, + /* 30 */ YY_NO_ANCHOR, + /* 31 */ YY_NO_ANCHOR, + /* 32 */ YY_NO_ANCHOR, + /* 33 */ YY_NO_ANCHOR, + /* 34 */ YY_NO_ANCHOR, + /* 35 */ YY_NO_ANCHOR, + /* 36 */ YY_NO_ANCHOR, + /* 37 */ YY_NO_ANCHOR, + /* 38 */ YY_NO_ANCHOR, + /* 39 */ YY_NO_ANCHOR, + /* 40 */ YY_NO_ANCHOR, + /* 41 */ YY_NO_ANCHOR, + /* 42 */ YY_NO_ANCHOR, + /* 43 */ YY_NO_ANCHOR, + /* 44 */ YY_NO_ANCHOR, + /* 45 */ YY_NOT_ACCEPT, + /* 46 */ YY_NO_ANCHOR, + /* 47 */ YY_NO_ANCHOR, + /* 48 */ YY_NO_ANCHOR, + /* 49 */ YY_NOT_ACCEPT, + /* 50 */ YY_NO_ANCHOR, + /* 51 */ YY_NOT_ACCEPT, + /* 52 */ YY_NO_ANCHOR, + /* 53 */ YY_NOT_ACCEPT, + /* 54 */ YY_NO_ANCHOR, + /* 55 */ YY_NOT_ACCEPT, + /* 56 */ YY_NO_ANCHOR, + /* 57 */ YY_NOT_ACCEPT, + /* 58 */ YY_NO_ANCHOR, + /* 59 */ YY_NOT_ACCEPT, + /* 60 */ YY_NO_ANCHOR, + /* 61 */ YY_NOT_ACCEPT, + /* 62 */ YY_NO_ANCHOR, + /* 63 */ YY_NO_ANCHOR, + /* 64 */ YY_NO_ANCHOR, + /* 65 */ YY_NO_ANCHOR, + /* 66 */ YY_NO_ANCHOR, + /* 67 */ YY_NO_ANCHOR, + /* 68 */ YY_NO_ANCHOR, + /* 69 */ YY_NO_ANCHOR, + /* 70 */ YY_NO_ANCHOR, + /* 71 */ YY_NO_ANCHOR, + /* 72 */ YY_NO_ANCHOR, + /* 73 */ YY_NO_ANCHOR, + /* 74 */ YY_NO_ANCHOR, + /* 75 */ YY_NO_ANCHOR, + /* 76 */ YY_NO_ANCHOR, + /* 77 */ YY_NO_ANCHOR, + /* 78 */ YY_NO_ANCHOR, + /* 79 */ YY_NO_ANCHOR, + /* 80 */ YY_NO_ANCHOR, + /* 81 */ YY_NO_ANCHOR, + /* 82 */ YY_NO_ANCHOR, + /* 83 */ YY_NO_ANCHOR, + /* 84 */ YY_NO_ANCHOR, + /* 85 */ YY_NO_ANCHOR, + /* 86 */ YY_NO_ANCHOR, + /* 87 */ YY_NO_ANCHOR, + /* 88 */ YY_NO_ANCHOR, + /* 89 */ YY_NO_ANCHOR, + /* 90 */ YY_NO_ANCHOR, + /* 91 */ YY_NO_ANCHOR, + /* 92 */ YY_NO_ANCHOR, + /* 93 */ YY_NO_ANCHOR, + /* 94 */ YY_NO_ANCHOR, + /* 95 */ YY_NO_ANCHOR + }; + private int yy_cmap[] = unpackFromString(1,65538, +"49:9,51,52,49,51,52,49:18,51,49,47,49:2,7,42,49,8,9,5,3,2,4,45,6,46,43:9,49" + +",1,12,11,10,49:2,13,18,17,15,20,21,28,32,22,41:2,25,41,14,26,30,41,23,16,24" + +",27,41,31,29,19,41,49,48,49:2,44,49,38,41:3,36,37,41:5,39,41,50,41:3,34,40," + +"33,35,41:5,49:69,41:23,49,41:31,49,41:8,49:65280,0:2")[0]; + + private int yy_rmap[] = unpackFromString(1,96, +"0,1:10,2,1,3,4,5,1:5,6,7,8,9,7:12,1:8,10,11,12,13,14,15,12,16,13,17,14,18,1" + +"9,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,4" + +"4,45,46,47,48,49,7,50,51,52,53,54,55,56")[0]; + + private int yy_nxt[][] = unpackFromString(57,53, +"1,2,3,4,5,6,7,8,9,10,11,12,13,14,46,81,85,88,50,88:2,90,88,91,88,92,52,88:4" + +",93,88,94,88:3,95,88:5,15,-1,45,47,16,-1:2,88,17:2,-1:64,18,-1:51,19,20,-1:" + +"54,88,54,88,21,88:25,-1,88:2,-1,88,-1:3,88,-1:22,49,-1:15,49,-1:6,15,-1,45," + +"15,-1:19,88:4,26,88:24,-1,88:2,-1,88,-1:3,88,-1:15,88:29,-1,88:2,-1,88,-1:3" + +",88,-1:15,88:2,89,88:26,-1,88:2,-1,88,-1:3,88,-1:22,55,-1:15,55,-1:6,24,-1:" + +"2,24,-1:49,24,-1:2,24,-1:19,88:13,56,58,88:14,-1,88:2,-1,88,-1:3,88,-1:22,4" + +"9,-1:15,49,-1:6,51,-1,45,51,-1:49,48,-1:2,48,-1:10,53,-1:38,48,-1:2,48,-1:1" + +"9,88:6,22,88:22,-1,88:2,-1,88,-1:3,88,-1:15,88:10,23,88:18,-1,88:2,-1,88,-1" + +":3,88,-1:15,88:2,25,88:26,-1,88:2,-1,88,-1:3,88,-1:15,88:11,27,88:17,-1,88:" + +"2,-1,88,-1:3,88,-1:2,1,-1:65,88:12,86,88:16,-1,88:2,-1,88,-1:3,88,-1:2,1,37" + +":46,38,39,37:3,-1:14,88:3,67,88:25,-1,88:2,-1,88,-1:3,88,-1:2,1,40:32,41,40" + +":13,42,43,40,44,40,-1:14,88:10,68,88:18,-1,88:2,-1,88,-1:3,88,-1:15,88:15,8" + +"7,88:13,-1,88:2,-1,88,-1:3,88,-1:15,88:7,70,88:21,-1,88:2,-1,88,-1:3,88,-1:" + +"15,88:22,71,88:6,-1,88:2,-1,88,-1:3,88,-1:15,88:26,72,88:2,-1,88:2,-1,88,-1" + +":3,88,-1:15,88:4,28,88:24,-1,88:2,-1,88,-1:3,88,-1:15,88:3,75,88:25,-1,88:2" + +",-1,88,-1:3,88,-1:15,88:11,29,88:17,-1,88:2,-1,88,-1:3,88,-1:15,88:10,78,88" + +":18,-1,88:2,-1,88,-1:3,88,-1:15,88:23,30,88:5,-1,88:2,-1,88,-1:3,88,-1:15,8" + +"8:27,71,88,-1,88:2,-1,88,-1:3,88,-1:15,88:3,31,88:25,-1,88:2,-1,88,-1:3,88," + +"-1:15,88:4,79,88:24,-1,88:2,-1,88,-1:3,88,-1:15,88:11,32,88:17,-1,88:2,-1,8" + +"8,-1:3,88,-1:15,88:16,80,88:12,-1,88:2,-1,88,-1:3,88,-1:15,88:10,33,88:18,-" + +"1,88:2,-1,88,-1:3,88,-1:15,88:7,34,88:21,-1,88:2,-1,88,-1:3,88,-1:15,88:11," + +"35,88:17,-1,88:2,-1,88,-1:3,88,-1:15,88:17,36,88:11,-1,88:2,-1,88,-1:3,88,-" + +"1:15,88:7,60,88:21,-1,88:2,-1,88,-1:3,88,-1:15,88:12,84,88:16,-1,88:2,-1,88" + +",-1:3,88,-1:15,88:3,69,88:25,-1,88:2,-1,88,-1:3,88,-1:15,88:7,74,88:21,-1,8" + +"8:2,-1,88,-1:3,88,-1:15,88:7,82,88:21,-1,88:2,-1,88,-1:3,88,-1:15,88:12,73," + +"88:16,-1,88:2,-1,88,-1:3,88,-1:15,88:7,76,88:21,-1,88:2,-1,88,-1:3,88,-1:15" + +",88:7,77,88:21,-1,88:2,-1,88,-1:3,88,-1:15,88:9,62,88:19,-1,88:2,-1,88,-1:3" + +",88,-1:15,88:7,63,88:21,-1,88:2,-1,88,-1:3,88,-1:15,83,88:28,-1,88:2,-1,88," + +"-1:3,88,-1:15,88:19,64,88:9,-1,88:2,-1,88,-1:3,88,-1:15,88:21,65,88:7,-1,88" + +":2,-1,88,-1:3,88,-1:15,88:25,66,88:3,-1,88:2,-1,88,-1:3,88,-1:2"); + + public java_cup.runtime.Symbol next_token () + throws java.io.IOException { + int yy_lookahead; + int yy_anchor = YY_NO_ANCHOR; + int yy_state = yy_state_dtrans[yy_lexical_state]; + int yy_next_state = YY_NO_STATE; + int yy_last_accept_state = YY_NO_STATE; + boolean yy_initial = true; + int yy_this_accept; + + yy_mark_start(); + yy_this_accept = yy_acpt[yy_state]; + if (YY_NOT_ACCEPT != yy_this_accept) { + yy_last_accept_state = yy_state; + yy_mark_end(); + } + while (true) { + if (yy_initial && yy_at_bol) yy_lookahead = YY_BOL; + else yy_lookahead = yy_advance(); + yy_next_state = YY_F; + yy_next_state = yy_nxt[yy_rmap[yy_state]][yy_cmap[yy_lookahead]]; + if (YY_EOF == yy_lookahead && true == yy_initial) { + return null; + } + if (YY_F != yy_next_state) { + yy_state = yy_next_state; + yy_initial = false; + yy_this_accept = yy_acpt[yy_state]; + if (YY_NOT_ACCEPT != yy_this_accept) { + yy_last_accept_state = yy_state; + yy_mark_end(); + } + } + else { + if (YY_NO_STATE == yy_last_accept_state) { + throw (new Error("Lexical Error: Unmatched Input.")); + } + else { + yy_anchor = yy_acpt[yy_last_accept_state]; + if (0 != (YY_END & yy_anchor)) { + yy_move_end(); + } + yy_to_mark(); + switch (yy_last_accept_state) { + case 1: + + case -2: + break; + case 2: + { return new Symbol(sym._SYMB_0); } + case -3: + break; + case 3: + { return new Symbol(sym._SYMB_1); } + case -4: + break; + case 4: + { return new Symbol(sym._SYMB_2); } + case -5: + break; + case 5: + { return new Symbol(sym._SYMB_3); } + case -6: + break; + case 6: + { return new Symbol(sym._SYMB_4); } + case -7: + break; + case 7: + { return new Symbol(sym._SYMB_5); } + case -8: + break; + case 8: + { return new Symbol(sym._SYMB_6); } + case -9: + break; + case 9: + { return new Symbol(sym._SYMB_7); } + case -10: + break; + case 10: + { return new Symbol(sym._SYMB_8); } + case -11: + break; + case 11: + { return new Symbol(sym._SYMB_9); } + case -12: + break; + case 12: + { return new Symbol(sym._SYMB_10); } + case -13: + break; + case 13: + { return new Symbol(sym._SYMB_12); } + case -14: + break; + case 14: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -15: + break; + case 15: + { return new Symbol(sym.QInteger, yytext().intern()); } + case -16: + break; + case 16: + { yybegin(STRING); } + case -17: + break; + case 17: + { /* ignore white space. */ } + case -18: + break; + case 18: + { return new Symbol(sym._SYMB_14); } + case -19: + break; + case 19: + { return new Symbol(sym._SYMB_11); } + case -20: + break; + case 20: + { return new Symbol(sym._SYMB_13); } + case -21: + break; + case 21: + { return new Symbol(sym._SYMB_16); } + case -22: + break; + case 22: + { return new Symbol(sym._SYMB_18); } + case -23: + break; + case 23: + { return new Symbol(sym._SYMB_24); } + case -24: + break; + case 24: + { return new Symbol(sym.QDouble, yytext().intern()); } + case -25: + break; + case 25: + { return new Symbol(sym._SYMB_15); } + case -26: + break; + case 26: + { return new Symbol(sym._SYMB_17); } + case -27: + break; + case 27: + { return new Symbol(sym._SYMB_22); } + case -28: + break; + case 28: + { return new Symbol(sym._SYMB_19); } + case -29: + break; + case 29: + { return new Symbol(sym._SYMB_21); } + case -30: + break; + case 30: + { return new Symbol(sym.QBool, yytext().intern()); } + case -31: + break; + case 31: + { return new Symbol(sym._SYMB_23); } + case -32: + break; + case 32: + { return new Symbol(sym._SYMB_20); } + case -33: + break; + case 33: + { return new Symbol(sym._SYMB_25); } + case -34: + break; + case 34: + { return new Symbol(sym._SYMB_28); } + case -35: + break; + case 35: + { return new Symbol(sym._SYMB_27); } + case -36: + break; + case 36: + { return new Symbol(sym._SYMB_26); } + case -37: + break; + case 37: + { pstring += yytext(); } + case -38: + break; + case 38: + { String foo = pstring; pstring = new String(); yybegin(YYINITIAL); return new Symbol(sym._STRING_, foo.intern()); } + case -39: + break; + case 39: + { yybegin(ESCAPED); } + case -40: + break; + case 40: + { pstring += yytext(); yybegin(STRING); } + case -41: + break; + case 41: + { pstring += "\t"; yybegin(STRING); } + case -42: + break; + case 42: + { pstring += "\""; yybegin(STRING); } + case -43: + break; + case 43: + { pstring += "\\"; yybegin(STRING); } + case -44: + break; + case 44: + { pstring += "\n"; yybegin(STRING); } + case -45: + break; + case 46: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -46: + break; + case 47: + { return new Symbol(sym.QInteger, yytext().intern()); } + case -47: + break; + case 48: + { return new Symbol(sym.QDouble, yytext().intern()); } + case -48: + break; + case 50: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -49: + break; + case 52: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -50: + break; + case 54: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -51: + break; + case 56: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -52: + break; + case 58: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -53: + break; + case 60: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -54: + break; + case 62: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -55: + break; + case 63: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -56: + break; + case 64: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -57: + break; + case 65: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -58: + break; + case 66: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -59: + break; + case 67: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -60: + break; + case 68: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -61: + break; + case 69: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -62: + break; + case 70: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -63: + break; + case 71: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -64: + break; + case 72: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -65: + break; + case 73: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -66: + break; + case 74: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -67: + break; + case 75: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -68: + break; + case 76: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -69: + break; + case 77: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -70: + break; + case 78: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -71: + break; + case 79: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -72: + break; + case 80: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -73: + break; + case 81: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -74: + break; + case 82: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -75: + break; + case 83: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -76: + break; + case 84: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -77: + break; + case 85: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -78: + break; + case 86: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -79: + break; + case 87: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -80: + break; + case 88: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -81: + break; + case 89: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -82: + break; + case 90: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -83: + break; + case 91: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -84: + break; + case 92: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -85: + break; + case 93: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -86: + break; + case 94: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -87: + break; + case 95: + { return new Symbol(sym.QIdent, yytext().intern()); } + case -88: + break; + default: + yy_error(YY_E_INTERNAL,false); + case -1: + } + yy_initial = true; + yy_state = yy_state_dtrans[yy_lexical_state]; + yy_next_state = YY_NO_STATE; + yy_last_accept_state = YY_NO_STATE; + yy_mark_start(); + yy_this_accept = yy_acpt[yy_state]; + if (YY_NOT_ACCEPT != yy_this_accept) { + yy_last_accept_state = yy_state; + yy_mark_end(); + } + } + } + } + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/parser.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/parser.java new file mode 100644 index 0000000..85a196b --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/parser.java @@ -0,0 +1,923 @@ + +//---------------------------------------------------- +// The following code was generated by CUP v0.11a beta 20060608 +// Sat Nov 16 17:39:43 CET 2013 +//---------------------------------------------------- + +package pl.edu.mimuw.cloudatlas.interpreter.query; + + +/** CUP v0.11a beta 20060608 generated parser. + * @version Sat Nov 16 17:39:43 CET 2013 + */ +public class parser extends java_cup.runtime.lr_parser { + + /** Default constructor. */ + public parser() {super();} + + /** Constructor which sets the default scanner. */ + public parser(java_cup.runtime.Scanner s) {super(s);} + + /** Constructor which sets the default scanner. */ + public parser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);} + + /** Production table. */ + protected static final short _production_table[][] = + unpackFromStrings(new String[] { + "\000\071\000\002\002\004\000\002\002\003\000\002\002" + + "\005\000\002\003\003\000\002\003\005\000\002\004\003" + + "\000\002\004\005\000\002\005\002\000\002\005\003\000" + + "\002\005\005\000\002\006\003\000\002\007\006\000\002" + + "\010\002\000\002\010\004\000\002\011\002\000\002\011" + + "\005\000\002\012\005\000\002\013\003\000\002\013\003" + + "\000\002\013\002\000\002\014\002\000\002\014\004\000" + + "\002\014\004\000\002\015\003\000\002\015\005\000\002" + + "\016\005\000\002\016\005\000\002\016\003\000\002\017" + + "\005\000\002\017\003\000\002\020\005\000\002\020\003" + + "\000\002\021\004\000\002\021\003\000\002\022\005\000" + + "\002\022\005\000\002\022\003\000\002\023\005\000\002" + + "\023\005\000\002\023\005\000\002\023\003\000\002\024" + + "\004\000\002\024\003\000\002\025\003\000\002\025\003" + + "\000\002\025\006\000\002\025\003\000\002\025\003\000" + + "\002\025\003\000\002\025\005\000\002\025\005\000\002" + + "\026\003\000\002\026\003\000\002\026\003\000\002\026" + + "\003\000\002\026\003\000\002\026\003" }); + + /** Access to production table. */ + public short[][] production_table() {return _production_table;} + + /** Parse-action table. */ + protected static final short[][] _action_table = + unpackFromStrings(new String[] { + "\000\124\000\004\037\006\001\002\000\004\002\126\001" + + "\002\000\006\002\000\004\124\001\002\000\022\007\024" + + "\013\023\032\030\041\012\042\026\043\025\044\015\045" + + "\016\001\002\000\004\002\ufff7\001\002\000\062\002\uffd7" + + "\004\uffd7\005\uffd7\006\uffd7\007\uffd7\010\uffd7\011\uffd7\012" + + "\uffd7\014\uffd7\015\uffd7\016\uffd7\017\uffd7\020\uffd7\021\uffd7" + + "\022\uffd7\023\uffd7\024\uffd7\025\uffd7\027\uffd7\033\uffd7\034" + + "\uffd7\035\uffd7\036\uffd7\040\uffd7\001\002\000\062\002\uffd9" + + "\004\uffd9\005\uffd9\006\uffd9\007\uffd9\010\uffd9\011\uffd9\012" + + "\uffd9\014\uffd9\015\uffd9\016\uffd9\017\uffd9\020\uffd9\021\uffd9" + + "\022\uffd9\023\uffd9\024\uffd9\025\uffd9\027\uffd9\033\uffd9\034" + + "\uffd9\035\uffd9\036\uffd9\040\uffd9\001\002\000\062\002\uffd3" + + "\004\uffd3\005\uffd3\006\uffd3\007\uffd3\010\uffd3\011\uffd3\012" + + "\uffd3\014\uffd3\015\uffd3\016\uffd3\017\uffd3\020\uffd3\021\uffd3" + + "\022\uffd3\023\uffd3\024\uffd3\025\uffd3\027\uffd3\033\uffd3\034" + + "\uffd3\035\uffd3\036\uffd3\040\uffd3\001\002\000\054\002\uffe6" + + "\004\uffe6\005\uffe6\006\110\007\107\014\uffe6\015\117\016" + + "\116\017\115\020\114\021\113\022\111\023\uffe6\024\uffe6" + + "\025\uffe6\027\uffe6\033\uffe6\034\uffe6\035\uffe6\036\106\040" + + "\uffe6\001\002\000\062\002\uffdd\004\uffdd\005\uffdd\006\uffdd" + + "\007\uffdd\010\100\011\102\012\101\014\uffdd\015\uffdd\016" + + "\uffdd\017\uffdd\020\uffdd\021\uffdd\022\uffdd\023\uffdd\024\uffdd" + + "\025\uffdd\027\uffdd\033\uffdd\034\uffdd\035\uffdd\036\uffdd\040" + + "\uffdd\001\002\000\062\002\uffd1\004\uffd1\005\uffd1\006\uffd1" + + "\007\uffd1\010\uffd1\011\uffd1\012\uffd1\014\uffd1\015\uffd1\016" + + "\uffd1\017\uffd1\020\uffd1\021\uffd1\022\uffd1\023\uffd1\024\uffd1" + + "\025\uffd1\027\uffd1\033\uffd1\034\uffd1\035\uffd1\036\uffd1\040" + + "\uffd1\001\002\000\062\002\uffd2\004\uffd2\005\uffd2\006\uffd2" + + "\007\uffd2\010\uffd2\011\uffd2\012\uffd2\014\uffd2\015\uffd2\016" + + "\uffd2\017\uffd2\020\uffd2\021\uffd2\022\uffd2\023\uffd2\024\uffd2" + + "\025\uffd2\027\uffd2\033\uffd2\034\uffd2\035\uffd2\036\uffd2\040" + + "\uffd2\001\002\000\014\002\ufff5\004\ufff5\014\ufff5\035\ufff5" + + "\040\056\001\002\000\022\002\uffea\004\uffea\005\uffea\014" + + "\uffea\024\054\034\042\035\uffea\040\uffea\001\002\000\032" + + "\002\uffe2\004\uffe2\005\uffe2\014\uffe2\023\uffe2\024\uffe2\025" + + "\uffe2\027\uffe2\033\uffe2\034\uffe2\035\uffe2\040\uffe2\001\002" + + "\000\032\002\uffe4\004\uffe4\005\uffe4\014\uffe4\023\044\024" + + "\uffe4\025\uffe4\027\uffe4\033\uffe4\034\uffe4\035\uffe4\040\uffe4" + + "\001\002\000\024\007\024\013\023\032\030\037\006\041" + + "\012\042\026\043\025\044\015\045\016\001\002\000\020" + + "\007\024\013\023\041\012\042\026\043\025\044\015\045" + + "\016\001\002\000\064\002\uffd5\004\uffd5\005\uffd5\006\uffd5" + + "\007\uffd5\010\uffd5\011\uffd5\012\uffd5\013\035\014\uffd5\015" + + "\uffd5\016\uffd5\017\uffd5\020\uffd5\021\uffd5\022\uffd5\023\uffd5" + + "\024\uffd5\025\uffd5\027\uffd5\033\uffd5\034\uffd5\035\uffd5\036" + + "\uffd5\040\uffd5\001\002\000\062\002\uffd6\004\uffd6\005\uffd6" + + "\006\uffd6\007\uffd6\010\uffd6\011\uffd6\012\uffd6\014\uffd6\015" + + "\uffd6\016\uffd6\017\uffd6\020\uffd6\021\uffd6\022\uffd6\023\uffd6" + + "\024\uffd6\025\uffd6\027\uffd6\033\uffd6\034\uffd6\035\uffd6\036" + + "\uffd6\040\uffd6\001\002\000\016\002\ufffc\004\ufffc\005\033" + + "\014\ufffc\035\ufffc\040\ufffc\001\002\000\022\007\024\013" + + "\023\032\030\041\012\042\026\043\025\044\015\045\016" + + "\001\002\000\032\002\uffe0\004\uffe0\005\uffe0\014\uffe0\023" + + "\uffe0\024\uffe0\025\uffe0\027\uffe0\033\uffe0\034\uffe0\035\uffe0" + + "\040\uffe0\001\002\000\032\002\uffe1\004\uffe1\005\uffe1\014" + + "\uffe1\023\uffe1\024\uffe1\025\uffe1\027\uffe1\033\uffe1\034\uffe1" + + "\035\uffe1\040\uffe1\001\002\000\022\007\024\013\023\032" + + "\030\041\012\042\026\043\025\044\015\045\016\001\002" + + "\000\014\002\ufffb\004\ufffb\014\ufffb\035\ufffb\040\ufffb\001" + + "\002\000\024\007\024\013\023\014\ufffa\032\030\041\012" + + "\042\026\043\025\044\015\045\016\001\002\000\010\005" + + "\041\014\ufff9\034\042\001\002\000\004\014\040\001\002" + + "\000\062\002\uffd4\004\uffd4\005\uffd4\006\uffd4\007\uffd4\010" + + "\uffd4\011\uffd4\012\uffd4\014\uffd4\015\uffd4\016\uffd4\017\uffd4" + + "\020\uffd4\021\uffd4\022\uffd4\023\uffd4\024\uffd4\025\uffd4\027" + + "\uffd4\033\uffd4\034\uffd4\035\uffd4\036\uffd4\040\uffd4\001\002" + + "\000\024\007\024\013\023\014\ufffa\032\030\041\012\042" + + "\026\043\025\044\015\045\016\001\002\000\022\007\024" + + "\013\023\032\030\041\012\042\026\043\025\044\015\045" + + "\016\001\002\000\032\002\uffe5\004\uffe5\005\uffe5\014\uffe5" + + "\023\044\024\uffe5\025\uffe5\027\uffe5\033\uffe5\034\uffe5\035" + + "\uffe5\040\uffe5\001\002\000\022\007\024\013\023\032\030" + + "\041\012\042\026\043\025\044\015\045\016\001\002\000" + + "\032\002\uffe3\004\uffe3\005\uffe3\014\uffe3\023\uffe3\024\uffe3" + + "\025\uffe3\027\uffe3\033\uffe3\034\uffe3\035\uffe3\040\uffe3\001" + + "\002\000\004\014\ufff8\001\002\000\062\002\uffd8\004\uffd8" + + "\005\uffd8\006\uffd8\007\uffd8\010\uffd8\011\uffd8\012\uffd8\014" + + "\uffd8\015\uffd8\016\uffd8\017\uffd8\020\uffd8\021\uffd8\022\uffd8" + + "\023\uffd8\024\uffd8\025\uffd8\027\uffd8\033\uffd8\034\uffd8\035" + + "\uffd8\036\uffd8\040\uffd8\001\002\000\006\014\053\034\042" + + "\001\002\000\004\014\052\001\002\000\062\002\uffcf\004" + + "\uffcf\005\uffcf\006\uffcf\007\uffcf\010\uffcf\011\uffcf\012\uffcf" + + "\014\uffcf\015\uffcf\016\uffcf\017\uffcf\020\uffcf\021\uffcf\022" + + "\uffcf\023\uffcf\024\uffcf\025\uffcf\027\uffcf\033\uffcf\034\uffcf" + + "\035\uffcf\036\uffcf\040\uffcf\001\002\000\062\002\uffd0\004" + + "\uffd0\005\uffd0\006\uffd0\007\uffd0\010\uffd0\011\uffd0\012\uffd0" + + "\014\uffd0\015\uffd0\016\uffd0\017\uffd0\020\uffd0\021\uffd0\022" + + "\uffd0\023\uffd0\024\uffd0\025\uffd0\027\uffd0\033\uffd0\034\uffd0" + + "\035\uffd0\036\uffd0\040\uffd0\001\002\000\004\043\055\001" + + "\002\000\016\002\uffe9\004\uffe9\005\uffe9\014\uffe9\035\uffe9" + + "\040\uffe9\001\002\000\022\007\024\013\023\032\030\041" + + "\012\042\026\043\025\044\015\045\016\001\002\000\012" + + "\002\ufff3\004\ufff3\014\ufff3\035\061\001\002\000\010\002" + + "\ufff6\004\ufff6\014\ufff6\001\002\000\004\026\062\001\002" + + "\000\022\007\024\013\023\032\030\041\012\042\026\043" + + "\025\044\015\045\016\001\002\000\012\002\ufffe\004\ufffe" + + "\005\075\014\ufffe\001\002\000\022\002\uffee\004\uffee\005" + + "\uffee\014\uffee\025\067\027\066\033\uffee\034\042\001\002" + + "\000\010\002\ufff2\004\ufff2\014\ufff2\001\002\000\014\002" + + "\uffef\004\uffef\005\uffef\014\uffef\033\uffef\001\002\000\014" + + "\002\ufff0\004\ufff0\005\ufff0\014\ufff0\033\ufff0\001\002\000" + + "\014\002\uffed\004\uffed\005\uffed\014\uffed\033\072\001\002" + + "\000\012\002\ufff1\004\ufff1\005\ufff1\014\ufff1\001\002\000" + + "\006\030\074\031\073\001\002\000\012\002\uffeb\004\uffeb" + + "\005\uffeb\014\uffeb\001\002\000\012\002\uffec\004\uffec\005" + + "\uffec\014\uffec\001\002\000\022\007\024\013\023\032\030" + + "\041\012\042\026\043\025\044\015\045\016\001\002\000" + + "\010\002\ufffd\004\ufffd\014\ufffd\001\002\000\014\002\ufff4" + + "\004\ufff4\014\ufff4\034\042\035\ufff4\001\002\000\020\007" + + "\024\013\023\041\012\042\026\043\025\044\015\045\016" + + "\001\002\000\020\007\024\013\023\041\012\042\026\043" + + "\025\044\015\045\016\001\002\000\020\007\024\013\023" + + "\041\012\042\026\043\025\044\015\045\016\001\002\000" + + "\062\002\uffdb\004\uffdb\005\uffdb\006\uffdb\007\uffdb\010\uffdb" + + "\011\uffdb\012\uffdb\014\uffdb\015\uffdb\016\uffdb\017\uffdb\020" + + "\uffdb\021\uffdb\022\uffdb\023\uffdb\024\uffdb\025\uffdb\027\uffdb" + + "\033\uffdb\034\uffdb\035\uffdb\036\uffdb\040\uffdb\001\002\000" + + "\062\002\uffda\004\uffda\005\uffda\006\uffda\007\uffda\010\uffda" + + "\011\uffda\012\uffda\014\uffda\015\uffda\016\uffda\017\uffda\020" + + "\uffda\021\uffda\022\uffda\023\uffda\024\uffda\025\uffda\027\uffda" + + "\033\uffda\034\uffda\035\uffda\036\uffda\040\uffda\001\002\000" + + "\062\002\uffdc\004\uffdc\005\uffdc\006\uffdc\007\uffdc\010\uffdc" + + "\011\uffdc\012\uffdc\014\uffdc\015\uffdc\016\uffdc\017\uffdc\020" + + "\uffdc\021\uffdc\022\uffdc\023\uffdc\024\uffdc\025\uffdc\027\uffdc" + + "\033\uffdc\034\uffdc\035\uffdc\036\uffdc\040\uffdc\001\002\000" + + "\004\041\123\001\002\000\020\007\024\013\023\041\012" + + "\042\026\043\025\044\015\045\016\001\002\000\020\007" + + "\024\013\023\041\012\042\026\043\025\044\015\045\016" + + "\001\002\000\020\007\uffc9\013\uffc9\041\uffc9\042\uffc9\043" + + "\uffc9\044\uffc9\045\uffc9\001\002\000\020\007\024\013\023" + + "\041\012\042\026\043\025\044\015\045\016\001\002\000" + + "\020\007\uffca\013\uffca\041\uffca\042\uffca\043\uffca\044\uffca" + + "\045\uffca\001\002\000\020\007\uffcb\013\uffcb\041\uffcb\042" + + "\uffcb\043\uffcb\044\uffcb\045\uffcb\001\002\000\020\007\uffcc" + + "\013\uffcc\041\uffcc\042\uffcc\043\uffcc\044\uffcc\045\uffcc\001" + + "\002\000\020\007\uffcd\013\uffcd\041\uffcd\042\uffcd\043\uffcd" + + "\044\uffcd\045\uffcd\001\002\000\020\007\uffce\013\uffce\041" + + "\uffce\042\uffce\043\uffce\044\uffce\045\uffce\001\002\000\036" + + "\002\uffe8\004\uffe8\005\uffe8\006\110\007\107\014\uffe8\023" + + "\uffe8\024\uffe8\025\uffe8\027\uffe8\033\uffe8\034\uffe8\035\uffe8" + + "\040\uffe8\001\002\000\062\002\uffdf\004\uffdf\005\uffdf\006" + + "\uffdf\007\uffdf\010\100\011\102\012\101\014\uffdf\015\uffdf" + + "\016\uffdf\017\uffdf\020\uffdf\021\uffdf\022\uffdf\023\uffdf\024" + + "\uffdf\025\uffdf\027\uffdf\033\uffdf\034\uffdf\035\uffdf\036\uffdf" + + "\040\uffdf\001\002\000\062\002\uffde\004\uffde\005\uffde\006" + + "\uffde\007\uffde\010\100\011\102\012\101\014\uffde\015\uffde" + + "\016\uffde\017\uffde\020\uffde\021\uffde\022\uffde\023\uffde\024" + + "\uffde\025\uffde\027\uffde\033\uffde\034\uffde\035\uffde\036\uffde" + + "\040\uffde\001\002\000\032\002\uffe7\004\uffe7\005\uffe7\014" + + "\uffe7\023\uffe7\024\uffe7\025\uffe7\027\uffe7\033\uffe7\034\uffe7" + + "\035\uffe7\040\uffe7\001\002\000\004\037\006\001\002\000" + + "\004\002\uffff\001\002\000\004\002\001\001\002" }); + + /** Access to parse-action table. */ + public short[][] action_table() {return _action_table;} + + /** <code>reduce_goto</code> table. */ + protected static final short[][] _reduce_table = + unpackFromStrings(new String[] { + "\000\124\000\010\002\006\006\003\007\004\001\001\000" + + "\002\001\001\000\002\001\001\000\026\004\016\015\026" + + "\016\030\017\017\020\021\021\020\022\012\023\013\024" + + "\010\025\007\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\004\026\111\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\004\010\056\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\024\007\050\016\030\017\047" + + "\020\021\021\020\022\012\023\013\024\010\025\007\001" + + "\001\000\006\024\046\025\007\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\016\016\030\021" + + "\031\022\012\023\013\024\010\025\007\001\001\000\002" + + "\001\001\000\002\001\001\000\026\004\033\015\026\016" + + "\030\017\017\020\021\021\020\022\012\023\013\024\010" + + "\025\007\001\001\000\002\001\001\000\024\005\036\016" + + "\030\017\035\020\021\021\020\022\012\023\013\024\010" + + "\025\007\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\024\005\045\016\030\017\035\020\021" + + "\021\020\022\012\023\013\024\010\025\007\001\001\000" + + "\020\016\030\020\042\021\020\022\012\023\013\024\010" + + "\025\007\001\001\000\002\001\001\000\016\016\030\021" + + "\044\022\012\023\013\024\010\025\007\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\022\016\030\017" + + "\076\020\021\021\020\022\012\023\013\024\010\025\007" + + "\001\001\000\004\011\057\001\001\000\002\001\001\000" + + "\002\001\001\000\026\003\064\012\062\016\030\017\063" + + "\020\021\021\020\022\012\023\013\024\010\025\007\001" + + "\001\000\002\001\001\000\004\013\067\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\004\014" + + "\070\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\026\003\075\012\062\016" + + "\030\017\063\020\021\021\020\022\012\023\013\024\010" + + "\025\007\001\001\000\002\001\001\000\002\001\001\000" + + "\006\024\104\025\007\001\001\000\006\024\103\025\007" + + "\001\001\000\006\024\102\025\007\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\010\023\121\024\010\025\007\001\001\000\010\023" + + "\120\024\010\025\007\001\001\000\002\001\001\000\012" + + "\022\117\023\013\024\010\025\007\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\006\002\124\007\004" + + "\001\001\000\002\001\001\000\002\001\001" }); + + /** Access to <code>reduce_goto</code> table. */ + public short[][] reduce_table() {return _reduce_table;} + + /** Instance of action encapsulation class. */ + protected CUP$parser$actions action_obj; + + /** Action encapsulation object initializer. */ + protected void init_actions() + { + action_obj = new CUP$parser$actions(this); + } + + /** Invoke a user supplied parse action. */ + public java_cup.runtime.Symbol do_action( + int act_num, + java_cup.runtime.lr_parser parser, + @SuppressWarnings("rawtypes") java.util.Stack stack, + int top) + throws java.lang.Exception + { + /* call code in generated class */ + return action_obj.CUP$parser$do_action(act_num, parser, stack, top); + } + + /** Indicates start state. */ + public int start_state() {return 0;} + /** Indicates start production. */ + public int start_production() {return 0;} + + /** <code>EOF</code> Symbol index. */ + public int EOF_sym() {return 0;} + + /** <code>error</code> Symbol index. */ + public int error_sym() {return 1;} + + + + public pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program pProgram() throws Exception + { + java_cup.runtime.Symbol res = parse(); + return (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program) res.value; + } + +public <B,A extends java.util.LinkedList<? super B>> A cons_(B x, A xs) { xs.addFirst(x); return xs; } + +public void syntax_error(java_cup.runtime.Symbol cur_token) +{ + report_error("Syntax Error, trying to recover and continue parse...", cur_token); +} + +public void unrecovered_syntax_error(java_cup.runtime.Symbol cur_token) throws java.lang.Exception +{ + throw new Exception("Unrecoverable Syntax Error"); +} + + +} + +/** Cup generated class to encapsulate user supplied action code.*/ +class CUP$parser$actions { + private final parser parser; + + /** Constructor */ + CUP$parser$actions(parser parser) { + this.parser = parser; + } + + /** Method with the actual generated action code. */ + public final java_cup.runtime.Symbol CUP$parser$do_action( + int CUP$parser$act_num, + java_cup.runtime.lr_parser CUP$parser$parser, + @SuppressWarnings("rawtypes") java.util.Stack CUP$parser$stack, + int CUP$parser$top) + throws java.lang.Exception + { + /* Symbol object for return from actions */ + java_cup.runtime.Symbol CUP$parser$result; + + /* select the action based on the action number */ + switch (CUP$parser$act_num) + { + /*. . . . . . . . . . . . . . . . . . . .*/ + case 56: // RelOp ::= _SYMB_14 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpGeC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("RelOp",20, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 55: // RelOp ::= _SYMB_13 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpLeC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("RelOp",20, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 54: // RelOp ::= _SYMB_12 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpLtC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("RelOp",20, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 53: // RelOp ::= _SYMB_11 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpNeC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("RelOp",20, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 52: // RelOp ::= _SYMB_10 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpEqC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("RelOp",20, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 51: // RelOp ::= _SYMB_9 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOpGtC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("RelOp",20, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 50: // BasicExpr3 ::= _SYMB_7 Statement _SYMB_8 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement p_2 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStmtC(p_2); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr3",19, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 49: // BasicExpr3 ::= _SYMB_7 CondExpr _SYMB_8 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_2 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ECondExprC(p_2); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr3",19, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 48: // BasicExpr3 ::= QDouble + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EDblC(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr3",19, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 47: // BasicExpr3 ::= QInteger + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIntC(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr3",19, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 46: // BasicExpr3 ::= _STRING_ + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EStrC(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr3",19, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 45: // BasicExpr3 ::= QIdent _SYMB_7 ListCondExpr _SYMB_8 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EFunC(p_1,p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr3",19, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 44: // BasicExpr3 ::= QIdent + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EIdentC(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr3",19, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 43: // BasicExpr3 ::= QBool + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.EBoolC(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr3",19, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 42: // BasicExpr2 ::= BasicExpr3 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = p_1; + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr2",18, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 41: // BasicExpr2 ::= _SYMB_3 BasicExpr2 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_2 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprNegC(p_2); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr2",18, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 40: // BasicExpr1 ::= BasicExpr2 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = p_1; + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr1",17, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 39: // BasicExpr1 ::= BasicExpr1 _SYMB_6 BasicExpr2 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprModC(p_1,p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr1",17, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 38: // BasicExpr1 ::= BasicExpr1 _SYMB_5 BasicExpr2 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprDivC(p_1,p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr1",17, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 37: // BasicExpr1 ::= BasicExpr1 _SYMB_4 BasicExpr2 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprMulC(p_1,p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr1",17, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 36: // BasicExpr ::= BasicExpr1 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = p_1; + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr",16, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 35: // BasicExpr ::= BasicExpr _SYMB_3 BasicExpr1 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprSubC(p_1,p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr",16, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 34: // BasicExpr ::= BasicExpr _SYMB_2 BasicExpr1 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExprAddC(p_1,p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BasicExpr",16, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 33: // CondExpr2 ::= BoolExpr + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprBoolExprC(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("CondExpr2",15, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 32: // CondExpr2 ::= _SYMB_22 CondExpr2 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_2 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprNotC(p_2); + CUP$parser$result = parser.getSymbolFactory().newSymbol("CondExpr2",15, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 31: // CondExpr1 ::= CondExpr2 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = p_1; + CUP$parser$result = parser.getSymbolFactory().newSymbol("CondExpr1",14, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 30: // CondExpr1 ::= CondExpr1 _SYMB_15 CondExpr2 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprAndC(p_1,p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("CondExpr1",14, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 29: // CondExpr ::= CondExpr1 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = p_1; + CUP$parser$result = parser.getSymbolFactory().newSymbol("CondExpr",13, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 28: // CondExpr ::= CondExpr _SYMB_24 CondExpr1 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExprOrC(p_1,p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("CondExpr",13, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 27: // BoolExpr ::= BasicExpr + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprBasicExprC(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BoolExpr",12, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 26: // BoolExpr ::= BasicExpr _SYMB_26 _STRING_ + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + String p_3 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprRegExpC(p_1,p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BoolExpr",12, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 25: // BoolExpr ::= BasicExpr RelOp BasicExpr + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp p_2 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.RelOp)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BasicExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.BoolExprCmpC(p_1,p_2,p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("BoolExpr",12, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 24: // SelItem ::= CondExpr _SYMB_16 QIdent + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + String p_3 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AliasedSelItemC(p_1,p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("SelItem",11, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 23: // SelItem ::= CondExpr + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItemC(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("SelItem",11, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 22: // Nulls ::= _SYMB_23 _SYMB_21 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NullsLastC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("Nulls",10, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 21: // Nulls ::= _SYMB_23 _SYMB_20 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NullFirstsC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("Nulls",10, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 20: // Nulls ::= + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoNullsC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("Nulls",10, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 19: // Order ::= + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoOrderC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("Order",9, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 18: // Order ::= _SYMB_19 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.DescOrderC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("Order",9, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 17: // Order ::= _SYMB_17 + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.AscOrderC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("Order",9, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 16: // OrderItem ::= CondExpr Order Nulls + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItem RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order p_2 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Order)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Nulls)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItemC(p_1,p_2,p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("OrderItem",8, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 15: // OrderBy ::= _SYMB_25 _SYMB_18 ListOrderItem + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderBy RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListOrderItem p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListOrderItem)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderByC(p_3); + CUP$parser$result = parser.getSymbolFactory().newSymbol("OrderBy",7, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 14: // OrderBy ::= + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderBy RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoOrderByC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("OrderBy",7, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 13: // Where ::= _SYMB_28 CondExpr + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Where RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_2 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.WhereC(p_2); + CUP$parser$result = parser.getSymbolFactory().newSymbol("Where",6, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 12: // Where ::= + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Where RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.NoWhereC(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("Where",6, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 11: // Statement ::= _SYMB_27 ListSelItem Where OrderBy + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListSelItem p_2 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListSelItem)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Where p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Where)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderBy p_4 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderBy)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.StatementC(p_2,p_3,p_4); + CUP$parser$result = parser.getSymbolFactory().newSymbol("Statement",5, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 10: // Program ::= ListStatement + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListStatement p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListStatement)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ProgramC(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("Program",4, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 9: // ListCondExpr ::= CondExpr _SYMB_1 ListCondExpr + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = p_3; p_3.addFirst(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("ListCondExpr",3, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 8: // ListCondExpr ::= CondExpr + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.CondExpr)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr(); RESULT.addLast(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("ListCondExpr",3, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 7: // ListCondExpr ::= + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr RESULT =null; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListCondExpr(); + CUP$parser$result = parser.getSymbolFactory().newSymbol("ListCondExpr",3, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 6: // ListSelItem ::= SelItem _SYMB_1 ListSelItem + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListSelItem RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListSelItem p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListSelItem)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = p_3; p_3.addFirst(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("ListSelItem",2, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 5: // ListSelItem ::= SelItem + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListSelItem RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.SelItem)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListSelItem(); RESULT.addLast(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("ListSelItem",2, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 4: // ListOrderItem ::= OrderItem _SYMB_1 ListOrderItem + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListOrderItem RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItem p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItem)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListOrderItem p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListOrderItem)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = p_3; p_3.addFirst(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("ListOrderItem",1, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 3: // ListOrderItem ::= OrderItem + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListOrderItem RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItem p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.OrderItem)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListOrderItem(); RESULT.addLast(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("ListOrderItem",1, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 2: // ListStatement ::= Statement _SYMB_0 ListStatement + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListStatement RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListStatement p_3 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListStatement)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = p_3; p_3.addFirst(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("ListStatement",0, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 1: // ListStatement ::= Statement + { + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListStatement RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement p_1 = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Statement)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value; + RESULT = new pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.ListStatement(); RESULT.addLast(p_1); + CUP$parser$result = parser.getSymbolFactory().newSymbol("ListStatement",0, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 0: // $START ::= Program EOF + { + Object RESULT =null; + pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program start_val = (pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = start_val; + CUP$parser$result = parser.getSymbolFactory().newSymbol("$START",0, RESULT); + } + /* ACCEPT */ + CUP$parser$parser.done_parsing(); + return CUP$parser$result; + + /* . . . . . .*/ + default: + throw new Exception( + "Invalid action number found in internal parse table"); + + } + } +} + diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/query.cup b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/query.cup new file mode 100644 index 0000000..6460d78 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/query.cup @@ -0,0 +1,169 @@ +// -*- Java -*- This Cup file was machine-generated by BNFC +package pl.edu.mimuw.mmws.cloudatlas.query; + +parser code {: + public pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Program pProgram() throws Exception + { + java_cup.runtime.Symbol res = parse(); + return (pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Program) res.value; + } + +public <B,A extends java.util.LinkedList<? super B>> A cons_(B x, A xs) { xs.addFirst(x); return xs; } + +public void syntax_error(java_cup.runtime.Symbol cur_token) +{ + report_error("Syntax Error, trying to recover and continue parse...", cur_token); +} + +public void unrecovered_syntax_error(java_cup.runtime.Symbol cur_token) throws java.lang.Exception +{ + throw new Exception("Unrecoverable Syntax Error"); +} + +:} + +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListStatement ListStatement; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListOrderItem ListOrderItem; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListSelItem ListSelItem; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListCondExpr ListCondExpr; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Program Program; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Statement Statement; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Where Where; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.OrderBy OrderBy; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.OrderItem OrderItem; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Order Order; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Nulls Nulls; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.SelItem SelItem; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BoolExpr BoolExpr; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExpr CondExpr; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExpr CondExpr1; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExpr CondExpr2; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExpr BasicExpr; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExpr BasicExpr1; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExpr BasicExpr2; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExpr BasicExpr3; +nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOp RelOp; + +terminal _SYMB_0; // ; +terminal _SYMB_1; // , +terminal _SYMB_2; // + +terminal _SYMB_3; // - +terminal _SYMB_4; // * +terminal _SYMB_5; // / +terminal _SYMB_6; // % +terminal _SYMB_7; // ( +terminal _SYMB_8; // ) +terminal _SYMB_9; // > +terminal _SYMB_10; // = +terminal _SYMB_11; // <> +terminal _SYMB_12; // < +terminal _SYMB_13; // <= +terminal _SYMB_14; // >= +terminal _SYMB_15; // AND +terminal _SYMB_16; // AS +terminal _SYMB_17; // ASC +terminal _SYMB_18; // BY +terminal _SYMB_19; // DESC +terminal _SYMB_20; // FIRST +terminal _SYMB_21; // LAST +terminal _SYMB_22; // NOT +terminal _SYMB_23; // NULLS +terminal _SYMB_24; // OR +terminal _SYMB_25; // ORDER +terminal _SYMB_26; // REGEXP +terminal _SYMB_27; // SELECT +terminal _SYMB_28; // WHERE + +terminal String _STRING_; + + + + + +terminal String QBool; +terminal String QIdent; +terminal String QDouble; +terminal String QInteger; + + +start with Program; + + +ListStatement ::= Statement:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListStatement(); RESULT.addLast(p_1); :} + | Statement:p_1 _SYMB_0 ListStatement:p_3 {: RESULT = p_3; p_3.addFirst(p_1); :} +; +ListOrderItem ::= OrderItem:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListOrderItem(); RESULT.addLast(p_1); :} + | OrderItem:p_1 _SYMB_1 ListOrderItem:p_3 {: RESULT = p_3; p_3.addFirst(p_1); :} +; +ListSelItem ::= SelItem:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListSelItem(); RESULT.addLast(p_1); :} + | SelItem:p_1 _SYMB_1 ListSelItem:p_3 {: RESULT = p_3; p_3.addFirst(p_1); :} +; +ListCondExpr ::= /* empty */ {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListCondExpr(); :} + | CondExpr:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListCondExpr(); RESULT.addLast(p_1); :} + | CondExpr:p_1 _SYMB_1 ListCondExpr:p_3 {: RESULT = p_3; p_3.addFirst(p_1); :} +; +Program ::= ListStatement:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ProgramC(p_1); :} +; +Statement ::= _SYMB_27 ListSelItem:p_2 Where:p_3 OrderBy:p_4 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.StatementC(p_2,p_3,p_4); :} +; +Where ::= /* empty */ {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.NoWhereC(); :} + | _SYMB_28 CondExpr:p_2 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.WhereC(p_2); :} +; +OrderBy ::= /* empty */ {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.NoOrderByC(); :} + | _SYMB_25 _SYMB_18 ListOrderItem:p_3 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.OrderByC(p_3); :} +; +OrderItem ::= CondExpr:p_1 Order:p_2 Nulls:p_3 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.OrderItemC(p_1,p_2,p_3); :} +; +Order ::= _SYMB_17 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.AscOrderC(); :} + | _SYMB_19 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.DescOrderC(); :} + | /* empty */ {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.NoOrderC(); :} +; +Nulls ::= /* empty */ {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.NoNullsC(); :} + | _SYMB_23 _SYMB_20 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.NullFirstsC(); :} + | _SYMB_23 _SYMB_21 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.NullsLastC(); :} +; +SelItem ::= CondExpr:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.SelItemC(p_1); :} + | CondExpr:p_1 _SYMB_16 QIdent:p_3 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.AliasedSelItemC(p_1,p_3); :} +; +BoolExpr ::= BasicExpr:p_1 RelOp:p_2 BasicExpr:p_3 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BoolExprCmpC(p_1,p_2,p_3); :} + | BasicExpr:p_1 _SYMB_26 _STRING_:p_3 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BoolExprRegExpC(p_1,p_3); :} + | BasicExpr:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BoolExprBasicExprC(p_1); :} +; +CondExpr ::= CondExpr:p_1 _SYMB_24 CondExpr1:p_3 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExprOrC(p_1,p_3); :} + | CondExpr1:p_1 {: RESULT = p_1; :} +; +CondExpr1 ::= CondExpr1:p_1 _SYMB_15 CondExpr2:p_3 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExprAndC(p_1,p_3); :} + | CondExpr2:p_1 {: RESULT = p_1; :} +; +CondExpr2 ::= _SYMB_22 CondExpr2:p_2 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExprNotC(p_2); :} + | BoolExpr:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExprBoolExprC(p_1); :} +; +BasicExpr ::= BasicExpr:p_1 _SYMB_2 BasicExpr1:p_3 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExprAddC(p_1,p_3); :} + | BasicExpr:p_1 _SYMB_3 BasicExpr1:p_3 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExprSubC(p_1,p_3); :} + | BasicExpr1:p_1 {: RESULT = p_1; :} +; +BasicExpr1 ::= BasicExpr1:p_1 _SYMB_4 BasicExpr2:p_3 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExprMulC(p_1,p_3); :} + | BasicExpr1:p_1 _SYMB_5 BasicExpr2:p_3 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExprDivC(p_1,p_3); :} + | BasicExpr1:p_1 _SYMB_6 BasicExpr2:p_3 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExprModC(p_1,p_3); :} + | BasicExpr2:p_1 {: RESULT = p_1; :} +; +BasicExpr2 ::= _SYMB_3 BasicExpr2:p_2 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExprNegC(p_2); :} + | BasicExpr3:p_1 {: RESULT = p_1; :} +; +BasicExpr3 ::= QBool:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EBoolC(p_1); :} + | QIdent:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EIdentC(p_1); :} + | QIdent:p_1 _SYMB_7 ListCondExpr:p_3 _SYMB_8 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EFunC(p_1,p_3); :} + | _STRING_:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EStrC(p_1); :} + | QInteger:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EIntC(p_1); :} + | QDouble:p_1 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EDblC(p_1); :} + | _SYMB_7 CondExpr:p_2 _SYMB_8 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ECondExprC(p_2); :} + | _SYMB_7 Statement:p_2 _SYMB_8 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EStmtC(p_2); :} +; +RelOp ::= _SYMB_9 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOpGtC(); :} + | _SYMB_10 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOpEqC(); :} + | _SYMB_11 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOpNeC(); :} + | _SYMB_12 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOpLtC(); :} + | _SYMB_13 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOpLeC(); :} + | _SYMB_14 {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOpGeC(); :} +; + diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/sym.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/sym.java new file mode 100644 index 0000000..34b6cc7 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/sym.java @@ -0,0 +1,49 @@ + +//---------------------------------------------------- +// The following code was generated by CUP v0.11a beta 20060608 +// Sat Nov 16 17:39:43 CET 2013 +//---------------------------------------------------- + +package pl.edu.mimuw.cloudatlas.interpreter.query; + +/** CUP generated class containing symbol constants. */ +public class sym { + /* terminals */ + public static final int _SYMB_18 = 20; + public static final int _SYMB_17 = 19; + public static final int _SYMB_16 = 18; + public static final int _SYMB_15 = 17; + public static final int _SYMB_14 = 16; + public static final int _SYMB_13 = 15; + public static final int QIdent = 33; + public static final int _SYMB_12 = 14; + public static final int _SYMB_11 = 13; + public static final int _SYMB_9 = 11; + public static final int _SYMB_8 = 10; + public static final int _SYMB_10 = 12; + public static final int _SYMB_7 = 9; + public static final int _SYMB_6 = 8; + public static final int _SYMB_5 = 7; + public static final int _SYMB_4 = 6; + public static final int _SYMB_3 = 5; + public static final int _SYMB_2 = 4; + public static final int _SYMB_1 = 3; + public static final int _SYMB_0 = 2; + public static final int QDouble = 34; + public static final int _STRING_ = 31; + public static final int EOF = 0; + public static final int error = 1; + public static final int _SYMB_28 = 30; + public static final int _SYMB_27 = 29; + public static final int _SYMB_26 = 28; + public static final int _SYMB_25 = 27; + public static final int QBool = 32; + public static final int _SYMB_24 = 26; + public static final int _SYMB_23 = 25; + public static final int _SYMB_22 = 24; + public static final int _SYMB_21 = 23; + public static final int _SYMB_20 = 22; + public static final int QInteger = 35; + public static final int _SYMB_19 = 21; +} + |