From fcf1729a4dbcda81708f263a9e078d802825a1cf Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 12 Oct 2020 11:55:23 +0200 Subject: [PATCH 001/206] added inferredSequenceType property and access methods to Expression class --- src/main/java/org/rumbledb/expressions/Expression.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/rumbledb/expressions/Expression.java b/src/main/java/org/rumbledb/expressions/Expression.java index f51e794c6b..bedef2575a 100644 --- a/src/main/java/org/rumbledb/expressions/Expression.java +++ b/src/main/java/org/rumbledb/expressions/Expression.java @@ -22,6 +22,7 @@ import org.rumbledb.context.StaticContext; import org.rumbledb.exceptions.ExceptionMetadata; +import org.rumbledb.types.SequenceType; /** * An expression is the first-class citizen in JSONiq syntax. Any expression @@ -37,6 +38,8 @@ public abstract class Expression extends Node { protected StaticContext staticContext; + protected SequenceType inferredSequenceType; + protected Expression(ExceptionMetadata metadata) { super(metadata); } @@ -48,4 +51,8 @@ public StaticContext getStaticContext() { public void setStaticContext(StaticContext staticContext) { this.staticContext = staticContext; } + + public SequenceType getInferredSequenceType() { return this.inferredSequenceType; } + + public void setInferredSequenceType(SequenceType inferredSequenceType) { this.inferredSequenceType = inferredSequenceType; } } From b3350009e9479b787b18d502bf876b11b51c8623 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 12 Oct 2020 17:09:45 +0200 Subject: [PATCH 002/206] Set up InferTypeVisitor and used for basic numeric and string primitives --- .../rumbledb/compiler/InferTypeVisitor.java | 61 +++++++++++++++++++ .../org/rumbledb/compiler/VisitorHelpers.java | 6 ++ 2 files changed, 67 insertions(+) create mode 100644 src/main/java/org/rumbledb/compiler/InferTypeVisitor.java diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java new file mode 100644 index 0000000000..9c001e82c1 --- /dev/null +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -0,0 +1,61 @@ +package org.rumbledb.compiler; + +import org.rumbledb.config.RumbleRuntimeConfiguration; +import org.rumbledb.expressions.AbstractNodeVisitor; +import org.rumbledb.expressions.primary.DecimalLiteralExpression; +import org.rumbledb.expressions.primary.DoubleLiteralExpression; +import org.rumbledb.expressions.primary.IntegerLiteralExpression; +import org.rumbledb.expressions.primary.StringLiteralExpression; +import org.rumbledb.types.ItemType; +import org.rumbledb.types.SequenceType; + +import java.util.ArrayList; + +/** + * This visitor infers a static SequenceType for each expression in the query + */ +public class InferTypeVisitor extends AbstractNodeVisitor { + + private RumbleRuntimeConfiguration rumbleRuntimeConfiguration; + + /** + * Builds a new visitor. + * + * @param rumbleRuntimeConfiguration the configuration. + */ + InferTypeVisitor(RumbleRuntimeConfiguration rumbleRuntimeConfiguration) { + this.rumbleRuntimeConfiguration = rumbleRuntimeConfiguration; + } + + // region primary + + @Override + public Void visitString(StringLiteralExpression expression, Void argument){ + System.out.println("visiting String literal"); + expression.setInferredSequenceType(new SequenceType(ItemType.stringItem)); + return argument; + } + + @Override + public Void visitInteger(IntegerLiteralExpression expression, Void argument) { + System.out.println("visiting Int literal"); + expression.setInferredSequenceType(new SequenceType(ItemType.integerItem)); + return argument; + } + + @Override + public Void visitDouble(DoubleLiteralExpression expression, Void argument) { + System.out.println("visiting Double literal"); + expression.setInferredSequenceType(new SequenceType(ItemType.doubleItem)); + return argument; + } + + @Override + public Void visitDecimal(DecimalLiteralExpression expression, Void argument) { + System.out.println("visiting Decimal literal"); + expression.setInferredSequenceType(new SequenceType(ItemType.decimalItem)); + return argument; + } + + // endregion +} diff --git a/src/main/java/org/rumbledb/compiler/VisitorHelpers.java b/src/main/java/org/rumbledb/compiler/VisitorHelpers.java index 047ce867bd..00d9e5c91a 100644 --- a/src/main/java/org/rumbledb/compiler/VisitorHelpers.java +++ b/src/main/java/org/rumbledb/compiler/VisitorHelpers.java @@ -50,6 +50,11 @@ private static void pruneModules(Node node, RumbleRuntimeConfiguration conf) { new ModulePruningVisitor(conf).visit(node, null); } + private static void inferTypes(Node node, RumbleRuntimeConfiguration conf) { + System.out.println("* Starting type inference *"); + new InferTypeVisitor(conf).visit(node, null); + } + private static void printTree(Module node, RumbleRuntimeConfiguration conf) { System.out.println("***************"); System.out.println("Expression tree"); @@ -104,6 +109,7 @@ public static MainModule parseMainModule(CharStream stream, URI uri, RumbleRunti pruneModules(mainModule, configuration); resolveDependencies(mainModule, configuration); populateStaticContext(mainModule, configuration); + inferTypes(mainModule, configuration); return mainModule; } catch (ParseCancellationException ex) { ParsingException e = new ParsingException( From c1044140ccff93dd7fdf30ce5c399f48148bc68a Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 12 Oct 2020 19:51:42 +0200 Subject: [PATCH 003/206] added findCommonSuperType method on ItemType, added CommaExpression inference --- .../rumbledb/compiler/InferTypeVisitor.java | 37 +++++++++++++++++++ .../UnexpectedStaticTypeException.java | 11 ++++++ .../java/org/rumbledb/types/ItemType.java | 18 ++++++++- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 9c001e82c1..d9f1ac5029 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1,7 +1,10 @@ package org.rumbledb.compiler; import org.rumbledb.config.RumbleRuntimeConfiguration; +import org.rumbledb.exceptions.UnexpectedStaticTypeException; import org.rumbledb.expressions.AbstractNodeVisitor; +import org.rumbledb.expressions.CommaExpression; +import org.rumbledb.expressions.Expression; import org.rumbledb.expressions.primary.DecimalLiteralExpression; import org.rumbledb.expressions.primary.DoubleLiteralExpression; import org.rumbledb.expressions.primary.IntegerLiteralExpression; @@ -27,6 +30,40 @@ public class InferTypeVisitor extends AbstractNodeVisitor { this.rumbleRuntimeConfiguration = rumbleRuntimeConfiguration; } + @Override + public Void visitCommaExpression(CommaExpression expression, Void argument) { + visitDescendants(expression, argument); + + SequenceType inferredType = SequenceType.EMPTY_SEQUENCE; + + for(Expression childExpression : expression.getExpressions()){ + SequenceType childExpressionInferredType = childExpression.getInferredSequenceType(); + + // if a child expression has no inferred type throw an error + if(childExpressionInferredType == null){ + throw new UnexpectedStaticTypeException("A child expression of a CommaExpression was null"); + } + + // if the child expression is an EMPTY_SEQUENCE it does not affect the comma expression type + if(!childExpressionInferredType.isEmptySequence()){ + if(inferredType.isEmptySequence()){ + inferredType = childExpressionInferredType; + } else{ + ItemType resultingItemType = inferredType.getItemType().findCommonSuperType(childExpressionInferredType.getItemType()); + SequenceType.Arity resultingArity = + ( (inferredType.getArity() == SequenceType.Arity.OneOrZero || inferredType.getArity() == SequenceType.Arity.ZeroOrMore) && + (childExpressionInferredType.getArity() == SequenceType.Arity.OneOrZero || childExpressionInferredType.getArity() == SequenceType.Arity.ZeroOrMore)) ? + SequenceType.Arity.ZeroOrMore : SequenceType.Arity.OneOrMore; + inferredType = new SequenceType(resultingItemType, resultingArity); + } + } + } + + System.out.println("visited comma expression with inferred type: " + inferredType); + expression.setInferredSequenceType(inferredType); + return argument; + } + // region primary @Override diff --git a/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java b/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java new file mode 100644 index 0000000000..01ac70b7df --- /dev/null +++ b/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java @@ -0,0 +1,11 @@ +package org.rumbledb.exceptions; + +public class UnexpectedStaticTypeException extends RumbleException { + + private static final long serialVersionUID = 1L; + + public UnexpectedStaticTypeException(String message) { + // TODO: investigates errorCode and Metadata + super(message); + } +} diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 00bb15e997..9c887ad1db 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -136,7 +136,7 @@ public boolean equals(Object other) { } - boolean isSubtypeOf(ItemType superType) { + public boolean isSubtypeOf(ItemType superType) { if (superType.equals(item)) { return true; } @@ -158,6 +158,22 @@ boolean isSubtypeOf(ItemType superType) { return false; } + + public ItemType findCommonSuperType(ItemType other){ + // TODO: check relation between Int and Double (numeric in general) + // TODO: first check is necessary due to inconsistency in ItemType subtype check + if(other.equals(this) || other.isSubtypeOf(this)){ + return this; + } else if(this.isSubtypeOf(other)){ + return other; + } else if(this.isSubtypeOf(ItemType.atomicItem) && other.isSubtypeOf(ItemType.atomicItem)){ + return ItemType.atomicItem; + } else if(this.isSubtypeOf(ItemType.JSONItem) && other.isSubtypeOf(ItemType.JSONItem)){ + return ItemType.JSONItem; + } else { + return ItemType.item; + } + } @Override public String toString() { From f9e61dc08cca7074943005b575a95054bf066265 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 12 Oct 2020 23:24:49 +0200 Subject: [PATCH 004/206] added boolean, null, variableReference, array and object constructors --- .../rumbledb/compiler/InferTypeVisitor.java | 60 +++++++++++++++++-- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index d9f1ac5029..6631352406 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -5,10 +5,7 @@ import org.rumbledb.expressions.AbstractNodeVisitor; import org.rumbledb.expressions.CommaExpression; import org.rumbledb.expressions.Expression; -import org.rumbledb.expressions.primary.DecimalLiteralExpression; -import org.rumbledb.expressions.primary.DoubleLiteralExpression; -import org.rumbledb.expressions.primary.IntegerLiteralExpression; -import org.rumbledb.expressions.primary.StringLiteralExpression; +import org.rumbledb.expressions.primary.*; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -41,7 +38,7 @@ public Void visitCommaExpression(CommaExpression expression, Void argument) { // if a child expression has no inferred type throw an error if(childExpressionInferredType == null){ - throw new UnexpectedStaticTypeException("A child expression of a CommaExpression was null"); + throw new UnexpectedStaticTypeException("A child expression of a CommaExpression has no inferred type"); } // if the child expression is an EMPTY_SEQUENCE it does not affect the comma expression type @@ -94,5 +91,58 @@ public Void visitDecimal(DecimalLiteralExpression expression, Void argument) { return argument; } + @Override + public Void visitNull(NullLiteralExpression expression, Void argument) { + System.out.println("visiting Null literal"); + expression.setInferredSequenceType(new SequenceType(ItemType.nullItem)); + return argument; + } + + @Override + public Void visitBoolean(BooleanLiteralExpression expression, Void argument) { + System.out.println("visiting Boolean literal"); + expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + return argument; + } + + @Override + public Void visitVariableReference(VariableReferenceExpression expression, Void argument) { + SequenceType variableType = expression.getType(); + if(variableType == null){ + System.out.println("variable reference type was null so"); + variableType = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; + } + System.out.println("visiting variable reference with type: " + variableType); + expression.setInferredSequenceType(variableType); + return argument; + } + + @Override + public Void visitArrayConstructor(ArrayConstructorExpression expression, Void argument) { + System.out.println("visiting Array constructor literal"); + visitDescendants(expression, argument); + expression.setInferredSequenceType(new SequenceType(ItemType.arrayItem)); + return argument; + } + + @Override + public Void visitObjectConstructor(ObjectConstructorExpression expression, Void argument) { + System.out.println("visiting Object constructor literal"); + visitDescendants(expression, argument); + // TODO: what about object merged constructor with childExpression + for(Expression keyExpression : expression.getKeys()){ + SequenceType keySequenceType = keyExpression.getInferredSequenceType(); + if(keySequenceType == null){ + throw new UnexpectedStaticTypeException("One of the key in the object constructor has no inferred type"); + } + ItemType keyType = keySequenceType.getItemType(); + if(!keyType.equals(ItemType.stringItem) && !keyType.equals(ItemType.atomicItem) && !keyType.equals(ItemType.item)){ + throw new UnexpectedStaticTypeException("The inferred static types for the keys of an Object must be String or one of its supertypes (i.e. atomicItem or item)"); + } + } + expression.setInferredSequenceType(new SequenceType(ItemType.objectItem)); + return argument; + } + // endregion } From c1f4233c85474e000370f999f4126efdf7e393cc Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 13 Oct 2020 17:28:32 +0200 Subject: [PATCH 005/206] in ItemType partially corrected isSubtypeOf, added isStaticallyCastableAs. Used this functions to implement typing expressions visitor in InferTypeVisitor (added castableAs, castAs, instanceOf, treatAs expressions visitor) --- .../rumbledb/compiler/InferTypeVisitor.java | 72 ++++++++++++++++++ .../java/org/rumbledb/types/ItemType.java | 75 ++++++++++++++++--- .../java/org/rumbledb/types/SequenceType.java | 1 + 3 files changed, 137 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 6631352406..b70450fe4f 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -6,6 +6,10 @@ import org.rumbledb.expressions.CommaExpression; import org.rumbledb.expressions.Expression; import org.rumbledb.expressions.primary.*; +import org.rumbledb.expressions.typing.CastExpression; +import org.rumbledb.expressions.typing.CastableExpression; +import org.rumbledb.expressions.typing.InstanceOfExpression; +import org.rumbledb.expressions.typing.TreatExpression; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -145,4 +149,72 @@ public Void visitObjectConstructor(ObjectConstructorExpression expression, Void } // endregion + + // region typing + + @Override + public Void visitCastableExpression(CastableExpression expression, Void argument) { + System.out.println("visiting Castable expression"); + visitDescendants(expression, argument); + expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + return argument; + } + + @Override + public Void visitCastExpression(CastExpression expression, Void argument) { + System.out.println("visiting Cast expression"); + visitDescendants(expression, argument); + + // check at static time for casting errors (note cast only allows for normal or ? arity) + SequenceType expressionSequenceType = expression.getMainExpression().getInferredSequenceType(); + SequenceType castedSequenceType = expression.getSequenceType(); + + // Arity basic check + if(expressionSequenceType.isEmptySequence() && castedSequenceType.getArity() == SequenceType.Arity.One){ + throw new UnexpectedStaticTypeException("Empty sequence cannot be cast to type with quantifier '1'"); + } + // ItemType static castability check + if(!expressionSequenceType.getItemType().staticallyCastableAs(castedSequenceType.getItemType())){ + throw new UnexpectedStaticTypeException("It is not possible to cast a " + + expressionSequenceType.getItemType() + " as " + castedSequenceType.getItemType()); + } + + expression.setInferredSequenceType(castedSequenceType); + return argument; + } + + @Override + public Void visitInstanceOfExpression(InstanceOfExpression expression, Void argument) { + System.out.println("visiting InstanceOf expression"); + visitDescendants(expression, argument); + expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + return argument; + } + + @Override + public Void visitTreatExpression(TreatExpression expression, Void argument) { + System.out.println("visiting Treat expression"); + visitDescendants(expression, argument); + + // check at static time for treat errors + SequenceType expressionSequenceType = expression.getMainExpression().getInferredSequenceType(); + SequenceType treatedSequenceType = expression.getSequenceType(); + + // Empty sequence check (potentially any other arity could fullfill any other arity) + if(expressionSequenceType.isEmptySequence() && + (treatedSequenceType.getArity() == SequenceType.Arity.One || treatedSequenceType.getArity() == SequenceType.Arity.OneOrMore)){ + throw new UnexpectedStaticTypeException("Empty sequence cannot be treated as type with quantifier '1' or '+'"); + } + // ItemType static treatability check (if the types' spaces are mutually exclusive, one cannot be treated like the other for sure) + if(!expressionSequenceType.getItemType().isSubtypeOf(treatedSequenceType.getItemType()) && + !treatedSequenceType.getItemType().isSubtypeOf(expressionSequenceType.getItemType())){ + throw new UnexpectedStaticTypeException("It is not possible to treat a " + + expressionSequenceType.getItemType() + " as " + treatedSequenceType.getItemType()); + } + + expression.setInferredSequenceType(treatedSequenceType); + return argument; + } + + // endregion } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 9c887ad1db..d96c2e3818 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -136,33 +136,32 @@ public boolean equals(Object other) { } + // Returns true if [this] is a subtype of [superType], any type is considered a subtype of itself public boolean isSubtypeOf(ItemType superType) { + // TODO: what about Dates/Durations, base64, hex and anyURI if (superType.equals(item)) { return true; - } - if (superType.equals(JSONItem)) { + } else if (superType.equals(JSONItem)) { return this.equals(objectItem) || this.equals(arrayItem) - || this.equals(JSONItem) - || this.equals(nullItem); - } - - if (superType.equals(atomicItem)) { + || this.equals(JSONItem); + } else if (superType.equals(atomicItem)) { return this.equals(stringItem) || this.equals(integerItem) || this.equals(decimalItem) || this.equals(doubleItem) || this.equals(booleanItem) - || this.equals(anyURIItem); + || this.equals(nullItem) + || this.equals(anyURIItem) + || this.equals(atomicItem); } - - return false; + return this.equals(superType); } public ItemType findCommonSuperType(ItemType other){ // TODO: check relation between Int and Double (numeric in general) // TODO: first check is necessary due to inconsistency in ItemType subtype check - if(other.equals(this) || other.isSubtypeOf(this)){ + if(other.isSubtypeOf(this)){ return this; } else if(this.isSubtypeOf(other)){ return other; @@ -175,6 +174,60 @@ public ItemType findCommonSuperType(ItemType other){ } } + public boolean staticallyCastableAs(ItemType other){ + // TODO: is null atomic or JSONitem? + // TODO: are jsonitems not castable to or form (excluding null) what about item + // TODO: no need for null special check if above applies + // TODO: can we cast to item (depends on inner functioning of cast as) + // JSON items cannot be cast from and to + if(this.isSubtypeOf(JSONItem) || other.isSubtypeOf(JSONItem)) + return false; + // anything can be casted to itself + if(this.equals(other)) + return true; + // anything can be casted from and to a string (or from one of its supertype) + if(this.equals(stringItem) || this.equals(item) || this.equals(atomicItem) || other.equals(stringItem)) + return true; + // boolean and numeric can be cast between themselves + if(this.equals(booleanItem) || this.equals(integerItem) || this.equals(doubleItem) || this.equals(decimalItem)){ + if(other.equals(integerItem) || + other.equals(doubleItem) || + other.equals(decimalItem) || + other.equals(stringItem) || + other.equals(booleanItem) + ) return true; + else return false; + } + // base64 and hex can be cast between themselves + if(this.equals(base64BinaryItem) || this.equals(hexBinaryItem)){ + if(other.equals(base64BinaryItem) || + other.equals(hexBinaryItem) || + other.equals(stringItem) + ) return true; + else return false; + } + // durations can be cast between themselves + if(this.equals(durationItem) || this.equals(yearMonthDurationItem) || this.equals(dayTimeDurationItem)){ + if(other.equals(durationItem) || + other.equals(yearMonthDurationItem) || + other.equals(dayTimeDurationItem) + ) return true; + else return false; + } + // DateTime can be cast also to Date or Time + if(this.equals(dateTimeItem)){ + if(other.equals(dateItem) || other.equals(timeItem)) return true; + else return false; + } + // Date can be cast also to DateTime + if(this.equals(dateItem)){ + if(other.equals(dateTimeItem)) return true; + else return false; + } + // Otherwise this cannot be casted to other + return false; + } + @Override public String toString() { return this.name; diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index eb82a5d51b..0ee70e3dc6 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -76,6 +76,7 @@ public Arity getArity() { } public boolean isSubtypeOf(SequenceType superType) { + // TODO: arity check because of possible error if (this.isEmptySequence) { return superType.arity == Arity.OneOrZero || superType.arity == Arity.ZeroOrMore; } From 486948d7e0b84b10d3e91f797aabd39ed8a0f6da Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 14 Oct 2020 15:54:59 +0200 Subject: [PATCH 006/206] added visitAdditiveExpr to type inference, added int index to ItemType and static tables to do static type inference --- .../rumbledb/compiler/InferTypeVisitor.java | 58 ++++++++++ .../java/org/rumbledb/types/ItemType.java | 109 ++++++++++++++---- 2 files changed, 145 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index b70450fe4f..6f7dbd4ba8 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -5,6 +5,8 @@ import org.rumbledb.expressions.AbstractNodeVisitor; import org.rumbledb.expressions.CommaExpression; import org.rumbledb.expressions.Expression; +import org.rumbledb.expressions.Node; +import org.rumbledb.expressions.arithmetic.AdditiveExpression; import org.rumbledb.expressions.primary.*; import org.rumbledb.expressions.typing.CastExpression; import org.rumbledb.expressions.typing.CastableExpression; @@ -14,6 +16,7 @@ import org.rumbledb.types.SequenceType; import java.util.ArrayList; +import java.util.List; /** * This visitor infers a static SequenceType for each expression in the query @@ -216,5 +219,60 @@ public Void visitTreatExpression(TreatExpression expression, Void argument) { return argument; } + // endregion + + // region arithmetic + + @Override + public Void visitAdditiveExpr(AdditiveExpression expression, Void argument) { + visitDescendants(expression, argument); + + // TODO: consider direct access with no casting + List childrenExpressions = expression.getChildren(); + SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); + SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); + + // if any of the child expression has null inferred type throw error + if(leftInferredType == null || rightInferredType == null){ + throw new UnexpectedStaticTypeException("A child expression of a AdditiveExpression has no inferred type"); + } + + // if any of the children is the empty sequence just infer the empty sequence + // TODO: check if returning () even when + is not supported with the other type is the intended behaviour + if(leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()){ + expression.setInferredSequenceType(SequenceType.EMPTY_SEQUENCE); + System.out.println("visiting Additive expression, set type: " + expression.getInferredSequenceType()); + return argument; + } + + ItemType inferredType; + SequenceType.Arity inferredArity; + + // if any of the children allows for the empty sequence the resulting arity is '?' + if(leftInferredType.getArity() == SequenceType.Arity.OneOrZero || + leftInferredType.getArity() == SequenceType.Arity.ZeroOrMore || + rightInferredType.getArity() == SequenceType.Arity.OneOrZero || + rightInferredType.getArity() == SequenceType.Arity.ZeroOrMore + ) inferredArity = SequenceType.Arity.OneOrZero; + else inferredArity = SequenceType.Arity.One; + + inferredType = leftInferredType.getItemType().staticallyAddTo(rightInferredType.getItemType(), expression.isMinus()); + + if(inferredType == null){ + if(inferredArity == SequenceType.Arity.OneOrZero){ + // we have incompatible types, but it is possible that at runtime one of the type resolve to be the empty sequence, that is the only possible output not causing an exception + expression.setInferredSequenceType(SequenceType.EMPTY_SEQUENCE); + } else { + throw new UnexpectedStaticTypeException("The following types operation is not possible: " + leftInferredType + (expression.isMinus() ? " - " : " + ") + rightInferredType); + } + } else { + expression.setInferredSequenceType(new SequenceType(inferredType, inferredArity)); + } + + System.out.println("visiting Additive expression, set type: " + expression.getInferredSequenceType()); + return argument; + } + + // endregion } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index d96c2e3818..11ac5c9a1a 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -29,40 +29,96 @@ public class ItemType implements Serializable { private static final long serialVersionUID = 1L; private String name; + private int index; // for private matrix operation - public static final ItemType objectItem = new ItemType("object"); - public static final ItemType atomicItem = new ItemType("atomic"); - public static final ItemType stringItem = new ItemType("string"); - public static final ItemType integerItem = new ItemType("integer"); - public static final ItemType decimalItem = new ItemType("decimal"); - public static final ItemType doubleItem = new ItemType("double"); - public static final ItemType booleanItem = new ItemType("boolean"); - public static final ItemType arrayItem = new ItemType("array"); - public static final ItemType nullItem = new ItemType("null"); - public static final ItemType JSONItem = new ItemType("json-item"); - public static final ItemType durationItem = new ItemType("duration"); - public static final ItemType yearMonthDurationItem = new ItemType("yearMonthDuration"); - public static final ItemType dayTimeDurationItem = new ItemType("dayTimeDuration"); - public static final ItemType dateTimeItem = new ItemType("dateTime"); - public static final ItemType dateItem = new ItemType("date"); - public static final ItemType timeItem = new ItemType("time"); - public static final ItemType hexBinaryItem = new ItemType("hexBinary"); - public static final ItemType anyURIItem = new ItemType("anyURI"); - public static final ItemType base64BinaryItem = new ItemType("base64Binary"); - public static final ItemType item = new ItemType("item"); - public static final ItemType functionItem = new ItemType("function"); + public static final ItemType item = new ItemType("item", 0); + public static final ItemType atomicItem = new ItemType("atomic", 1); + public static final ItemType stringItem = new ItemType("string", 2); + public static final ItemType integerItem = new ItemType("integer", 3); + public static final ItemType decimalItem = new ItemType("decimal", 4); + public static final ItemType doubleItem = new ItemType("double", 5); + public static final ItemType booleanItem = new ItemType("boolean", 6); + public static final ItemType nullItem = new ItemType("null", 7); + public static final ItemType durationItem = new ItemType("duration", 8); + public static final ItemType yearMonthDurationItem = new ItemType("yearMonthDuration", 9); + public static final ItemType dayTimeDurationItem = new ItemType("dayTimeDuration", 10); + public static final ItemType dateTimeItem = new ItemType("dateTime", 11); + public static final ItemType dateItem = new ItemType("date", 12); + public static final ItemType timeItem = new ItemType("time", 13); + public static final ItemType hexBinaryItem = new ItemType("hexBinary", 14); + public static final ItemType anyURIItem = new ItemType("anyURI", 15); + public static final ItemType base64BinaryItem = new ItemType("base64Binary", 16); + public static final ItemType JSONItem = new ItemType("json-item", 17); + public static final ItemType objectItem = new ItemType("object", 18); + public static final ItemType arrayItem = new ItemType("array", 19); + public static final ItemType functionItem = new ItemType("function", 20); public ItemType() { } - private ItemType(String name) { + private ItemType(String name, int index) { this.name = name; + this.index = index; } + // resulting type of [row] + [col] + private static ItemType addTable[][] = { + // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex any-uri base64 json-item object array function + /* item */ { atomicItem, atomicItem, null, atomicItem, atomicItem, atomicItem, null, null, atomicItem, atomicItem, atomicItem, atomicItem, atomicItem, timeItem, null, null, null, null, null, null, null }, + /* atomic */ { atomicItem, atomicItem, null, atomicItem, atomicItem, atomicItem, null, null, atomicItem, atomicItem, atomicItem, atomicItem, atomicItem, timeItem, null, null, null, null, null, null, null }, + /* string */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* integer */ { atomicItem, atomicItem, null, integerItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* decimal */ { atomicItem, atomicItem, null, decimalItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* double */ { atomicItem, atomicItem, null, doubleItem, doubleItem, doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* bool */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* null */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* duration */ { atomicItem, atomicItem, null, null, null, null, null, null, durationItem, yearMonthDurationItem, dayTimeDurationItem,dateTimeItem, dateItem, timeItem, null, null, null, null, null, null, null }, + /* y-m-dur */ { atomicItem, atomicItem, null, null, null, null, null, null, yearMonthDurationItem, yearMonthDurationItem, null, dateTimeItem, dateItem, null, null, null, null, null, null, null, null }, + /* d-t-dur */ { atomicItem, atomicItem, null, null, null, null, null, null, dayTimeDurationItem, null, dayTimeDurationItem,dateTimeItem, dateItem, timeItem, null, null, null, null, null, null, null }, + /* date-time*/ { atomicItem, atomicItem, null, null, null, null, null, null, dateTimeItem, dateTimeItem, dateTimeItem, null, null, null, null, null, null, null, null, null, null }, + /* date */ { atomicItem, atomicItem, null, null, null, null, null, null, dateItem, dateItem, dateItem, null, null, null, null, null, null, null, null, null, null }, + /* time */ { timeItem, timeItem, null, null, null, null, null, null, timeItem, null, timeItem, null, null, null, null, null, null, null, null, null, null }, + /* hex */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* any-uri */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* base64 */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* json-item*/ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* object */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* array */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* function */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + }; + + // resulting type of [row] - [col] + private static ItemType subTable[][] = { + // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex any-uri base64 json-item object array function + /* item */ { atomicItem, atomicItem, null, atomicItem, atomicItem, atomicItem, null, null, atomicItem, atomicItem, atomicItem, atomicItem, atomicItem, atomicItem, null, null, null, null, null, null, null }, + /* atomic */ { atomicItem, atomicItem, null, atomicItem, atomicItem, atomicItem, null, null, atomicItem, atomicItem, atomicItem, atomicItem, atomicItem, atomicItem, null, null, null, null, null, null, null }, + /* string */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* integer */ { atomicItem, atomicItem, null, integerItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* decimal */ { atomicItem, atomicItem, null, decimalItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* double */ { atomicItem, atomicItem, null, doubleItem, doubleItem, doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* bool */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* null */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* duration */ { durationItem, durationItem, null, null, null, null, null, null, durationItem, yearMonthDurationItem, dayTimeDurationItem,null, null, null, null, null, null, null, null, null, null }, + /* y-m-dur */ { yearMonthDurationItem,yearMonthDurationItem, null, null, null, null, null, null, yearMonthDurationItem, yearMonthDurationItem, null, null, null, null, null, null, null, null, null, null, null }, + /* d-t-dur */ { dayTimeDurationItem, dayTimeDurationItem, null, null, null, null, null, null, dayTimeDurationItem, null, dayTimeDurationItem,null, null, null, null, null, null, null, null, null, null }, + /* date-time*/ { atomicItem, atomicItem, null, null, null, null, null, null, dateTimeItem, dateTimeItem, dateTimeItem, dayTimeDurationItem,null, null, null, null, null, null, null, null, null }, + /* date */ { atomicItem, atomicItem, null, null, null, null, null, null, dateItem, dateItem, dateItem, null, dayTimeDurationItem,null, null, null, null, null, null, null, null }, + /* time */ { atomicItem, atomicItem, null, null, null, null, null, null, timeItem, null, timeItem, null, null, dayTimeDurationItem,null, null, null, null, null, null, null }, + /* hex */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* any-uri */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* base64 */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* json-item*/ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* object */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* array */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* function */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + }; + public String getName() { return this.name; } + public int getIndex() { return this.index; } + public static ItemType getItemTypeByName(String name) { if (name.equals(objectItem.name)) { return objectItem; @@ -228,6 +284,15 @@ public boolean staticallyCastableAs(ItemType other){ return false; } + // return the resulting statically inferred ItemType from adding [this] to [other], return null in case of incompatible inferred static types + public ItemType staticallyAddTo(ItemType other, boolean isMinus) { + if(isMinus){ + return subTable[this.getIndex()][other.getIndex()]; + } else { + return addTable[this.getIndex()][other.getIndex()]; + } + } + @Override public String toString() { return this.name; From 3021aba3f2f20bb0c87666e159f5873223087a69 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 14 Oct 2020 17:55:12 +0200 Subject: [PATCH 007/206] added unary expression inference, and isNumeric() function to itemType --- .../rumbledb/compiler/InferTypeVisitor.java | 37 +++++++++++++++++++ .../java/org/rumbledb/types/ItemType.java | 9 +++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 6f7dbd4ba8..a43886acc3 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -7,6 +7,7 @@ import org.rumbledb.expressions.Expression; import org.rumbledb.expressions.Node; import org.rumbledb.expressions.arithmetic.AdditiveExpression; +import org.rumbledb.expressions.arithmetic.UnaryExpression; import org.rumbledb.expressions.primary.*; import org.rumbledb.expressions.typing.CastExpression; import org.rumbledb.expressions.typing.CastableExpression; @@ -273,6 +274,42 @@ public Void visitAdditiveExpr(AdditiveExpression expression, Void argument) { return argument; } + @Override + public Void visitUnaryExpr(UnaryExpression expression, Void argument) { + visitDescendants(expression, argument); + SequenceType childInferredType = expression.getMainExpression().getInferredSequenceType(); + + // if the child expression has null inferred type throw error + if(childInferredType == null){ + throw new UnexpectedStaticTypeException("The child expression of a UnaryExpression has no inferred type"); + } + + // if the child is the empty sequence just infer the empty sequence + if(childInferredType.isEmptySequence()){ + expression.setInferredSequenceType(SequenceType.EMPTY_SEQUENCE); + System.out.println("visiting Unary expression, set type: " + expression.getInferredSequenceType()); + return argument; + } + + // If child allows for the empty sequence, set returning arity to '?', normal otherwise + SequenceType.Arity inferredArity = (childInferredType.getArity() == SequenceType.Arity.OneOrZero || childInferredType.getArity() == SequenceType.Arity.ZeroOrMore) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.One; + + // if inferred arity does not allow for empty sequence and static type is not an accepted one throw a static error + ItemType childItemType = childInferredType.getItemType(); + if(childItemType.isNumeric() || childItemType.equals(ItemType.atomicItem) || childItemType.equals(ItemType.item)){ + expression.setInferredSequenceType(new SequenceType(childItemType, inferredArity)); + } else { + if(inferredArity == SequenceType.Arity.OneOrZero){ + // incompatible type, but still possible to have empty sequence at runtime + expression.setInferredSequenceType(SequenceType.EMPTY_SEQUENCE); + } else { + throw new UnexpectedStaticTypeException("It is not possible to have an Unary expression with the following type: " + childInferredType); + } + } + + System.out.println("visiting Unary expression, set type: " + expression.getInferredSequenceType()); + return argument; + } // endregion } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 11ac5c9a1a..9bb2bbca51 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -249,7 +249,6 @@ public boolean staticallyCastableAs(ItemType other){ if(other.equals(integerItem) || other.equals(doubleItem) || other.equals(decimalItem) || - other.equals(stringItem) || other.equals(booleanItem) ) return true; else return false; @@ -257,8 +256,7 @@ public boolean staticallyCastableAs(ItemType other){ // base64 and hex can be cast between themselves if(this.equals(base64BinaryItem) || this.equals(hexBinaryItem)){ if(other.equals(base64BinaryItem) || - other.equals(hexBinaryItem) || - other.equals(stringItem) + other.equals(hexBinaryItem) ) return true; else return false; } @@ -293,6 +291,11 @@ public ItemType staticallyAddTo(ItemType other, boolean isMinus) { } } + // return [true] if this is a numeric type (i.e. [integerItem], [decimalItem] or [doubleItem]), false otherwise + public boolean isNumeric(){ + return this.equals(integerItem) || this.equals(decimalItem) || this.equals(doubleItem); + } + @Override public String toString() { return this.name; From f1ecf68e70d7a28e91bcd7ccb2bc5841315b22f5 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Fri, 16 Oct 2020 10:03:37 +0200 Subject: [PATCH 008/206] corrected ItemType to include missing atomic types in subtypeOf and minor fixes in staticallyCastableAs and findCommonSuperType, added multiplicate expression static type inference --- .../rumbledb/compiler/InferTypeVisitor.java | 94 +++++++++++++++++++ .../java/org/rumbledb/types/ItemType.java | 46 +++++---- 2 files changed, 120 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index a43886acc3..eeb320ba6c 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -7,6 +7,7 @@ import org.rumbledb.expressions.Expression; import org.rumbledb.expressions.Node; import org.rumbledb.expressions.arithmetic.AdditiveExpression; +import org.rumbledb.expressions.arithmetic.MultiplicativeExpression; import org.rumbledb.expressions.arithmetic.UnaryExpression; import org.rumbledb.expressions.primary.*; import org.rumbledb.expressions.typing.CastExpression; @@ -274,6 +275,99 @@ public Void visitAdditiveExpr(AdditiveExpression expression, Void argument) { return argument; } + // This function assume 2 numeric ItemType + private ItemType resolveNumericType(ItemType left, ItemType right){ + if(left.equals(ItemType.doubleItem) || right.equals(ItemType.doubleItem)){ + return ItemType.doubleItem; + } else if(left.equals(ItemType.decimalItem) || right.equals(ItemType.decimalItem)){ + return ItemType.decimalItem; + } else { + return ItemType.integerItem; + } + } + + // For arithmetic operations, given 2 arities, return the resulting arity or null in case of invalid arity + private SequenceType.Arity resolveArities(SequenceType.Arity left, SequenceType.Arity right) { + if(left == null || + left == SequenceType.Arity.ZeroOrMore || + left == SequenceType.Arity.OneOrMore || + right == null || + right == SequenceType.Arity.ZeroOrMore || + right == SequenceType.Arity.OneOrMore + ) return null; + return (left == SequenceType.Arity.OneOrZero || right == SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.One; + } + + @Override + public Void visitMultiplicativeExpr(MultiplicativeExpression expression, Void argument) { + // TODO: Behaviour of empty sequence to check, now is accepted as only return type + visitDescendants(expression, argument); + + List childrenExpressions = expression.getChildren(); + SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); + SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); + + // if any of the child expression has null inferred type throw error + if(leftInferredType == null || rightInferredType == null){ + throw new UnexpectedStaticTypeException("A child expression of a MultiplicativeExpression has no inferred type"); + } + + // if any of the children is the empty sequence just infer the empty sequence + if(leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()){ + expression.setInferredSequenceType(SequenceType.EMPTY_SEQUENCE); + System.out.println("visiting Multiplicative expression, set type: " + expression.getInferredSequenceType()); + return argument; + } + + ItemType inferredType = null; + SequenceType.Arity inferredArity = resolveArities(leftInferredType.getArity(), rightInferredType.getArity()); + + if(inferredArity == null){ + throw new UnexpectedStaticTypeException(expression.getMultiplicativeOperator() + " operator does not support sequences with possible arity greater than one (i.e. '*' and '+' arities)"); + } + + ItemType leftItemType = leftInferredType.getItemType(); + ItemType rightItemType = rightInferredType.getItemType(); + + // check resulting item for each operation + if(leftItemType.isNumeric()){ + if(rightItemType.isNumeric()){ + if(expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.IDIV){ + inferredType = ItemType.integerItem; + } else if(expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV) { + inferredType = resolveNumericType(ItemType.decimalItem, resolveNumericType(leftItemType, rightItemType)); + } else { + inferredType = resolveNumericType(leftItemType, rightItemType); + } + } else if(rightItemType.isSubtypeOf(ItemType.durationItem) && + expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL){ + inferredType = rightItemType; + } + } else if(leftItemType.isSubtypeOf(ItemType.durationItem)){ + if(rightItemType.isNumeric() && ( + expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL || + expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV )){ + inferredType = rightItemType; + } else if(rightItemType.equals(leftItemType) && !leftItemType.equals(ItemType.durationItem)){ + inferredType = ItemType.decimalItem; + } + } + + if(inferredType == null){ + if(inferredArity == SequenceType.Arity.OneOrZero){ + // if no type combination but still optional arity, only possible resulting type is empty sequence + expression.setInferredSequenceType(SequenceType.EMPTY_SEQUENCE); + } else { + throw new UnexpectedStaticTypeException("The following types expression is not valid: " + leftItemType + " " + expression.getMultiplicativeOperator() + " " + rightItemType); + } + } else { + expression.setInferredSequenceType(new SequenceType(inferredType, inferredArity)); + } + + System.out.println("visiting Multiplicative expression, set type: " + expression.getInferredSequenceType()); + return argument; + } + @Override public Void visitUnaryExpr(UnaryExpression expression, Void argument) { visitDescendants(expression, argument); diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 9bb2bbca51..e19f11bb7b 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -209,34 +209,43 @@ public boolean isSubtypeOf(ItemType superType) { || this.equals(booleanItem) || this.equals(nullItem) || this.equals(anyURIItem) + || this.equals(hexBinaryItem) + || this.equals(base64BinaryItem) + || this.equals(dateTimeItem) + || this.equals(dateItem) + || this.equals(timeItem) + || this.equals(durationItem) + || this.equals(yearMonthDurationItem) + || this.equals(dayTimeDurationItem) || this.equals(atomicItem); + } else if (superType.equals(durationItem)) { + return this.equals(yearMonthDurationItem) + || this.equals(dayTimeDurationItem) + || this.equals(durationItem); } return this.equals(superType); } public ItemType findCommonSuperType(ItemType other){ - // TODO: check relation between Int and Double (numeric in general) - // TODO: first check is necessary due to inconsistency in ItemType subtype check + // TODO: consider introducing numeric if(other.isSubtypeOf(this)){ return this; - } else if(this.isSubtypeOf(other)){ + } else if(this.isSubtypeOf(other)) { return other; - } else if(this.isSubtypeOf(ItemType.atomicItem) && other.isSubtypeOf(ItemType.atomicItem)){ - return ItemType.atomicItem; - } else if(this.isSubtypeOf(ItemType.JSONItem) && other.isSubtypeOf(ItemType.JSONItem)){ - return ItemType.JSONItem; + } else if(this.isSubtypeOf(durationItem) && other.isSubtypeOf(durationItem)){ + return durationItem; + } else if(this.isSubtypeOf(atomicItem) && other.isSubtypeOf(atomicItem)){ + return atomicItem; + } else if(this.isSubtypeOf(JSONItem) && other.isSubtypeOf(JSONItem)){ + return JSONItem; } else { - return ItemType.item; + return item; } } - public boolean staticallyCastableAs(ItemType other){ - // TODO: is null atomic or JSONitem? - // TODO: are jsonitems not castable to or form (excluding null) what about item - // TODO: no need for null special check if above applies - // TODO: can we cast to item (depends on inner functioning of cast as) - // JSON items cannot be cast from and to - if(this.isSubtypeOf(JSONItem) || other.isSubtypeOf(JSONItem)) + public boolean staticallyCastableAs(ItemType other){ + // JSON items cannot be cast from and to, nor function items, nor we can cast to atomic or item + if(this.isSubtypeOf(JSONItem) || other.isSubtypeOf(JSONItem) || this.equals(functionItem) || other.equals(functionItem) || other.equals(atomicItem) || other.equals(item)) return false; // anything can be casted to itself if(this.equals(other)) @@ -261,11 +270,8 @@ public boolean staticallyCastableAs(ItemType other){ else return false; } // durations can be cast between themselves - if(this.equals(durationItem) || this.equals(yearMonthDurationItem) || this.equals(dayTimeDurationItem)){ - if(other.equals(durationItem) || - other.equals(yearMonthDurationItem) || - other.equals(dayTimeDurationItem) - ) return true; + if(this.isSubtypeOf(durationItem)){ + if(other.isSubtypeOf(durationItem)) return true; else return false; } // DateTime can be cast also to Date or Time From 5117278173e1c4f4a12ca96e5182ac8a783d0ae0 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Fri, 16 Oct 2020 11:17:49 +0200 Subject: [PATCH 009/206] added static type inference for logic expressions, added hasEffectiveBooleanValue to SequenceType --- .../rumbledb/compiler/InferTypeVisitor.java | 56 +++++++++++++++++++ .../java/org/rumbledb/types/SequenceType.java | 16 ++++++ 2 files changed, 72 insertions(+) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index eeb320ba6c..f8b463e27f 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -9,6 +9,9 @@ import org.rumbledb.expressions.arithmetic.AdditiveExpression; import org.rumbledb.expressions.arithmetic.MultiplicativeExpression; import org.rumbledb.expressions.arithmetic.UnaryExpression; +import org.rumbledb.expressions.logic.AndExpression; +import org.rumbledb.expressions.logic.NotExpression; +import org.rumbledb.expressions.logic.OrExpression; import org.rumbledb.expressions.primary.*; import org.rumbledb.expressions.typing.CastExpression; import org.rumbledb.expressions.typing.CastableExpression; @@ -406,4 +409,57 @@ public Void visitUnaryExpr(UnaryExpression expression, Void argument) { } // endregion + + // region logic + + private Void visitAndOrExpr(Expression expression, Void argument, String expressionName){ + visitDescendants(expression, argument); + + List childrenExpressions = expression.getChildren(); + SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); + SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); + + if(leftInferredType == null || rightInferredType == null){ + throw new UnexpectedStaticTypeException("A child expression of a " + expressionName + "Expression has no inferred type"); + } + + if(!leftInferredType.hasEffectiveBooleanValue()){ + throw new UnexpectedStaticTypeException("left expression of a " + expressionName + "Expression has " + leftInferredType + " inferred type, which has no effective boolean value"); + } + + if(!rightInferredType.hasEffectiveBooleanValue()){ + throw new UnexpectedStaticTypeException("right expression of a " + expressionName + "Expression has " + rightInferredType + " inferred type, which has no effective boolean value"); + } + + expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + return argument; + } + + @Override + public Void visitAndExpr(AndExpression expression, Void argument) { + return visitAndOrExpr(expression, argument, "And"); + } + + @Override + public Void visitOrExpr(OrExpression expression, Void argument) { + return visitAndOrExpr(expression, argument, "Or"); + } + + @Override + public Void visitNotExpr(NotExpression expression, Void argument) { + visitDescendants(expression, argument); + + SequenceType childInferredType = expression.getMainExpression().getInferredSequenceType(); + if(childInferredType == null){ + throw new UnexpectedStaticTypeException("The child expression of NotExpression has no inferred type"); + } + if(!childInferredType.hasEffectiveBooleanValue()){ + throw new UnexpectedStaticTypeException("The child expression of NotExpression has " + childInferredType + " inferred type, which has no effective boolean value"); + } + + expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + return argument; + } + + // endregion } diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index 0ee70e3dc6..fe9e25c1e3 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -85,6 +85,22 @@ public boolean isSubtypeOf(SequenceType superType) { this.arity == superType.arity; } + public boolean hasEffectiveBooleanValue(){ + if(this.isEmptySequence){ + return true; + } else if((this.arity == Arity.One || this.arity == Arity.OneOrZero) && ( + this.itemType.isSubtypeOf(ItemType.JSONItem) || + this.itemType.isNumeric() || + this.itemType.equals(ItemType.stringItem) || + this.itemType.equals(ItemType.anyURIItem) || + this.itemType.equals(ItemType.nullItem) || + this.itemType.equals(ItemType.booleanItem))){ + return true; + } else { + return false; + } + } + @Override public boolean equals(Object other) { if (!(other instanceof SequenceType)) { From a73c280cb0a6b868935910dd87d877119872299f Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 19 Oct 2020 13:12:32 +0200 Subject: [PATCH 010/206] fixed isSubtypeOf in SeuenceType and added Arity subtypeOf function, corrected object construction and considered merged constructor --- .../rumbledb/compiler/InferTypeVisitor.java | 26 ++++++++++++------- .../java/org/rumbledb/types/ItemType.java | 1 - .../java/org/rumbledb/types/SequenceType.java | 12 +++++++-- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index f8b463e27f..301ab6ae93 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -20,7 +20,6 @@ import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; -import java.util.ArrayList; import java.util.List; /** @@ -141,15 +140,24 @@ public Void visitArrayConstructor(ArrayConstructorExpression expression, Void ar public Void visitObjectConstructor(ObjectConstructorExpression expression, Void argument) { System.out.println("visiting Object constructor literal"); visitDescendants(expression, argument); - // TODO: what about object merged constructor with childExpression - for(Expression keyExpression : expression.getKeys()){ - SequenceType keySequenceType = keyExpression.getInferredSequenceType(); - if(keySequenceType == null){ - throw new UnexpectedStaticTypeException("One of the key in the object constructor has no inferred type"); + if(expression.isMergedConstructor()){ + // if it is a merged constructor the child must be a subtype of object* inferred type + SequenceType childSequenceType = ((Expression) expression.getChildren().get(0)).getInferredSequenceType(); + if(childSequenceType == null) { + throw new UnexpectedStaticTypeException("The child expression has no inferred type"); } - ItemType keyType = keySequenceType.getItemType(); - if(!keyType.equals(ItemType.stringItem) && !keyType.equals(ItemType.atomicItem) && !keyType.equals(ItemType.item)){ - throw new UnexpectedStaticTypeException("The inferred static types for the keys of an Object must be String or one of its supertypes (i.e. atomicItem or item)"); + if(!childSequenceType.isSubtypeOf(SequenceType.createSequenceType("object*"))){ + throw new UnexpectedStaticTypeException("The child expression must have object* sequence type, instead found: " + childSequenceType); + } + } else { + for (Expression keyExpression : expression.getKeys()) { + SequenceType keySequenceType = keyExpression.getInferredSequenceType(); + if (keySequenceType == null) { + throw new UnexpectedStaticTypeException("One of the key in the object constructor has no inferred type"); + } + if (!keySequenceType.isSubtypeOf(SequenceType.createSequenceType("string")) && !keySequenceType.isSubtypeOf(SequenceType.createSequenceType("anyURI"))) { + throw new UnexpectedStaticTypeException("The inferred static sequence types for the keys of an Object must be a subtype of string or anyURI, instead found a: " + keySequenceType); + } } } expression.setInferredSequenceType(new SequenceType(ItemType.objectItem)); diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index e19f11bb7b..134531b187 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -227,7 +227,6 @@ public boolean isSubtypeOf(ItemType superType) { } public ItemType findCommonSuperType(ItemType other){ - // TODO: consider introducing numeric if(other.isSubtypeOf(this)){ return this; } else if(this.isSubtypeOf(other)) { diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index fe9e25c1e3..a78b507069 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -76,13 +76,20 @@ public Arity getArity() { } public boolean isSubtypeOf(SequenceType superType) { - // TODO: arity check because of possible error if (this.isEmptySequence) { return superType.arity == Arity.OneOrZero || superType.arity == Arity.ZeroOrMore; } return this.itemType.isSubtypeOf(superType.getItemType()) && - this.arity == superType.arity; + this.isAritySubtypeOf(superType.arity); + } + + // check if the arity of a sequence type is subtype of another arity, assume [this] is a non-empty sequence + public boolean isAritySubtypeOf(Arity superArity){ + if(superArity == Arity.ZeroOrMore || superArity == this.arity) + return true; + else + return this.arity == Arity.One; } public boolean hasEffectiveBooleanValue(){ @@ -209,6 +216,7 @@ public String toString() { sequenceTypes.put("time?", new SequenceType(ItemType.timeItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("anyURI", new SequenceType(ItemType.anyURIItem)); sequenceTypes.put("anyURI?", new SequenceType(ItemType.anyURIItem, SequenceType.Arity.OneOrZero)); sequenceTypes.put("hexBinary?", new SequenceType(ItemType.hexBinaryItem, SequenceType.Arity.OneOrZero)); From 5e5f8647b90a8f53ed86f7d4a7ed912f79526459 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 19 Oct 2020 15:20:52 +0200 Subject: [PATCH 011/206] added XPST0005 error checks and corrected behaviours of typing and arithmetic expressions --- .../rumbledb/compiler/InferTypeVisitor.java | 96 ++++++++----------- .../org/rumbledb/errorcodes/ErrorCode.java | 1 + .../UnexpectedStaticTypeException.java | 6 ++ .../java/org/rumbledb/types/ItemType.java | 46 ++++----- 4 files changed, 72 insertions(+), 77 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 301ab6ae93..eee6b9157e 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1,6 +1,7 @@ package org.rumbledb.compiler; import org.rumbledb.config.RumbleRuntimeConfiguration; +import org.rumbledb.errorcodes.ErrorCode; import org.rumbledb.exceptions.UnexpectedStaticTypeException; import org.rumbledb.expressions.AbstractNodeVisitor; import org.rumbledb.expressions.CommaExpression; @@ -185,14 +186,24 @@ public Void visitCastExpression(CastExpression expression, Void argument) { SequenceType expressionSequenceType = expression.getMainExpression().getInferredSequenceType(); SequenceType castedSequenceType = expression.getSequenceType(); - // Arity basic check - if(expressionSequenceType.isEmptySequence() && castedSequenceType.getArity() == SequenceType.Arity.One){ - throw new UnexpectedStaticTypeException("Empty sequence cannot be cast to type with quantifier '1'"); + // Empty sequence check + if(expressionSequenceType.isEmptySequence() && castedSequenceType.getArity() != SequenceType.Arity.OneOrZero){ + throw new UnexpectedStaticTypeException("Empty sequence cannot be cast to type with quantifier different from '?'"); } + + // Arity check + if(!castedSequenceType.isAritySubtypeOf(SequenceType.Arity.OneOrZero)){ + throw new UnexpectedStaticTypeException("It is possible to cast only to types with arity '1' or '?'"); + } + if(!expressionSequenceType.isAritySubtypeOf(castedSequenceType.getArity())){ + throw new UnexpectedStaticTypeException("It is never possible to cast a " + + expressionSequenceType + " as " + castedSequenceType); + } + // ItemType static castability check if(!expressionSequenceType.getItemType().staticallyCastableAs(castedSequenceType.getItemType())){ - throw new UnexpectedStaticTypeException("It is not possible to cast a " + - expressionSequenceType.getItemType() + " as " + castedSequenceType.getItemType()); + throw new UnexpectedStaticTypeException("It is never possible to cast a " + + expressionSequenceType + " as " + castedSequenceType); } expression.setInferredSequenceType(castedSequenceType); @@ -216,16 +227,8 @@ public Void visitTreatExpression(TreatExpression expression, Void argument) { SequenceType expressionSequenceType = expression.getMainExpression().getInferredSequenceType(); SequenceType treatedSequenceType = expression.getSequenceType(); - // Empty sequence check (potentially any other arity could fullfill any other arity) - if(expressionSequenceType.isEmptySequence() && - (treatedSequenceType.getArity() == SequenceType.Arity.One || treatedSequenceType.getArity() == SequenceType.Arity.OneOrMore)){ - throw new UnexpectedStaticTypeException("Empty sequence cannot be treated as type with quantifier '1' or '+'"); - } - // ItemType static treatability check (if the types' spaces are mutually exclusive, one cannot be treated like the other for sure) - if(!expressionSequenceType.getItemType().isSubtypeOf(treatedSequenceType.getItemType()) && - !treatedSequenceType.getItemType().isSubtypeOf(expressionSequenceType.getItemType())){ - throw new UnexpectedStaticTypeException("It is not possible to treat a " + - expressionSequenceType.getItemType() + " as " + treatedSequenceType.getItemType()); + if(expressionSequenceType == null || treatedSequenceType == null){ + throw new UnexpectedStaticTypeException("The child expression of a Treat expression has no inferred type or it is being treated as null sequence type"); } expression.setInferredSequenceType(treatedSequenceType); @@ -240,7 +243,6 @@ public Void visitTreatExpression(TreatExpression expression, Void argument) { public Void visitAdditiveExpr(AdditiveExpression expression, Void argument) { visitDescendants(expression, argument); - // TODO: consider direct access with no casting List childrenExpressions = expression.getChildren(); SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); @@ -250,38 +252,31 @@ public Void visitAdditiveExpr(AdditiveExpression expression, Void argument) { throw new UnexpectedStaticTypeException("A child expression of a AdditiveExpression has no inferred type"); } - // if any of the children is the empty sequence just infer the empty sequence - // TODO: check if returning () even when + is not supported with the other type is the intended behaviour + // if any of the children is the empty sequence throw error XPST0005 if(leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()){ - expression.setInferredSequenceType(SequenceType.EMPTY_SEQUENCE); - System.out.println("visiting Additive expression, set type: " + expression.getInferredSequenceType()); - return argument; + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); } ItemType inferredType; - SequenceType.Arity inferredArity; + SequenceType.Arity inferredArity = resolveArities(leftInferredType.getArity(), rightInferredType.getArity()); - // if any of the children allows for the empty sequence the resulting arity is '?' - if(leftInferredType.getArity() == SequenceType.Arity.OneOrZero || - leftInferredType.getArity() == SequenceType.Arity.ZeroOrMore || - rightInferredType.getArity() == SequenceType.Arity.OneOrZero || - rightInferredType.getArity() == SequenceType.Arity.ZeroOrMore - ) inferredArity = SequenceType.Arity.OneOrZero; - else inferredArity = SequenceType.Arity.One; + // arity check + if(inferredArity == null){ + throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for additive expressions"); + } inferredType = leftInferredType.getItemType().staticallyAddTo(rightInferredType.getItemType(), expression.isMinus()); if(inferredType == null){ if(inferredArity == SequenceType.Arity.OneOrZero){ - // we have incompatible types, but it is possible that at runtime one of the type resolve to be the empty sequence, that is the only possible output not causing an exception - expression.setInferredSequenceType(SequenceType.EMPTY_SEQUENCE); + // Only possible resulting type is empty sequence so throw error XPST0005 + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); } else { throw new UnexpectedStaticTypeException("The following types operation is not possible: " + leftInferredType + (expression.isMinus() ? " - " : " + ") + rightInferredType); } - } else { - expression.setInferredSequenceType(new SequenceType(inferredType, inferredArity)); } + expression.setInferredSequenceType(new SequenceType(inferredType, inferredArity)); System.out.println("visiting Additive expression, set type: " + expression.getInferredSequenceType()); return argument; } @@ -311,7 +306,6 @@ private SequenceType.Arity resolveArities(SequenceType.Arity left, SequenceType. @Override public Void visitMultiplicativeExpr(MultiplicativeExpression expression, Void argument) { - // TODO: Behaviour of empty sequence to check, now is accepted as only return type visitDescendants(expression, argument); List childrenExpressions = expression.getChildren(); @@ -323,18 +317,16 @@ public Void visitMultiplicativeExpr(MultiplicativeExpression expression, Void ar throw new UnexpectedStaticTypeException("A child expression of a MultiplicativeExpression has no inferred type"); } - // if any of the children is the empty sequence just infer the empty sequence + // if any of the children is the empty sequence throw error XPST0005 if(leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()){ - expression.setInferredSequenceType(SequenceType.EMPTY_SEQUENCE); - System.out.println("visiting Multiplicative expression, set type: " + expression.getInferredSequenceType()); - return argument; + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); } ItemType inferredType = null; SequenceType.Arity inferredArity = resolveArities(leftInferredType.getArity(), rightInferredType.getArity()); if(inferredArity == null){ - throw new UnexpectedStaticTypeException(expression.getMultiplicativeOperator() + " operator does not support sequences with possible arity greater than one (i.e. '*' and '+' arities)"); + throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for multiplicative expressions"); } ItemType leftItemType = leftInferredType.getItemType(); @@ -366,15 +358,14 @@ public Void visitMultiplicativeExpr(MultiplicativeExpression expression, Void ar if(inferredType == null){ if(inferredArity == SequenceType.Arity.OneOrZero){ - // if no type combination but still optional arity, only possible resulting type is empty sequence - expression.setInferredSequenceType(SequenceType.EMPTY_SEQUENCE); + // Only possible resulting type is empty sequence so throw error XPST0005 + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); } else { throw new UnexpectedStaticTypeException("The following types expression is not valid: " + leftItemType + " " + expression.getMultiplicativeOperator() + " " + rightItemType); } - } else { - expression.setInferredSequenceType(new SequenceType(inferredType, inferredArity)); } + expression.setInferredSequenceType(new SequenceType(inferredType, inferredArity)); System.out.println("visiting Multiplicative expression, set type: " + expression.getInferredSequenceType()); return argument; } @@ -391,27 +382,24 @@ public Void visitUnaryExpr(UnaryExpression expression, Void argument) { // if the child is the empty sequence just infer the empty sequence if(childInferredType.isEmptySequence()){ - expression.setInferredSequenceType(SequenceType.EMPTY_SEQUENCE); - System.out.println("visiting Unary expression, set type: " + expression.getInferredSequenceType()); - return argument; + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); } - // If child allows for the empty sequence, set returning arity to '?', normal otherwise - SequenceType.Arity inferredArity = (childInferredType.getArity() == SequenceType.Arity.OneOrZero || childInferredType.getArity() == SequenceType.Arity.ZeroOrMore) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.One; + if(childInferredType.getArity() == SequenceType.Arity.OneOrMore || childInferredType.getArity() == SequenceType.Arity.ZeroOrMore){ + throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for unary expressions"); + } // if inferred arity does not allow for empty sequence and static type is not an accepted one throw a static error ItemType childItemType = childInferredType.getItemType(); - if(childItemType.isNumeric() || childItemType.equals(ItemType.atomicItem) || childItemType.equals(ItemType.item)){ - expression.setInferredSequenceType(new SequenceType(childItemType, inferredArity)); - } else { - if(inferredArity == SequenceType.Arity.OneOrZero){ - // incompatible type, but still possible to have empty sequence at runtime - expression.setInferredSequenceType(SequenceType.EMPTY_SEQUENCE); + if(!childItemType.isNumeric()){ + if(childInferredType.getArity() == SequenceType.Arity.OneOrZero){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); } else { throw new UnexpectedStaticTypeException("It is not possible to have an Unary expression with the following type: " + childInferredType); } } + expression.setInferredSequenceType(new SequenceType(childItemType, childInferredType.getArity())); System.out.println("visiting Unary expression, set type: " + expression.getInferredSequenceType()); return argument; } diff --git a/src/main/java/org/rumbledb/errorcodes/ErrorCode.java b/src/main/java/org/rumbledb/errorcodes/ErrorCode.java index f6eb96526f..6f2923efae 100644 --- a/src/main/java/org/rumbledb/errorcodes/ErrorCode.java +++ b/src/main/java/org/rumbledb/errorcodes/ErrorCode.java @@ -77,6 +77,7 @@ public enum ErrorCode { ParsingErrorCode("XPST0003"), + StaticallyInferredEmptySequenceNotFromCommaExpression("XPST0005"), UndeclaredVariableErrorCode("XPST0008"), InvalidFunctionCallErrorCode("XPST0017"), CastableErrorCode("XPST0080"), diff --git a/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java b/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java index 01ac70b7df..9eb792f139 100644 --- a/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java +++ b/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java @@ -1,5 +1,7 @@ package org.rumbledb.exceptions; +import org.rumbledb.errorcodes.ErrorCode; + public class UnexpectedStaticTypeException extends RumbleException { private static final long serialVersionUID = 1L; @@ -8,4 +10,8 @@ public UnexpectedStaticTypeException(String message) { // TODO: investigates errorCode and Metadata super(message); } + + public UnexpectedStaticTypeException(String message, ErrorCode errorCode){ + super(message, errorCode); + } } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 134531b187..20fc6da94c 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -64,20 +64,20 @@ private ItemType(String name, int index) { // resulting type of [row] + [col] private static ItemType addTable[][] = { // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex any-uri base64 json-item object array function - /* item */ { atomicItem, atomicItem, null, atomicItem, atomicItem, atomicItem, null, null, atomicItem, atomicItem, atomicItem, atomicItem, atomicItem, timeItem, null, null, null, null, null, null, null }, - /* atomic */ { atomicItem, atomicItem, null, atomicItem, atomicItem, atomicItem, null, null, atomicItem, atomicItem, atomicItem, atomicItem, atomicItem, timeItem, null, null, null, null, null, null, null }, + /* item */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* atomic */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, /* string */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* integer */ { atomicItem, atomicItem, null, integerItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* decimal */ { atomicItem, atomicItem, null, decimalItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* double */ { atomicItem, atomicItem, null, doubleItem, doubleItem, doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* integer */ { null, null, null, integerItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* decimal */ { null, null, null, decimalItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* double */ { null, null, null, doubleItem, doubleItem, doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, /* bool */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, /* null */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* duration */ { atomicItem, atomicItem, null, null, null, null, null, null, durationItem, yearMonthDurationItem, dayTimeDurationItem,dateTimeItem, dateItem, timeItem, null, null, null, null, null, null, null }, - /* y-m-dur */ { atomicItem, atomicItem, null, null, null, null, null, null, yearMonthDurationItem, yearMonthDurationItem, null, dateTimeItem, dateItem, null, null, null, null, null, null, null, null }, - /* d-t-dur */ { atomicItem, atomicItem, null, null, null, null, null, null, dayTimeDurationItem, null, dayTimeDurationItem,dateTimeItem, dateItem, timeItem, null, null, null, null, null, null, null }, - /* date-time*/ { atomicItem, atomicItem, null, null, null, null, null, null, dateTimeItem, dateTimeItem, dateTimeItem, null, null, null, null, null, null, null, null, null, null }, - /* date */ { atomicItem, atomicItem, null, null, null, null, null, null, dateItem, dateItem, dateItem, null, null, null, null, null, null, null, null, null, null }, - /* time */ { timeItem, timeItem, null, null, null, null, null, null, timeItem, null, timeItem, null, null, null, null, null, null, null, null, null, null }, + /* duration */ { null, null, null, null, null, null, null, null, null, null, null, dateTimeItem, dateItem, null, null, null, null, null, null, null, null }, + /* y-m-dur */ { null, null, null, null, null, null, null, null, null, yearMonthDurationItem, null, dateTimeItem, dateItem, null, null, null, null, null, null, null, null }, + /* d-t-dur */ { null, null, null, null, null, null, null, null, null, null, dayTimeDurationItem,dateTimeItem, dateItem, timeItem, null, null, null, null, null, null, null }, + /* date-time*/ { null, null, null, null, null, null, null, null, dateTimeItem, dateTimeItem, dateTimeItem, null, null, null, null, null, null, null, null, null, null }, + /* date */ { null, null, null, null, null, null, null, null, dateItem, dateItem, dateItem, null, null, null, null, null, null, null, null, null, null }, + /* time */ { null, null, null, null, null, null, null, null, null, null, timeItem, null, null, null, null, null, null, null, null, null, null }, /* hex */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, /* any-uri */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, /* base64 */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, @@ -90,20 +90,20 @@ private ItemType(String name, int index) { // resulting type of [row] - [col] private static ItemType subTable[][] = { // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex any-uri base64 json-item object array function - /* item */ { atomicItem, atomicItem, null, atomicItem, atomicItem, atomicItem, null, null, atomicItem, atomicItem, atomicItem, atomicItem, atomicItem, atomicItem, null, null, null, null, null, null, null }, - /* atomic */ { atomicItem, atomicItem, null, atomicItem, atomicItem, atomicItem, null, null, atomicItem, atomicItem, atomicItem, atomicItem, atomicItem, atomicItem, null, null, null, null, null, null, null }, + /* item */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* atomic */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, /* string */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* integer */ { atomicItem, atomicItem, null, integerItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* decimal */ { atomicItem, atomicItem, null, decimalItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* double */ { atomicItem, atomicItem, null, doubleItem, doubleItem, doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* integer */ { null, null, null, integerItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* decimal */ { null, null, null, decimalItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* double */ { null, null, null, doubleItem, doubleItem, doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, /* bool */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, /* null */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* duration */ { durationItem, durationItem, null, null, null, null, null, null, durationItem, yearMonthDurationItem, dayTimeDurationItem,null, null, null, null, null, null, null, null, null, null }, - /* y-m-dur */ { yearMonthDurationItem,yearMonthDurationItem, null, null, null, null, null, null, yearMonthDurationItem, yearMonthDurationItem, null, null, null, null, null, null, null, null, null, null, null }, - /* d-t-dur */ { dayTimeDurationItem, dayTimeDurationItem, null, null, null, null, null, null, dayTimeDurationItem, null, dayTimeDurationItem,null, null, null, null, null, null, null, null, null, null }, - /* date-time*/ { atomicItem, atomicItem, null, null, null, null, null, null, dateTimeItem, dateTimeItem, dateTimeItem, dayTimeDurationItem,null, null, null, null, null, null, null, null, null }, - /* date */ { atomicItem, atomicItem, null, null, null, null, null, null, dateItem, dateItem, dateItem, null, dayTimeDurationItem,null, null, null, null, null, null, null, null }, - /* time */ { atomicItem, atomicItem, null, null, null, null, null, null, timeItem, null, timeItem, null, null, dayTimeDurationItem,null, null, null, null, null, null, null }, + /* duration */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + /* y-m-dur */ { null, null, null, null, null, null, null, null, null, yearMonthDurationItem, null, null, null, null, null, null, null, null, null, null, null }, + /* d-t-dur */ { null, null, null, null, null, null, null, null, null, null, dayTimeDurationItem,null, null, null, null, null, null, null, null, null, null }, + /* date-time*/ { null, null, null, null, null, null, null, null, dateTimeItem, dateTimeItem, dateTimeItem, dayTimeDurationItem,null, null, null, null, null, null, null, null, null }, + /* date */ { null, null, null, null, null, null, null, null, dateItem, dateItem, dateItem, null, dayTimeDurationItem,null, null, null, null, null, null, null, null }, + /* time */ { null, null, null, null, null, null, null, null, null, null, timeItem, null, null, dayTimeDurationItem,null, null, null, null, null, null, null }, /* hex */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, /* any-uri */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, /* base64 */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, @@ -242,7 +242,7 @@ public ItemType findCommonSuperType(ItemType other){ } } - public boolean staticallyCastableAs(ItemType other){ + public boolean staticallyCastableAs(ItemType other){ // JSON items cannot be cast from and to, nor function items, nor we can cast to atomic or item if(this.isSubtypeOf(JSONItem) || other.isSubtypeOf(JSONItem) || this.equals(functionItem) || other.equals(functionItem) || other.equals(atomicItem) || other.equals(item)) return false; From dbad0bf956729571a7105e004c9fe2d8045e924c Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 19 Oct 2020 19:12:59 +0200 Subject: [PATCH 012/206] added comparison expression type inference and utility to check if type can be promoted to string --- .../rumbledb/compiler/InferTypeVisitor.java | 59 +++++++++++++++++++ .../java/org/rumbledb/types/ItemType.java | 5 ++ 2 files changed, 64 insertions(+) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index eee6b9157e..f53a8f6575 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -10,6 +10,7 @@ import org.rumbledb.expressions.arithmetic.AdditiveExpression; import org.rumbledb.expressions.arithmetic.MultiplicativeExpression; import org.rumbledb.expressions.arithmetic.UnaryExpression; +import org.rumbledb.expressions.comparison.ComparisonExpression; import org.rumbledb.expressions.logic.AndExpression; import org.rumbledb.expressions.logic.NotExpression; import org.rumbledb.expressions.logic.OrExpression; @@ -458,4 +459,62 @@ public Void visitNotExpr(NotExpression expression, Void argument) { } // endregion + + // region comparison + + @Override + public Void visitComparisonExpr(ComparisonExpression expression, Void argument) { + visitDescendants(expression, argument); + + List childrenExpressions = expression.getChildren(); + SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); + SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); + + if(leftInferredType == null || rightInferredType == null){ + throw new UnexpectedStaticTypeException("A child expression of a ComparisonExpression has no inferred type"); + } + + ComparisonExpression.ComparisonOperator operator = expression.getComparisonOperator(); + + // for value comparison arities * and + are not allowed, also if one return the empty sequence for sure throw XPST0005 error + if(operator.isValueComparison()){ + if(leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + if(resolveArities(leftInferredType.getArity(), rightInferredType.getArity()) == null){ + throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for this comparison operator: " + operator); + } + } + + ItemType leftItemType = leftInferredType.getItemType(); + ItemType rightItemType = rightInferredType.getItemType(); + + // Type must be a strict subtype of atomic + if(!leftItemType.isSubtypeOf(ItemType.atomicItem) || !rightItemType.isSubtypeOf(ItemType.atomicItem) || leftItemType.equals(ItemType.atomicItem) || rightItemType.equals(ItemType.atomicItem)){ + throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types"); + } + + // Type must match exactly or be both numeric or both promotable to string + if(!leftItemType.equals(rightItemType) && + !(leftItemType.isNumeric() && rightItemType.isNumeric()) && + !(leftItemType.canBePromotedToString() && rightItemType.canBePromotedToString())){ + // TODO: how to deal with duration + throw new UnexpectedStaticTypeException("It is not possible to compare these types: " + leftItemType + " and " + rightItemType); + } + + // Inequality is not defined for hexBinary and base64binary + if((operator != ComparisonExpression.ComparisonOperator.VC_EQ || + operator != ComparisonExpression.ComparisonOperator.VC_NE || + operator != ComparisonExpression.ComparisonOperator.GC_EQ || + operator != ComparisonExpression.ComparisonOperator.GC_NE) && ( + leftItemType.equals(ItemType.hexBinaryItem) || leftItemType.equals(ItemType.base64BinaryItem) + )){ + throw new UnexpectedStaticTypeException("It is not possible to compare these types: " + leftItemType + " " + operator + " " + rightItemType); + } + + expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + return argument; + } + + // endregion } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 20fc6da94c..5b00c78f28 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -301,6 +301,11 @@ public boolean isNumeric(){ return this.equals(integerItem) || this.equals(decimalItem) || this.equals(doubleItem); } + // returns [true] if this can be promoted to string + public boolean canBePromotedToString(){ + return this.equals(stringItem) || this.equals(anyURIItem); + } + @Override public String toString() { return this.name; From 3eccd990feb6aae1a7d3b86be7c53fbcae12ac7d Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 21 Oct 2020 17:07:04 +0200 Subject: [PATCH 013/206] added configuration to static context --- src/main/java/org/rumbledb/api/Rumble.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/api/Rumble.java b/src/main/java/org/rumbledb/api/Rumble.java index c5308a2af7..dc7ec4bbba 100644 --- a/src/main/java/org/rumbledb/api/Rumble.java +++ b/src/main/java/org/rumbledb/api/Rumble.java @@ -43,7 +43,7 @@ public Rumble(RumbleRuntimeConfiguration configuration) { public SequenceOfItems runQuery(String query) { MainModule mainModule = VisitorHelpers.parseMainModuleFromQuery( query, - RumbleRuntimeConfiguration.getDefaultConfiguration() + this.configuration ); DynamicContext dynamicContext = VisitorHelpers.createDynamicContext(mainModule, this.configuration); RuntimeIterator iterator = VisitorHelpers.generateRuntimeIterator( From f0f0b9789043ad0abbc6a378d1403c7bb3904da8 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 21 Oct 2020 17:13:57 +0200 Subject: [PATCH 014/206] completed primary expressions and added subtypeOfOrCanBePromotedTo function to SequenceItem --- .../rumbledb/compiler/InferTypeVisitor.java | 85 ++++++++++++++++++- .../java/org/rumbledb/types/SequenceType.java | 13 +++ 2 files changed, 95 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index f53a8f6575..9207c44dd1 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1,7 +1,11 @@ package org.rumbledb.compiler; import org.rumbledb.config.RumbleRuntimeConfiguration; +import org.rumbledb.context.BuiltinFunction; +import org.rumbledb.context.BuiltinFunctionCatalogue; +import org.rumbledb.context.Name; import org.rumbledb.errorcodes.ErrorCode; +import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedStaticTypeException; import org.rumbledb.expressions.AbstractNodeVisitor; import org.rumbledb.expressions.CommaExpression; @@ -166,6 +170,75 @@ public Void visitObjectConstructor(ObjectConstructorExpression expression, Void return argument; } + @Override + public Void visitContextExpr(ContextItemExpression expression, Void argument) { + // Context item not available at static time + expression.setInferredSequenceType(new SequenceType(ItemType.item)); + System.out.println("Visited context expression"); + return argument; + } + + @Override + public Void visitInlineFunctionExpr(InlineFunctionExpression expression, Void argument) { + visitDescendants(expression, argument); + expression.setInferredSequenceType(new SequenceType(ItemType.functionItem)); + System.out.println("Visited inline function expression"); + return argument; + } + + @Override + public Void visitNamedFunctionRef(NamedFunctionReferenceExpression expression, Void argument) { + visitDescendants(expression, argument); + expression.setInferredSequenceType(new SequenceType(ItemType.functionItem)); + System.out.println("Visited named function expression"); + return argument; + } + + @Override + public Void visitFunctionCall(FunctionCallExpression expression, Void argument) { + visitDescendants(expression, argument); + + BuiltinFunction function = null; + try { + function = BuiltinFunctionCatalogue.getBuiltinFunction(expression.getFunctionIdentifier()); + } catch (OurBadException exception){ + // TODO: where can i find all available functions in the static context + } + + if(function == null){ + throw new UnexpectedStaticTypeException("Function " + expression.getFunctionIdentifier() + " is not available"); + } + + List parameterExpressions = expression.getArguments(); + List parameterTypes = function.getSignature().getParameterTypes(); + int paramsLength = parameterExpressions.size(); + + for(int i = 0; i < paramsLength; ++i){ + if(parameterExpressions.get(i) != null){ + SequenceType actualType = parameterExpressions.get(i).getInferredSequenceType(); + SequenceType expectedType = parameterTypes.get(i); + // check actual parameters is either a subtype of or can be promoted to expected type + // TODO: should i consider automatic prmotion as valid or not + if(!actualType.isSubtypeOfOrCanBePromotedTo(expectedType)){ + throw new UnexpectedStaticTypeException("Argument " + i + " requires " + expectedType + " but " + actualType + " was found"); + } + } + } + + if(expression.isPartialApplication()){ + expression.setInferredSequenceType(new SequenceType(ItemType.functionItem)); + } else { + SequenceType returnType = function.getSignature().getReturnType(); + if(returnType == null){ + returnType = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; + } + expression.setInferredSequenceType(returnType); + } + + System.out.println("Visited static function call, set type to " + expression.getInferredSequenceType()); + return argument; + } + // endregion // region typing @@ -503,9 +576,9 @@ public Void visitComparisonExpr(ComparisonExpression expression, Void argument) } // Inequality is not defined for hexBinary and base64binary - if((operator != ComparisonExpression.ComparisonOperator.VC_EQ || - operator != ComparisonExpression.ComparisonOperator.VC_NE || - operator != ComparisonExpression.ComparisonOperator.GC_EQ || + if((operator != ComparisonExpression.ComparisonOperator.VC_EQ && + operator != ComparisonExpression.ComparisonOperator.VC_NE && + operator != ComparisonExpression.ComparisonOperator.GC_EQ && operator != ComparisonExpression.ComparisonOperator.GC_NE) && ( leftItemType.equals(ItemType.hexBinaryItem) || leftItemType.equals(ItemType.base64BinaryItem) )){ @@ -516,5 +589,11 @@ public Void visitComparisonExpr(ComparisonExpression expression, Void argument) return argument; } + // endregion + + // region control + + + // endregion } diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index a78b507069..8dfae2ebcb 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -84,6 +84,19 @@ public boolean isSubtypeOf(SequenceType superType) { this.isAritySubtypeOf(superType.arity); } + // keep in consideration also automatic promotion of integer > decimal > double and anyURI > string + public boolean isSubtypeOfOrCanBePromotedTo(SequenceType superType) { + if (this.isEmptySequence) { + return superType.arity == Arity.OneOrZero || superType.arity == Arity.ZeroOrMore; + } + return this.isAritySubtypeOf(superType.arity) && ( + this.itemType.isSubtypeOf(superType.getItemType()) || + (this.itemType.canBePromotedToString() && superType.itemType.equals(ItemType.stringItem)) || + (this.itemType.isNumeric() && superType.itemType.equals(ItemType.doubleItem)) || + (this.itemType.equals(ItemType.integerItem) && superType.itemType.equals(ItemType.decimalItem)) + ); + } + // check if the arity of a sequence type is subtype of another arity, assume [this] is a non-empty sequence public boolean isAritySubtypeOf(Arity superArity){ if(superArity == Arity.ZeroOrMore || superArity == this.arity) From 55b3d71b028409585fdedc599bd9c04b5cf93b10 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Fri, 23 Oct 2020 16:24:47 +0200 Subject: [PATCH 015/206] InferTypeVisitor now use StaticContext instead of Void as argument to have access to it --- .../rumbledb/compiler/InferTypeVisitor.java | 55 ++++++++++--------- .../org/rumbledb/compiler/VisitorHelpers.java | 4 +- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 9207c44dd1..f22b525b9b 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -4,6 +4,7 @@ import org.rumbledb.context.BuiltinFunction; import org.rumbledb.context.BuiltinFunctionCatalogue; import org.rumbledb.context.Name; +import org.rumbledb.context.StaticContext; import org.rumbledb.errorcodes.ErrorCode; import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedStaticTypeException; @@ -31,7 +32,7 @@ /** * This visitor infers a static SequenceType for each expression in the query */ -public class InferTypeVisitor extends AbstractNodeVisitor { +public class InferTypeVisitor extends AbstractNodeVisitor { private RumbleRuntimeConfiguration rumbleRuntimeConfiguration; @@ -45,7 +46,7 @@ public class InferTypeVisitor extends AbstractNodeVisitor { } @Override - public Void visitCommaExpression(CommaExpression expression, Void argument) { + public StaticContext visitCommaExpression(CommaExpression expression, StaticContext argument) { visitDescendants(expression, argument); SequenceType inferredType = SequenceType.EMPTY_SEQUENCE; @@ -81,49 +82,49 @@ public Void visitCommaExpression(CommaExpression expression, Void argument) { // region primary @Override - public Void visitString(StringLiteralExpression expression, Void argument){ + public StaticContext visitString(StringLiteralExpression expression, StaticContext argument){ System.out.println("visiting String literal"); expression.setInferredSequenceType(new SequenceType(ItemType.stringItem)); return argument; } @Override - public Void visitInteger(IntegerLiteralExpression expression, Void argument) { + public StaticContext visitInteger(IntegerLiteralExpression expression, StaticContext argument) { System.out.println("visiting Int literal"); expression.setInferredSequenceType(new SequenceType(ItemType.integerItem)); return argument; } @Override - public Void visitDouble(DoubleLiteralExpression expression, Void argument) { + public StaticContext visitDouble(DoubleLiteralExpression expression, StaticContext argument) { System.out.println("visiting Double literal"); expression.setInferredSequenceType(new SequenceType(ItemType.doubleItem)); return argument; } @Override - public Void visitDecimal(DecimalLiteralExpression expression, Void argument) { + public StaticContext visitDecimal(DecimalLiteralExpression expression, StaticContext argument) { System.out.println("visiting Decimal literal"); expression.setInferredSequenceType(new SequenceType(ItemType.decimalItem)); return argument; } @Override - public Void visitNull(NullLiteralExpression expression, Void argument) { + public StaticContext visitNull(NullLiteralExpression expression, StaticContext argument) { System.out.println("visiting Null literal"); expression.setInferredSequenceType(new SequenceType(ItemType.nullItem)); return argument; } @Override - public Void visitBoolean(BooleanLiteralExpression expression, Void argument) { + public StaticContext visitBoolean(BooleanLiteralExpression expression, StaticContext argument) { System.out.println("visiting Boolean literal"); expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); return argument; } @Override - public Void visitVariableReference(VariableReferenceExpression expression, Void argument) { + public StaticContext visitVariableReference(VariableReferenceExpression expression, StaticContext argument) { SequenceType variableType = expression.getType(); if(variableType == null){ System.out.println("variable reference type was null so"); @@ -135,7 +136,7 @@ public Void visitVariableReference(VariableReferenceExpression expression, Void } @Override - public Void visitArrayConstructor(ArrayConstructorExpression expression, Void argument) { + public StaticContext visitArrayConstructor(ArrayConstructorExpression expression, StaticContext argument) { System.out.println("visiting Array constructor literal"); visitDescendants(expression, argument); expression.setInferredSequenceType(new SequenceType(ItemType.arrayItem)); @@ -143,7 +144,7 @@ public Void visitArrayConstructor(ArrayConstructorExpression expression, Void ar } @Override - public Void visitObjectConstructor(ObjectConstructorExpression expression, Void argument) { + public StaticContext visitObjectConstructor(ObjectConstructorExpression expression, StaticContext argument) { System.out.println("visiting Object constructor literal"); visitDescendants(expression, argument); if(expression.isMergedConstructor()){ @@ -171,7 +172,7 @@ public Void visitObjectConstructor(ObjectConstructorExpression expression, Void } @Override - public Void visitContextExpr(ContextItemExpression expression, Void argument) { + public StaticContext visitContextExpr(ContextItemExpression expression, StaticContext argument) { // Context item not available at static time expression.setInferredSequenceType(new SequenceType(ItemType.item)); System.out.println("Visited context expression"); @@ -179,7 +180,7 @@ public Void visitContextExpr(ContextItemExpression expression, Void argument) { } @Override - public Void visitInlineFunctionExpr(InlineFunctionExpression expression, Void argument) { + public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression, StaticContext argument) { visitDescendants(expression, argument); expression.setInferredSequenceType(new SequenceType(ItemType.functionItem)); System.out.println("Visited inline function expression"); @@ -187,7 +188,7 @@ public Void visitInlineFunctionExpr(InlineFunctionExpression expression, Void ar } @Override - public Void visitNamedFunctionRef(NamedFunctionReferenceExpression expression, Void argument) { + public StaticContext visitNamedFunctionRef(NamedFunctionReferenceExpression expression, StaticContext argument) { visitDescendants(expression, argument); expression.setInferredSequenceType(new SequenceType(ItemType.functionItem)); System.out.println("Visited named function expression"); @@ -195,7 +196,7 @@ public Void visitNamedFunctionRef(NamedFunctionReferenceExpression expression, V } @Override - public Void visitFunctionCall(FunctionCallExpression expression, Void argument) { + public StaticContext visitFunctionCall(FunctionCallExpression expression, StaticContext argument) { visitDescendants(expression, argument); BuiltinFunction function = null; @@ -244,7 +245,7 @@ public Void visitFunctionCall(FunctionCallExpression expression, Void argument) // region typing @Override - public Void visitCastableExpression(CastableExpression expression, Void argument) { + public StaticContext visitCastableExpression(CastableExpression expression, StaticContext argument) { System.out.println("visiting Castable expression"); visitDescendants(expression, argument); expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); @@ -252,7 +253,7 @@ public Void visitCastableExpression(CastableExpression expression, Void argument } @Override - public Void visitCastExpression(CastExpression expression, Void argument) { + public StaticContext visitCastExpression(CastExpression expression, StaticContext argument) { System.out.println("visiting Cast expression"); visitDescendants(expression, argument); @@ -285,7 +286,7 @@ public Void visitCastExpression(CastExpression expression, Void argument) { } @Override - public Void visitInstanceOfExpression(InstanceOfExpression expression, Void argument) { + public StaticContext visitInstanceOfExpression(InstanceOfExpression expression, StaticContext argument) { System.out.println("visiting InstanceOf expression"); visitDescendants(expression, argument); expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); @@ -293,7 +294,7 @@ public Void visitInstanceOfExpression(InstanceOfExpression expression, Void argu } @Override - public Void visitTreatExpression(TreatExpression expression, Void argument) { + public StaticContext visitTreatExpression(TreatExpression expression, StaticContext argument) { System.out.println("visiting Treat expression"); visitDescendants(expression, argument); @@ -314,7 +315,7 @@ public Void visitTreatExpression(TreatExpression expression, Void argument) { // region arithmetic @Override - public Void visitAdditiveExpr(AdditiveExpression expression, Void argument) { + public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticContext argument) { visitDescendants(expression, argument); List childrenExpressions = expression.getChildren(); @@ -379,7 +380,7 @@ private SequenceType.Arity resolveArities(SequenceType.Arity left, SequenceType. } @Override - public Void visitMultiplicativeExpr(MultiplicativeExpression expression, Void argument) { + public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression, StaticContext argument) { visitDescendants(expression, argument); List childrenExpressions = expression.getChildren(); @@ -445,7 +446,7 @@ public Void visitMultiplicativeExpr(MultiplicativeExpression expression, Void ar } @Override - public Void visitUnaryExpr(UnaryExpression expression, Void argument) { + public StaticContext visitUnaryExpr(UnaryExpression expression, StaticContext argument) { visitDescendants(expression, argument); SequenceType childInferredType = expression.getMainExpression().getInferredSequenceType(); @@ -482,7 +483,7 @@ public Void visitUnaryExpr(UnaryExpression expression, Void argument) { // region logic - private Void visitAndOrExpr(Expression expression, Void argument, String expressionName){ + private StaticContext visitAndOrExpr(Expression expression, StaticContext argument, String expressionName){ visitDescendants(expression, argument); List childrenExpressions = expression.getChildren(); @@ -506,17 +507,17 @@ private Void visitAndOrExpr(Expression expression, Void argument, String express } @Override - public Void visitAndExpr(AndExpression expression, Void argument) { + public StaticContext visitAndExpr(AndExpression expression, StaticContext argument) { return visitAndOrExpr(expression, argument, "And"); } @Override - public Void visitOrExpr(OrExpression expression, Void argument) { + public StaticContext visitOrExpr(OrExpression expression, StaticContext argument) { return visitAndOrExpr(expression, argument, "Or"); } @Override - public Void visitNotExpr(NotExpression expression, Void argument) { + public StaticContext visitNotExpr(NotExpression expression, StaticContext argument) { visitDescendants(expression, argument); SequenceType childInferredType = expression.getMainExpression().getInferredSequenceType(); @@ -536,7 +537,7 @@ public Void visitNotExpr(NotExpression expression, Void argument) { // region comparison @Override - public Void visitComparisonExpr(ComparisonExpression expression, Void argument) { + public StaticContext visitComparisonExpr(ComparisonExpression expression, StaticContext argument) { visitDescendants(expression, argument); List childrenExpressions = expression.getChildren(); diff --git a/src/main/java/org/rumbledb/compiler/VisitorHelpers.java b/src/main/java/org/rumbledb/compiler/VisitorHelpers.java index 00d9e5c91a..056d07b689 100644 --- a/src/main/java/org/rumbledb/compiler/VisitorHelpers.java +++ b/src/main/java/org/rumbledb/compiler/VisitorHelpers.java @@ -50,9 +50,9 @@ private static void pruneModules(Node node, RumbleRuntimeConfiguration conf) { new ModulePruningVisitor(conf).visit(node, null); } - private static void inferTypes(Node node, RumbleRuntimeConfiguration conf) { + private static void inferTypes(Module module, RumbleRuntimeConfiguration conf) { System.out.println("* Starting type inference *"); - new InferTypeVisitor(conf).visit(node, null); + new InferTypeVisitor(conf).visit(module, module.getStaticContext()); } private static void printTree(Module node, RumbleRuntimeConfiguration conf) { From 099221fb4ef962e010f99d3d41943930a14c28bb Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sat, 24 Oct 2020 10:19:30 +0200 Subject: [PATCH 016/206] variable declaration and reference now store null if type was not specified, but in that case it is still treated as item* or with static analysis a proper type is inferred --- .../rumbledb/compiler/InferTypeVisitor.java | 31 +++++++++++++++++-- .../compiler/StaticContextVisitor.java | 4 ++- .../rumbledb/compiler/TranslationVisitor.java | 6 ++-- .../org/rumbledb/context/StaticContext.java | 6 ++++ .../module/VariableDeclaration.java | 8 ++++- .../primary/VariableReferenceExpression.java | 5 +++ 6 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index f22b525b9b..1258c1f8fd 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -19,6 +19,7 @@ import org.rumbledb.expressions.logic.AndExpression; import org.rumbledb.expressions.logic.NotExpression; import org.rumbledb.expressions.logic.OrExpression; +import org.rumbledb.expressions.module.VariableDeclaration; import org.rumbledb.expressions.primary.*; import org.rumbledb.expressions.typing.CastExpression; import org.rumbledb.expressions.typing.CastableExpression; @@ -125,10 +126,13 @@ public StaticContext visitBoolean(BooleanLiteralExpression expression, StaticCon @Override public StaticContext visitVariableReference(VariableReferenceExpression expression, StaticContext argument) { - SequenceType variableType = expression.getType(); + SequenceType variableType = expression.getActualType(); if(variableType == null){ - System.out.println("variable reference type was null so"); - variableType = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; + // if is null, no 'as [SequenceType]' part was present in the declaration, therefore we infer it + System.out.println("variable reference type was null so we infer it"); + variableType = argument.getVariableSequenceType(expression.getVariableName()); + // we also set variableReference type + expression.setType(variableType); } System.out.println("visiting variable reference with type: " + variableType); expression.setInferredSequenceType(variableType); @@ -596,5 +600,26 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static + // endregion + + // region module + + @Override + public StaticContext visitVariableDeclaration(VariableDeclaration expression, StaticContext argument) { + // if expression has no type we infer it, and overwrite the type in the correspondent InScopeVariable + visitDescendants(expression, argument); + if(expression.getActualSequenceType() == null){ + SequenceType inferredType = expression.getExpression().getInferredSequenceType(); + if(inferredType == null){ + throw new OurBadException("The child expression of VariableDeclaration has no inferred type"); + } + // TODO: should I also change the variableDeclaration SequenceType? + argument.replaceVariableSequenceType(expression.getVariableName(), inferredType); + } + + return argument; + } + + // endregion } diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index 74bdeee3bf..9e5f4412ac 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -132,12 +132,14 @@ public StaticContext visitVariableReference(VariableReferenceExpression expressi expression.getMetadata() ); } else { + // note: sequence type can be null expression.setType(argument.getVariableSequenceType(variableName)); ExecutionMode mode = argument.getVariableStorageMode(variableName); if (this.visitorConfig.setUnsetToLocal() && mode.equals(ExecutionMode.UNSET)) { mode = ExecutionMode.LOCAL; } expression.setHighestExecutionMode(mode); + // TODO: check staticContext available return argument; } } @@ -414,7 +416,7 @@ public StaticContext visitVariableDeclaration(VariableDeclaration variableDeclar // first pass. argument.addVariable( variableDeclaration.getVariableName(), - variableDeclaration.getSequenceType(), + variableDeclaration.getActualSequenceType(), variableDeclaration.getMetadata(), variableDeclaration.getVariableHighestStorageMode(this.visitorConfig) ); diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index c16f4a44df..f5698d6338 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -1398,19 +1398,19 @@ private ExceptionMetadata createMetadataFromContext(ParserRuleContext ctx) { @Override public Node visitVarDecl(JsoniqParser.VarDeclContext ctx) { + // if there is no 'as sequenceType' is set to null to differentiate from the case of 'as item*' + // but it is actually treated as if it was item* SequenceType seq = null; boolean external; Name var = ((VariableReferenceExpression) this.visitVarRef(ctx.varRef())).getVariableName(); if (ctx.sequenceType() != null) { seq = this.processSequenceType(ctx.sequenceType()); - } else { - seq = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; } external = (ctx.external != null); Expression expr = null; if (ctx.exprSingle() != null) { expr = (Expression) this.visitExprSingle(ctx.exprSingle()); - if (!seq.equals(SequenceType.MOST_GENERAL_SEQUENCE_TYPE)) { + if (seq != null) { expr = new TreatExpression(expr, seq, ErrorCode.UnexpectedTypeErrorCode, expr.getMetadata()); } } diff --git a/src/main/java/org/rumbledb/context/StaticContext.java b/src/main/java/org/rumbledb/context/StaticContext.java index 3573bfe5ad..a3874a40c7 100644 --- a/src/main/java/org/rumbledb/context/StaticContext.java +++ b/src/main/java/org/rumbledb/context/StaticContext.java @@ -113,6 +113,12 @@ private InScopeVariable getInScopeVariable(Name varName) { } } + // replace the sequence type of an existing InScopeVariable, throws an error if the variable does not exists + public void replaceVariableSequenceType(Name varName, SequenceType newSequenceType){ + InScopeVariable variable = getInScopeVariable(varName); + this.inScopeVariables.replace(varName, new InScopeVariable(varName, newSequenceType, variable.getMetadata(), variable.getStorageMode())); + } + public SequenceType getVariableSequenceType(Name varName) { return getInScopeVariable(varName).getSequenceType(); } diff --git a/src/main/java/org/rumbledb/expressions/module/VariableDeclaration.java b/src/main/java/org/rumbledb/expressions/module/VariableDeclaration.java index 21c3dd653c..31ccbcee9e 100644 --- a/src/main/java/org/rumbledb/expressions/module/VariableDeclaration.java +++ b/src/main/java/org/rumbledb/expressions/module/VariableDeclaration.java @@ -68,7 +68,13 @@ public boolean external() { return this.external; } + // return item* if sequenceType is [null] public SequenceType getSequenceType() { + return this.sequenceType == null ? SequenceType.MOST_GENERAL_SEQUENCE_TYPE : this.sequenceType; + } + + // as above but does NOT default to item* + public SequenceType getActualSequenceType() { return this.sequenceType; } @@ -115,7 +121,7 @@ public void print(StringBuffer buffer, int indent) { + (this.variableName) + ", " + (this.external ? "external, " : "") - + this.sequenceType.toString() + + this.getSequenceType().toString() + ") " ); buffer.append(" | " + this.highestExecutionMode); diff --git a/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java b/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java index bd672882c1..7fecfc431f 100644 --- a/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java @@ -55,7 +55,12 @@ public Name getVariableName() { return this.name; } + // default to item* if type is null public SequenceType getType() { + return this.type == null ? SequenceType.MOST_GENERAL_SEQUENCE_TYPE : this.type; + } + + public SequenceType getActualType() { return this.type; } From ffb0716b7c40b7030848fa224e9e2960f759c08a Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sat, 24 Oct 2020 11:30:39 +0200 Subject: [PATCH 017/206] added flag to turn on static analysis and flag to debug type inference --- .../java/org/rumbledb/compiler/VisitorHelpers.java | 8 +++++++- .../rumbledb/config/RumbleRuntimeConfiguration.java | 10 +++++++++- .../java/org/rumbledb/expressions/Expression.java | 13 +++++++++++++ .../expressions/arithmetic/AdditiveExpression.java | 1 + .../arithmetic/MultiplicativeExpression.java | 1 + .../expressions/arithmetic/UnaryExpression.java | 1 + .../comparison/ComparisonExpression.java | 1 + .../expressions/flowr/SimpleMapExpression.java | 1 + .../postfix/DynamicFunctionCallExpression.java | 1 + .../primary/BooleanLiteralExpression.java | 1 + .../primary/DecimalLiteralExpression.java | 1 + .../primary/DoubleLiteralExpression.java | 1 + .../expressions/primary/FunctionCallExpression.java | 1 + .../primary/InlineFunctionExpression.java | 1 + .../primary/IntegerLiteralExpression.java | 1 + .../primary/NamedFunctionReferenceExpression.java | 1 + .../primary/StringLiteralExpression.java | 1 + .../primary/VariableReferenceExpression.java | 1 + .../quantifiers/QuantifiedExpression.java | 1 + .../rumbledb/expressions/typing/CastExpression.java | 1 + .../expressions/typing/CastableExpression.java | 1 + .../expressions/typing/InstanceOfExpression.java | 1 + .../expressions/typing/TreatExpression.java | 1 + 23 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/VisitorHelpers.java b/src/main/java/org/rumbledb/compiler/VisitorHelpers.java index 056d07b689..0bb51bf7e8 100644 --- a/src/main/java/org/rumbledb/compiler/VisitorHelpers.java +++ b/src/main/java/org/rumbledb/compiler/VisitorHelpers.java @@ -53,6 +53,10 @@ private static void pruneModules(Node node, RumbleRuntimeConfiguration conf) { private static void inferTypes(Module module, RumbleRuntimeConfiguration conf) { System.out.println("* Starting type inference *"); new InferTypeVisitor(conf).visit(module, module.getStaticContext()); + System.out.println("* Completed type inference *"); + if(conf.printInferredTypes()){ + printTree(module, conf); + } } private static void printTree(Module node, RumbleRuntimeConfiguration conf) { @@ -109,7 +113,9 @@ public static MainModule parseMainModule(CharStream stream, URI uri, RumbleRunti pruneModules(mainModule, configuration); resolveDependencies(mainModule, configuration); populateStaticContext(mainModule, configuration); - inferTypes(mainModule, configuration); + if(configuration.doStaticAnalysis()){ + inferTypes(mainModule, configuration); + } return mainModule; } catch (ParseCancellationException ex) { ParsingException e = new ParsingException( diff --git a/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java b/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java index a64f565ba9..95df4d7146 100644 --- a/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java +++ b/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java @@ -222,7 +222,7 @@ public int getResultSizeCap() { * Sets the number of Items that should be collected in case of a forced materialization. This applies in particular * to a local use of the ItemIterator. * - * @param cap the maximum number of Items to collect. + * @param i the maximum number of Items to collect. */ public void setResultSizeCap(int i) { this.resultsSizeCap = i; @@ -261,6 +261,14 @@ public boolean isPrintIteratorTree() { } } + public boolean doStaticAnalysis() { + return this.arguments.containsKey("static-analysis") && this.arguments.get("static-analysis").equals("yes"); + } + + public boolean printInferredTypes() { + return this.arguments.containsKey("print-inferred-types") && this.arguments.get("print-inferred-types").equals("yes"); + } + public boolean isLocal() { String masterConfig = SparkSessionManager.getInstance().getJavaSparkContext().getConf().get("spark.master"); return masterConfig.contains("local"); diff --git a/src/main/java/org/rumbledb/expressions/Expression.java b/src/main/java/org/rumbledb/expressions/Expression.java index bedef2575a..7fa24c246c 100644 --- a/src/main/java/org/rumbledb/expressions/Expression.java +++ b/src/main/java/org/rumbledb/expressions/Expression.java @@ -55,4 +55,17 @@ public void setStaticContext(StaticContext staticContext) { public SequenceType getInferredSequenceType() { return this.inferredSequenceType; } public void setInferredSequenceType(SequenceType inferredSequenceType) { this.inferredSequenceType = inferredSequenceType; } + + public void print(StringBuffer buffer, int indent) { + for (int i = 0; i < indent; ++i) { + buffer.append(" "); + } + buffer.append(getClass().getSimpleName()); + buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append("\n"); + for (Node iterator : getChildren()) { + iterator.print(buffer, indent + 1); + } + } } diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java index 2a958496c1..f6106206a4 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java @@ -67,6 +67,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.isMinus ? "-" : "+") + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java index 15db49cd6c..2bb185ce89 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java @@ -103,6 +103,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.multiplicativeOperator) + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/UnaryExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/UnaryExpression.java index 9b6bc35798..4c1ba7beeb 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/UnaryExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/UnaryExpression.java @@ -70,6 +70,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.negated ? "-" : "+") + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java b/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java index 70d6829def..887e821a17 100644 --- a/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java +++ b/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java @@ -151,6 +151,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.comparisonOperator) + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java b/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java index 045244f9f5..8d776486f3 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java +++ b/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java @@ -66,6 +66,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (!)"); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java b/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java index 2c4057eb52..f6ddb6cee9 100644 --- a/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java +++ b/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java @@ -82,6 +82,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(getClass().getSimpleName()); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Expression arg : this.arguments) { if (arg == null) { diff --git a/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java index 2d18c3d9b5..9217e226e9 100644 --- a/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java @@ -59,6 +59,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.value) + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java index 19db68308a..3f6e65705b 100644 --- a/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java @@ -60,6 +60,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.value) + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java index e19999abd0..4a7699caf6 100644 --- a/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java @@ -59,6 +59,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.value) + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java b/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java index c93add089f..ab0d02242a 100644 --- a/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java @@ -173,6 +173,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(getClass().getSimpleName()); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Expression arg : this.arguments) { if (arg == null) { diff --git a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java index 2520afa0b1..2600f94cee 100644 --- a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java @@ -118,6 +118,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(this.returnType.toString()); buffer.append(")"); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (int i = 0; i < indent + 2; ++i) { buffer.append(" "); diff --git a/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java index a1b36d94ba..e423c8d532 100644 --- a/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java @@ -59,6 +59,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.lexicalValue) + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java b/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java index 8d765bd8af..11e94d3913 100644 --- a/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java @@ -60,6 +60,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(getClass().getSimpleName()); buffer.append(" (" + this.identifier.getName() + "#" + this.identifier.getArity() + ") "); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); } } diff --git a/src/main/java/org/rumbledb/expressions/primary/StringLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/StringLiteralExpression.java index 5ad3b3653c..14a6c44e75 100644 --- a/src/main/java/org/rumbledb/expressions/primary/StringLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/StringLiteralExpression.java @@ -60,6 +60,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.value) + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java b/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java index 7fecfc431f..1f47e088f2 100644 --- a/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java @@ -92,6 +92,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" ($" + this.name + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpression.java b/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpression.java index e10435db02..c84619bec9 100644 --- a/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpression.java +++ b/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpression.java @@ -94,6 +94,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(")"); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/typing/CastExpression.java b/src/main/java/org/rumbledb/expressions/typing/CastExpression.java index 63fdd0861e..16e654d111 100644 --- a/src/main/java/org/rumbledb/expressions/typing/CastExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/CastExpression.java @@ -55,6 +55,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.sequenceType.toString()) + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java b/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java index 653169cd3d..a8bd337234 100644 --- a/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java @@ -55,6 +55,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.sequenceType.toString()) + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java b/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java index 19c39a1eeb..e15dbcf3ed 100644 --- a/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java @@ -74,6 +74,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.sequenceType.toString()) + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/typing/TreatExpression.java b/src/main/java/org/rumbledb/expressions/typing/TreatExpression.java index b81218f3a0..dad1ffa1d8 100644 --- a/src/main/java/org/rumbledb/expressions/typing/TreatExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/TreatExpression.java @@ -93,6 +93,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.sequenceType.toString()) + ") "); buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); From bb87d83324f4b9589cbab7a5f4ac85d99250d456 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sat, 24 Oct 2020 15:05:34 +0200 Subject: [PATCH 018/206] small correction for context and comparison expression and to effective boolean value calculation --- .../rumbledb/compiler/InferTypeVisitor.java | 23 +++++++++++-------- .../org/rumbledb/context/StaticContext.java | 13 +++++++++++ .../java/org/rumbledb/types/SequenceType.java | 5 ++-- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 1258c1f8fd..86f665f937 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -130,7 +130,7 @@ public StaticContext visitVariableReference(VariableReferenceExpression expressi if(variableType == null){ // if is null, no 'as [SequenceType]' part was present in the declaration, therefore we infer it System.out.println("variable reference type was null so we infer it"); - variableType = argument.getVariableSequenceType(expression.getVariableName()); + variableType = expression.getStaticContext().getVariableSequenceType(expression.getVariableName()); // we also set variableReference type expression.setType(variableType); } @@ -177,9 +177,12 @@ public StaticContext visitObjectConstructor(ObjectConstructorExpression expressi @Override public StaticContext visitContextExpr(ContextItemExpression expression, StaticContext argument) { - // Context item not available at static time - expression.setInferredSequenceType(new SequenceType(ItemType.item)); - System.out.println("Visited context expression"); + SequenceType contextType = expression.getStaticContext().getContextItemStaticType(); + if(contextType == null){ + contextType = new SequenceType(ItemType.item); + } + expression.setInferredSequenceType(contextType); + System.out.println("Visited context expression, set type: " + contextType); return argument; } @@ -572,20 +575,22 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types"); } - // Type must match exactly or be both numeric or both promotable to string + // Type must match exactly or be both numeric or both promotable to string or both durations if(!leftItemType.equals(rightItemType) && !(leftItemType.isNumeric() && rightItemType.isNumeric()) && + !(leftItemType.isSubtypeOf(ItemType.durationItem) && rightItemType.isSubtypeOf(ItemType.durationItem)) && !(leftItemType.canBePromotedToString() && rightItemType.canBePromotedToString())){ - // TODO: how to deal with duration throw new UnexpectedStaticTypeException("It is not possible to compare these types: " + leftItemType + " and " + rightItemType); } - // Inequality is not defined for hexBinary and base64binary + // Inequality is not defined for hexBinary and base64binary or for duration of different types if((operator != ComparisonExpression.ComparisonOperator.VC_EQ && operator != ComparisonExpression.ComparisonOperator.VC_NE && operator != ComparisonExpression.ComparisonOperator.GC_EQ && operator != ComparisonExpression.ComparisonOperator.GC_NE) && ( - leftItemType.equals(ItemType.hexBinaryItem) || leftItemType.equals(ItemType.base64BinaryItem) + leftItemType.equals(ItemType.hexBinaryItem) || leftItemType.equals(ItemType.base64BinaryItem) || + leftItemType.equals(ItemType.durationItem) || rightItemType.equals(ItemType.durationItem) || + ((leftItemType.equals(ItemType.dayTimeDurationItem) || leftItemType.equals(ItemType.yearMonthDurationItem)) && !rightItemType.equals(leftItemType)) )){ throw new UnexpectedStaticTypeException("It is not possible to compare these types: " + leftItemType + " " + operator + " " + rightItemType); } @@ -613,13 +618,11 @@ public StaticContext visitVariableDeclaration(VariableDeclaration expression, St if(inferredType == null){ throw new OurBadException("The child expression of VariableDeclaration has no inferred type"); } - // TODO: should I also change the variableDeclaration SequenceType? argument.replaceVariableSequenceType(expression.getVariableName(), inferredType); } return argument; } - // endregion } diff --git a/src/main/java/org/rumbledb/context/StaticContext.java b/src/main/java/org/rumbledb/context/StaticContext.java index a3874a40c7..6bb4a432eb 100644 --- a/src/main/java/org/rumbledb/context/StaticContext.java +++ b/src/main/java/org/rumbledb/context/StaticContext.java @@ -47,6 +47,8 @@ public class StaticContext implements Serializable, KryoSerializable { private StaticContext parent; private URI staticBaseURI; private boolean emptySequenceOrderLeast; + // TODO: should this be transient? + private transient SequenceType contextItemStaticType; public StaticContext() { this.parent = null; @@ -54,6 +56,7 @@ public StaticContext() { this.inScopeVariables = null; this.userDefinedFunctionExecutionModes = null; this.emptySequenceOrderLeast = true; + this.contextItemStaticType = null; } public StaticContext(URI staticBaseURI) { @@ -62,12 +65,14 @@ public StaticContext(URI staticBaseURI) { this.inScopeVariables = new HashMap<>(); this.userDefinedFunctionExecutionModes = null; this.emptySequenceOrderLeast = true; + this.contextItemStaticType = null; } public StaticContext(StaticContext parent) { this.parent = parent; this.inScopeVariables = new HashMap<>(); this.userDefinedFunctionExecutionModes = null; + this.contextItemStaticType = null; } public StaticContext getParent() { @@ -265,4 +270,12 @@ public StaticContext getModuleContext() { } return this; } + + public SequenceType getContextItemStaticType() { + return contextItemStaticType; + } + + public void setContextItemStaticType(SequenceType contextItemStaticType) { + this.contextItemStaticType = contextItemStaticType; + } } diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index 8dfae2ebcb..ab153537a5 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -106,10 +106,11 @@ public boolean isAritySubtypeOf(Arity superArity){ } public boolean hasEffectiveBooleanValue(){ - if(this.isEmptySequence){ + if(this.isEmptySequence) { + return true; + } else if(this.itemType.isSubtypeOf(ItemType.JSONItem) || this.itemType.equals(ItemType.item)) { return true; } else if((this.arity == Arity.One || this.arity == Arity.OneOrZero) && ( - this.itemType.isSubtypeOf(ItemType.JSONItem) || this.itemType.isNumeric() || this.itemType.equals(ItemType.stringItem) || this.itemType.equals(ItemType.anyURIItem) || From 3a3c69714ad843d44361fe45eb50519a10e67f46 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sat, 24 Oct 2020 23:49:33 +0200 Subject: [PATCH 019/206] visited trycatch, conditional and typeswitch expressions, added leastCommonSupertypeWith in Sequence type --- .../rumbledb/compiler/InferTypeVisitor.java | 104 ++++++++++++++++++ .../java/org/rumbledb/types/SequenceType.java | 35 ++++++ 2 files changed, 139 insertions(+) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 86f665f937..57fffb5aa9 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -16,6 +16,10 @@ import org.rumbledb.expressions.arithmetic.MultiplicativeExpression; import org.rumbledb.expressions.arithmetic.UnaryExpression; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.expressions.control.ConditionalExpression; +import org.rumbledb.expressions.control.TryCatchExpression; +import org.rumbledb.expressions.control.TypeSwitchExpression; +import org.rumbledb.expressions.control.TypeswitchCase; import org.rumbledb.expressions.logic.AndExpression; import org.rumbledb.expressions.logic.NotExpression; import org.rumbledb.expressions.logic.OrExpression; @@ -603,7 +607,107 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static // region control + @Override + public StaticContext visitConditionalExpression(ConditionalExpression expression, StaticContext argument) { + visitDescendants(expression, argument); + + SequenceType ifType = expression.getCondition().getInferredSequenceType(); + SequenceType thenType = expression.getBranch().getInferredSequenceType(); + SequenceType elseType = expression.getElseBranch().getInferredSequenceType(); + + if(ifType == null || thenType == null || elseType == null){ + throw new OurBadException("A child expression of a ConditionalExpression has no inferred type"); + } + + if(!ifType.hasEffectiveBooleanValue()){ + throw new UnexpectedStaticTypeException("The condition in the 'if' must have effective boolean value, found inferred type: " + ifType + " (which has not effective boolean value)"); + } + + if(thenType.isEmptySequence() && elseType.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + + expression.setInferredSequenceType(thenType.leastCommonSupertypeWith(elseType)); + System.out.println("visiting Conditional expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + + @Override + public StaticContext visitTryCatchExpression(TryCatchExpression expression, StaticContext argument) { + visitDescendants(expression, argument); + SequenceType inferredType = null; + + for(Node childNode : expression.getChildren()){ + SequenceType childType = ((Expression) childNode).getInferredSequenceType(); + if(childType == null){ + throw new OurBadException("A child expression of a TryCatchExpression has no inferred type"); + } + + if(inferredType == null){ + inferredType = childType; + } else { + inferredType = inferredType.leastCommonSupertypeWith(childType); + } + } + + if(inferredType.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + expression.setInferredSequenceType(inferredType); + System.out.println("visiting TryCatch expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + + @Override + public StaticContext visitTypeSwitchExpression(TypeSwitchExpression expression, StaticContext argument) { + visit(expression.getTestCondition(), argument); + SequenceType inferredType = null; + + SequenceType conditionType = expression.getTestCondition().getInferredSequenceType(); + if(conditionType == null){ + throw new OurBadException("A child expression of a TypeSwitchExpression has no inferred type"); + } + + for(TypeswitchCase typeswitchCase : expression.getCases()){ + Name variableName = typeswitchCase.getVariableName(); + Expression returnExpression = typeswitchCase.getReturnExpression(); + // if we bind a variable we add the static type of it in the context of the return expression + if(variableName != null){ + SequenceType variableType = null; + for(SequenceType st : typeswitchCase.getUnion()){ + variableType = variableType == null ? st : variableType.leastCommonSupertypeWith(st); + } + returnExpression.getStaticContext().replaceVariableSequenceType(variableName, variableType); + } + visit(returnExpression, argument); + SequenceType caseType = returnExpression.getInferredSequenceType(); + if(caseType == null){ + throw new OurBadException("A child expression of a TypeSwitchExpression has no inferred type"); + } + inferredType = inferredType == null ? caseType : inferredType.leastCommonSupertypeWith(caseType); + } + + Name variableName = expression.getDefaultCase().getVariableName(); + Expression returnExpression = expression.getDefaultCase().getReturnExpression(); + // if we bind a variable in the default case, we infer testCondition type + if(variableName != null){ + returnExpression.getStaticContext().replaceVariableSequenceType(variableName, conditionType); + } + visit(returnExpression, argument); + SequenceType defaultType = returnExpression.getInferredSequenceType(); + if(defaultType == null){ + throw new OurBadException("A child expression of a TypeSwitchExpression has no inferred type"); + } + inferredType = inferredType.leastCommonSupertypeWith(defaultType); + + if(inferredType.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + expression.setInferredSequenceType(inferredType); + System.out.println("visiting TypeSwitch expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } // endregion diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index ab153537a5..11c1a96ef5 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -122,6 +122,41 @@ public boolean hasEffectiveBooleanValue(){ } } + public SequenceType leastCommonSupertypeWith(SequenceType other){ + if(this.isEmptySequence){ + if(other.isEmptySequence()){ + return this; + } else { + Arity resultingArity = other.getArity(); + if(resultingArity == Arity.One){ + resultingArity = Arity.OneOrZero; + } else if(resultingArity == Arity.OneOrMore){ + resultingArity = Arity.ZeroOrMore; + } + return new SequenceType(other.itemType, resultingArity); + } + } + if(other.isEmptySequence()){ + Arity resultingArity = this.getArity(); + if(resultingArity == Arity.One){ + resultingArity = Arity.OneOrZero; + } else if(resultingArity == Arity.OneOrMore){ + resultingArity = Arity.ZeroOrMore; + } + return new SequenceType(this.itemType, resultingArity); + } + + ItemType itemSupertype = this.getItemType().findCommonSuperType(other.getItemType()); + Arity aritySuperType = Arity.ZeroOrMore; + if(this.isAritySubtypeOf(other.getArity())){ + aritySuperType = other.getArity(); + } else if(other.isAritySubtypeOf(this.getArity())){ + aritySuperType = this.getArity(); + } + // no need additional check because the only disjointed arity are ? and +, which least common supertype is * + return new SequenceType(itemSupertype, aritySuperType); + } + @Override public boolean equals(Object other) { if (!(other instanceof SequenceType)) { From f4bfdf14deecda58f684d2ab55b5748f8a7fb953 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 25 Oct 2020 09:21:32 +0100 Subject: [PATCH 020/206] added range and concat expression, fixed warning for unqualified access in static context --- .../rumbledb/compiler/InferTypeVisitor.java | 54 +++++++++++++++++++ .../org/rumbledb/context/StaticContext.java | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 57fffb5aa9..96d94c5f0d 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -23,6 +23,8 @@ import org.rumbledb.expressions.logic.AndExpression; import org.rumbledb.expressions.logic.NotExpression; import org.rumbledb.expressions.logic.OrExpression; +import org.rumbledb.expressions.miscellaneous.RangeExpression; +import org.rumbledb.expressions.miscellaneous.StringConcatExpression; import org.rumbledb.expressions.module.VariableDeclaration; import org.rumbledb.expressions.primary.*; import org.rumbledb.expressions.typing.CastExpression; @@ -711,6 +713,58 @@ public StaticContext visitTypeSwitchExpression(TypeSwitchExpression expression, // endregion + // region miscellaneous + + @Override + public StaticContext visitRangeExpr(RangeExpression expression, StaticContext argument) { + visitDescendants(expression, argument); + + List children = expression.getChildren(); + SequenceType leftType = ((Expression) children.get(0)).getInferredSequenceType(); + SequenceType rightType = ((Expression) children.get(1)).getInferredSequenceType(); + + if(leftType == null || rightType == null){ + throw new OurBadException("A child expression of a RangeExpression has no inferred type"); + } + + if(leftType.isEmptySequence() || rightType.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + + SequenceType intOpt = new SequenceType(ItemType.integerItem, SequenceType.Arity.OneOrZero); + if(!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)){ + throw new UnexpectedStaticTypeException("operands of the range expression must match type integer? instead found: " + leftType + " and " + rightType); + } + + expression.setInferredSequenceType(new SequenceType(ItemType.integerItem, SequenceType.Arity.ZeroOrMore)); + System.out.println("visiting Range expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + + @Override + public StaticContext visitStringConcatExpr(StringConcatExpression expression, StaticContext argument) { + visitDescendants(expression, argument); + + List children = expression.getChildren(); + SequenceType leftType = ((Expression) children.get(0)).getInferredSequenceType(); + SequenceType rightType = ((Expression) children.get(1)).getInferredSequenceType(); + + if(leftType == null || rightType == null){ + throw new OurBadException("A child expression of a ConcatExpression has no inferred type"); + } + + SequenceType intOpt = new SequenceType(ItemType.atomicItem, SequenceType.Arity.OneOrZero); + if(!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)){ + throw new UnexpectedStaticTypeException("operands of the concat expression must match type atomic? instead found: " + leftType + " and " + rightType); + } + + expression.setInferredSequenceType(new SequenceType(ItemType.stringItem)); + System.out.println("visiting Concat expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + + // endregion + // region module @Override diff --git a/src/main/java/org/rumbledb/context/StaticContext.java b/src/main/java/org/rumbledb/context/StaticContext.java index 6bb4a432eb..ef98e1e1e3 100644 --- a/src/main/java/org/rumbledb/context/StaticContext.java +++ b/src/main/java/org/rumbledb/context/StaticContext.java @@ -272,7 +272,7 @@ public StaticContext getModuleContext() { } public SequenceType getContextItemStaticType() { - return contextItemStaticType; + return this.contextItemStaticType; } public void setContextItemStaticType(SequenceType contextItemStaticType) { From b73fea7ec54d445df52fdc48f69401229266e3c0 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 25 Oct 2020 10:46:14 +0100 Subject: [PATCH 021/206] added quantified expression, now translation visitor set null in the clause when type is not present and the same does the staticContext visitor for the inscope variables of evaluation context, for all other purposes if no type is specified item is still assumed instead of item* --- .../rumbledb/compiler/InferTypeVisitor.java | 50 +++++++++++++++++++ .../compiler/StaticContextVisitor.java | 2 +- .../rumbledb/compiler/TranslationVisitor.java | 2 - .../quantifiers/QuantifiedExpressionVar.java | 6 +++ 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 96d94c5f0d..a41f39d0a0 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -27,6 +27,8 @@ import org.rumbledb.expressions.miscellaneous.StringConcatExpression; import org.rumbledb.expressions.module.VariableDeclaration; import org.rumbledb.expressions.primary.*; +import org.rumbledb.expressions.quantifiers.QuantifiedExpression; +import org.rumbledb.expressions.quantifiers.QuantifiedExpressionVar; import org.rumbledb.expressions.typing.CastExpression; import org.rumbledb.expressions.typing.CastableExpression; import org.rumbledb.expressions.typing.InstanceOfExpression; @@ -763,6 +765,54 @@ public StaticContext visitStringConcatExpr(StringConcatExpression expression, St return argument; } + // endregion + + // region quantified + + @Override + public StaticContext visitQuantifiedExpression(QuantifiedExpression expression, StaticContext argument) { + Expression evaluationExpression = (Expression) expression.getEvaluationExpression(); + boolean skipTestInference = false; + for(QuantifiedExpressionVar var : expression.getVariables()){ + visit(var.getExpression(), argument); + SequenceType varType = var.getActualSequenceType(); + SequenceType inferredType = var.getExpression().getInferredSequenceType(); + if(varType == null){ + // if type was not specified for a clause we use the single version of the inferred one + if(inferredType == null){ + throw new OurBadException("A child expression of a QuantifiedExpression has no inferred type"); + } + if(inferredType.isEmptySequence()){ + skipTestInference = true; + } else { + System.out.println("setting "+var.getVariableName()+" type to: "+inferredType.getItemType()); + evaluationExpression.getStaticContext().replaceVariableSequenceType(var.getVariableName(), new SequenceType(inferredType.getItemType())); + } + } else { + // otherwise we must check that the type is appropriate + if(!inferredType.isEmptySequence() && !(new SequenceType(inferredType.getItemType())).isSubtypeOfOrCanBePromotedTo(varType)){ + throw new UnexpectedStaticTypeException("expected type for variable " + var.getVariableName() + " must match " + varType + " but " + inferredType.getItemType() + " was inferred"); + } + } + } + + if(!skipTestInference){ + visit(evaluationExpression, argument); + SequenceType evaluationType = evaluationExpression.getInferredSequenceType(); + if(evaluationType == null){ + throw new OurBadException("A child expression of a QuantifiedExpression has no inferred type"); + } + if(!evaluationType.hasEffectiveBooleanValue()){ + throw new UnexpectedStaticTypeException("evaluation expression of quantified expression has " + evaluationType + " inferred type, which has no effective boolean value"); + } + } + + expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + System.out.println("visiting Quantified expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + + // endregion // region module diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index 9e5f4412ac..ec02678015 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -347,7 +347,7 @@ public StaticContext visitQuantifiedExpression(QuantifiedExpression expression, StaticContext result = new StaticContext(contextWithQuantifiedExpressionVariables); result.addVariable( clause.getVariableName(), - clause.getSequenceType(), + clause.getActualSequenceType(), expression.getMetadata(), ExecutionMode.LOCAL ); diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index f5698d6338..2793571db2 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -1348,8 +1348,6 @@ public Node visitQuantifiedExpr(JsoniqParser.QuantifiedExprContext ctx) { )).getVariableName(); if (currentVariable.sequenceType() != null) { sequenceType = this.processSequenceType(currentVariable.sequenceType()); - } else { - sequenceType = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; } varExpression = (Expression) this.visitExprSingle(currentVariable.exprSingle()); diff --git a/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpressionVar.java b/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpressionVar.java index 2829d17201..d5f86dbdb5 100644 --- a/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpressionVar.java +++ b/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpressionVar.java @@ -22,6 +22,7 @@ import org.rumbledb.context.Name; import org.rumbledb.expressions.Expression; +import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; public class QuantifiedExpressionVar { @@ -48,7 +49,12 @@ public Name getVariableName() { return this.variableName; } + // default to item if it is [null] public SequenceType getSequenceType() { + return this.sequenceType == null ? new SequenceType(ItemType.item) : this.sequenceType; + } + + public SequenceType getActualSequenceType() { return this.sequenceType; } } From b466f25c84cb8ddd6939b7d06121fd2222ffa057 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 25 Oct 2020 14:16:12 +0100 Subject: [PATCH 022/206] added array lookup, object lookup and array unboxing expressions, also added hasOverlapWith method to SequenceType --- .../rumbledb/compiler/InferTypeVisitor.java | 77 +++++++++++++++++++ .../java/org/rumbledb/types/SequenceType.java | 13 ++++ 2 files changed, 90 insertions(+) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index a41f39d0a0..21f0ca38d6 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -26,6 +26,9 @@ import org.rumbledb.expressions.miscellaneous.RangeExpression; import org.rumbledb.expressions.miscellaneous.StringConcatExpression; import org.rumbledb.expressions.module.VariableDeclaration; +import org.rumbledb.expressions.postfix.ArrayLookupExpression; +import org.rumbledb.expressions.postfix.ArrayUnboxingExpression; +import org.rumbledb.expressions.postfix.ObjectLookupExpression; import org.rumbledb.expressions.primary.*; import org.rumbledb.expressions.quantifiers.QuantifiedExpression; import org.rumbledb.expressions.quantifiers.QuantifiedExpressionVar; @@ -813,6 +816,80 @@ public StaticContext visitQuantifiedExpression(QuantifiedExpression expression, } + // endregion + + // region postfix + + @Override + public StaticContext visitArrayLookupExpression(ArrayLookupExpression expression, StaticContext argument) { + visitDescendants(expression, argument); + + SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); + SequenceType lookupType = expression.getLookupExpression().getInferredSequenceType(); + + if(mainType == null || lookupType == null){ + throw new OurBadException("A child expression of a ArrayLookupExpression has no inferred type"); + } + + if(!lookupType.isSubtypeOf(SequenceType.createSequenceType("integer"))){ + throw new UnexpectedStaticTypeException("the lookup expression type must match integer, instead " + lookupType + " was inferred"); + } + + if(!mainType.hasOverlapWith(SequenceType.createSequenceType("array*")) || mainType.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + + SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; + expression.setInferredSequenceType(new SequenceType(ItemType.arrayItem, inferredArity)); + System.out.println("visiting ArrayLookup expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + + @Override + public StaticContext visitObjectLookupExpression(ObjectLookupExpression expression, StaticContext argument) { + visitDescendants(expression, argument); + + SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); + SequenceType lookupType = expression.getLookupExpression().getInferredSequenceType(); + + if(mainType == null || lookupType == null){ + throw new OurBadException("A child expression of a ObjectLookupExpression has no inferred type"); + } + + // must be castable to string + if(!lookupType.isSubtypeOf(SequenceType.createSequenceType("atomic"))){ + throw new UnexpectedStaticTypeException("the lookup expression type must be castable to string (i.e. must match atomic), instead " + lookupType + " was inferred"); + } + + if(!mainType.hasOverlapWith(SequenceType.createSequenceType("object*")) || mainType.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + + SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; + expression.setInferredSequenceType(new SequenceType(ItemType.objectItem, inferredArity)); + System.out.println("visiting ObjectLookup expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + + @Override + public StaticContext visitArrayUnboxingExpression(ArrayUnboxingExpression expression, StaticContext argument) { + visitDescendants(expression, argument); + + SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); + + if(mainType == null){ + throw new OurBadException("A child expression of a ArrayUnboxingExpression has no inferred type"); + } + + if(!mainType.hasOverlapWith(SequenceType.createSequenceType("array*")) || mainType.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + + expression.setInferredSequenceType(SequenceType.createSequenceType("item*")); + System.out.println("visiting ArrayUnboxingExpression expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + // endregion // region module diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index 11c1a96ef5..a61eff9e5e 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -122,6 +122,18 @@ public boolean hasEffectiveBooleanValue(){ } } + public boolean hasOverlapWith(SequenceType other){ + // types overlap if both itemType and Arity overlap, we also need to take care of empty sequence + if(this.isEmptySequence()){ + return other.isEmptySequence() || other.getArity() == Arity.OneOrZero || other.getArity() == Arity.ZeroOrMore; + } + if(other.isEmptySequence()){ + return this.getArity() == Arity.OneOrZero || this.getArity() == Arity.ZeroOrMore; + } + // All arities overlap between each other + return this.getItemType().isSubtypeOf(other.getItemType()) || other.getItemType().isSubtypeOf(this.getItemType()); + } + public SequenceType leastCommonSupertypeWith(SequenceType other){ if(this.isEmptySequence){ if(other.isEmptySequence()){ @@ -226,6 +238,7 @@ public String toString() { sequenceTypes.put("object*", new SequenceType(ItemType.objectItem, SequenceType.Arity.ZeroOrMore)); sequenceTypes.put("array?", new SequenceType(ItemType.arrayItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("array*", new SequenceType(ItemType.arrayItem, Arity.ZeroOrMore)); sequenceTypes.put("atomic", new SequenceType(ItemType.atomicItem, SequenceType.Arity.One)); sequenceTypes.put("atomic?", new SequenceType(ItemType.atomicItem, SequenceType.Arity.OneOrZero)); From 74559fac8ab0961e2c45269b8a6b96500341a867 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 25 Oct 2020 21:02:51 +0100 Subject: [PATCH 023/206] renamed PredicateExpression to FilterExpression and associated visit functions --- .../java/org/rumbledb/compiler/RuntimeIteratorVisitor.java | 4 ++-- src/main/java/org/rumbledb/compiler/TranslationVisitor.java | 4 ++-- .../org/rumbledb/compiler/VariableDependenciesVisitor.java | 4 ++-- .../java/org/rumbledb/expressions/AbstractNodeVisitor.java | 4 ++-- .../{PredicateExpression.java => FilterExpression.java} | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) rename src/main/java/org/rumbledb/expressions/postfix/{PredicateExpression.java => FilterExpression.java} (90%) diff --git a/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java b/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java index ca0a3b35a5..dafb7c35ab 100644 --- a/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java +++ b/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java @@ -68,7 +68,7 @@ import org.rumbledb.expressions.postfix.ArrayUnboxingExpression; import org.rumbledb.expressions.postfix.DynamicFunctionCallExpression; import org.rumbledb.expressions.postfix.ObjectLookupExpression; -import org.rumbledb.expressions.postfix.PredicateExpression; +import org.rumbledb.expressions.postfix.FilterExpression; import org.rumbledb.expressions.primary.ArrayConstructorExpression; import org.rumbledb.expressions.primary.BooleanLiteralExpression; import org.rumbledb.expressions.primary.ContextItemExpression; @@ -333,7 +333,7 @@ public RuntimeIterator visitVariableReference(VariableReferenceExpression expres // region primary @Override - public RuntimeIterator visitPredicateExpression(PredicateExpression expression, RuntimeIterator argument) { + public RuntimeIterator visitFilterExpression(FilterExpression expression, RuntimeIterator argument) { RuntimeIterator mainIterator = this.visit(expression.getMainExpression(), argument); RuntimeIterator filterIterator = this.visit(expression.getPredicateExpression(), argument); RuntimeIterator runtimeIterator = new PredicateIterator( diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 2793571db2..53d074c01e 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -85,7 +85,7 @@ import org.rumbledb.expressions.postfix.ArrayUnboxingExpression; import org.rumbledb.expressions.postfix.DynamicFunctionCallExpression; import org.rumbledb.expressions.postfix.ObjectLookupExpression; -import org.rumbledb.expressions.postfix.PredicateExpression; +import org.rumbledb.expressions.postfix.FilterExpression; import org.rumbledb.expressions.primary.ArrayConstructorExpression; import org.rumbledb.expressions.primary.BooleanLiteralExpression; import org.rumbledb.expressions.primary.ContextItemExpression; @@ -910,7 +910,7 @@ public Node visitPostFixExpr(JsoniqParser.PostFixExprContext ctx) { for (ParseTree child : ctx.children.subList(1, ctx.children.size())) { if (child instanceof JsoniqParser.PredicateContext) { Expression expr = (Expression) this.visitPredicate((JsoniqParser.PredicateContext) child); - mainExpression = new PredicateExpression( + mainExpression = new FilterExpression( mainExpression, expr, createMetadataFromContext(ctx) diff --git a/src/main/java/org/rumbledb/compiler/VariableDependenciesVisitor.java b/src/main/java/org/rumbledb/compiler/VariableDependenciesVisitor.java index 85d5c4e43c..abd8ff814e 100644 --- a/src/main/java/org/rumbledb/compiler/VariableDependenciesVisitor.java +++ b/src/main/java/org/rumbledb/compiler/VariableDependenciesVisitor.java @@ -58,7 +58,7 @@ import org.rumbledb.expressions.module.Prolog; import org.rumbledb.expressions.module.VariableDeclaration; import org.rumbledb.expressions.postfix.DynamicFunctionCallExpression; -import org.rumbledb.expressions.postfix.PredicateExpression; +import org.rumbledb.expressions.postfix.FilterExpression; import org.rumbledb.expressions.primary.ContextItemExpression; import org.rumbledb.expressions.primary.FunctionCallExpression; import org.rumbledb.expressions.primary.InlineFunctionExpression; @@ -332,7 +332,7 @@ public Void visitReturnClause(ReturnClause expression, Void argument) { return null; } - public Void visitPredicateExpression(PredicateExpression expression, Void argument) { + public Void visitFilterExpression(FilterExpression expression, Void argument) { visit(expression.getMainExpression(), null); visit(expression.getPredicateExpression(), null); diff --git a/src/main/java/org/rumbledb/expressions/AbstractNodeVisitor.java b/src/main/java/org/rumbledb/expressions/AbstractNodeVisitor.java index 3840d3d3b4..ad6129d523 100644 --- a/src/main/java/org/rumbledb/expressions/AbstractNodeVisitor.java +++ b/src/main/java/org/rumbledb/expressions/AbstractNodeVisitor.java @@ -51,7 +51,7 @@ import org.rumbledb.expressions.postfix.ArrayUnboxingExpression; import org.rumbledb.expressions.postfix.DynamicFunctionCallExpression; import org.rumbledb.expressions.postfix.ObjectLookupExpression; -import org.rumbledb.expressions.postfix.PredicateExpression; +import org.rumbledb.expressions.postfix.FilterExpression; import org.rumbledb.expressions.primary.ArrayConstructorExpression; import org.rumbledb.expressions.primary.BooleanLiteralExpression; import org.rumbledb.expressions.primary.ContextItemExpression; @@ -159,7 +159,7 @@ public T visitObjectLookupExpression(ObjectLookupExpression expression, T argume return defaultAction(expression, argument); } - public T visitPredicateExpression(PredicateExpression expression, T argument) { + public T visitFilterExpression(FilterExpression expression, T argument) { return defaultAction(expression, argument); } diff --git a/src/main/java/org/rumbledb/expressions/postfix/PredicateExpression.java b/src/main/java/org/rumbledb/expressions/postfix/FilterExpression.java similarity index 90% rename from src/main/java/org/rumbledb/expressions/postfix/PredicateExpression.java rename to src/main/java/org/rumbledb/expressions/postfix/FilterExpression.java index b3685fbfe5..6f5d0e2a17 100644 --- a/src/main/java/org/rumbledb/expressions/postfix/PredicateExpression.java +++ b/src/main/java/org/rumbledb/expressions/postfix/FilterExpression.java @@ -32,12 +32,12 @@ import java.util.List; -public class PredicateExpression extends Expression { +public class FilterExpression extends Expression { private Expression mainExpression; private Expression predicateExpression; - public PredicateExpression(Expression mainExpression, Expression predicateExpression, ExceptionMetadata metadata) { + public FilterExpression(Expression mainExpression, Expression predicateExpression, ExceptionMetadata metadata) { super(metadata); if (mainExpression == null) { throw new OurBadException("Main expression cannot be null in a postfix expression."); @@ -60,7 +60,7 @@ public Expression getPredicateExpression() { @Override public T accept(AbstractNodeVisitor visitor, T argument) { - return visitor.visitPredicateExpression(this, argument); + return visitor.visitFilterExpression(this, argument); } public Expression getMainExpression() { From 96b166229950baaa90c4bedf82f35fcbf0bd5f6a Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 25 Oct 2020 21:41:32 +0100 Subject: [PATCH 024/206] added filter expression type inference --- .../rumbledb/compiler/InferTypeVisitor.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 21f0ca38d6..093f9d9cef 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -28,6 +28,7 @@ import org.rumbledb.expressions.module.VariableDeclaration; import org.rumbledb.expressions.postfix.ArrayLookupExpression; import org.rumbledb.expressions.postfix.ArrayUnboxingExpression; +import org.rumbledb.expressions.postfix.FilterExpression; import org.rumbledb.expressions.postfix.ObjectLookupExpression; import org.rumbledb.expressions.primary.*; import org.rumbledb.expressions.quantifiers.QuantifiedExpression; @@ -890,6 +891,45 @@ public StaticContext visitArrayUnboxingExpression(ArrayUnboxingExpression expres return argument; } + @Override + public StaticContext visitFilterExpression(FilterExpression expression, StaticContext argument) { + visit(expression.getMainExpression(), argument); + SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); + + if(mainType == null){ + throw new OurBadException("A child expression of a FilterExpression has no inferred type"); + } + + if(mainType.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + + Expression predicateExpression = expression.getPredicateExpression(); + // set context item static type + predicateExpression.getStaticContext().setContextItemStaticType(new SequenceType(mainType.getItemType())); + visit(predicateExpression, argument); + SequenceType predicateType = predicateExpression.getInferredSequenceType(); + // unset context item static type + predicateExpression.getStaticContext().setContextItemStaticType(null); + + if(predicateType == null){ + throw new OurBadException("A child expression of a FilterExpression has no inferred type"); + } + // always false so the return type is for sure () + if(predicateType.isEmptySequence() || predicateType.isSubtypeOf(SequenceType.createSequenceType("null?"))){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + if(!predicateType.hasEffectiveBooleanValue()){ + throw new UnexpectedStaticTypeException("Inferred type " + predicateType + " has no effective boolean value"); + } + + // if we are filter one or less items or we use an integer to select a specific position we return at most one element, otherwise * + SequenceType.Arity inferredArity = (mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) || mainType.getItemType().equals(ItemType.integerItem)) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; + expression.setInferredSequenceType(new SequenceType(mainType.getItemType(), inferredArity)); + System.out.println("visiting Filter expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + // endregion // region module From 3b20250154bbc363993243908b5753827fb87f39 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 25 Oct 2020 22:58:24 +0100 Subject: [PATCH 025/206] added statically known function signatures in the static context during type inference --- .../rumbledb/compiler/InferTypeVisitor.java | 38 ++++++++++++++++--- .../rumbledb/compiler/TranslationVisitor.java | 4 +- .../org/rumbledb/context/StaticContext.java | 25 +++++++++++- .../primary/InlineFunctionExpression.java | 6 ++- 4 files changed, 62 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 093f9d9cef..1528cfd3f3 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -25,6 +25,7 @@ import org.rumbledb.expressions.logic.OrExpression; import org.rumbledb.expressions.miscellaneous.RangeExpression; import org.rumbledb.expressions.miscellaneous.StringConcatExpression; +import org.rumbledb.expressions.module.FunctionDeclaration; import org.rumbledb.expressions.module.VariableDeclaration; import org.rumbledb.expressions.postfix.ArrayLookupExpression; import org.rumbledb.expressions.postfix.ArrayUnboxingExpression; @@ -37,9 +38,11 @@ import org.rumbledb.expressions.typing.CastableExpression; import org.rumbledb.expressions.typing.InstanceOfExpression; import org.rumbledb.expressions.typing.TreatExpression; +import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; +import java.util.ArrayList; import java.util.List; /** @@ -219,18 +222,20 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static visitDescendants(expression, argument); BuiltinFunction function = null; + FunctionSignature signature = null; try { function = BuiltinFunctionCatalogue.getBuiltinFunction(expression.getFunctionIdentifier()); } catch (OurBadException exception){ - // TODO: where can i find all available functions in the static context + signature = expression.getStaticContext().getFunctionSignature(expression.getFunctionIdentifier()); } - if(function == null){ - throw new UnexpectedStaticTypeException("Function " + expression.getFunctionIdentifier() + " is not available"); - } + List parameterExpressions = expression.getArguments(); - List parameterTypes = function.getSignature().getParameterTypes(); + if(function != null){ + signature = function.getSignature(); + } + List parameterTypes = signature.getParameterTypes(); int paramsLength = parameterExpressions.size(); for(int i = 0; i < paramsLength; ++i){ @@ -248,7 +253,7 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static if(expression.isPartialApplication()){ expression.setInferredSequenceType(new SequenceType(ItemType.functionItem)); } else { - SequenceType returnType = function.getSignature().getReturnType(); + SequenceType returnType = signature.getReturnType(); if(returnType == null){ returnType = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; } @@ -949,5 +954,26 @@ public StaticContext visitVariableDeclaration(VariableDeclaration expression, St return argument; } + @Override + public StaticContext visitFunctionDeclaration(FunctionDeclaration expression, StaticContext argument) { + visitDescendants(expression, argument); + + InlineFunctionExpression inlineExpression = ((InlineFunctionExpression) expression.getExpression()); + SequenceType inferredType = inlineExpression.getBody().getInferredSequenceType(); + SequenceType expectedType = inlineExpression.getActualReturnType(); + + if(expectedType == null){ + // TODO: should i register the function with the inferred type or most general in this case? + expectedType = inferredType; + } else if(!inferredType.isSubtypeOf(expectedType)) { + throw new UnexpectedStaticTypeException("The declared function inferred type " + inferredType + " does not match the expected return type " + expectedType); + } + + // add function signature to the statically known one + argument.addFunctionSignature(inlineExpression.getFunctionIdentifier(), new FunctionSignature(new ArrayList(inlineExpression.getParams().values()), expectedType)); + + return argument; + } + // endregion } diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 53d074c01e..59d50aba2b 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -358,7 +358,7 @@ public Name parseName(JsoniqParser.QnameContext ctx, boolean isFunction) { public Node visitFunctionDecl(JsoniqParser.FunctionDeclContext ctx) { Name name = parseName(ctx.qname(), true); Map fnParams = new LinkedHashMap<>(); - SequenceType fnReturnType = MOST_GENERAL_SEQUENCE_TYPE; + SequenceType fnReturnType = null; Name paramName; SequenceType paramType; if (ctx.paramList() != null) { @@ -383,8 +383,6 @@ public Node visitFunctionDecl(JsoniqParser.FunctionDeclContext ctx) { if (ctx.return_type != null) { fnReturnType = this.processSequenceType(ctx.return_type); - } else { - fnReturnType = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; } Expression bodyExpression = (Expression) this.visitExpr(ctx.fn_body); diff --git a/src/main/java/org/rumbledb/context/StaticContext.java b/src/main/java/org/rumbledb/context/StaticContext.java index ef98e1e1e3..5009f9a72e 100644 --- a/src/main/java/org/rumbledb/context/StaticContext.java +++ b/src/main/java/org/rumbledb/context/StaticContext.java @@ -24,6 +24,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.SemanticException; import org.rumbledb.expressions.ExecutionMode; +import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.SequenceType; import com.esotericsoftware.kryo.Kryo; @@ -47,8 +48,9 @@ public class StaticContext implements Serializable, KryoSerializable { private StaticContext parent; private URI staticBaseURI; private boolean emptySequenceOrderLeast; - // TODO: should this be transient? + // TODO: should these be transient? private transient SequenceType contextItemStaticType; + private transient Map staticallyKnownFunctionSignatures; public StaticContext() { this.parent = null; @@ -66,6 +68,7 @@ public StaticContext(URI staticBaseURI) { this.userDefinedFunctionExecutionModes = null; this.emptySequenceOrderLeast = true; this.contextItemStaticType = null; + this.staticallyKnownFunctionSignatures = new HashMap<>(); } public StaticContext(StaticContext parent) { @@ -73,6 +76,7 @@ public StaticContext(StaticContext parent) { this.inScopeVariables = new HashMap<>(); this.userDefinedFunctionExecutionModes = null; this.contextItemStaticType = null; + this.staticallyKnownFunctionSignatures = new HashMap<>(); } public StaticContext getParent() { @@ -118,6 +122,21 @@ private InScopeVariable getInScopeVariable(Name varName) { } } + public FunctionSignature getFunctionSignature(FunctionIdentifier identifier) { + if (this.staticallyKnownFunctionSignatures.containsKey(identifier)) { + return this.staticallyKnownFunctionSignatures.get(identifier); + } else { + StaticContext ancestor = this.parent; + while (ancestor != null) { + if (ancestor.staticallyKnownFunctionSignatures.containsKey(identifier)) { + return ancestor.staticallyKnownFunctionSignatures.get(identifier); + } + ancestor = ancestor.parent; + } + throw new SemanticException("function " + identifier + " not in scope", null); + } + } + // replace the sequence type of an existing InScopeVariable, throws an error if the variable does not exists public void replaceVariableSequenceType(Name varName, SequenceType newSequenceType){ InScopeVariable variable = getInScopeVariable(varName); @@ -145,6 +164,10 @@ public void addVariable( this.inScopeVariables.put(varName, new InScopeVariable(varName, type, metadata, storageMode)); } + public void addFunctionSignature(FunctionIdentifier identifier, FunctionSignature signature){ + this.staticallyKnownFunctionSignatures.put(identifier, signature); + } + protected Map getInScopeVariables() { return this.inScopeVariables; } diff --git a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java index 2600f94cee..1721e9a32e 100644 --- a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java @@ -70,6 +70,10 @@ public Map getParams() { } public SequenceType getReturnType() { + return this.returnType == null ? SequenceType.MOST_GENERAL_SEQUENCE_TYPE : this.returnType; + } + + public SequenceType getActualReturnType() { return this.returnType; } @@ -115,7 +119,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(entry.getValue().toString()); buffer.append(", "); } - buffer.append(this.returnType.toString()); + buffer.append(this.returnType == null ? "not set" : this.returnType.toString()); buffer.append(")"); buffer.append(" | " + this.highestExecutionMode); buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); From 16c8a1b5e05d2e089feae64af5370dee1a7c270e Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 27 Oct 2020 11:02:03 +0100 Subject: [PATCH 026/206] added type inference for switch and dynamic function call expressions --- .../rumbledb/compiler/InferTypeVisitor.java | 84 +++++++++++++++++-- .../org/rumbledb/errorcodes/ErrorCode.java | 4 + 2 files changed, 80 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 1528cfd3f3..831eee6e2c 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -16,10 +16,7 @@ import org.rumbledb.expressions.arithmetic.MultiplicativeExpression; import org.rumbledb.expressions.arithmetic.UnaryExpression; import org.rumbledb.expressions.comparison.ComparisonExpression; -import org.rumbledb.expressions.control.ConditionalExpression; -import org.rumbledb.expressions.control.TryCatchExpression; -import org.rumbledb.expressions.control.TypeSwitchExpression; -import org.rumbledb.expressions.control.TypeswitchCase; +import org.rumbledb.expressions.control.*; import org.rumbledb.expressions.logic.AndExpression; import org.rumbledb.expressions.logic.NotExpression; import org.rumbledb.expressions.logic.OrExpression; @@ -27,10 +24,7 @@ import org.rumbledb.expressions.miscellaneous.StringConcatExpression; import org.rumbledb.expressions.module.FunctionDeclaration; import org.rumbledb.expressions.module.VariableDeclaration; -import org.rumbledb.expressions.postfix.ArrayLookupExpression; -import org.rumbledb.expressions.postfix.ArrayUnboxingExpression; -import org.rumbledb.expressions.postfix.FilterExpression; -import org.rumbledb.expressions.postfix.ObjectLookupExpression; +import org.rumbledb.expressions.postfix.*; import org.rumbledb.expressions.primary.*; import org.rumbledb.expressions.quantifiers.QuantifiedExpression; import org.rumbledb.expressions.quantifiers.QuantifiedExpressionVar; @@ -645,6 +639,61 @@ public StaticContext visitConditionalExpression(ConditionalExpression expression return argument; } + // throw errors if [type] does not conform to switch test and cases requirements + public void checkSwitchType(SequenceType type){ + if(type == null){ + throw new OurBadException("A child expression of a SwitchExpression has no inferred type"); + } + if(type.isEmptySequence()){ + return; // no further check is required + } + if(type.getArity() == SequenceType.Arity.OneOrZero || type.getArity() == SequenceType.Arity.ZeroOrMore){ + throw new UnexpectedStaticTypeException("+ and * arities are not allowed for the expressions of switch test condition and cases"); + } + ItemType itemType = type.getItemType(); + if(itemType.equals(ItemType.functionItem)){ + throw new UnexpectedStaticTypeException("function item not allowed for the expressions of switch test condition and cases", ErrorCode.UnexpectedFunctionITem); + } + if(!itemType.isSubtypeOf(ItemType.atomicItem)){ + throw new UnexpectedStaticTypeException("switch test condition and cases expressions' item type must match atomic, instead inferred: " + itemType); + } + } + + @Override + public StaticContext visitSwitchExpression(SwitchExpression expression, StaticContext argument) { + visitDescendants(expression, argument); + SequenceType testType = expression.getTestCondition().getInferredSequenceType(); + checkSwitchType(testType); + + SequenceType returnType = expression.getDefaultExpression().getInferredSequenceType(); + if(returnType == null){ + throw new OurBadException("A child expression of a SwitchExpression has no inferred type"); + } + + for(SwitchCase switchCase : expression.getCases()){ + boolean addToReturnType = false; + for(Expression caseExpression : switchCase.getConditionExpressions()){ + // test the case expression + checkSwitchType(caseExpression.getInferredSequenceType()); + // if has overlap with the test condition will add the return type to the possible ones + if(caseExpression.getInferredSequenceType().hasOverlapWith(testType)){ + addToReturnType = true; + } + } + SequenceType caseReturnType = switchCase.getReturnExpression().getInferredSequenceType(); + if(caseReturnType == null){ + throw new OurBadException("A child expression of a SwitchExpression has no inferred type"); + } + if(addToReturnType){ + returnType = returnType.leastCommonSupertypeWith(caseReturnType); + } + } + + expression.setInferredSequenceType(returnType); + System.out.println("visiting Switch expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + @Override public StaticContext visitTryCatchExpression(TryCatchExpression expression, StaticContext argument) { visitDescendants(expression, argument); @@ -935,6 +984,25 @@ public StaticContext visitFilterExpression(FilterExpression expression, StaticCo return argument; } + @Override + public StaticContext visitDynamicFunctionCallExpression(DynamicFunctionCallExpression expression, StaticContext argument) { + // since we do not specify function's signature in the itemType we can only check that it is a function + visitDescendants(expression, argument); + + SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); + if(mainType == null){ + throw new OurBadException("A child expression of a DynamicExpression has no inferred type"); + } + if(!mainType.equals(new SequenceType(ItemType.functionItem))){ + throw new UnexpectedStaticTypeException("the type of a dynamic function call main expression must be function, instead inferred " + mainType); + } + + // TODO: what aout partial application? + expression.setInferredSequenceType(SequenceType.MOST_GENERAL_SEQUENCE_TYPE); + System.out.println("visiting DynamicFunctionCall expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + // endregion // region module diff --git a/src/main/java/org/rumbledb/errorcodes/ErrorCode.java b/src/main/java/org/rumbledb/errorcodes/ErrorCode.java index 6f2923efae..43a36ec8f0 100644 --- a/src/main/java/org/rumbledb/errorcodes/ErrorCode.java +++ b/src/main/java/org/rumbledb/errorcodes/ErrorCode.java @@ -104,8 +104,12 @@ public enum ErrorCode { PositionalVariableNameSameAsForVariable("XQST0089"), InvalidGroupVariableErrorCode("XQST0094"), + UnexpectedFunctionITem("FOTY0015"), + InvalidTimezoneValue("FODT0003"); + + private String code; ErrorCode(String c) { From 282439a47a9f818c48e2d0175ba3b9577a57fe70 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 27 Oct 2020 14:26:10 +0100 Subject: [PATCH 027/206] added type inference for simple map expression --- .../rumbledb/compiler/InferTypeVisitor.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 831eee6e2c..1268e8c62f 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -17,6 +17,7 @@ import org.rumbledb.expressions.arithmetic.UnaryExpression; import org.rumbledb.expressions.comparison.ComparisonExpression; import org.rumbledb.expressions.control.*; +import org.rumbledb.expressions.flowr.SimpleMapExpression; import org.rumbledb.expressions.logic.AndExpression; import org.rumbledb.expressions.logic.NotExpression; import org.rumbledb.expressions.logic.OrExpression; @@ -1003,6 +1004,49 @@ public StaticContext visitDynamicFunctionCallExpression(DynamicFunctionCallExpre return argument; } + @Override + public StaticContext visitSimpleMapExpr(SimpleMapExpression expression, StaticContext argument) { + List nodes = expression.getChildren(); + Expression leftExpression = (Expression) nodes.get(0); + Expression rightExpression = (Expression) nodes.get(1); + + visit(leftExpression, argument); + SequenceType leftType = leftExpression.getInferredSequenceType(); + if(leftType == null){ + throw new OurBadException("A child expression of a SimpleMapExpression has no inferred type"); + } + if(leftType.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + + // set context item static type + rightExpression.getStaticContext().setContextItemStaticType(new SequenceType(leftType.getItemType())); + visit(rightExpression, argument); + rightExpression.getStaticContext().setContextItemStaticType(null); + + SequenceType rightType = rightExpression.getInferredSequenceType(); + if(rightType == null){ + throw new OurBadException("A child expression of a SimpleMapExpression has no inferred type"); + } + if(rightType.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + + SequenceType.Arity resultingArity = SequenceType.Arity.ZeroOrMore; + + if(leftType.getArity() == SequenceType.Arity.One && rightType.getArity() == SequenceType.Arity.One){ + resultingArity = SequenceType.Arity.One; + } else if(leftType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) && rightType.isAritySubtypeOf(SequenceType.Arity.OneOrZero)){ + resultingArity = SequenceType.Arity.OneOrZero; + } else if(leftType.isAritySubtypeOf(SequenceType.Arity.OneOrMore) && rightType.isAritySubtypeOf(SequenceType.Arity.OneOrMore)){ + resultingArity = SequenceType.Arity.OneOrMore; + } + + expression.setInferredSequenceType(new SequenceType(rightType.getItemType(), resultingArity)); + System.out.println("visiting SimpleMap expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + // endregion // region module From 82e33ed7b188a4253e68c7541b13702e8b003ba7 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 27 Oct 2020 14:29:35 +0100 Subject: [PATCH 028/206] item* now has no effective boolean value --- src/main/java/org/rumbledb/types/SequenceType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index a61eff9e5e..a570064726 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -108,7 +108,7 @@ public boolean isAritySubtypeOf(Arity superArity){ public boolean hasEffectiveBooleanValue(){ if(this.isEmptySequence) { return true; - } else if(this.itemType.isSubtypeOf(ItemType.JSONItem) || this.itemType.equals(ItemType.item)) { + } else if(this.itemType.isSubtypeOf(ItemType.JSONItem)) { return true; } else if((this.arity == Arity.One || this.arity == Arity.OneOrZero) && ( this.itemType.isNumeric() || From f76282c1f5c0e30331a8f5f64ba9dc598891b578 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 27 Oct 2020 15:38:06 +0100 Subject: [PATCH 029/206] started type inference on flowrExpression, covered returnClause and letClause, changed TranslationVisitor behaviour to set Sequence type to null when not present instead of item* --- .../rumbledb/compiler/InferTypeVisitor.java | 50 ++++++++++++++++++- .../compiler/StaticContextVisitor.java | 2 +- .../rumbledb/compiler/TranslationVisitor.java | 4 +- .../rumbledb/expressions/flowr/LetClause.java | 6 ++- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 1268e8c62f..352bad3375 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -17,7 +17,7 @@ import org.rumbledb.expressions.arithmetic.UnaryExpression; import org.rumbledb.expressions.comparison.ComparisonExpression; import org.rumbledb.expressions.control.*; -import org.rumbledb.expressions.flowr.SimpleMapExpression; +import org.rumbledb.expressions.flowr.*; import org.rumbledb.expressions.logic.AndExpression; import org.rumbledb.expressions.logic.NotExpression; import org.rumbledb.expressions.logic.OrExpression; @@ -1049,6 +1049,53 @@ public StaticContext visitSimpleMapExpr(SimpleMapExpression expression, StaticCo // endregion + // region FLOWR + + @Override + public StaticContext visitFlowrExpression(FlworExpression expression, StaticContext argument) { + Clause clause = expression.getReturnClause().getFirstClause(); + + while (clause != null){ + this.visit(clause, argument); + clause = clause.getNextClause(); + } + + SequenceType returnType = expression.getReturnClause().getReturnExpr().getInferredSequenceType(); + if(returnType == null){ + throw new OurBadException("A child expression of a FlowrExpression has no inferred type"); + } + if(returnType.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + + expression.setInferredSequenceType(returnType); + System.out.println("visiting Flowr expression, type set to: " + expression.getInferredSequenceType()); + return argument; + } + + @Override + public StaticContext visitLetClause(LetClause expression, StaticContext argument) { + // if type was not defined we infer it and overwrite it in the next clause context + visit(expression.getExpression(), argument); + SequenceType inferredType = expression.getExpression().getInferredSequenceType(); + if(inferredType == null){ + throw new OurBadException("The child expression of VariableDeclaration has no inferred type"); + } + if(expression.getActualSequenceType() == null){ + // if type was not defined we infer it and overwrite it in the next clause context + // getNextClause() cannot return null because LetClause cannot be the last clause + expression.getNextClause().getStaticContext().replaceVariableSequenceType(expression.getVariableName(), inferredType); + } else { + if(!inferredType.isSubtypeOfOrCanBePromotedTo(expression.getActualSequenceType())){ + throw new UnexpectedStaticTypeException(expression.getVariableName() + " has expected type " + expression.getActualSequenceType() + " but is not matched by the inferred type: " + inferredType); + } + } + System.out.println("visiting Let clause, inferred var " + expression.getVariableName() + " : " + inferredType); + return argument; + } + + // endregion + // region module @Override @@ -1060,6 +1107,7 @@ public StaticContext visitVariableDeclaration(VariableDeclaration expression, St if(inferredType == null){ throw new OurBadException("The child expression of VariableDeclaration has no inferred type"); } + // TODO: consider static check as well argument.replaceVariableSequenceType(expression.getVariableName(), inferredType); } diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index ec02678015..0523df6b5b 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -287,7 +287,7 @@ public StaticContext visitLetClause(LetClause clause, StaticContext argument) { StaticContext result = new StaticContext(argument); result.addVariable( clause.getVariableName(), - clause.getSequenceType(), + clause.getActualSequenceType(), clause.getMetadata(), clause.getVariableHighestStorageMode(this.visitorConfig) ); diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 59d50aba2b..b54ad7447e 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -560,12 +560,10 @@ public Node visitLetVar(JsoniqParser.LetVarContext ctx) { Name var = ((VariableReferenceExpression) this.visitVarRef(ctx.var_ref)).getVariableName(); if (ctx.seq != null) { seq = this.processSequenceType(ctx.seq); - } else { - seq = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; } Expression expr = (Expression) this.visitExprSingle(ctx.ex); - if (!seq.equals(SequenceType.MOST_GENERAL_SEQUENCE_TYPE)) { + if (seq != null) { expr = new TreatExpression(expr, seq, ErrorCode.UnexpectedTypeErrorCode, expr.getMetadata()); } diff --git a/src/main/java/org/rumbledb/expressions/flowr/LetClause.java b/src/main/java/org/rumbledb/expressions/flowr/LetClause.java index baddd89526..26040b979a 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/LetClause.java +++ b/src/main/java/org/rumbledb/expressions/flowr/LetClause.java @@ -63,6 +63,10 @@ public Name getVariableName() { } public SequenceType getSequenceType() { + return this.sequenceType == null ? SequenceType.MOST_GENERAL_SEQUENCE_TYPE : this.sequenceType; + } + + public SequenceType getActualSequenceType() { return this.sequenceType; } @@ -110,7 +114,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(" "); } buffer.append(getClass().getSimpleName()); - buffer.append(" (" + (this.variableName) + ", " + this.sequenceType.toString() + ") "); + buffer.append(" (" + (this.variableName) + ", " + this.getSequenceType().toString() + ") "); buffer.append(")"); buffer.append(" | " + this.highestExecutionMode); buffer.append("\n"); From ee1b518b0ee67c8442fda8ea95f7d5794429a78d Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 27 Oct 2020 22:29:18 +0100 Subject: [PATCH 030/206] added orderBy and where clause type inference processing --- .../rumbledb/compiler/InferTypeVisitor.java | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 352bad3375..eb0d5d2791 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1068,6 +1068,7 @@ public StaticContext visitFlowrExpression(FlworExpression expression, StaticCont throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); } + // TODO: deal properly with arity basing on for clauses expression.setInferredSequenceType(returnType); System.out.println("visiting Flowr expression, type set to: " + expression.getInferredSequenceType()); return argument; @@ -1079,9 +1080,9 @@ public StaticContext visitLetClause(LetClause expression, StaticContext argument visit(expression.getExpression(), argument); SequenceType inferredType = expression.getExpression().getInferredSequenceType(); if(inferredType == null){ - throw new OurBadException("The child expression of VariableDeclaration has no inferred type"); + throw new OurBadException("The child expression of LetClause has no inferred type"); } - if(expression.getActualSequenceType() == null){ + if(expression.getActualSequenceType() == null){ // if type was not defined we infer it and overwrite it in the next clause context // getNextClause() cannot return null because LetClause cannot be the last clause expression.getNextClause().getStaticContext().replaceVariableSequenceType(expression.getVariableName(), inferredType); @@ -1094,6 +1095,42 @@ public StaticContext visitLetClause(LetClause expression, StaticContext argument return argument; } + @Override + public StaticContext visitWhereClause(WhereClause expression, StaticContext argument) { + visit(expression.getWhereExpression(), argument); + SequenceType whereType = expression.getWhereExpression().getInferredSequenceType(); + if(whereType == null){ + throw new OurBadException("The child expression of WhereClause has no inferred type"); + } + if(!whereType.hasEffectiveBooleanValue()){ + throw new UnexpectedStaticTypeException("where clause inferred type (" + whereType + ") has no effective boolean value"); + } + if(whereType.isEmptySequence() || whereType.isSubtypeOf(SequenceType.createSequenceType("null?"))){ + throw new UnexpectedStaticTypeException("where clause always return false, so return expression inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + return argument; + } + + @Override + public StaticContext visitOrderByClause(OrderByClause expression, StaticContext argument) { + visitDescendants(expression, argument); + for(OrderByClauseSortingKey orderClause : expression.getSortingKeys()){ + SequenceType orderType = orderClause.getExpression().getInferredSequenceType(); + if(orderType == null){ + throw new OurBadException("The child expression of OrderByClause has no inferred type"); + } + if(!orderType.isSubtypeOf(SequenceType.createSequenceType("atomic?")) || + orderType.getItemType().equals(ItemType.atomicItem) || + orderType.getItemType().equals(ItemType.durationItem) || + orderType.getItemType().equals(ItemType.hexBinaryItem) || + orderType.getItemType().equals(ItemType.base64BinaryItem)){ + throw new UnexpectedStaticTypeException("order by sorting expression's type must match atomic? and be comparable using 'gt' operator (so duration, hexBinary, base64Binary and atomic item type are not allowed), instead inferred: " + orderType); + } + } + + return argument; + } + // endregion // region module From 87e2a7765af56de79643f889d7fc655199d05064 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 28 Oct 2020 14:54:55 +0100 Subject: [PATCH 031/206] added for clause processing in type inference, changed translate visitor to set null as sequence type if 'as [type]' statement is not present --- .../rumbledb/compiler/InferTypeVisitor.java | 30 +++++++++++++++++++ .../compiler/StaticContextVisitor.java | 2 +- .../rumbledb/compiler/TranslationVisitor.java | 12 ++++---- .../rumbledb/expressions/flowr/ForClause.java | 6 +++- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index eb0d5d2791..919f21b2cf 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1074,6 +1074,36 @@ public StaticContext visitFlowrExpression(FlworExpression expression, StaticCont return argument; } + @Override + public StaticContext visitForClause(ForClause expression, StaticContext argument) { + visit(expression.getExpression(), argument); + SequenceType inferredType = expression.getExpression().getInferredSequenceType(); + if(inferredType == null){ + throw new OurBadException("The child expression of ForClause has no inferred type"); + } + if(inferredType.isEmptySequence()){ + if(!expression.isAllowEmpty()) { + // for sure we will not have any tuple to process and return the empty sequence + throw new UnexpectedStaticTypeException("In for clause Inferred type is empty sequence, empty is not allowed, so the result returned is for sure () and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + } else { + // we take the single arity version of the inferred type + inferredType = new SequenceType(inferredType.getItemType()); + } + + if(expression.getActualSequenceType() == null){ + // if type was not defined we infer it and overwrite it in the next clause context + // getNextClause() cannot return null because ForClause cannot be the last clause + expression.getNextClause().getStaticContext().replaceVariableSequenceType(expression.getVariableName(), inferredType); + } else { + if(!inferredType.isSubtypeOfOrCanBePromotedTo(expression.getActualSequenceType())){ + throw new UnexpectedStaticTypeException(expression.getVariableName() + " has expected type " + expression.getActualSequenceType() + " but is not matched by the inferred type: " + inferredType); + } + } + System.out.println("visiting For clause, inferred var " + expression.getVariableName() + " : " + inferredType); + return argument; + } + @Override public StaticContext visitLetClause(LetClause expression, StaticContext argument) { // if type was not defined we infer it and overwrite it in the next clause context diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index 0523df6b5b..f238f1eb65 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -263,7 +263,7 @@ public StaticContext visitForClause(ForClause clause, StaticContext argument) { StaticContext result = new StaticContext(argument); result.addVariable( clause.getVariableName(), - clause.getSequenceType(), + clause.getActualSequenceType(), clause.getMetadata(), clause.getVariableHighestStorageMode(this.visitorConfig) ); diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index b54ad7447e..d730321d06 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -510,8 +510,6 @@ public Node visitForVar(JsoniqParser.ForVarContext ctx) { Name var = ((VariableReferenceExpression) this.visitVarRef(ctx.var_ref)).getVariableName(); if (ctx.seq != null) { seq = this.processSequenceType(ctx.seq); - } else { - seq = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; } emptyFlag = (ctx.flag != null); Name atVar = null; @@ -528,11 +526,11 @@ public Node visitForVar(JsoniqParser.ForVarContext ctx) { // If the sequenceType is specified, we have to "extend" its arity to * // because TreatIterator is wrapping the whole assignment expression, // meaning there is not one TreatIterator for each variable we loop over. - SequenceType expressionType = new SequenceType( - seq.getItemType(), - SequenceType.Arity.ZeroOrMore - ); - if (!expressionType.equals(SequenceType.MOST_GENERAL_SEQUENCE_TYPE)) { + if (seq != null) { + SequenceType expressionType = new SequenceType( + seq.getItemType(), + SequenceType.Arity.ZeroOrMore + ); expr = new TreatExpression(expr, expressionType, ErrorCode.UnexpectedTypeErrorCode, expr.getMetadata()); } diff --git a/src/main/java/org/rumbledb/expressions/flowr/ForClause.java b/src/main/java/org/rumbledb/expressions/flowr/ForClause.java index 2570d11709..b7f52274e0 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/ForClause.java +++ b/src/main/java/org/rumbledb/expressions/flowr/ForClause.java @@ -79,6 +79,10 @@ public Name getPositionalVariableName() { } public SequenceType getSequenceType() { + return this.sequenceType == null ? SequenceType.createSequenceType("item") : this.sequenceType; + } + + public SequenceType getActualSequenceType() { return this.sequenceType; } @@ -127,7 +131,7 @@ public void print(StringBuffer buffer, int indent) { " (" + (this.variableName) + ", " - + this.sequenceType.toString() + + this.getSequenceType().toString() + ", " + (this.allowingEmpty ? "allowing empty, " : "") + this.positionalVariableName From d6a84a08a129e977cff9fa5f25f28054ba561240 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 28 Oct 2020 17:30:20 +0100 Subject: [PATCH 032/206] added group by clause type inference processing, translation visitor sets type to null when undefined for any declared variable, also added functions to static context and sequence type to deal with the change in the static type of the variables bound in the flowr expression so far --- .../rumbledb/compiler/InferTypeVisitor.java | 42 +++++++++++++++++++ .../compiler/StaticContextVisitor.java | 2 +- .../rumbledb/compiler/TranslationVisitor.java | 4 +- .../org/rumbledb/context/StaticContext.java | 22 ++++++++++ .../flowr/GroupByVariableDeclaration.java | 9 ++-- .../java/org/rumbledb/types/SequenceType.java | 12 ++++++ 6 files changed, 82 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 919f21b2cf..e2ada2366e 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -38,7 +38,9 @@ import org.rumbledb.types.SequenceType; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * This visitor infers a static SequenceType for each expression in the query @@ -1141,6 +1143,46 @@ public StaticContext visitWhereClause(WhereClause expression, StaticContext argu return argument; } + @Override + public StaticContext visitGroupByClause(GroupByClause expression, StaticContext argument) { + Clause nextClause = expression.getNextClause(); // != null because group by cannot be last clause of FLOWR expression + Set groupingVars = new HashSet<>(); + for(GroupByVariableDeclaration groupByVar : expression.getGroupVariables()){ + // if we are grouping by an existing var (i.e. expr is null), then the appropriate type is already inferred + Expression groupByVarExpr = groupByVar.getExpression(); + SequenceType expectedType; + if(groupByVarExpr != null){ + visit(groupByVarExpr, argument); + SequenceType inferredType = groupByVarExpr.getInferredSequenceType(); + if(inferredType == null){ + throw new OurBadException("The child expression of GroupByClause has no inferred type"); + } + expectedType = groupByVar.getActualSequenceType(); + if(expectedType == null){ + nextClause.getStaticContext().replaceVariableSequenceType(groupByVar.getVariableName(), inferredType); + expectedType = inferredType; + } else { + // TODO: treat as expr in case of type so should i ignore check (apply to let and for as well) + } + } else { + expectedType = expression.getStaticContext().getVariableSequenceType(groupByVar.getVariableName()); + } + // check that expectedType is a subtype of atomic? + if(!expectedType.isSubtypeOf(SequenceType.createSequenceType("atomic?"))){ + throw new UnexpectedStaticTypeException("group by variable " + groupByVar.getVariableName() + " must match atomic? instead found " + expectedType); + } + groupingVars.add(groupByVar.getVariableName()); + } + + // finally if there was a for clause we need to change the arity of the variables binded so far in the flowr expression, from ? to * and from 1 to + + // excluding the grouping variables + StaticContext firstClauseStaticContext = expression.getFirstClause().getStaticContext(); + nextClause.getStaticContext().incrementArities(firstClauseStaticContext, groupingVars); + + + return argument; + } + @Override public StaticContext visitOrderByClause(OrderByClause expression, StaticContext argument) { visitDescendants(expression, argument); diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index f238f1eb65..7094ba6a94 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -304,7 +304,7 @@ public StaticContext visitGroupByClause(GroupByClause clause, StaticContext argu this.visit(variable.getExpression(), argument); groupByClauseContext.addVariable( variable.getVariableName(), - variable.getSequenceType(), + variable.getActualSequenceType(), clause.getMetadata(), ExecutionMode.LOCAL ); diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index d730321d06..c230771e0a 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -644,13 +644,11 @@ public GroupByVariableDeclaration processGroupByVar(JsoniqParser.GroupByVarConte if (ctx.seq != null) { seq = this.processSequenceType(ctx.seq); - } else { - seq = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; } if (ctx.ex != null) { expr = (Expression) this.visitExprSingle(ctx.ex); - if (!seq.equals(SequenceType.MOST_GENERAL_SEQUENCE_TYPE)) { + if (seq != null) { expr = new TreatExpression(expr, seq, ErrorCode.UnexpectedTypeErrorCode, expr.getMetadata()); } diff --git a/src/main/java/org/rumbledb/context/StaticContext.java b/src/main/java/org/rumbledb/context/StaticContext.java index 5009f9a72e..c94e9a70e2 100644 --- a/src/main/java/org/rumbledb/context/StaticContext.java +++ b/src/main/java/org/rumbledb/context/StaticContext.java @@ -20,6 +20,7 @@ package org.rumbledb.context; +import com.amazonaws.transform.MapEntry; import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.SemanticException; @@ -37,6 +38,7 @@ import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; +import java.util.Set; public class StaticContext implements Serializable, KryoSerializable { @@ -301,4 +303,24 @@ public SequenceType getContextItemStaticType() { public void setContextItemStaticType(SequenceType contextItemStaticType) { this.contextItemStaticType = contextItemStaticType; } + + // replace all inScopeVariable in this context and all parents until [stopContext] with name not in [varToExclude] with same variable with sequence type arity changed from 1 to + and form ? to * + // used by groupBy cluse + public void incrementArities(StaticContext stopContext, Set varToExclude){ + this.inScopeVariables.replaceAll((key, value) -> varToExclude.contains(value) ? value : + new InScopeVariable( + value.getName(), + value.getSequenceType().incrementArity(), + value.getMetadata(), + value.getStorageMode())); + StaticContext current = this.parent; + while (current != null && current != stopContext){ + for(Map.Entry entry : current.inScopeVariables.entrySet()){ + if(!this.inScopeVariables.containsKey(entry.getKey())){ + this.addVariable(entry.getKey(), entry.getValue().getSequenceType().incrementArity(), entry.getValue().getMetadata(), entry.getValue().getStorageMode()); + } + } + current = current.parent; + } + } } diff --git a/src/main/java/org/rumbledb/expressions/flowr/GroupByVariableDeclaration.java b/src/main/java/org/rumbledb/expressions/flowr/GroupByVariableDeclaration.java index 9ff2a6f6e3..0f4225572a 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/GroupByVariableDeclaration.java +++ b/src/main/java/org/rumbledb/expressions/flowr/GroupByVariableDeclaration.java @@ -41,12 +41,7 @@ public GroupByVariableDeclaration( } this.variableName = variableName; this.sequenceType = sequenceType; - if (this.sequenceType == null) { - throw new OurBadException("A sequence type cannot be null"); - } this.expression = expression; - - sequenceType = this.sequenceType; } public Name getVariableName() { @@ -58,6 +53,10 @@ public Expression getExpression() { } public SequenceType getSequenceType() { + return this.sequenceType == null ? SequenceType.MOST_GENERAL_SEQUENCE_TYPE : this.sequenceType; + } + + public SequenceType getActualSequenceType() { return this.sequenceType; } } diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index a570064726..ff812906f2 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -169,6 +169,18 @@ public SequenceType leastCommonSupertypeWith(SequenceType other){ return new SequenceType(itemSupertype, aritySuperType); } + // increment arity of a sequence type from ? to * and from 1 to +, leave others arity or sequence types untouched + public SequenceType incrementArity(){ + if(!this.isEmptySequence()){ + if(this.arity == Arity.One){ + return new SequenceType(this.getItemType(), Arity.OneOrMore); + } else if(this.arity == Arity.OneOrZero){ + return new SequenceType(this.getItemType(), Arity.ZeroOrMore); + } + } + return this; + } + @Override public boolean equals(Object other) { if (!(other instanceof SequenceType)) { From 7ecc3e059a111b8084b953fa34ef8a5cef81b778 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 29 Oct 2020 12:44:22 +0100 Subject: [PATCH 033/206] corrected working behaviour of flowr expression to account for ForClause(s) in inferring output arity, added subtypeOf and multiplyWith method to Arity enum --- .../rumbledb/compiler/InferTypeVisitor.java | 25 +++++++++--------- .../java/org/rumbledb/types/SequenceType.java | 26 ++++++++++++++++--- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index e2ada2366e..6b288c6d6c 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1034,16 +1034,7 @@ public StaticContext visitSimpleMapExpr(SimpleMapExpression expression, StaticCo throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); } - SequenceType.Arity resultingArity = SequenceType.Arity.ZeroOrMore; - - if(leftType.getArity() == SequenceType.Arity.One && rightType.getArity() == SequenceType.Arity.One){ - resultingArity = SequenceType.Arity.One; - } else if(leftType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) && rightType.isAritySubtypeOf(SequenceType.Arity.OneOrZero)){ - resultingArity = SequenceType.Arity.OneOrZero; - } else if(leftType.isAritySubtypeOf(SequenceType.Arity.OneOrMore) && rightType.isAritySubtypeOf(SequenceType.Arity.OneOrMore)){ - resultingArity = SequenceType.Arity.OneOrMore; - } - + SequenceType.Arity resultingArity = leftType.getArity().multiplyWith(rightType.getArity()); expression.setInferredSequenceType(new SequenceType(rightType.getItemType(), resultingArity)); System.out.println("visiting SimpleMap expression, type set to: " + expression.getInferredSequenceType()); return argument; @@ -1056,9 +1047,20 @@ public StaticContext visitSimpleMapExpr(SimpleMapExpression expression, StaticCo @Override public StaticContext visitFlowrExpression(FlworExpression expression, StaticContext argument) { Clause clause = expression.getReturnClause().getFirstClause(); + SequenceType.Arity forArities = SequenceType.Arity.One; // One is arity multiplication's neutral element + SequenceType forType; while (clause != null){ this.visit(clause, argument); + // if there are for clauses we need to consider their arities for the returning expression + if(clause.getClauseType() == FLWOR_CLAUSES.FOR){ + forType = ((ForClause) clause).getExpression().getInferredSequenceType(); + // if forType is the empty sequence that means that allowing empty is set otherwise we would have thrown an error + // therefore this for loop will generate one tuple binding the empty sequence, so as for the arities count as arity.One + if(!forType.isEmptySequence()){ + forArities = forType.getArity().multiplyWith(forArities); + } + } clause = clause.getNextClause(); } @@ -1069,8 +1071,7 @@ public StaticContext visitFlowrExpression(FlworExpression expression, StaticCont if(returnType.isEmptySequence()){ throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); } - - // TODO: deal properly with arity basing on for clauses + returnType = new SequenceType(returnType.getItemType(), returnType.getArity().multiplyWith(forArities)); expression.setInferredSequenceType(returnType); System.out.println("visiting Flowr expression, type set to: " + expression.getInferredSequenceType()); return argument; diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index ff812906f2..163454b172 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -98,11 +98,9 @@ public boolean isSubtypeOfOrCanBePromotedTo(SequenceType superType) { } // check if the arity of a sequence type is subtype of another arity, assume [this] is a non-empty sequence + // TODO: consider removing it public boolean isAritySubtypeOf(Arity superArity){ - if(superArity == Arity.ZeroOrMore || superArity == this.arity) - return true; - else - return this.arity == Arity.One; + return this.arity.isSubtypeOf(superArity); } public boolean hasEffectiveBooleanValue(){ @@ -223,6 +221,26 @@ public String getSymbol() { }; public abstract String getSymbol(); + + public boolean isSubtypeOf(Arity superArity){ + if(superArity == Arity.ZeroOrMore || superArity == this) + return true; + else + return this == Arity.One; + } + + public Arity multiplyWith(Arity other){ + if(this == One && other == One){ + return One; + } else if(this.isSubtypeOf(OneOrZero) && other.isSubtypeOf(OneOrZero)){ + return OneOrZero; + } else if(this.isSubtypeOf(OneOrMore) && other.isSubtypeOf(OneOrMore)){ + return OneOrMore; + } else { + return ZeroOrMore; + } + } + } @Override From a9afbec60e16b024aa912f6a2f62fc27bff97a52 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 29 Oct 2020 15:07:14 +0100 Subject: [PATCH 034/206] corrected for clause element type inference based on allowing empty flag and generating sequence arity --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 6b288c6d6c..3ff15fab6e 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1090,8 +1090,12 @@ public StaticContext visitForClause(ForClause expression, StaticContext argument throw new UnexpectedStaticTypeException("In for clause Inferred type is empty sequence, empty is not allowed, so the result returned is for sure () and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); } } else { - // we take the single arity version of the inferred type - inferredType = new SequenceType(inferredType.getItemType()); + // we take the single arity version of the inferred type or optional arity if we allow empty and the sequence allows () (i.e. arity ? or *) + if(expression.isAllowEmpty() && (inferredType.getArity() == SequenceType.Arity.OneOrZero || inferredType.getArity() == SequenceType.Arity.ZeroOrMore)){ + inferredType = new SequenceType(inferredType.getItemType(), SequenceType.Arity.OneOrZero); + } else { + inferredType = new SequenceType(inferredType.getItemType()); + } } if(expression.getActualSequenceType() == null){ From 809118d724b2486a79c8700cff308fe53612c579 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 4 Nov 2020 16:52:04 +0100 Subject: [PATCH 035/206] refactored code to perform basic null and empty sequence inferred type, and function to do variable declaration and checks --- .../rumbledb/compiler/InferTypeVisitor.java | 255 +++++++++--------- .../UnexpectedStaticTypeException.java | 3 +- 2 files changed, 128 insertions(+), 130 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 3ff15fab6e..b211a4dda5 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -37,10 +37,7 @@ import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; /** * This visitor infers a static SequenceType for each expression in the query @@ -58,6 +55,52 @@ public class InferTypeVisitor extends AbstractNodeVisitor { this.rumbleRuntimeConfiguration = rumbleRuntimeConfiguration; } + /** + * Perform basic checks on a list of SequenceType, available checks are for null (OurBad exception) and inferred the empty sequence (XPST0005) + * + * @param types list of sequence types to check + * @param nodeName name of the node to use in the errors + * @param nullCheck flag indicating to perform null check + * @param inferredEmptyCheck flag indicating to perform empty sequence check + */ + private void basicChecks(List types, String nodeName, boolean nullCheck, boolean inferredEmptyCheck){ + if(nullCheck){ + for (SequenceType type : types){ + if(type == null){ + throw new OurBadException("A child expression of a " + nodeName + " has no inferred type"); + } + } + } + if(inferredEmptyCheck){ + for (SequenceType type : types){ + if(type.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type for " + nodeName + " is empty sequence (with active static typing feature, only allowed for CommaExpression)", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + } + } + } + + /** + * Perform basic checks on a SequenceType, available checks are for null (OurBad exception) and inferred the empty sequence (XPST0005) + * + * @param type sequence types to check + * @param nodeName name of the node to use in the errors + * @param nullCheck flag indicating to perform null check + * @param inferredEmptyCheck flag indicating to perform empty sequence check + */ + private void basicChecks(SequenceType type, String nodeName, boolean nullCheck, boolean inferredEmptyCheck){ + if(nullCheck){ + if(type == null){ + throw new OurBadException("A child expression of a " + nodeName + " has no inferred type"); + } + } + if(inferredEmptyCheck){ + if(type.isEmptySequence()){ + throw new UnexpectedStaticTypeException("Inferred type for " + nodeName + " is empty sequence (with active static typing feature, only allowed for CommaExpression)", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + } + } + } + @Override public StaticContext visitCommaExpression(CommaExpression expression, StaticContext argument) { visitDescendants(expression, argument); @@ -729,9 +772,7 @@ public StaticContext visitTypeSwitchExpression(TypeSwitchExpression expression, SequenceType inferredType = null; SequenceType conditionType = expression.getTestCondition().getInferredSequenceType(); - if(conditionType == null){ - throw new OurBadException("A child expression of a TypeSwitchExpression has no inferred type"); - } + basicChecks(conditionType, expression.getClass().getSimpleName(), true, false); for(TypeswitchCase typeswitchCase : expression.getCases()){ Name variableName = typeswitchCase.getVariableName(); @@ -747,9 +788,7 @@ public StaticContext visitTypeSwitchExpression(TypeSwitchExpression expression, visit(returnExpression, argument); SequenceType caseType = returnExpression.getInferredSequenceType(); - if(caseType == null){ - throw new OurBadException("A child expression of a TypeSwitchExpression has no inferred type"); - } + basicChecks(caseType, expression.getClass().getSimpleName(), true, false); inferredType = inferredType == null ? caseType : inferredType.leastCommonSupertypeWith(caseType); } @@ -761,14 +800,10 @@ public StaticContext visitTypeSwitchExpression(TypeSwitchExpression expression, } visit(returnExpression, argument); SequenceType defaultType = returnExpression.getInferredSequenceType(); - if(defaultType == null){ - throw new OurBadException("A child expression of a TypeSwitchExpression has no inferred type"); - } + basicChecks(defaultType, expression.getClass().getSimpleName(), true, false); inferredType = inferredType.leastCommonSupertypeWith(defaultType); - if(inferredType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); - } + basicChecks(inferredType, expression.getClass().getSimpleName(), false, true); expression.setInferredSequenceType(inferredType); System.out.println("visiting TypeSwitch expression, type set to: " + expression.getInferredSequenceType()); return argument; @@ -836,33 +871,22 @@ public StaticContext visitQuantifiedExpression(QuantifiedExpression expression, boolean skipTestInference = false; for(QuantifiedExpressionVar var : expression.getVariables()){ visit(var.getExpression(), argument); - SequenceType varType = var.getActualSequenceType(); SequenceType inferredType = var.getExpression().getInferredSequenceType(); - if(varType == null){ - // if type was not specified for a clause we use the single version of the inferred one - if(inferredType == null){ - throw new OurBadException("A child expression of a QuantifiedExpression has no inferred type"); - } - if(inferredType.isEmptySequence()){ - skipTestInference = true; - } else { - System.out.println("setting "+var.getVariableName()+" type to: "+inferredType.getItemType()); - evaluationExpression.getStaticContext().replaceVariableSequenceType(var.getVariableName(), new SequenceType(inferredType.getItemType())); - } + basicChecks(inferredType, expression.getClass().getSimpleName(), true, false); + + SequenceType varType = var.getActualSequenceType(); + + if(inferredType.isEmptySequence()){ + skipTestInference = true; } else { - // otherwise we must check that the type is appropriate - if(!inferredType.isEmptySequence() && !(new SequenceType(inferredType.getItemType())).isSubtypeOfOrCanBePromotedTo(varType)){ - throw new UnexpectedStaticTypeException("expected type for variable " + var.getVariableName() + " must match " + varType + " but " + inferredType.getItemType() + " was inferred"); - } + checkVariableType(varType, inferredType, evaluationExpression.getStaticContext(), expression.getClass().getSimpleName(), var.getVariableName()); } } if(!skipTestInference){ visit(evaluationExpression, argument); SequenceType evaluationType = evaluationExpression.getInferredSequenceType(); - if(evaluationType == null){ - throw new OurBadException("A child expression of a QuantifiedExpression has no inferred type"); - } + basicChecks(evaluationType, expression.getClass().getSimpleName(), true, false); if(!evaluationType.hasEffectiveBooleanValue()){ throw new UnexpectedStaticTypeException("evaluation expression of quantified expression has " + evaluationType + " inferred type, which has no effective boolean value"); } @@ -952,14 +976,7 @@ public StaticContext visitArrayUnboxingExpression(ArrayUnboxingExpression expres public StaticContext visitFilterExpression(FilterExpression expression, StaticContext argument) { visit(expression.getMainExpression(), argument); SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); - - if(mainType == null){ - throw new OurBadException("A child expression of a FilterExpression has no inferred type"); - } - - if(mainType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); - } + basicChecks(mainType, expression.getClass().getSimpleName(), true, true); Expression predicateExpression = expression.getPredicateExpression(); // set context item static type @@ -969,15 +986,13 @@ public StaticContext visitFilterExpression(FilterExpression expression, StaticCo // unset context item static type predicateExpression.getStaticContext().setContextItemStaticType(null); - if(predicateType == null){ - throw new OurBadException("A child expression of a FilterExpression has no inferred type"); - } + basicChecks(predicateType, expression.getClass().getSimpleName(), true, true); // always false so the return type is for sure () - if(predicateType.isEmptySequence() || predicateType.isSubtypeOf(SequenceType.createSequenceType("null?"))){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if(predicateType.isSubtypeOf(SequenceType.createSequenceType("null?"))){ + throw new UnexpectedStaticTypeException("Inferred type for FilterExpression is empty sequence (with active static typing feature, only allowed for CommaExpression)", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); } if(!predicateType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("Inferred type " + predicateType + " has no effective boolean value"); + throw new UnexpectedStaticTypeException("Inferred type " + predicateType + " in FilterExpression has no effective boolean value"); } // if we are filter one or less items or we use an integer to select a specific position we return at most one element, otherwise * @@ -993,14 +1008,12 @@ public StaticContext visitDynamicFunctionCallExpression(DynamicFunctionCallExpre visitDescendants(expression, argument); SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); - if(mainType == null){ - throw new OurBadException("A child expression of a DynamicExpression has no inferred type"); - } + basicChecks(mainType, expression.getClass().getSimpleName(), true, false); if(!mainType.equals(new SequenceType(ItemType.functionItem))){ throw new UnexpectedStaticTypeException("the type of a dynamic function call main expression must be function, instead inferred " + mainType); } - // TODO: what aout partial application? + // TODO: need to add support for partial application expression.setInferredSequenceType(SequenceType.MOST_GENERAL_SEQUENCE_TYPE); System.out.println("visiting DynamicFunctionCall expression, type set to: " + expression.getInferredSequenceType()); return argument; @@ -1014,12 +1027,7 @@ public StaticContext visitSimpleMapExpr(SimpleMapExpression expression, StaticCo visit(leftExpression, argument); SequenceType leftType = leftExpression.getInferredSequenceType(); - if(leftType == null){ - throw new OurBadException("A child expression of a SimpleMapExpression has no inferred type"); - } - if(leftType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); - } + basicChecks(leftType, expression.getClass().getSimpleName(), true, true); // set context item static type rightExpression.getStaticContext().setContextItemStaticType(new SequenceType(leftType.getItemType())); @@ -1027,12 +1035,7 @@ public StaticContext visitSimpleMapExpr(SimpleMapExpression expression, StaticCo rightExpression.getStaticContext().setContextItemStaticType(null); SequenceType rightType = rightExpression.getInferredSequenceType(); - if(rightType == null){ - throw new OurBadException("A child expression of a SimpleMapExpression has no inferred type"); - } - if(rightType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); - } + basicChecks(rightType, expression.getClass().getSimpleName(), true, true); SequenceType.Arity resultingArity = leftType.getArity().multiplyWith(rightType.getArity()); expression.setInferredSequenceType(new SequenceType(rightType.getItemType(), resultingArity)); @@ -1065,12 +1068,7 @@ public StaticContext visitFlowrExpression(FlworExpression expression, StaticCont } SequenceType returnType = expression.getReturnClause().getReturnExpr().getInferredSequenceType(); - if(returnType == null){ - throw new OurBadException("A child expression of a FlowrExpression has no inferred type"); - } - if(returnType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); - } + basicChecks(returnType, expression.getClass().getSimpleName(), true, true); returnType = new SequenceType(returnType.getItemType(), returnType.getArity().multiplyWith(forArities)); expression.setInferredSequenceType(returnType); System.out.println("visiting Flowr expression, type set to: " + expression.getInferredSequenceType()); @@ -1080,10 +1078,10 @@ public StaticContext visitFlowrExpression(FlworExpression expression, StaticCont @Override public StaticContext visitForClause(ForClause expression, StaticContext argument) { visit(expression.getExpression(), argument); - SequenceType inferredType = expression.getExpression().getInferredSequenceType(); - if(inferredType == null){ - throw new OurBadException("The child expression of ForClause has no inferred type"); - } + + SequenceType declaredType = expression.getActualSequenceType(); + SequenceType inferredType = (declaredType == null ? expression.getExpression() : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); + basicChecks(inferredType, expression.getClass().getSimpleName(), true, false); if(inferredType.isEmptySequence()){ if(!expression.isAllowEmpty()) { // for sure we will not have any tuple to process and return the empty sequence @@ -1098,37 +1096,28 @@ public StaticContext visitForClause(ForClause expression, StaticContext argument } } - if(expression.getActualSequenceType() == null){ - // if type was not defined we infer it and overwrite it in the next clause context - // getNextClause() cannot return null because ForClause cannot be the last clause - expression.getNextClause().getStaticContext().replaceVariableSequenceType(expression.getVariableName(), inferredType); - } else { - if(!inferredType.isSubtypeOfOrCanBePromotedTo(expression.getActualSequenceType())){ - throw new UnexpectedStaticTypeException(expression.getVariableName() + " has expected type " + expression.getActualSequenceType() + " but is not matched by the inferred type: " + inferredType); - } - } + checkVariableType(declaredType, + inferredType, + expression.getNextClause().getStaticContext(), + expression.getClass().getSimpleName(), + expression.getVariableName()); + System.out.println("visiting For clause, inferred var " + expression.getVariableName() + " : " + inferredType); return argument; } @Override public StaticContext visitLetClause(LetClause expression, StaticContext argument) { - // if type was not defined we infer it and overwrite it in the next clause context visit(expression.getExpression(), argument); - SequenceType inferredType = expression.getExpression().getInferredSequenceType(); - if(inferredType == null){ - throw new OurBadException("The child expression of LetClause has no inferred type"); - } - if(expression.getActualSequenceType() == null){ - // if type was not defined we infer it and overwrite it in the next clause context - // getNextClause() cannot return null because LetClause cannot be the last clause - expression.getNextClause().getStaticContext().replaceVariableSequenceType(expression.getVariableName(), inferredType); - } else { - if(!inferredType.isSubtypeOfOrCanBePromotedTo(expression.getActualSequenceType())){ - throw new UnexpectedStaticTypeException(expression.getVariableName() + " has expected type " + expression.getActualSequenceType() + " but is not matched by the inferred type: " + inferredType); - } - } - System.out.println("visiting Let clause, inferred var " + expression.getVariableName() + " : " + inferredType); + SequenceType declaredType = expression.getActualSequenceType(); + SequenceType inferredType = (declaredType == null ? expression.getExpression() : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); + checkVariableType(declaredType, + inferredType, + expression.getNextClause().getStaticContext(), + expression.getClass().getSimpleName(), + expression.getVariableName()); + + System.out.println("visiting Let clause, var " + expression.getVariableName() + " : " + inferredType); return argument; } @@ -1136,9 +1125,7 @@ public StaticContext visitLetClause(LetClause expression, StaticContext argument public StaticContext visitWhereClause(WhereClause expression, StaticContext argument) { visit(expression.getWhereExpression(), argument); SequenceType whereType = expression.getWhereExpression().getInferredSequenceType(); - if(whereType == null){ - throw new OurBadException("The child expression of WhereClause has no inferred type"); - } + basicChecks(whereType, expression.getClass().getSimpleName(), true, false); if(!whereType.hasEffectiveBooleanValue()){ throw new UnexpectedStaticTypeException("where clause inferred type (" + whereType + ") has no effective boolean value"); } @@ -1158,17 +1145,20 @@ public StaticContext visitGroupByClause(GroupByClause expression, StaticContext SequenceType expectedType; if(groupByVarExpr != null){ visit(groupByVarExpr, argument); - SequenceType inferredType = groupByVarExpr.getInferredSequenceType(); - if(inferredType == null){ - throw new OurBadException("The child expression of GroupByClause has no inferred type"); - } - expectedType = groupByVar.getActualSequenceType(); - if(expectedType == null){ - nextClause.getStaticContext().replaceVariableSequenceType(groupByVar.getVariableName(), inferredType); + SequenceType declaredType = groupByVar.getActualSequenceType(); + SequenceType inferredType; + if(declaredType == null){ + inferredType = groupByVarExpr.getInferredSequenceType(); expectedType = inferredType; } else { - // TODO: treat as expr in case of type so should i ignore check (apply to let and for as well) + inferredType = ((TreatExpression) groupByVarExpr).getMainExpression().getInferredSequenceType(); + expectedType = declaredType; } + checkVariableType(declaredType, + inferredType, + nextClause.getStaticContext(), + expression.getClass().getSimpleName(), + groupByVar.getVariableName()); } else { expectedType = expression.getStaticContext().getVariableSequenceType(groupByVar.getVariableName()); } @@ -1183,8 +1173,6 @@ public StaticContext visitGroupByClause(GroupByClause expression, StaticContext // excluding the grouping variables StaticContext firstClauseStaticContext = expression.getFirstClause().getStaticContext(); nextClause.getStaticContext().incrementArities(firstClauseStaticContext, groupingVars); - - return argument; } @@ -1193,9 +1181,7 @@ public StaticContext visitOrderByClause(OrderByClause expression, StaticContext visitDescendants(expression, argument); for(OrderByClauseSortingKey orderClause : expression.getSortingKeys()){ SequenceType orderType = orderClause.getExpression().getInferredSequenceType(); - if(orderType == null){ - throw new OurBadException("The child expression of OrderByClause has no inferred type"); - } + basicChecks(orderType, expression.getClass().getSimpleName(), true, false); if(!orderType.isSubtypeOf(SequenceType.createSequenceType("atomic?")) || orderType.getItemType().equals(ItemType.atomicItem) || orderType.getItemType().equals(ItemType.durationItem) || @@ -1212,18 +1198,32 @@ public StaticContext visitOrderByClause(OrderByClause expression, StaticContext // region module + // if [declaredType] is not null, check if the inferred type matches or can be promoted to the declared type (otherwise throw type error) + // if [declaredType] is null, replace the type of [variableName] in the [context] with the inferred type + public void checkVariableType(SequenceType declaredType, SequenceType inferredType, StaticContext context, String nodeName, Name variableName) { + basicChecks(inferredType, nodeName, true, false); + + if(declaredType == null){ + // if declared type is null, we overwrite the type in the correspondent InScopeVariable with the inferred type + context.replaceVariableSequenceType(variableName, inferredType); + } else { + // the expression we get is a treat expression by design so we need to extract the inferred type of its main expression + if(!inferredType.isSubtypeOfOrCanBePromotedTo(declaredType)){ + throw new UnexpectedStaticTypeException("In a " + nodeName + ", the variable $" + variableName + " inferred type " + inferredType + " does not match or can be promoted to the declared type " + declaredType); + } + } + } + @Override public StaticContext visitVariableDeclaration(VariableDeclaration expression, StaticContext argument) { - // if expression has no type we infer it, and overwrite the type in the correspondent InScopeVariable visitDescendants(expression, argument); - if(expression.getActualSequenceType() == null){ - SequenceType inferredType = expression.getExpression().getInferredSequenceType(); - if(inferredType == null){ - throw new OurBadException("The child expression of VariableDeclaration has no inferred type"); - } - // TODO: consider static check as well - argument.replaceVariableSequenceType(expression.getVariableName(), inferredType); - } + SequenceType declaredType = expression.getActualSequenceType(); + SequenceType inferredType = (declaredType == null ? expression.getExpression() : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); + checkVariableType(declaredType, + inferredType, + argument, + expression.getClass().getSimpleName(), + expression.getVariableName()); return argument; } @@ -1232,15 +1232,14 @@ public StaticContext visitVariableDeclaration(VariableDeclaration expression, St public StaticContext visitFunctionDeclaration(FunctionDeclaration expression, StaticContext argument) { visitDescendants(expression, argument); - InlineFunctionExpression inlineExpression = ((InlineFunctionExpression) expression.getExpression()); + InlineFunctionExpression inlineExpression = (InlineFunctionExpression) expression.getExpression(); SequenceType inferredType = inlineExpression.getBody().getInferredSequenceType(); SequenceType expectedType = inlineExpression.getActualReturnType(); if(expectedType == null){ - // TODO: should i register the function with the inferred type or most general in this case? expectedType = inferredType; - } else if(!inferredType.isSubtypeOf(expectedType)) { - throw new UnexpectedStaticTypeException("The declared function inferred type " + inferredType + " does not match the expected return type " + expectedType); + } else if(!inferredType.isSubtypeOfOrCanBePromotedTo(expectedType)) { + throw new UnexpectedStaticTypeException("The declared function return inferred type " + inferredType + " does not match or can be promoted to the expected return type " + expectedType); } // add function signature to the statically known one diff --git a/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java b/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java index 9eb792f139..ce2469ffc9 100644 --- a/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java +++ b/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java @@ -7,8 +7,7 @@ public class UnexpectedStaticTypeException extends RumbleException { private static final long serialVersionUID = 1L; public UnexpectedStaticTypeException(String message) { - // TODO: investigates errorCode and Metadata - super(message); + super(message, ErrorCode.UnexpectedTypeErrorCode); } public UnexpectedStaticTypeException(String message, ErrorCode errorCode){ From 665ff28645028a51796e6a947087c132eb5d95d6 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Fri, 6 Nov 2020 12:28:00 +0100 Subject: [PATCH 036/206] added JNTY0004 error to Switch clause and empty sequence check to variable reference --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index b211a4dda5..c3aad6e6d5 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -189,6 +189,7 @@ public StaticContext visitVariableReference(VariableReferenceExpression expressi // we also set variableReference type expression.setType(variableType); } + basicChecks(variableType, expression.getClass().getSimpleName(), false, true); System.out.println("visiting variable reference with type: " + variableType); expression.setInferredSequenceType(variableType); return argument; @@ -697,9 +698,12 @@ public void checkSwitchType(SequenceType type){ throw new UnexpectedStaticTypeException("+ and * arities are not allowed for the expressions of switch test condition and cases"); } ItemType itemType = type.getItemType(); - if(itemType.equals(ItemType.functionItem)){ + if(itemType.isSubtypeOf(ItemType.functionItem)){ throw new UnexpectedStaticTypeException("function item not allowed for the expressions of switch test condition and cases", ErrorCode.UnexpectedFunctionITem); } + if(itemType.isSubtypeOf(ItemType.JSONItem)){ + throw new UnexpectedStaticTypeException("switch test condition and cases expressions' item type must match atomic, instead inferred: " + itemType, ErrorCode.NonAtomicElementErrorCode); + } if(!itemType.isSubtypeOf(ItemType.atomicItem)){ throw new UnexpectedStaticTypeException("switch test condition and cases expressions' item type must match atomic, instead inferred: " + itemType); } From 67a8442efac7f50cf89c913b34778669dd3081d7 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Fri, 6 Nov 2020 13:31:38 +0100 Subject: [PATCH 037/206] spotless + added "statically is" expression in grammar, abstract node visitor, translator visitor, and corresponding Expression --- .../rumbledb/compiler/InferTypeVisitor.java | 864 ++++--- .../rumbledb/compiler/TranslationVisitor.java | 22 +- .../org/rumbledb/compiler/VisitorHelpers.java | 4 +- .../config/RumbleRuntimeConfiguration.java | 3 +- .../org/rumbledb/context/StaticContext.java | 38 +- .../UnexpectedStaticTypeException.java | 2 +- .../expressions/AbstractNodeVisitor.java | 9 +- .../org/rumbledb/expressions/Expression.java | 10 +- .../arithmetic/AdditiveExpression.java | 2 +- .../arithmetic/MultiplicativeExpression.java | 2 +- .../arithmetic/UnaryExpression.java | 2 +- .../comparison/ComparisonExpression.java | 2 +- .../flowr/GroupByVariableDeclaration.java | 1 - .../flowr/SimpleMapExpression.java | 2 +- .../DynamicFunctionCallExpression.java | 2 +- .../primary/BooleanLiteralExpression.java | 2 +- .../primary/DecimalLiteralExpression.java | 2 +- .../primary/DoubleLiteralExpression.java | 2 +- .../primary/FunctionCallExpression.java | 2 +- .../primary/InlineFunctionExpression.java | 2 +- .../primary/IntegerLiteralExpression.java | 2 +- .../NamedFunctionReferenceExpression.java | 2 +- .../primary/StringLiteralExpression.java | 2 +- .../primary/VariableReferenceExpression.java | 2 +- .../quantifiers/QuantifiedExpression.java | 2 +- .../expressions/typing/CastExpression.java | 2 +- .../typing/CastableExpression.java | 2 +- .../typing/InstanceOfExpression.java | 2 +- .../typing/StaticallyIsExpression.java | 61 + .../expressions/typing/TreatExpression.java | 2 +- src/main/java/org/rumbledb/parser/Jsoniq.g4 | 4 +- .../java/org/rumbledb/parser/Jsoniq.tokens | 2 + .../rumbledb/parser/JsoniqBaseVisitor.java | 7 + .../org/rumbledb/parser/JsoniqParser.java | 2015 +++++++++-------- .../org/rumbledb/parser/JsoniqVisitor.java | 6 + .../java/org/rumbledb/types/ItemType.java | 1070 ++++++++- .../java/org/rumbledb/types/SequenceType.java | 93 +- 37 files changed, 2825 insertions(+), 1426 deletions(-) create mode 100644 src/main/java/org/rumbledb/expressions/typing/StaticallyIsExpression.java diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index c3aad6e6d5..b2f9c479e2 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -56,47 +56,59 @@ public class InferTypeVisitor extends AbstractNodeVisitor { } /** - * Perform basic checks on a list of SequenceType, available checks are for null (OurBad exception) and inferred the empty sequence (XPST0005) + * Perform basic checks on a list of SequenceType, available checks are for null (OurBad exception) and inferred the + * empty sequence (XPST0005) * * @param types list of sequence types to check * @param nodeName name of the node to use in the errors * @param nullCheck flag indicating to perform null check * @param inferredEmptyCheck flag indicating to perform empty sequence check */ - private void basicChecks(List types, String nodeName, boolean nullCheck, boolean inferredEmptyCheck){ - if(nullCheck){ - for (SequenceType type : types){ - if(type == null){ + private void basicChecks(List types, String nodeName, boolean nullCheck, boolean inferredEmptyCheck) { + if (nullCheck) { + for (SequenceType type : types) { + if (type == null) { throw new OurBadException("A child expression of a " + nodeName + " has no inferred type"); } } } - if(inferredEmptyCheck){ - for (SequenceType type : types){ - if(type.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type for " + nodeName + " is empty sequence (with active static typing feature, only allowed for CommaExpression)", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (inferredEmptyCheck) { + for (SequenceType type : types) { + if (type.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type for " + + nodeName + + " is empty sequence (with active static typing feature, only allowed for CommaExpression)", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } } } } /** - * Perform basic checks on a SequenceType, available checks are for null (OurBad exception) and inferred the empty sequence (XPST0005) + * Perform basic checks on a SequenceType, available checks are for null (OurBad exception) and inferred the empty + * sequence (XPST0005) * * @param type sequence types to check * @param nodeName name of the node to use in the errors * @param nullCheck flag indicating to perform null check * @param inferredEmptyCheck flag indicating to perform empty sequence check */ - private void basicChecks(SequenceType type, String nodeName, boolean nullCheck, boolean inferredEmptyCheck){ - if(nullCheck){ - if(type == null){ + private void basicChecks(SequenceType type, String nodeName, boolean nullCheck, boolean inferredEmptyCheck) { + if (nullCheck) { + if (type == null) { throw new OurBadException("A child expression of a " + nodeName + " has no inferred type"); } } - if(inferredEmptyCheck){ - if(type.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type for " + nodeName + " is empty sequence (with active static typing feature, only allowed for CommaExpression)", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (inferredEmptyCheck) { + if (type.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type for " + + nodeName + + " is empty sequence (with active static typing feature, only allowed for CommaExpression)", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } } } @@ -106,26 +118,31 @@ public StaticContext visitCommaExpression(CommaExpression expression, StaticCont visitDescendants(expression, argument); SequenceType inferredType = SequenceType.EMPTY_SEQUENCE; - - for(Expression childExpression : expression.getExpressions()){ + + for (Expression childExpression : expression.getExpressions()) { SequenceType childExpressionInferredType = childExpression.getInferredSequenceType(); // if a child expression has no inferred type throw an error - if(childExpressionInferredType == null){ + if (childExpressionInferredType == null) { throw new UnexpectedStaticTypeException("A child expression of a CommaExpression has no inferred type"); } // if the child expression is an EMPTY_SEQUENCE it does not affect the comma expression type - if(!childExpressionInferredType.isEmptySequence()){ - if(inferredType.isEmptySequence()){ + if (!childExpressionInferredType.isEmptySequence()) { + if (inferredType.isEmptySequence()) { inferredType = childExpressionInferredType; - } else{ - ItemType resultingItemType = inferredType.getItemType().findCommonSuperType(childExpressionInferredType.getItemType()); - SequenceType.Arity resultingArity = - ( (inferredType.getArity() == SequenceType.Arity.OneOrZero || inferredType.getArity() == SequenceType.Arity.ZeroOrMore) && - (childExpressionInferredType.getArity() == SequenceType.Arity.OneOrZero || childExpressionInferredType.getArity() == SequenceType.Arity.ZeroOrMore)) ? - SequenceType.Arity.ZeroOrMore : SequenceType.Arity.OneOrMore; - inferredType = new SequenceType(resultingItemType, resultingArity); + } else { + ItemType resultingItemType = inferredType.getItemType() + .findCommonSuperType(childExpressionInferredType.getItemType()); + SequenceType.Arity resultingArity = + ((inferredType.getArity() == SequenceType.Arity.OneOrZero + || inferredType.getArity() == SequenceType.Arity.ZeroOrMore) + && + (childExpressionInferredType.getArity() == SequenceType.Arity.OneOrZero + || childExpressionInferredType.getArity() == SequenceType.Arity.ZeroOrMore)) + ? SequenceType.Arity.ZeroOrMore + : SequenceType.Arity.OneOrMore; + inferredType = new SequenceType(resultingItemType, resultingArity); } } } @@ -138,7 +155,7 @@ public StaticContext visitCommaExpression(CommaExpression expression, StaticCont // region primary @Override - public StaticContext visitString(StringLiteralExpression expression, StaticContext argument){ + public StaticContext visitString(StringLiteralExpression expression, StaticContext argument) { System.out.println("visiting String literal"); expression.setInferredSequenceType(new SequenceType(ItemType.stringItem)); return argument; @@ -182,7 +199,7 @@ public StaticContext visitBoolean(BooleanLiteralExpression expression, StaticCon @Override public StaticContext visitVariableReference(VariableReferenceExpression expression, StaticContext argument) { SequenceType variableType = expression.getActualType(); - if(variableType == null){ + if (variableType == null) { // if is null, no 'as [SequenceType]' part was present in the declaration, therefore we infer it System.out.println("variable reference type was null so we infer it"); variableType = expression.getStaticContext().getVariableSequenceType(expression.getVariableName()); @@ -207,23 +224,33 @@ public StaticContext visitArrayConstructor(ArrayConstructorExpression expression public StaticContext visitObjectConstructor(ObjectConstructorExpression expression, StaticContext argument) { System.out.println("visiting Object constructor literal"); visitDescendants(expression, argument); - if(expression.isMergedConstructor()){ + if (expression.isMergedConstructor()) { // if it is a merged constructor the child must be a subtype of object* inferred type SequenceType childSequenceType = ((Expression) expression.getChildren().get(0)).getInferredSequenceType(); - if(childSequenceType == null) { + if (childSequenceType == null) { throw new UnexpectedStaticTypeException("The child expression has no inferred type"); } - if(!childSequenceType.isSubtypeOf(SequenceType.createSequenceType("object*"))){ - throw new UnexpectedStaticTypeException("The child expression must have object* sequence type, instead found: " + childSequenceType); + if (!childSequenceType.isSubtypeOf(SequenceType.createSequenceType("object*"))) { + throw new UnexpectedStaticTypeException( + "The child expression must have object* sequence type, instead found: " + childSequenceType + ); } } else { for (Expression keyExpression : expression.getKeys()) { SequenceType keySequenceType = keyExpression.getInferredSequenceType(); if (keySequenceType == null) { - throw new UnexpectedStaticTypeException("One of the key in the object constructor has no inferred type"); + throw new UnexpectedStaticTypeException( + "One of the key in the object constructor has no inferred type" + ); } - if (!keySequenceType.isSubtypeOf(SequenceType.createSequenceType("string")) && !keySequenceType.isSubtypeOf(SequenceType.createSequenceType("anyURI"))) { - throw new UnexpectedStaticTypeException("The inferred static sequence types for the keys of an Object must be a subtype of string or anyURI, instead found a: " + keySequenceType); + if ( + !keySequenceType.isSubtypeOf(SequenceType.createSequenceType("string")) + && !keySequenceType.isSubtypeOf(SequenceType.createSequenceType("anyURI")) + ) { + throw new UnexpectedStaticTypeException( + "The inferred static sequence types for the keys of an Object must be a subtype of string or anyURI, instead found a: " + + keySequenceType + ); } } } @@ -234,7 +261,7 @@ public StaticContext visitObjectConstructor(ObjectConstructorExpression expressi @Override public StaticContext visitContextExpr(ContextItemExpression expression, StaticContext argument) { SequenceType contextType = expression.getStaticContext().getContextItemStaticType(); - if(contextType == null){ + if (contextType == null) { contextType = new SequenceType(ItemType.item); } expression.setInferredSequenceType(contextType); @@ -266,36 +293,38 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static FunctionSignature signature = null; try { function = BuiltinFunctionCatalogue.getBuiltinFunction(expression.getFunctionIdentifier()); - } catch (OurBadException exception){ + } catch (OurBadException exception) { signature = expression.getStaticContext().getFunctionSignature(expression.getFunctionIdentifier()); } List parameterExpressions = expression.getArguments(); - if(function != null){ + if (function != null) { signature = function.getSignature(); } List parameterTypes = signature.getParameterTypes(); int paramsLength = parameterExpressions.size(); - for(int i = 0; i < paramsLength; ++i){ - if(parameterExpressions.get(i) != null){ + for (int i = 0; i < paramsLength; ++i) { + if (parameterExpressions.get(i) != null) { SequenceType actualType = parameterExpressions.get(i).getInferredSequenceType(); SequenceType expectedType = parameterTypes.get(i); // check actual parameters is either a subtype of or can be promoted to expected type // TODO: should i consider automatic prmotion as valid or not - if(!actualType.isSubtypeOfOrCanBePromotedTo(expectedType)){ - throw new UnexpectedStaticTypeException("Argument " + i + " requires " + expectedType + " but " + actualType + " was found"); + if (!actualType.isSubtypeOfOrCanBePromotedTo(expectedType)) { + throw new UnexpectedStaticTypeException( + "Argument " + i + " requires " + expectedType + " but " + actualType + " was found" + ); } } } - if(expression.isPartialApplication()){ + if (expression.isPartialApplication()) { expression.setInferredSequenceType(new SequenceType(ItemType.functionItem)); } else { SequenceType returnType = signature.getReturnType(); - if(returnType == null){ + if (returnType == null) { returnType = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; } expression.setInferredSequenceType(returnType); @@ -327,23 +356,35 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex SequenceType castedSequenceType = expression.getSequenceType(); // Empty sequence check - if(expressionSequenceType.isEmptySequence() && castedSequenceType.getArity() != SequenceType.Arity.OneOrZero){ - throw new UnexpectedStaticTypeException("Empty sequence cannot be cast to type with quantifier different from '?'"); + if (expressionSequenceType.isEmptySequence() && castedSequenceType.getArity() != SequenceType.Arity.OneOrZero) { + throw new UnexpectedStaticTypeException( + "Empty sequence cannot be cast to type with quantifier different from '?'" + ); } // Arity check - if(!castedSequenceType.isAritySubtypeOf(SequenceType.Arity.OneOrZero)){ + if (!castedSequenceType.isAritySubtypeOf(SequenceType.Arity.OneOrZero)) { throw new UnexpectedStaticTypeException("It is possible to cast only to types with arity '1' or '?'"); } - if(!expressionSequenceType.isAritySubtypeOf(castedSequenceType.getArity())){ - throw new UnexpectedStaticTypeException("It is never possible to cast a " + - expressionSequenceType + " as " + castedSequenceType); + if (!expressionSequenceType.isAritySubtypeOf(castedSequenceType.getArity())) { + throw new UnexpectedStaticTypeException( + "It is never possible to cast a " + + + expressionSequenceType + + " as " + + castedSequenceType + ); } // ItemType static castability check - if(!expressionSequenceType.getItemType().staticallyCastableAs(castedSequenceType.getItemType())){ - throw new UnexpectedStaticTypeException("It is never possible to cast a " + - expressionSequenceType + " as " + castedSequenceType); + if (!expressionSequenceType.getItemType().staticallyCastableAs(castedSequenceType.getItemType())) { + throw new UnexpectedStaticTypeException( + "It is never possible to cast a " + + + expressionSequenceType + + " as " + + castedSequenceType + ); } expression.setInferredSequenceType(castedSequenceType); @@ -367,8 +408,10 @@ public StaticContext visitTreatExpression(TreatExpression expression, StaticCont SequenceType expressionSequenceType = expression.getMainExpression().getInferredSequenceType(); SequenceType treatedSequenceType = expression.getSequenceType(); - if(expressionSequenceType == null || treatedSequenceType == null){ - throw new UnexpectedStaticTypeException("The child expression of a Treat expression has no inferred type or it is being treated as null sequence type"); + if (expressionSequenceType == null || treatedSequenceType == null) { + throw new UnexpectedStaticTypeException( + "The child expression of a Treat expression has no inferred type or it is being treated as null sequence type" + ); } expression.setInferredSequenceType(treatedSequenceType); @@ -388,31 +431,43 @@ public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticCont SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); // if any of the child expression has null inferred type throw error - if(leftInferredType == null || rightInferredType == null){ + if (leftInferredType == null || rightInferredType == null) { throw new UnexpectedStaticTypeException("A child expression of a AdditiveExpression has no inferred type"); } // if any of the children is the empty sequence throw error XPST0005 - if(leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } ItemType inferredType; SequenceType.Arity inferredArity = resolveArities(leftInferredType.getArity(), rightInferredType.getArity()); // arity check - if(inferredArity == null){ + if (inferredArity == null) { throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for additive expressions"); } - inferredType = leftInferredType.getItemType().staticallyAddTo(rightInferredType.getItemType(), expression.isMinus()); + inferredType = leftInferredType.getItemType() + .staticallyAddTo(rightInferredType.getItemType(), expression.isMinus()); - if(inferredType == null){ - if(inferredArity == SequenceType.Arity.OneOrZero){ + if (inferredType == null) { + if (inferredArity == SequenceType.Arity.OneOrZero) { // Only possible resulting type is empty sequence so throw error XPST0005 - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } else { - throw new UnexpectedStaticTypeException("The following types operation is not possible: " + leftInferredType + (expression.isMinus() ? " - " : " + ") + rightInferredType); + throw new UnexpectedStaticTypeException( + "The following types operation is not possible: " + + leftInferredType + + (expression.isMinus() ? " - " : " + ") + + rightInferredType + ); } } @@ -422,10 +477,10 @@ public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticCont } // This function assume 2 numeric ItemType - private ItemType resolveNumericType(ItemType left, ItemType right){ - if(left.equals(ItemType.doubleItem) || right.equals(ItemType.doubleItem)){ + private ItemType resolveNumericType(ItemType left, ItemType right) { + if (left.equals(ItemType.doubleItem) || right.equals(ItemType.doubleItem)) { return ItemType.doubleItem; - } else if(left.equals(ItemType.decimalItem) || right.equals(ItemType.decimalItem)){ + } else if (left.equals(ItemType.decimalItem) || right.equals(ItemType.decimalItem)) { return ItemType.decimalItem; } else { return ItemType.integerItem; @@ -434,14 +489,23 @@ private ItemType resolveNumericType(ItemType left, ItemType right){ // For arithmetic operations, given 2 arities, return the resulting arity or null in case of invalid arity private SequenceType.Arity resolveArities(SequenceType.Arity left, SequenceType.Arity right) { - if(left == null || - left == SequenceType.Arity.ZeroOrMore || - left == SequenceType.Arity.OneOrMore || - right == null || - right == SequenceType.Arity.ZeroOrMore || + if ( + left == null + || + left == SequenceType.Arity.ZeroOrMore + || + left == SequenceType.Arity.OneOrMore + || + right == null + || + right == SequenceType.Arity.ZeroOrMore + || right == SequenceType.Arity.OneOrMore - ) return null; - return (left == SequenceType.Arity.OneOrZero || right == SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.One; + ) + return null; + return (left == SequenceType.Arity.OneOrZero || right == SequenceType.Arity.OneOrZero) + ? SequenceType.Arity.OneOrZero + : SequenceType.Arity.One; } @Override @@ -453,55 +517,83 @@ public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); // if any of the child expression has null inferred type throw error - if(leftInferredType == null || rightInferredType == null){ - throw new UnexpectedStaticTypeException("A child expression of a MultiplicativeExpression has no inferred type"); + if (leftInferredType == null || rightInferredType == null) { + throw new UnexpectedStaticTypeException( + "A child expression of a MultiplicativeExpression has no inferred type" + ); } // if any of the children is the empty sequence throw error XPST0005 - if(leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } ItemType inferredType = null; SequenceType.Arity inferredArity = resolveArities(leftInferredType.getArity(), rightInferredType.getArity()); - if(inferredArity == null){ - throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for multiplicative expressions"); + if (inferredArity == null) { + throw new UnexpectedStaticTypeException( + "'+' and '*' arities are not allowed for multiplicative expressions" + ); } ItemType leftItemType = leftInferredType.getItemType(); ItemType rightItemType = rightInferredType.getItemType(); // check resulting item for each operation - if(leftItemType.isNumeric()){ - if(rightItemType.isNumeric()){ - if(expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.IDIV){ + if (leftItemType.isNumeric()) { + if (rightItemType.isNumeric()) { + if (expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.IDIV) { inferredType = ItemType.integerItem; - } else if(expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV) { - inferredType = resolveNumericType(ItemType.decimalItem, resolveNumericType(leftItemType, rightItemType)); + } else if ( + expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV + ) { + inferredType = resolveNumericType( + ItemType.decimalItem, + resolveNumericType(leftItemType, rightItemType) + ); } else { inferredType = resolveNumericType(leftItemType, rightItemType); } - } else if(rightItemType.isSubtypeOf(ItemType.durationItem) && - expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL){ + } else if ( + rightItemType.isSubtypeOf(ItemType.durationItem) + && + expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL + ) { inferredType = rightItemType; } - } else if(leftItemType.isSubtypeOf(ItemType.durationItem)){ - if(rightItemType.isNumeric() && ( - expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL || - expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV )){ + } else if (leftItemType.isSubtypeOf(ItemType.durationItem)) { + if ( + rightItemType.isNumeric() + && (expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL + || + expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV) + ) { inferredType = rightItemType; - } else if(rightItemType.equals(leftItemType) && !leftItemType.equals(ItemType.durationItem)){ + } else if (rightItemType.equals(leftItemType) && !leftItemType.equals(ItemType.durationItem)) { inferredType = ItemType.decimalItem; } } - if(inferredType == null){ - if(inferredArity == SequenceType.Arity.OneOrZero){ + if (inferredType == null) { + if (inferredArity == SequenceType.Arity.OneOrZero) { // Only possible resulting type is empty sequence so throw error XPST0005 - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } else { - throw new UnexpectedStaticTypeException("The following types expression is not valid: " + leftItemType + " " + expression.getMultiplicativeOperator() + " " + rightItemType); + throw new UnexpectedStaticTypeException( + "The following types expression is not valid: " + + leftItemType + + " " + + expression.getMultiplicativeOperator() + + " " + + rightItemType + ); } } @@ -516,26 +608,38 @@ public StaticContext visitUnaryExpr(UnaryExpression expression, StaticContext ar SequenceType childInferredType = expression.getMainExpression().getInferredSequenceType(); // if the child expression has null inferred type throw error - if(childInferredType == null){ + if (childInferredType == null) { throw new UnexpectedStaticTypeException("The child expression of a UnaryExpression has no inferred type"); } // if the child is the empty sequence just infer the empty sequence - if(childInferredType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (childInferredType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } - if(childInferredType.getArity() == SequenceType.Arity.OneOrMore || childInferredType.getArity() == SequenceType.Arity.ZeroOrMore){ + if ( + childInferredType.getArity() == SequenceType.Arity.OneOrMore + || childInferredType.getArity() == SequenceType.Arity.ZeroOrMore + ) { throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for unary expressions"); } - // if inferred arity does not allow for empty sequence and static type is not an accepted one throw a static error + // if inferred arity does not allow for empty sequence and static type is not an accepted one throw a static + // error ItemType childItemType = childInferredType.getItemType(); - if(!childItemType.isNumeric()){ - if(childInferredType.getArity() == SequenceType.Arity.OneOrZero){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (!childItemType.isNumeric()) { + if (childInferredType.getArity() == SequenceType.Arity.OneOrZero) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } else { - throw new UnexpectedStaticTypeException("It is not possible to have an Unary expression with the following type: " + childInferredType); + throw new UnexpectedStaticTypeException( + "It is not possible to have an Unary expression with the following type: " + childInferredType + ); } } @@ -548,23 +652,37 @@ public StaticContext visitUnaryExpr(UnaryExpression expression, StaticContext ar // region logic - private StaticContext visitAndOrExpr(Expression expression, StaticContext argument, String expressionName){ + private StaticContext visitAndOrExpr(Expression expression, StaticContext argument, String expressionName) { visitDescendants(expression, argument); List childrenExpressions = expression.getChildren(); SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); - if(leftInferredType == null || rightInferredType == null){ - throw new UnexpectedStaticTypeException("A child expression of a " + expressionName + "Expression has no inferred type"); + if (leftInferredType == null || rightInferredType == null) { + throw new UnexpectedStaticTypeException( + "A child expression of a " + expressionName + "Expression has no inferred type" + ); } - if(!leftInferredType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("left expression of a " + expressionName + "Expression has " + leftInferredType + " inferred type, which has no effective boolean value"); + if (!leftInferredType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "left expression of a " + + expressionName + + "Expression has " + + leftInferredType + + " inferred type, which has no effective boolean value" + ); } - if(!rightInferredType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("right expression of a " + expressionName + "Expression has " + rightInferredType + " inferred type, which has no effective boolean value"); + if (!rightInferredType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "right expression of a " + + expressionName + + "Expression has " + + rightInferredType + + " inferred type, which has no effective boolean value" + ); } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); @@ -586,11 +704,15 @@ public StaticContext visitNotExpr(NotExpression expression, StaticContext argume visitDescendants(expression, argument); SequenceType childInferredType = expression.getMainExpression().getInferredSequenceType(); - if(childInferredType == null){ + if (childInferredType == null) { throw new UnexpectedStaticTypeException("The child expression of NotExpression has no inferred type"); } - if(!childInferredType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("The child expression of NotExpression has " + childInferredType + " inferred type, which has no effective boolean value"); + if (!childInferredType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "The child expression of NotExpression has " + + childInferredType + + " inferred type, which has no effective boolean value" + ); } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); @@ -609,19 +731,27 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); - if(leftInferredType == null || rightInferredType == null){ - throw new UnexpectedStaticTypeException("A child expression of a ComparisonExpression has no inferred type"); + if (leftInferredType == null || rightInferredType == null) { + throw new UnexpectedStaticTypeException( + "A child expression of a ComparisonExpression has no inferred type" + ); } ComparisonExpression.ComparisonOperator operator = expression.getComparisonOperator(); - // for value comparison arities * and + are not allowed, also if one return the empty sequence for sure throw XPST0005 error - if(operator.isValueComparison()){ - if(leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + // for value comparison arities * and + are not allowed, also if one return the empty sequence for sure throw + // XPST0005 error + if (operator.isValueComparison()) { + if (leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } - if(resolveArities(leftInferredType.getArity(), rightInferredType.getArity()) == null){ - throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for this comparison operator: " + operator); + if (resolveArities(leftInferredType.getArity(), rightInferredType.getArity()) == null) { + throw new UnexpectedStaticTypeException( + "'+' and '*' arities are not allowed for this comparison operator: " + operator + ); } } @@ -629,28 +759,51 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static ItemType rightItemType = rightInferredType.getItemType(); // Type must be a strict subtype of atomic - if(!leftItemType.isSubtypeOf(ItemType.atomicItem) || !rightItemType.isSubtypeOf(ItemType.atomicItem) || leftItemType.equals(ItemType.atomicItem) || rightItemType.equals(ItemType.atomicItem)){ + if ( + !leftItemType.isSubtypeOf(ItemType.atomicItem) + || !rightItemType.isSubtypeOf(ItemType.atomicItem) + || leftItemType.equals(ItemType.atomicItem) + || rightItemType.equals(ItemType.atomicItem) + ) { throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types"); } // Type must match exactly or be both numeric or both promotable to string or both durations - if(!leftItemType.equals(rightItemType) && - !(leftItemType.isNumeric() && rightItemType.isNumeric()) && - !(leftItemType.isSubtypeOf(ItemType.durationItem) && rightItemType.isSubtypeOf(ItemType.durationItem)) && - !(leftItemType.canBePromotedToString() && rightItemType.canBePromotedToString())){ - throw new UnexpectedStaticTypeException("It is not possible to compare these types: " + leftItemType + " and " + rightItemType); + if ( + !leftItemType.equals(rightItemType) + && + !(leftItemType.isNumeric() && rightItemType.isNumeric()) + && + !(leftItemType.isSubtypeOf(ItemType.durationItem) && rightItemType.isSubtypeOf(ItemType.durationItem)) + && + !(leftItemType.canBePromotedToString() && rightItemType.canBePromotedToString()) + ) { + throw new UnexpectedStaticTypeException( + "It is not possible to compare these types: " + leftItemType + " and " + rightItemType + ); } // Inequality is not defined for hexBinary and base64binary or for duration of different types - if((operator != ComparisonExpression.ComparisonOperator.VC_EQ && - operator != ComparisonExpression.ComparisonOperator.VC_NE && - operator != ComparisonExpression.ComparisonOperator.GC_EQ && - operator != ComparisonExpression.ComparisonOperator.GC_NE) && ( - leftItemType.equals(ItemType.hexBinaryItem) || leftItemType.equals(ItemType.base64BinaryItem) || - leftItemType.equals(ItemType.durationItem) || rightItemType.equals(ItemType.durationItem) || - ((leftItemType.equals(ItemType.dayTimeDurationItem) || leftItemType.equals(ItemType.yearMonthDurationItem)) && !rightItemType.equals(leftItemType)) - )){ - throw new UnexpectedStaticTypeException("It is not possible to compare these types: " + leftItemType + " " + operator + " " + rightItemType); + if ( + (operator != ComparisonExpression.ComparisonOperator.VC_EQ + && + operator != ComparisonExpression.ComparisonOperator.VC_NE + && + operator != ComparisonExpression.ComparisonOperator.GC_EQ + && + operator != ComparisonExpression.ComparisonOperator.GC_NE) + && (leftItemType.equals(ItemType.hexBinaryItem) + || leftItemType.equals(ItemType.base64BinaryItem) + || + leftItemType.equals(ItemType.durationItem) + || rightItemType.equals(ItemType.durationItem) + || + ((leftItemType.equals(ItemType.dayTimeDurationItem) + || leftItemType.equals(ItemType.yearMonthDurationItem)) && !rightItemType.equals(leftItemType))) + ) { + throw new UnexpectedStaticTypeException( + "It is not possible to compare these types: " + leftItemType + " " + operator + " " + rightItemType + ); } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); @@ -669,16 +822,23 @@ public StaticContext visitConditionalExpression(ConditionalExpression expression SequenceType thenType = expression.getBranch().getInferredSequenceType(); SequenceType elseType = expression.getElseBranch().getInferredSequenceType(); - if(ifType == null || thenType == null || elseType == null){ + if (ifType == null || thenType == null || elseType == null) { throw new OurBadException("A child expression of a ConditionalExpression has no inferred type"); } - if(!ifType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("The condition in the 'if' must have effective boolean value, found inferred type: " + ifType + " (which has not effective boolean value)"); + if (!ifType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "The condition in the 'if' must have effective boolean value, found inferred type: " + + ifType + + " (which has not effective boolean value)" + ); } - if(thenType.isEmptySequence() && elseType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (thenType.isEmptySequence() && elseType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } expression.setInferredSequenceType(thenType.leastCommonSupertypeWith(elseType)); @@ -687,25 +847,37 @@ public StaticContext visitConditionalExpression(ConditionalExpression expression } // throw errors if [type] does not conform to switch test and cases requirements - public void checkSwitchType(SequenceType type){ - if(type == null){ + public void checkSwitchType(SequenceType type) { + if (type == null) { throw new OurBadException("A child expression of a SwitchExpression has no inferred type"); } - if(type.isEmptySequence()){ + if (type.isEmptySequence()) { return; // no further check is required } - if(type.getArity() == SequenceType.Arity.OneOrZero || type.getArity() == SequenceType.Arity.ZeroOrMore){ - throw new UnexpectedStaticTypeException("+ and * arities are not allowed for the expressions of switch test condition and cases"); + if (type.getArity() == SequenceType.Arity.OneOrZero || type.getArity() == SequenceType.Arity.ZeroOrMore) { + throw new UnexpectedStaticTypeException( + "+ and * arities are not allowed for the expressions of switch test condition and cases" + ); } ItemType itemType = type.getItemType(); - if(itemType.isSubtypeOf(ItemType.functionItem)){ - throw new UnexpectedStaticTypeException("function item not allowed for the expressions of switch test condition and cases", ErrorCode.UnexpectedFunctionITem); - } - if(itemType.isSubtypeOf(ItemType.JSONItem)){ - throw new UnexpectedStaticTypeException("switch test condition and cases expressions' item type must match atomic, instead inferred: " + itemType, ErrorCode.NonAtomicElementErrorCode); - } - if(!itemType.isSubtypeOf(ItemType.atomicItem)){ - throw new UnexpectedStaticTypeException("switch test condition and cases expressions' item type must match atomic, instead inferred: " + itemType); + if (itemType.isSubtypeOf(ItemType.functionItem)) { + throw new UnexpectedStaticTypeException( + "function item not allowed for the expressions of switch test condition and cases", + ErrorCode.UnexpectedFunctionITem + ); + } + if (itemType.isSubtypeOf(ItemType.JSONItem)) { + throw new UnexpectedStaticTypeException( + "switch test condition and cases expressions' item type must match atomic, instead inferred: " + + itemType, + ErrorCode.NonAtomicElementErrorCode + ); + } + if (!itemType.isSubtypeOf(ItemType.atomicItem)) { + throw new UnexpectedStaticTypeException( + "switch test condition and cases expressions' item type must match atomic, instead inferred: " + + itemType + ); } } @@ -716,25 +888,25 @@ public StaticContext visitSwitchExpression(SwitchExpression expression, StaticCo checkSwitchType(testType); SequenceType returnType = expression.getDefaultExpression().getInferredSequenceType(); - if(returnType == null){ + if (returnType == null) { throw new OurBadException("A child expression of a SwitchExpression has no inferred type"); } - for(SwitchCase switchCase : expression.getCases()){ + for (SwitchCase switchCase : expression.getCases()) { boolean addToReturnType = false; - for(Expression caseExpression : switchCase.getConditionExpressions()){ + for (Expression caseExpression : switchCase.getConditionExpressions()) { // test the case expression checkSwitchType(caseExpression.getInferredSequenceType()); // if has overlap with the test condition will add the return type to the possible ones - if(caseExpression.getInferredSequenceType().hasOverlapWith(testType)){ + if (caseExpression.getInferredSequenceType().hasOverlapWith(testType)) { addToReturnType = true; } } SequenceType caseReturnType = switchCase.getReturnExpression().getInferredSequenceType(); - if(caseReturnType == null){ + if (caseReturnType == null) { throw new OurBadException("A child expression of a SwitchExpression has no inferred type"); } - if(addToReturnType){ + if (addToReturnType) { returnType = returnType.leastCommonSupertypeWith(caseReturnType); } } @@ -749,21 +921,24 @@ public StaticContext visitTryCatchExpression(TryCatchExpression expression, Stat visitDescendants(expression, argument); SequenceType inferredType = null; - for(Node childNode : expression.getChildren()){ + for (Node childNode : expression.getChildren()) { SequenceType childType = ((Expression) childNode).getInferredSequenceType(); - if(childType == null){ + if (childType == null) { throw new OurBadException("A child expression of a TryCatchExpression has no inferred type"); } - if(inferredType == null){ + if (inferredType == null) { inferredType = childType; } else { inferredType = inferredType.leastCommonSupertypeWith(childType); } } - if(inferredType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (inferredType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } expression.setInferredSequenceType(inferredType); System.out.println("visiting TryCatch expression, type set to: " + expression.getInferredSequenceType()); @@ -778,13 +953,13 @@ public StaticContext visitTypeSwitchExpression(TypeSwitchExpression expression, SequenceType conditionType = expression.getTestCondition().getInferredSequenceType(); basicChecks(conditionType, expression.getClass().getSimpleName(), true, false); - for(TypeswitchCase typeswitchCase : expression.getCases()){ + for (TypeswitchCase typeswitchCase : expression.getCases()) { Name variableName = typeswitchCase.getVariableName(); Expression returnExpression = typeswitchCase.getReturnExpression(); // if we bind a variable we add the static type of it in the context of the return expression - if(variableName != null){ + if (variableName != null) { SequenceType variableType = null; - for(SequenceType st : typeswitchCase.getUnion()){ + for (SequenceType st : typeswitchCase.getUnion()) { variableType = variableType == null ? st : variableType.leastCommonSupertypeWith(st); } returnExpression.getStaticContext().replaceVariableSequenceType(variableName, variableType); @@ -799,7 +974,7 @@ public StaticContext visitTypeSwitchExpression(TypeSwitchExpression expression, Name variableName = expression.getDefaultCase().getVariableName(); Expression returnExpression = expression.getDefaultCase().getReturnExpression(); // if we bind a variable in the default case, we infer testCondition type - if(variableName != null){ + if (variableName != null) { returnExpression.getStaticContext().replaceVariableSequenceType(variableName, conditionType); } visit(returnExpression, argument); @@ -825,17 +1000,25 @@ public StaticContext visitRangeExpr(RangeExpression expression, StaticContext ar SequenceType leftType = ((Expression) children.get(0)).getInferredSequenceType(); SequenceType rightType = ((Expression) children.get(1)).getInferredSequenceType(); - if(leftType == null || rightType == null){ + if (leftType == null || rightType == null) { throw new OurBadException("A child expression of a RangeExpression has no inferred type"); } - if(leftType.isEmptySequence() || rightType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (leftType.isEmptySequence() || rightType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } SequenceType intOpt = new SequenceType(ItemType.integerItem, SequenceType.Arity.OneOrZero); - if(!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)){ - throw new UnexpectedStaticTypeException("operands of the range expression must match type integer? instead found: " + leftType + " and " + rightType); + if (!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)) { + throw new UnexpectedStaticTypeException( + "operands of the range expression must match type integer? instead found: " + + leftType + + " and " + + rightType + ); } expression.setInferredSequenceType(new SequenceType(ItemType.integerItem, SequenceType.Arity.ZeroOrMore)); @@ -851,13 +1034,18 @@ public StaticContext visitStringConcatExpr(StringConcatExpression expression, St SequenceType leftType = ((Expression) children.get(0)).getInferredSequenceType(); SequenceType rightType = ((Expression) children.get(1)).getInferredSequenceType(); - if(leftType == null || rightType == null){ + if (leftType == null || rightType == null) { throw new OurBadException("A child expression of a ConcatExpression has no inferred type"); } SequenceType intOpt = new SequenceType(ItemType.atomicItem, SequenceType.Arity.OneOrZero); - if(!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)){ - throw new UnexpectedStaticTypeException("operands of the concat expression must match type atomic? instead found: " + leftType + " and " + rightType); + if (!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)) { + throw new UnexpectedStaticTypeException( + "operands of the concat expression must match type atomic? instead found: " + + leftType + + " and " + + rightType + ); } expression.setInferredSequenceType(new SequenceType(ItemType.stringItem)); @@ -873,26 +1061,36 @@ public StaticContext visitStringConcatExpr(StringConcatExpression expression, St public StaticContext visitQuantifiedExpression(QuantifiedExpression expression, StaticContext argument) { Expression evaluationExpression = (Expression) expression.getEvaluationExpression(); boolean skipTestInference = false; - for(QuantifiedExpressionVar var : expression.getVariables()){ + for (QuantifiedExpressionVar var : expression.getVariables()) { visit(var.getExpression(), argument); SequenceType inferredType = var.getExpression().getInferredSequenceType(); basicChecks(inferredType, expression.getClass().getSimpleName(), true, false); SequenceType varType = var.getActualSequenceType(); - if(inferredType.isEmptySequence()){ + if (inferredType.isEmptySequence()) { skipTestInference = true; } else { - checkVariableType(varType, inferredType, evaluationExpression.getStaticContext(), expression.getClass().getSimpleName(), var.getVariableName()); + checkVariableType( + varType, + inferredType, + evaluationExpression.getStaticContext(), + expression.getClass().getSimpleName(), + var.getVariableName() + ); } } - if(!skipTestInference){ + if (!skipTestInference) { visit(evaluationExpression, argument); SequenceType evaluationType = evaluationExpression.getInferredSequenceType(); basicChecks(evaluationType, expression.getClass().getSimpleName(), true, false); - if(!evaluationType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("evaluation expression of quantified expression has " + evaluationType + " inferred type, which has no effective boolean value"); + if (!evaluationType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "evaluation expression of quantified expression has " + + evaluationType + + " inferred type, which has no effective boolean value" + ); } } @@ -913,19 +1111,26 @@ public StaticContext visitArrayLookupExpression(ArrayLookupExpression expression SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); SequenceType lookupType = expression.getLookupExpression().getInferredSequenceType(); - if(mainType == null || lookupType == null){ + if (mainType == null || lookupType == null) { throw new OurBadException("A child expression of a ArrayLookupExpression has no inferred type"); } - if(!lookupType.isSubtypeOf(SequenceType.createSequenceType("integer"))){ - throw new UnexpectedStaticTypeException("the lookup expression type must match integer, instead " + lookupType + " was inferred"); + if (!lookupType.isSubtypeOf(SequenceType.createSequenceType("integer"))) { + throw new UnexpectedStaticTypeException( + "the lookup expression type must match integer, instead " + lookupType + " was inferred" + ); } - if(!mainType.hasOverlapWith(SequenceType.createSequenceType("array*")) || mainType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (!mainType.hasOverlapWith(SequenceType.createSequenceType("array*")) || mainType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } - SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; + SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) + ? SequenceType.Arity.OneOrZero + : SequenceType.Arity.ZeroOrMore; expression.setInferredSequenceType(new SequenceType(ItemType.arrayItem, inferredArity)); System.out.println("visiting ArrayLookup expression, type set to: " + expression.getInferredSequenceType()); return argument; @@ -938,20 +1143,29 @@ public StaticContext visitObjectLookupExpression(ObjectLookupExpression expressi SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); SequenceType lookupType = expression.getLookupExpression().getInferredSequenceType(); - if(mainType == null || lookupType == null){ + if (mainType == null || lookupType == null) { throw new OurBadException("A child expression of a ObjectLookupExpression has no inferred type"); } // must be castable to string - if(!lookupType.isSubtypeOf(SequenceType.createSequenceType("atomic"))){ - throw new UnexpectedStaticTypeException("the lookup expression type must be castable to string (i.e. must match atomic), instead " + lookupType + " was inferred"); + if (!lookupType.isSubtypeOf(SequenceType.createSequenceType("atomic"))) { + throw new UnexpectedStaticTypeException( + "the lookup expression type must be castable to string (i.e. must match atomic), instead " + + lookupType + + " was inferred" + ); } - if(!mainType.hasOverlapWith(SequenceType.createSequenceType("object*")) || mainType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (!mainType.hasOverlapWith(SequenceType.createSequenceType("object*")) || mainType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } - SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; + SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) + ? SequenceType.Arity.OneOrZero + : SequenceType.Arity.ZeroOrMore; expression.setInferredSequenceType(new SequenceType(ItemType.objectItem, inferredArity)); System.out.println("visiting ObjectLookup expression, type set to: " + expression.getInferredSequenceType()); return argument; @@ -963,16 +1177,21 @@ public StaticContext visitArrayUnboxingExpression(ArrayUnboxingExpression expres SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); - if(mainType == null){ + if (mainType == null) { throw new OurBadException("A child expression of a ArrayUnboxingExpression has no inferred type"); } - if(!mainType.hasOverlapWith(SequenceType.createSequenceType("array*")) || mainType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (!mainType.hasOverlapWith(SequenceType.createSequenceType("array*")) || mainType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } expression.setInferredSequenceType(SequenceType.createSequenceType("item*")); - System.out.println("visiting ArrayUnboxingExpression expression, type set to: " + expression.getInferredSequenceType()); + System.out.println( + "visiting ArrayUnboxingExpression expression, type set to: " + expression.getInferredSequenceType() + ); return argument; } @@ -992,34 +1211,50 @@ public StaticContext visitFilterExpression(FilterExpression expression, StaticCo basicChecks(predicateType, expression.getClass().getSimpleName(), true, true); // always false so the return type is for sure () - if(predicateType.isSubtypeOf(SequenceType.createSequenceType("null?"))){ - throw new UnexpectedStaticTypeException("Inferred type for FilterExpression is empty sequence (with active static typing feature, only allowed for CommaExpression)", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); - } - if(!predicateType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("Inferred type " + predicateType + " in FilterExpression has no effective boolean value"); - } - - // if we are filter one or less items or we use an integer to select a specific position we return at most one element, otherwise * - SequenceType.Arity inferredArity = (mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) || mainType.getItemType().equals(ItemType.integerItem)) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; + if (predicateType.isSubtypeOf(SequenceType.createSequenceType("null?"))) { + throw new UnexpectedStaticTypeException( + "Inferred type for FilterExpression is empty sequence (with active static typing feature, only allowed for CommaExpression)", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); + } + if (!predicateType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "Inferred type " + predicateType + " in FilterExpression has no effective boolean value" + ); + } + + // if we are filter one or less items or we use an integer to select a specific position we return at most one + // element, otherwise * + SequenceType.Arity inferredArity = (mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) + || mainType.getItemType().equals(ItemType.integerItem)) + ? SequenceType.Arity.OneOrZero + : SequenceType.Arity.ZeroOrMore; expression.setInferredSequenceType(new SequenceType(mainType.getItemType(), inferredArity)); System.out.println("visiting Filter expression, type set to: " + expression.getInferredSequenceType()); return argument; } @Override - public StaticContext visitDynamicFunctionCallExpression(DynamicFunctionCallExpression expression, StaticContext argument) { + public StaticContext visitDynamicFunctionCallExpression( + DynamicFunctionCallExpression expression, + StaticContext argument + ) { // since we do not specify function's signature in the itemType we can only check that it is a function visitDescendants(expression, argument); SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); basicChecks(mainType, expression.getClass().getSimpleName(), true, false); - if(!mainType.equals(new SequenceType(ItemType.functionItem))){ - throw new UnexpectedStaticTypeException("the type of a dynamic function call main expression must be function, instead inferred " + mainType); + if (!mainType.equals(new SequenceType(ItemType.functionItem))) { + throw new UnexpectedStaticTypeException( + "the type of a dynamic function call main expression must be function, instead inferred " + mainType + ); } // TODO: need to add support for partial application expression.setInferredSequenceType(SequenceType.MOST_GENERAL_SEQUENCE_TYPE); - System.out.println("visiting DynamicFunctionCall expression, type set to: " + expression.getInferredSequenceType()); + System.out.println( + "visiting DynamicFunctionCall expression, type set to: " + expression.getInferredSequenceType() + ); return argument; } @@ -1057,14 +1292,16 @@ public StaticContext visitFlowrExpression(FlworExpression expression, StaticCont SequenceType.Arity forArities = SequenceType.Arity.One; // One is arity multiplication's neutral element SequenceType forType; - while (clause != null){ + while (clause != null) { this.visit(clause, argument); // if there are for clauses we need to consider their arities for the returning expression - if(clause.getClauseType() == FLWOR_CLAUSES.FOR){ - forType = ((ForClause) clause).getExpression().getInferredSequenceType(); - // if forType is the empty sequence that means that allowing empty is set otherwise we would have thrown an error - // therefore this for loop will generate one tuple binding the empty sequence, so as for the arities count as arity.One - if(!forType.isEmptySequence()){ + if (clause.getClauseType() == FLWOR_CLAUSES.FOR) { + forType = ((ForClause) clause).getExpression().getInferredSequenceType(); + // if forType is the empty sequence that means that allowing empty is set otherwise we would have thrown + // an error + // therefore this for loop will generate one tuple binding the empty sequence, so as for the arities + // count as arity.One + if (!forType.isEmptySequence()) { forArities = forType.getArity().multiplyWith(forArities); } } @@ -1084,27 +1321,39 @@ public StaticContext visitForClause(ForClause expression, StaticContext argument visit(expression.getExpression(), argument); SequenceType declaredType = expression.getActualSequenceType(); - SequenceType inferredType = (declaredType == null ? expression.getExpression() : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); + SequenceType inferredType = (declaredType == null + ? expression.getExpression() + : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); basicChecks(inferredType, expression.getClass().getSimpleName(), true, false); - if(inferredType.isEmptySequence()){ - if(!expression.isAllowEmpty()) { + if (inferredType.isEmptySequence()) { + if (!expression.isAllowEmpty()) { // for sure we will not have any tuple to process and return the empty sequence - throw new UnexpectedStaticTypeException("In for clause Inferred type is empty sequence, empty is not allowed, so the result returned is for sure () and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + throw new UnexpectedStaticTypeException( + "In for clause Inferred type is empty sequence, empty is not allowed, so the result returned is for sure () and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } } else { - // we take the single arity version of the inferred type or optional arity if we allow empty and the sequence allows () (i.e. arity ? or *) - if(expression.isAllowEmpty() && (inferredType.getArity() == SequenceType.Arity.OneOrZero || inferredType.getArity() == SequenceType.Arity.ZeroOrMore)){ + // we take the single arity version of the inferred type or optional arity if we allow empty and the + // sequence allows () (i.e. arity ? or *) + if ( + expression.isAllowEmpty() + && (inferredType.getArity() == SequenceType.Arity.OneOrZero + || inferredType.getArity() == SequenceType.Arity.ZeroOrMore) + ) { inferredType = new SequenceType(inferredType.getItemType(), SequenceType.Arity.OneOrZero); } else { inferredType = new SequenceType(inferredType.getItemType()); } } - checkVariableType(declaredType, - inferredType, - expression.getNextClause().getStaticContext(), - expression.getClass().getSimpleName(), - expression.getVariableName()); + checkVariableType( + declaredType, + inferredType, + expression.getNextClause().getStaticContext(), + expression.getClass().getSimpleName(), + expression.getVariableName() + ); System.out.println("visiting For clause, inferred var " + expression.getVariableName() + " : " + inferredType); return argument; @@ -1114,12 +1363,16 @@ public StaticContext visitForClause(ForClause expression, StaticContext argument public StaticContext visitLetClause(LetClause expression, StaticContext argument) { visit(expression.getExpression(), argument); SequenceType declaredType = expression.getActualSequenceType(); - SequenceType inferredType = (declaredType == null ? expression.getExpression() : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); - checkVariableType(declaredType, - inferredType, - expression.getNextClause().getStaticContext(), - expression.getClass().getSimpleName(), - expression.getVariableName()); + SequenceType inferredType = (declaredType == null + ? expression.getExpression() + : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); + checkVariableType( + declaredType, + inferredType, + expression.getNextClause().getStaticContext(), + expression.getClass().getSimpleName(), + expression.getVariableName() + ); System.out.println("visiting Let clause, var " + expression.getVariableName() + " : " + inferredType); return argument; @@ -1130,50 +1383,64 @@ public StaticContext visitWhereClause(WhereClause expression, StaticContext argu visit(expression.getWhereExpression(), argument); SequenceType whereType = expression.getWhereExpression().getInferredSequenceType(); basicChecks(whereType, expression.getClass().getSimpleName(), true, false); - if(!whereType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("where clause inferred type (" + whereType + ") has no effective boolean value"); + if (!whereType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "where clause inferred type (" + whereType + ") has no effective boolean value" + ); } - if(whereType.isEmptySequence() || whereType.isSubtypeOf(SequenceType.createSequenceType("null?"))){ - throw new UnexpectedStaticTypeException("where clause always return false, so return expression inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (whereType.isEmptySequence() || whereType.isSubtypeOf(SequenceType.createSequenceType("null?"))) { + throw new UnexpectedStaticTypeException( + "where clause always return false, so return expression inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } return argument; } @Override public StaticContext visitGroupByClause(GroupByClause expression, StaticContext argument) { - Clause nextClause = expression.getNextClause(); // != null because group by cannot be last clause of FLOWR expression + Clause nextClause = expression.getNextClause(); // != null because group by cannot be last clause of FLOWR + // expression Set groupingVars = new HashSet<>(); - for(GroupByVariableDeclaration groupByVar : expression.getGroupVariables()){ + for (GroupByVariableDeclaration groupByVar : expression.getGroupVariables()) { // if we are grouping by an existing var (i.e. expr is null), then the appropriate type is already inferred Expression groupByVarExpr = groupByVar.getExpression(); SequenceType expectedType; - if(groupByVarExpr != null){ + if (groupByVarExpr != null) { visit(groupByVarExpr, argument); SequenceType declaredType = groupByVar.getActualSequenceType(); SequenceType inferredType; - if(declaredType == null){ + if (declaredType == null) { inferredType = groupByVarExpr.getInferredSequenceType(); expectedType = inferredType; } else { inferredType = ((TreatExpression) groupByVarExpr).getMainExpression().getInferredSequenceType(); expectedType = declaredType; } - checkVariableType(declaredType, - inferredType, - nextClause.getStaticContext(), - expression.getClass().getSimpleName(), - groupByVar.getVariableName()); + checkVariableType( + declaredType, + inferredType, + nextClause.getStaticContext(), + expression.getClass().getSimpleName(), + groupByVar.getVariableName() + ); } else { expectedType = expression.getStaticContext().getVariableSequenceType(groupByVar.getVariableName()); } // check that expectedType is a subtype of atomic? - if(!expectedType.isSubtypeOf(SequenceType.createSequenceType("atomic?"))){ - throw new UnexpectedStaticTypeException("group by variable " + groupByVar.getVariableName() + " must match atomic? instead found " + expectedType); + if (!expectedType.isSubtypeOf(SequenceType.createSequenceType("atomic?"))) { + throw new UnexpectedStaticTypeException( + "group by variable " + + groupByVar.getVariableName() + + " must match atomic? instead found " + + expectedType + ); } groupingVars.add(groupByVar.getVariableName()); } - // finally if there was a for clause we need to change the arity of the variables binded so far in the flowr expression, from ? to * and from 1 to + + // finally if there was a for clause we need to change the arity of the variables binded so far in the flowr + // expression, from ? to * and from 1 to + // excluding the grouping variables StaticContext firstClauseStaticContext = expression.getFirstClause().getStaticContext(); nextClause.getStaticContext().incrementArities(firstClauseStaticContext, groupingVars); @@ -1183,15 +1450,24 @@ public StaticContext visitGroupByClause(GroupByClause expression, StaticContext @Override public StaticContext visitOrderByClause(OrderByClause expression, StaticContext argument) { visitDescendants(expression, argument); - for(OrderByClauseSortingKey orderClause : expression.getSortingKeys()){ + for (OrderByClauseSortingKey orderClause : expression.getSortingKeys()) { SequenceType orderType = orderClause.getExpression().getInferredSequenceType(); basicChecks(orderType, expression.getClass().getSimpleName(), true, false); - if(!orderType.isSubtypeOf(SequenceType.createSequenceType("atomic?")) || - orderType.getItemType().equals(ItemType.atomicItem) || - orderType.getItemType().equals(ItemType.durationItem) || - orderType.getItemType().equals(ItemType.hexBinaryItem) || - orderType.getItemType().equals(ItemType.base64BinaryItem)){ - throw new UnexpectedStaticTypeException("order by sorting expression's type must match atomic? and be comparable using 'gt' operator (so duration, hexBinary, base64Binary and atomic item type are not allowed), instead inferred: " + orderType); + if ( + !orderType.isSubtypeOf(SequenceType.createSequenceType("atomic?")) + || + orderType.getItemType().equals(ItemType.atomicItem) + || + orderType.getItemType().equals(ItemType.durationItem) + || + orderType.getItemType().equals(ItemType.hexBinaryItem) + || + orderType.getItemType().equals(ItemType.base64BinaryItem) + ) { + throw new UnexpectedStaticTypeException( + "order by sorting expression's type must match atomic? and be comparable using 'gt' operator (so duration, hexBinary, base64Binary and atomic item type are not allowed), instead inferred: " + + orderType + ); } } @@ -1202,18 +1478,36 @@ public StaticContext visitOrderByClause(OrderByClause expression, StaticContext // region module - // if [declaredType] is not null, check if the inferred type matches or can be promoted to the declared type (otherwise throw type error) + // if [declaredType] is not null, check if the inferred type matches or can be promoted to the declared type + // (otherwise throw type error) // if [declaredType] is null, replace the type of [variableName] in the [context] with the inferred type - public void checkVariableType(SequenceType declaredType, SequenceType inferredType, StaticContext context, String nodeName, Name variableName) { + public void checkVariableType( + SequenceType declaredType, + SequenceType inferredType, + StaticContext context, + String nodeName, + Name variableName + ) { basicChecks(inferredType, nodeName, true, false); - if(declaredType == null){ - // if declared type is null, we overwrite the type in the correspondent InScopeVariable with the inferred type + if (declaredType == null) { + // if declared type is null, we overwrite the type in the correspondent InScopeVariable with the inferred + // type context.replaceVariableSequenceType(variableName, inferredType); } else { - // the expression we get is a treat expression by design so we need to extract the inferred type of its main expression - if(!inferredType.isSubtypeOfOrCanBePromotedTo(declaredType)){ - throw new UnexpectedStaticTypeException("In a " + nodeName + ", the variable $" + variableName + " inferred type " + inferredType + " does not match or can be promoted to the declared type " + declaredType); + // the expression we get is a treat expression by design so we need to extract the inferred type of its main + // expression + if (!inferredType.isSubtypeOfOrCanBePromotedTo(declaredType)) { + throw new UnexpectedStaticTypeException( + "In a " + + nodeName + + ", the variable $" + + variableName + + " inferred type " + + inferredType + + " does not match or can be promoted to the declared type " + + declaredType + ); } } } @@ -1222,12 +1516,16 @@ public void checkVariableType(SequenceType declaredType, SequenceType inferredTy public StaticContext visitVariableDeclaration(VariableDeclaration expression, StaticContext argument) { visitDescendants(expression, argument); SequenceType declaredType = expression.getActualSequenceType(); - SequenceType inferredType = (declaredType == null ? expression.getExpression() : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); - checkVariableType(declaredType, - inferredType, - argument, - expression.getClass().getSimpleName(), - expression.getVariableName()); + SequenceType inferredType = (declaredType == null + ? expression.getExpression() + : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); + checkVariableType( + declaredType, + inferredType, + argument, + expression.getClass().getSimpleName(), + expression.getVariableName() + ); return argument; } @@ -1240,14 +1538,22 @@ public StaticContext visitFunctionDeclaration(FunctionDeclaration expression, St SequenceType inferredType = inlineExpression.getBody().getInferredSequenceType(); SequenceType expectedType = inlineExpression.getActualReturnType(); - if(expectedType == null){ + if (expectedType == null) { expectedType = inferredType; - } else if(!inferredType.isSubtypeOfOrCanBePromotedTo(expectedType)) { - throw new UnexpectedStaticTypeException("The declared function return inferred type " + inferredType + " does not match or can be promoted to the expected return type " + expectedType); + } else if (!inferredType.isSubtypeOfOrCanBePromotedTo(expectedType)) { + throw new UnexpectedStaticTypeException( + "The declared function return inferred type " + + inferredType + + " does not match or can be promoted to the expected return type " + + expectedType + ); } // add function signature to the statically known one - argument.addFunctionSignature(inlineExpression.getFunctionIdentifier(), new FunctionSignature(new ArrayList(inlineExpression.getParams().values()), expectedType)); + argument.addFunctionSignature( + inlineExpression.getFunctionIdentifier(), + new FunctionSignature(new ArrayList(inlineExpression.getParams().values()), expectedType) + ); return argument; } diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index c230771e0a..cefd5b4c10 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -101,10 +101,7 @@ import org.rumbledb.expressions.primary.VariableReferenceExpression; import org.rumbledb.expressions.quantifiers.QuantifiedExpression; import org.rumbledb.expressions.quantifiers.QuantifiedExpressionVar; -import org.rumbledb.expressions.typing.CastExpression; -import org.rumbledb.expressions.typing.CastableExpression; -import org.rumbledb.expressions.typing.InstanceOfExpression; -import org.rumbledb.expressions.typing.TreatExpression; +import org.rumbledb.expressions.typing.*; import org.rumbledb.parser.JsoniqParser; import org.rumbledb.parser.JsoniqParser.DefaultCollationDeclContext; import org.rumbledb.parser.JsoniqParser.EmptyOrderDeclContext; @@ -813,7 +810,7 @@ public Node visitSimpleMapExpr(JsoniqParser.SimpleMapExprContext ctx) { @Override public Node visitInstanceOfExpr(JsoniqParser.InstanceOfExprContext ctx) { - Expression mainExpression = (Expression) this.visitTreatExpr(ctx.main_expr); + Expression mainExpression = (Expression) this.visitStaticallyIsExpr(ctx.main_expr); if (ctx.seq == null || ctx.seq.isEmpty()) { return mainExpression; } @@ -826,6 +823,21 @@ public Node visitInstanceOfExpr(JsoniqParser.InstanceOfExprContext ctx) { ); } + @Override + public Node visitStaticallyIsExpr(JsoniqParser.StaticallyIsExprContext ctx) { + Expression mainExpression = (Expression) this.visitTreatExpr(ctx.main_expr); + if (ctx.seq == null || ctx.seq.isEmpty()) { + return mainExpression; + } + JsoniqParser.SequenceTypeContext child = ctx.seq; + SequenceType sequenceType = this.processSequenceType(child); + return new StaticallyIsExpression( + mainExpression, + sequenceType, + createMetadataFromContext(ctx) + ); + } + @Override public Node visitTreatExpr(JsoniqParser.TreatExprContext ctx) { Expression mainExpression = (Expression) this.visitCastableExpr(ctx.main_expr); diff --git a/src/main/java/org/rumbledb/compiler/VisitorHelpers.java b/src/main/java/org/rumbledb/compiler/VisitorHelpers.java index 0bb51bf7e8..6a8ba3bf7c 100644 --- a/src/main/java/org/rumbledb/compiler/VisitorHelpers.java +++ b/src/main/java/org/rumbledb/compiler/VisitorHelpers.java @@ -54,7 +54,7 @@ private static void inferTypes(Module module, RumbleRuntimeConfiguration conf) { System.out.println("* Starting type inference *"); new InferTypeVisitor(conf).visit(module, module.getStaticContext()); System.out.println("* Completed type inference *"); - if(conf.printInferredTypes()){ + if (conf.printInferredTypes()) { printTree(module, conf); } } @@ -113,7 +113,7 @@ public static MainModule parseMainModule(CharStream stream, URI uri, RumbleRunti pruneModules(mainModule, configuration); resolveDependencies(mainModule, configuration); populateStaticContext(mainModule, configuration); - if(configuration.doStaticAnalysis()){ + if (configuration.doStaticAnalysis()) { inferTypes(mainModule, configuration); } return mainModule; diff --git a/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java b/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java index 95df4d7146..20f30de8ce 100644 --- a/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java +++ b/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java @@ -266,7 +266,8 @@ public boolean doStaticAnalysis() { } public boolean printInferredTypes() { - return this.arguments.containsKey("print-inferred-types") && this.arguments.get("print-inferred-types").equals("yes"); + return this.arguments.containsKey("print-inferred-types") + && this.arguments.get("print-inferred-types").equals("yes"); } public boolean isLocal() { diff --git a/src/main/java/org/rumbledb/context/StaticContext.java b/src/main/java/org/rumbledb/context/StaticContext.java index c94e9a70e2..10b7a3ee87 100644 --- a/src/main/java/org/rumbledb/context/StaticContext.java +++ b/src/main/java/org/rumbledb/context/StaticContext.java @@ -20,7 +20,6 @@ package org.rumbledb.context; -import com.amazonaws.transform.MapEntry; import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.SemanticException; @@ -140,9 +139,12 @@ public FunctionSignature getFunctionSignature(FunctionIdentifier identifier) { } // replace the sequence type of an existing InScopeVariable, throws an error if the variable does not exists - public void replaceVariableSequenceType(Name varName, SequenceType newSequenceType){ + public void replaceVariableSequenceType(Name varName, SequenceType newSequenceType) { InScopeVariable variable = getInScopeVariable(varName); - this.inScopeVariables.replace(varName, new InScopeVariable(varName, newSequenceType, variable.getMetadata(), variable.getStorageMode())); + this.inScopeVariables.replace( + varName, + new InScopeVariable(varName, newSequenceType, variable.getMetadata(), variable.getStorageMode()) + ); } public SequenceType getVariableSequenceType(Name varName) { @@ -166,7 +168,7 @@ public void addVariable( this.inScopeVariables.put(varName, new InScopeVariable(varName, type, metadata, storageMode)); } - public void addFunctionSignature(FunctionIdentifier identifier, FunctionSignature signature){ + public void addFunctionSignature(FunctionIdentifier identifier, FunctionSignature signature) { this.staticallyKnownFunctionSignatures.put(identifier, signature); } @@ -304,20 +306,30 @@ public void setContextItemStaticType(SequenceType contextItemStaticType) { this.contextItemStaticType = contextItemStaticType; } - // replace all inScopeVariable in this context and all parents until [stopContext] with name not in [varToExclude] with same variable with sequence type arity changed from 1 to + and form ? to * + // replace all inScopeVariable in this context and all parents until [stopContext] with name not in [varToExclude] + // with same variable with sequence type arity changed from 1 to + and form ? to * // used by groupBy cluse - public void incrementArities(StaticContext stopContext, Set varToExclude){ - this.inScopeVariables.replaceAll((key, value) -> varToExclude.contains(value) ? value : - new InScopeVariable( + public void incrementArities(StaticContext stopContext, Set varToExclude) { + this.inScopeVariables.replaceAll( + (key, value) -> varToExclude.contains(value) + ? value + : new InScopeVariable( value.getName(), value.getSequenceType().incrementArity(), value.getMetadata(), - value.getStorageMode())); + value.getStorageMode() + ) + ); StaticContext current = this.parent; - while (current != null && current != stopContext){ - for(Map.Entry entry : current.inScopeVariables.entrySet()){ - if(!this.inScopeVariables.containsKey(entry.getKey())){ - this.addVariable(entry.getKey(), entry.getValue().getSequenceType().incrementArity(), entry.getValue().getMetadata(), entry.getValue().getStorageMode()); + while (current != null && current != stopContext) { + for (Map.Entry entry : current.inScopeVariables.entrySet()) { + if (!this.inScopeVariables.containsKey(entry.getKey())) { + this.addVariable( + entry.getKey(), + entry.getValue().getSequenceType().incrementArity(), + entry.getValue().getMetadata(), + entry.getValue().getStorageMode() + ); } } current = current.parent; diff --git a/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java b/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java index ce2469ffc9..54af406bc6 100644 --- a/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java +++ b/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java @@ -10,7 +10,7 @@ public UnexpectedStaticTypeException(String message) { super(message, ErrorCode.UnexpectedTypeErrorCode); } - public UnexpectedStaticTypeException(String message, ErrorCode errorCode){ + public UnexpectedStaticTypeException(String message, ErrorCode errorCode) { super(message, errorCode); } } diff --git a/src/main/java/org/rumbledb/expressions/AbstractNodeVisitor.java b/src/main/java/org/rumbledb/expressions/AbstractNodeVisitor.java index ad6129d523..25b0039ebe 100644 --- a/src/main/java/org/rumbledb/expressions/AbstractNodeVisitor.java +++ b/src/main/java/org/rumbledb/expressions/AbstractNodeVisitor.java @@ -66,10 +66,7 @@ import org.rumbledb.expressions.primary.StringLiteralExpression; import org.rumbledb.expressions.primary.VariableReferenceExpression; import org.rumbledb.expressions.quantifiers.QuantifiedExpression; -import org.rumbledb.expressions.typing.CastExpression; -import org.rumbledb.expressions.typing.CastableExpression; -import org.rumbledb.expressions.typing.InstanceOfExpression; -import org.rumbledb.expressions.typing.TreatExpression; +import org.rumbledb.expressions.typing.*; public abstract class AbstractNodeVisitor { @@ -265,6 +262,10 @@ public T visitInstanceOfExpression(InstanceOfExpression expression, T argument) return defaultAction(expression, argument); } + public T visitStaticallyIsExpr(StaticallyIsExpression expression, T argument) { + return defaultAction(expression, argument); + } + public T visitTreatExpression(TreatExpression expression, T argument) { return defaultAction(expression, argument); } diff --git a/src/main/java/org/rumbledb/expressions/Expression.java b/src/main/java/org/rumbledb/expressions/Expression.java index 7fa24c246c..8beed7d360 100644 --- a/src/main/java/org/rumbledb/expressions/Expression.java +++ b/src/main/java/org/rumbledb/expressions/Expression.java @@ -52,9 +52,13 @@ public void setStaticContext(StaticContext staticContext) { this.staticContext = staticContext; } - public SequenceType getInferredSequenceType() { return this.inferredSequenceType; } + public SequenceType getInferredSequenceType() { + return this.inferredSequenceType; + } - public void setInferredSequenceType(SequenceType inferredSequenceType) { this.inferredSequenceType = inferredSequenceType; } + public void setInferredSequenceType(SequenceType inferredSequenceType) { + this.inferredSequenceType = inferredSequenceType; + } public void print(StringBuffer buffer, int indent) { for (int i = 0; i < indent; ++i) { @@ -62,7 +66,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(getClass().getSimpleName()); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java index f6106206a4..4350884ae2 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java @@ -67,7 +67,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.isMinus ? "-" : "+") + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java index 2bb185ce89..3273663047 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java @@ -103,7 +103,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.multiplicativeOperator) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/UnaryExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/UnaryExpression.java index 4c1ba7beeb..6d3a1953c4 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/UnaryExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/UnaryExpression.java @@ -70,7 +70,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.negated ? "-" : "+") + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java b/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java index 887e821a17..4545eacba5 100644 --- a/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java +++ b/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java @@ -151,7 +151,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.comparisonOperator) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/flowr/GroupByVariableDeclaration.java b/src/main/java/org/rumbledb/expressions/flowr/GroupByVariableDeclaration.java index 0f4225572a..a9dd4e8c48 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/GroupByVariableDeclaration.java +++ b/src/main/java/org/rumbledb/expressions/flowr/GroupByVariableDeclaration.java @@ -21,7 +21,6 @@ package org.rumbledb.expressions.flowr; import org.rumbledb.context.Name; -import org.rumbledb.exceptions.OurBadException; import org.rumbledb.expressions.Expression; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java b/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java index 8d776486f3..e6385826fd 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java +++ b/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java @@ -66,7 +66,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (!)"); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java b/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java index f6ddb6cee9..8bac2af94a 100644 --- a/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java +++ b/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java @@ -82,7 +82,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(getClass().getSimpleName()); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Expression arg : this.arguments) { if (arg == null) { diff --git a/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java index 9217e226e9..6d67bf2d5c 100644 --- a/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java @@ -59,7 +59,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.value) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java index 3f6e65705b..e20694e081 100644 --- a/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java @@ -60,7 +60,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.value) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java index 4a7699caf6..e49684e884 100644 --- a/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java @@ -59,7 +59,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.value) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java b/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java index ab0d02242a..55fea1c683 100644 --- a/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java @@ -173,7 +173,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(getClass().getSimpleName()); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Expression arg : this.arguments) { if (arg == null) { diff --git a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java index 1721e9a32e..faaa3c0b3c 100644 --- a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java @@ -122,7 +122,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(this.returnType == null ? "not set" : this.returnType.toString()); buffer.append(")"); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (int i = 0; i < indent + 2; ++i) { buffer.append(" "); diff --git a/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java index e423c8d532..f1367603ae 100644 --- a/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java @@ -59,7 +59,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.lexicalValue) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java b/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java index 11e94d3913..27bc1ec3d3 100644 --- a/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java @@ -60,7 +60,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(getClass().getSimpleName()); buffer.append(" (" + this.identifier.getName() + "#" + this.identifier.getArity() + ") "); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); } } diff --git a/src/main/java/org/rumbledb/expressions/primary/StringLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/StringLiteralExpression.java index 14a6c44e75..a8afa05e42 100644 --- a/src/main/java/org/rumbledb/expressions/primary/StringLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/StringLiteralExpression.java @@ -60,7 +60,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.value) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java b/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java index 1f47e088f2..13d31f800f 100644 --- a/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java @@ -92,7 +92,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" ($" + this.name + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpression.java b/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpression.java index c84619bec9..464d101354 100644 --- a/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpression.java +++ b/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpression.java @@ -94,7 +94,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(")"); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/typing/CastExpression.java b/src/main/java/org/rumbledb/expressions/typing/CastExpression.java index 16e654d111..52f878c830 100644 --- a/src/main/java/org/rumbledb/expressions/typing/CastExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/CastExpression.java @@ -55,7 +55,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.sequenceType.toString()) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java b/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java index a8bd337234..7395e662f1 100644 --- a/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java @@ -55,7 +55,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.sequenceType.toString()) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java b/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java index e15dbcf3ed..fcaa4eed2b 100644 --- a/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java @@ -74,7 +74,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.sequenceType.toString()) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/typing/StaticallyIsExpression.java b/src/main/java/org/rumbledb/expressions/typing/StaticallyIsExpression.java new file mode 100644 index 0000000000..8e5932f9fd --- /dev/null +++ b/src/main/java/org/rumbledb/expressions/typing/StaticallyIsExpression.java @@ -0,0 +1,61 @@ +package org.rumbledb.expressions.typing; + +import org.rumbledb.exceptions.ExceptionMetadata; +import org.rumbledb.exceptions.OurBadException; +import org.rumbledb.expressions.AbstractNodeVisitor; +import org.rumbledb.expressions.Expression; +import org.rumbledb.expressions.Node; +import org.rumbledb.types.SequenceType; + +import java.util.Collections; +import java.util.List; + +public class StaticallyIsExpression extends Expression { + private Expression mainExpression; + private SequenceType sequenceType; + + public StaticallyIsExpression( + Expression mainExpression, + SequenceType sequenceType, + ExceptionMetadata metadata + ) { + super(metadata); + if (mainExpression == null) { + throw new OurBadException("Expression cannot be null."); + } + this.mainExpression = mainExpression; + this.sequenceType = sequenceType; + } + + @Override + public T accept(AbstractNodeVisitor visitor, T argument) { + return visitor.visitStaticallyIsExpr(this, argument); + } + + public SequenceType getSequenceType() { + return this.sequenceType; + } + + public Expression getMainExpression() { + return this.mainExpression; + } + + @Override + public List getChildren() { + return Collections.singletonList(this.mainExpression); + } + + public void print(StringBuffer buffer, int indent) { + for (int i = 0; i < indent; ++i) { + buffer.append(" "); + } + buffer.append(getClass().getSimpleName()); + buffer.append(" (" + (this.sequenceType.toString()) + ") "); + buffer.append(" | " + this.highestExecutionMode); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); + buffer.append("\n"); + for (Node iterator : getChildren()) { + iterator.print(buffer, indent + 1); + } + } +} diff --git a/src/main/java/org/rumbledb/expressions/typing/TreatExpression.java b/src/main/java/org/rumbledb/expressions/typing/TreatExpression.java index dad1ffa1d8..34fcc3b640 100644 --- a/src/main/java/org/rumbledb/expressions/typing/TreatExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/TreatExpression.java @@ -93,7 +93,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.sequenceType.toString()) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/parser/Jsoniq.g4 b/src/main/java/org/rumbledb/parser/Jsoniq.g4 index 77073df11f..c19e72f840 100644 --- a/src/main/java/org/rumbledb/parser/Jsoniq.g4 +++ b/src/main/java/org/rumbledb/parser/Jsoniq.g4 @@ -150,7 +150,9 @@ additiveExpr : main_expr=multiplicativeExpr ( op+=('+' | '-') rhs+=mu multiplicativeExpr : main_expr=instanceOfExpr ( op+=('*' | 'div' | 'idiv' | 'mod') rhs+=instanceOfExpr )*; -instanceOfExpr : main_expr=treatExpr ( Kinstance Kof seq=sequenceType)?; +instanceOfExpr : main_expr=staticallyIsExpr ( Kinstance Kof seq=sequenceType)?; + +staticallyIsExpr : main_expr=treatExpr ( Kstatically Kis seq=sequenceType)?; treatExpr : main_expr=castableExpr ( Ktreat Kas seq=sequenceType )?; diff --git a/src/main/java/org/rumbledb/parser/Jsoniq.tokens b/src/main/java/org/rumbledb/parser/Jsoniq.tokens index 315c988809..e9695362cb 100644 --- a/src/main/java/org/rumbledb/parser/Jsoniq.tokens +++ b/src/main/java/org/rumbledb/parser/Jsoniq.tokens @@ -130,6 +130,8 @@ WS=129 NCName=130 XQComment=131 ContentChar=132 +Kstatically=133 +Kis=134 ';'=1 'module'=2 'namespace'=3 diff --git a/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java b/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java index 65d7c7ba3e..30c77c1f3f 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java +++ b/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java @@ -364,6 +364,13 @@ public class JsoniqBaseVisitor extends AbstractParseTreeVisitor implements * {@link #visitChildren} on {@code ctx}.

*/ @Override public T visitInstanceOfExpr(JsoniqParser.InstanceOfExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStaticallyIsExpr(JsoniqParser.StaticallyIsExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * diff --git a/src/main/java/org/rumbledb/parser/JsoniqParser.java b/src/main/java/org/rumbledb/parser/JsoniqParser.java index 768cda7d9e..0e9bc78b30 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqParser.java +++ b/src/main/java/org/rumbledb/parser/JsoniqParser.java @@ -50,7 +50,7 @@ public class JsoniqParser extends Parser { Kcast=115, Kcastable=116, Kversion=117, Kjsoniq=118, Kjson=119, STRING=120, ArgumentPlaceholder=121, NullLiteral=122, Literal=123, NumericLiteral=124, BooleanLiteral=125, IntegerLiteral=126, DecimalLiteral=127, DoubleLiteral=128, - WS=129, NCName=130, XQComment=131, ContentChar=132; + WS=129, NCName=130, XQComment=131, ContentChar=132, Kstatically=133, Kis=134; public static final int RULE_moduleAndThisIsIt = 0, RULE_module = 1, RULE_mainModule = 2, RULE_libraryModule = 3, RULE_prolog = 4, RULE_setter = 5, RULE_namespaceDecl = 6, RULE_annotatedDecl = 7, @@ -66,22 +66,23 @@ public class JsoniqParser extends Parser { RULE_ifExpr = 38, RULE_tryCatchExpr = 39, RULE_catchClause = 40, RULE_orExpr = 41, RULE_andExpr = 42, RULE_notExpr = 43, RULE_comparisonExpr = 44, RULE_stringConcatExpr = 45, RULE_rangeExpr = 46, RULE_additiveExpr = 47, RULE_multiplicativeExpr = 48, - RULE_instanceOfExpr = 49, RULE_treatExpr = 50, RULE_castableExpr = 51, - RULE_castExpr = 52, RULE_arrowExpr = 53, RULE_unaryExpr = 54, RULE_simpleMapExpr = 55, - RULE_postFixExpr = 56, RULE_arrayLookup = 57, RULE_arrayUnboxing = 58, - RULE_predicate = 59, RULE_objectLookup = 60, RULE_primaryExpr = 61, RULE_varRef = 62, - RULE_parenthesizedExpr = 63, RULE_contextItemExpr = 64, RULE_orderedExpr = 65, - RULE_unorderedExpr = 66, RULE_functionCall = 67, RULE_argumentList = 68, - RULE_argument = 69, RULE_functionItemExpr = 70, RULE_namedFunctionRef = 71, - RULE_inlineFunctionExpr = 72, RULE_sequenceType = 73, RULE_objectConstructor = 74, - RULE_itemType = 75, RULE_jSONItemTest = 76, RULE_keyWordString = 77, RULE_keyWordInteger = 78, - RULE_keyWordDecimal = 79, RULE_keyWordDouble = 80, RULE_keyWordBoolean = 81, - RULE_keyWordDuration = 82, RULE_keyWordYearMonthDuration = 83, RULE_keyWordDayTimeDuration = 84, - RULE_keyWordHexBinary = 85, RULE_keyWordBase64Binary = 86, RULE_keyWordDateTime = 87, - RULE_keyWordDate = 88, RULE_keyWordTime = 89, RULE_keyWordAnyURI = 90, - RULE_typesKeywords = 91, RULE_singleType = 92, RULE_atomicType = 93, RULE_nCNameOrKeyWord = 94, - RULE_pairConstructor = 95, RULE_arrayConstructor = 96, RULE_uriLiteral = 97, - RULE_stringLiteral = 98, RULE_keyWords = 99; + RULE_instanceOfExpr = 49, RULE_staticallyIsExpr = 50, RULE_treatExpr = 51, + RULE_castableExpr = 52, RULE_castExpr = 53, RULE_arrowExpr = 54, RULE_unaryExpr = 55, + RULE_simpleMapExpr = 56, RULE_postFixExpr = 57, RULE_arrayLookup = 58, + RULE_arrayUnboxing = 59, RULE_predicate = 60, RULE_objectLookup = 61, + RULE_primaryExpr = 62, RULE_varRef = 63, RULE_parenthesizedExpr = 64, + RULE_contextItemExpr = 65, RULE_orderedExpr = 66, RULE_unorderedExpr = 67, + RULE_functionCall = 68, RULE_argumentList = 69, RULE_argument = 70, RULE_functionItemExpr = 71, + RULE_namedFunctionRef = 72, RULE_inlineFunctionExpr = 73, RULE_sequenceType = 74, + RULE_objectConstructor = 75, RULE_itemType = 76, RULE_jSONItemTest = 77, + RULE_keyWordString = 78, RULE_keyWordInteger = 79, RULE_keyWordDecimal = 80, + RULE_keyWordDouble = 81, RULE_keyWordBoolean = 82, RULE_keyWordDuration = 83, + RULE_keyWordYearMonthDuration = 84, RULE_keyWordDayTimeDuration = 85, + RULE_keyWordHexBinary = 86, RULE_keyWordBase64Binary = 87, RULE_keyWordDateTime = 88, + RULE_keyWordDate = 89, RULE_keyWordTime = 90, RULE_keyWordAnyURI = 91, + RULE_typesKeywords = 92, RULE_singleType = 93, RULE_atomicType = 94, RULE_nCNameOrKeyWord = 95, + RULE_pairConstructor = 96, RULE_arrayConstructor = 97, RULE_uriLiteral = 98, + RULE_stringLiteral = 99, RULE_keyWords = 100; public static final String[] ruleNames = { "moduleAndThisIsIt", "module", "mainModule", "libraryModule", "prolog", "setter", "namespaceDecl", "annotatedDecl", "defaultCollationDecl", "orderingModeDecl", @@ -92,8 +93,8 @@ public class JsoniqParser extends Parser { "quantifiedExpr", "quantifiedExprVar", "switchExpr", "switchCaseClause", "typeSwitchExpr", "caseClause", "ifExpr", "tryCatchExpr", "catchClause", "orExpr", "andExpr", "notExpr", "comparisonExpr", "stringConcatExpr", - "rangeExpr", "additiveExpr", "multiplicativeExpr", "instanceOfExpr", "treatExpr", - "castableExpr", "castExpr", "arrowExpr", "unaryExpr", "simpleMapExpr", + "rangeExpr", "additiveExpr", "multiplicativeExpr", "instanceOfExpr", "staticallyIsExpr", + "treatExpr", "castableExpr", "castExpr", "arrowExpr", "unaryExpr", "simpleMapExpr", "postFixExpr", "arrayLookup", "arrayUnboxing", "predicate", "objectLookup", "primaryExpr", "varRef", "parenthesizedExpr", "contextItemExpr", "orderedExpr", "unorderedExpr", "functionCall", "argumentList", "argument", "functionItemExpr", @@ -141,7 +142,7 @@ public class JsoniqParser extends Parser { "Kinstance", "Kof", "Ktreat", "Kcast", "Kcastable", "Kversion", "Kjsoniq", "Kjson", "STRING", "ArgumentPlaceholder", "NullLiteral", "Literal", "NumericLiteral", "BooleanLiteral", "IntegerLiteral", "DecimalLiteral", "DoubleLiteral", - "WS", "NCName", "XQComment", "ContentChar" + "WS", "NCName", "XQComment", "ContentChar", "Kstatically", "Kis" }; public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); @@ -214,9 +215,9 @@ public final ModuleAndThisIsItContext moduleAndThisIsIt() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(200); + setState(202); module(); - setState(201); + setState(203); match(EOF); } } @@ -262,28 +263,28 @@ public final ModuleContext module() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(208); + setState(210); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,0,_ctx) ) { case 1: { - setState(203); + setState(205); match(Kjsoniq); - setState(204); + setState(206); match(Kversion); - setState(205); + setState(207); ((ModuleContext)_localctx).vers = stringLiteral(); - setState(206); + setState(208); match(T__0); } break; } - setState(212); + setState(214); _errHandler.sync(this); switch (_input.LA(1)) { case T__1: { - setState(210); + setState(212); libraryModule(); } break; @@ -362,7 +363,7 @@ public final ModuleContext module() throws RecognitionException { case Literal: case NCName: { - setState(211); + setState(213); ((ModuleContext)_localctx).main = mainModule(); } break; @@ -406,9 +407,9 @@ public final MainModuleContext mainModule() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(214); + setState(216); prolog(); - setState(215); + setState(217); expr(); } } @@ -448,19 +449,19 @@ public final LibraryModuleContext libraryModule() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(217); + setState(219); match(T__1); - setState(218); + setState(220); match(T__2); - setState(219); + setState(221); match(NCName); - setState(220); + setState(222); match(T__3); - setState(221); + setState(223); uriLiteral(); - setState(222); + setState(224); match(T__0); - setState(223); + setState(225); prolog(); } } @@ -519,57 +520,57 @@ public final PrologContext prolog() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(234); + setState(236); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,3,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(228); + setState(230); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) { case 1: { - setState(225); + setState(227); setter(); } break; case 2: { - setState(226); + setState(228); namespaceDecl(); } break; case 3: { - setState(227); + setState(229); moduleImport(); } break; } - setState(230); + setState(232); match(T__0); } } } - setState(236); + setState(238); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,3,_ctx); } - setState(242); + setState(244); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__4) { { { - setState(237); + setState(239); annotatedDecl(); - setState(238); + setState(240); match(T__0); } } - setState(244); + setState(246); _errHandler.sync(this); _la = _input.LA(1); } @@ -614,34 +615,34 @@ public final SetterContext setter() throws RecognitionException { SetterContext _localctx = new SetterContext(_ctx, getState()); enterRule(_localctx, 10, RULE_setter); try { - setState(249); + setState(251); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,5,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(245); + setState(247); defaultCollationDecl(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(246); + setState(248); orderingModeDecl(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(247); + setState(249); emptyOrderDecl(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(248); + setState(250); decimalFormatDecl(); } break; @@ -680,15 +681,15 @@ public final NamespaceDeclContext namespaceDecl() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(251); + setState(253); match(T__4); - setState(252); + setState(254); match(T__2); - setState(253); + setState(255); match(NCName); - setState(254); + setState(256); match(T__3); - setState(255); + setState(257); uriLiteral(); } } @@ -725,20 +726,20 @@ public final AnnotatedDeclContext annotatedDecl() throws RecognitionException { AnnotatedDeclContext _localctx = new AnnotatedDeclContext(_ctx, getState()); enterRule(_localctx, 14, RULE_annotatedDecl); try { - setState(259); + setState(261); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(257); + setState(259); functionDecl(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(258); + setState(260); varDecl(); } break; @@ -778,13 +779,13 @@ public final DefaultCollationDeclContext defaultCollationDecl() throws Recogniti try { enterOuterAlt(_localctx, 1); { - setState(261); + setState(263); match(T__4); - setState(262); + setState(264); match(Kdefault); - setState(263); + setState(265); match(Kcollation); - setState(264); + setState(266); uriLiteral(); } } @@ -818,11 +819,11 @@ public final OrderingModeDeclContext orderingModeDecl() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(266); + setState(268); match(T__4); - setState(267); + setState(269); match(T__5); - setState(268); + setState(270); _la = _input.LA(1); if ( !(_la==T__6 || _la==T__7) ) { _errHandler.recoverInline(this); @@ -869,16 +870,16 @@ public final EmptyOrderDeclContext emptyOrderDecl() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(270); + setState(272); match(T__4); - setState(271); + setState(273); match(Kdefault); - setState(272); + setState(274); match(Korder); - setState(273); + setState(275); match(Kempty); { - setState(274); + setState(276); ((EmptyOrderDeclContext)_localctx).emptySequenceOrder = _input.LT(1); _la = _input.LA(1); if ( !(_la==Kgreatest || _la==Kleast) ) { @@ -938,17 +939,17 @@ public final DecimalFormatDeclContext decimalFormatDecl() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(276); + setState(278); match(T__4); - setState(281); + setState(283); _errHandler.sync(this); switch (_input.LA(1)) { case T__8: { { - setState(277); + setState(279); match(T__8); - setState(278); + setState(280); qname(); } } @@ -956,9 +957,9 @@ public final DecimalFormatDeclContext decimalFormatDecl() throws RecognitionExce case Kdefault: { { - setState(279); + setState(281); match(Kdefault); - setState(280); + setState(282); match(T__8); } } @@ -966,21 +967,21 @@ public final DecimalFormatDeclContext decimalFormatDecl() throws RecognitionExce default: throw new NoViableAltException(this); } - setState(289); + setState(291); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__14) | (1L << T__15) | (1L << T__16) | (1L << T__17) | (1L << T__18) | (1L << T__19))) != 0)) { { { - setState(283); + setState(285); dfPropertyName(); - setState(284); + setState(286); match(T__3); - setState(285); + setState(287); stringLiteral(); } } - setState(291); + setState(293); _errHandler.sync(this); _la = _input.LA(1); } @@ -1029,17 +1030,17 @@ public final QnameContext qname() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(297); + setState(299); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,10,_ctx) ) { case 1: { - setState(294); + setState(296); _errHandler.sync(this); switch (_input.LA(1)) { case NCName: { - setState(292); + setState(294); ((QnameContext)_localctx).ns = match(NCName); } break; @@ -1087,19 +1088,19 @@ public final QnameContext qname() throws RecognitionException { case Kjsoniq: case Kjson: { - setState(293); + setState(295); ((QnameContext)_localctx).nskw = keyWords(); } break; default: throw new NoViableAltException(this); } - setState(296); + setState(298); match(T__9); } break; } - setState(301); + setState(303); _errHandler.sync(this); switch (_input.LA(1)) { case T__61: @@ -1118,7 +1119,7 @@ public final QnameContext qname() throws RecognitionException { case T__74: case NCName: { - setState(299); + setState(301); ((QnameContext)_localctx).local_name = nCNameOrKeyWord(); } break; @@ -1166,7 +1167,7 @@ public final QnameContext qname() throws RecognitionException { case Kjsoniq: case Kjson: { - setState(300); + setState(302); ((QnameContext)_localctx).local_namekw = keyWords(); } break; @@ -1205,7 +1206,7 @@ public final DfPropertyNameContext dfPropertyName() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(303); + setState(305); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__14) | (1L << T__15) | (1L << T__16) | (1L << T__17) | (1L << T__18) | (1L << T__19))) != 0)) ) { _errHandler.recoverInline(this); @@ -1257,48 +1258,48 @@ public final ModuleImportContext moduleImport() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(305); + setState(307); match(T__20); - setState(306); + setState(308); match(T__1); - setState(310); + setState(312); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__2) { { - setState(307); + setState(309); match(T__2); - setState(308); + setState(310); ((ModuleImportContext)_localctx).prefix = match(NCName); - setState(309); + setState(311); match(T__3); } } - setState(312); + setState(314); ((ModuleImportContext)_localctx).targetNamespace = uriLiteral(); - setState(322); + setState(324); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kat) { { - setState(313); + setState(315); match(Kat); - setState(314); + setState(316); uriLiteral(); - setState(319); + setState(321); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(315); + setState(317); match(T__21); - setState(316); + setState(318); uriLiteral(); } } - setState(321); + setState(323); _errHandler.sync(this); _la = _input.LA(1); } @@ -1348,33 +1349,33 @@ public final VarDeclContext varDecl() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(324); + setState(326); match(T__4); - setState(325); + setState(327); match(T__22); - setState(326); + setState(328); varRef(); - setState(329); + setState(331); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(327); + setState(329); match(Kas); - setState(328); + setState(330); sequenceType(); } } - setState(338); + setState(340); _errHandler.sync(this); switch (_input.LA(1)) { case T__23: { { - setState(331); + setState(333); match(T__23); - setState(332); + setState(334); exprSingle(); } } @@ -1382,16 +1383,16 @@ public final VarDeclContext varDecl() throws RecognitionException { case T__24: { { - setState(333); + setState(335); ((VarDeclContext)_localctx).external = match(T__24); - setState(336); + setState(338); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__23) { { - setState(334); + setState(336); match(T__23); - setState(335); + setState(337); exprSingle(); } } @@ -1450,54 +1451,54 @@ public final FunctionDeclContext functionDecl() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(340); + setState(342); match(T__4); - setState(341); + setState(343); match(T__25); - setState(342); + setState(344); ((FunctionDeclContext)_localctx).fn_name = qname(); - setState(343); - match(T__26); setState(345); + match(T__26); + setState(347); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(344); + setState(346); paramList(); } } - setState(347); + setState(349); match(T__27); - setState(350); + setState(352); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(348); + setState(350); match(Kas); - setState(349); + setState(351); ((FunctionDeclContext)_localctx).return_type = sequenceType(); } } - setState(357); + setState(359); _errHandler.sync(this); switch (_input.LA(1)) { case T__28: { - setState(352); + setState(354); match(T__28); - setState(353); + setState(355); ((FunctionDeclContext)_localctx).fn_body = expr(); - setState(354); + setState(356); match(T__29); } break; case T__24: { - setState(356); + setState(358); match(T__24); } break; @@ -1542,21 +1543,21 @@ public final ParamListContext paramList() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(359); + setState(361); param(); - setState(364); + setState(366); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(360); + setState(362); match(T__21); - setState(361); + setState(363); param(); } } - setState(366); + setState(368); _errHandler.sync(this); _la = _input.LA(1); } @@ -1599,18 +1600,18 @@ public final ParamContext param() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(367); + setState(369); match(T__30); - setState(368); + setState(370); qname(); - setState(371); + setState(373); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(369); + setState(371); match(Kas); - setState(370); + setState(372); sequenceType(); } } @@ -1653,21 +1654,21 @@ public final ExprContext expr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(373); + setState(375); exprSingle(); - setState(378); + setState(380); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(374); + setState(376); match(T__21); - setState(375); + setState(377); exprSingle(); } } - setState(380); + setState(382); _errHandler.sync(this); _la = _input.LA(1); } @@ -1721,55 +1722,55 @@ public final ExprSingleContext exprSingle() throws RecognitionException { ExprSingleContext _localctx = new ExprSingleContext(_ctx, getState()); enterRule(_localctx, 40, RULE_exprSingle); try { - setState(388); + setState(390); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,24,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(381); + setState(383); flowrExpr(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(382); + setState(384); quantifiedExpr(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(383); + setState(385); switchExpr(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(384); + setState(386); typeSwitchExpr(); } break; case 5: enterOuterAlt(_localctx, 5); { - setState(385); + setState(387); ifExpr(); } break; case 6: enterOuterAlt(_localctx, 6); { - setState(386); + setState(388); tryCatchExpr(); } break; case 7: enterOuterAlt(_localctx, 7); { - setState(387); + setState(389); orExpr(); } break; @@ -1848,66 +1849,66 @@ public final FlowrExprContext flowrExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(392); + setState(394); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: { - setState(390); + setState(392); ((FlowrExprContext)_localctx).start_for = forClause(); } break; case Klet: { - setState(391); + setState(393); ((FlowrExprContext)_localctx).start_let = letClause(); } break; default: throw new NoViableAltException(this); } - setState(402); + setState(404); _errHandler.sync(this); _la = _input.LA(1); while (((((_la - 77)) & ~0x3f) == 0 && ((1L << (_la - 77)) & ((1L << (Kfor - 77)) | (1L << (Klet - 77)) | (1L << (Kwhere - 77)) | (1L << (Kgroup - 77)) | (1L << (Korder - 77)) | (1L << (Kcount - 77)) | (1L << (Kstable - 77)))) != 0)) { { - setState(400); + setState(402); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: { - setState(394); + setState(396); forClause(); } break; case Kwhere: { - setState(395); + setState(397); whereClause(); } break; case Klet: { - setState(396); + setState(398); letClause(); } break; case Kgroup: { - setState(397); + setState(399); groupByClause(); } break; case Korder: case Kstable: { - setState(398); + setState(400); orderByClause(); } break; case Kcount: { - setState(399); + setState(401); countClause(); } break; @@ -1915,13 +1916,13 @@ public final FlowrExprContext flowrExpr() throws RecognitionException { throw new NoViableAltException(this); } } - setState(404); + setState(406); _errHandler.sync(this); _la = _input.LA(1); } - setState(405); + setState(407); match(Kreturn); - setState(406); + setState(408); ((FlowrExprContext)_localctx).return_expr = exprSingle(); } } @@ -1964,25 +1965,25 @@ public final ForClauseContext forClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(408); + setState(410); match(Kfor); - setState(409); + setState(411); ((ForClauseContext)_localctx).forVar = forVar(); ((ForClauseContext)_localctx).vars.add(((ForClauseContext)_localctx).forVar); - setState(414); + setState(416); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(410); + setState(412); match(T__21); - setState(411); + setState(413); ((ForClauseContext)_localctx).forVar = forVar(); ((ForClauseContext)_localctx).vars.add(((ForClauseContext)_localctx).forVar); } } - setState(416); + setState(418); _errHandler.sync(this); _la = _input.LA(1); } @@ -2040,47 +2041,47 @@ public final ForVarContext forVar() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(417); + setState(419); ((ForVarContext)_localctx).var_ref = varRef(); - setState(420); + setState(422); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(418); + setState(420); match(Kas); - setState(419); + setState(421); ((ForVarContext)_localctx).seq = sequenceType(); } } - setState(424); + setState(426); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kallowing) { { - setState(422); + setState(424); ((ForVarContext)_localctx).flag = match(Kallowing); - setState(423); + setState(425); match(Kempty); } } - setState(428); + setState(430); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kat) { { - setState(426); + setState(428); match(Kat); - setState(427); + setState(429); ((ForVarContext)_localctx).at = varRef(); } } - setState(430); + setState(432); match(Kin); - setState(431); + setState(433); ((ForVarContext)_localctx).ex = exprSingle(); } } @@ -2123,25 +2124,25 @@ public final LetClauseContext letClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(433); + setState(435); match(Klet); - setState(434); + setState(436); ((LetClauseContext)_localctx).letVar = letVar(); ((LetClauseContext)_localctx).vars.add(((LetClauseContext)_localctx).letVar); - setState(439); + setState(441); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(435); + setState(437); match(T__21); - setState(436); + setState(438); ((LetClauseContext)_localctx).letVar = letVar(); ((LetClauseContext)_localctx).vars.add(((LetClauseContext)_localctx).letVar); } } - setState(441); + setState(443); _errHandler.sync(this); _la = _input.LA(1); } @@ -2190,23 +2191,23 @@ public final LetVarContext letVar() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(442); + setState(444); ((LetVarContext)_localctx).var_ref = varRef(); - setState(445); + setState(447); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(443); + setState(445); match(Kas); - setState(444); + setState(446); ((LetVarContext)_localctx).seq = sequenceType(); } } - setState(447); + setState(449); match(T__23); - setState(448); + setState(450); ((LetVarContext)_localctx).ex = exprSingle(); } } @@ -2243,9 +2244,9 @@ public final WhereClauseContext whereClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(450); + setState(452); match(Kwhere); - setState(451); + setState(453); exprSingle(); } } @@ -2289,27 +2290,27 @@ public final GroupByClauseContext groupByClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(453); + setState(455); match(Kgroup); - setState(454); + setState(456); match(Kby); - setState(455); + setState(457); ((GroupByClauseContext)_localctx).groupByVar = groupByVar(); ((GroupByClauseContext)_localctx).vars.add(((GroupByClauseContext)_localctx).groupByVar); - setState(460); + setState(462); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(456); + setState(458); match(T__21); - setState(457); + setState(459); ((GroupByClauseContext)_localctx).groupByVar = groupByVar(); ((GroupByClauseContext)_localctx).vars.add(((GroupByClauseContext)_localctx).groupByVar); } } - setState(462); + setState(464); _errHandler.sync(this); _la = _input.LA(1); } @@ -2364,40 +2365,40 @@ public final GroupByVarContext groupByVar() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(463); + setState(465); ((GroupByVarContext)_localctx).var_ref = varRef(); - setState(470); + setState(472); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__23 || _la==Kas) { { - setState(466); + setState(468); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(464); + setState(466); match(Kas); - setState(465); + setState(467); ((GroupByVarContext)_localctx).seq = sequenceType(); } } - setState(468); + setState(470); ((GroupByVarContext)_localctx).decl = match(T__23); - setState(469); + setState(471); ((GroupByVarContext)_localctx).ex = exprSingle(); } } - setState(474); + setState(476); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kcollation) { { - setState(472); + setState(474); match(Kcollation); - setState(473); + setState(475); ((GroupByVarContext)_localctx).uri = uriLiteral(); } } @@ -2444,15 +2445,15 @@ public final OrderByClauseContext orderByClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(481); + setState(483); _errHandler.sync(this); switch (_input.LA(1)) { case Korder: { { - setState(476); + setState(478); match(Korder); - setState(477); + setState(479); match(Kby); } } @@ -2460,11 +2461,11 @@ public final OrderByClauseContext orderByClause() throws RecognitionException { case Kstable: { { - setState(478); + setState(480); ((OrderByClauseContext)_localctx).stb = match(Kstable); - setState(479); + setState(481); match(Korder); - setState(480); + setState(482); match(Kby); } } @@ -2472,21 +2473,21 @@ public final OrderByClauseContext orderByClause() throws RecognitionException { default: throw new NoViableAltException(this); } - setState(483); + setState(485); orderByExpr(); - setState(488); + setState(490); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(484); + setState(486); match(T__21); - setState(485); + setState(487); orderByExpr(); } } - setState(490); + setState(492); _errHandler.sync(this); _la = _input.LA(1); } @@ -2539,20 +2540,20 @@ public final OrderByExprContext orderByExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(491); + setState(493); ((OrderByExprContext)_localctx).ex = exprSingle(); - setState(494); + setState(496); _errHandler.sync(this); switch (_input.LA(1)) { case Kascending: { - setState(492); + setState(494); match(Kascending); } break; case Kdescending: { - setState(493); + setState(495); ((OrderByExprContext)_localctx).desc = match(Kdescending); } break; @@ -2571,25 +2572,25 @@ public final OrderByExprContext orderByExpr() throws RecognitionException { default: break; } - setState(501); + setState(503); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kempty) { { - setState(496); + setState(498); match(Kempty); - setState(499); + setState(501); _errHandler.sync(this); switch (_input.LA(1)) { case Kgreatest: { - setState(497); + setState(499); ((OrderByExprContext)_localctx).gr = match(Kgreatest); } break; case Kleast: { - setState(498); + setState(500); ((OrderByExprContext)_localctx).ls = match(Kleast); } break; @@ -2599,14 +2600,14 @@ public final OrderByExprContext orderByExpr() throws RecognitionException { } } - setState(505); + setState(507); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kcollation) { { - setState(503); + setState(505); match(Kcollation); - setState(504); + setState(506); ((OrderByExprContext)_localctx).uril = uriLiteral(); } } @@ -2646,9 +2647,9 @@ public final CountClauseContext countClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(507); + setState(509); match(Kcount); - setState(508); + setState(510); varRef(); } } @@ -2698,47 +2699,47 @@ public final QuantifiedExprContext quantifiedExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(512); + setState(514); _errHandler.sync(this); switch (_input.LA(1)) { case Ksome: { - setState(510); + setState(512); ((QuantifiedExprContext)_localctx).so = match(Ksome); } break; case Kevery: { - setState(511); + setState(513); ((QuantifiedExprContext)_localctx).ev = match(Kevery); } break; default: throw new NoViableAltException(this); } - setState(514); + setState(516); ((QuantifiedExprContext)_localctx).quantifiedExprVar = quantifiedExprVar(); ((QuantifiedExprContext)_localctx).vars.add(((QuantifiedExprContext)_localctx).quantifiedExprVar); - setState(519); + setState(521); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(515); + setState(517); match(T__21); - setState(516); + setState(518); ((QuantifiedExprContext)_localctx).quantifiedExprVar = quantifiedExprVar(); ((QuantifiedExprContext)_localctx).vars.add(((QuantifiedExprContext)_localctx).quantifiedExprVar); } } - setState(521); + setState(523); _errHandler.sync(this); _la = _input.LA(1); } - setState(522); + setState(524); match(Ksatisfies); - setState(523); + setState(525); exprSingle(); } } @@ -2783,23 +2784,23 @@ public final QuantifiedExprVarContext quantifiedExprVar() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(525); + setState(527); varRef(); - setState(528); + setState(530); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(526); + setState(528); match(Kas); - setState(527); + setState(529); sequenceType(); } } - setState(530); + setState(532); match(Kin); - setState(531); + setState(533); exprSingle(); } } @@ -2852,34 +2853,34 @@ public final SwitchExprContext switchExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(533); + setState(535); match(Kswitch); - setState(534); + setState(536); match(T__26); - setState(535); + setState(537); ((SwitchExprContext)_localctx).cond = expr(); - setState(536); + setState(538); match(T__27); - setState(538); + setState(540); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(537); + setState(539); ((SwitchExprContext)_localctx).switchCaseClause = switchCaseClause(); ((SwitchExprContext)_localctx).cases.add(((SwitchExprContext)_localctx).switchCaseClause); } } - setState(540); + setState(542); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Kcase ); - setState(542); + setState(544); match(Kdefault); - setState(543); + setState(545); match(Kreturn); - setState(544); + setState(546); ((SwitchExprContext)_localctx).def = exprSingle(); } } @@ -2927,26 +2928,26 @@ public final SwitchCaseClauseContext switchCaseClause() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(548); + setState(550); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(546); + setState(548); match(Kcase); - setState(547); + setState(549); ((SwitchCaseClauseContext)_localctx).exprSingle = exprSingle(); ((SwitchCaseClauseContext)_localctx).cond.add(((SwitchCaseClauseContext)_localctx).exprSingle); } } - setState(550); + setState(552); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Kcase ); - setState(552); + setState(554); match(Kreturn); - setState(553); + setState(555); ((SwitchCaseClauseContext)_localctx).ret = exprSingle(); } } @@ -3003,44 +3004,44 @@ public final TypeSwitchExprContext typeSwitchExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(555); + setState(557); match(Ktypeswitch); - setState(556); + setState(558); match(T__26); - setState(557); + setState(559); ((TypeSwitchExprContext)_localctx).cond = expr(); - setState(558); + setState(560); match(T__27); - setState(560); + setState(562); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(559); + setState(561); ((TypeSwitchExprContext)_localctx).caseClause = caseClause(); ((TypeSwitchExprContext)_localctx).cses.add(((TypeSwitchExprContext)_localctx).caseClause); } } - setState(562); + setState(564); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Kcase ); - setState(564); - match(Kdefault); setState(566); + match(Kdefault); + setState(568); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(565); + setState(567); ((TypeSwitchExprContext)_localctx).var_ref = varRef(); } } - setState(568); + setState(570); match(Kreturn); - setState(569); + setState(571); ((TypeSwitchExprContext)_localctx).def = exprSingle(); } } @@ -3093,43 +3094,43 @@ public final CaseClauseContext caseClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(571); + setState(573); match(Kcase); - setState(575); + setState(577); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(572); + setState(574); ((CaseClauseContext)_localctx).var_ref = varRef(); - setState(573); + setState(575); match(Kas); } } - setState(577); + setState(579); ((CaseClauseContext)_localctx).sequenceType = sequenceType(); ((CaseClauseContext)_localctx).union.add(((CaseClauseContext)_localctx).sequenceType); - setState(582); + setState(584); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__31) { { { - setState(578); + setState(580); match(T__31); - setState(579); + setState(581); ((CaseClauseContext)_localctx).sequenceType = sequenceType(); ((CaseClauseContext)_localctx).union.add(((CaseClauseContext)_localctx).sequenceType); } } - setState(584); + setState(586); _errHandler.sync(this); _la = _input.LA(1); } - setState(585); + setState(587); match(Kreturn); - setState(586); + setState(588); ((CaseClauseContext)_localctx).ret = exprSingle(); } } @@ -3177,21 +3178,21 @@ public final IfExprContext ifExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(588); + setState(590); match(Kif); - setState(589); + setState(591); match(T__26); - setState(590); + setState(592); ((IfExprContext)_localctx).test_condition = expr(); - setState(591); + setState(593); match(T__27); - setState(592); + setState(594); match(Kthen); - setState(593); + setState(595); ((IfExprContext)_localctx).branch = exprSingle(); - setState(594); + setState(596); match(Kelse); - setState(595); + setState(597); ((IfExprContext)_localctx).else_branch = exprSingle(); } } @@ -3238,15 +3239,15 @@ public final TryCatchExprContext tryCatchExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(597); + setState(599); match(Ktry); - setState(598); + setState(600); match(T__28); - setState(599); + setState(601); ((TryCatchExprContext)_localctx).try_expression = expr(); - setState(600); + setState(602); match(T__29); - setState(602); + setState(604); _errHandler.sync(this); _alt = 1; do { @@ -3254,7 +3255,7 @@ public final TryCatchExprContext tryCatchExpr() throws RecognitionException { case 1: { { - setState(601); + setState(603); ((TryCatchExprContext)_localctx).catchClause = catchClause(); ((TryCatchExprContext)_localctx).catches.add(((TryCatchExprContext)_localctx).catchClause); } @@ -3263,7 +3264,7 @@ public final TryCatchExprContext tryCatchExpr() throws RecognitionException { default: throw new NoViableAltException(this); } - setState(604); + setState(606); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,53,_ctx); } while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); @@ -3314,14 +3315,14 @@ public final CatchClauseContext catchClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(606); + setState(608); match(Kcatch); - setState(609); + setState(611); _errHandler.sync(this); switch (_input.LA(1)) { case T__32: { - setState(607); + setState(609); ((CatchClauseContext)_localctx).s33 = match(T__32); ((CatchClauseContext)_localctx).jokers.add(((CatchClauseContext)_localctx).s33); } @@ -3385,7 +3386,7 @@ public final CatchClauseContext catchClause() throws RecognitionException { case Kjson: case NCName: { - setState(608); + setState(610); ((CatchClauseContext)_localctx).qname = qname(); ((CatchClauseContext)_localctx).errors.add(((CatchClauseContext)_localctx).qname); } @@ -3393,20 +3394,20 @@ public final CatchClauseContext catchClause() throws RecognitionException { default: throw new NoViableAltException(this); } - setState(618); + setState(620); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__31) { { { - setState(611); + setState(613); match(T__31); - setState(614); + setState(616); _errHandler.sync(this); switch (_input.LA(1)) { case T__32: { - setState(612); + setState(614); ((CatchClauseContext)_localctx).s33 = match(T__32); ((CatchClauseContext)_localctx).jokers.add(((CatchClauseContext)_localctx).s33); } @@ -3470,7 +3471,7 @@ public final CatchClauseContext catchClause() throws RecognitionException { case Kjson: case NCName: { - setState(613); + setState(615); ((CatchClauseContext)_localctx).qname = qname(); ((CatchClauseContext)_localctx).errors.add(((CatchClauseContext)_localctx).qname); } @@ -3480,15 +3481,15 @@ public final CatchClauseContext catchClause() throws RecognitionException { } } } - setState(620); + setState(622); _errHandler.sync(this); _la = _input.LA(1); } - setState(621); + setState(623); match(T__28); - setState(622); + setState(624); ((CatchClauseContext)_localctx).catch_expression = expr(); - setState(623); + setState(625); match(T__29); } } @@ -3535,24 +3536,24 @@ public final OrExprContext orExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(625); + setState(627); ((OrExprContext)_localctx).main_expr = andExpr(); - setState(630); + setState(632); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,57,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(626); + setState(628); match(Kor); - setState(627); + setState(629); ((OrExprContext)_localctx).andExpr = andExpr(); ((OrExprContext)_localctx).rhs.add(((OrExprContext)_localctx).andExpr); } } } - setState(632); + setState(634); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,57,_ctx); } @@ -3601,24 +3602,24 @@ public final AndExprContext andExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(633); + setState(635); ((AndExprContext)_localctx).main_expr = notExpr(); - setState(638); + setState(640); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,58,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(634); + setState(636); match(Kand); - setState(635); + setState(637); ((AndExprContext)_localctx).notExpr = notExpr(); ((AndExprContext)_localctx).rhs.add(((AndExprContext)_localctx).notExpr); } } } - setState(640); + setState(642); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,58,_ctx); } @@ -3660,18 +3661,18 @@ public final NotExprContext notExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(642); + setState(644); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,59,_ctx) ) { case 1: { - setState(641); + setState(643); ((NotExprContext)_localctx).Knot = match(Knot); ((NotExprContext)_localctx).op.add(((NotExprContext)_localctx).Knot); } break; } - setState(644); + setState(646); ((NotExprContext)_localctx).main_expr = comparisonExpr(); } } @@ -3728,14 +3729,14 @@ public final ComparisonExprContext comparisonExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(646); + setState(648); ((ComparisonExprContext)_localctx).main_expr = stringConcatExpr(); - setState(649); + setState(651); _errHandler.sync(this); _la = _input.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40) | (1L << T__41) | (1L << T__42) | (1L << T__43))) != 0)) { { - setState(647); + setState(649); ((ComparisonExprContext)_localctx)._tset1157 = _input.LT(1); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40) | (1L << T__41) | (1L << T__42) | (1L << T__43))) != 0)) ) { @@ -3747,7 +3748,7 @@ public final ComparisonExprContext comparisonExpr() throws RecognitionException consume(); } ((ComparisonExprContext)_localctx).op.add(((ComparisonExprContext)_localctx)._tset1157); - setState(648); + setState(650); ((ComparisonExprContext)_localctx).stringConcatExpr = stringConcatExpr(); ((ComparisonExprContext)_localctx).rhs.add(((ComparisonExprContext)_localctx).stringConcatExpr); } @@ -3794,22 +3795,22 @@ public final StringConcatExprContext stringConcatExpr() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(651); + setState(653); ((StringConcatExprContext)_localctx).main_expr = rangeExpr(); - setState(656); + setState(658); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__44) { { { - setState(652); + setState(654); match(T__44); - setState(653); + setState(655); ((StringConcatExprContext)_localctx).rangeExpr = rangeExpr(); ((StringConcatExprContext)_localctx).rhs.add(((StringConcatExprContext)_localctx).rangeExpr); } } - setState(658); + setState(660); _errHandler.sync(this); _la = _input.LA(1); } @@ -3854,16 +3855,16 @@ public final RangeExprContext rangeExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(659); + setState(661); ((RangeExprContext)_localctx).main_expr = additiveExpr(); - setState(662); + setState(664); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,62,_ctx) ) { case 1: { - setState(660); + setState(662); match(Kto); - setState(661); + setState(663); ((RangeExprContext)_localctx).additiveExpr = additiveExpr(); ((RangeExprContext)_localctx).rhs.add(((RangeExprContext)_localctx).additiveExpr); } @@ -3915,16 +3916,16 @@ public final AdditiveExprContext additiveExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(664); + setState(666); ((AdditiveExprContext)_localctx).main_expr = multiplicativeExpr(); - setState(669); + setState(671); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,63,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(665); + setState(667); ((AdditiveExprContext)_localctx)._tset1266 = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__45 || _la==T__46) ) { @@ -3936,13 +3937,13 @@ public final AdditiveExprContext additiveExpr() throws RecognitionException { consume(); } ((AdditiveExprContext)_localctx).op.add(((AdditiveExprContext)_localctx)._tset1266); - setState(666); + setState(668); ((AdditiveExprContext)_localctx).multiplicativeExpr = multiplicativeExpr(); ((AdditiveExprContext)_localctx).rhs.add(((AdditiveExprContext)_localctx).multiplicativeExpr); } } } - setState(671); + setState(673); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,63,_ctx); } @@ -3993,15 +3994,15 @@ public final MultiplicativeExprContext multiplicativeExpr() throws RecognitionEx try { enterOuterAlt(_localctx, 1); { - setState(672); + setState(674); ((MultiplicativeExprContext)_localctx).main_expr = instanceOfExpr(); - setState(677); + setState(679); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__32) | (1L << T__47) | (1L << T__48) | (1L << T__49))) != 0)) { { { - setState(673); + setState(675); ((MultiplicativeExprContext)_localctx)._tset1294 = _input.LT(1); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__32) | (1L << T__47) | (1L << T__48) | (1L << T__49))) != 0)) ) { @@ -4013,12 +4014,12 @@ public final MultiplicativeExprContext multiplicativeExpr() throws RecognitionEx consume(); } ((MultiplicativeExprContext)_localctx).op.add(((MultiplicativeExprContext)_localctx)._tset1294); - setState(674); + setState(676); ((MultiplicativeExprContext)_localctx).instanceOfExpr = instanceOfExpr(); ((MultiplicativeExprContext)_localctx).rhs.add(((MultiplicativeExprContext)_localctx).instanceOfExpr); } } - setState(679); + setState(681); _errHandler.sync(this); _la = _input.LA(1); } @@ -4036,10 +4037,10 @@ public final MultiplicativeExprContext multiplicativeExpr() throws RecognitionEx } public static class InstanceOfExprContext extends ParserRuleContext { - public TreatExprContext main_expr; + public StaticallyIsExprContext main_expr; public SequenceTypeContext seq; - public TreatExprContext treatExpr() { - return getRuleContext(TreatExprContext.class,0); + public StaticallyIsExprContext staticallyIsExpr() { + return getRuleContext(StaticallyIsExprContext.class,0); } public TerminalNode Kinstance() { return getToken(JsoniqParser.Kinstance, 0); } public TerminalNode Kof() { return getToken(JsoniqParser.Kof, 0); } @@ -4063,18 +4064,18 @@ public final InstanceOfExprContext instanceOfExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(680); - ((InstanceOfExprContext)_localctx).main_expr = treatExpr(); - setState(684); + setState(682); + ((InstanceOfExprContext)_localctx).main_expr = staticallyIsExpr(); + setState(686); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,65,_ctx) ) { case 1: { - setState(681); + setState(683); match(Kinstance); - setState(682); + setState(684); match(Kof); - setState(683); + setState(685); ((InstanceOfExprContext)_localctx).seq = sequenceType(); } break; @@ -4092,6 +4093,64 @@ public final InstanceOfExprContext instanceOfExpr() throws RecognitionException return _localctx; } + public static class StaticallyIsExprContext extends ParserRuleContext { + public TreatExprContext main_expr; + public SequenceTypeContext seq; + public TreatExprContext treatExpr() { + return getRuleContext(TreatExprContext.class,0); + } + public TerminalNode Kstatically() { return getToken(JsoniqParser.Kstatically, 0); } + public TerminalNode Kis() { return getToken(JsoniqParser.Kis, 0); } + public SequenceTypeContext sequenceType() { + return getRuleContext(SequenceTypeContext.class,0); + } + public StaticallyIsExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_staticallyIsExpr; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor)visitor).visitStaticallyIsExpr(this); + else return visitor.visitChildren(this); + } + } + + public final StaticallyIsExprContext staticallyIsExpr() throws RecognitionException { + StaticallyIsExprContext _localctx = new StaticallyIsExprContext(_ctx, getState()); + enterRule(_localctx, 100, RULE_staticallyIsExpr); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(688); + ((StaticallyIsExprContext)_localctx).main_expr = treatExpr(); + setState(692); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==Kstatically) { + { + setState(689); + match(Kstatically); + setState(690); + match(Kis); + setState(691); + ((StaticallyIsExprContext)_localctx).seq = sequenceType(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + public static class TreatExprContext extends ParserRuleContext { public CastableExprContext main_expr; public SequenceTypeContext seq; @@ -4116,22 +4175,22 @@ public T accept(ParseTreeVisitor visitor) { public final TreatExprContext treatExpr() throws RecognitionException { TreatExprContext _localctx = new TreatExprContext(_ctx, getState()); - enterRule(_localctx, 100, RULE_treatExpr); + enterRule(_localctx, 102, RULE_treatExpr); try { enterOuterAlt(_localctx, 1); { - setState(686); + setState(694); ((TreatExprContext)_localctx).main_expr = castableExpr(); - setState(690); + setState(698); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,66,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,67,_ctx) ) { case 1: { - setState(687); + setState(695); match(Ktreat); - setState(688); + setState(696); match(Kas); - setState(689); + setState(697); ((TreatExprContext)_localctx).seq = sequenceType(); } break; @@ -4173,22 +4232,22 @@ public T accept(ParseTreeVisitor visitor) { public final CastableExprContext castableExpr() throws RecognitionException { CastableExprContext _localctx = new CastableExprContext(_ctx, getState()); - enterRule(_localctx, 102, RULE_castableExpr); + enterRule(_localctx, 104, RULE_castableExpr); try { enterOuterAlt(_localctx, 1); { - setState(692); + setState(700); ((CastableExprContext)_localctx).main_expr = castExpr(); - setState(696); + setState(704); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,67,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,68,_ctx) ) { case 1: { - setState(693); + setState(701); match(Kcastable); - setState(694); + setState(702); match(Kas); - setState(695); + setState(703); ((CastableExprContext)_localctx).single = singleType(); } break; @@ -4230,22 +4289,22 @@ public T accept(ParseTreeVisitor visitor) { public final CastExprContext castExpr() throws RecognitionException { CastExprContext _localctx = new CastExprContext(_ctx, getState()); - enterRule(_localctx, 104, RULE_castExpr); + enterRule(_localctx, 106, RULE_castExpr); try { enterOuterAlt(_localctx, 1); { - setState(698); + setState(706); ((CastExprContext)_localctx).main_expr = arrowExpr(); - setState(702); + setState(710); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,68,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,69,_ctx) ) { case 1: { - setState(699); + setState(707); match(Kcast); - setState(700); + setState(708); match(Kas); - setState(701); + setState(709); ((CastExprContext)_localctx).single = singleType(); } break; @@ -4289,35 +4348,35 @@ public T accept(ParseTreeVisitor visitor) { public final ArrowExprContext arrowExpr() throws RecognitionException { ArrowExprContext _localctx = new ArrowExprContext(_ctx, getState()); - enterRule(_localctx, 106, RULE_arrowExpr); + enterRule(_localctx, 108, RULE_arrowExpr); try { int _alt; enterOuterAlt(_localctx, 1); { - setState(704); + setState(712); ((ArrowExprContext)_localctx).main_expr = unaryExpr(); - setState(711); + setState(719); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,69,_ctx); + _alt = getInterpreter().adaptivePredict(_input,70,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { { - setState(705); + setState(713); match(T__3); - setState(706); + setState(714); match(T__42); } - setState(708); + setState(716); ((ArrowExprContext)_localctx).functionCall = functionCall(); ((ArrowExprContext)_localctx).function_call_expr.add(((ArrowExprContext)_localctx).functionCall); } } } - setState(713); + setState(721); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,69,_ctx); + _alt = getInterpreter().adaptivePredict(_input,70,_ctx); } } } @@ -4336,7 +4395,7 @@ public static class UnaryExprContext extends ParserRuleContext { public Token s47; public List op = new ArrayList(); public Token s46; - public Token _tset1433; + public Token _tset1454; public SimpleMapExprContext main_expr; public SimpleMapExprContext simpleMapExpr() { return getRuleContext(SimpleMapExprContext.class,0); @@ -4354,36 +4413,36 @@ public T accept(ParseTreeVisitor visitor) { public final UnaryExprContext unaryExpr() throws RecognitionException { UnaryExprContext _localctx = new UnaryExprContext(_ctx, getState()); - enterRule(_localctx, 108, RULE_unaryExpr); + enterRule(_localctx, 110, RULE_unaryExpr); int _la; try { enterOuterAlt(_localctx, 1); { - setState(717); + setState(725); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__45 || _la==T__46) { { { - setState(714); - ((UnaryExprContext)_localctx)._tset1433 = _input.LT(1); + setState(722); + ((UnaryExprContext)_localctx)._tset1454 = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__45 || _la==T__46) ) { - ((UnaryExprContext)_localctx)._tset1433 = (Token)_errHandler.recoverInline(this); + ((UnaryExprContext)_localctx)._tset1454 = (Token)_errHandler.recoverInline(this); } else { if ( _input.LA(1)==Token.EOF ) matchedEOF = true; _errHandler.reportMatch(this); consume(); } - ((UnaryExprContext)_localctx).op.add(((UnaryExprContext)_localctx)._tset1433); + ((UnaryExprContext)_localctx).op.add(((UnaryExprContext)_localctx)._tset1454); } } - setState(719); + setState(727); _errHandler.sync(this); _la = _input.LA(1); } - setState(720); + setState(728); ((UnaryExprContext)_localctx).main_expr = simpleMapExpr(); } } @@ -4421,27 +4480,27 @@ public T accept(ParseTreeVisitor visitor) { public final SimpleMapExprContext simpleMapExpr() throws RecognitionException { SimpleMapExprContext _localctx = new SimpleMapExprContext(_ctx, getState()); - enterRule(_localctx, 110, RULE_simpleMapExpr); + enterRule(_localctx, 112, RULE_simpleMapExpr); int _la; try { enterOuterAlt(_localctx, 1); { - setState(722); + setState(730); ((SimpleMapExprContext)_localctx).main_expr = postFixExpr(); - setState(727); + setState(735); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__50) { { { - setState(723); + setState(731); match(T__50); - setState(724); + setState(732); ((SimpleMapExprContext)_localctx).postFixExpr = postFixExpr(); ((SimpleMapExprContext)_localctx).map_expr.add(((SimpleMapExprContext)_localctx).postFixExpr); } } - setState(729); + setState(737); _errHandler.sync(this); _la = _input.LA(1); } @@ -4506,58 +4565,58 @@ public T accept(ParseTreeVisitor visitor) { public final PostFixExprContext postFixExpr() throws RecognitionException { PostFixExprContext _localctx = new PostFixExprContext(_ctx, getState()); - enterRule(_localctx, 112, RULE_postFixExpr); + enterRule(_localctx, 114, RULE_postFixExpr); try { int _alt; enterOuterAlt(_localctx, 1); { - setState(730); - ((PostFixExprContext)_localctx).main_expr = primaryExpr(); setState(738); + ((PostFixExprContext)_localctx).main_expr = primaryExpr(); + setState(746); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,73,_ctx); + _alt = getInterpreter().adaptivePredict(_input,74,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { - setState(736); + setState(744); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,72,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,73,_ctx) ) { case 1: { - setState(731); + setState(739); arrayLookup(); } break; case 2: { - setState(732); + setState(740); predicate(); } break; case 3: { - setState(733); + setState(741); objectLookup(); } break; case 4: { - setState(734); + setState(742); arrayUnboxing(); } break; case 5: { - setState(735); + setState(743); argumentList(); } break; } } } - setState(740); + setState(748); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,73,_ctx); + _alt = getInterpreter().adaptivePredict(_input,74,_ctx); } } } @@ -4589,19 +4648,19 @@ public T accept(ParseTreeVisitor visitor) { public final ArrayLookupContext arrayLookup() throws RecognitionException { ArrayLookupContext _localctx = new ArrayLookupContext(_ctx, getState()); - enterRule(_localctx, 114, RULE_arrayLookup); + enterRule(_localctx, 116, RULE_arrayLookup); try { enterOuterAlt(_localctx, 1); { - setState(741); + setState(749); match(T__51); - setState(742); + setState(750); match(T__51); - setState(743); + setState(751); expr(); - setState(744); + setState(752); match(T__52); - setState(745); + setState(753); match(T__52); } } @@ -4630,13 +4689,13 @@ public T accept(ParseTreeVisitor visitor) { public final ArrayUnboxingContext arrayUnboxing() throws RecognitionException { ArrayUnboxingContext _localctx = new ArrayUnboxingContext(_ctx, getState()); - enterRule(_localctx, 116, RULE_arrayUnboxing); + enterRule(_localctx, 118, RULE_arrayUnboxing); try { enterOuterAlt(_localctx, 1); { - setState(747); + setState(755); match(T__51); - setState(748); + setState(756); match(T__52); } } @@ -4668,15 +4727,15 @@ public T accept(ParseTreeVisitor visitor) { public final PredicateContext predicate() throws RecognitionException { PredicateContext _localctx = new PredicateContext(_ctx, getState()); - enterRule(_localctx, 118, RULE_predicate); + enterRule(_localctx, 120, RULE_predicate); try { enterOuterAlt(_localctx, 1); { - setState(750); + setState(758); match(T__51); - setState(751); + setState(759); expr(); - setState(752); + setState(760); match(T__52); } } @@ -4731,13 +4790,13 @@ public T accept(ParseTreeVisitor visitor) { public final ObjectLookupContext objectLookup() throws RecognitionException { ObjectLookupContext _localctx = new ObjectLookupContext(_ctx, getState()); - enterRule(_localctx, 120, RULE_objectLookup); + enterRule(_localctx, 122, RULE_objectLookup); try { enterOuterAlt(_localctx, 1); { - setState(754); - match(T__53); setState(762); + match(T__53); + setState(770); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: @@ -4784,37 +4843,37 @@ public final ObjectLookupContext objectLookup() throws RecognitionException { case Kjsoniq: case Kjson: { - setState(755); + setState(763); ((ObjectLookupContext)_localctx).kw = keyWords(); } break; case STRING: { - setState(756); + setState(764); ((ObjectLookupContext)_localctx).lt = stringLiteral(); } break; case NCName: { - setState(757); + setState(765); ((ObjectLookupContext)_localctx).nc = match(NCName); } break; case T__26: { - setState(758); + setState(766); ((ObjectLookupContext)_localctx).pe = parenthesizedExpr(); } break; case T__30: { - setState(759); + setState(767); ((ObjectLookupContext)_localctx).vr = varRef(); } break; case T__54: { - setState(760); + setState(768); ((ObjectLookupContext)_localctx).ci = contextItemExpr(); } break; @@ -4833,7 +4892,7 @@ public final ObjectLookupContext objectLookup() throws RecognitionException { case T__73: case T__74: { - setState(761); + setState(769); ((ObjectLookupContext)_localctx).tkw = typesKeywords(); } break; @@ -4899,92 +4958,92 @@ public T accept(ParseTreeVisitor visitor) { public final PrimaryExprContext primaryExpr() throws RecognitionException { PrimaryExprContext _localctx = new PrimaryExprContext(_ctx, getState()); - enterRule(_localctx, 122, RULE_primaryExpr); + enterRule(_localctx, 124, RULE_primaryExpr); try { - setState(776); + setState(784); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,75,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,76,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(764); + setState(772); match(NullLiteral); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(765); + setState(773); match(Literal); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(766); + setState(774); stringLiteral(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(767); + setState(775); varRef(); } break; case 5: enterOuterAlt(_localctx, 5); { - setState(768); + setState(776); parenthesizedExpr(); } break; case 6: enterOuterAlt(_localctx, 6); { - setState(769); + setState(777); contextItemExpr(); } break; case 7: enterOuterAlt(_localctx, 7); { - setState(770); + setState(778); objectConstructor(); } break; case 8: enterOuterAlt(_localctx, 8); { - setState(771); + setState(779); functionCall(); } break; case 9: enterOuterAlt(_localctx, 9); { - setState(772); + setState(780); orderedExpr(); } break; case 10: enterOuterAlt(_localctx, 10); { - setState(773); + setState(781); unorderedExpr(); } break; case 11: enterOuterAlt(_localctx, 11); { - setState(774); + setState(782); arrayConstructor(); } break; case 12: enterOuterAlt(_localctx, 12); { - setState(775); + setState(783); functionItemExpr(); } break; @@ -5019,13 +5078,13 @@ public T accept(ParseTreeVisitor visitor) { public final VarRefContext varRef() throws RecognitionException { VarRefContext _localctx = new VarRefContext(_ctx, getState()); - enterRule(_localctx, 124, RULE_varRef); + enterRule(_localctx, 126, RULE_varRef); try { enterOuterAlt(_localctx, 1); { - setState(778); + setState(786); match(T__30); - setState(779); + setState(787); ((VarRefContext)_localctx).var_name = qname(); } } @@ -5057,24 +5116,24 @@ public T accept(ParseTreeVisitor visitor) { public final ParenthesizedExprContext parenthesizedExpr() throws RecognitionException { ParenthesizedExprContext _localctx = new ParenthesizedExprContext(_ctx, getState()); - enterRule(_localctx, 126, RULE_parenthesizedExpr); + enterRule(_localctx, 128, RULE_parenthesizedExpr); int _la; try { enterOuterAlt(_localctx, 1); { - setState(781); + setState(789); match(T__26); - setState(783); + setState(791); _errHandler.sync(this); _la = _input.LA(1); if (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { { - setState(782); + setState(790); expr(); } } - setState(785); + setState(793); match(T__27); } } @@ -5103,11 +5162,11 @@ public T accept(ParseTreeVisitor visitor) { public final ContextItemExprContext contextItemExpr() throws RecognitionException { ContextItemExprContext _localctx = new ContextItemExprContext(_ctx, getState()); - enterRule(_localctx, 128, RULE_contextItemExpr); + enterRule(_localctx, 130, RULE_contextItemExpr); try { enterOuterAlt(_localctx, 1); { - setState(787); + setState(795); match(T__54); } } @@ -5139,17 +5198,17 @@ public T accept(ParseTreeVisitor visitor) { public final OrderedExprContext orderedExpr() throws RecognitionException { OrderedExprContext _localctx = new OrderedExprContext(_ctx, getState()); - enterRule(_localctx, 130, RULE_orderedExpr); + enterRule(_localctx, 132, RULE_orderedExpr); try { enterOuterAlt(_localctx, 1); { - setState(789); + setState(797); match(T__6); - setState(790); + setState(798); match(T__28); - setState(791); + setState(799); expr(); - setState(792); + setState(800); match(T__29); } } @@ -5181,17 +5240,17 @@ public T accept(ParseTreeVisitor visitor) { public final UnorderedExprContext unorderedExpr() throws RecognitionException { UnorderedExprContext _localctx = new UnorderedExprContext(_ctx, getState()); - enterRule(_localctx, 132, RULE_unorderedExpr); + enterRule(_localctx, 134, RULE_unorderedExpr); try { enterOuterAlt(_localctx, 1); { - setState(794); + setState(802); match(T__7); - setState(795); + setState(803); match(T__28); - setState(796); + setState(804); expr(); - setState(797); + setState(805); match(T__29); } } @@ -5227,13 +5286,13 @@ public T accept(ParseTreeVisitor visitor) { public final FunctionCallContext functionCall() throws RecognitionException { FunctionCallContext _localctx = new FunctionCallContext(_ctx, getState()); - enterRule(_localctx, 134, RULE_functionCall); + enterRule(_localctx, 136, RULE_functionCall); try { enterOuterAlt(_localctx, 1); { - setState(799); + setState(807); ((FunctionCallContext)_localctx).fn_name = qname(); - setState(800); + setState(808); argumentList(); } } @@ -5270,39 +5329,39 @@ public T accept(ParseTreeVisitor visitor) { public final ArgumentListContext argumentList() throws RecognitionException { ArgumentListContext _localctx = new ArgumentListContext(_ctx, getState()); - enterRule(_localctx, 136, RULE_argumentList); + enterRule(_localctx, 138, RULE_argumentList); int _la; try { enterOuterAlt(_localctx, 1); { - setState(802); + setState(810); match(T__26); - setState(809); + setState(817); _errHandler.sync(this); _la = _input.LA(1); while (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (ArgumentPlaceholder - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { { { - setState(803); + setState(811); ((ArgumentListContext)_localctx).argument = argument(); ((ArgumentListContext)_localctx).args.add(((ArgumentListContext)_localctx).argument); - setState(805); + setState(813); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__21) { { - setState(804); + setState(812); match(T__21); } } } } - setState(811); + setState(819); _errHandler.sync(this); _la = _input.LA(1); } - setState(812); + setState(820); match(T__27); } } @@ -5335,9 +5394,9 @@ public T accept(ParseTreeVisitor visitor) { public final ArgumentContext argument() throws RecognitionException { ArgumentContext _localctx = new ArgumentContext(_ctx, getState()); - enterRule(_localctx, 138, RULE_argument); + enterRule(_localctx, 140, RULE_argument); try { - setState(816); + setState(824); _errHandler.sync(this); switch (_input.LA(1)) { case T__6: @@ -5414,14 +5473,14 @@ public final ArgumentContext argument() throws RecognitionException { case NCName: enterOuterAlt(_localctx, 1); { - setState(814); + setState(822); exprSingle(); } break; case ArgumentPlaceholder: enterOuterAlt(_localctx, 2); { - setState(815); + setState(823); match(ArgumentPlaceholder); } break; @@ -5460,9 +5519,9 @@ public T accept(ParseTreeVisitor visitor) { public final FunctionItemExprContext functionItemExpr() throws RecognitionException { FunctionItemExprContext _localctx = new FunctionItemExprContext(_ctx, getState()); - enterRule(_localctx, 140, RULE_functionItemExpr); + enterRule(_localctx, 142, RULE_functionItemExpr); try { - setState(820); + setState(828); _errHandler.sync(this); switch (_input.LA(1)) { case T__61: @@ -5525,14 +5584,14 @@ public final FunctionItemExprContext functionItemExpr() throws RecognitionExcept case NCName: enterOuterAlt(_localctx, 1); { - setState(818); + setState(826); namedFunctionRef(); } break; case T__25: enterOuterAlt(_localctx, 2); { - setState(819); + setState(827); inlineFunctionExpr(); } break; @@ -5571,15 +5630,15 @@ public T accept(ParseTreeVisitor visitor) { public final NamedFunctionRefContext namedFunctionRef() throws RecognitionException { NamedFunctionRefContext _localctx = new NamedFunctionRefContext(_ctx, getState()); - enterRule(_localctx, 142, RULE_namedFunctionRef); + enterRule(_localctx, 144, RULE_namedFunctionRef); try { enterOuterAlt(_localctx, 1); { - setState(822); + setState(830); ((NamedFunctionRefContext)_localctx).fn_name = qname(); - setState(823); + setState(831); match(T__55); - setState(824); + setState(832); ((NamedFunctionRefContext)_localctx).arity = match(Literal); } } @@ -5620,45 +5679,45 @@ public T accept(ParseTreeVisitor visitor) { public final InlineFunctionExprContext inlineFunctionExpr() throws RecognitionException { InlineFunctionExprContext _localctx = new InlineFunctionExprContext(_ctx, getState()); - enterRule(_localctx, 144, RULE_inlineFunctionExpr); + enterRule(_localctx, 146, RULE_inlineFunctionExpr); int _la; try { enterOuterAlt(_localctx, 1); { - setState(826); + setState(834); match(T__25); - setState(827); + setState(835); match(T__26); - setState(829); + setState(837); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(828); + setState(836); paramList(); } } - setState(831); + setState(839); match(T__27); - setState(834); + setState(842); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(832); + setState(840); match(Kas); - setState(833); + setState(841); ((InlineFunctionExprContext)_localctx).return_type = sequenceType(); } } { - setState(836); + setState(844); match(T__28); - setState(837); + setState(845); ((InlineFunctionExprContext)_localctx).fn_body = expr(); - setState(838); + setState(846); match(T__29); } } @@ -5698,17 +5757,17 @@ public T accept(ParseTreeVisitor visitor) { public final SequenceTypeContext sequenceType() throws RecognitionException { SequenceTypeContext _localctx = new SequenceTypeContext(_ctx, getState()); - enterRule(_localctx, 146, RULE_sequenceType); + enterRule(_localctx, 148, RULE_sequenceType); try { - setState(848); + setState(856); _errHandler.sync(this); switch (_input.LA(1)) { case T__26: enterOuterAlt(_localctx, 1); { - setState(840); + setState(848); match(T__26); - setState(841); + setState(849); match(T__27); } break; @@ -5734,28 +5793,28 @@ public final SequenceTypeContext sequenceType() throws RecognitionException { case NullLiteral: enterOuterAlt(_localctx, 2); { - setState(842); + setState(850); ((SequenceTypeContext)_localctx).item = itemType(); - setState(846); + setState(854); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,83,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,84,_ctx) ) { case 1: { - setState(843); + setState(851); ((SequenceTypeContext)_localctx).s121 = match(ArgumentPlaceholder); ((SequenceTypeContext)_localctx).question.add(((SequenceTypeContext)_localctx).s121); } break; case 2: { - setState(844); + setState(852); ((SequenceTypeContext)_localctx).s33 = match(T__32); ((SequenceTypeContext)_localctx).star.add(((SequenceTypeContext)_localctx).s33); } break; case 3: { - setState(845); + setState(853); ((SequenceTypeContext)_localctx).s46 = match(T__45); ((SequenceTypeContext)_localctx).plus.add(((SequenceTypeContext)_localctx).s46); } @@ -5803,56 +5862,56 @@ public T accept(ParseTreeVisitor visitor) { public final ObjectConstructorContext objectConstructor() throws RecognitionException { ObjectConstructorContext _localctx = new ObjectConstructorContext(_ctx, getState()); - enterRule(_localctx, 148, RULE_objectConstructor); + enterRule(_localctx, 150, RULE_objectConstructor); int _la; try { - setState(866); + setState(874); _errHandler.sync(this); switch (_input.LA(1)) { case T__28: enterOuterAlt(_localctx, 1); { - setState(850); + setState(858); match(T__28); - setState(859); + setState(867); _errHandler.sync(this); _la = _input.LA(1); if (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { { - setState(851); + setState(859); pairConstructor(); - setState(856); + setState(864); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(852); + setState(860); match(T__21); - setState(853); + setState(861); pairConstructor(); } } - setState(858); + setState(866); _errHandler.sync(this); _la = _input.LA(1); } } } - setState(861); + setState(869); match(T__29); } break; case T__56: enterOuterAlt(_localctx, 2); { - setState(862); + setState(870); ((ObjectConstructorContext)_localctx).s57 = match(T__56); ((ObjectConstructorContext)_localctx).merge_operator.add(((ObjectConstructorContext)_localctx).s57); - setState(863); + setState(871); expr(); - setState(864); + setState(872); match(T__57); } break; @@ -5891,15 +5950,15 @@ public T accept(ParseTreeVisitor visitor) { public final ItemTypeContext itemType() throws RecognitionException { ItemTypeContext _localctx = new ItemTypeContext(_ctx, getState()); - enterRule(_localctx, 150, RULE_itemType); + enterRule(_localctx, 152, RULE_itemType); try { - setState(871); + setState(879); _errHandler.sync(this); switch (_input.LA(1)) { case T__58: enterOuterAlt(_localctx, 1); { - setState(868); + setState(876); match(T__58); } break; @@ -5908,7 +5967,7 @@ public final ItemTypeContext itemType() throws RecognitionException { case Kjson: enterOuterAlt(_localctx, 2); { - setState(869); + setState(877); jSONItemTest(); } break; @@ -5930,7 +5989,7 @@ public final ItemTypeContext itemType() throws RecognitionException { case NullLiteral: enterOuterAlt(_localctx, 3); { - setState(870); + setState(878); atomicType(); } break; @@ -5964,12 +6023,12 @@ public T accept(ParseTreeVisitor visitor) { public final JSONItemTestContext jSONItemTest() throws RecognitionException { JSONItemTestContext _localctx = new JSONItemTestContext(_ctx, getState()); - enterRule(_localctx, 152, RULE_jSONItemTest); + enterRule(_localctx, 154, RULE_jSONItemTest); int _la; try { enterOuterAlt(_localctx, 1); { - setState(873); + setState(881); _la = _input.LA(1); if ( !(((((_la - 60)) & ~0x3f) == 0 && ((1L << (_la - 60)) & ((1L << (T__59 - 60)) | (1L << (T__60 - 60)) | (1L << (Kjson - 60)))) != 0)) ) { _errHandler.recoverInline(this); @@ -6006,11 +6065,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordStringContext keyWordString() throws RecognitionException { KeyWordStringContext _localctx = new KeyWordStringContext(_ctx, getState()); - enterRule(_localctx, 154, RULE_keyWordString); + enterRule(_localctx, 156, RULE_keyWordString); try { enterOuterAlt(_localctx, 1); { - setState(875); + setState(883); match(T__61); } } @@ -6039,11 +6098,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordIntegerContext keyWordInteger() throws RecognitionException { KeyWordIntegerContext _localctx = new KeyWordIntegerContext(_ctx, getState()); - enterRule(_localctx, 156, RULE_keyWordInteger); + enterRule(_localctx, 158, RULE_keyWordInteger); try { enterOuterAlt(_localctx, 1); { - setState(877); + setState(885); match(T__62); } } @@ -6072,11 +6131,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordDecimalContext keyWordDecimal() throws RecognitionException { KeyWordDecimalContext _localctx = new KeyWordDecimalContext(_ctx, getState()); - enterRule(_localctx, 158, RULE_keyWordDecimal); + enterRule(_localctx, 160, RULE_keyWordDecimal); try { enterOuterAlt(_localctx, 1); { - setState(879); + setState(887); match(T__63); } } @@ -6105,11 +6164,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordDoubleContext keyWordDouble() throws RecognitionException { KeyWordDoubleContext _localctx = new KeyWordDoubleContext(_ctx, getState()); - enterRule(_localctx, 160, RULE_keyWordDouble); + enterRule(_localctx, 162, RULE_keyWordDouble); try { enterOuterAlt(_localctx, 1); { - setState(881); + setState(889); match(T__64); } } @@ -6138,11 +6197,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordBooleanContext keyWordBoolean() throws RecognitionException { KeyWordBooleanContext _localctx = new KeyWordBooleanContext(_ctx, getState()); - enterRule(_localctx, 162, RULE_keyWordBoolean); + enterRule(_localctx, 164, RULE_keyWordBoolean); try { enterOuterAlt(_localctx, 1); { - setState(883); + setState(891); match(T__65); } } @@ -6171,11 +6230,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordDurationContext keyWordDuration() throws RecognitionException { KeyWordDurationContext _localctx = new KeyWordDurationContext(_ctx, getState()); - enterRule(_localctx, 164, RULE_keyWordDuration); + enterRule(_localctx, 166, RULE_keyWordDuration); try { enterOuterAlt(_localctx, 1); { - setState(885); + setState(893); match(T__66); } } @@ -6204,11 +6263,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordYearMonthDurationContext keyWordYearMonthDuration() throws RecognitionException { KeyWordYearMonthDurationContext _localctx = new KeyWordYearMonthDurationContext(_ctx, getState()); - enterRule(_localctx, 166, RULE_keyWordYearMonthDuration); + enterRule(_localctx, 168, RULE_keyWordYearMonthDuration); try { enterOuterAlt(_localctx, 1); { - setState(887); + setState(895); match(T__67); } } @@ -6237,11 +6296,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordDayTimeDurationContext keyWordDayTimeDuration() throws RecognitionException { KeyWordDayTimeDurationContext _localctx = new KeyWordDayTimeDurationContext(_ctx, getState()); - enterRule(_localctx, 168, RULE_keyWordDayTimeDuration); + enterRule(_localctx, 170, RULE_keyWordDayTimeDuration); try { enterOuterAlt(_localctx, 1); { - setState(889); + setState(897); match(T__68); } } @@ -6270,11 +6329,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordHexBinaryContext keyWordHexBinary() throws RecognitionException { KeyWordHexBinaryContext _localctx = new KeyWordHexBinaryContext(_ctx, getState()); - enterRule(_localctx, 170, RULE_keyWordHexBinary); + enterRule(_localctx, 172, RULE_keyWordHexBinary); try { enterOuterAlt(_localctx, 1); { - setState(891); + setState(899); match(T__69); } } @@ -6303,11 +6362,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordBase64BinaryContext keyWordBase64Binary() throws RecognitionException { KeyWordBase64BinaryContext _localctx = new KeyWordBase64BinaryContext(_ctx, getState()); - enterRule(_localctx, 172, RULE_keyWordBase64Binary); + enterRule(_localctx, 174, RULE_keyWordBase64Binary); try { enterOuterAlt(_localctx, 1); { - setState(893); + setState(901); match(T__70); } } @@ -6336,11 +6395,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordDateTimeContext keyWordDateTime() throws RecognitionException { KeyWordDateTimeContext _localctx = new KeyWordDateTimeContext(_ctx, getState()); - enterRule(_localctx, 174, RULE_keyWordDateTime); + enterRule(_localctx, 176, RULE_keyWordDateTime); try { enterOuterAlt(_localctx, 1); { - setState(895); + setState(903); match(T__71); } } @@ -6369,11 +6428,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordDateContext keyWordDate() throws RecognitionException { KeyWordDateContext _localctx = new KeyWordDateContext(_ctx, getState()); - enterRule(_localctx, 176, RULE_keyWordDate); + enterRule(_localctx, 178, RULE_keyWordDate); try { enterOuterAlt(_localctx, 1); { - setState(897); + setState(905); match(T__72); } } @@ -6402,11 +6461,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordTimeContext keyWordTime() throws RecognitionException { KeyWordTimeContext _localctx = new KeyWordTimeContext(_ctx, getState()); - enterRule(_localctx, 178, RULE_keyWordTime); + enterRule(_localctx, 180, RULE_keyWordTime); try { enterOuterAlt(_localctx, 1); { - setState(899); + setState(907); match(T__73); } } @@ -6435,11 +6494,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordAnyURIContext keyWordAnyURI() throws RecognitionException { KeyWordAnyURIContext _localctx = new KeyWordAnyURIContext(_ctx, getState()); - enterRule(_localctx, 180, RULE_keyWordAnyURI); + enterRule(_localctx, 182, RULE_keyWordAnyURI); try { enterOuterAlt(_localctx, 1); { - setState(901); + setState(909); match(T__74); } } @@ -6510,106 +6569,106 @@ public T accept(ParseTreeVisitor visitor) { public final TypesKeywordsContext typesKeywords() throws RecognitionException { TypesKeywordsContext _localctx = new TypesKeywordsContext(_ctx, getState()); - enterRule(_localctx, 182, RULE_typesKeywords); + enterRule(_localctx, 184, RULE_typesKeywords); try { - setState(917); + setState(925); _errHandler.sync(this); switch (_input.LA(1)) { case T__61: enterOuterAlt(_localctx, 1); { - setState(903); + setState(911); keyWordString(); } break; case T__62: enterOuterAlt(_localctx, 2); { - setState(904); + setState(912); keyWordInteger(); } break; case T__63: enterOuterAlt(_localctx, 3); { - setState(905); + setState(913); keyWordDecimal(); } break; case T__64: enterOuterAlt(_localctx, 4); { - setState(906); + setState(914); keyWordDouble(); } break; case T__65: enterOuterAlt(_localctx, 5); { - setState(907); + setState(915); keyWordBoolean(); } break; case T__66: enterOuterAlt(_localctx, 6); { - setState(908); + setState(916); keyWordDuration(); } break; case T__67: enterOuterAlt(_localctx, 7); { - setState(909); + setState(917); keyWordYearMonthDuration(); } break; case T__68: enterOuterAlt(_localctx, 8); { - setState(910); + setState(918); keyWordDayTimeDuration(); } break; case T__71: enterOuterAlt(_localctx, 9); { - setState(911); + setState(919); keyWordDateTime(); } break; case T__72: enterOuterAlt(_localctx, 10); { - setState(912); + setState(920); keyWordDate(); } break; case T__73: enterOuterAlt(_localctx, 11); { - setState(913); + setState(921); keyWordTime(); } break; case T__69: enterOuterAlt(_localctx, 12); { - setState(914); + setState(922); keyWordHexBinary(); } break; case T__70: enterOuterAlt(_localctx, 13); { - setState(915); + setState(923); keyWordBase64Binary(); } break; case T__74: enterOuterAlt(_localctx, 14); { - setState(916); + setState(924); keyWordAnyURI(); } break; @@ -6648,18 +6707,18 @@ public T accept(ParseTreeVisitor visitor) { public final SingleTypeContext singleType() throws RecognitionException { SingleTypeContext _localctx = new SingleTypeContext(_ctx, getState()); - enterRule(_localctx, 184, RULE_singleType); + enterRule(_localctx, 186, RULE_singleType); try { enterOuterAlt(_localctx, 1); { - setState(919); + setState(927); ((SingleTypeContext)_localctx).item = atomicType(); - setState(921); + setState(929); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,90,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,91,_ctx) ) { case 1: { - setState(920); + setState(928); ((SingleTypeContext)_localctx).s121 = match(ArgumentPlaceholder); ((SingleTypeContext)_localctx).question.add(((SingleTypeContext)_localctx).s121); } @@ -6696,15 +6755,15 @@ public T accept(ParseTreeVisitor visitor) { public final AtomicTypeContext atomicType() throws RecognitionException { AtomicTypeContext _localctx = new AtomicTypeContext(_ctx, getState()); - enterRule(_localctx, 186, RULE_atomicType); + enterRule(_localctx, 188, RULE_atomicType); try { - setState(926); + setState(934); _errHandler.sync(this); switch (_input.LA(1)) { case T__75: enterOuterAlt(_localctx, 1); { - setState(923); + setState(931); match(T__75); } break; @@ -6724,14 +6783,14 @@ public final AtomicTypeContext atomicType() throws RecognitionException { case T__74: enterOuterAlt(_localctx, 2); { - setState(924); + setState(932); typesKeywords(); } break; case NullLiteral: enterOuterAlt(_localctx, 3); { - setState(925); + setState(933); match(NullLiteral); } break; @@ -6768,15 +6827,15 @@ public T accept(ParseTreeVisitor visitor) { public final NCNameOrKeyWordContext nCNameOrKeyWord() throws RecognitionException { NCNameOrKeyWordContext _localctx = new NCNameOrKeyWordContext(_ctx, getState()); - enterRule(_localctx, 188, RULE_nCNameOrKeyWord); + enterRule(_localctx, 190, RULE_nCNameOrKeyWord); try { - setState(930); + setState(938); _errHandler.sync(this); switch (_input.LA(1)) { case NCName: enterOuterAlt(_localctx, 1); { - setState(928); + setState(936); match(NCName); } break; @@ -6796,7 +6855,7 @@ public final NCNameOrKeyWordContext nCNameOrKeyWord() throws RecognitionExceptio case T__74: enterOuterAlt(_localctx, 2); { - setState(929); + setState(937); typesKeywords(); } break; @@ -6839,28 +6898,28 @@ public T accept(ParseTreeVisitor visitor) { public final PairConstructorContext pairConstructor() throws RecognitionException { PairConstructorContext _localctx = new PairConstructorContext(_ctx, getState()); - enterRule(_localctx, 190, RULE_pairConstructor); + enterRule(_localctx, 192, RULE_pairConstructor); int _la; try { enterOuterAlt(_localctx, 1); { - setState(934); + setState(942); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,93,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,94,_ctx) ) { case 1: { - setState(932); + setState(940); ((PairConstructorContext)_localctx).lhs = exprSingle(); } break; case 2: { - setState(933); + setState(941); ((PairConstructorContext)_localctx).name = match(NCName); } break; } - setState(936); + setState(944); _la = _input.LA(1); if ( !(_la==T__9 || _la==ArgumentPlaceholder) ) { _errHandler.recoverInline(this); @@ -6870,7 +6929,7 @@ public final PairConstructorContext pairConstructor() throws RecognitionExceptio _errHandler.reportMatch(this); consume(); } - setState(937); + setState(945); ((PairConstructorContext)_localctx).rhs = exprSingle(); } } @@ -6902,24 +6961,24 @@ public T accept(ParseTreeVisitor visitor) { public final ArrayConstructorContext arrayConstructor() throws RecognitionException { ArrayConstructorContext _localctx = new ArrayConstructorContext(_ctx, getState()); - enterRule(_localctx, 192, RULE_arrayConstructor); + enterRule(_localctx, 194, RULE_arrayConstructor); int _la; try { enterOuterAlt(_localctx, 1); { - setState(939); + setState(947); match(T__51); - setState(941); + setState(949); _errHandler.sync(this); _la = _input.LA(1); if (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { { - setState(940); + setState(948); expr(); } } - setState(943); + setState(951); match(T__52); } } @@ -6951,11 +7010,11 @@ public T accept(ParseTreeVisitor visitor) { public final UriLiteralContext uriLiteral() throws RecognitionException { UriLiteralContext _localctx = new UriLiteralContext(_ctx, getState()); - enterRule(_localctx, 194, RULE_uriLiteral); + enterRule(_localctx, 196, RULE_uriLiteral); try { enterOuterAlt(_localctx, 1); { - setState(945); + setState(953); stringLiteral(); } } @@ -6985,11 +7044,11 @@ public T accept(ParseTreeVisitor visitor) { public final StringLiteralContext stringLiteral() throws RecognitionException { StringLiteralContext _localctx = new StringLiteralContext(_ctx, getState()); - enterRule(_localctx, 196, RULE_stringLiteral); + enterRule(_localctx, 198, RULE_stringLiteral); try { enterOuterAlt(_localctx, 1); { - setState(947); + setState(955); match(STRING); } } @@ -7061,12 +7120,12 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordsContext keyWords() throws RecognitionException { KeyWordsContext _localctx = new KeyWordsContext(_ctx, getState()); - enterRule(_localctx, 198, RULE_keyWords); + enterRule(_localctx, 200, RULE_keyWords); int _la; try { enterOuterAlt(_localctx, 1); { - setState(949); + setState(957); _la = _input.LA(1); if ( !(((((_la - 77)) & ~0x3f) == 0 && ((1L << (_la - 77)) & ((1L << (Kfor - 77)) | (1L << (Klet - 77)) | (1L << (Kwhere - 77)) | (1L << (Kgroup - 77)) | (1L << (Kby - 77)) | (1L << (Korder - 77)) | (1L << (Kreturn - 77)) | (1L << (Kif - 77)) | (1L << (Kin - 77)) | (1L << (Kas - 77)) | (1L << (Kat - 77)) | (1L << (Kallowing - 77)) | (1L << (Kempty - 77)) | (1L << (Kcount - 77)) | (1L << (Kstable - 77)) | (1L << (Kascending - 77)) | (1L << (Kdescending - 77)) | (1L << (Ksome - 77)) | (1L << (Kevery - 77)) | (1L << (Ksatisfies - 77)) | (1L << (Kcollation - 77)) | (1L << (Kgreatest - 77)) | (1L << (Kleast - 77)) | (1L << (Kswitch - 77)) | (1L << (Kcase - 77)) | (1L << (Ktry - 77)) | (1L << (Kcatch - 77)) | (1L << (Kdefault - 77)) | (1L << (Kthen - 77)) | (1L << (Kelse - 77)) | (1L << (Ktypeswitch - 77)) | (1L << (Kor - 77)) | (1L << (Kand - 77)) | (1L << (Knot - 77)) | (1L << (Kto - 77)) | (1L << (Kinstance - 77)) | (1L << (Kof - 77)) | (1L << (Ktreat - 77)) | (1L << (Kcast - 77)) | (1L << (Kcastable - 77)) | (1L << (Kversion - 77)) | (1L << (Kjsoniq - 77)) | (1L << (Kjson - 77)))) != 0)) ) { _errHandler.recoverInline(this); @@ -7090,7 +7149,7 @@ public final KeyWordsContext keyWords() throws RecognitionException { } public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\u0086\u03ba\4\2\t"+ + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\u0088\u03c2\4\2\t"+ "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ @@ -7101,348 +7160,352 @@ public final KeyWordsContext keyWords() throws RecognitionException { "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I"+ "\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT"+ "\4U\tU\4V\tV\4W\tW\4X\tX\4Y\tY\4Z\tZ\4[\t[\4\\\t\\\4]\t]\4^\t^\4_\t_\4"+ - "`\t`\4a\ta\4b\tb\4c\tc\4d\td\4e\te\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\5\3"+ - "\u00d3\n\3\3\3\3\3\5\3\u00d7\n\3\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3"+ - "\5\3\5\3\6\3\6\3\6\5\6\u00e7\n\6\3\6\3\6\7\6\u00eb\n\6\f\6\16\6\u00ee"+ - "\13\6\3\6\3\6\3\6\7\6\u00f3\n\6\f\6\16\6\u00f6\13\6\3\7\3\7\3\7\3\7\5"+ - "\7\u00fc\n\7\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3\t\5\t\u0106\n\t\3\n\3\n\3\n"+ - "\3\n\3\n\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3"+ - "\r\5\r\u011c\n\r\3\r\3\r\3\r\3\r\7\r\u0122\n\r\f\r\16\r\u0125\13\r\3\16"+ - "\3\16\5\16\u0129\n\16\3\16\5\16\u012c\n\16\3\16\3\16\5\16\u0130\n\16\3"+ - "\17\3\17\3\20\3\20\3\20\3\20\3\20\5\20\u0139\n\20\3\20\3\20\3\20\3\20"+ - "\3\20\7\20\u0140\n\20\f\20\16\20\u0143\13\20\5\20\u0145\n\20\3\21\3\21"+ - "\3\21\3\21\3\21\5\21\u014c\n\21\3\21\3\21\3\21\3\21\3\21\5\21\u0153\n"+ - "\21\5\21\u0155\n\21\3\22\3\22\3\22\3\22\3\22\5\22\u015c\n\22\3\22\3\22"+ - "\3\22\5\22\u0161\n\22\3\22\3\22\3\22\3\22\3\22\5\22\u0168\n\22\3\23\3"+ - "\23\3\23\7\23\u016d\n\23\f\23\16\23\u0170\13\23\3\24\3\24\3\24\3\24\5"+ - "\24\u0176\n\24\3\25\3\25\3\25\7\25\u017b\n\25\f\25\16\25\u017e\13\25\3"+ - "\26\3\26\3\26\3\26\3\26\3\26\3\26\5\26\u0187\n\26\3\27\3\27\5\27\u018b"+ - "\n\27\3\27\3\27\3\27\3\27\3\27\3\27\7\27\u0193\n\27\f\27\16\27\u0196\13"+ - "\27\3\27\3\27\3\27\3\30\3\30\3\30\3\30\7\30\u019f\n\30\f\30\16\30\u01a2"+ - "\13\30\3\31\3\31\3\31\5\31\u01a7\n\31\3\31\3\31\5\31\u01ab\n\31\3\31\3"+ - "\31\5\31\u01af\n\31\3\31\3\31\3\31\3\32\3\32\3\32\3\32\7\32\u01b8\n\32"+ - "\f\32\16\32\u01bb\13\32\3\33\3\33\3\33\5\33\u01c0\n\33\3\33\3\33\3\33"+ - "\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\7\35\u01cd\n\35\f\35\16\35\u01d0"+ - "\13\35\3\36\3\36\3\36\5\36\u01d5\n\36\3\36\3\36\5\36\u01d9\n\36\3\36\3"+ - "\36\5\36\u01dd\n\36\3\37\3\37\3\37\3\37\3\37\5\37\u01e4\n\37\3\37\3\37"+ - "\3\37\7\37\u01e9\n\37\f\37\16\37\u01ec\13\37\3 \3 \3 \5 \u01f1\n \3 \3"+ - " \3 \5 \u01f6\n \5 \u01f8\n \3 \3 \5 \u01fc\n \3!\3!\3!\3\"\3\"\5\"\u0203"+ - "\n\"\3\"\3\"\3\"\7\"\u0208\n\"\f\"\16\"\u020b\13\"\3\"\3\"\3\"\3#\3#\3"+ - "#\5#\u0213\n#\3#\3#\3#\3$\3$\3$\3$\3$\6$\u021d\n$\r$\16$\u021e\3$\3$\3"+ - "$\3$\3%\3%\6%\u0227\n%\r%\16%\u0228\3%\3%\3%\3&\3&\3&\3&\3&\6&\u0233\n"+ - "&\r&\16&\u0234\3&\3&\5&\u0239\n&\3&\3&\3&\3\'\3\'\3\'\3\'\5\'\u0242\n"+ - "\'\3\'\3\'\3\'\7\'\u0247\n\'\f\'\16\'\u024a\13\'\3\'\3\'\3\'\3(\3(\3("+ - "\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\6)\u025d\n)\r)\16)\u025e\3*\3*\3*\5"+ - "*\u0264\n*\3*\3*\3*\5*\u0269\n*\7*\u026b\n*\f*\16*\u026e\13*\3*\3*\3*"+ - "\3*\3+\3+\3+\7+\u0277\n+\f+\16+\u027a\13+\3,\3,\3,\7,\u027f\n,\f,\16,"+ - "\u0282\13,\3-\5-\u0285\n-\3-\3-\3.\3.\3.\5.\u028c\n.\3/\3/\3/\7/\u0291"+ - "\n/\f/\16/\u0294\13/\3\60\3\60\3\60\5\60\u0299\n\60\3\61\3\61\3\61\7\61"+ - "\u029e\n\61\f\61\16\61\u02a1\13\61\3\62\3\62\3\62\7\62\u02a6\n\62\f\62"+ - "\16\62\u02a9\13\62\3\63\3\63\3\63\3\63\5\63\u02af\n\63\3\64\3\64\3\64"+ - "\3\64\5\64\u02b5\n\64\3\65\3\65\3\65\3\65\5\65\u02bb\n\65\3\66\3\66\3"+ - "\66\3\66\5\66\u02c1\n\66\3\67\3\67\3\67\3\67\3\67\7\67\u02c8\n\67\f\67"+ - "\16\67\u02cb\13\67\38\78\u02ce\n8\f8\168\u02d1\138\38\38\39\39\39\79\u02d8"+ - "\n9\f9\169\u02db\139\3:\3:\3:\3:\3:\3:\7:\u02e3\n:\f:\16:\u02e6\13:\3"+ - ";\3;\3;\3;\3;\3;\3<\3<\3<\3=\3=\3=\3=\3>\3>\3>\3>\3>\3>\3>\3>\5>\u02fd"+ - "\n>\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\5?\u030b\n?\3@\3@\3@\3A\3A\5A"+ - "\u0312\nA\3A\3A\3B\3B\3C\3C\3C\3C\3C\3D\3D\3D\3D\3D\3E\3E\3E\3F\3F\3F"+ - "\5F\u0328\nF\7F\u032a\nF\fF\16F\u032d\13F\3F\3F\3G\3G\5G\u0333\nG\3H\3"+ - "H\5H\u0337\nH\3I\3I\3I\3I\3J\3J\3J\5J\u0340\nJ\3J\3J\3J\5J\u0345\nJ\3"+ - "J\3J\3J\3J\3K\3K\3K\3K\3K\3K\5K\u0351\nK\5K\u0353\nK\3L\3L\3L\3L\7L\u0359"+ - "\nL\fL\16L\u035c\13L\5L\u035e\nL\3L\3L\3L\3L\3L\5L\u0365\nL\3M\3M\3M\5"+ - "M\u036a\nM\3N\3N\3O\3O\3P\3P\3Q\3Q\3R\3R\3S\3S\3T\3T\3U\3U\3V\3V\3W\3"+ - "W\3X\3X\3Y\3Y\3Z\3Z\3[\3[\3\\\3\\\3]\3]\3]\3]\3]\3]\3]\3]\3]\3]\3]\3]"+ - "\3]\3]\5]\u0398\n]\3^\3^\5^\u039c\n^\3_\3_\3_\5_\u03a1\n_\3`\3`\5`\u03a5"+ - "\n`\3a\3a\5a\u03a9\na\3a\3a\3a\3b\3b\5b\u03b0\nb\3b\3b\3c\3c\3d\3d\3e"+ - "\3e\3e\2\2f\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&(*,.\60\62\64\66"+ - "8:<>@BDFHJLNPRTVXZ\\^`bdfhjlnprtvxz|~\u0080\u0082\u0084\u0086\u0088\u008a"+ - "\u008c\u008e\u0090\u0092\u0094\u0096\u0098\u009a\u009c\u009e\u00a0\u00a2"+ - "\u00a4\u00a6\u00a8\u00aa\u00ac\u00ae\u00b0\u00b2\u00b4\u00b6\u00b8\u00ba"+ - "\u00bc\u00be\u00c0\u00c2\u00c4\u00c6\u00c8\2\13\3\2\t\n\3\2de\3\2\r\26"+ - "\4\2\6\6$.\3\2\60\61\4\2##\62\64\4\2>?yy\4\2\f\f{{\3\2Oy\2\u03e3\2\u00ca"+ - "\3\2\2\2\4\u00d2\3\2\2\2\6\u00d8\3\2\2\2\b\u00db\3\2\2\2\n\u00ec\3\2\2"+ - "\2\f\u00fb\3\2\2\2\16\u00fd\3\2\2\2\20\u0105\3\2\2\2\22\u0107\3\2\2\2"+ - "\24\u010c\3\2\2\2\26\u0110\3\2\2\2\30\u0116\3\2\2\2\32\u012b\3\2\2\2\34"+ - "\u0131\3\2\2\2\36\u0133\3\2\2\2 \u0146\3\2\2\2\"\u0156\3\2\2\2$\u0169"+ - "\3\2\2\2&\u0171\3\2\2\2(\u0177\3\2\2\2*\u0186\3\2\2\2,\u018a\3\2\2\2."+ - "\u019a\3\2\2\2\60\u01a3\3\2\2\2\62\u01b3\3\2\2\2\64\u01bc\3\2\2\2\66\u01c4"+ - "\3\2\2\28\u01c7\3\2\2\2:\u01d1\3\2\2\2<\u01e3\3\2\2\2>\u01ed\3\2\2\2@"+ - "\u01fd\3\2\2\2B\u0202\3\2\2\2D\u020f\3\2\2\2F\u0217\3\2\2\2H\u0226\3\2"+ - "\2\2J\u022d\3\2\2\2L\u023d\3\2\2\2N\u024e\3\2\2\2P\u0257\3\2\2\2R\u0260"+ - "\3\2\2\2T\u0273\3\2\2\2V\u027b\3\2\2\2X\u0284\3\2\2\2Z\u0288\3\2\2\2\\"+ - "\u028d\3\2\2\2^\u0295\3\2\2\2`\u029a\3\2\2\2b\u02a2\3\2\2\2d\u02aa\3\2"+ - "\2\2f\u02b0\3\2\2\2h\u02b6\3\2\2\2j\u02bc\3\2\2\2l\u02c2\3\2\2\2n\u02cf"+ - "\3\2\2\2p\u02d4\3\2\2\2r\u02dc\3\2\2\2t\u02e7\3\2\2\2v\u02ed\3\2\2\2x"+ - "\u02f0\3\2\2\2z\u02f4\3\2\2\2|\u030a\3\2\2\2~\u030c\3\2\2\2\u0080\u030f"+ - "\3\2\2\2\u0082\u0315\3\2\2\2\u0084\u0317\3\2\2\2\u0086\u031c\3\2\2\2\u0088"+ - "\u0321\3\2\2\2\u008a\u0324\3\2\2\2\u008c\u0332\3\2\2\2\u008e\u0336\3\2"+ - "\2\2\u0090\u0338\3\2\2\2\u0092\u033c\3\2\2\2\u0094\u0352\3\2\2\2\u0096"+ - "\u0364\3\2\2\2\u0098\u0369\3\2\2\2\u009a\u036b\3\2\2\2\u009c\u036d\3\2"+ - "\2\2\u009e\u036f\3\2\2\2\u00a0\u0371\3\2\2\2\u00a2\u0373\3\2\2\2\u00a4"+ - "\u0375\3\2\2\2\u00a6\u0377\3\2\2\2\u00a8\u0379\3\2\2\2\u00aa\u037b\3\2"+ - "\2\2\u00ac\u037d\3\2\2\2\u00ae\u037f\3\2\2\2\u00b0\u0381\3\2\2\2\u00b2"+ - "\u0383\3\2\2\2\u00b4\u0385\3\2\2\2\u00b6\u0387\3\2\2\2\u00b8\u0397\3\2"+ - "\2\2\u00ba\u0399\3\2\2\2\u00bc\u03a0\3\2\2\2\u00be\u03a4\3\2\2\2\u00c0"+ - "\u03a8\3\2\2\2\u00c2\u03ad\3\2\2\2\u00c4\u03b3\3\2\2\2\u00c6\u03b5\3\2"+ - "\2\2\u00c8\u03b7\3\2\2\2\u00ca\u00cb\5\4\3\2\u00cb\u00cc\7\2\2\3\u00cc"+ - "\3\3\2\2\2\u00cd\u00ce\7x\2\2\u00ce\u00cf\7w\2\2\u00cf\u00d0\5\u00c6d"+ - "\2\u00d0\u00d1\7\3\2\2\u00d1\u00d3\3\2\2\2\u00d2\u00cd\3\2\2\2\u00d2\u00d3"+ - "\3\2\2\2\u00d3\u00d6\3\2\2\2\u00d4\u00d7\5\b\5\2\u00d5\u00d7\5\6\4\2\u00d6"+ - "\u00d4\3\2\2\2\u00d6\u00d5\3\2\2\2\u00d7\5\3\2\2\2\u00d8\u00d9\5\n\6\2"+ - "\u00d9\u00da\5(\25\2\u00da\7\3\2\2\2\u00db\u00dc\7\4\2\2\u00dc\u00dd\7"+ - "\5\2\2\u00dd\u00de\7\u0084\2\2\u00de\u00df\7\6\2\2\u00df\u00e0\5\u00c4"+ - "c\2\u00e0\u00e1\7\3\2\2\u00e1\u00e2\5\n\6\2\u00e2\t\3\2\2\2\u00e3\u00e7"+ - "\5\f\7\2\u00e4\u00e7\5\16\b\2\u00e5\u00e7\5\36\20\2\u00e6\u00e3\3\2\2"+ - "\2\u00e6\u00e4\3\2\2\2\u00e6\u00e5\3\2\2\2\u00e7\u00e8\3\2\2\2\u00e8\u00e9"+ - "\7\3\2\2\u00e9\u00eb\3\2\2\2\u00ea\u00e6\3\2\2\2\u00eb\u00ee\3\2\2\2\u00ec"+ - "\u00ea\3\2\2\2\u00ec\u00ed\3\2\2\2\u00ed\u00f4\3\2\2\2\u00ee\u00ec\3\2"+ - "\2\2\u00ef\u00f0\5\20\t\2\u00f0\u00f1\7\3\2\2\u00f1\u00f3\3\2\2\2\u00f2"+ - "\u00ef\3\2\2\2\u00f3\u00f6\3\2\2\2\u00f4\u00f2\3\2\2\2\u00f4\u00f5\3\2"+ - "\2\2\u00f5\13\3\2\2\2\u00f6\u00f4\3\2\2\2\u00f7\u00fc\5\22\n\2\u00f8\u00fc"+ - "\5\24\13\2\u00f9\u00fc\5\26\f\2\u00fa\u00fc\5\30\r\2\u00fb\u00f7\3\2\2"+ - "\2\u00fb\u00f8\3\2\2\2\u00fb\u00f9\3\2\2\2\u00fb\u00fa\3\2\2\2\u00fc\r"+ - "\3\2\2\2\u00fd\u00fe\7\7\2\2\u00fe\u00ff\7\5\2\2\u00ff\u0100\7\u0084\2"+ - "\2\u0100\u0101\7\6\2\2\u0101\u0102\5\u00c4c\2\u0102\17\3\2\2\2\u0103\u0106"+ - "\5\"\22\2\u0104\u0106\5 \21\2\u0105\u0103\3\2\2\2\u0105\u0104\3\2\2\2"+ - "\u0106\21\3\2\2\2\u0107\u0108\7\7\2\2\u0108\u0109\7j\2\2\u0109\u010a\7"+ - "c\2\2\u010a\u010b\5\u00c4c\2\u010b\23\3\2\2\2\u010c\u010d\7\7\2\2\u010d"+ - "\u010e\7\b\2\2\u010e\u010f\t\2\2\2\u010f\25\3\2\2\2\u0110\u0111\7\7\2"+ - "\2\u0111\u0112\7j\2\2\u0112\u0113\7T\2\2\u0113\u0114\7[\2\2\u0114\u0115"+ - "\t\3\2\2\u0115\27\3\2\2\2\u0116\u011b\7\7\2\2\u0117\u0118\7\13\2\2\u0118"+ - "\u011c\5\32\16\2\u0119\u011a\7j\2\2\u011a\u011c\7\13\2\2\u011b\u0117\3"+ - "\2\2\2\u011b\u0119\3\2\2\2\u011c\u0123\3\2\2\2\u011d\u011e\5\34\17\2\u011e"+ - "\u011f\7\6\2\2\u011f\u0120\5\u00c6d\2\u0120\u0122\3\2\2\2\u0121\u011d"+ - "\3\2\2\2\u0122\u0125\3\2\2\2\u0123\u0121\3\2\2\2\u0123\u0124\3\2\2\2\u0124"+ - "\31\3\2\2\2\u0125\u0123\3\2\2\2\u0126\u0129\7\u0084\2\2\u0127\u0129\5"+ - "\u00c8e\2\u0128\u0126\3\2\2\2\u0128\u0127\3\2\2\2\u0129\u012a\3\2\2\2"+ - "\u012a\u012c\7\f\2\2\u012b\u0128\3\2\2\2\u012b\u012c\3\2\2\2\u012c\u012f"+ - "\3\2\2\2\u012d\u0130\5\u00be`\2\u012e\u0130\5\u00c8e\2\u012f\u012d\3\2"+ - "\2\2\u012f\u012e\3\2\2\2\u0130\33\3\2\2\2\u0131\u0132\t\4\2\2\u0132\35"+ - "\3\2\2\2\u0133\u0134\7\27\2\2\u0134\u0138\7\4\2\2\u0135\u0136\7\5\2\2"+ - "\u0136\u0137\7\u0084\2\2\u0137\u0139\7\6\2\2\u0138\u0135\3\2\2\2\u0138"+ - "\u0139\3\2\2\2\u0139\u013a\3\2\2\2\u013a\u0144\5\u00c4c\2\u013b\u013c"+ - "\7Y\2\2\u013c\u0141\5\u00c4c\2\u013d\u013e\7\30\2\2\u013e\u0140\5\u00c4"+ - "c\2\u013f\u013d\3\2\2\2\u0140\u0143\3\2\2\2\u0141\u013f\3\2\2\2\u0141"+ - "\u0142\3\2\2\2\u0142\u0145\3\2\2\2\u0143\u0141\3\2\2\2\u0144\u013b\3\2"+ - "\2\2\u0144\u0145\3\2\2\2\u0145\37\3\2\2\2\u0146\u0147\7\7\2\2\u0147\u0148"+ - "\7\31\2\2\u0148\u014b\5~@\2\u0149\u014a\7X\2\2\u014a\u014c\5\u0094K\2"+ - "\u014b\u0149\3\2\2\2\u014b\u014c\3\2\2\2\u014c\u0154\3\2\2\2\u014d\u014e"+ - "\7\32\2\2\u014e\u0155\5*\26\2\u014f\u0152\7\33\2\2\u0150\u0151\7\32\2"+ - "\2\u0151\u0153\5*\26\2\u0152\u0150\3\2\2\2\u0152\u0153\3\2\2\2\u0153\u0155"+ - "\3\2\2\2\u0154\u014d\3\2\2\2\u0154\u014f\3\2\2\2\u0155!\3\2\2\2\u0156"+ - "\u0157\7\7\2\2\u0157\u0158\7\34\2\2\u0158\u0159\5\32\16\2\u0159\u015b"+ - "\7\35\2\2\u015a\u015c\5$\23\2\u015b\u015a\3\2\2\2\u015b\u015c\3\2\2\2"+ - "\u015c\u015d\3\2\2\2\u015d\u0160\7\36\2\2\u015e\u015f\7X\2\2\u015f\u0161"+ - "\5\u0094K\2\u0160\u015e\3\2\2\2\u0160\u0161\3\2\2\2\u0161\u0167\3\2\2"+ - "\2\u0162\u0163\7\37\2\2\u0163\u0164\5(\25\2\u0164\u0165\7 \2\2\u0165\u0168"+ - "\3\2\2\2\u0166\u0168\7\33\2\2\u0167\u0162\3\2\2\2\u0167\u0166\3\2\2\2"+ - "\u0168#\3\2\2\2\u0169\u016e\5&\24\2\u016a\u016b\7\30\2\2\u016b\u016d\5"+ - "&\24\2\u016c\u016a\3\2\2\2\u016d\u0170\3\2\2\2\u016e\u016c\3\2\2\2\u016e"+ - "\u016f\3\2\2\2\u016f%\3\2\2\2\u0170\u016e\3\2\2\2\u0171\u0172\7!\2\2\u0172"+ - "\u0175\5\32\16\2\u0173\u0174\7X\2\2\u0174\u0176\5\u0094K\2\u0175\u0173"+ - "\3\2\2\2\u0175\u0176\3\2\2\2\u0176\'\3\2\2\2\u0177\u017c\5*\26\2\u0178"+ - "\u0179\7\30\2\2\u0179\u017b\5*\26\2\u017a\u0178\3\2\2\2\u017b\u017e\3"+ - "\2\2\2\u017c\u017a\3\2\2\2\u017c\u017d\3\2\2\2\u017d)\3\2\2\2\u017e\u017c"+ - "\3\2\2\2\u017f\u0187\5,\27\2\u0180\u0187\5B\"\2\u0181\u0187\5F$\2\u0182"+ - "\u0187\5J&\2\u0183\u0187\5N(\2\u0184\u0187\5P)\2\u0185\u0187\5T+\2\u0186"+ - "\u017f\3\2\2\2\u0186\u0180\3\2\2\2\u0186\u0181\3\2\2\2\u0186\u0182\3\2"+ - "\2\2\u0186\u0183\3\2\2\2\u0186\u0184\3\2\2\2\u0186\u0185\3\2\2\2\u0187"+ - "+\3\2\2\2\u0188\u018b\5.\30\2\u0189\u018b\5\62\32\2\u018a\u0188\3\2\2"+ - "\2\u018a\u0189\3\2\2\2\u018b\u0194\3\2\2\2\u018c\u0193\5.\30\2\u018d\u0193"+ - "\5\66\34\2\u018e\u0193\5\62\32\2\u018f\u0193\58\35\2\u0190\u0193\5<\37"+ - "\2\u0191\u0193\5@!\2\u0192\u018c\3\2\2\2\u0192\u018d\3\2\2\2\u0192\u018e"+ - "\3\2\2\2\u0192\u018f\3\2\2\2\u0192\u0190\3\2\2\2\u0192\u0191\3\2\2\2\u0193"+ - "\u0196\3\2\2\2\u0194\u0192\3\2\2\2\u0194\u0195\3\2\2\2\u0195\u0197\3\2"+ - "\2\2\u0196\u0194\3\2\2\2\u0197\u0198\7U\2\2\u0198\u0199\5*\26\2\u0199"+ - "-\3\2\2\2\u019a\u019b\7O\2\2\u019b\u01a0\5\60\31\2\u019c\u019d\7\30\2"+ - "\2\u019d\u019f\5\60\31\2\u019e\u019c\3\2\2\2\u019f\u01a2\3\2\2\2\u01a0"+ - "\u019e\3\2\2\2\u01a0\u01a1\3\2\2\2\u01a1/\3\2\2\2\u01a2\u01a0\3\2\2\2"+ - "\u01a3\u01a6\5~@\2\u01a4\u01a5\7X\2\2\u01a5\u01a7\5\u0094K\2\u01a6\u01a4"+ - "\3\2\2\2\u01a6\u01a7\3\2\2\2\u01a7\u01aa\3\2\2\2\u01a8\u01a9\7Z\2\2\u01a9"+ - "\u01ab\7[\2\2\u01aa\u01a8\3\2\2\2\u01aa\u01ab\3\2\2\2\u01ab\u01ae\3\2"+ - "\2\2\u01ac\u01ad\7Y\2\2\u01ad\u01af\5~@\2\u01ae\u01ac\3\2\2\2\u01ae\u01af"+ - "\3\2\2\2\u01af\u01b0\3\2\2\2\u01b0\u01b1\7W\2\2\u01b1\u01b2\5*\26\2\u01b2"+ - "\61\3\2\2\2\u01b3\u01b4\7P\2\2\u01b4\u01b9\5\64\33\2\u01b5\u01b6\7\30"+ - "\2\2\u01b6\u01b8\5\64\33\2\u01b7\u01b5\3\2\2\2\u01b8\u01bb\3\2\2\2\u01b9"+ - "\u01b7\3\2\2\2\u01b9\u01ba\3\2\2\2\u01ba\63\3\2\2\2\u01bb\u01b9\3\2\2"+ - "\2\u01bc\u01bf\5~@\2\u01bd\u01be\7X\2\2\u01be\u01c0\5\u0094K\2\u01bf\u01bd"+ - "\3\2\2\2\u01bf\u01c0\3\2\2\2\u01c0\u01c1\3\2\2\2\u01c1\u01c2\7\32\2\2"+ - "\u01c2\u01c3\5*\26\2\u01c3\65\3\2\2\2\u01c4\u01c5\7Q\2\2\u01c5\u01c6\5"+ - "*\26\2\u01c6\67\3\2\2\2\u01c7\u01c8\7R\2\2\u01c8\u01c9\7S\2\2\u01c9\u01ce"+ - "\5:\36\2\u01ca\u01cb\7\30\2\2\u01cb\u01cd\5:\36\2\u01cc\u01ca\3\2\2\2"+ - "\u01cd\u01d0\3\2\2\2\u01ce\u01cc\3\2\2\2\u01ce\u01cf\3\2\2\2\u01cf9\3"+ - "\2\2\2\u01d0\u01ce\3\2\2\2\u01d1\u01d8\5~@\2\u01d2\u01d3\7X\2\2\u01d3"+ - "\u01d5\5\u0094K\2\u01d4\u01d2\3\2\2\2\u01d4\u01d5\3\2\2\2\u01d5\u01d6"+ - "\3\2\2\2\u01d6\u01d7\7\32\2\2\u01d7\u01d9\5*\26\2\u01d8\u01d4\3\2\2\2"+ - "\u01d8\u01d9\3\2\2\2\u01d9\u01dc\3\2\2\2\u01da\u01db\7c\2\2\u01db\u01dd"+ - "\5\u00c4c\2\u01dc\u01da\3\2\2\2\u01dc\u01dd\3\2\2\2\u01dd;\3\2\2\2\u01de"+ - "\u01df\7T\2\2\u01df\u01e4\7S\2\2\u01e0\u01e1\7]\2\2\u01e1\u01e2\7T\2\2"+ - "\u01e2\u01e4\7S\2\2\u01e3\u01de\3\2\2\2\u01e3\u01e0\3\2\2\2\u01e4\u01e5"+ - "\3\2\2\2\u01e5\u01ea\5> \2\u01e6\u01e7\7\30\2\2\u01e7\u01e9\5> \2\u01e8"+ - "\u01e6\3\2\2\2\u01e9\u01ec\3\2\2\2\u01ea\u01e8\3\2\2\2\u01ea\u01eb\3\2"+ - "\2\2\u01eb=\3\2\2\2\u01ec\u01ea\3\2\2\2\u01ed\u01f0\5*\26\2\u01ee\u01f1"+ - "\7^\2\2\u01ef\u01f1\7_\2\2\u01f0\u01ee\3\2\2\2\u01f0\u01ef\3\2\2\2\u01f0"+ - "\u01f1\3\2\2\2\u01f1\u01f7\3\2\2\2\u01f2\u01f5\7[\2\2\u01f3\u01f6\7d\2"+ - "\2\u01f4\u01f6\7e\2\2\u01f5\u01f3\3\2\2\2\u01f5\u01f4\3\2\2\2\u01f6\u01f8"+ - "\3\2\2\2\u01f7\u01f2\3\2\2\2\u01f7\u01f8\3\2\2\2\u01f8\u01fb\3\2\2\2\u01f9"+ - "\u01fa\7c\2\2\u01fa\u01fc\5\u00c4c\2\u01fb\u01f9\3\2\2\2\u01fb\u01fc\3"+ - "\2\2\2\u01fc?\3\2\2\2\u01fd\u01fe\7\\\2\2\u01fe\u01ff\5~@\2\u01ffA\3\2"+ - "\2\2\u0200\u0203\7`\2\2\u0201\u0203\7a\2\2\u0202\u0200\3\2\2\2\u0202\u0201"+ - "\3\2\2\2\u0203\u0204\3\2\2\2\u0204\u0209\5D#\2\u0205\u0206\7\30\2\2\u0206"+ - "\u0208\5D#\2\u0207\u0205\3\2\2\2\u0208\u020b\3\2\2\2\u0209\u0207\3\2\2"+ - "\2\u0209\u020a\3\2\2\2\u020a\u020c\3\2\2\2\u020b\u0209\3\2\2\2\u020c\u020d"+ - "\7b\2\2\u020d\u020e\5*\26\2\u020eC\3\2\2\2\u020f\u0212\5~@\2\u0210\u0211"+ - "\7X\2\2\u0211\u0213\5\u0094K\2\u0212\u0210\3\2\2\2\u0212\u0213\3\2\2\2"+ - "\u0213\u0214\3\2\2\2\u0214\u0215\7W\2\2\u0215\u0216\5*\26\2\u0216E\3\2"+ - "\2\2\u0217\u0218\7f\2\2\u0218\u0219\7\35\2\2\u0219\u021a\5(\25\2\u021a"+ - "\u021c\7\36\2\2\u021b\u021d\5H%\2\u021c\u021b\3\2\2\2\u021d\u021e\3\2"+ - "\2\2\u021e\u021c\3\2\2\2\u021e\u021f\3\2\2\2\u021f\u0220\3\2\2\2\u0220"+ - "\u0221\7j\2\2\u0221\u0222\7U\2\2\u0222\u0223\5*\26\2\u0223G\3\2\2\2\u0224"+ - "\u0225\7g\2\2\u0225\u0227\5*\26\2\u0226\u0224\3\2\2\2\u0227\u0228\3\2"+ - "\2\2\u0228\u0226\3\2\2\2\u0228\u0229\3\2\2\2\u0229\u022a\3\2\2\2\u022a"+ - "\u022b\7U\2\2\u022b\u022c\5*\26\2\u022cI\3\2\2\2\u022d\u022e\7m\2\2\u022e"+ - "\u022f\7\35\2\2\u022f\u0230\5(\25\2\u0230\u0232\7\36\2\2\u0231\u0233\5"+ - "L\'\2\u0232\u0231\3\2\2\2\u0233\u0234\3\2\2\2\u0234\u0232\3\2\2\2\u0234"+ - "\u0235\3\2\2\2\u0235\u0236\3\2\2\2\u0236\u0238\7j\2\2\u0237\u0239\5~@"+ - "\2\u0238\u0237\3\2\2\2\u0238\u0239\3\2\2\2\u0239\u023a\3\2\2\2\u023a\u023b"+ - "\7U\2\2\u023b\u023c\5*\26\2\u023cK\3\2\2\2\u023d\u0241\7g\2\2\u023e\u023f"+ - "\5~@\2\u023f\u0240\7X\2\2\u0240\u0242\3\2\2\2\u0241\u023e\3\2\2\2\u0241"+ - "\u0242\3\2\2\2\u0242\u0243\3\2\2\2\u0243\u0248\5\u0094K\2\u0244\u0245"+ - "\7\"\2\2\u0245\u0247\5\u0094K\2\u0246\u0244\3\2\2\2\u0247\u024a\3\2\2"+ - "\2\u0248\u0246\3\2\2\2\u0248\u0249\3\2\2\2\u0249\u024b\3\2\2\2\u024a\u0248"+ - "\3\2\2\2\u024b\u024c\7U\2\2\u024c\u024d\5*\26\2\u024dM\3\2\2\2\u024e\u024f"+ - "\7V\2\2\u024f\u0250\7\35\2\2\u0250\u0251\5(\25\2\u0251\u0252\7\36\2\2"+ - "\u0252\u0253\7k\2\2\u0253\u0254\5*\26\2\u0254\u0255\7l\2\2\u0255\u0256"+ - "\5*\26\2\u0256O\3\2\2\2\u0257\u0258\7h\2\2\u0258\u0259\7\37\2\2\u0259"+ - "\u025a\5(\25\2\u025a\u025c\7 \2\2\u025b\u025d\5R*\2\u025c\u025b\3\2\2"+ - "\2\u025d\u025e\3\2\2\2\u025e\u025c\3\2\2\2\u025e\u025f\3\2\2\2\u025fQ"+ - "\3\2\2\2\u0260\u0263\7i\2\2\u0261\u0264\7#\2\2\u0262\u0264\5\32\16\2\u0263"+ - "\u0261\3\2\2\2\u0263\u0262\3\2\2\2\u0264\u026c\3\2\2\2\u0265\u0268\7\""+ - "\2\2\u0266\u0269\7#\2\2\u0267\u0269\5\32\16\2\u0268\u0266\3\2\2\2\u0268"+ - "\u0267\3\2\2\2\u0269\u026b\3\2\2\2\u026a\u0265\3\2\2\2\u026b\u026e\3\2"+ - "\2\2\u026c\u026a\3\2\2\2\u026c\u026d\3\2\2\2\u026d\u026f\3\2\2\2\u026e"+ - "\u026c\3\2\2\2\u026f\u0270\7\37\2\2\u0270\u0271\5(\25\2\u0271\u0272\7"+ - " \2\2\u0272S\3\2\2\2\u0273\u0278\5V,\2\u0274\u0275\7n\2\2\u0275\u0277"+ - "\5V,\2\u0276\u0274\3\2\2\2\u0277\u027a\3\2\2\2\u0278\u0276\3\2\2\2\u0278"+ - "\u0279\3\2\2\2\u0279U\3\2\2\2\u027a\u0278\3\2\2\2\u027b\u0280\5X-\2\u027c"+ - "\u027d\7o\2\2\u027d\u027f\5X-\2\u027e\u027c\3\2\2\2\u027f\u0282\3\2\2"+ - "\2\u0280\u027e\3\2\2\2\u0280\u0281\3\2\2\2\u0281W\3\2\2\2\u0282\u0280"+ - "\3\2\2\2\u0283\u0285\7p\2\2\u0284\u0283\3\2\2\2\u0284\u0285\3\2\2\2\u0285"+ - "\u0286\3\2\2\2\u0286\u0287\5Z.\2\u0287Y\3\2\2\2\u0288\u028b\5\\/\2\u0289"+ - "\u028a\t\5\2\2\u028a\u028c\5\\/\2\u028b\u0289\3\2\2\2\u028b\u028c\3\2"+ - "\2\2\u028c[\3\2\2\2\u028d\u0292\5^\60\2\u028e\u028f\7/\2\2\u028f\u0291"+ - "\5^\60\2\u0290\u028e\3\2\2\2\u0291\u0294\3\2\2\2\u0292\u0290\3\2\2\2\u0292"+ - "\u0293\3\2\2\2\u0293]\3\2\2\2\u0294\u0292\3\2\2\2\u0295\u0298\5`\61\2"+ - "\u0296\u0297\7q\2\2\u0297\u0299\5`\61\2\u0298\u0296\3\2\2\2\u0298\u0299"+ - "\3\2\2\2\u0299_\3\2\2\2\u029a\u029f\5b\62\2\u029b\u029c\t\6\2\2\u029c"+ - "\u029e\5b\62\2\u029d\u029b\3\2\2\2\u029e\u02a1\3\2\2\2\u029f\u029d\3\2"+ - "\2\2\u029f\u02a0\3\2\2\2\u02a0a\3\2\2\2\u02a1\u029f\3\2\2\2\u02a2\u02a7"+ - "\5d\63\2\u02a3\u02a4\t\7\2\2\u02a4\u02a6\5d\63\2\u02a5\u02a3\3\2\2\2\u02a6"+ - "\u02a9\3\2\2\2\u02a7\u02a5\3\2\2\2\u02a7\u02a8\3\2\2\2\u02a8c\3\2\2\2"+ - "\u02a9\u02a7\3\2\2\2\u02aa\u02ae\5f\64\2\u02ab\u02ac\7r\2\2\u02ac\u02ad"+ - "\7s\2\2\u02ad\u02af\5\u0094K\2\u02ae\u02ab\3\2\2\2\u02ae\u02af\3\2\2\2"+ - "\u02afe\3\2\2\2\u02b0\u02b4\5h\65\2\u02b1\u02b2\7t\2\2\u02b2\u02b3\7X"+ - "\2\2\u02b3\u02b5\5\u0094K\2\u02b4\u02b1\3\2\2\2\u02b4\u02b5\3\2\2\2\u02b5"+ - "g\3\2\2\2\u02b6\u02ba\5j\66\2\u02b7\u02b8\7v\2\2\u02b8\u02b9\7X\2\2\u02b9"+ - "\u02bb\5\u00ba^\2\u02ba\u02b7\3\2\2\2\u02ba\u02bb\3\2\2\2\u02bbi\3\2\2"+ - "\2\u02bc\u02c0\5l\67\2\u02bd\u02be\7u\2\2\u02be\u02bf\7X\2\2\u02bf\u02c1"+ - "\5\u00ba^\2\u02c0\u02bd\3\2\2\2\u02c0\u02c1\3\2\2\2\u02c1k\3\2\2\2\u02c2"+ - "\u02c9\5n8\2\u02c3\u02c4\7\6\2\2\u02c4\u02c5\7-\2\2\u02c5\u02c6\3\2\2"+ - "\2\u02c6\u02c8\5\u0088E\2\u02c7\u02c3\3\2\2\2\u02c8\u02cb\3\2\2\2\u02c9"+ - "\u02c7\3\2\2\2\u02c9\u02ca\3\2\2\2\u02cam\3\2\2\2\u02cb\u02c9\3\2\2\2"+ - "\u02cc\u02ce\t\6\2\2\u02cd\u02cc\3\2\2\2\u02ce\u02d1\3\2\2\2\u02cf\u02cd"+ - "\3\2\2\2\u02cf\u02d0\3\2\2\2\u02d0\u02d2\3\2\2\2\u02d1\u02cf\3\2\2\2\u02d2"+ - "\u02d3\5p9\2\u02d3o\3\2\2\2\u02d4\u02d9\5r:\2\u02d5\u02d6\7\65\2\2\u02d6"+ - "\u02d8\5r:\2\u02d7\u02d5\3\2\2\2\u02d8\u02db\3\2\2\2\u02d9\u02d7\3\2\2"+ - "\2\u02d9\u02da\3\2\2\2\u02daq\3\2\2\2\u02db\u02d9\3\2\2\2\u02dc\u02e4"+ - "\5|?\2\u02dd\u02e3\5t;\2\u02de\u02e3\5x=\2\u02df\u02e3\5z>\2\u02e0\u02e3"+ - "\5v<\2\u02e1\u02e3\5\u008aF\2\u02e2\u02dd\3\2\2\2\u02e2\u02de\3\2\2\2"+ - "\u02e2\u02df\3\2\2\2\u02e2\u02e0\3\2\2\2\u02e2\u02e1\3\2\2\2\u02e3\u02e6"+ - "\3\2\2\2\u02e4\u02e2\3\2\2\2\u02e4\u02e5\3\2\2\2\u02e5s\3\2\2\2\u02e6"+ - "\u02e4\3\2\2\2\u02e7\u02e8\7\66\2\2\u02e8\u02e9\7\66\2\2\u02e9\u02ea\5"+ - "(\25\2\u02ea\u02eb\7\67\2\2\u02eb\u02ec\7\67\2\2\u02ecu\3\2\2\2\u02ed"+ - "\u02ee\7\66\2\2\u02ee\u02ef\7\67\2\2\u02efw\3\2\2\2\u02f0\u02f1\7\66\2"+ - "\2\u02f1\u02f2\5(\25\2\u02f2\u02f3\7\67\2\2\u02f3y\3\2\2\2\u02f4\u02fc"+ - "\78\2\2\u02f5\u02fd\5\u00c8e\2\u02f6\u02fd\5\u00c6d\2\u02f7\u02fd\7\u0084"+ - "\2\2\u02f8\u02fd\5\u0080A\2\u02f9\u02fd\5~@\2\u02fa\u02fd\5\u0082B\2\u02fb"+ - "\u02fd\5\u00b8]\2\u02fc\u02f5\3\2\2\2\u02fc\u02f6\3\2\2\2\u02fc\u02f7"+ - "\3\2\2\2\u02fc\u02f8\3\2\2\2\u02fc\u02f9\3\2\2\2\u02fc\u02fa\3\2\2\2\u02fc"+ - "\u02fb\3\2\2\2\u02fd{\3\2\2\2\u02fe\u030b\7|\2\2\u02ff\u030b\7}\2\2\u0300"+ - "\u030b\5\u00c6d\2\u0301\u030b\5~@\2\u0302\u030b\5\u0080A\2\u0303\u030b"+ - "\5\u0082B\2\u0304\u030b\5\u0096L\2\u0305\u030b\5\u0088E\2\u0306\u030b"+ - "\5\u0084C\2\u0307\u030b\5\u0086D\2\u0308\u030b\5\u00c2b\2\u0309\u030b"+ - "\5\u008eH\2\u030a\u02fe\3\2\2\2\u030a\u02ff\3\2\2\2\u030a\u0300\3\2\2"+ - "\2\u030a\u0301\3\2\2\2\u030a\u0302\3\2\2\2\u030a\u0303\3\2\2\2\u030a\u0304"+ - "\3\2\2\2\u030a\u0305\3\2\2\2\u030a\u0306\3\2\2\2\u030a\u0307\3\2\2\2\u030a"+ - "\u0308\3\2\2\2\u030a\u0309\3\2\2\2\u030b}\3\2\2\2\u030c\u030d\7!\2\2\u030d"+ - "\u030e\5\32\16\2\u030e\177\3\2\2\2\u030f\u0311\7\35\2\2\u0310\u0312\5"+ - "(\25\2\u0311\u0310\3\2\2\2\u0311\u0312\3\2\2\2\u0312\u0313\3\2\2\2\u0313"+ - "\u0314\7\36\2\2\u0314\u0081\3\2\2\2\u0315\u0316\79\2\2\u0316\u0083\3\2"+ - "\2\2\u0317\u0318\7\t\2\2\u0318\u0319\7\37\2\2\u0319\u031a\5(\25\2\u031a"+ - "\u031b\7 \2\2\u031b\u0085\3\2\2\2\u031c\u031d\7\n\2\2\u031d\u031e\7\37"+ - "\2\2\u031e\u031f\5(\25\2\u031f\u0320\7 \2\2\u0320\u0087\3\2\2\2\u0321"+ - "\u0322\5\32\16\2\u0322\u0323\5\u008aF\2\u0323\u0089\3\2\2\2\u0324\u032b"+ - "\7\35\2\2\u0325\u0327\5\u008cG\2\u0326\u0328\7\30\2\2\u0327\u0326\3\2"+ - "\2\2\u0327\u0328\3\2\2\2\u0328\u032a\3\2\2\2\u0329\u0325\3\2\2\2\u032a"+ - "\u032d\3\2\2\2\u032b\u0329\3\2\2\2\u032b\u032c\3\2\2\2\u032c\u032e\3\2"+ - "\2\2\u032d\u032b\3\2\2\2\u032e\u032f\7\36\2\2\u032f\u008b\3\2\2\2\u0330"+ - "\u0333\5*\26\2\u0331\u0333\7{\2\2\u0332\u0330\3\2\2\2\u0332\u0331\3\2"+ - "\2\2\u0333\u008d\3\2\2\2\u0334\u0337\5\u0090I\2\u0335\u0337\5\u0092J\2"+ - "\u0336\u0334\3\2\2\2\u0336\u0335\3\2\2\2\u0337\u008f\3\2\2\2\u0338\u0339"+ - "\5\32\16\2\u0339\u033a\7:\2\2\u033a\u033b\7}\2\2\u033b\u0091\3\2\2\2\u033c"+ - "\u033d\7\34\2\2\u033d\u033f\7\35\2\2\u033e\u0340\5$\23\2\u033f\u033e\3"+ - "\2\2\2\u033f\u0340\3\2\2\2\u0340\u0341\3\2\2\2\u0341\u0344\7\36\2\2\u0342"+ - "\u0343\7X\2\2\u0343\u0345\5\u0094K\2\u0344\u0342\3\2\2\2\u0344\u0345\3"+ - "\2\2\2\u0345\u0346\3\2\2\2\u0346\u0347\7\37\2\2\u0347\u0348\5(\25\2\u0348"+ - "\u0349\7 \2\2\u0349\u0093\3\2\2\2\u034a\u034b\7\35\2\2\u034b\u0353\7\36"+ - "\2\2\u034c\u0350\5\u0098M\2\u034d\u0351\7{\2\2\u034e\u0351\7#\2\2\u034f"+ - "\u0351\7\60\2\2\u0350\u034d\3\2\2\2\u0350\u034e\3\2\2\2\u0350\u034f\3"+ - "\2\2\2\u0350\u0351\3\2\2\2\u0351\u0353\3\2\2\2\u0352\u034a\3\2\2\2\u0352"+ - "\u034c\3\2\2\2\u0353\u0095\3\2\2\2\u0354\u035d\7\37\2\2\u0355\u035a\5"+ - "\u00c0a\2\u0356\u0357\7\30\2\2\u0357\u0359\5\u00c0a\2\u0358\u0356\3\2"+ - "\2\2\u0359\u035c\3\2\2\2\u035a\u0358\3\2\2\2\u035a\u035b\3\2\2\2\u035b"+ - "\u035e\3\2\2\2\u035c\u035a\3\2\2\2\u035d\u0355\3\2\2\2\u035d\u035e\3\2"+ - "\2\2\u035e\u035f\3\2\2\2\u035f\u0365\7 \2\2\u0360\u0361\7;\2\2\u0361\u0362"+ - "\5(\25\2\u0362\u0363\7<\2\2\u0363\u0365\3\2\2\2\u0364\u0354\3\2\2\2\u0364"+ - "\u0360\3\2\2\2\u0365\u0097\3\2\2\2\u0366\u036a\7=\2\2\u0367\u036a\5\u009a"+ - "N\2\u0368\u036a\5\u00bc_\2\u0369\u0366\3\2\2\2\u0369\u0367\3\2\2\2\u0369"+ - "\u0368\3\2\2\2\u036a\u0099\3\2\2\2\u036b\u036c\t\b\2\2\u036c\u009b\3\2"+ - "\2\2\u036d\u036e\7@\2\2\u036e\u009d\3\2\2\2\u036f\u0370\7A\2\2\u0370\u009f"+ - "\3\2\2\2\u0371\u0372\7B\2\2\u0372\u00a1\3\2\2\2\u0373\u0374\7C\2\2\u0374"+ - "\u00a3\3\2\2\2\u0375\u0376\7D\2\2\u0376\u00a5\3\2\2\2\u0377\u0378\7E\2"+ - "\2\u0378\u00a7\3\2\2\2\u0379\u037a\7F\2\2\u037a\u00a9\3\2\2\2\u037b\u037c"+ - "\7G\2\2\u037c\u00ab\3\2\2\2\u037d\u037e\7H\2\2\u037e\u00ad\3\2\2\2\u037f"+ - "\u0380\7I\2\2\u0380\u00af\3\2\2\2\u0381\u0382\7J\2\2\u0382\u00b1\3\2\2"+ - "\2\u0383\u0384\7K\2\2\u0384\u00b3\3\2\2\2\u0385\u0386\7L\2\2\u0386\u00b5"+ - "\3\2\2\2\u0387\u0388\7M\2\2\u0388\u00b7\3\2\2\2\u0389\u0398\5\u009cO\2"+ - "\u038a\u0398\5\u009eP\2\u038b\u0398\5\u00a0Q\2\u038c\u0398\5\u00a2R\2"+ - "\u038d\u0398\5\u00a4S\2\u038e\u0398\5\u00a6T\2\u038f\u0398\5\u00a8U\2"+ - "\u0390\u0398\5\u00aaV\2\u0391\u0398\5\u00b0Y\2\u0392\u0398\5\u00b2Z\2"+ - "\u0393\u0398\5\u00b4[\2\u0394\u0398\5\u00acW\2\u0395\u0398\5\u00aeX\2"+ - "\u0396\u0398\5\u00b6\\\2\u0397\u0389\3\2\2\2\u0397\u038a\3\2\2\2\u0397"+ - "\u038b\3\2\2\2\u0397\u038c\3\2\2\2\u0397\u038d\3\2\2\2\u0397\u038e\3\2"+ - "\2\2\u0397\u038f\3\2\2\2\u0397\u0390\3\2\2\2\u0397\u0391\3\2\2\2\u0397"+ - "\u0392\3\2\2\2\u0397\u0393\3\2\2\2\u0397\u0394\3\2\2\2\u0397\u0395\3\2"+ - "\2\2\u0397\u0396\3\2\2\2\u0398\u00b9\3\2\2\2\u0399\u039b\5\u00bc_\2\u039a"+ - "\u039c\7{\2\2\u039b\u039a\3\2\2\2\u039b\u039c\3\2\2\2\u039c\u00bb\3\2"+ - "\2\2\u039d\u03a1\7N\2\2\u039e\u03a1\5\u00b8]\2\u039f\u03a1\7|\2\2\u03a0"+ - "\u039d\3\2\2\2\u03a0\u039e\3\2\2\2\u03a0\u039f\3\2\2\2\u03a1\u00bd\3\2"+ - "\2\2\u03a2\u03a5\7\u0084\2\2\u03a3\u03a5\5\u00b8]\2\u03a4\u03a2\3\2\2"+ - "\2\u03a4\u03a3\3\2\2\2\u03a5\u00bf\3\2\2\2\u03a6\u03a9\5*\26\2\u03a7\u03a9"+ - "\7\u0084\2\2\u03a8\u03a6\3\2\2\2\u03a8\u03a7\3\2\2\2\u03a9\u03aa\3\2\2"+ - "\2\u03aa\u03ab\t\t\2\2\u03ab\u03ac\5*\26\2\u03ac\u00c1\3\2\2\2\u03ad\u03af"+ - "\7\66\2\2\u03ae\u03b0\5(\25\2\u03af\u03ae\3\2\2\2\u03af\u03b0\3\2\2\2"+ - "\u03b0\u03b1\3\2\2\2\u03b1\u03b2\7\67\2\2\u03b2\u00c3\3\2\2\2\u03b3\u03b4"+ - "\5\u00c6d\2\u03b4\u00c5\3\2\2\2\u03b5\u03b6\7z\2\2\u03b6\u00c7\3\2\2\2"+ - "\u03b7\u03b8\t\n\2\2\u03b8\u00c9\3\2\2\2a\u00d2\u00d6\u00e6\u00ec\u00f4"+ - "\u00fb\u0105\u011b\u0123\u0128\u012b\u012f\u0138\u0141\u0144\u014b\u0152"+ - "\u0154\u015b\u0160\u0167\u016e\u0175\u017c\u0186\u018a\u0192\u0194\u01a0"+ - "\u01a6\u01aa\u01ae\u01b9\u01bf\u01ce\u01d4\u01d8\u01dc\u01e3\u01ea\u01f0"+ - "\u01f5\u01f7\u01fb\u0202\u0209\u0212\u021e\u0228\u0234\u0238\u0241\u0248"+ - "\u025e\u0263\u0268\u026c\u0278\u0280\u0284\u028b\u0292\u0298\u029f\u02a7"+ - "\u02ae\u02b4\u02ba\u02c0\u02c9\u02cf\u02d9\u02e2\u02e4\u02fc\u030a\u0311"+ - "\u0327\u032b\u0332\u0336\u033f\u0344\u0350\u0352\u035a\u035d\u0364\u0369"+ - "\u0397\u039b\u03a0\u03a4\u03a8\u03af"; + "`\t`\4a\ta\4b\tb\4c\tc\4d\td\4e\te\4f\tf\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3"+ + "\3\5\3\u00d5\n\3\3\3\3\3\5\3\u00d9\n\3\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5"+ + "\3\5\3\5\3\5\3\6\3\6\3\6\5\6\u00e9\n\6\3\6\3\6\7\6\u00ed\n\6\f\6\16\6"+ + "\u00f0\13\6\3\6\3\6\3\6\7\6\u00f5\n\6\f\6\16\6\u00f8\13\6\3\7\3\7\3\7"+ + "\3\7\5\7\u00fe\n\7\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3\t\5\t\u0108\n\t\3\n\3"+ + "\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r"+ + "\3\r\3\r\5\r\u011e\n\r\3\r\3\r\3\r\3\r\7\r\u0124\n\r\f\r\16\r\u0127\13"+ + "\r\3\16\3\16\5\16\u012b\n\16\3\16\5\16\u012e\n\16\3\16\3\16\5\16\u0132"+ + "\n\16\3\17\3\17\3\20\3\20\3\20\3\20\3\20\5\20\u013b\n\20\3\20\3\20\3\20"+ + "\3\20\3\20\7\20\u0142\n\20\f\20\16\20\u0145\13\20\5\20\u0147\n\20\3\21"+ + "\3\21\3\21\3\21\3\21\5\21\u014e\n\21\3\21\3\21\3\21\3\21\3\21\5\21\u0155"+ + "\n\21\5\21\u0157\n\21\3\22\3\22\3\22\3\22\3\22\5\22\u015e\n\22\3\22\3"+ + "\22\3\22\5\22\u0163\n\22\3\22\3\22\3\22\3\22\3\22\5\22\u016a\n\22\3\23"+ + "\3\23\3\23\7\23\u016f\n\23\f\23\16\23\u0172\13\23\3\24\3\24\3\24\3\24"+ + "\5\24\u0178\n\24\3\25\3\25\3\25\7\25\u017d\n\25\f\25\16\25\u0180\13\25"+ + "\3\26\3\26\3\26\3\26\3\26\3\26\3\26\5\26\u0189\n\26\3\27\3\27\5\27\u018d"+ + "\n\27\3\27\3\27\3\27\3\27\3\27\3\27\7\27\u0195\n\27\f\27\16\27\u0198\13"+ + "\27\3\27\3\27\3\27\3\30\3\30\3\30\3\30\7\30\u01a1\n\30\f\30\16\30\u01a4"+ + "\13\30\3\31\3\31\3\31\5\31\u01a9\n\31\3\31\3\31\5\31\u01ad\n\31\3\31\3"+ + "\31\5\31\u01b1\n\31\3\31\3\31\3\31\3\32\3\32\3\32\3\32\7\32\u01ba\n\32"+ + "\f\32\16\32\u01bd\13\32\3\33\3\33\3\33\5\33\u01c2\n\33\3\33\3\33\3\33"+ + "\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\7\35\u01cf\n\35\f\35\16\35\u01d2"+ + "\13\35\3\36\3\36\3\36\5\36\u01d7\n\36\3\36\3\36\5\36\u01db\n\36\3\36\3"+ + "\36\5\36\u01df\n\36\3\37\3\37\3\37\3\37\3\37\5\37\u01e6\n\37\3\37\3\37"+ + "\3\37\7\37\u01eb\n\37\f\37\16\37\u01ee\13\37\3 \3 \3 \5 \u01f3\n \3 \3"+ + " \3 \5 \u01f8\n \5 \u01fa\n \3 \3 \5 \u01fe\n \3!\3!\3!\3\"\3\"\5\"\u0205"+ + "\n\"\3\"\3\"\3\"\7\"\u020a\n\"\f\"\16\"\u020d\13\"\3\"\3\"\3\"\3#\3#\3"+ + "#\5#\u0215\n#\3#\3#\3#\3$\3$\3$\3$\3$\6$\u021f\n$\r$\16$\u0220\3$\3$\3"+ + "$\3$\3%\3%\6%\u0229\n%\r%\16%\u022a\3%\3%\3%\3&\3&\3&\3&\3&\6&\u0235\n"+ + "&\r&\16&\u0236\3&\3&\5&\u023b\n&\3&\3&\3&\3\'\3\'\3\'\3\'\5\'\u0244\n"+ + "\'\3\'\3\'\3\'\7\'\u0249\n\'\f\'\16\'\u024c\13\'\3\'\3\'\3\'\3(\3(\3("+ + "\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\6)\u025f\n)\r)\16)\u0260\3*\3*\3*\5"+ + "*\u0266\n*\3*\3*\3*\5*\u026b\n*\7*\u026d\n*\f*\16*\u0270\13*\3*\3*\3*"+ + "\3*\3+\3+\3+\7+\u0279\n+\f+\16+\u027c\13+\3,\3,\3,\7,\u0281\n,\f,\16,"+ + "\u0284\13,\3-\5-\u0287\n-\3-\3-\3.\3.\3.\5.\u028e\n.\3/\3/\3/\7/\u0293"+ + "\n/\f/\16/\u0296\13/\3\60\3\60\3\60\5\60\u029b\n\60\3\61\3\61\3\61\7\61"+ + "\u02a0\n\61\f\61\16\61\u02a3\13\61\3\62\3\62\3\62\7\62\u02a8\n\62\f\62"+ + "\16\62\u02ab\13\62\3\63\3\63\3\63\3\63\5\63\u02b1\n\63\3\64\3\64\3\64"+ + "\3\64\5\64\u02b7\n\64\3\65\3\65\3\65\3\65\5\65\u02bd\n\65\3\66\3\66\3"+ + "\66\3\66\5\66\u02c3\n\66\3\67\3\67\3\67\3\67\5\67\u02c9\n\67\38\38\38"+ + "\38\38\78\u02d0\n8\f8\168\u02d3\138\39\79\u02d6\n9\f9\169\u02d9\139\3"+ + "9\39\3:\3:\3:\7:\u02e0\n:\f:\16:\u02e3\13:\3;\3;\3;\3;\3;\3;\7;\u02eb"+ + "\n;\f;\16;\u02ee\13;\3<\3<\3<\3<\3<\3<\3=\3=\3=\3>\3>\3>\3>\3?\3?\3?\3"+ + "?\3?\3?\3?\3?\5?\u0305\n?\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\5@\u0313"+ + "\n@\3A\3A\3A\3B\3B\5B\u031a\nB\3B\3B\3C\3C\3D\3D\3D\3D\3D\3E\3E\3E\3E"+ + "\3E\3F\3F\3F\3G\3G\3G\5G\u0330\nG\7G\u0332\nG\fG\16G\u0335\13G\3G\3G\3"+ + "H\3H\5H\u033b\nH\3I\3I\5I\u033f\nI\3J\3J\3J\3J\3K\3K\3K\5K\u0348\nK\3"+ + "K\3K\3K\5K\u034d\nK\3K\3K\3K\3K\3L\3L\3L\3L\3L\3L\5L\u0359\nL\5L\u035b"+ + "\nL\3M\3M\3M\3M\7M\u0361\nM\fM\16M\u0364\13M\5M\u0366\nM\3M\3M\3M\3M\3"+ + "M\5M\u036d\nM\3N\3N\3N\5N\u0372\nN\3O\3O\3P\3P\3Q\3Q\3R\3R\3S\3S\3T\3"+ + "T\3U\3U\3V\3V\3W\3W\3X\3X\3Y\3Y\3Z\3Z\3[\3[\3\\\3\\\3]\3]\3^\3^\3^\3^"+ + "\3^\3^\3^\3^\3^\3^\3^\3^\3^\3^\5^\u03a0\n^\3_\3_\5_\u03a4\n_\3`\3`\3`"+ + "\5`\u03a9\n`\3a\3a\5a\u03ad\na\3b\3b\5b\u03b1\nb\3b\3b\3b\3c\3c\5c\u03b8"+ + "\nc\3c\3c\3d\3d\3e\3e\3f\3f\3f\2\2g\2\4\6\b\n\f\16\20\22\24\26\30\32\34"+ + "\36 \"$&(*,.\60\62\64\668:<>@BDFHJLNPRTVXZ\\^`bdfhjlnprtvxz|~\u0080\u0082"+ + "\u0084\u0086\u0088\u008a\u008c\u008e\u0090\u0092\u0094\u0096\u0098\u009a"+ + "\u009c\u009e\u00a0\u00a2\u00a4\u00a6\u00a8\u00aa\u00ac\u00ae\u00b0\u00b2"+ + "\u00b4\u00b6\u00b8\u00ba\u00bc\u00be\u00c0\u00c2\u00c4\u00c6\u00c8\u00ca"+ + "\2\13\3\2\t\n\3\2de\3\2\r\26\4\2\6\6$.\3\2\60\61\4\2##\62\64\4\2>?yy\4"+ + "\2\f\f{{\3\2Oy\2\u03eb\2\u00cc\3\2\2\2\4\u00d4\3\2\2\2\6\u00da\3\2\2\2"+ + "\b\u00dd\3\2\2\2\n\u00ee\3\2\2\2\f\u00fd\3\2\2\2\16\u00ff\3\2\2\2\20\u0107"+ + "\3\2\2\2\22\u0109\3\2\2\2\24\u010e\3\2\2\2\26\u0112\3\2\2\2\30\u0118\3"+ + "\2\2\2\32\u012d\3\2\2\2\34\u0133\3\2\2\2\36\u0135\3\2\2\2 \u0148\3\2\2"+ + "\2\"\u0158\3\2\2\2$\u016b\3\2\2\2&\u0173\3\2\2\2(\u0179\3\2\2\2*\u0188"+ + "\3\2\2\2,\u018c\3\2\2\2.\u019c\3\2\2\2\60\u01a5\3\2\2\2\62\u01b5\3\2\2"+ + "\2\64\u01be\3\2\2\2\66\u01c6\3\2\2\28\u01c9\3\2\2\2:\u01d3\3\2\2\2<\u01e5"+ + "\3\2\2\2>\u01ef\3\2\2\2@\u01ff\3\2\2\2B\u0204\3\2\2\2D\u0211\3\2\2\2F"+ + "\u0219\3\2\2\2H\u0228\3\2\2\2J\u022f\3\2\2\2L\u023f\3\2\2\2N\u0250\3\2"+ + "\2\2P\u0259\3\2\2\2R\u0262\3\2\2\2T\u0275\3\2\2\2V\u027d\3\2\2\2X\u0286"+ + "\3\2\2\2Z\u028a\3\2\2\2\\\u028f\3\2\2\2^\u0297\3\2\2\2`\u029c\3\2\2\2"+ + "b\u02a4\3\2\2\2d\u02ac\3\2\2\2f\u02b2\3\2\2\2h\u02b8\3\2\2\2j\u02be\3"+ + "\2\2\2l\u02c4\3\2\2\2n\u02ca\3\2\2\2p\u02d7\3\2\2\2r\u02dc\3\2\2\2t\u02e4"+ + "\3\2\2\2v\u02ef\3\2\2\2x\u02f5\3\2\2\2z\u02f8\3\2\2\2|\u02fc\3\2\2\2~"+ + "\u0312\3\2\2\2\u0080\u0314\3\2\2\2\u0082\u0317\3\2\2\2\u0084\u031d\3\2"+ + "\2\2\u0086\u031f\3\2\2\2\u0088\u0324\3\2\2\2\u008a\u0329\3\2\2\2\u008c"+ + "\u032c\3\2\2\2\u008e\u033a\3\2\2\2\u0090\u033e\3\2\2\2\u0092\u0340\3\2"+ + "\2\2\u0094\u0344\3\2\2\2\u0096\u035a\3\2\2\2\u0098\u036c\3\2\2\2\u009a"+ + "\u0371\3\2\2\2\u009c\u0373\3\2\2\2\u009e\u0375\3\2\2\2\u00a0\u0377\3\2"+ + "\2\2\u00a2\u0379\3\2\2\2\u00a4\u037b\3\2\2\2\u00a6\u037d\3\2\2\2\u00a8"+ + "\u037f\3\2\2\2\u00aa\u0381\3\2\2\2\u00ac\u0383\3\2\2\2\u00ae\u0385\3\2"+ + "\2\2\u00b0\u0387\3\2\2\2\u00b2\u0389\3\2\2\2\u00b4\u038b\3\2\2\2\u00b6"+ + "\u038d\3\2\2\2\u00b8\u038f\3\2\2\2\u00ba\u039f\3\2\2\2\u00bc\u03a1\3\2"+ + "\2\2\u00be\u03a8\3\2\2\2\u00c0\u03ac\3\2\2\2\u00c2\u03b0\3\2\2\2\u00c4"+ + "\u03b5\3\2\2\2\u00c6\u03bb\3\2\2\2\u00c8\u03bd\3\2\2\2\u00ca\u03bf\3\2"+ + "\2\2\u00cc\u00cd\5\4\3\2\u00cd\u00ce\7\2\2\3\u00ce\3\3\2\2\2\u00cf\u00d0"+ + "\7x\2\2\u00d0\u00d1\7w\2\2\u00d1\u00d2\5\u00c8e\2\u00d2\u00d3\7\3\2\2"+ + "\u00d3\u00d5\3\2\2\2\u00d4\u00cf\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5\u00d8"+ + "\3\2\2\2\u00d6\u00d9\5\b\5\2\u00d7\u00d9\5\6\4\2\u00d8\u00d6\3\2\2\2\u00d8"+ + "\u00d7\3\2\2\2\u00d9\5\3\2\2\2\u00da\u00db\5\n\6\2\u00db\u00dc\5(\25\2"+ + "\u00dc\7\3\2\2\2\u00dd\u00de\7\4\2\2\u00de\u00df\7\5\2\2\u00df\u00e0\7"+ + "\u0084\2\2\u00e0\u00e1\7\6\2\2\u00e1\u00e2\5\u00c6d\2\u00e2\u00e3\7\3"+ + "\2\2\u00e3\u00e4\5\n\6\2\u00e4\t\3\2\2\2\u00e5\u00e9\5\f\7\2\u00e6\u00e9"+ + "\5\16\b\2\u00e7\u00e9\5\36\20\2\u00e8\u00e5\3\2\2\2\u00e8\u00e6\3\2\2"+ + "\2\u00e8\u00e7\3\2\2\2\u00e9\u00ea\3\2\2\2\u00ea\u00eb\7\3\2\2\u00eb\u00ed"+ + "\3\2\2\2\u00ec\u00e8\3\2\2\2\u00ed\u00f0\3\2\2\2\u00ee\u00ec\3\2\2\2\u00ee"+ + "\u00ef\3\2\2\2\u00ef\u00f6\3\2\2\2\u00f0\u00ee\3\2\2\2\u00f1\u00f2\5\20"+ + "\t\2\u00f2\u00f3\7\3\2\2\u00f3\u00f5\3\2\2\2\u00f4\u00f1\3\2\2\2\u00f5"+ + "\u00f8\3\2\2\2\u00f6\u00f4\3\2\2\2\u00f6\u00f7\3\2\2\2\u00f7\13\3\2\2"+ + "\2\u00f8\u00f6\3\2\2\2\u00f9\u00fe\5\22\n\2\u00fa\u00fe\5\24\13\2\u00fb"+ + "\u00fe\5\26\f\2\u00fc\u00fe\5\30\r\2\u00fd\u00f9\3\2\2\2\u00fd\u00fa\3"+ + "\2\2\2\u00fd\u00fb\3\2\2\2\u00fd\u00fc\3\2\2\2\u00fe\r\3\2\2\2\u00ff\u0100"+ + "\7\7\2\2\u0100\u0101\7\5\2\2\u0101\u0102\7\u0084\2\2\u0102\u0103\7\6\2"+ + "\2\u0103\u0104\5\u00c6d\2\u0104\17\3\2\2\2\u0105\u0108\5\"\22\2\u0106"+ + "\u0108\5 \21\2\u0107\u0105\3\2\2\2\u0107\u0106\3\2\2\2\u0108\21\3\2\2"+ + "\2\u0109\u010a\7\7\2\2\u010a\u010b\7j\2\2\u010b\u010c\7c\2\2\u010c\u010d"+ + "\5\u00c6d\2\u010d\23\3\2\2\2\u010e\u010f\7\7\2\2\u010f\u0110\7\b\2\2\u0110"+ + "\u0111\t\2\2\2\u0111\25\3\2\2\2\u0112\u0113\7\7\2\2\u0113\u0114\7j\2\2"+ + "\u0114\u0115\7T\2\2\u0115\u0116\7[\2\2\u0116\u0117\t\3\2\2\u0117\27\3"+ + "\2\2\2\u0118\u011d\7\7\2\2\u0119\u011a\7\13\2\2\u011a\u011e\5\32\16\2"+ + "\u011b\u011c\7j\2\2\u011c\u011e\7\13\2\2\u011d\u0119\3\2\2\2\u011d\u011b"+ + "\3\2\2\2\u011e\u0125\3\2\2\2\u011f\u0120\5\34\17\2\u0120\u0121\7\6\2\2"+ + "\u0121\u0122\5\u00c8e\2\u0122\u0124\3\2\2\2\u0123\u011f\3\2\2\2\u0124"+ + "\u0127\3\2\2\2\u0125\u0123\3\2\2\2\u0125\u0126\3\2\2\2\u0126\31\3\2\2"+ + "\2\u0127\u0125\3\2\2\2\u0128\u012b\7\u0084\2\2\u0129\u012b\5\u00caf\2"+ + "\u012a\u0128\3\2\2\2\u012a\u0129\3\2\2\2\u012b\u012c\3\2\2\2\u012c\u012e"+ + "\7\f\2\2\u012d\u012a\3\2\2\2\u012d\u012e\3\2\2\2\u012e\u0131\3\2\2\2\u012f"+ + "\u0132\5\u00c0a\2\u0130\u0132\5\u00caf\2\u0131\u012f\3\2\2\2\u0131\u0130"+ + "\3\2\2\2\u0132\33\3\2\2\2\u0133\u0134\t\4\2\2\u0134\35\3\2\2\2\u0135\u0136"+ + "\7\27\2\2\u0136\u013a\7\4\2\2\u0137\u0138\7\5\2\2\u0138\u0139\7\u0084"+ + "\2\2\u0139\u013b\7\6\2\2\u013a\u0137\3\2\2\2\u013a\u013b\3\2\2\2\u013b"+ + "\u013c\3\2\2\2\u013c\u0146\5\u00c6d\2\u013d\u013e\7Y\2\2\u013e\u0143\5"+ + "\u00c6d\2\u013f\u0140\7\30\2\2\u0140\u0142\5\u00c6d\2\u0141\u013f\3\2"+ + "\2\2\u0142\u0145\3\2\2\2\u0143\u0141\3\2\2\2\u0143\u0144\3\2\2\2\u0144"+ + "\u0147\3\2\2\2\u0145\u0143\3\2\2\2\u0146\u013d\3\2\2\2\u0146\u0147\3\2"+ + "\2\2\u0147\37\3\2\2\2\u0148\u0149\7\7\2\2\u0149\u014a\7\31\2\2\u014a\u014d"+ + "\5\u0080A\2\u014b\u014c\7X\2\2\u014c\u014e\5\u0096L\2\u014d\u014b\3\2"+ + "\2\2\u014d\u014e\3\2\2\2\u014e\u0156\3\2\2\2\u014f\u0150\7\32\2\2\u0150"+ + "\u0157\5*\26\2\u0151\u0154\7\33\2\2\u0152\u0153\7\32\2\2\u0153\u0155\5"+ + "*\26\2\u0154\u0152\3\2\2\2\u0154\u0155\3\2\2\2\u0155\u0157\3\2\2\2\u0156"+ + "\u014f\3\2\2\2\u0156\u0151\3\2\2\2\u0157!\3\2\2\2\u0158\u0159\7\7\2\2"+ + "\u0159\u015a\7\34\2\2\u015a\u015b\5\32\16\2\u015b\u015d\7\35\2\2\u015c"+ + "\u015e\5$\23\2\u015d\u015c\3\2\2\2\u015d\u015e\3\2\2\2\u015e\u015f\3\2"+ + "\2\2\u015f\u0162\7\36\2\2\u0160\u0161\7X\2\2\u0161\u0163\5\u0096L\2\u0162"+ + "\u0160\3\2\2\2\u0162\u0163\3\2\2\2\u0163\u0169\3\2\2\2\u0164\u0165\7\37"+ + "\2\2\u0165\u0166\5(\25\2\u0166\u0167\7 \2\2\u0167\u016a\3\2\2\2\u0168"+ + "\u016a\7\33\2\2\u0169\u0164\3\2\2\2\u0169\u0168\3\2\2\2\u016a#\3\2\2\2"+ + "\u016b\u0170\5&\24\2\u016c\u016d\7\30\2\2\u016d\u016f\5&\24\2\u016e\u016c"+ + "\3\2\2\2\u016f\u0172\3\2\2\2\u0170\u016e\3\2\2\2\u0170\u0171\3\2\2\2\u0171"+ + "%\3\2\2\2\u0172\u0170\3\2\2\2\u0173\u0174\7!\2\2\u0174\u0177\5\32\16\2"+ + "\u0175\u0176\7X\2\2\u0176\u0178\5\u0096L\2\u0177\u0175\3\2\2\2\u0177\u0178"+ + "\3\2\2\2\u0178\'\3\2\2\2\u0179\u017e\5*\26\2\u017a\u017b\7\30\2\2\u017b"+ + "\u017d\5*\26\2\u017c\u017a\3\2\2\2\u017d\u0180\3\2\2\2\u017e\u017c\3\2"+ + "\2\2\u017e\u017f\3\2\2\2\u017f)\3\2\2\2\u0180\u017e\3\2\2\2\u0181\u0189"+ + "\5,\27\2\u0182\u0189\5B\"\2\u0183\u0189\5F$\2\u0184\u0189\5J&\2\u0185"+ + "\u0189\5N(\2\u0186\u0189\5P)\2\u0187\u0189\5T+\2\u0188\u0181\3\2\2\2\u0188"+ + "\u0182\3\2\2\2\u0188\u0183\3\2\2\2\u0188\u0184\3\2\2\2\u0188\u0185\3\2"+ + "\2\2\u0188\u0186\3\2\2\2\u0188\u0187\3\2\2\2\u0189+\3\2\2\2\u018a\u018d"+ + "\5.\30\2\u018b\u018d\5\62\32\2\u018c\u018a\3\2\2\2\u018c\u018b\3\2\2\2"+ + "\u018d\u0196\3\2\2\2\u018e\u0195\5.\30\2\u018f\u0195\5\66\34\2\u0190\u0195"+ + "\5\62\32\2\u0191\u0195\58\35\2\u0192\u0195\5<\37\2\u0193\u0195\5@!\2\u0194"+ + "\u018e\3\2\2\2\u0194\u018f\3\2\2\2\u0194\u0190\3\2\2\2\u0194\u0191\3\2"+ + "\2\2\u0194\u0192\3\2\2\2\u0194\u0193\3\2\2\2\u0195\u0198\3\2\2\2\u0196"+ + "\u0194\3\2\2\2\u0196\u0197\3\2\2\2\u0197\u0199\3\2\2\2\u0198\u0196\3\2"+ + "\2\2\u0199\u019a\7U\2\2\u019a\u019b\5*\26\2\u019b-\3\2\2\2\u019c\u019d"+ + "\7O\2\2\u019d\u01a2\5\60\31\2\u019e\u019f\7\30\2\2\u019f\u01a1\5\60\31"+ + "\2\u01a0\u019e\3\2\2\2\u01a1\u01a4\3\2\2\2\u01a2\u01a0\3\2\2\2\u01a2\u01a3"+ + "\3\2\2\2\u01a3/\3\2\2\2\u01a4\u01a2\3\2\2\2\u01a5\u01a8\5\u0080A\2\u01a6"+ + "\u01a7\7X\2\2\u01a7\u01a9\5\u0096L\2\u01a8\u01a6\3\2\2\2\u01a8\u01a9\3"+ + "\2\2\2\u01a9\u01ac\3\2\2\2\u01aa\u01ab\7Z\2\2\u01ab\u01ad\7[\2\2\u01ac"+ + "\u01aa\3\2\2\2\u01ac\u01ad\3\2\2\2\u01ad\u01b0\3\2\2\2\u01ae\u01af\7Y"+ + "\2\2\u01af\u01b1\5\u0080A\2\u01b0\u01ae\3\2\2\2\u01b0\u01b1\3\2\2\2\u01b1"+ + "\u01b2\3\2\2\2\u01b2\u01b3\7W\2\2\u01b3\u01b4\5*\26\2\u01b4\61\3\2\2\2"+ + "\u01b5\u01b6\7P\2\2\u01b6\u01bb\5\64\33\2\u01b7\u01b8\7\30\2\2\u01b8\u01ba"+ + "\5\64\33\2\u01b9\u01b7\3\2\2\2\u01ba\u01bd\3\2\2\2\u01bb\u01b9\3\2\2\2"+ + "\u01bb\u01bc\3\2\2\2\u01bc\63\3\2\2\2\u01bd\u01bb\3\2\2\2\u01be\u01c1"+ + "\5\u0080A\2\u01bf\u01c0\7X\2\2\u01c0\u01c2\5\u0096L\2\u01c1\u01bf\3\2"+ + "\2\2\u01c1\u01c2\3\2\2\2\u01c2\u01c3\3\2\2\2\u01c3\u01c4\7\32\2\2\u01c4"+ + "\u01c5\5*\26\2\u01c5\65\3\2\2\2\u01c6\u01c7\7Q\2\2\u01c7\u01c8\5*\26\2"+ + "\u01c8\67\3\2\2\2\u01c9\u01ca\7R\2\2\u01ca\u01cb\7S\2\2\u01cb\u01d0\5"+ + ":\36\2\u01cc\u01cd\7\30\2\2\u01cd\u01cf\5:\36\2\u01ce\u01cc\3\2\2\2\u01cf"+ + "\u01d2\3\2\2\2\u01d0\u01ce\3\2\2\2\u01d0\u01d1\3\2\2\2\u01d19\3\2\2\2"+ + "\u01d2\u01d0\3\2\2\2\u01d3\u01da\5\u0080A\2\u01d4\u01d5\7X\2\2\u01d5\u01d7"+ + "\5\u0096L\2\u01d6\u01d4\3\2\2\2\u01d6\u01d7\3\2\2\2\u01d7\u01d8\3\2\2"+ + "\2\u01d8\u01d9\7\32\2\2\u01d9\u01db\5*\26\2\u01da\u01d6\3\2\2\2\u01da"+ + "\u01db\3\2\2\2\u01db\u01de\3\2\2\2\u01dc\u01dd\7c\2\2\u01dd\u01df\5\u00c6"+ + "d\2\u01de\u01dc\3\2\2\2\u01de\u01df\3\2\2\2\u01df;\3\2\2\2\u01e0\u01e1"+ + "\7T\2\2\u01e1\u01e6\7S\2\2\u01e2\u01e3\7]\2\2\u01e3\u01e4\7T\2\2\u01e4"+ + "\u01e6\7S\2\2\u01e5\u01e0\3\2\2\2\u01e5\u01e2\3\2\2\2\u01e6\u01e7\3\2"+ + "\2\2\u01e7\u01ec\5> \2\u01e8\u01e9\7\30\2\2\u01e9\u01eb\5> \2\u01ea\u01e8"+ + "\3\2\2\2\u01eb\u01ee\3\2\2\2\u01ec\u01ea\3\2\2\2\u01ec\u01ed\3\2\2\2\u01ed"+ + "=\3\2\2\2\u01ee\u01ec\3\2\2\2\u01ef\u01f2\5*\26\2\u01f0\u01f3\7^\2\2\u01f1"+ + "\u01f3\7_\2\2\u01f2\u01f0\3\2\2\2\u01f2\u01f1\3\2\2\2\u01f2\u01f3\3\2"+ + "\2\2\u01f3\u01f9\3\2\2\2\u01f4\u01f7\7[\2\2\u01f5\u01f8\7d\2\2\u01f6\u01f8"+ + "\7e\2\2\u01f7\u01f5\3\2\2\2\u01f7\u01f6\3\2\2\2\u01f8\u01fa\3\2\2\2\u01f9"+ + "\u01f4\3\2\2\2\u01f9\u01fa\3\2\2\2\u01fa\u01fd\3\2\2\2\u01fb\u01fc\7c"+ + "\2\2\u01fc\u01fe\5\u00c6d\2\u01fd\u01fb\3\2\2\2\u01fd\u01fe\3\2\2\2\u01fe"+ + "?\3\2\2\2\u01ff\u0200\7\\\2\2\u0200\u0201\5\u0080A\2\u0201A\3\2\2\2\u0202"+ + "\u0205\7`\2\2\u0203\u0205\7a\2\2\u0204\u0202\3\2\2\2\u0204\u0203\3\2\2"+ + "\2\u0205\u0206\3\2\2\2\u0206\u020b\5D#\2\u0207\u0208\7\30\2\2\u0208\u020a"+ + "\5D#\2\u0209\u0207\3\2\2\2\u020a\u020d\3\2\2\2\u020b\u0209\3\2\2\2\u020b"+ + "\u020c\3\2\2\2\u020c\u020e\3\2\2\2\u020d\u020b\3\2\2\2\u020e\u020f\7b"+ + "\2\2\u020f\u0210\5*\26\2\u0210C\3\2\2\2\u0211\u0214\5\u0080A\2\u0212\u0213"+ + "\7X\2\2\u0213\u0215\5\u0096L\2\u0214\u0212\3\2\2\2\u0214\u0215\3\2\2\2"+ + "\u0215\u0216\3\2\2\2\u0216\u0217\7W\2\2\u0217\u0218\5*\26\2\u0218E\3\2"+ + "\2\2\u0219\u021a\7f\2\2\u021a\u021b\7\35\2\2\u021b\u021c\5(\25\2\u021c"+ + "\u021e\7\36\2\2\u021d\u021f\5H%\2\u021e\u021d\3\2\2\2\u021f\u0220\3\2"+ + "\2\2\u0220\u021e\3\2\2\2\u0220\u0221\3\2\2\2\u0221\u0222\3\2\2\2\u0222"+ + "\u0223\7j\2\2\u0223\u0224\7U\2\2\u0224\u0225\5*\26\2\u0225G\3\2\2\2\u0226"+ + "\u0227\7g\2\2\u0227\u0229\5*\26\2\u0228\u0226\3\2\2\2\u0229\u022a\3\2"+ + "\2\2\u022a\u0228\3\2\2\2\u022a\u022b\3\2\2\2\u022b\u022c\3\2\2\2\u022c"+ + "\u022d\7U\2\2\u022d\u022e\5*\26\2\u022eI\3\2\2\2\u022f\u0230\7m\2\2\u0230"+ + "\u0231\7\35\2\2\u0231\u0232\5(\25\2\u0232\u0234\7\36\2\2\u0233\u0235\5"+ + "L\'\2\u0234\u0233\3\2\2\2\u0235\u0236\3\2\2\2\u0236\u0234\3\2\2\2\u0236"+ + "\u0237\3\2\2\2\u0237\u0238\3\2\2\2\u0238\u023a\7j\2\2\u0239\u023b\5\u0080"+ + "A\2\u023a\u0239\3\2\2\2\u023a\u023b\3\2\2\2\u023b\u023c\3\2\2\2\u023c"+ + "\u023d\7U\2\2\u023d\u023e\5*\26\2\u023eK\3\2\2\2\u023f\u0243\7g\2\2\u0240"+ + "\u0241\5\u0080A\2\u0241\u0242\7X\2\2\u0242\u0244\3\2\2\2\u0243\u0240\3"+ + "\2\2\2\u0243\u0244\3\2\2\2\u0244\u0245\3\2\2\2\u0245\u024a\5\u0096L\2"+ + "\u0246\u0247\7\"\2\2\u0247\u0249\5\u0096L\2\u0248\u0246\3\2\2\2\u0249"+ + "\u024c\3\2\2\2\u024a\u0248\3\2\2\2\u024a\u024b\3\2\2\2\u024b\u024d\3\2"+ + "\2\2\u024c\u024a\3\2\2\2\u024d\u024e\7U\2\2\u024e\u024f\5*\26\2\u024f"+ + "M\3\2\2\2\u0250\u0251\7V\2\2\u0251\u0252\7\35\2\2\u0252\u0253\5(\25\2"+ + "\u0253\u0254\7\36\2\2\u0254\u0255\7k\2\2\u0255\u0256\5*\26\2\u0256\u0257"+ + "\7l\2\2\u0257\u0258\5*\26\2\u0258O\3\2\2\2\u0259\u025a\7h\2\2\u025a\u025b"+ + "\7\37\2\2\u025b\u025c\5(\25\2\u025c\u025e\7 \2\2\u025d\u025f\5R*\2\u025e"+ + "\u025d\3\2\2\2\u025f\u0260\3\2\2\2\u0260\u025e\3\2\2\2\u0260\u0261\3\2"+ + "\2\2\u0261Q\3\2\2\2\u0262\u0265\7i\2\2\u0263\u0266\7#\2\2\u0264\u0266"+ + "\5\32\16\2\u0265\u0263\3\2\2\2\u0265\u0264\3\2\2\2\u0266\u026e\3\2\2\2"+ + "\u0267\u026a\7\"\2\2\u0268\u026b\7#\2\2\u0269\u026b\5\32\16\2\u026a\u0268"+ + "\3\2\2\2\u026a\u0269\3\2\2\2\u026b\u026d\3\2\2\2\u026c\u0267\3\2\2\2\u026d"+ + "\u0270\3\2\2\2\u026e\u026c\3\2\2\2\u026e\u026f\3\2\2\2\u026f\u0271\3\2"+ + "\2\2\u0270\u026e\3\2\2\2\u0271\u0272\7\37\2\2\u0272\u0273\5(\25\2\u0273"+ + "\u0274\7 \2\2\u0274S\3\2\2\2\u0275\u027a\5V,\2\u0276\u0277\7n\2\2\u0277"+ + "\u0279\5V,\2\u0278\u0276\3\2\2\2\u0279\u027c\3\2\2\2\u027a\u0278\3\2\2"+ + "\2\u027a\u027b\3\2\2\2\u027bU\3\2\2\2\u027c\u027a\3\2\2\2\u027d\u0282"+ + "\5X-\2\u027e\u027f\7o\2\2\u027f\u0281\5X-\2\u0280\u027e\3\2\2\2\u0281"+ + "\u0284\3\2\2\2\u0282\u0280\3\2\2\2\u0282\u0283\3\2\2\2\u0283W\3\2\2\2"+ + "\u0284\u0282\3\2\2\2\u0285\u0287\7p\2\2\u0286\u0285\3\2\2\2\u0286\u0287"+ + "\3\2\2\2\u0287\u0288\3\2\2\2\u0288\u0289\5Z.\2\u0289Y\3\2\2\2\u028a\u028d"+ + "\5\\/\2\u028b\u028c\t\5\2\2\u028c\u028e\5\\/\2\u028d\u028b\3\2\2\2\u028d"+ + "\u028e\3\2\2\2\u028e[\3\2\2\2\u028f\u0294\5^\60\2\u0290\u0291\7/\2\2\u0291"+ + "\u0293\5^\60\2\u0292\u0290\3\2\2\2\u0293\u0296\3\2\2\2\u0294\u0292\3\2"+ + "\2\2\u0294\u0295\3\2\2\2\u0295]\3\2\2\2\u0296\u0294\3\2\2\2\u0297\u029a"+ + "\5`\61\2\u0298\u0299\7q\2\2\u0299\u029b\5`\61\2\u029a\u0298\3\2\2\2\u029a"+ + "\u029b\3\2\2\2\u029b_\3\2\2\2\u029c\u02a1\5b\62\2\u029d\u029e\t\6\2\2"+ + "\u029e\u02a0\5b\62\2\u029f\u029d\3\2\2\2\u02a0\u02a3\3\2\2\2\u02a1\u029f"+ + "\3\2\2\2\u02a1\u02a2\3\2\2\2\u02a2a\3\2\2\2\u02a3\u02a1\3\2\2\2\u02a4"+ + "\u02a9\5d\63\2\u02a5\u02a6\t\7\2\2\u02a6\u02a8\5d\63\2\u02a7\u02a5\3\2"+ + "\2\2\u02a8\u02ab\3\2\2\2\u02a9\u02a7\3\2\2\2\u02a9\u02aa\3\2\2\2\u02aa"+ + "c\3\2\2\2\u02ab\u02a9\3\2\2\2\u02ac\u02b0\5f\64\2\u02ad\u02ae\7r\2\2\u02ae"+ + "\u02af\7s\2\2\u02af\u02b1\5\u0096L\2\u02b0\u02ad\3\2\2\2\u02b0\u02b1\3"+ + "\2\2\2\u02b1e\3\2\2\2\u02b2\u02b6\5h\65\2\u02b3\u02b4\7\u0087\2\2\u02b4"+ + "\u02b5\7\u0088\2\2\u02b5\u02b7\5\u0096L\2\u02b6\u02b3\3\2\2\2\u02b6\u02b7"+ + "\3\2\2\2\u02b7g\3\2\2\2\u02b8\u02bc\5j\66\2\u02b9\u02ba\7t\2\2\u02ba\u02bb"+ + "\7X\2\2\u02bb\u02bd\5\u0096L\2\u02bc\u02b9\3\2\2\2\u02bc\u02bd\3\2\2\2"+ + "\u02bdi\3\2\2\2\u02be\u02c2\5l\67\2\u02bf\u02c0\7v\2\2\u02c0\u02c1\7X"+ + "\2\2\u02c1\u02c3\5\u00bc_\2\u02c2\u02bf\3\2\2\2\u02c2\u02c3\3\2\2\2\u02c3"+ + "k\3\2\2\2\u02c4\u02c8\5n8\2\u02c5\u02c6\7u\2\2\u02c6\u02c7\7X\2\2\u02c7"+ + "\u02c9\5\u00bc_\2\u02c8\u02c5\3\2\2\2\u02c8\u02c9\3\2\2\2\u02c9m\3\2\2"+ + "\2\u02ca\u02d1\5p9\2\u02cb\u02cc\7\6\2\2\u02cc\u02cd\7-\2\2\u02cd\u02ce"+ + "\3\2\2\2\u02ce\u02d0\5\u008aF\2\u02cf\u02cb\3\2\2\2\u02d0\u02d3\3\2\2"+ + "\2\u02d1\u02cf\3\2\2\2\u02d1\u02d2\3\2\2\2\u02d2o\3\2\2\2\u02d3\u02d1"+ + "\3\2\2\2\u02d4\u02d6\t\6\2\2\u02d5\u02d4\3\2\2\2\u02d6\u02d9\3\2\2\2\u02d7"+ + "\u02d5\3\2\2\2\u02d7\u02d8\3\2\2\2\u02d8\u02da\3\2\2\2\u02d9\u02d7\3\2"+ + "\2\2\u02da\u02db\5r:\2\u02dbq\3\2\2\2\u02dc\u02e1\5t;\2\u02dd\u02de\7"+ + "\65\2\2\u02de\u02e0\5t;\2\u02df\u02dd\3\2\2\2\u02e0\u02e3\3\2\2\2\u02e1"+ + "\u02df\3\2\2\2\u02e1\u02e2\3\2\2\2\u02e2s\3\2\2\2\u02e3\u02e1\3\2\2\2"+ + "\u02e4\u02ec\5~@\2\u02e5\u02eb\5v<\2\u02e6\u02eb\5z>\2\u02e7\u02eb\5|"+ + "?\2\u02e8\u02eb\5x=\2\u02e9\u02eb\5\u008cG\2\u02ea\u02e5\3\2\2\2\u02ea"+ + "\u02e6\3\2\2\2\u02ea\u02e7\3\2\2\2\u02ea\u02e8\3\2\2\2\u02ea\u02e9\3\2"+ + "\2\2\u02eb\u02ee\3\2\2\2\u02ec\u02ea\3\2\2\2\u02ec\u02ed\3\2\2\2\u02ed"+ + "u\3\2\2\2\u02ee\u02ec\3\2\2\2\u02ef\u02f0\7\66\2\2\u02f0\u02f1\7\66\2"+ + "\2\u02f1\u02f2\5(\25\2\u02f2\u02f3\7\67\2\2\u02f3\u02f4\7\67\2\2\u02f4"+ + "w\3\2\2\2\u02f5\u02f6\7\66\2\2\u02f6\u02f7\7\67\2\2\u02f7y\3\2\2\2\u02f8"+ + "\u02f9\7\66\2\2\u02f9\u02fa\5(\25\2\u02fa\u02fb\7\67\2\2\u02fb{\3\2\2"+ + "\2\u02fc\u0304\78\2\2\u02fd\u0305\5\u00caf\2\u02fe\u0305\5\u00c8e\2\u02ff"+ + "\u0305\7\u0084\2\2\u0300\u0305\5\u0082B\2\u0301\u0305\5\u0080A\2\u0302"+ + "\u0305\5\u0084C\2\u0303\u0305\5\u00ba^\2\u0304\u02fd\3\2\2\2\u0304\u02fe"+ + "\3\2\2\2\u0304\u02ff\3\2\2\2\u0304\u0300\3\2\2\2\u0304\u0301\3\2\2\2\u0304"+ + "\u0302\3\2\2\2\u0304\u0303\3\2\2\2\u0305}\3\2\2\2\u0306\u0313\7|\2\2\u0307"+ + "\u0313\7}\2\2\u0308\u0313\5\u00c8e\2\u0309\u0313\5\u0080A\2\u030a\u0313"+ + "\5\u0082B\2\u030b\u0313\5\u0084C\2\u030c\u0313\5\u0098M\2\u030d\u0313"+ + "\5\u008aF\2\u030e\u0313\5\u0086D\2\u030f\u0313\5\u0088E\2\u0310\u0313"+ + "\5\u00c4c\2\u0311\u0313\5\u0090I\2\u0312\u0306\3\2\2\2\u0312\u0307\3\2"+ + "\2\2\u0312\u0308\3\2\2\2\u0312\u0309\3\2\2\2\u0312\u030a\3\2\2\2\u0312"+ + "\u030b\3\2\2\2\u0312\u030c\3\2\2\2\u0312\u030d\3\2\2\2\u0312\u030e\3\2"+ + "\2\2\u0312\u030f\3\2\2\2\u0312\u0310\3\2\2\2\u0312\u0311\3\2\2\2\u0313"+ + "\177\3\2\2\2\u0314\u0315\7!\2\2\u0315\u0316\5\32\16\2\u0316\u0081\3\2"+ + "\2\2\u0317\u0319\7\35\2\2\u0318\u031a\5(\25\2\u0319\u0318\3\2\2\2\u0319"+ + "\u031a\3\2\2\2\u031a\u031b\3\2\2\2\u031b\u031c\7\36\2\2\u031c\u0083\3"+ + "\2\2\2\u031d\u031e\79\2\2\u031e\u0085\3\2\2\2\u031f\u0320\7\t\2\2\u0320"+ + "\u0321\7\37\2\2\u0321\u0322\5(\25\2\u0322\u0323\7 \2\2\u0323\u0087\3\2"+ + "\2\2\u0324\u0325\7\n\2\2\u0325\u0326\7\37\2\2\u0326\u0327\5(\25\2\u0327"+ + "\u0328\7 \2\2\u0328\u0089\3\2\2\2\u0329\u032a\5\32\16\2\u032a\u032b\5"+ + "\u008cG\2\u032b\u008b\3\2\2\2\u032c\u0333\7\35\2\2\u032d\u032f\5\u008e"+ + "H\2\u032e\u0330\7\30\2\2\u032f\u032e\3\2\2\2\u032f\u0330\3\2\2\2\u0330"+ + "\u0332\3\2\2\2\u0331\u032d\3\2\2\2\u0332\u0335\3\2\2\2\u0333\u0331\3\2"+ + "\2\2\u0333\u0334\3\2\2\2\u0334\u0336\3\2\2\2\u0335\u0333\3\2\2\2\u0336"+ + "\u0337\7\36\2\2\u0337\u008d\3\2\2\2\u0338\u033b\5*\26\2\u0339\u033b\7"+ + "{\2\2\u033a\u0338\3\2\2\2\u033a\u0339\3\2\2\2\u033b\u008f\3\2\2\2\u033c"+ + "\u033f\5\u0092J\2\u033d\u033f\5\u0094K\2\u033e\u033c\3\2\2\2\u033e\u033d"+ + "\3\2\2\2\u033f\u0091\3\2\2\2\u0340\u0341\5\32\16\2\u0341\u0342\7:\2\2"+ + "\u0342\u0343\7}\2\2\u0343\u0093\3\2\2\2\u0344\u0345\7\34\2\2\u0345\u0347"+ + "\7\35\2\2\u0346\u0348\5$\23\2\u0347\u0346\3\2\2\2\u0347\u0348\3\2\2\2"+ + "\u0348\u0349\3\2\2\2\u0349\u034c\7\36\2\2\u034a\u034b\7X\2\2\u034b\u034d"+ + "\5\u0096L\2\u034c\u034a\3\2\2\2\u034c\u034d\3\2\2\2\u034d\u034e\3\2\2"+ + "\2\u034e\u034f\7\37\2\2\u034f\u0350\5(\25\2\u0350\u0351\7 \2\2\u0351\u0095"+ + "\3\2\2\2\u0352\u0353\7\35\2\2\u0353\u035b\7\36\2\2\u0354\u0358\5\u009a"+ + "N\2\u0355\u0359\7{\2\2\u0356\u0359\7#\2\2\u0357\u0359\7\60\2\2\u0358\u0355"+ + "\3\2\2\2\u0358\u0356\3\2\2\2\u0358\u0357\3\2\2\2\u0358\u0359\3\2\2\2\u0359"+ + "\u035b\3\2\2\2\u035a\u0352\3\2\2\2\u035a\u0354\3\2\2\2\u035b\u0097\3\2"+ + "\2\2\u035c\u0365\7\37\2\2\u035d\u0362\5\u00c2b\2\u035e\u035f\7\30\2\2"+ + "\u035f\u0361\5\u00c2b\2\u0360\u035e\3\2\2\2\u0361\u0364\3\2\2\2\u0362"+ + "\u0360\3\2\2\2\u0362\u0363\3\2\2\2\u0363\u0366\3\2\2\2\u0364\u0362\3\2"+ + "\2\2\u0365\u035d\3\2\2\2\u0365\u0366\3\2\2\2\u0366\u0367\3\2\2\2\u0367"+ + "\u036d\7 \2\2\u0368\u0369\7;\2\2\u0369\u036a\5(\25\2\u036a\u036b\7<\2"+ + "\2\u036b\u036d\3\2\2\2\u036c\u035c\3\2\2\2\u036c\u0368\3\2\2\2\u036d\u0099"+ + "\3\2\2\2\u036e\u0372\7=\2\2\u036f\u0372\5\u009cO\2\u0370\u0372\5\u00be"+ + "`\2\u0371\u036e\3\2\2\2\u0371\u036f\3\2\2\2\u0371\u0370\3\2\2\2\u0372"+ + "\u009b\3\2\2\2\u0373\u0374\t\b\2\2\u0374\u009d\3\2\2\2\u0375\u0376\7@"+ + "\2\2\u0376\u009f\3\2\2\2\u0377\u0378\7A\2\2\u0378\u00a1\3\2\2\2\u0379"+ + "\u037a\7B\2\2\u037a\u00a3\3\2\2\2\u037b\u037c\7C\2\2\u037c\u00a5\3\2\2"+ + "\2\u037d\u037e\7D\2\2\u037e\u00a7\3\2\2\2\u037f\u0380\7E\2\2\u0380\u00a9"+ + "\3\2\2\2\u0381\u0382\7F\2\2\u0382\u00ab\3\2\2\2\u0383\u0384\7G\2\2\u0384"+ + "\u00ad\3\2\2\2\u0385\u0386\7H\2\2\u0386\u00af\3\2\2\2\u0387\u0388\7I\2"+ + "\2\u0388\u00b1\3\2\2\2\u0389\u038a\7J\2\2\u038a\u00b3\3\2\2\2\u038b\u038c"+ + "\7K\2\2\u038c\u00b5\3\2\2\2\u038d\u038e\7L\2\2\u038e\u00b7\3\2\2\2\u038f"+ + "\u0390\7M\2\2\u0390\u00b9\3\2\2\2\u0391\u03a0\5\u009eP\2\u0392\u03a0\5"+ + "\u00a0Q\2\u0393\u03a0\5\u00a2R\2\u0394\u03a0\5\u00a4S\2\u0395\u03a0\5"+ + "\u00a6T\2\u0396\u03a0\5\u00a8U\2\u0397\u03a0\5\u00aaV\2\u0398\u03a0\5"+ + "\u00acW\2\u0399\u03a0\5\u00b2Z\2\u039a\u03a0\5\u00b4[\2\u039b\u03a0\5"+ + "\u00b6\\\2\u039c\u03a0\5\u00aeX\2\u039d\u03a0\5\u00b0Y\2\u039e\u03a0\5"+ + "\u00b8]\2\u039f\u0391\3\2\2\2\u039f\u0392\3\2\2\2\u039f\u0393\3\2\2\2"+ + "\u039f\u0394\3\2\2\2\u039f\u0395\3\2\2\2\u039f\u0396\3\2\2\2\u039f\u0397"+ + "\3\2\2\2\u039f\u0398\3\2\2\2\u039f\u0399\3\2\2\2\u039f\u039a\3\2\2\2\u039f"+ + "\u039b\3\2\2\2\u039f\u039c\3\2\2\2\u039f\u039d\3\2\2\2\u039f\u039e\3\2"+ + "\2\2\u03a0\u00bb\3\2\2\2\u03a1\u03a3\5\u00be`\2\u03a2\u03a4\7{\2\2\u03a3"+ + "\u03a2\3\2\2\2\u03a3\u03a4\3\2\2\2\u03a4\u00bd\3\2\2\2\u03a5\u03a9\7N"+ + "\2\2\u03a6\u03a9\5\u00ba^\2\u03a7\u03a9\7|\2\2\u03a8\u03a5\3\2\2\2\u03a8"+ + "\u03a6\3\2\2\2\u03a8\u03a7\3\2\2\2\u03a9\u00bf\3\2\2\2\u03aa\u03ad\7\u0084"+ + "\2\2\u03ab\u03ad\5\u00ba^\2\u03ac\u03aa\3\2\2\2\u03ac\u03ab\3\2\2\2\u03ad"+ + "\u00c1\3\2\2\2\u03ae\u03b1\5*\26\2\u03af\u03b1\7\u0084\2\2\u03b0\u03ae"+ + "\3\2\2\2\u03b0\u03af\3\2\2\2\u03b1\u03b2\3\2\2\2\u03b2\u03b3\t\t\2\2\u03b3"+ + "\u03b4\5*\26\2\u03b4\u00c3\3\2\2\2\u03b5\u03b7\7\66\2\2\u03b6\u03b8\5"+ + "(\25\2\u03b7\u03b6\3\2\2\2\u03b7\u03b8\3\2\2\2\u03b8\u03b9\3\2\2\2\u03b9"+ + "\u03ba\7\67\2\2\u03ba\u00c5\3\2\2\2\u03bb\u03bc\5\u00c8e\2\u03bc\u00c7"+ + "\3\2\2\2\u03bd\u03be\7z\2\2\u03be\u00c9\3\2\2\2\u03bf\u03c0\t\n\2\2\u03c0"+ + "\u00cb\3\2\2\2b\u00d4\u00d8\u00e8\u00ee\u00f6\u00fd\u0107\u011d\u0125"+ + "\u012a\u012d\u0131\u013a\u0143\u0146\u014d\u0154\u0156\u015d\u0162\u0169"+ + "\u0170\u0177\u017e\u0188\u018c\u0194\u0196\u01a2\u01a8\u01ac\u01b0\u01bb"+ + "\u01c1\u01d0\u01d6\u01da\u01de\u01e5\u01ec\u01f2\u01f7\u01f9\u01fd\u0204"+ + "\u020b\u0214\u0220\u022a\u0236\u023a\u0243\u024a\u0260\u0265\u026a\u026e"+ + "\u027a\u0282\u0286\u028d\u0294\u029a\u02a1\u02a9\u02b0\u02b6\u02bc\u02c2"+ + "\u02c8\u02d1\u02d7\u02e1\u02ea\u02ec\u0304\u0312\u0319\u032f\u0333\u033a"+ + "\u033e\u0347\u034c\u0358\u035a\u0362\u0365\u036c\u0371\u039f\u03a3\u03a8"+ + "\u03ac\u03b0\u03b7"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/src/main/java/org/rumbledb/parser/JsoniqVisitor.java b/src/main/java/org/rumbledb/parser/JsoniqVisitor.java index ebf739af73..95a6a9ae2f 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqVisitor.java +++ b/src/main/java/org/rumbledb/parser/JsoniqVisitor.java @@ -313,6 +313,12 @@ public interface JsoniqVisitor extends ParseTreeVisitor { * @return the visitor result */ T visitInstanceOfExpr(JsoniqParser.InstanceOfExprContext ctx); + /** + * Visit a parse tree produced by {@link JsoniqParser#staticallyIsExpr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStaticallyIsExpr(JsoniqParser.StaticallyIsExprContext ctx); /** * Visit a parse tree produced by {@link JsoniqParser#treatExpr}. * @param ctx the parse tree diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 5b00c78f28..e0003eda86 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -63,61 +63,947 @@ private ItemType(String name, int index) { // resulting type of [row] + [col] private static ItemType addTable[][] = { - // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex any-uri base64 json-item object array function - /* item */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* atomic */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* string */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* integer */ { null, null, null, integerItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* decimal */ { null, null, null, decimalItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* double */ { null, null, null, doubleItem, doubleItem, doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* bool */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* null */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* duration */ { null, null, null, null, null, null, null, null, null, null, null, dateTimeItem, dateItem, null, null, null, null, null, null, null, null }, - /* y-m-dur */ { null, null, null, null, null, null, null, null, null, yearMonthDurationItem, null, dateTimeItem, dateItem, null, null, null, null, null, null, null, null }, - /* d-t-dur */ { null, null, null, null, null, null, null, null, null, null, dayTimeDurationItem,dateTimeItem, dateItem, timeItem, null, null, null, null, null, null, null }, - /* date-time*/ { null, null, null, null, null, null, null, null, dateTimeItem, dateTimeItem, dateTimeItem, null, null, null, null, null, null, null, null, null, null }, - /* date */ { null, null, null, null, null, null, null, null, dateItem, dateItem, dateItem, null, null, null, null, null, null, null, null, null, null }, - /* time */ { null, null, null, null, null, null, null, null, null, null, timeItem, null, null, null, null, null, null, null, null, null, null }, - /* hex */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* any-uri */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* base64 */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* json-item*/ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* object */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* array */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* function */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex + // any-uri base64 json-item object array function + /* item */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* atomic */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* string */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* integer */ { + null, + null, + null, + integerItem, + decimalItem, + doubleItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* decimal */ { + null, + null, + null, + decimalItem, + decimalItem, + doubleItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* double */ { + null, + null, + null, + doubleItem, + doubleItem, + doubleItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* bool */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* null */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* duration */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + dateTimeItem, + dateItem, + null, + null, + null, + null, + null, + null, + null, + null }, + /* y-m-dur */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + yearMonthDurationItem, + null, + dateTimeItem, + dateItem, + null, + null, + null, + null, + null, + null, + null, + null }, + /* d-t-dur */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + dayTimeDurationItem, + dateTimeItem, + dateItem, + timeItem, + null, + null, + null, + null, + null, + null, + null }, + /* date-time */ { + null, + null, + null, + null, + null, + null, + null, + null, + dateTimeItem, + dateTimeItem, + dateTimeItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* date */ { + null, + null, + null, + null, + null, + null, + null, + null, + dateItem, + dateItem, + dateItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* time */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + timeItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* hex */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* any-uri */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* base64 */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* json-item */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* object */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* array */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* function */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, }; // resulting type of [row] - [col] private static ItemType subTable[][] = { - // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex any-uri base64 json-item object array function - /* item */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* atomic */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* string */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* integer */ { null, null, null, integerItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* decimal */ { null, null, null, decimalItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* double */ { null, null, null, doubleItem, doubleItem, doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* bool */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* null */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* duration */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* y-m-dur */ { null, null, null, null, null, null, null, null, null, yearMonthDurationItem, null, null, null, null, null, null, null, null, null, null, null }, - /* d-t-dur */ { null, null, null, null, null, null, null, null, null, null, dayTimeDurationItem,null, null, null, null, null, null, null, null, null, null }, - /* date-time*/ { null, null, null, null, null, null, null, null, dateTimeItem, dateTimeItem, dateTimeItem, dayTimeDurationItem,null, null, null, null, null, null, null, null, null }, - /* date */ { null, null, null, null, null, null, null, null, dateItem, dateItem, dateItem, null, dayTimeDurationItem,null, null, null, null, null, null, null, null }, - /* time */ { null, null, null, null, null, null, null, null, null, null, timeItem, null, null, dayTimeDurationItem,null, null, null, null, null, null, null }, - /* hex */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* any-uri */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* base64 */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* json-item*/ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* object */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* array */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* function */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex + // any-uri base64 json-item object array function + /* item */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* atomic */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* string */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* integer */ { + null, + null, + null, + integerItem, + decimalItem, + doubleItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* decimal */ { + null, + null, + null, + decimalItem, + decimalItem, + doubleItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* double */ { + null, + null, + null, + doubleItem, + doubleItem, + doubleItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* bool */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* null */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* duration */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* y-m-dur */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + yearMonthDurationItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* d-t-dur */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + dayTimeDurationItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* date-time */ { + null, + null, + null, + null, + null, + null, + null, + null, + dateTimeItem, + dateTimeItem, + dateTimeItem, + dayTimeDurationItem, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* date */ { + null, + null, + null, + null, + null, + null, + null, + null, + dateItem, + dateItem, + dateItem, + null, + dayTimeDurationItem, + null, + null, + null, + null, + null, + null, + null, + null }, + /* time */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + timeItem, + null, + null, + dayTimeDurationItem, + null, + null, + null, + null, + null, + null, + null }, + /* hex */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* any-uri */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* base64 */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* json-item */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* object */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* array */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* function */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, }; public String getName() { return this.name; } - public int getIndex() { return this.index; } + public int getIndex() { + return this.index; + } public static ItemType getItemTypeByName(String name) { if (name.equals(objectItem.name)) { @@ -225,71 +1111,97 @@ public boolean isSubtypeOf(ItemType superType) { } return this.equals(superType); } - - public ItemType findCommonSuperType(ItemType other){ - if(other.isSubtypeOf(this)){ + + public ItemType findCommonSuperType(ItemType other) { + if (other.isSubtypeOf(this)) { return this; - } else if(this.isSubtypeOf(other)) { + } else if (this.isSubtypeOf(other)) { return other; - } else if(this.isSubtypeOf(durationItem) && other.isSubtypeOf(durationItem)){ + } else if (this.isSubtypeOf(durationItem) && other.isSubtypeOf(durationItem)) { return durationItem; - } else if(this.isSubtypeOf(atomicItem) && other.isSubtypeOf(atomicItem)){ + } else if (this.isSubtypeOf(atomicItem) && other.isSubtypeOf(atomicItem)) { return atomicItem; - } else if(this.isSubtypeOf(JSONItem) && other.isSubtypeOf(JSONItem)){ + } else if (this.isSubtypeOf(JSONItem) && other.isSubtypeOf(JSONItem)) { return JSONItem; } else { return item; } } - public boolean staticallyCastableAs(ItemType other){ + public boolean staticallyCastableAs(ItemType other) { // JSON items cannot be cast from and to, nor function items, nor we can cast to atomic or item - if(this.isSubtypeOf(JSONItem) || other.isSubtypeOf(JSONItem) || this.equals(functionItem) || other.equals(functionItem) || other.equals(atomicItem) || other.equals(item)) + if ( + this.isSubtypeOf(JSONItem) + || other.isSubtypeOf(JSONItem) + || this.equals(functionItem) + || other.equals(functionItem) + || other.equals(atomicItem) + || other.equals(item) + ) return false; // anything can be casted to itself - if(this.equals(other)) + if (this.equals(other)) return true; // anything can be casted from and to a string (or from one of its supertype) - if(this.equals(stringItem) || this.equals(item) || this.equals(atomicItem) || other.equals(stringItem)) + if (this.equals(stringItem) || this.equals(item) || this.equals(atomicItem) || other.equals(stringItem)) return true; // boolean and numeric can be cast between themselves - if(this.equals(booleanItem) || this.equals(integerItem) || this.equals(doubleItem) || this.equals(decimalItem)){ - if(other.equals(integerItem) || - other.equals(doubleItem) || - other.equals(decimalItem) || + if ( + this.equals(booleanItem) || this.equals(integerItem) || this.equals(doubleItem) || this.equals(decimalItem) + ) { + if ( + other.equals(integerItem) + || + other.equals(doubleItem) + || + other.equals(decimalItem) + || other.equals(booleanItem) - ) return true; - else return false; + ) + return true; + else + return false; } // base64 and hex can be cast between themselves - if(this.equals(base64BinaryItem) || this.equals(hexBinaryItem)){ - if(other.equals(base64BinaryItem) || + if (this.equals(base64BinaryItem) || this.equals(hexBinaryItem)) { + if ( + other.equals(base64BinaryItem) + || other.equals(hexBinaryItem) - ) return true; - else return false; + ) + return true; + else + return false; } // durations can be cast between themselves - if(this.isSubtypeOf(durationItem)){ - if(other.isSubtypeOf(durationItem)) return true; - else return false; + if (this.isSubtypeOf(durationItem)) { + if (other.isSubtypeOf(durationItem)) + return true; + else + return false; } // DateTime can be cast also to Date or Time - if(this.equals(dateTimeItem)){ - if(other.equals(dateItem) || other.equals(timeItem)) return true; - else return false; + if (this.equals(dateTimeItem)) { + if (other.equals(dateItem) || other.equals(timeItem)) + return true; + else + return false; } // Date can be cast also to DateTime - if(this.equals(dateItem)){ - if(other.equals(dateTimeItem)) return true; - else return false; + if (this.equals(dateItem)) { + if (other.equals(dateTimeItem)) + return true; + else + return false; } // Otherwise this cannot be casted to other return false; } - // return the resulting statically inferred ItemType from adding [this] to [other], return null in case of incompatible inferred static types + // return the resulting statically inferred ItemType from adding [this] to [other], return null in case of + // incompatible inferred static types public ItemType staticallyAddTo(ItemType other, boolean isMinus) { - if(isMinus){ + if (isMinus) { return subTable[this.getIndex()][other.getIndex()]; } else { return addTable[this.getIndex()][other.getIndex()]; @@ -297,12 +1209,12 @@ public ItemType staticallyAddTo(ItemType other, boolean isMinus) { } // return [true] if this is a numeric type (i.e. [integerItem], [decimalItem] or [doubleItem]), false otherwise - public boolean isNumeric(){ + public boolean isNumeric() { return this.equals(integerItem) || this.equals(decimalItem) || this.equals(doubleItem); } // returns [true] if this can be promoted to string - public boolean canBePromotedToString(){ + public boolean canBePromotedToString() { return this.equals(stringItem) || this.equals(anyURIItem); } diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index 163454b172..f1ec7aa285 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -89,68 +89,79 @@ public boolean isSubtypeOfOrCanBePromotedTo(SequenceType superType) { if (this.isEmptySequence) { return superType.arity == Arity.OneOrZero || superType.arity == Arity.ZeroOrMore; } - return this.isAritySubtypeOf(superType.arity) && ( - this.itemType.isSubtypeOf(superType.getItemType()) || - (this.itemType.canBePromotedToString() && superType.itemType.equals(ItemType.stringItem)) || - (this.itemType.isNumeric() && superType.itemType.equals(ItemType.doubleItem)) || - (this.itemType.equals(ItemType.integerItem) && superType.itemType.equals(ItemType.decimalItem)) - ); + return this.isAritySubtypeOf(superType.arity) + && (this.itemType.isSubtypeOf(superType.getItemType()) + || + (this.itemType.canBePromotedToString() && superType.itemType.equals(ItemType.stringItem)) + || + (this.itemType.isNumeric() && superType.itemType.equals(ItemType.doubleItem)) + || + (this.itemType.equals(ItemType.integerItem) && superType.itemType.equals(ItemType.decimalItem))); } // check if the arity of a sequence type is subtype of another arity, assume [this] is a non-empty sequence // TODO: consider removing it - public boolean isAritySubtypeOf(Arity superArity){ + public boolean isAritySubtypeOf(Arity superArity) { return this.arity.isSubtypeOf(superArity); } - public boolean hasEffectiveBooleanValue(){ - if(this.isEmptySequence) { + public boolean hasEffectiveBooleanValue() { + if (this.isEmptySequence) { return true; - } else if(this.itemType.isSubtypeOf(ItemType.JSONItem)) { + } else if (this.itemType.isSubtypeOf(ItemType.JSONItem)) { return true; - } else if((this.arity == Arity.One || this.arity == Arity.OneOrZero) && ( - this.itemType.isNumeric() || - this.itemType.equals(ItemType.stringItem) || - this.itemType.equals(ItemType.anyURIItem) || - this.itemType.equals(ItemType.nullItem) || - this.itemType.equals(ItemType.booleanItem))){ + } else if ( + (this.arity == Arity.One || this.arity == Arity.OneOrZero) + && (this.itemType.isNumeric() + || + this.itemType.equals(ItemType.stringItem) + || + this.itemType.equals(ItemType.anyURIItem) + || + this.itemType.equals(ItemType.nullItem) + || + this.itemType.equals(ItemType.booleanItem)) + ) { return true; } else { return false; } } - public boolean hasOverlapWith(SequenceType other){ + public boolean hasOverlapWith(SequenceType other) { // types overlap if both itemType and Arity overlap, we also need to take care of empty sequence - if(this.isEmptySequence()){ - return other.isEmptySequence() || other.getArity() == Arity.OneOrZero || other.getArity() == Arity.ZeroOrMore; + if (this.isEmptySequence()) { + return other.isEmptySequence() + || other.getArity() == Arity.OneOrZero + || other.getArity() == Arity.ZeroOrMore; } - if(other.isEmptySequence()){ + if (other.isEmptySequence()) { return this.getArity() == Arity.OneOrZero || this.getArity() == Arity.ZeroOrMore; } // All arities overlap between each other - return this.getItemType().isSubtypeOf(other.getItemType()) || other.getItemType().isSubtypeOf(this.getItemType()); + return this.getItemType().isSubtypeOf(other.getItemType()) + || other.getItemType().isSubtypeOf(this.getItemType()); } - public SequenceType leastCommonSupertypeWith(SequenceType other){ - if(this.isEmptySequence){ - if(other.isEmptySequence()){ + public SequenceType leastCommonSupertypeWith(SequenceType other) { + if (this.isEmptySequence) { + if (other.isEmptySequence()) { return this; } else { Arity resultingArity = other.getArity(); - if(resultingArity == Arity.One){ + if (resultingArity == Arity.One) { resultingArity = Arity.OneOrZero; - } else if(resultingArity == Arity.OneOrMore){ + } else if (resultingArity == Arity.OneOrMore) { resultingArity = Arity.ZeroOrMore; } return new SequenceType(other.itemType, resultingArity); } } - if(other.isEmptySequence()){ + if (other.isEmptySequence()) { Arity resultingArity = this.getArity(); - if(resultingArity == Arity.One){ + if (resultingArity == Arity.One) { resultingArity = Arity.OneOrZero; - } else if(resultingArity == Arity.OneOrMore){ + } else if (resultingArity == Arity.OneOrMore) { resultingArity = Arity.ZeroOrMore; } return new SequenceType(this.itemType, resultingArity); @@ -158,9 +169,9 @@ public SequenceType leastCommonSupertypeWith(SequenceType other){ ItemType itemSupertype = this.getItemType().findCommonSuperType(other.getItemType()); Arity aritySuperType = Arity.ZeroOrMore; - if(this.isAritySubtypeOf(other.getArity())){ + if (this.isAritySubtypeOf(other.getArity())) { aritySuperType = other.getArity(); - } else if(other.isAritySubtypeOf(this.getArity())){ + } else if (other.isAritySubtypeOf(this.getArity())) { aritySuperType = this.getArity(); } // no need additional check because the only disjointed arity are ? and +, which least common supertype is * @@ -168,11 +179,11 @@ public SequenceType leastCommonSupertypeWith(SequenceType other){ } // increment arity of a sequence type from ? to * and from 1 to +, leave others arity or sequence types untouched - public SequenceType incrementArity(){ - if(!this.isEmptySequence()){ - if(this.arity == Arity.One){ + public SequenceType incrementArity() { + if (!this.isEmptySequence()) { + if (this.arity == Arity.One) { return new SequenceType(this.getItemType(), Arity.OneOrMore); - } else if(this.arity == Arity.OneOrZero){ + } else if (this.arity == Arity.OneOrZero) { return new SequenceType(this.getItemType(), Arity.ZeroOrMore); } } @@ -222,19 +233,19 @@ public String getSymbol() { public abstract String getSymbol(); - public boolean isSubtypeOf(Arity superArity){ - if(superArity == Arity.ZeroOrMore || superArity == this) + public boolean isSubtypeOf(Arity superArity) { + if (superArity == Arity.ZeroOrMore || superArity == this) return true; else return this == Arity.One; } - public Arity multiplyWith(Arity other){ - if(this == One && other == One){ + public Arity multiplyWith(Arity other) { + if (this == One && other == One) { return One; - } else if(this.isSubtypeOf(OneOrZero) && other.isSubtypeOf(OneOrZero)){ + } else if (this.isSubtypeOf(OneOrZero) && other.isSubtypeOf(OneOrZero)) { return OneOrZero; - } else if(this.isSubtypeOf(OneOrMore) && other.isSubtypeOf(OneOrMore)){ + } else if (this.isSubtypeOf(OneOrMore) && other.isSubtypeOf(OneOrMore)) { return OneOrMore; } else { return ZeroOrMore; From d7343dea14fb543eb7d2e0fc42bb735b87177d10 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Fri, 6 Nov 2020 13:41:51 +0100 Subject: [PATCH 038/206] spotless --- .../rumbledb/compiler/InferTypeVisitor.java | 864 ++++++++----- .../org/rumbledb/compiler/VisitorHelpers.java | 4 +- .../config/RumbleRuntimeConfiguration.java | 3 +- .../org/rumbledb/context/StaticContext.java | 38 +- .../UnexpectedStaticTypeException.java | 2 +- .../org/rumbledb/expressions/Expression.java | 10 +- .../arithmetic/AdditiveExpression.java | 2 +- .../arithmetic/MultiplicativeExpression.java | 2 +- .../arithmetic/UnaryExpression.java | 2 +- .../comparison/ComparisonExpression.java | 2 +- .../flowr/GroupByVariableDeclaration.java | 1 - .../flowr/SimpleMapExpression.java | 2 +- .../DynamicFunctionCallExpression.java | 2 +- .../primary/BooleanLiteralExpression.java | 2 +- .../primary/DecimalLiteralExpression.java | 2 +- .../primary/DoubleLiteralExpression.java | 2 +- .../primary/FunctionCallExpression.java | 2 +- .../primary/InlineFunctionExpression.java | 2 +- .../primary/IntegerLiteralExpression.java | 2 +- .../NamedFunctionReferenceExpression.java | 2 +- .../primary/StringLiteralExpression.java | 2 +- .../primary/VariableReferenceExpression.java | 2 +- .../quantifiers/QuantifiedExpression.java | 2 +- .../expressions/typing/CastExpression.java | 2 +- .../typing/CastableExpression.java | 2 +- .../typing/InstanceOfExpression.java | 2 +- .../expressions/typing/TreatExpression.java | 2 +- .../java/org/rumbledb/types/ItemType.java | 1070 +++++++++++++++-- .../java/org/rumbledb/types/SequenceType.java | 93 +- 29 files changed, 1685 insertions(+), 440 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index c3aad6e6d5..b2f9c479e2 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -56,47 +56,59 @@ public class InferTypeVisitor extends AbstractNodeVisitor { } /** - * Perform basic checks on a list of SequenceType, available checks are for null (OurBad exception) and inferred the empty sequence (XPST0005) + * Perform basic checks on a list of SequenceType, available checks are for null (OurBad exception) and inferred the + * empty sequence (XPST0005) * * @param types list of sequence types to check * @param nodeName name of the node to use in the errors * @param nullCheck flag indicating to perform null check * @param inferredEmptyCheck flag indicating to perform empty sequence check */ - private void basicChecks(List types, String nodeName, boolean nullCheck, boolean inferredEmptyCheck){ - if(nullCheck){ - for (SequenceType type : types){ - if(type == null){ + private void basicChecks(List types, String nodeName, boolean nullCheck, boolean inferredEmptyCheck) { + if (nullCheck) { + for (SequenceType type : types) { + if (type == null) { throw new OurBadException("A child expression of a " + nodeName + " has no inferred type"); } } } - if(inferredEmptyCheck){ - for (SequenceType type : types){ - if(type.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type for " + nodeName + " is empty sequence (with active static typing feature, only allowed for CommaExpression)", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (inferredEmptyCheck) { + for (SequenceType type : types) { + if (type.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type for " + + nodeName + + " is empty sequence (with active static typing feature, only allowed for CommaExpression)", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } } } } /** - * Perform basic checks on a SequenceType, available checks are for null (OurBad exception) and inferred the empty sequence (XPST0005) + * Perform basic checks on a SequenceType, available checks are for null (OurBad exception) and inferred the empty + * sequence (XPST0005) * * @param type sequence types to check * @param nodeName name of the node to use in the errors * @param nullCheck flag indicating to perform null check * @param inferredEmptyCheck flag indicating to perform empty sequence check */ - private void basicChecks(SequenceType type, String nodeName, boolean nullCheck, boolean inferredEmptyCheck){ - if(nullCheck){ - if(type == null){ + private void basicChecks(SequenceType type, String nodeName, boolean nullCheck, boolean inferredEmptyCheck) { + if (nullCheck) { + if (type == null) { throw new OurBadException("A child expression of a " + nodeName + " has no inferred type"); } } - if(inferredEmptyCheck){ - if(type.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type for " + nodeName + " is empty sequence (with active static typing feature, only allowed for CommaExpression)", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (inferredEmptyCheck) { + if (type.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type for " + + nodeName + + " is empty sequence (with active static typing feature, only allowed for CommaExpression)", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } } } @@ -106,26 +118,31 @@ public StaticContext visitCommaExpression(CommaExpression expression, StaticCont visitDescendants(expression, argument); SequenceType inferredType = SequenceType.EMPTY_SEQUENCE; - - for(Expression childExpression : expression.getExpressions()){ + + for (Expression childExpression : expression.getExpressions()) { SequenceType childExpressionInferredType = childExpression.getInferredSequenceType(); // if a child expression has no inferred type throw an error - if(childExpressionInferredType == null){ + if (childExpressionInferredType == null) { throw new UnexpectedStaticTypeException("A child expression of a CommaExpression has no inferred type"); } // if the child expression is an EMPTY_SEQUENCE it does not affect the comma expression type - if(!childExpressionInferredType.isEmptySequence()){ - if(inferredType.isEmptySequence()){ + if (!childExpressionInferredType.isEmptySequence()) { + if (inferredType.isEmptySequence()) { inferredType = childExpressionInferredType; - } else{ - ItemType resultingItemType = inferredType.getItemType().findCommonSuperType(childExpressionInferredType.getItemType()); - SequenceType.Arity resultingArity = - ( (inferredType.getArity() == SequenceType.Arity.OneOrZero || inferredType.getArity() == SequenceType.Arity.ZeroOrMore) && - (childExpressionInferredType.getArity() == SequenceType.Arity.OneOrZero || childExpressionInferredType.getArity() == SequenceType.Arity.ZeroOrMore)) ? - SequenceType.Arity.ZeroOrMore : SequenceType.Arity.OneOrMore; - inferredType = new SequenceType(resultingItemType, resultingArity); + } else { + ItemType resultingItemType = inferredType.getItemType() + .findCommonSuperType(childExpressionInferredType.getItemType()); + SequenceType.Arity resultingArity = + ((inferredType.getArity() == SequenceType.Arity.OneOrZero + || inferredType.getArity() == SequenceType.Arity.ZeroOrMore) + && + (childExpressionInferredType.getArity() == SequenceType.Arity.OneOrZero + || childExpressionInferredType.getArity() == SequenceType.Arity.ZeroOrMore)) + ? SequenceType.Arity.ZeroOrMore + : SequenceType.Arity.OneOrMore; + inferredType = new SequenceType(resultingItemType, resultingArity); } } } @@ -138,7 +155,7 @@ public StaticContext visitCommaExpression(CommaExpression expression, StaticCont // region primary @Override - public StaticContext visitString(StringLiteralExpression expression, StaticContext argument){ + public StaticContext visitString(StringLiteralExpression expression, StaticContext argument) { System.out.println("visiting String literal"); expression.setInferredSequenceType(new SequenceType(ItemType.stringItem)); return argument; @@ -182,7 +199,7 @@ public StaticContext visitBoolean(BooleanLiteralExpression expression, StaticCon @Override public StaticContext visitVariableReference(VariableReferenceExpression expression, StaticContext argument) { SequenceType variableType = expression.getActualType(); - if(variableType == null){ + if (variableType == null) { // if is null, no 'as [SequenceType]' part was present in the declaration, therefore we infer it System.out.println("variable reference type was null so we infer it"); variableType = expression.getStaticContext().getVariableSequenceType(expression.getVariableName()); @@ -207,23 +224,33 @@ public StaticContext visitArrayConstructor(ArrayConstructorExpression expression public StaticContext visitObjectConstructor(ObjectConstructorExpression expression, StaticContext argument) { System.out.println("visiting Object constructor literal"); visitDescendants(expression, argument); - if(expression.isMergedConstructor()){ + if (expression.isMergedConstructor()) { // if it is a merged constructor the child must be a subtype of object* inferred type SequenceType childSequenceType = ((Expression) expression.getChildren().get(0)).getInferredSequenceType(); - if(childSequenceType == null) { + if (childSequenceType == null) { throw new UnexpectedStaticTypeException("The child expression has no inferred type"); } - if(!childSequenceType.isSubtypeOf(SequenceType.createSequenceType("object*"))){ - throw new UnexpectedStaticTypeException("The child expression must have object* sequence type, instead found: " + childSequenceType); + if (!childSequenceType.isSubtypeOf(SequenceType.createSequenceType("object*"))) { + throw new UnexpectedStaticTypeException( + "The child expression must have object* sequence type, instead found: " + childSequenceType + ); } } else { for (Expression keyExpression : expression.getKeys()) { SequenceType keySequenceType = keyExpression.getInferredSequenceType(); if (keySequenceType == null) { - throw new UnexpectedStaticTypeException("One of the key in the object constructor has no inferred type"); + throw new UnexpectedStaticTypeException( + "One of the key in the object constructor has no inferred type" + ); } - if (!keySequenceType.isSubtypeOf(SequenceType.createSequenceType("string")) && !keySequenceType.isSubtypeOf(SequenceType.createSequenceType("anyURI"))) { - throw new UnexpectedStaticTypeException("The inferred static sequence types for the keys of an Object must be a subtype of string or anyURI, instead found a: " + keySequenceType); + if ( + !keySequenceType.isSubtypeOf(SequenceType.createSequenceType("string")) + && !keySequenceType.isSubtypeOf(SequenceType.createSequenceType("anyURI")) + ) { + throw new UnexpectedStaticTypeException( + "The inferred static sequence types for the keys of an Object must be a subtype of string or anyURI, instead found a: " + + keySequenceType + ); } } } @@ -234,7 +261,7 @@ public StaticContext visitObjectConstructor(ObjectConstructorExpression expressi @Override public StaticContext visitContextExpr(ContextItemExpression expression, StaticContext argument) { SequenceType contextType = expression.getStaticContext().getContextItemStaticType(); - if(contextType == null){ + if (contextType == null) { contextType = new SequenceType(ItemType.item); } expression.setInferredSequenceType(contextType); @@ -266,36 +293,38 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static FunctionSignature signature = null; try { function = BuiltinFunctionCatalogue.getBuiltinFunction(expression.getFunctionIdentifier()); - } catch (OurBadException exception){ + } catch (OurBadException exception) { signature = expression.getStaticContext().getFunctionSignature(expression.getFunctionIdentifier()); } List parameterExpressions = expression.getArguments(); - if(function != null){ + if (function != null) { signature = function.getSignature(); } List parameterTypes = signature.getParameterTypes(); int paramsLength = parameterExpressions.size(); - for(int i = 0; i < paramsLength; ++i){ - if(parameterExpressions.get(i) != null){ + for (int i = 0; i < paramsLength; ++i) { + if (parameterExpressions.get(i) != null) { SequenceType actualType = parameterExpressions.get(i).getInferredSequenceType(); SequenceType expectedType = parameterTypes.get(i); // check actual parameters is either a subtype of or can be promoted to expected type // TODO: should i consider automatic prmotion as valid or not - if(!actualType.isSubtypeOfOrCanBePromotedTo(expectedType)){ - throw new UnexpectedStaticTypeException("Argument " + i + " requires " + expectedType + " but " + actualType + " was found"); + if (!actualType.isSubtypeOfOrCanBePromotedTo(expectedType)) { + throw new UnexpectedStaticTypeException( + "Argument " + i + " requires " + expectedType + " but " + actualType + " was found" + ); } } } - if(expression.isPartialApplication()){ + if (expression.isPartialApplication()) { expression.setInferredSequenceType(new SequenceType(ItemType.functionItem)); } else { SequenceType returnType = signature.getReturnType(); - if(returnType == null){ + if (returnType == null) { returnType = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; } expression.setInferredSequenceType(returnType); @@ -327,23 +356,35 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex SequenceType castedSequenceType = expression.getSequenceType(); // Empty sequence check - if(expressionSequenceType.isEmptySequence() && castedSequenceType.getArity() != SequenceType.Arity.OneOrZero){ - throw new UnexpectedStaticTypeException("Empty sequence cannot be cast to type with quantifier different from '?'"); + if (expressionSequenceType.isEmptySequence() && castedSequenceType.getArity() != SequenceType.Arity.OneOrZero) { + throw new UnexpectedStaticTypeException( + "Empty sequence cannot be cast to type with quantifier different from '?'" + ); } // Arity check - if(!castedSequenceType.isAritySubtypeOf(SequenceType.Arity.OneOrZero)){ + if (!castedSequenceType.isAritySubtypeOf(SequenceType.Arity.OneOrZero)) { throw new UnexpectedStaticTypeException("It is possible to cast only to types with arity '1' or '?'"); } - if(!expressionSequenceType.isAritySubtypeOf(castedSequenceType.getArity())){ - throw new UnexpectedStaticTypeException("It is never possible to cast a " + - expressionSequenceType + " as " + castedSequenceType); + if (!expressionSequenceType.isAritySubtypeOf(castedSequenceType.getArity())) { + throw new UnexpectedStaticTypeException( + "It is never possible to cast a " + + + expressionSequenceType + + " as " + + castedSequenceType + ); } // ItemType static castability check - if(!expressionSequenceType.getItemType().staticallyCastableAs(castedSequenceType.getItemType())){ - throw new UnexpectedStaticTypeException("It is never possible to cast a " + - expressionSequenceType + " as " + castedSequenceType); + if (!expressionSequenceType.getItemType().staticallyCastableAs(castedSequenceType.getItemType())) { + throw new UnexpectedStaticTypeException( + "It is never possible to cast a " + + + expressionSequenceType + + " as " + + castedSequenceType + ); } expression.setInferredSequenceType(castedSequenceType); @@ -367,8 +408,10 @@ public StaticContext visitTreatExpression(TreatExpression expression, StaticCont SequenceType expressionSequenceType = expression.getMainExpression().getInferredSequenceType(); SequenceType treatedSequenceType = expression.getSequenceType(); - if(expressionSequenceType == null || treatedSequenceType == null){ - throw new UnexpectedStaticTypeException("The child expression of a Treat expression has no inferred type or it is being treated as null sequence type"); + if (expressionSequenceType == null || treatedSequenceType == null) { + throw new UnexpectedStaticTypeException( + "The child expression of a Treat expression has no inferred type or it is being treated as null sequence type" + ); } expression.setInferredSequenceType(treatedSequenceType); @@ -388,31 +431,43 @@ public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticCont SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); // if any of the child expression has null inferred type throw error - if(leftInferredType == null || rightInferredType == null){ + if (leftInferredType == null || rightInferredType == null) { throw new UnexpectedStaticTypeException("A child expression of a AdditiveExpression has no inferred type"); } // if any of the children is the empty sequence throw error XPST0005 - if(leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } ItemType inferredType; SequenceType.Arity inferredArity = resolveArities(leftInferredType.getArity(), rightInferredType.getArity()); // arity check - if(inferredArity == null){ + if (inferredArity == null) { throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for additive expressions"); } - inferredType = leftInferredType.getItemType().staticallyAddTo(rightInferredType.getItemType(), expression.isMinus()); + inferredType = leftInferredType.getItemType() + .staticallyAddTo(rightInferredType.getItemType(), expression.isMinus()); - if(inferredType == null){ - if(inferredArity == SequenceType.Arity.OneOrZero){ + if (inferredType == null) { + if (inferredArity == SequenceType.Arity.OneOrZero) { // Only possible resulting type is empty sequence so throw error XPST0005 - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } else { - throw new UnexpectedStaticTypeException("The following types operation is not possible: " + leftInferredType + (expression.isMinus() ? " - " : " + ") + rightInferredType); + throw new UnexpectedStaticTypeException( + "The following types operation is not possible: " + + leftInferredType + + (expression.isMinus() ? " - " : " + ") + + rightInferredType + ); } } @@ -422,10 +477,10 @@ public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticCont } // This function assume 2 numeric ItemType - private ItemType resolveNumericType(ItemType left, ItemType right){ - if(left.equals(ItemType.doubleItem) || right.equals(ItemType.doubleItem)){ + private ItemType resolveNumericType(ItemType left, ItemType right) { + if (left.equals(ItemType.doubleItem) || right.equals(ItemType.doubleItem)) { return ItemType.doubleItem; - } else if(left.equals(ItemType.decimalItem) || right.equals(ItemType.decimalItem)){ + } else if (left.equals(ItemType.decimalItem) || right.equals(ItemType.decimalItem)) { return ItemType.decimalItem; } else { return ItemType.integerItem; @@ -434,14 +489,23 @@ private ItemType resolveNumericType(ItemType left, ItemType right){ // For arithmetic operations, given 2 arities, return the resulting arity or null in case of invalid arity private SequenceType.Arity resolveArities(SequenceType.Arity left, SequenceType.Arity right) { - if(left == null || - left == SequenceType.Arity.ZeroOrMore || - left == SequenceType.Arity.OneOrMore || - right == null || - right == SequenceType.Arity.ZeroOrMore || + if ( + left == null + || + left == SequenceType.Arity.ZeroOrMore + || + left == SequenceType.Arity.OneOrMore + || + right == null + || + right == SequenceType.Arity.ZeroOrMore + || right == SequenceType.Arity.OneOrMore - ) return null; - return (left == SequenceType.Arity.OneOrZero || right == SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.One; + ) + return null; + return (left == SequenceType.Arity.OneOrZero || right == SequenceType.Arity.OneOrZero) + ? SequenceType.Arity.OneOrZero + : SequenceType.Arity.One; } @Override @@ -453,55 +517,83 @@ public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); // if any of the child expression has null inferred type throw error - if(leftInferredType == null || rightInferredType == null){ - throw new UnexpectedStaticTypeException("A child expression of a MultiplicativeExpression has no inferred type"); + if (leftInferredType == null || rightInferredType == null) { + throw new UnexpectedStaticTypeException( + "A child expression of a MultiplicativeExpression has no inferred type" + ); } // if any of the children is the empty sequence throw error XPST0005 - if(leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } ItemType inferredType = null; SequenceType.Arity inferredArity = resolveArities(leftInferredType.getArity(), rightInferredType.getArity()); - if(inferredArity == null){ - throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for multiplicative expressions"); + if (inferredArity == null) { + throw new UnexpectedStaticTypeException( + "'+' and '*' arities are not allowed for multiplicative expressions" + ); } ItemType leftItemType = leftInferredType.getItemType(); ItemType rightItemType = rightInferredType.getItemType(); // check resulting item for each operation - if(leftItemType.isNumeric()){ - if(rightItemType.isNumeric()){ - if(expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.IDIV){ + if (leftItemType.isNumeric()) { + if (rightItemType.isNumeric()) { + if (expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.IDIV) { inferredType = ItemType.integerItem; - } else if(expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV) { - inferredType = resolveNumericType(ItemType.decimalItem, resolveNumericType(leftItemType, rightItemType)); + } else if ( + expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV + ) { + inferredType = resolveNumericType( + ItemType.decimalItem, + resolveNumericType(leftItemType, rightItemType) + ); } else { inferredType = resolveNumericType(leftItemType, rightItemType); } - } else if(rightItemType.isSubtypeOf(ItemType.durationItem) && - expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL){ + } else if ( + rightItemType.isSubtypeOf(ItemType.durationItem) + && + expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL + ) { inferredType = rightItemType; } - } else if(leftItemType.isSubtypeOf(ItemType.durationItem)){ - if(rightItemType.isNumeric() && ( - expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL || - expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV )){ + } else if (leftItemType.isSubtypeOf(ItemType.durationItem)) { + if ( + rightItemType.isNumeric() + && (expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL + || + expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV) + ) { inferredType = rightItemType; - } else if(rightItemType.equals(leftItemType) && !leftItemType.equals(ItemType.durationItem)){ + } else if (rightItemType.equals(leftItemType) && !leftItemType.equals(ItemType.durationItem)) { inferredType = ItemType.decimalItem; } } - if(inferredType == null){ - if(inferredArity == SequenceType.Arity.OneOrZero){ + if (inferredType == null) { + if (inferredArity == SequenceType.Arity.OneOrZero) { // Only possible resulting type is empty sequence so throw error XPST0005 - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } else { - throw new UnexpectedStaticTypeException("The following types expression is not valid: " + leftItemType + " " + expression.getMultiplicativeOperator() + " " + rightItemType); + throw new UnexpectedStaticTypeException( + "The following types expression is not valid: " + + leftItemType + + " " + + expression.getMultiplicativeOperator() + + " " + + rightItemType + ); } } @@ -516,26 +608,38 @@ public StaticContext visitUnaryExpr(UnaryExpression expression, StaticContext ar SequenceType childInferredType = expression.getMainExpression().getInferredSequenceType(); // if the child expression has null inferred type throw error - if(childInferredType == null){ + if (childInferredType == null) { throw new UnexpectedStaticTypeException("The child expression of a UnaryExpression has no inferred type"); } // if the child is the empty sequence just infer the empty sequence - if(childInferredType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (childInferredType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } - if(childInferredType.getArity() == SequenceType.Arity.OneOrMore || childInferredType.getArity() == SequenceType.Arity.ZeroOrMore){ + if ( + childInferredType.getArity() == SequenceType.Arity.OneOrMore + || childInferredType.getArity() == SequenceType.Arity.ZeroOrMore + ) { throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for unary expressions"); } - // if inferred arity does not allow for empty sequence and static type is not an accepted one throw a static error + // if inferred arity does not allow for empty sequence and static type is not an accepted one throw a static + // error ItemType childItemType = childInferredType.getItemType(); - if(!childItemType.isNumeric()){ - if(childInferredType.getArity() == SequenceType.Arity.OneOrZero){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (!childItemType.isNumeric()) { + if (childInferredType.getArity() == SequenceType.Arity.OneOrZero) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } else { - throw new UnexpectedStaticTypeException("It is not possible to have an Unary expression with the following type: " + childInferredType); + throw new UnexpectedStaticTypeException( + "It is not possible to have an Unary expression with the following type: " + childInferredType + ); } } @@ -548,23 +652,37 @@ public StaticContext visitUnaryExpr(UnaryExpression expression, StaticContext ar // region logic - private StaticContext visitAndOrExpr(Expression expression, StaticContext argument, String expressionName){ + private StaticContext visitAndOrExpr(Expression expression, StaticContext argument, String expressionName) { visitDescendants(expression, argument); List childrenExpressions = expression.getChildren(); SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); - if(leftInferredType == null || rightInferredType == null){ - throw new UnexpectedStaticTypeException("A child expression of a " + expressionName + "Expression has no inferred type"); + if (leftInferredType == null || rightInferredType == null) { + throw new UnexpectedStaticTypeException( + "A child expression of a " + expressionName + "Expression has no inferred type" + ); } - if(!leftInferredType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("left expression of a " + expressionName + "Expression has " + leftInferredType + " inferred type, which has no effective boolean value"); + if (!leftInferredType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "left expression of a " + + expressionName + + "Expression has " + + leftInferredType + + " inferred type, which has no effective boolean value" + ); } - if(!rightInferredType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("right expression of a " + expressionName + "Expression has " + rightInferredType + " inferred type, which has no effective boolean value"); + if (!rightInferredType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "right expression of a " + + expressionName + + "Expression has " + + rightInferredType + + " inferred type, which has no effective boolean value" + ); } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); @@ -586,11 +704,15 @@ public StaticContext visitNotExpr(NotExpression expression, StaticContext argume visitDescendants(expression, argument); SequenceType childInferredType = expression.getMainExpression().getInferredSequenceType(); - if(childInferredType == null){ + if (childInferredType == null) { throw new UnexpectedStaticTypeException("The child expression of NotExpression has no inferred type"); } - if(!childInferredType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("The child expression of NotExpression has " + childInferredType + " inferred type, which has no effective boolean value"); + if (!childInferredType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "The child expression of NotExpression has " + + childInferredType + + " inferred type, which has no effective boolean value" + ); } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); @@ -609,19 +731,27 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); - if(leftInferredType == null || rightInferredType == null){ - throw new UnexpectedStaticTypeException("A child expression of a ComparisonExpression has no inferred type"); + if (leftInferredType == null || rightInferredType == null) { + throw new UnexpectedStaticTypeException( + "A child expression of a ComparisonExpression has no inferred type" + ); } ComparisonExpression.ComparisonOperator operator = expression.getComparisonOperator(); - // for value comparison arities * and + are not allowed, also if one return the empty sequence for sure throw XPST0005 error - if(operator.isValueComparison()){ - if(leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + // for value comparison arities * and + are not allowed, also if one return the empty sequence for sure throw + // XPST0005 error + if (operator.isValueComparison()) { + if (leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } - if(resolveArities(leftInferredType.getArity(), rightInferredType.getArity()) == null){ - throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for this comparison operator: " + operator); + if (resolveArities(leftInferredType.getArity(), rightInferredType.getArity()) == null) { + throw new UnexpectedStaticTypeException( + "'+' and '*' arities are not allowed for this comparison operator: " + operator + ); } } @@ -629,28 +759,51 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static ItemType rightItemType = rightInferredType.getItemType(); // Type must be a strict subtype of atomic - if(!leftItemType.isSubtypeOf(ItemType.atomicItem) || !rightItemType.isSubtypeOf(ItemType.atomicItem) || leftItemType.equals(ItemType.atomicItem) || rightItemType.equals(ItemType.atomicItem)){ + if ( + !leftItemType.isSubtypeOf(ItemType.atomicItem) + || !rightItemType.isSubtypeOf(ItemType.atomicItem) + || leftItemType.equals(ItemType.atomicItem) + || rightItemType.equals(ItemType.atomicItem) + ) { throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types"); } // Type must match exactly or be both numeric or both promotable to string or both durations - if(!leftItemType.equals(rightItemType) && - !(leftItemType.isNumeric() && rightItemType.isNumeric()) && - !(leftItemType.isSubtypeOf(ItemType.durationItem) && rightItemType.isSubtypeOf(ItemType.durationItem)) && - !(leftItemType.canBePromotedToString() && rightItemType.canBePromotedToString())){ - throw new UnexpectedStaticTypeException("It is not possible to compare these types: " + leftItemType + " and " + rightItemType); + if ( + !leftItemType.equals(rightItemType) + && + !(leftItemType.isNumeric() && rightItemType.isNumeric()) + && + !(leftItemType.isSubtypeOf(ItemType.durationItem) && rightItemType.isSubtypeOf(ItemType.durationItem)) + && + !(leftItemType.canBePromotedToString() && rightItemType.canBePromotedToString()) + ) { + throw new UnexpectedStaticTypeException( + "It is not possible to compare these types: " + leftItemType + " and " + rightItemType + ); } // Inequality is not defined for hexBinary and base64binary or for duration of different types - if((operator != ComparisonExpression.ComparisonOperator.VC_EQ && - operator != ComparisonExpression.ComparisonOperator.VC_NE && - operator != ComparisonExpression.ComparisonOperator.GC_EQ && - operator != ComparisonExpression.ComparisonOperator.GC_NE) && ( - leftItemType.equals(ItemType.hexBinaryItem) || leftItemType.equals(ItemType.base64BinaryItem) || - leftItemType.equals(ItemType.durationItem) || rightItemType.equals(ItemType.durationItem) || - ((leftItemType.equals(ItemType.dayTimeDurationItem) || leftItemType.equals(ItemType.yearMonthDurationItem)) && !rightItemType.equals(leftItemType)) - )){ - throw new UnexpectedStaticTypeException("It is not possible to compare these types: " + leftItemType + " " + operator + " " + rightItemType); + if ( + (operator != ComparisonExpression.ComparisonOperator.VC_EQ + && + operator != ComparisonExpression.ComparisonOperator.VC_NE + && + operator != ComparisonExpression.ComparisonOperator.GC_EQ + && + operator != ComparisonExpression.ComparisonOperator.GC_NE) + && (leftItemType.equals(ItemType.hexBinaryItem) + || leftItemType.equals(ItemType.base64BinaryItem) + || + leftItemType.equals(ItemType.durationItem) + || rightItemType.equals(ItemType.durationItem) + || + ((leftItemType.equals(ItemType.dayTimeDurationItem) + || leftItemType.equals(ItemType.yearMonthDurationItem)) && !rightItemType.equals(leftItemType))) + ) { + throw new UnexpectedStaticTypeException( + "It is not possible to compare these types: " + leftItemType + " " + operator + " " + rightItemType + ); } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); @@ -669,16 +822,23 @@ public StaticContext visitConditionalExpression(ConditionalExpression expression SequenceType thenType = expression.getBranch().getInferredSequenceType(); SequenceType elseType = expression.getElseBranch().getInferredSequenceType(); - if(ifType == null || thenType == null || elseType == null){ + if (ifType == null || thenType == null || elseType == null) { throw new OurBadException("A child expression of a ConditionalExpression has no inferred type"); } - if(!ifType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("The condition in the 'if' must have effective boolean value, found inferred type: " + ifType + " (which has not effective boolean value)"); + if (!ifType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "The condition in the 'if' must have effective boolean value, found inferred type: " + + ifType + + " (which has not effective boolean value)" + ); } - if(thenType.isEmptySequence() && elseType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (thenType.isEmptySequence() && elseType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } expression.setInferredSequenceType(thenType.leastCommonSupertypeWith(elseType)); @@ -687,25 +847,37 @@ public StaticContext visitConditionalExpression(ConditionalExpression expression } // throw errors if [type] does not conform to switch test and cases requirements - public void checkSwitchType(SequenceType type){ - if(type == null){ + public void checkSwitchType(SequenceType type) { + if (type == null) { throw new OurBadException("A child expression of a SwitchExpression has no inferred type"); } - if(type.isEmptySequence()){ + if (type.isEmptySequence()) { return; // no further check is required } - if(type.getArity() == SequenceType.Arity.OneOrZero || type.getArity() == SequenceType.Arity.ZeroOrMore){ - throw new UnexpectedStaticTypeException("+ and * arities are not allowed for the expressions of switch test condition and cases"); + if (type.getArity() == SequenceType.Arity.OneOrZero || type.getArity() == SequenceType.Arity.ZeroOrMore) { + throw new UnexpectedStaticTypeException( + "+ and * arities are not allowed for the expressions of switch test condition and cases" + ); } ItemType itemType = type.getItemType(); - if(itemType.isSubtypeOf(ItemType.functionItem)){ - throw new UnexpectedStaticTypeException("function item not allowed for the expressions of switch test condition and cases", ErrorCode.UnexpectedFunctionITem); - } - if(itemType.isSubtypeOf(ItemType.JSONItem)){ - throw new UnexpectedStaticTypeException("switch test condition and cases expressions' item type must match atomic, instead inferred: " + itemType, ErrorCode.NonAtomicElementErrorCode); - } - if(!itemType.isSubtypeOf(ItemType.atomicItem)){ - throw new UnexpectedStaticTypeException("switch test condition and cases expressions' item type must match atomic, instead inferred: " + itemType); + if (itemType.isSubtypeOf(ItemType.functionItem)) { + throw new UnexpectedStaticTypeException( + "function item not allowed for the expressions of switch test condition and cases", + ErrorCode.UnexpectedFunctionITem + ); + } + if (itemType.isSubtypeOf(ItemType.JSONItem)) { + throw new UnexpectedStaticTypeException( + "switch test condition and cases expressions' item type must match atomic, instead inferred: " + + itemType, + ErrorCode.NonAtomicElementErrorCode + ); + } + if (!itemType.isSubtypeOf(ItemType.atomicItem)) { + throw new UnexpectedStaticTypeException( + "switch test condition and cases expressions' item type must match atomic, instead inferred: " + + itemType + ); } } @@ -716,25 +888,25 @@ public StaticContext visitSwitchExpression(SwitchExpression expression, StaticCo checkSwitchType(testType); SequenceType returnType = expression.getDefaultExpression().getInferredSequenceType(); - if(returnType == null){ + if (returnType == null) { throw new OurBadException("A child expression of a SwitchExpression has no inferred type"); } - for(SwitchCase switchCase : expression.getCases()){ + for (SwitchCase switchCase : expression.getCases()) { boolean addToReturnType = false; - for(Expression caseExpression : switchCase.getConditionExpressions()){ + for (Expression caseExpression : switchCase.getConditionExpressions()) { // test the case expression checkSwitchType(caseExpression.getInferredSequenceType()); // if has overlap with the test condition will add the return type to the possible ones - if(caseExpression.getInferredSequenceType().hasOverlapWith(testType)){ + if (caseExpression.getInferredSequenceType().hasOverlapWith(testType)) { addToReturnType = true; } } SequenceType caseReturnType = switchCase.getReturnExpression().getInferredSequenceType(); - if(caseReturnType == null){ + if (caseReturnType == null) { throw new OurBadException("A child expression of a SwitchExpression has no inferred type"); } - if(addToReturnType){ + if (addToReturnType) { returnType = returnType.leastCommonSupertypeWith(caseReturnType); } } @@ -749,21 +921,24 @@ public StaticContext visitTryCatchExpression(TryCatchExpression expression, Stat visitDescendants(expression, argument); SequenceType inferredType = null; - for(Node childNode : expression.getChildren()){ + for (Node childNode : expression.getChildren()) { SequenceType childType = ((Expression) childNode).getInferredSequenceType(); - if(childType == null){ + if (childType == null) { throw new OurBadException("A child expression of a TryCatchExpression has no inferred type"); } - if(inferredType == null){ + if (inferredType == null) { inferredType = childType; } else { inferredType = inferredType.leastCommonSupertypeWith(childType); } } - if(inferredType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (inferredType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } expression.setInferredSequenceType(inferredType); System.out.println("visiting TryCatch expression, type set to: " + expression.getInferredSequenceType()); @@ -778,13 +953,13 @@ public StaticContext visitTypeSwitchExpression(TypeSwitchExpression expression, SequenceType conditionType = expression.getTestCondition().getInferredSequenceType(); basicChecks(conditionType, expression.getClass().getSimpleName(), true, false); - for(TypeswitchCase typeswitchCase : expression.getCases()){ + for (TypeswitchCase typeswitchCase : expression.getCases()) { Name variableName = typeswitchCase.getVariableName(); Expression returnExpression = typeswitchCase.getReturnExpression(); // if we bind a variable we add the static type of it in the context of the return expression - if(variableName != null){ + if (variableName != null) { SequenceType variableType = null; - for(SequenceType st : typeswitchCase.getUnion()){ + for (SequenceType st : typeswitchCase.getUnion()) { variableType = variableType == null ? st : variableType.leastCommonSupertypeWith(st); } returnExpression.getStaticContext().replaceVariableSequenceType(variableName, variableType); @@ -799,7 +974,7 @@ public StaticContext visitTypeSwitchExpression(TypeSwitchExpression expression, Name variableName = expression.getDefaultCase().getVariableName(); Expression returnExpression = expression.getDefaultCase().getReturnExpression(); // if we bind a variable in the default case, we infer testCondition type - if(variableName != null){ + if (variableName != null) { returnExpression.getStaticContext().replaceVariableSequenceType(variableName, conditionType); } visit(returnExpression, argument); @@ -825,17 +1000,25 @@ public StaticContext visitRangeExpr(RangeExpression expression, StaticContext ar SequenceType leftType = ((Expression) children.get(0)).getInferredSequenceType(); SequenceType rightType = ((Expression) children.get(1)).getInferredSequenceType(); - if(leftType == null || rightType == null){ + if (leftType == null || rightType == null) { throw new OurBadException("A child expression of a RangeExpression has no inferred type"); } - if(leftType.isEmptySequence() || rightType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (leftType.isEmptySequence() || rightType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } SequenceType intOpt = new SequenceType(ItemType.integerItem, SequenceType.Arity.OneOrZero); - if(!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)){ - throw new UnexpectedStaticTypeException("operands of the range expression must match type integer? instead found: " + leftType + " and " + rightType); + if (!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)) { + throw new UnexpectedStaticTypeException( + "operands of the range expression must match type integer? instead found: " + + leftType + + " and " + + rightType + ); } expression.setInferredSequenceType(new SequenceType(ItemType.integerItem, SequenceType.Arity.ZeroOrMore)); @@ -851,13 +1034,18 @@ public StaticContext visitStringConcatExpr(StringConcatExpression expression, St SequenceType leftType = ((Expression) children.get(0)).getInferredSequenceType(); SequenceType rightType = ((Expression) children.get(1)).getInferredSequenceType(); - if(leftType == null || rightType == null){ + if (leftType == null || rightType == null) { throw new OurBadException("A child expression of a ConcatExpression has no inferred type"); } SequenceType intOpt = new SequenceType(ItemType.atomicItem, SequenceType.Arity.OneOrZero); - if(!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)){ - throw new UnexpectedStaticTypeException("operands of the concat expression must match type atomic? instead found: " + leftType + " and " + rightType); + if (!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)) { + throw new UnexpectedStaticTypeException( + "operands of the concat expression must match type atomic? instead found: " + + leftType + + " and " + + rightType + ); } expression.setInferredSequenceType(new SequenceType(ItemType.stringItem)); @@ -873,26 +1061,36 @@ public StaticContext visitStringConcatExpr(StringConcatExpression expression, St public StaticContext visitQuantifiedExpression(QuantifiedExpression expression, StaticContext argument) { Expression evaluationExpression = (Expression) expression.getEvaluationExpression(); boolean skipTestInference = false; - for(QuantifiedExpressionVar var : expression.getVariables()){ + for (QuantifiedExpressionVar var : expression.getVariables()) { visit(var.getExpression(), argument); SequenceType inferredType = var.getExpression().getInferredSequenceType(); basicChecks(inferredType, expression.getClass().getSimpleName(), true, false); SequenceType varType = var.getActualSequenceType(); - if(inferredType.isEmptySequence()){ + if (inferredType.isEmptySequence()) { skipTestInference = true; } else { - checkVariableType(varType, inferredType, evaluationExpression.getStaticContext(), expression.getClass().getSimpleName(), var.getVariableName()); + checkVariableType( + varType, + inferredType, + evaluationExpression.getStaticContext(), + expression.getClass().getSimpleName(), + var.getVariableName() + ); } } - if(!skipTestInference){ + if (!skipTestInference) { visit(evaluationExpression, argument); SequenceType evaluationType = evaluationExpression.getInferredSequenceType(); basicChecks(evaluationType, expression.getClass().getSimpleName(), true, false); - if(!evaluationType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("evaluation expression of quantified expression has " + evaluationType + " inferred type, which has no effective boolean value"); + if (!evaluationType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "evaluation expression of quantified expression has " + + evaluationType + + " inferred type, which has no effective boolean value" + ); } } @@ -913,19 +1111,26 @@ public StaticContext visitArrayLookupExpression(ArrayLookupExpression expression SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); SequenceType lookupType = expression.getLookupExpression().getInferredSequenceType(); - if(mainType == null || lookupType == null){ + if (mainType == null || lookupType == null) { throw new OurBadException("A child expression of a ArrayLookupExpression has no inferred type"); } - if(!lookupType.isSubtypeOf(SequenceType.createSequenceType("integer"))){ - throw new UnexpectedStaticTypeException("the lookup expression type must match integer, instead " + lookupType + " was inferred"); + if (!lookupType.isSubtypeOf(SequenceType.createSequenceType("integer"))) { + throw new UnexpectedStaticTypeException( + "the lookup expression type must match integer, instead " + lookupType + " was inferred" + ); } - if(!mainType.hasOverlapWith(SequenceType.createSequenceType("array*")) || mainType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (!mainType.hasOverlapWith(SequenceType.createSequenceType("array*")) || mainType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } - SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; + SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) + ? SequenceType.Arity.OneOrZero + : SequenceType.Arity.ZeroOrMore; expression.setInferredSequenceType(new SequenceType(ItemType.arrayItem, inferredArity)); System.out.println("visiting ArrayLookup expression, type set to: " + expression.getInferredSequenceType()); return argument; @@ -938,20 +1143,29 @@ public StaticContext visitObjectLookupExpression(ObjectLookupExpression expressi SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); SequenceType lookupType = expression.getLookupExpression().getInferredSequenceType(); - if(mainType == null || lookupType == null){ + if (mainType == null || lookupType == null) { throw new OurBadException("A child expression of a ObjectLookupExpression has no inferred type"); } // must be castable to string - if(!lookupType.isSubtypeOf(SequenceType.createSequenceType("atomic"))){ - throw new UnexpectedStaticTypeException("the lookup expression type must be castable to string (i.e. must match atomic), instead " + lookupType + " was inferred"); + if (!lookupType.isSubtypeOf(SequenceType.createSequenceType("atomic"))) { + throw new UnexpectedStaticTypeException( + "the lookup expression type must be castable to string (i.e. must match atomic), instead " + + lookupType + + " was inferred" + ); } - if(!mainType.hasOverlapWith(SequenceType.createSequenceType("object*")) || mainType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (!mainType.hasOverlapWith(SequenceType.createSequenceType("object*")) || mainType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } - SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; + SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) + ? SequenceType.Arity.OneOrZero + : SequenceType.Arity.ZeroOrMore; expression.setInferredSequenceType(new SequenceType(ItemType.objectItem, inferredArity)); System.out.println("visiting ObjectLookup expression, type set to: " + expression.getInferredSequenceType()); return argument; @@ -963,16 +1177,21 @@ public StaticContext visitArrayUnboxingExpression(ArrayUnboxingExpression expres SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); - if(mainType == null){ + if (mainType == null) { throw new OurBadException("A child expression of a ArrayUnboxingExpression has no inferred type"); } - if(!mainType.hasOverlapWith(SequenceType.createSequenceType("array*")) || mainType.isEmptySequence()){ - throw new UnexpectedStaticTypeException("Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (!mainType.hasOverlapWith(SequenceType.createSequenceType("array*")) || mainType.isEmptySequence()) { + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } expression.setInferredSequenceType(SequenceType.createSequenceType("item*")); - System.out.println("visiting ArrayUnboxingExpression expression, type set to: " + expression.getInferredSequenceType()); + System.out.println( + "visiting ArrayUnboxingExpression expression, type set to: " + expression.getInferredSequenceType() + ); return argument; } @@ -992,34 +1211,50 @@ public StaticContext visitFilterExpression(FilterExpression expression, StaticCo basicChecks(predicateType, expression.getClass().getSimpleName(), true, true); // always false so the return type is for sure () - if(predicateType.isSubtypeOf(SequenceType.createSequenceType("null?"))){ - throw new UnexpectedStaticTypeException("Inferred type for FilterExpression is empty sequence (with active static typing feature, only allowed for CommaExpression)", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); - } - if(!predicateType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("Inferred type " + predicateType + " in FilterExpression has no effective boolean value"); - } - - // if we are filter one or less items or we use an integer to select a specific position we return at most one element, otherwise * - SequenceType.Arity inferredArity = (mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) || mainType.getItemType().equals(ItemType.integerItem)) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; + if (predicateType.isSubtypeOf(SequenceType.createSequenceType("null?"))) { + throw new UnexpectedStaticTypeException( + "Inferred type for FilterExpression is empty sequence (with active static typing feature, only allowed for CommaExpression)", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); + } + if (!predicateType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "Inferred type " + predicateType + " in FilterExpression has no effective boolean value" + ); + } + + // if we are filter one or less items or we use an integer to select a specific position we return at most one + // element, otherwise * + SequenceType.Arity inferredArity = (mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) + || mainType.getItemType().equals(ItemType.integerItem)) + ? SequenceType.Arity.OneOrZero + : SequenceType.Arity.ZeroOrMore; expression.setInferredSequenceType(new SequenceType(mainType.getItemType(), inferredArity)); System.out.println("visiting Filter expression, type set to: " + expression.getInferredSequenceType()); return argument; } @Override - public StaticContext visitDynamicFunctionCallExpression(DynamicFunctionCallExpression expression, StaticContext argument) { + public StaticContext visitDynamicFunctionCallExpression( + DynamicFunctionCallExpression expression, + StaticContext argument + ) { // since we do not specify function's signature in the itemType we can only check that it is a function visitDescendants(expression, argument); SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); basicChecks(mainType, expression.getClass().getSimpleName(), true, false); - if(!mainType.equals(new SequenceType(ItemType.functionItem))){ - throw new UnexpectedStaticTypeException("the type of a dynamic function call main expression must be function, instead inferred " + mainType); + if (!mainType.equals(new SequenceType(ItemType.functionItem))) { + throw new UnexpectedStaticTypeException( + "the type of a dynamic function call main expression must be function, instead inferred " + mainType + ); } // TODO: need to add support for partial application expression.setInferredSequenceType(SequenceType.MOST_GENERAL_SEQUENCE_TYPE); - System.out.println("visiting DynamicFunctionCall expression, type set to: " + expression.getInferredSequenceType()); + System.out.println( + "visiting DynamicFunctionCall expression, type set to: " + expression.getInferredSequenceType() + ); return argument; } @@ -1057,14 +1292,16 @@ public StaticContext visitFlowrExpression(FlworExpression expression, StaticCont SequenceType.Arity forArities = SequenceType.Arity.One; // One is arity multiplication's neutral element SequenceType forType; - while (clause != null){ + while (clause != null) { this.visit(clause, argument); // if there are for clauses we need to consider their arities for the returning expression - if(clause.getClauseType() == FLWOR_CLAUSES.FOR){ - forType = ((ForClause) clause).getExpression().getInferredSequenceType(); - // if forType is the empty sequence that means that allowing empty is set otherwise we would have thrown an error - // therefore this for loop will generate one tuple binding the empty sequence, so as for the arities count as arity.One - if(!forType.isEmptySequence()){ + if (clause.getClauseType() == FLWOR_CLAUSES.FOR) { + forType = ((ForClause) clause).getExpression().getInferredSequenceType(); + // if forType is the empty sequence that means that allowing empty is set otherwise we would have thrown + // an error + // therefore this for loop will generate one tuple binding the empty sequence, so as for the arities + // count as arity.One + if (!forType.isEmptySequence()) { forArities = forType.getArity().multiplyWith(forArities); } } @@ -1084,27 +1321,39 @@ public StaticContext visitForClause(ForClause expression, StaticContext argument visit(expression.getExpression(), argument); SequenceType declaredType = expression.getActualSequenceType(); - SequenceType inferredType = (declaredType == null ? expression.getExpression() : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); + SequenceType inferredType = (declaredType == null + ? expression.getExpression() + : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); basicChecks(inferredType, expression.getClass().getSimpleName(), true, false); - if(inferredType.isEmptySequence()){ - if(!expression.isAllowEmpty()) { + if (inferredType.isEmptySequence()) { + if (!expression.isAllowEmpty()) { // for sure we will not have any tuple to process and return the empty sequence - throw new UnexpectedStaticTypeException("In for clause Inferred type is empty sequence, empty is not allowed, so the result returned is for sure () and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + throw new UnexpectedStaticTypeException( + "In for clause Inferred type is empty sequence, empty is not allowed, so the result returned is for sure () and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } } else { - // we take the single arity version of the inferred type or optional arity if we allow empty and the sequence allows () (i.e. arity ? or *) - if(expression.isAllowEmpty() && (inferredType.getArity() == SequenceType.Arity.OneOrZero || inferredType.getArity() == SequenceType.Arity.ZeroOrMore)){ + // we take the single arity version of the inferred type or optional arity if we allow empty and the + // sequence allows () (i.e. arity ? or *) + if ( + expression.isAllowEmpty() + && (inferredType.getArity() == SequenceType.Arity.OneOrZero + || inferredType.getArity() == SequenceType.Arity.ZeroOrMore) + ) { inferredType = new SequenceType(inferredType.getItemType(), SequenceType.Arity.OneOrZero); } else { inferredType = new SequenceType(inferredType.getItemType()); } } - checkVariableType(declaredType, - inferredType, - expression.getNextClause().getStaticContext(), - expression.getClass().getSimpleName(), - expression.getVariableName()); + checkVariableType( + declaredType, + inferredType, + expression.getNextClause().getStaticContext(), + expression.getClass().getSimpleName(), + expression.getVariableName() + ); System.out.println("visiting For clause, inferred var " + expression.getVariableName() + " : " + inferredType); return argument; @@ -1114,12 +1363,16 @@ public StaticContext visitForClause(ForClause expression, StaticContext argument public StaticContext visitLetClause(LetClause expression, StaticContext argument) { visit(expression.getExpression(), argument); SequenceType declaredType = expression.getActualSequenceType(); - SequenceType inferredType = (declaredType == null ? expression.getExpression() : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); - checkVariableType(declaredType, - inferredType, - expression.getNextClause().getStaticContext(), - expression.getClass().getSimpleName(), - expression.getVariableName()); + SequenceType inferredType = (declaredType == null + ? expression.getExpression() + : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); + checkVariableType( + declaredType, + inferredType, + expression.getNextClause().getStaticContext(), + expression.getClass().getSimpleName(), + expression.getVariableName() + ); System.out.println("visiting Let clause, var " + expression.getVariableName() + " : " + inferredType); return argument; @@ -1130,50 +1383,64 @@ public StaticContext visitWhereClause(WhereClause expression, StaticContext argu visit(expression.getWhereExpression(), argument); SequenceType whereType = expression.getWhereExpression().getInferredSequenceType(); basicChecks(whereType, expression.getClass().getSimpleName(), true, false); - if(!whereType.hasEffectiveBooleanValue()){ - throw new UnexpectedStaticTypeException("where clause inferred type (" + whereType + ") has no effective boolean value"); + if (!whereType.hasEffectiveBooleanValue()) { + throw new UnexpectedStaticTypeException( + "where clause inferred type (" + whereType + ") has no effective boolean value" + ); } - if(whereType.isEmptySequence() || whereType.isSubtypeOf(SequenceType.createSequenceType("null?"))){ - throw new UnexpectedStaticTypeException("where clause always return false, so return expression inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression); + if (whereType.isEmptySequence() || whereType.isSubtypeOf(SequenceType.createSequenceType("null?"))) { + throw new UnexpectedStaticTypeException( + "where clause always return false, so return expression inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); } return argument; } @Override public StaticContext visitGroupByClause(GroupByClause expression, StaticContext argument) { - Clause nextClause = expression.getNextClause(); // != null because group by cannot be last clause of FLOWR expression + Clause nextClause = expression.getNextClause(); // != null because group by cannot be last clause of FLOWR + // expression Set groupingVars = new HashSet<>(); - for(GroupByVariableDeclaration groupByVar : expression.getGroupVariables()){ + for (GroupByVariableDeclaration groupByVar : expression.getGroupVariables()) { // if we are grouping by an existing var (i.e. expr is null), then the appropriate type is already inferred Expression groupByVarExpr = groupByVar.getExpression(); SequenceType expectedType; - if(groupByVarExpr != null){ + if (groupByVarExpr != null) { visit(groupByVarExpr, argument); SequenceType declaredType = groupByVar.getActualSequenceType(); SequenceType inferredType; - if(declaredType == null){ + if (declaredType == null) { inferredType = groupByVarExpr.getInferredSequenceType(); expectedType = inferredType; } else { inferredType = ((TreatExpression) groupByVarExpr).getMainExpression().getInferredSequenceType(); expectedType = declaredType; } - checkVariableType(declaredType, - inferredType, - nextClause.getStaticContext(), - expression.getClass().getSimpleName(), - groupByVar.getVariableName()); + checkVariableType( + declaredType, + inferredType, + nextClause.getStaticContext(), + expression.getClass().getSimpleName(), + groupByVar.getVariableName() + ); } else { expectedType = expression.getStaticContext().getVariableSequenceType(groupByVar.getVariableName()); } // check that expectedType is a subtype of atomic? - if(!expectedType.isSubtypeOf(SequenceType.createSequenceType("atomic?"))){ - throw new UnexpectedStaticTypeException("group by variable " + groupByVar.getVariableName() + " must match atomic? instead found " + expectedType); + if (!expectedType.isSubtypeOf(SequenceType.createSequenceType("atomic?"))) { + throw new UnexpectedStaticTypeException( + "group by variable " + + groupByVar.getVariableName() + + " must match atomic? instead found " + + expectedType + ); } groupingVars.add(groupByVar.getVariableName()); } - // finally if there was a for clause we need to change the arity of the variables binded so far in the flowr expression, from ? to * and from 1 to + + // finally if there was a for clause we need to change the arity of the variables binded so far in the flowr + // expression, from ? to * and from 1 to + // excluding the grouping variables StaticContext firstClauseStaticContext = expression.getFirstClause().getStaticContext(); nextClause.getStaticContext().incrementArities(firstClauseStaticContext, groupingVars); @@ -1183,15 +1450,24 @@ public StaticContext visitGroupByClause(GroupByClause expression, StaticContext @Override public StaticContext visitOrderByClause(OrderByClause expression, StaticContext argument) { visitDescendants(expression, argument); - for(OrderByClauseSortingKey orderClause : expression.getSortingKeys()){ + for (OrderByClauseSortingKey orderClause : expression.getSortingKeys()) { SequenceType orderType = orderClause.getExpression().getInferredSequenceType(); basicChecks(orderType, expression.getClass().getSimpleName(), true, false); - if(!orderType.isSubtypeOf(SequenceType.createSequenceType("atomic?")) || - orderType.getItemType().equals(ItemType.atomicItem) || - orderType.getItemType().equals(ItemType.durationItem) || - orderType.getItemType().equals(ItemType.hexBinaryItem) || - orderType.getItemType().equals(ItemType.base64BinaryItem)){ - throw new UnexpectedStaticTypeException("order by sorting expression's type must match atomic? and be comparable using 'gt' operator (so duration, hexBinary, base64Binary and atomic item type are not allowed), instead inferred: " + orderType); + if ( + !orderType.isSubtypeOf(SequenceType.createSequenceType("atomic?")) + || + orderType.getItemType().equals(ItemType.atomicItem) + || + orderType.getItemType().equals(ItemType.durationItem) + || + orderType.getItemType().equals(ItemType.hexBinaryItem) + || + orderType.getItemType().equals(ItemType.base64BinaryItem) + ) { + throw new UnexpectedStaticTypeException( + "order by sorting expression's type must match atomic? and be comparable using 'gt' operator (so duration, hexBinary, base64Binary and atomic item type are not allowed), instead inferred: " + + orderType + ); } } @@ -1202,18 +1478,36 @@ public StaticContext visitOrderByClause(OrderByClause expression, StaticContext // region module - // if [declaredType] is not null, check if the inferred type matches or can be promoted to the declared type (otherwise throw type error) + // if [declaredType] is not null, check if the inferred type matches or can be promoted to the declared type + // (otherwise throw type error) // if [declaredType] is null, replace the type of [variableName] in the [context] with the inferred type - public void checkVariableType(SequenceType declaredType, SequenceType inferredType, StaticContext context, String nodeName, Name variableName) { + public void checkVariableType( + SequenceType declaredType, + SequenceType inferredType, + StaticContext context, + String nodeName, + Name variableName + ) { basicChecks(inferredType, nodeName, true, false); - if(declaredType == null){ - // if declared type is null, we overwrite the type in the correspondent InScopeVariable with the inferred type + if (declaredType == null) { + // if declared type is null, we overwrite the type in the correspondent InScopeVariable with the inferred + // type context.replaceVariableSequenceType(variableName, inferredType); } else { - // the expression we get is a treat expression by design so we need to extract the inferred type of its main expression - if(!inferredType.isSubtypeOfOrCanBePromotedTo(declaredType)){ - throw new UnexpectedStaticTypeException("In a " + nodeName + ", the variable $" + variableName + " inferred type " + inferredType + " does not match or can be promoted to the declared type " + declaredType); + // the expression we get is a treat expression by design so we need to extract the inferred type of its main + // expression + if (!inferredType.isSubtypeOfOrCanBePromotedTo(declaredType)) { + throw new UnexpectedStaticTypeException( + "In a " + + nodeName + + ", the variable $" + + variableName + + " inferred type " + + inferredType + + " does not match or can be promoted to the declared type " + + declaredType + ); } } } @@ -1222,12 +1516,16 @@ public void checkVariableType(SequenceType declaredType, SequenceType inferredTy public StaticContext visitVariableDeclaration(VariableDeclaration expression, StaticContext argument) { visitDescendants(expression, argument); SequenceType declaredType = expression.getActualSequenceType(); - SequenceType inferredType = (declaredType == null ? expression.getExpression() : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); - checkVariableType(declaredType, - inferredType, - argument, - expression.getClass().getSimpleName(), - expression.getVariableName()); + SequenceType inferredType = (declaredType == null + ? expression.getExpression() + : ((TreatExpression) expression.getExpression()).getMainExpression()).getInferredSequenceType(); + checkVariableType( + declaredType, + inferredType, + argument, + expression.getClass().getSimpleName(), + expression.getVariableName() + ); return argument; } @@ -1240,14 +1538,22 @@ public StaticContext visitFunctionDeclaration(FunctionDeclaration expression, St SequenceType inferredType = inlineExpression.getBody().getInferredSequenceType(); SequenceType expectedType = inlineExpression.getActualReturnType(); - if(expectedType == null){ + if (expectedType == null) { expectedType = inferredType; - } else if(!inferredType.isSubtypeOfOrCanBePromotedTo(expectedType)) { - throw new UnexpectedStaticTypeException("The declared function return inferred type " + inferredType + " does not match or can be promoted to the expected return type " + expectedType); + } else if (!inferredType.isSubtypeOfOrCanBePromotedTo(expectedType)) { + throw new UnexpectedStaticTypeException( + "The declared function return inferred type " + + inferredType + + " does not match or can be promoted to the expected return type " + + expectedType + ); } // add function signature to the statically known one - argument.addFunctionSignature(inlineExpression.getFunctionIdentifier(), new FunctionSignature(new ArrayList(inlineExpression.getParams().values()), expectedType)); + argument.addFunctionSignature( + inlineExpression.getFunctionIdentifier(), + new FunctionSignature(new ArrayList(inlineExpression.getParams().values()), expectedType) + ); return argument; } diff --git a/src/main/java/org/rumbledb/compiler/VisitorHelpers.java b/src/main/java/org/rumbledb/compiler/VisitorHelpers.java index 0bb51bf7e8..6a8ba3bf7c 100644 --- a/src/main/java/org/rumbledb/compiler/VisitorHelpers.java +++ b/src/main/java/org/rumbledb/compiler/VisitorHelpers.java @@ -54,7 +54,7 @@ private static void inferTypes(Module module, RumbleRuntimeConfiguration conf) { System.out.println("* Starting type inference *"); new InferTypeVisitor(conf).visit(module, module.getStaticContext()); System.out.println("* Completed type inference *"); - if(conf.printInferredTypes()){ + if (conf.printInferredTypes()) { printTree(module, conf); } } @@ -113,7 +113,7 @@ public static MainModule parseMainModule(CharStream stream, URI uri, RumbleRunti pruneModules(mainModule, configuration); resolveDependencies(mainModule, configuration); populateStaticContext(mainModule, configuration); - if(configuration.doStaticAnalysis()){ + if (configuration.doStaticAnalysis()) { inferTypes(mainModule, configuration); } return mainModule; diff --git a/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java b/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java index 95df4d7146..20f30de8ce 100644 --- a/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java +++ b/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java @@ -266,7 +266,8 @@ public boolean doStaticAnalysis() { } public boolean printInferredTypes() { - return this.arguments.containsKey("print-inferred-types") && this.arguments.get("print-inferred-types").equals("yes"); + return this.arguments.containsKey("print-inferred-types") + && this.arguments.get("print-inferred-types").equals("yes"); } public boolean isLocal() { diff --git a/src/main/java/org/rumbledb/context/StaticContext.java b/src/main/java/org/rumbledb/context/StaticContext.java index c94e9a70e2..10b7a3ee87 100644 --- a/src/main/java/org/rumbledb/context/StaticContext.java +++ b/src/main/java/org/rumbledb/context/StaticContext.java @@ -20,7 +20,6 @@ package org.rumbledb.context; -import com.amazonaws.transform.MapEntry; import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.SemanticException; @@ -140,9 +139,12 @@ public FunctionSignature getFunctionSignature(FunctionIdentifier identifier) { } // replace the sequence type of an existing InScopeVariable, throws an error if the variable does not exists - public void replaceVariableSequenceType(Name varName, SequenceType newSequenceType){ + public void replaceVariableSequenceType(Name varName, SequenceType newSequenceType) { InScopeVariable variable = getInScopeVariable(varName); - this.inScopeVariables.replace(varName, new InScopeVariable(varName, newSequenceType, variable.getMetadata(), variable.getStorageMode())); + this.inScopeVariables.replace( + varName, + new InScopeVariable(varName, newSequenceType, variable.getMetadata(), variable.getStorageMode()) + ); } public SequenceType getVariableSequenceType(Name varName) { @@ -166,7 +168,7 @@ public void addVariable( this.inScopeVariables.put(varName, new InScopeVariable(varName, type, metadata, storageMode)); } - public void addFunctionSignature(FunctionIdentifier identifier, FunctionSignature signature){ + public void addFunctionSignature(FunctionIdentifier identifier, FunctionSignature signature) { this.staticallyKnownFunctionSignatures.put(identifier, signature); } @@ -304,20 +306,30 @@ public void setContextItemStaticType(SequenceType contextItemStaticType) { this.contextItemStaticType = contextItemStaticType; } - // replace all inScopeVariable in this context and all parents until [stopContext] with name not in [varToExclude] with same variable with sequence type arity changed from 1 to + and form ? to * + // replace all inScopeVariable in this context and all parents until [stopContext] with name not in [varToExclude] + // with same variable with sequence type arity changed from 1 to + and form ? to * // used by groupBy cluse - public void incrementArities(StaticContext stopContext, Set varToExclude){ - this.inScopeVariables.replaceAll((key, value) -> varToExclude.contains(value) ? value : - new InScopeVariable( + public void incrementArities(StaticContext stopContext, Set varToExclude) { + this.inScopeVariables.replaceAll( + (key, value) -> varToExclude.contains(value) + ? value + : new InScopeVariable( value.getName(), value.getSequenceType().incrementArity(), value.getMetadata(), - value.getStorageMode())); + value.getStorageMode() + ) + ); StaticContext current = this.parent; - while (current != null && current != stopContext){ - for(Map.Entry entry : current.inScopeVariables.entrySet()){ - if(!this.inScopeVariables.containsKey(entry.getKey())){ - this.addVariable(entry.getKey(), entry.getValue().getSequenceType().incrementArity(), entry.getValue().getMetadata(), entry.getValue().getStorageMode()); + while (current != null && current != stopContext) { + for (Map.Entry entry : current.inScopeVariables.entrySet()) { + if (!this.inScopeVariables.containsKey(entry.getKey())) { + this.addVariable( + entry.getKey(), + entry.getValue().getSequenceType().incrementArity(), + entry.getValue().getMetadata(), + entry.getValue().getStorageMode() + ); } } current = current.parent; diff --git a/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java b/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java index ce2469ffc9..54af406bc6 100644 --- a/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java +++ b/src/main/java/org/rumbledb/exceptions/UnexpectedStaticTypeException.java @@ -10,7 +10,7 @@ public UnexpectedStaticTypeException(String message) { super(message, ErrorCode.UnexpectedTypeErrorCode); } - public UnexpectedStaticTypeException(String message, ErrorCode errorCode){ + public UnexpectedStaticTypeException(String message, ErrorCode errorCode) { super(message, errorCode); } } diff --git a/src/main/java/org/rumbledb/expressions/Expression.java b/src/main/java/org/rumbledb/expressions/Expression.java index 7fa24c246c..8beed7d360 100644 --- a/src/main/java/org/rumbledb/expressions/Expression.java +++ b/src/main/java/org/rumbledb/expressions/Expression.java @@ -52,9 +52,13 @@ public void setStaticContext(StaticContext staticContext) { this.staticContext = staticContext; } - public SequenceType getInferredSequenceType() { return this.inferredSequenceType; } + public SequenceType getInferredSequenceType() { + return this.inferredSequenceType; + } - public void setInferredSequenceType(SequenceType inferredSequenceType) { this.inferredSequenceType = inferredSequenceType; } + public void setInferredSequenceType(SequenceType inferredSequenceType) { + this.inferredSequenceType = inferredSequenceType; + } public void print(StringBuffer buffer, int indent) { for (int i = 0; i < indent; ++i) { @@ -62,7 +66,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(getClass().getSimpleName()); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java index f6106206a4..4350884ae2 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java @@ -67,7 +67,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.isMinus ? "-" : "+") + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java index 2bb185ce89..3273663047 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java @@ -103,7 +103,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.multiplicativeOperator) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/UnaryExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/UnaryExpression.java index 4c1ba7beeb..6d3a1953c4 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/UnaryExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/UnaryExpression.java @@ -70,7 +70,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.negated ? "-" : "+") + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java b/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java index 887e821a17..4545eacba5 100644 --- a/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java +++ b/src/main/java/org/rumbledb/expressions/comparison/ComparisonExpression.java @@ -151,7 +151,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.comparisonOperator) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/flowr/GroupByVariableDeclaration.java b/src/main/java/org/rumbledb/expressions/flowr/GroupByVariableDeclaration.java index 0f4225572a..a9dd4e8c48 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/GroupByVariableDeclaration.java +++ b/src/main/java/org/rumbledb/expressions/flowr/GroupByVariableDeclaration.java @@ -21,7 +21,6 @@ package org.rumbledb.expressions.flowr; import org.rumbledb.context.Name; -import org.rumbledb.exceptions.OurBadException; import org.rumbledb.expressions.Expression; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java b/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java index 8d776486f3..e6385826fd 100644 --- a/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java +++ b/src/main/java/org/rumbledb/expressions/flowr/SimpleMapExpression.java @@ -66,7 +66,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (!)"); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java b/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java index f6ddb6cee9..8bac2af94a 100644 --- a/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java +++ b/src/main/java/org/rumbledb/expressions/postfix/DynamicFunctionCallExpression.java @@ -82,7 +82,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(getClass().getSimpleName()); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Expression arg : this.arguments) { if (arg == null) { diff --git a/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java index 9217e226e9..6d67bf2d5c 100644 --- a/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/BooleanLiteralExpression.java @@ -59,7 +59,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.value) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java index 3f6e65705b..e20694e081 100644 --- a/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/DecimalLiteralExpression.java @@ -60,7 +60,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.value) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java index 4a7699caf6..e49684e884 100644 --- a/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/DoubleLiteralExpression.java @@ -59,7 +59,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.value) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java b/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java index ab0d02242a..55fea1c683 100644 --- a/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/FunctionCallExpression.java @@ -173,7 +173,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(getClass().getSimpleName()); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Expression arg : this.arguments) { if (arg == null) { diff --git a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java index 1721e9a32e..faaa3c0b3c 100644 --- a/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/InlineFunctionExpression.java @@ -122,7 +122,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(this.returnType == null ? "not set" : this.returnType.toString()); buffer.append(")"); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (int i = 0; i < indent + 2; ++i) { buffer.append(" "); diff --git a/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java index e423c8d532..f1367603ae 100644 --- a/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/IntegerLiteralExpression.java @@ -59,7 +59,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.lexicalValue) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java b/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java index 11e94d3913..27bc1ec3d3 100644 --- a/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/NamedFunctionReferenceExpression.java @@ -60,7 +60,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(getClass().getSimpleName()); buffer.append(" (" + this.identifier.getName() + "#" + this.identifier.getArity() + ") "); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); } } diff --git a/src/main/java/org/rumbledb/expressions/primary/StringLiteralExpression.java b/src/main/java/org/rumbledb/expressions/primary/StringLiteralExpression.java index 14a6c44e75..a8afa05e42 100644 --- a/src/main/java/org/rumbledb/expressions/primary/StringLiteralExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/StringLiteralExpression.java @@ -60,7 +60,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.value) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java b/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java index 1f47e088f2..13d31f800f 100644 --- a/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java +++ b/src/main/java/org/rumbledb/expressions/primary/VariableReferenceExpression.java @@ -92,7 +92,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" ($" + this.name + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpression.java b/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpression.java index c84619bec9..464d101354 100644 --- a/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpression.java +++ b/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpression.java @@ -94,7 +94,7 @@ public void print(StringBuffer buffer, int indent) { } buffer.append(")"); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/typing/CastExpression.java b/src/main/java/org/rumbledb/expressions/typing/CastExpression.java index 16e654d111..52f878c830 100644 --- a/src/main/java/org/rumbledb/expressions/typing/CastExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/CastExpression.java @@ -55,7 +55,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.sequenceType.toString()) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java b/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java index a8bd337234..7395e662f1 100644 --- a/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/CastableExpression.java @@ -55,7 +55,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.sequenceType.toString()) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java b/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java index e15dbcf3ed..fcaa4eed2b 100644 --- a/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/InstanceOfExpression.java @@ -74,7 +74,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.sequenceType.toString()) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/expressions/typing/TreatExpression.java b/src/main/java/org/rumbledb/expressions/typing/TreatExpression.java index dad1ffa1d8..34fcc3b640 100644 --- a/src/main/java/org/rumbledb/expressions/typing/TreatExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/TreatExpression.java @@ -93,7 +93,7 @@ public void print(StringBuffer buffer, int indent) { buffer.append(getClass().getSimpleName()); buffer.append(" (" + (this.sequenceType.toString()) + ") "); buffer.append(" | " + this.highestExecutionMode); - buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType) ); + buffer.append(" | " + (this.inferredSequenceType == null ? "not set" : this.inferredSequenceType)); buffer.append("\n"); for (Node iterator : getChildren()) { iterator.print(buffer, indent + 1); diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 5b00c78f28..e0003eda86 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -63,61 +63,947 @@ private ItemType(String name, int index) { // resulting type of [row] + [col] private static ItemType addTable[][] = { - // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex any-uri base64 json-item object array function - /* item */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* atomic */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* string */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* integer */ { null, null, null, integerItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* decimal */ { null, null, null, decimalItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* double */ { null, null, null, doubleItem, doubleItem, doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* bool */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* null */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* duration */ { null, null, null, null, null, null, null, null, null, null, null, dateTimeItem, dateItem, null, null, null, null, null, null, null, null }, - /* y-m-dur */ { null, null, null, null, null, null, null, null, null, yearMonthDurationItem, null, dateTimeItem, dateItem, null, null, null, null, null, null, null, null }, - /* d-t-dur */ { null, null, null, null, null, null, null, null, null, null, dayTimeDurationItem,dateTimeItem, dateItem, timeItem, null, null, null, null, null, null, null }, - /* date-time*/ { null, null, null, null, null, null, null, null, dateTimeItem, dateTimeItem, dateTimeItem, null, null, null, null, null, null, null, null, null, null }, - /* date */ { null, null, null, null, null, null, null, null, dateItem, dateItem, dateItem, null, null, null, null, null, null, null, null, null, null }, - /* time */ { null, null, null, null, null, null, null, null, null, null, timeItem, null, null, null, null, null, null, null, null, null, null }, - /* hex */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* any-uri */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* base64 */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* json-item*/ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* object */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* array */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* function */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex + // any-uri base64 json-item object array function + /* item */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* atomic */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* string */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* integer */ { + null, + null, + null, + integerItem, + decimalItem, + doubleItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* decimal */ { + null, + null, + null, + decimalItem, + decimalItem, + doubleItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* double */ { + null, + null, + null, + doubleItem, + doubleItem, + doubleItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* bool */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* null */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* duration */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + dateTimeItem, + dateItem, + null, + null, + null, + null, + null, + null, + null, + null }, + /* y-m-dur */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + yearMonthDurationItem, + null, + dateTimeItem, + dateItem, + null, + null, + null, + null, + null, + null, + null, + null }, + /* d-t-dur */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + dayTimeDurationItem, + dateTimeItem, + dateItem, + timeItem, + null, + null, + null, + null, + null, + null, + null }, + /* date-time */ { + null, + null, + null, + null, + null, + null, + null, + null, + dateTimeItem, + dateTimeItem, + dateTimeItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* date */ { + null, + null, + null, + null, + null, + null, + null, + null, + dateItem, + dateItem, + dateItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* time */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + timeItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* hex */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* any-uri */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* base64 */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* json-item */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* object */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* array */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* function */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, }; // resulting type of [row] - [col] private static ItemType subTable[][] = { - // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex any-uri base64 json-item object array function - /* item */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* atomic */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* string */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* integer */ { null, null, null, integerItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* decimal */ { null, null, null, decimalItem,decimalItem,doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* double */ { null, null, null, doubleItem, doubleItem, doubleItem, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* bool */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* null */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* duration */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* y-m-dur */ { null, null, null, null, null, null, null, null, null, yearMonthDurationItem, null, null, null, null, null, null, null, null, null, null, null }, - /* d-t-dur */ { null, null, null, null, null, null, null, null, null, null, dayTimeDurationItem,null, null, null, null, null, null, null, null, null, null }, - /* date-time*/ { null, null, null, null, null, null, null, null, dateTimeItem, dateTimeItem, dateTimeItem, dayTimeDurationItem,null, null, null, null, null, null, null, null, null }, - /* date */ { null, null, null, null, null, null, null, null, dateItem, dateItem, dateItem, null, dayTimeDurationItem,null, null, null, null, null, null, null, null }, - /* time */ { null, null, null, null, null, null, null, null, null, null, timeItem, null, null, dayTimeDurationItem,null, null, null, null, null, null, null }, - /* hex */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* any-uri */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* base64 */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* json-item*/ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* object */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* array */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, - /* function */ { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }, + // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex + // any-uri base64 json-item object array function + /* item */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* atomic */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* string */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* integer */ { + null, + null, + null, + integerItem, + decimalItem, + doubleItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* decimal */ { + null, + null, + null, + decimalItem, + decimalItem, + doubleItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* double */ { + null, + null, + null, + doubleItem, + doubleItem, + doubleItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* bool */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* null */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* duration */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* y-m-dur */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + yearMonthDurationItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* d-t-dur */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + dayTimeDurationItem, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* date-time */ { + null, + null, + null, + null, + null, + null, + null, + null, + dateTimeItem, + dateTimeItem, + dateTimeItem, + dayTimeDurationItem, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* date */ { + null, + null, + null, + null, + null, + null, + null, + null, + dateItem, + dateItem, + dateItem, + null, + dayTimeDurationItem, + null, + null, + null, + null, + null, + null, + null, + null }, + /* time */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + timeItem, + null, + null, + dayTimeDurationItem, + null, + null, + null, + null, + null, + null, + null }, + /* hex */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* any-uri */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* base64 */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* json-item */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* object */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* array */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, + /* function */ { + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null }, }; public String getName() { return this.name; } - public int getIndex() { return this.index; } + public int getIndex() { + return this.index; + } public static ItemType getItemTypeByName(String name) { if (name.equals(objectItem.name)) { @@ -225,71 +1111,97 @@ public boolean isSubtypeOf(ItemType superType) { } return this.equals(superType); } - - public ItemType findCommonSuperType(ItemType other){ - if(other.isSubtypeOf(this)){ + + public ItemType findCommonSuperType(ItemType other) { + if (other.isSubtypeOf(this)) { return this; - } else if(this.isSubtypeOf(other)) { + } else if (this.isSubtypeOf(other)) { return other; - } else if(this.isSubtypeOf(durationItem) && other.isSubtypeOf(durationItem)){ + } else if (this.isSubtypeOf(durationItem) && other.isSubtypeOf(durationItem)) { return durationItem; - } else if(this.isSubtypeOf(atomicItem) && other.isSubtypeOf(atomicItem)){ + } else if (this.isSubtypeOf(atomicItem) && other.isSubtypeOf(atomicItem)) { return atomicItem; - } else if(this.isSubtypeOf(JSONItem) && other.isSubtypeOf(JSONItem)){ + } else if (this.isSubtypeOf(JSONItem) && other.isSubtypeOf(JSONItem)) { return JSONItem; } else { return item; } } - public boolean staticallyCastableAs(ItemType other){ + public boolean staticallyCastableAs(ItemType other) { // JSON items cannot be cast from and to, nor function items, nor we can cast to atomic or item - if(this.isSubtypeOf(JSONItem) || other.isSubtypeOf(JSONItem) || this.equals(functionItem) || other.equals(functionItem) || other.equals(atomicItem) || other.equals(item)) + if ( + this.isSubtypeOf(JSONItem) + || other.isSubtypeOf(JSONItem) + || this.equals(functionItem) + || other.equals(functionItem) + || other.equals(atomicItem) + || other.equals(item) + ) return false; // anything can be casted to itself - if(this.equals(other)) + if (this.equals(other)) return true; // anything can be casted from and to a string (or from one of its supertype) - if(this.equals(stringItem) || this.equals(item) || this.equals(atomicItem) || other.equals(stringItem)) + if (this.equals(stringItem) || this.equals(item) || this.equals(atomicItem) || other.equals(stringItem)) return true; // boolean and numeric can be cast between themselves - if(this.equals(booleanItem) || this.equals(integerItem) || this.equals(doubleItem) || this.equals(decimalItem)){ - if(other.equals(integerItem) || - other.equals(doubleItem) || - other.equals(decimalItem) || + if ( + this.equals(booleanItem) || this.equals(integerItem) || this.equals(doubleItem) || this.equals(decimalItem) + ) { + if ( + other.equals(integerItem) + || + other.equals(doubleItem) + || + other.equals(decimalItem) + || other.equals(booleanItem) - ) return true; - else return false; + ) + return true; + else + return false; } // base64 and hex can be cast between themselves - if(this.equals(base64BinaryItem) || this.equals(hexBinaryItem)){ - if(other.equals(base64BinaryItem) || + if (this.equals(base64BinaryItem) || this.equals(hexBinaryItem)) { + if ( + other.equals(base64BinaryItem) + || other.equals(hexBinaryItem) - ) return true; - else return false; + ) + return true; + else + return false; } // durations can be cast between themselves - if(this.isSubtypeOf(durationItem)){ - if(other.isSubtypeOf(durationItem)) return true; - else return false; + if (this.isSubtypeOf(durationItem)) { + if (other.isSubtypeOf(durationItem)) + return true; + else + return false; } // DateTime can be cast also to Date or Time - if(this.equals(dateTimeItem)){ - if(other.equals(dateItem) || other.equals(timeItem)) return true; - else return false; + if (this.equals(dateTimeItem)) { + if (other.equals(dateItem) || other.equals(timeItem)) + return true; + else + return false; } // Date can be cast also to DateTime - if(this.equals(dateItem)){ - if(other.equals(dateTimeItem)) return true; - else return false; + if (this.equals(dateItem)) { + if (other.equals(dateTimeItem)) + return true; + else + return false; } // Otherwise this cannot be casted to other return false; } - // return the resulting statically inferred ItemType from adding [this] to [other], return null in case of incompatible inferred static types + // return the resulting statically inferred ItemType from adding [this] to [other], return null in case of + // incompatible inferred static types public ItemType staticallyAddTo(ItemType other, boolean isMinus) { - if(isMinus){ + if (isMinus) { return subTable[this.getIndex()][other.getIndex()]; } else { return addTable[this.getIndex()][other.getIndex()]; @@ -297,12 +1209,12 @@ public ItemType staticallyAddTo(ItemType other, boolean isMinus) { } // return [true] if this is a numeric type (i.e. [integerItem], [decimalItem] or [doubleItem]), false otherwise - public boolean isNumeric(){ + public boolean isNumeric() { return this.equals(integerItem) || this.equals(decimalItem) || this.equals(doubleItem); } // returns [true] if this can be promoted to string - public boolean canBePromotedToString(){ + public boolean canBePromotedToString() { return this.equals(stringItem) || this.equals(anyURIItem); } diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index 163454b172..f1ec7aa285 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -89,68 +89,79 @@ public boolean isSubtypeOfOrCanBePromotedTo(SequenceType superType) { if (this.isEmptySequence) { return superType.arity == Arity.OneOrZero || superType.arity == Arity.ZeroOrMore; } - return this.isAritySubtypeOf(superType.arity) && ( - this.itemType.isSubtypeOf(superType.getItemType()) || - (this.itemType.canBePromotedToString() && superType.itemType.equals(ItemType.stringItem)) || - (this.itemType.isNumeric() && superType.itemType.equals(ItemType.doubleItem)) || - (this.itemType.equals(ItemType.integerItem) && superType.itemType.equals(ItemType.decimalItem)) - ); + return this.isAritySubtypeOf(superType.arity) + && (this.itemType.isSubtypeOf(superType.getItemType()) + || + (this.itemType.canBePromotedToString() && superType.itemType.equals(ItemType.stringItem)) + || + (this.itemType.isNumeric() && superType.itemType.equals(ItemType.doubleItem)) + || + (this.itemType.equals(ItemType.integerItem) && superType.itemType.equals(ItemType.decimalItem))); } // check if the arity of a sequence type is subtype of another arity, assume [this] is a non-empty sequence // TODO: consider removing it - public boolean isAritySubtypeOf(Arity superArity){ + public boolean isAritySubtypeOf(Arity superArity) { return this.arity.isSubtypeOf(superArity); } - public boolean hasEffectiveBooleanValue(){ - if(this.isEmptySequence) { + public boolean hasEffectiveBooleanValue() { + if (this.isEmptySequence) { return true; - } else if(this.itemType.isSubtypeOf(ItemType.JSONItem)) { + } else if (this.itemType.isSubtypeOf(ItemType.JSONItem)) { return true; - } else if((this.arity == Arity.One || this.arity == Arity.OneOrZero) && ( - this.itemType.isNumeric() || - this.itemType.equals(ItemType.stringItem) || - this.itemType.equals(ItemType.anyURIItem) || - this.itemType.equals(ItemType.nullItem) || - this.itemType.equals(ItemType.booleanItem))){ + } else if ( + (this.arity == Arity.One || this.arity == Arity.OneOrZero) + && (this.itemType.isNumeric() + || + this.itemType.equals(ItemType.stringItem) + || + this.itemType.equals(ItemType.anyURIItem) + || + this.itemType.equals(ItemType.nullItem) + || + this.itemType.equals(ItemType.booleanItem)) + ) { return true; } else { return false; } } - public boolean hasOverlapWith(SequenceType other){ + public boolean hasOverlapWith(SequenceType other) { // types overlap if both itemType and Arity overlap, we also need to take care of empty sequence - if(this.isEmptySequence()){ - return other.isEmptySequence() || other.getArity() == Arity.OneOrZero || other.getArity() == Arity.ZeroOrMore; + if (this.isEmptySequence()) { + return other.isEmptySequence() + || other.getArity() == Arity.OneOrZero + || other.getArity() == Arity.ZeroOrMore; } - if(other.isEmptySequence()){ + if (other.isEmptySequence()) { return this.getArity() == Arity.OneOrZero || this.getArity() == Arity.ZeroOrMore; } // All arities overlap between each other - return this.getItemType().isSubtypeOf(other.getItemType()) || other.getItemType().isSubtypeOf(this.getItemType()); + return this.getItemType().isSubtypeOf(other.getItemType()) + || other.getItemType().isSubtypeOf(this.getItemType()); } - public SequenceType leastCommonSupertypeWith(SequenceType other){ - if(this.isEmptySequence){ - if(other.isEmptySequence()){ + public SequenceType leastCommonSupertypeWith(SequenceType other) { + if (this.isEmptySequence) { + if (other.isEmptySequence()) { return this; } else { Arity resultingArity = other.getArity(); - if(resultingArity == Arity.One){ + if (resultingArity == Arity.One) { resultingArity = Arity.OneOrZero; - } else if(resultingArity == Arity.OneOrMore){ + } else if (resultingArity == Arity.OneOrMore) { resultingArity = Arity.ZeroOrMore; } return new SequenceType(other.itemType, resultingArity); } } - if(other.isEmptySequence()){ + if (other.isEmptySequence()) { Arity resultingArity = this.getArity(); - if(resultingArity == Arity.One){ + if (resultingArity == Arity.One) { resultingArity = Arity.OneOrZero; - } else if(resultingArity == Arity.OneOrMore){ + } else if (resultingArity == Arity.OneOrMore) { resultingArity = Arity.ZeroOrMore; } return new SequenceType(this.itemType, resultingArity); @@ -158,9 +169,9 @@ public SequenceType leastCommonSupertypeWith(SequenceType other){ ItemType itemSupertype = this.getItemType().findCommonSuperType(other.getItemType()); Arity aritySuperType = Arity.ZeroOrMore; - if(this.isAritySubtypeOf(other.getArity())){ + if (this.isAritySubtypeOf(other.getArity())) { aritySuperType = other.getArity(); - } else if(other.isAritySubtypeOf(this.getArity())){ + } else if (other.isAritySubtypeOf(this.getArity())) { aritySuperType = this.getArity(); } // no need additional check because the only disjointed arity are ? and +, which least common supertype is * @@ -168,11 +179,11 @@ public SequenceType leastCommonSupertypeWith(SequenceType other){ } // increment arity of a sequence type from ? to * and from 1 to +, leave others arity or sequence types untouched - public SequenceType incrementArity(){ - if(!this.isEmptySequence()){ - if(this.arity == Arity.One){ + public SequenceType incrementArity() { + if (!this.isEmptySequence()) { + if (this.arity == Arity.One) { return new SequenceType(this.getItemType(), Arity.OneOrMore); - } else if(this.arity == Arity.OneOrZero){ + } else if (this.arity == Arity.OneOrZero) { return new SequenceType(this.getItemType(), Arity.ZeroOrMore); } } @@ -222,19 +233,19 @@ public String getSymbol() { public abstract String getSymbol(); - public boolean isSubtypeOf(Arity superArity){ - if(superArity == Arity.ZeroOrMore || superArity == this) + public boolean isSubtypeOf(Arity superArity) { + if (superArity == Arity.ZeroOrMore || superArity == this) return true; else return this == Arity.One; } - public Arity multiplyWith(Arity other){ - if(this == One && other == One){ + public Arity multiplyWith(Arity other) { + if (this == One && other == One) { return One; - } else if(this.isSubtypeOf(OneOrZero) && other.isSubtypeOf(OneOrZero)){ + } else if (this.isSubtypeOf(OneOrZero) && other.isSubtypeOf(OneOrZero)) { return OneOrZero; - } else if(this.isSubtypeOf(OneOrMore) && other.isSubtypeOf(OneOrMore)){ + } else if (this.isSubtypeOf(OneOrMore) && other.isSubtypeOf(OneOrMore)) { return OneOrMore; } else { return ZeroOrMore; From 7d36883983b4935db3bdeb3dca4a6d5b402f8d0d Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Fri, 6 Nov 2020 13:57:09 +0100 Subject: [PATCH 039/206] fixed grammar document --- src/main/java/org/rumbledb/parser/Jsoniq.g4 | 6 + .../java/org/rumbledb/parser/Jsoniq.tokens | 60 +- .../java/org/rumbledb/parser/JsoniqLexer.java | 736 +++++++++--------- .../org/rumbledb/parser/JsoniqLexer.tokens | 58 +- .../org/rumbledb/parser/JsoniqParser.java | 293 +++---- 5 files changed, 595 insertions(+), 558 deletions(-) diff --git a/src/main/java/org/rumbledb/parser/Jsoniq.g4 b/src/main/java/org/rumbledb/parser/Jsoniq.g4 index c19e72f840..94e8f9dcac 100644 --- a/src/main/java/org/rumbledb/parser/Jsoniq.g4 +++ b/src/main/java/org/rumbledb/parser/Jsoniq.g4 @@ -301,6 +301,8 @@ keyWords : Kjsoniq | Kto | Kinstance | Kof + | Kstatically + | Kis | Ktreat | Kcast | Kcastable @@ -412,6 +414,10 @@ Kinstance : 'instance' ; Kof : 'of' ; +Kstatically : 'statically' ; + +Kis : 'is' ; + Ktreat : 'treat'; Kcast : 'cast'; diff --git a/src/main/java/org/rumbledb/parser/Jsoniq.tokens b/src/main/java/org/rumbledb/parser/Jsoniq.tokens index e9695362cb..7e4049a327 100644 --- a/src/main/java/org/rumbledb/parser/Jsoniq.tokens +++ b/src/main/java/org/rumbledb/parser/Jsoniq.tokens @@ -111,27 +111,27 @@ Knot=110 Kto=111 Kinstance=112 Kof=113 -Ktreat=114 -Kcast=115 -Kcastable=116 -Kversion=117 -Kjsoniq=118 -Kjson=119 -STRING=120 -ArgumentPlaceholder=121 -NullLiteral=122 -Literal=123 -NumericLiteral=124 -BooleanLiteral=125 -IntegerLiteral=126 -DecimalLiteral=127 -DoubleLiteral=128 -WS=129 -NCName=130 -XQComment=131 -ContentChar=132 -Kstatically=133 -Kis=134 +Kstatically=114 +Kis=115 +Ktreat=116 +Kcast=117 +Kcastable=118 +Kversion=119 +Kjsoniq=120 +Kjson=121 +STRING=122 +ArgumentPlaceholder=123 +NullLiteral=124 +Literal=125 +NumericLiteral=126 +BooleanLiteral=127 +IntegerLiteral=128 +DecimalLiteral=129 +DoubleLiteral=130 +WS=131 +NCName=132 +XQComment=133 +ContentChar=134 ';'=1 'module'=2 'namespace'=3 @@ -245,11 +245,13 @@ Kis=134 'to'=111 'instance'=112 'of'=113 -'treat'=114 -'cast'=115 -'castable'=116 -'version'=117 -'jsoniq'=118 -'json-item'=119 -'?'=121 -'null'=122 +'statically'=114 +'is'=115 +'treat'=116 +'cast'=117 +'castable'=118 +'version'=119 +'jsoniq'=120 +'json-item'=121 +'?'=123 +'null'=124 diff --git a/src/main/java/org/rumbledb/parser/JsoniqLexer.java b/src/main/java/org/rumbledb/parser/JsoniqLexer.java index acb0b27d6c..63e1b05478 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqLexer.java +++ b/src/main/java/org/rumbledb/parser/JsoniqLexer.java @@ -37,11 +37,11 @@ public class JsoniqLexer extends Lexer { Kempty=89, Kcount=90, Kstable=91, Kascending=92, Kdescending=93, Ksome=94, Kevery=95, Ksatisfies=96, Kcollation=97, Kgreatest=98, Kleast=99, Kswitch=100, Kcase=101, Ktry=102, Kcatch=103, Kdefault=104, Kthen=105, Kelse=106, Ktypeswitch=107, - Kor=108, Kand=109, Knot=110, Kto=111, Kinstance=112, Kof=113, Ktreat=114, - Kcast=115, Kcastable=116, Kversion=117, Kjsoniq=118, Kjson=119, STRING=120, - ArgumentPlaceholder=121, NullLiteral=122, Literal=123, NumericLiteral=124, - BooleanLiteral=125, IntegerLiteral=126, DecimalLiteral=127, DoubleLiteral=128, - WS=129, NCName=130, XQComment=131, ContentChar=132; + Kor=108, Kand=109, Knot=110, Kto=111, Kinstance=112, Kof=113, Kstatically=114, + Kis=115, Ktreat=116, Kcast=117, Kcastable=118, Kversion=119, Kjsoniq=120, + Kjson=121, STRING=122, ArgumentPlaceholder=123, NullLiteral=124, Literal=125, + NumericLiteral=126, BooleanLiteral=127, IntegerLiteral=128, DecimalLiteral=129, + DoubleLiteral=130, WS=131, NCName=132, XQComment=133, ContentChar=134; public static String[] channelNames = { "DEFAULT_TOKEN_CHANNEL", "HIDDEN" }; @@ -65,11 +65,11 @@ public class JsoniqLexer extends Lexer { "Kcount", "Kstable", "Kascending", "Kdescending", "Ksome", "Kevery", "Ksatisfies", "Kcollation", "Kgreatest", "Kleast", "Kswitch", "Kcase", "Ktry", "Kcatch", "Kdefault", "Kthen", "Kelse", "Ktypeswitch", "Kor", "Kand", "Knot", "Kto", - "Kinstance", "Kof", "Ktreat", "Kcast", "Kcastable", "Kversion", "Kjsoniq", - "Kjson", "STRING", "ESC", "UNICODE", "HEX", "ArgumentPlaceholder", "NullLiteral", - "Literal", "NumericLiteral", "BooleanLiteral", "IntegerLiteral", "DecimalLiteral", - "DoubleLiteral", "Digits", "WS", "NCName", "NameStartChar", "NameChar", - "XQComment", "ContentChar" + "Kinstance", "Kof", "Kstatically", "Kis", "Ktreat", "Kcast", "Kcastable", + "Kversion", "Kjsoniq", "Kjson", "STRING", "ESC", "UNICODE", "HEX", "ArgumentPlaceholder", + "NullLiteral", "Literal", "NumericLiteral", "BooleanLiteral", "IntegerLiteral", + "DecimalLiteral", "DoubleLiteral", "Digits", "WS", "NCName", "NameStartChar", + "NameChar", "XQComment", "ContentChar" }; private static final String[] _LITERAL_NAMES = { @@ -89,8 +89,9 @@ public class JsoniqLexer extends Lexer { "'stable'", "'ascending'", "'descending'", "'some'", "'every'", "'satisfies'", "'collation'", "'greatest'", "'least'", "'switch'", "'case'", "'try'", "'catch'", "'default'", "'then'", "'else'", "'typeswitch'", "'or'", "'and'", - "'not'", "'to'", "'instance'", "'of'", "'treat'", "'cast'", "'castable'", - "'version'", "'jsoniq'", "'json-item'", null, "'?'", "'null'" + "'not'", "'to'", "'instance'", "'of'", "'statically'", "'is'", "'treat'", + "'cast'", "'castable'", "'version'", "'jsoniq'", "'json-item'", null, + "'?'", "'null'" }; private static final String[] _SYMBOLIC_NAMES = { null, null, null, null, null, null, null, null, null, null, null, null, @@ -104,10 +105,10 @@ public class JsoniqLexer extends Lexer { "Kcount", "Kstable", "Kascending", "Kdescending", "Ksome", "Kevery", "Ksatisfies", "Kcollation", "Kgreatest", "Kleast", "Kswitch", "Kcase", "Ktry", "Kcatch", "Kdefault", "Kthen", "Kelse", "Ktypeswitch", "Kor", "Kand", "Knot", "Kto", - "Kinstance", "Kof", "Ktreat", "Kcast", "Kcastable", "Kversion", "Kjsoniq", - "Kjson", "STRING", "ArgumentPlaceholder", "NullLiteral", "Literal", "NumericLiteral", - "BooleanLiteral", "IntegerLiteral", "DecimalLiteral", "DoubleLiteral", - "WS", "NCName", "XQComment", "ContentChar" + "Kinstance", "Kof", "Kstatically", "Kis", "Ktreat", "Kcast", "Kcastable", + "Kversion", "Kjsoniq", "Kjson", "STRING", "ArgumentPlaceholder", "NullLiteral", + "Literal", "NumericLiteral", "BooleanLiteral", "IntegerLiteral", "DecimalLiteral", + "DoubleLiteral", "WS", "NCName", "XQComment", "ContentChar" }; public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); @@ -167,7 +168,7 @@ public JsoniqLexer(CharStream input) { public ATN getATN() { return _ATN; } public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\u0086\u0474\b\1\4"+ + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\u0088\u0486\b\1\4"+ "\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n"+ "\4\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22"+ "\t\22\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31"+ @@ -183,76 +184,78 @@ public JsoniqLexer(CharStream input) { "\4w\tw\4x\tx\4y\ty\4z\tz\4{\t{\4|\t|\4}\t}\4~\t~\4\177\t\177\4\u0080\t"+ "\u0080\4\u0081\t\u0081\4\u0082\t\u0082\4\u0083\t\u0083\4\u0084\t\u0084"+ "\4\u0085\t\u0085\4\u0086\t\u0086\4\u0087\t\u0087\4\u0088\t\u0088\4\u0089"+ - "\t\u0089\4\u008a\t\u008a\4\u008b\t\u008b\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3"+ - "\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\6"+ - "\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3"+ - "\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n"+ - "\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\f\3\f\3\f\3\f"+ - "\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3"+ - "\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\16\3"+ - "\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\3"+ - "\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3"+ - "\21\3\21\3\21\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\23\3"+ - "\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3"+ - "\24\3\24\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3"+ - "\25\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\27\3"+ - "\27\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\31\3\31\3\31\3\32\3"+ - "\32\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33\3\33\3"+ - "\33\3\33\3\33\3\34\3\34\3\35\3\35\3\36\3\36\3\37\3\37\3 \3 \3!\3!\3\""+ - "\3\"\3#\3#\3#\3$\3$\3$\3%\3%\3%\3&\3&\3&\3\'\3\'\3\'\3(\3(\3(\3)\3)\3"+ - ")\3*\3*\3+\3+\3+\3,\3,\3-\3-\3-\3.\3.\3.\3/\3/\3\60\3\60\3\61\3\61\3\61"+ - "\3\61\3\62\3\62\3\62\3\62\3\62\3\63\3\63\3\63\3\63\3\64\3\64\3\65\3\65"+ - "\3\66\3\66\3\67\3\67\38\38\38\39\39\3:\3:\3:\3;\3;\3;\3<\3<\3<\3<\3<\3"+ - "=\3=\3=\3=\3=\3=\3=\3>\3>\3>\3>\3>\3>\3?\3?\3?\3?\3?\3?\3?\3@\3@\3@\3"+ - "@\3@\3@\3@\3@\3A\3A\3A\3A\3A\3A\3A\3A\3B\3B\3B\3B\3B\3B\3B\3C\3C\3C\3"+ - "C\3C\3C\3C\3C\3D\3D\3D\3D\3D\3D\3D\3D\3D\3E\3E\3E\3E\3E\3E\3E\3E\3E\3"+ - "E\3E\3E\3E\3E\3E\3E\3E\3E\3F\3F\3F\3F\3F\3F\3F\3F\3F\3F\3F\3F\3F\3F\3"+ - "F\3F\3G\3G\3G\3G\3G\3G\3G\3G\3G\3G\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3"+ - "H\3H\3I\3I\3I\3I\3I\3I\3I\3I\3I\3J\3J\3J\3J\3J\3K\3K\3K\3K\3K\3L\3L\3"+ - "L\3L\3L\3L\3L\3M\3M\3M\3M\3M\3M\3M\3N\3N\3N\3N\3O\3O\3O\3O\3P\3P\3P\3"+ - "P\3P\3P\3Q\3Q\3Q\3Q\3Q\3Q\3R\3R\3R\3S\3S\3S\3S\3S\3S\3T\3T\3T\3T\3T\3"+ - "T\3T\3U\3U\3U\3V\3V\3V\3W\3W\3W\3X\3X\3X\3Y\3Y\3Y\3Y\3Y\3Y\3Y\3Y\3Y\3"+ - "Z\3Z\3Z\3Z\3Z\3Z\3[\3[\3[\3[\3[\3[\3\\\3\\\3\\\3\\\3\\\3\\\3\\\3]\3]\3"+ - "]\3]\3]\3]\3]\3]\3]\3]\3^\3^\3^\3^\3^\3^\3^\3^\3^\3^\3^\3_\3_\3_\3_\3"+ - "_\3`\3`\3`\3`\3`\3`\3a\3a\3a\3a\3a\3a\3a\3a\3a\3a\3b\3b\3b\3b\3b\3b\3"+ - "b\3b\3b\3b\3c\3c\3c\3c\3c\3c\3c\3c\3c\3d\3d\3d\3d\3d\3d\3e\3e\3e\3e\3"+ - "e\3e\3e\3f\3f\3f\3f\3f\3g\3g\3g\3g\3h\3h\3h\3h\3h\3h\3i\3i\3i\3i\3i\3"+ - "i\3i\3i\3j\3j\3j\3j\3j\3k\3k\3k\3k\3k\3l\3l\3l\3l\3l\3l\3l\3l\3l\3l\3"+ - "l\3m\3m\3m\3n\3n\3n\3n\3o\3o\3o\3o\3p\3p\3p\3q\3q\3q\3q\3q\3q\3q\3q\3"+ - "q\3r\3r\3r\3s\3s\3s\3s\3s\3s\3t\3t\3t\3t\3t\3u\3u\3u\3u\3u\3u\3u\3u\3"+ - "u\3v\3v\3v\3v\3v\3v\3v\3v\3w\3w\3w\3w\3w\3w\3w\3x\3x\3x\3x\3x\3x\3x\3"+ - "x\3x\3x\3y\3y\3y\7y\u03f5\ny\fy\16y\u03f8\13y\3y\3y\3z\3z\3z\5z\u03ff"+ - "\nz\3{\3{\3{\3{\3{\3{\3|\3|\3}\3}\3~\3~\3~\3~\3~\3\177\3\177\5\177\u0412"+ - "\n\177\3\u0080\3\u0080\3\u0080\5\u0080\u0417\n\u0080\3\u0081\3\u0081\3"+ - "\u0081\3\u0081\3\u0081\3\u0081\3\u0081\3\u0081\3\u0081\5\u0081\u0422\n"+ - "\u0081\3\u0082\3\u0082\3\u0083\3\u0083\3\u0083\3\u0083\3\u0083\7\u0083"+ - "\u042b\n\u0083\f\u0083\16\u0083\u042e\13\u0083\5\u0083\u0430\n\u0083\3"+ - "\u0084\3\u0084\3\u0084\3\u0084\3\u0084\7\u0084\u0437\n\u0084\f\u0084\16"+ - "\u0084\u043a\13\u0084\5\u0084\u043c\n\u0084\5\u0084\u043e\n\u0084\3\u0084"+ - "\3\u0084\5\u0084\u0442\n\u0084\3\u0084\3\u0084\3\u0085\6\u0085\u0447\n"+ - "\u0085\r\u0085\16\u0085\u0448\3\u0086\3\u0086\3\u0086\3\u0086\3\u0087"+ - "\3\u0087\7\u0087\u0451\n\u0087\f\u0087\16\u0087\u0454\13\u0087\3\u0088"+ - "\5\u0088\u0457\n\u0088\3\u0089\3\u0089\5\u0089\u045b\n\u0089\3\u008a\3"+ - "\u008a\3\u008a\3\u008a\3\u008a\3\u008a\3\u008a\3\u008a\7\u008a\u0465\n"+ - "\u008a\f\u008a\16\u008a\u0468\13\u008a\3\u008a\6\u008a\u046b\n\u008a\r"+ - "\u008a\16\u008a\u046c\3\u008a\3\u008a\3\u008a\3\u008a\3\u008b\3\u008b"+ - "\2\2\u008c\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33"+ - "\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67"+ - "\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64g\65"+ - "i\66k\67m8o9q:s;u{?}@\177A\u0081B\u0083C\u0085D\u0087E\u0089F\u008b"+ - "G\u008dH\u008fI\u0091J\u0093K\u0095L\u0097M\u0099N\u009bO\u009dP\u009f"+ - "Q\u00a1R\u00a3S\u00a5T\u00a7U\u00a9V\u00abW\u00adX\u00afY\u00b1Z\u00b3"+ - "[\u00b5\\\u00b7]\u00b9^\u00bb_\u00bd`\u00bfa\u00c1b\u00c3c\u00c5d\u00c7"+ - "e\u00c9f\u00cbg\u00cdh\u00cfi\u00d1j\u00d3k\u00d5l\u00d7m\u00d9n\u00db"+ - "o\u00ddp\u00dfq\u00e1r\u00e3s\u00e5t\u00e7u\u00e9v\u00ebw\u00edx\u00ef"+ - "y\u00f1z\u00f3\2\u00f5\2\u00f7\2\u00f9{\u00fb|\u00fd}\u00ff~\u0101\177"+ - "\u0103\u0080\u0105\u0081\u0107\u0082\u0109\2\u010b\u0083\u010d\u0084\u010f"+ - "\2\u0111\2\u0113\u0085\u0115\u0086\3\2\17\4\2$$^^\n\2$$\61\61^^ddhhpp"+ - "ttvv\5\2\62;CHch\3\2\62;\4\2GGgg\4\2--//\5\2\13\f\17\17\"\"\20\2C\\aa"+ - "c|\u00c2\u00d8\u00da\u00f8\u00fa\u0301\u0372\u037f\u0381\u2001\u200e\u200f"+ + "\t\u0089\4\u008a\t\u008a\4\u008b\t\u008b\4\u008c\t\u008c\4\u008d\t\u008d"+ + "\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3"+ + "\4\3\4\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\7"+ + "\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3"+ + "\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n"+ + "\3\n\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f"+ + "\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3"+ + "\r\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3"+ + "\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3"+ + "\20\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22\3\22\3\22\3\22\3"+ + "\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3"+ + "\23\3\23\3\24\3\24\3\24\3\24\3\24\3\24\3\25\3\25\3\25\3\25\3\25\3\25\3"+ + "\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3"+ + "\26\3\26\3\26\3\26\3\26\3\27\3\27\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3"+ + "\30\3\30\3\31\3\31\3\31\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3"+ + "\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\35\3\35\3\36\3"+ + "\36\3\37\3\37\3 \3 \3!\3!\3\"\3\"\3#\3#\3#\3$\3$\3$\3%\3%\3%\3&\3&\3&"+ + "\3\'\3\'\3\'\3(\3(\3(\3)\3)\3)\3*\3*\3+\3+\3+\3,\3,\3-\3-\3-\3.\3.\3."+ + "\3/\3/\3\60\3\60\3\61\3\61\3\61\3\61\3\62\3\62\3\62\3\62\3\62\3\63\3\63"+ + "\3\63\3\63\3\64\3\64\3\65\3\65\3\66\3\66\3\67\3\67\38\38\38\39\39\3:\3"+ + ":\3:\3;\3;\3;\3<\3<\3<\3<\3<\3=\3=\3=\3=\3=\3=\3=\3>\3>\3>\3>\3>\3>\3"+ + "?\3?\3?\3?\3?\3?\3?\3@\3@\3@\3@\3@\3@\3@\3@\3A\3A\3A\3A\3A\3A\3A\3A\3"+ + "B\3B\3B\3B\3B\3B\3B\3C\3C\3C\3C\3C\3C\3C\3C\3D\3D\3D\3D\3D\3D\3D\3D\3"+ + "D\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3F\3F\3F\3F\3"+ + "F\3F\3F\3F\3F\3F\3F\3F\3F\3F\3F\3F\3G\3G\3G\3G\3G\3G\3G\3G\3G\3G\3H\3"+ + "H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3I\3I\3I\3I\3I\3I\3I\3I\3I\3J\3J\3"+ + "J\3J\3J\3K\3K\3K\3K\3K\3L\3L\3L\3L\3L\3L\3L\3M\3M\3M\3M\3M\3M\3M\3N\3"+ + "N\3N\3N\3O\3O\3O\3O\3P\3P\3P\3P\3P\3P\3Q\3Q\3Q\3Q\3Q\3Q\3R\3R\3R\3S\3"+ + "S\3S\3S\3S\3S\3T\3T\3T\3T\3T\3T\3T\3U\3U\3U\3V\3V\3V\3W\3W\3W\3X\3X\3"+ + "X\3Y\3Y\3Y\3Y\3Y\3Y\3Y\3Y\3Y\3Z\3Z\3Z\3Z\3Z\3Z\3[\3[\3[\3[\3[\3[\3\\\3"+ + "\\\3\\\3\\\3\\\3\\\3\\\3]\3]\3]\3]\3]\3]\3]\3]\3]\3]\3^\3^\3^\3^\3^\3"+ + "^\3^\3^\3^\3^\3^\3_\3_\3_\3_\3_\3`\3`\3`\3`\3`\3`\3a\3a\3a\3a\3a\3a\3"+ + "a\3a\3a\3a\3b\3b\3b\3b\3b\3b\3b\3b\3b\3b\3c\3c\3c\3c\3c\3c\3c\3c\3c\3"+ + "d\3d\3d\3d\3d\3d\3e\3e\3e\3e\3e\3e\3e\3f\3f\3f\3f\3f\3g\3g\3g\3g\3h\3"+ + "h\3h\3h\3h\3h\3i\3i\3i\3i\3i\3i\3i\3i\3j\3j\3j\3j\3j\3k\3k\3k\3k\3k\3"+ + "l\3l\3l\3l\3l\3l\3l\3l\3l\3l\3l\3m\3m\3m\3n\3n\3n\3n\3o\3o\3o\3o\3p\3"+ + "p\3p\3q\3q\3q\3q\3q\3q\3q\3q\3q\3r\3r\3r\3s\3s\3s\3s\3s\3s\3s\3s\3s\3"+ + "s\3s\3t\3t\3t\3u\3u\3u\3u\3u\3u\3v\3v\3v\3v\3v\3w\3w\3w\3w\3w\3w\3w\3"+ + "w\3w\3x\3x\3x\3x\3x\3x\3x\3x\3y\3y\3y\3y\3y\3y\3y\3z\3z\3z\3z\3z\3z\3"+ + "z\3z\3z\3z\3{\3{\3{\7{\u0407\n{\f{\16{\u040a\13{\3{\3{\3|\3|\3|\5|\u0411"+ + "\n|\3}\3}\3}\3}\3}\3}\3~\3~\3\177\3\177\3\u0080\3\u0080\3\u0080\3\u0080"+ + "\3\u0080\3\u0081\3\u0081\5\u0081\u0424\n\u0081\3\u0082\3\u0082\3\u0082"+ + "\5\u0082\u0429\n\u0082\3\u0083\3\u0083\3\u0083\3\u0083\3\u0083\3\u0083"+ + "\3\u0083\3\u0083\3\u0083\5\u0083\u0434\n\u0083\3\u0084\3\u0084\3\u0085"+ + "\3\u0085\3\u0085\3\u0085\3\u0085\7\u0085\u043d\n\u0085\f\u0085\16\u0085"+ + "\u0440\13\u0085\5\u0085\u0442\n\u0085\3\u0086\3\u0086\3\u0086\3\u0086"+ + "\3\u0086\7\u0086\u0449\n\u0086\f\u0086\16\u0086\u044c\13\u0086\5\u0086"+ + "\u044e\n\u0086\5\u0086\u0450\n\u0086\3\u0086\3\u0086\5\u0086\u0454\n\u0086"+ + "\3\u0086\3\u0086\3\u0087\6\u0087\u0459\n\u0087\r\u0087\16\u0087\u045a"+ + "\3\u0088\3\u0088\3\u0088\3\u0088\3\u0089\3\u0089\7\u0089\u0463\n\u0089"+ + "\f\u0089\16\u0089\u0466\13\u0089\3\u008a\5\u008a\u0469\n\u008a\3\u008b"+ + "\3\u008b\5\u008b\u046d\n\u008b\3\u008c\3\u008c\3\u008c\3\u008c\3\u008c"+ + "\3\u008c\3\u008c\3\u008c\7\u008c\u0477\n\u008c\f\u008c\16\u008c\u047a"+ + "\13\u008c\3\u008c\6\u008c\u047d\n\u008c\r\u008c\16\u008c\u047e\3\u008c"+ + "\3\u008c\3\u008c\3\u008c\3\u008d\3\u008d\2\2\u008e\3\3\5\4\7\5\t\6\13"+ + "\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'"+ + "\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'"+ + "M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67m8o9q:s;u{?}@\177"+ + "A\u0081B\u0083C\u0085D\u0087E\u0089F\u008bG\u008dH\u008fI\u0091J\u0093"+ + "K\u0095L\u0097M\u0099N\u009bO\u009dP\u009fQ\u00a1R\u00a3S\u00a5T\u00a7"+ + "U\u00a9V\u00abW\u00adX\u00afY\u00b1Z\u00b3[\u00b5\\\u00b7]\u00b9^\u00bb"+ + "_\u00bd`\u00bfa\u00c1b\u00c3c\u00c5d\u00c7e\u00c9f\u00cbg\u00cdh\u00cf"+ + "i\u00d1j\u00d3k\u00d5l\u00d7m\u00d9n\u00dbo\u00ddp\u00dfq\u00e1r\u00e3"+ + "s\u00e5t\u00e7u\u00e9v\u00ebw\u00edx\u00efy\u00f1z\u00f3{\u00f5|\u00f7"+ + "\2\u00f9\2\u00fb\2\u00fd}\u00ff~\u0101\177\u0103\u0080\u0105\u0081\u0107"+ + "\u0082\u0109\u0083\u010b\u0084\u010d\2\u010f\u0085\u0111\u0086\u0113\2"+ + "\u0115\2\u0117\u0087\u0119\u0088\3\2\17\4\2$$^^\n\2$$\61\61^^ddhhpptt"+ + "vv\5\2\62;CHch\3\2\62;\4\2GGgg\4\2--//\5\2\13\f\17\17\"\"\20\2C\\aac|"+ + "\u00c2\u00d8\u00da\u00f8\u00fa\u0301\u0372\u037f\u0381\u2001\u200e\u200f"+ "\u2072\u2191\u2c02\u2ff1\u3003\ud801\uf902\ufdd1\ufdf2\uffff\7\2//\62"+ ";\u00b9\u00b9\u0302\u0371\u2041\u2042\3\2<<\3\2++\4\2**<<\7\2$$()>>}}"+ - "\177\177\2\u0482\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13"+ + "\177\177\2\u0494\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13"+ "\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2"+ "\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2"+ "!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3"+ @@ -275,286 +278,291 @@ public JsoniqLexer(CharStream input) { "\3\2\2\2\2\u00d5\3\2\2\2\2\u00d7\3\2\2\2\2\u00d9\3\2\2\2\2\u00db\3\2\2"+ "\2\2\u00dd\3\2\2\2\2\u00df\3\2\2\2\2\u00e1\3\2\2\2\2\u00e3\3\2\2\2\2\u00e5"+ "\3\2\2\2\2\u00e7\3\2\2\2\2\u00e9\3\2\2\2\2\u00eb\3\2\2\2\2\u00ed\3\2\2"+ - "\2\2\u00ef\3\2\2\2\2\u00f1\3\2\2\2\2\u00f9\3\2\2\2\2\u00fb\3\2\2\2\2\u00fd"+ + "\2\2\u00ef\3\2\2\2\2\u00f1\3\2\2\2\2\u00f3\3\2\2\2\2\u00f5\3\2\2\2\2\u00fd"+ "\3\2\2\2\2\u00ff\3\2\2\2\2\u0101\3\2\2\2\2\u0103\3\2\2\2\2\u0105\3\2\2"+ - "\2\2\u0107\3\2\2\2\2\u010b\3\2\2\2\2\u010d\3\2\2\2\2\u0113\3\2\2\2\2\u0115"+ - "\3\2\2\2\3\u0117\3\2\2\2\5\u0119\3\2\2\2\7\u0120\3\2\2\2\t\u012a\3\2\2"+ - "\2\13\u012c\3\2\2\2\r\u0134\3\2\2\2\17\u013d\3\2\2\2\21\u0145\3\2\2\2"+ - "\23\u014f\3\2\2\2\25\u015e\3\2\2\2\27\u0160\3\2\2\2\31\u0172\3\2\2\2\33"+ - "\u0185\3\2\2\2\35\u018e\3\2\2\2\37\u0199\3\2\2\2!\u019d\3\2\2\2#\u01a5"+ - "\3\2\2\2%\u01af\3\2\2\2\'\u01ba\3\2\2\2)\u01c0\3\2\2\2+\u01d2\3\2\2\2"+ - "-\u01d9\3\2\2\2/\u01db\3\2\2\2\61\u01e4\3\2\2\2\63\u01e7\3\2\2\2\65\u01f0"+ - "\3\2\2\2\67\u01f9\3\2\2\29\u01fb\3\2\2\2;\u01fd\3\2\2\2=\u01ff\3\2\2\2"+ - "?\u0201\3\2\2\2A\u0203\3\2\2\2C\u0205\3\2\2\2E\u0207\3\2\2\2G\u020a\3"+ - "\2\2\2I\u020d\3\2\2\2K\u0210\3\2\2\2M\u0213\3\2\2\2O\u0216\3\2\2\2Q\u0219"+ - "\3\2\2\2S\u021c\3\2\2\2U\u021e\3\2\2\2W\u0221\3\2\2\2Y\u0223\3\2\2\2["+ - "\u0226\3\2\2\2]\u0229\3\2\2\2_\u022b\3\2\2\2a\u022d\3\2\2\2c\u0231\3\2"+ - "\2\2e\u0236\3\2\2\2g\u023a\3\2\2\2i\u023c\3\2\2\2k\u023e\3\2\2\2m\u0240"+ - "\3\2\2\2o\u0242\3\2\2\2q\u0245\3\2\2\2s\u0247\3\2\2\2u\u024a\3\2\2\2w"+ - "\u024d\3\2\2\2y\u0252\3\2\2\2{\u0259\3\2\2\2}\u025f\3\2\2\2\177\u0266"+ - "\3\2\2\2\u0081\u026e\3\2\2\2\u0083\u0276\3\2\2\2\u0085\u027d\3\2\2\2\u0087"+ - "\u0285\3\2\2\2\u0089\u028e\3\2\2\2\u008b\u02a0\3\2\2\2\u008d\u02b0\3\2"+ - "\2\2\u008f\u02ba\3\2\2\2\u0091\u02c7\3\2\2\2\u0093\u02d0\3\2\2\2\u0095"+ - "\u02d5\3\2\2\2\u0097\u02da\3\2\2\2\u0099\u02e1\3\2\2\2\u009b\u02e8\3\2"+ - "\2\2\u009d\u02ec\3\2\2\2\u009f\u02f0\3\2\2\2\u00a1\u02f6\3\2\2\2\u00a3"+ - "\u02fc\3\2\2\2\u00a5\u02ff\3\2\2\2\u00a7\u0305\3\2\2\2\u00a9\u030c\3\2"+ - "\2\2\u00ab\u030f\3\2\2\2\u00ad\u0312\3\2\2\2\u00af\u0315\3\2\2\2\u00b1"+ - "\u0318\3\2\2\2\u00b3\u0321\3\2\2\2\u00b5\u0327\3\2\2\2\u00b7\u032d\3\2"+ - "\2\2\u00b9\u0334\3\2\2\2\u00bb\u033e\3\2\2\2\u00bd\u0349\3\2\2\2\u00bf"+ - "\u034e\3\2\2\2\u00c1\u0354\3\2\2\2\u00c3\u035e\3\2\2\2\u00c5\u0368\3\2"+ - "\2\2\u00c7\u0371\3\2\2\2\u00c9\u0377\3\2\2\2\u00cb\u037e\3\2\2\2\u00cd"+ - "\u0383\3\2\2\2\u00cf\u0387\3\2\2\2\u00d1\u038d\3\2\2\2\u00d3\u0395\3\2"+ - "\2\2\u00d5\u039a\3\2\2\2\u00d7\u039f\3\2\2\2\u00d9\u03aa\3\2\2\2\u00db"+ - "\u03ad\3\2\2\2\u00dd\u03b1\3\2\2\2\u00df\u03b5\3\2\2\2\u00e1\u03b8\3\2"+ - "\2\2\u00e3\u03c1\3\2\2\2\u00e5\u03c4\3\2\2\2\u00e7\u03ca\3\2\2\2\u00e9"+ - "\u03cf\3\2\2\2\u00eb\u03d8\3\2\2\2\u00ed\u03e0\3\2\2\2\u00ef\u03e7\3\2"+ - "\2\2\u00f1\u03f1\3\2\2\2\u00f3\u03fb\3\2\2\2\u00f5\u0400\3\2\2\2\u00f7"+ - "\u0406\3\2\2\2\u00f9\u0408\3\2\2\2\u00fb\u040a\3\2\2\2\u00fd\u0411\3\2"+ - "\2\2\u00ff\u0416\3\2\2\2\u0101\u0421\3\2\2\2\u0103\u0423\3\2\2\2\u0105"+ - "\u042f\3\2\2\2\u0107\u043d\3\2\2\2\u0109\u0446\3\2\2\2\u010b\u044a\3\2"+ - "\2\2\u010d\u044e\3\2\2\2\u010f\u0456\3\2\2\2\u0111\u045a\3\2\2\2\u0113"+ - "\u045c\3\2\2\2\u0115\u0472\3\2\2\2\u0117\u0118\7=\2\2\u0118\4\3\2\2\2"+ - "\u0119\u011a\7o\2\2\u011a\u011b\7q\2\2\u011b\u011c\7f\2\2\u011c\u011d"+ - "\7w\2\2\u011d\u011e\7n\2\2\u011e\u011f\7g\2\2\u011f\6\3\2\2\2\u0120\u0121"+ - "\7p\2\2\u0121\u0122\7c\2\2\u0122\u0123\7o\2\2\u0123\u0124\7g\2\2\u0124"+ - "\u0125\7u\2\2\u0125\u0126\7r\2\2\u0126\u0127\7c\2\2\u0127\u0128\7e\2\2"+ - "\u0128\u0129\7g\2\2\u0129\b\3\2\2\2\u012a\u012b\7?\2\2\u012b\n\3\2\2\2"+ - "\u012c\u012d\7f\2\2\u012d\u012e\7g\2\2\u012e\u012f\7e\2\2\u012f\u0130"+ - "\7n\2\2\u0130\u0131\7c\2\2\u0131\u0132\7t\2\2\u0132\u0133\7g\2\2\u0133"+ - "\f\3\2\2\2\u0134\u0135\7q\2\2\u0135\u0136\7t\2\2\u0136\u0137\7f\2\2\u0137"+ - "\u0138\7g\2\2\u0138\u0139\7t\2\2\u0139\u013a\7k\2\2\u013a\u013b\7p\2\2"+ - "\u013b\u013c\7i\2\2\u013c\16\3\2\2\2\u013d\u013e\7q\2\2\u013e\u013f\7"+ - "t\2\2\u013f\u0140\7f\2\2\u0140\u0141\7g\2\2\u0141\u0142\7t\2\2\u0142\u0143"+ - "\7g\2\2\u0143\u0144\7f\2\2\u0144\20\3\2\2\2\u0145\u0146\7w\2\2\u0146\u0147"+ - "\7p\2\2\u0147\u0148\7q\2\2\u0148\u0149\7t\2\2\u0149\u014a\7f\2\2\u014a"+ - "\u014b\7g\2\2\u014b\u014c\7t\2\2\u014c\u014d\7g\2\2\u014d\u014e\7f\2\2"+ - "\u014e\22\3\2\2\2\u014f\u0150\7f\2\2\u0150\u0151\7g\2\2\u0151\u0152\7"+ - "e\2\2\u0152\u0153\7k\2\2\u0153\u0154\7o\2\2\u0154\u0155\7c\2\2\u0155\u0156"+ - "\7n\2\2\u0156\u0157\7/\2\2\u0157\u0158\7h\2\2\u0158\u0159\7q\2\2\u0159"+ - "\u015a\7t\2\2\u015a\u015b\7o\2\2\u015b\u015c\7c\2\2\u015c\u015d\7v\2\2"+ - "\u015d\24\3\2\2\2\u015e\u015f\7<\2\2\u015f\26\3\2\2\2\u0160\u0161\7f\2"+ - "\2\u0161\u0162\7g\2\2\u0162\u0163\7e\2\2\u0163\u0164\7k\2\2\u0164\u0165"+ - "\7o\2\2\u0165\u0166\7c\2\2\u0166\u0167\7n\2\2\u0167\u0168\7/\2\2\u0168"+ - "\u0169\7u\2\2\u0169\u016a\7g\2\2\u016a\u016b\7r\2\2\u016b\u016c\7c\2\2"+ - "\u016c\u016d\7t\2\2\u016d\u016e\7c\2\2\u016e\u016f\7v\2\2\u016f\u0170"+ - "\7q\2\2\u0170\u0171\7t\2\2\u0171\30\3\2\2\2\u0172\u0173\7i\2\2\u0173\u0174"+ - "\7t\2\2\u0174\u0175\7q\2\2\u0175\u0176\7w\2\2\u0176\u0177\7r\2\2\u0177"+ - "\u0178\7k\2\2\u0178\u0179\7p\2\2\u0179\u017a\7i\2\2\u017a\u017b\7/\2\2"+ - "\u017b\u017c\7u\2\2\u017c\u017d\7g\2\2\u017d\u017e\7r\2\2\u017e\u017f"+ - "\7c\2\2\u017f\u0180\7t\2\2\u0180\u0181\7c\2\2\u0181\u0182\7v\2\2\u0182"+ - "\u0183\7q\2\2\u0183\u0184\7t\2\2\u0184\32\3\2\2\2\u0185\u0186\7k\2\2\u0186"+ - "\u0187\7p\2\2\u0187\u0188\7h\2\2\u0188\u0189\7k\2\2\u0189\u018a\7p\2\2"+ - "\u018a\u018b\7k\2\2\u018b\u018c\7v\2\2\u018c\u018d\7{\2\2\u018d\34\3\2"+ - "\2\2\u018e\u018f\7o\2\2\u018f\u0190\7k\2\2\u0190\u0191\7p\2\2\u0191\u0192"+ - "\7w\2\2\u0192\u0193\7u\2\2\u0193\u0194\7/\2\2\u0194\u0195\7u\2\2\u0195"+ - "\u0196\7k\2\2\u0196\u0197\7i\2\2\u0197\u0198\7p\2\2\u0198\36\3\2\2\2\u0199"+ - "\u019a\7P\2\2\u019a\u019b\7c\2\2\u019b\u019c\7P\2\2\u019c \3\2\2\2\u019d"+ - "\u019e\7r\2\2\u019e\u019f\7g\2\2\u019f\u01a0\7t\2\2\u01a0\u01a1\7e\2\2"+ - "\u01a1\u01a2\7g\2\2\u01a2\u01a3\7p\2\2\u01a3\u01a4\7v\2\2\u01a4\"\3\2"+ - "\2\2\u01a5\u01a6\7r\2\2\u01a6\u01a7\7g\2\2\u01a7\u01a8\7t\2\2\u01a8\u01a9"+ - "\7/\2\2\u01a9\u01aa\7o\2\2\u01aa\u01ab\7k\2\2\u01ab\u01ac\7n\2\2\u01ac"+ - "\u01ad\7n\2\2\u01ad\u01ae\7g\2\2\u01ae$\3\2\2\2\u01af\u01b0\7|\2\2\u01b0"+ - "\u01b1\7g\2\2\u01b1\u01b2\7t\2\2\u01b2\u01b3\7q\2\2\u01b3\u01b4\7/\2\2"+ - "\u01b4\u01b5\7f\2\2\u01b5\u01b6\7k\2\2\u01b6\u01b7\7i\2\2\u01b7\u01b8"+ - "\7k\2\2\u01b8\u01b9\7v\2\2\u01b9&\3\2\2\2\u01ba\u01bb\7f\2\2\u01bb\u01bc"+ - "\7k\2\2\u01bc\u01bd\7i\2\2\u01bd\u01be\7k\2\2\u01be\u01bf\7v\2\2\u01bf"+ - "(\3\2\2\2\u01c0\u01c1\7r\2\2\u01c1\u01c2\7c\2\2\u01c2\u01c3\7v\2\2\u01c3"+ - "\u01c4\7v\2\2\u01c4\u01c5\7g\2\2\u01c5\u01c6\7t\2\2\u01c6\u01c7\7p\2\2"+ - "\u01c7\u01c8\7/\2\2\u01c8\u01c9\7u\2\2\u01c9\u01ca\7g\2\2\u01ca\u01cb"+ - "\7r\2\2\u01cb\u01cc\7c\2\2\u01cc\u01cd\7t\2\2\u01cd\u01ce\7c\2\2\u01ce"+ - "\u01cf\7v\2\2\u01cf\u01d0\7q\2\2\u01d0\u01d1\7t\2\2\u01d1*\3\2\2\2\u01d2"+ - "\u01d3\7k\2\2\u01d3\u01d4\7o\2\2\u01d4\u01d5\7r\2\2\u01d5\u01d6\7q\2\2"+ - "\u01d6\u01d7\7t\2\2\u01d7\u01d8\7v\2\2\u01d8,\3\2\2\2\u01d9\u01da\7.\2"+ - "\2\u01da.\3\2\2\2\u01db\u01dc\7x\2\2\u01dc\u01dd\7c\2\2\u01dd\u01de\7"+ - "t\2\2\u01de\u01df\7k\2\2\u01df\u01e0\7c\2\2\u01e0\u01e1\7d\2\2\u01e1\u01e2"+ - "\7n\2\2\u01e2\u01e3\7g\2\2\u01e3\60\3\2\2\2\u01e4\u01e5\7<\2\2\u01e5\u01e6"+ - "\7?\2\2\u01e6\62\3\2\2\2\u01e7\u01e8\7g\2\2\u01e8\u01e9\7z\2\2\u01e9\u01ea"+ - "\7v\2\2\u01ea\u01eb\7g\2\2\u01eb\u01ec\7t\2\2\u01ec\u01ed\7p\2\2\u01ed"+ - "\u01ee\7c\2\2\u01ee\u01ef\7n\2\2\u01ef\64\3\2\2\2\u01f0\u01f1\7h\2\2\u01f1"+ - "\u01f2\7w\2\2\u01f2\u01f3\7p\2\2\u01f3\u01f4\7e\2\2\u01f4\u01f5\7v\2\2"+ - "\u01f5\u01f6\7k\2\2\u01f6\u01f7\7q\2\2\u01f7\u01f8\7p\2\2\u01f8\66\3\2"+ - "\2\2\u01f9\u01fa\7*\2\2\u01fa8\3\2\2\2\u01fb\u01fc\7+\2\2\u01fc:\3\2\2"+ - "\2\u01fd\u01fe\7}\2\2\u01fe<\3\2\2\2\u01ff\u0200\7\177\2\2\u0200>\3\2"+ - "\2\2\u0201\u0202\7&\2\2\u0202@\3\2\2\2\u0203\u0204\7~\2\2\u0204B\3\2\2"+ - "\2\u0205\u0206\7,\2\2\u0206D\3\2\2\2\u0207\u0208\7g\2\2\u0208\u0209\7"+ - "s\2\2\u0209F\3\2\2\2\u020a\u020b\7p\2\2\u020b\u020c\7g\2\2\u020cH\3\2"+ - "\2\2\u020d\u020e\7n\2\2\u020e\u020f\7v\2\2\u020fJ\3\2\2\2\u0210\u0211"+ - "\7n\2\2\u0211\u0212\7g\2\2\u0212L\3\2\2\2\u0213\u0214\7i\2\2\u0214\u0215"+ - "\7v\2\2\u0215N\3\2\2\2\u0216\u0217\7i\2\2\u0217\u0218\7g\2\2\u0218P\3"+ - "\2\2\2\u0219\u021a\7#\2\2\u021a\u021b\7?\2\2\u021bR\3\2\2\2\u021c\u021d"+ - "\7>\2\2\u021dT\3\2\2\2\u021e\u021f\7>\2\2\u021f\u0220\7?\2\2\u0220V\3"+ - "\2\2\2\u0221\u0222\7@\2\2\u0222X\3\2\2\2\u0223\u0224\7@\2\2\u0224\u0225"+ - "\7?\2\2\u0225Z\3\2\2\2\u0226\u0227\7~\2\2\u0227\u0228\7~\2\2\u0228\\\3"+ - "\2\2\2\u0229\u022a\7-\2\2\u022a^\3\2\2\2\u022b\u022c\7/\2\2\u022c`\3\2"+ - "\2\2\u022d\u022e\7f\2\2\u022e\u022f\7k\2\2\u022f\u0230\7x\2\2\u0230b\3"+ - "\2\2\2\u0231\u0232\7k\2\2\u0232\u0233\7f\2\2\u0233\u0234\7k\2\2\u0234"+ - "\u0235\7x\2\2\u0235d\3\2\2\2\u0236\u0237\7o\2\2\u0237\u0238\7q\2\2\u0238"+ - "\u0239\7f\2\2\u0239f\3\2\2\2\u023a\u023b\7#\2\2\u023bh\3\2\2\2\u023c\u023d"+ - "\7]\2\2\u023dj\3\2\2\2\u023e\u023f\7_\2\2\u023fl\3\2\2\2\u0240\u0241\7"+ - "\60\2\2\u0241n\3\2\2\2\u0242\u0243\7&\2\2\u0243\u0244\7&\2\2\u0244p\3"+ - "\2\2\2\u0245\u0246\7%\2\2\u0246r\3\2\2\2\u0247\u0248\7}\2\2\u0248\u0249"+ - "\7~\2\2\u0249t\3\2\2\2\u024a\u024b\7~\2\2\u024b\u024c\7\177\2\2\u024c"+ - "v\3\2\2\2\u024d\u024e\7k\2\2\u024e\u024f\7v\2\2\u024f\u0250\7g\2\2\u0250"+ - "\u0251\7o\2\2\u0251x\3\2\2\2\u0252\u0253\7q\2\2\u0253\u0254\7d\2\2\u0254"+ - "\u0255\7l\2\2\u0255\u0256\7g\2\2\u0256\u0257\7e\2\2\u0257\u0258\7v\2\2"+ - "\u0258z\3\2\2\2\u0259\u025a\7c\2\2\u025a\u025b\7t\2\2\u025b\u025c\7t\2"+ - "\2\u025c\u025d\7c\2\2\u025d\u025e\7{\2\2\u025e|\3\2\2\2\u025f\u0260\7"+ - "u\2\2\u0260\u0261\7v\2\2\u0261\u0262\7t\2\2\u0262\u0263\7k\2\2\u0263\u0264"+ - "\7p\2\2\u0264\u0265\7i\2\2\u0265~\3\2\2\2\u0266\u0267\7k\2\2\u0267\u0268"+ - "\7p\2\2\u0268\u0269\7v\2\2\u0269\u026a\7g\2\2\u026a\u026b\7i\2\2\u026b"+ - "\u026c\7g\2\2\u026c\u026d\7t\2\2\u026d\u0080\3\2\2\2\u026e\u026f\7f\2"+ - "\2\u026f\u0270\7g\2\2\u0270\u0271\7e\2\2\u0271\u0272\7k\2\2\u0272\u0273"+ - "\7o\2\2\u0273\u0274\7c\2\2\u0274\u0275\7n\2\2\u0275\u0082\3\2\2\2\u0276"+ - "\u0277\7f\2\2\u0277\u0278\7q\2\2\u0278\u0279\7w\2\2\u0279\u027a\7d\2\2"+ - "\u027a\u027b\7n\2\2\u027b\u027c\7g\2\2\u027c\u0084\3\2\2\2\u027d\u027e"+ - "\7d\2\2\u027e\u027f\7q\2\2\u027f\u0280\7q\2\2\u0280\u0281\7n\2\2\u0281"+ - "\u0282\7g\2\2\u0282\u0283\7c\2\2\u0283\u0284\7p\2\2\u0284\u0086\3\2\2"+ - "\2\u0285\u0286\7f\2\2\u0286\u0287\7w\2\2\u0287\u0288\7t\2\2\u0288\u0289"+ - "\7c\2\2\u0289\u028a\7v\2\2\u028a\u028b\7k\2\2\u028b\u028c\7q\2\2\u028c"+ - "\u028d\7p\2\2\u028d\u0088\3\2\2\2\u028e\u028f\7{\2\2\u028f\u0290\7g\2"+ - "\2\u0290\u0291\7c\2\2\u0291\u0292\7t\2\2\u0292\u0293\7O\2\2\u0293\u0294"+ - "\7q\2\2\u0294\u0295\7p\2\2\u0295\u0296\7v\2\2\u0296\u0297\7j\2\2\u0297"+ - "\u0298\7F\2\2\u0298\u0299\7w\2\2\u0299\u029a\7t\2\2\u029a\u029b\7c\2\2"+ - "\u029b\u029c\7v\2\2\u029c\u029d\7k\2\2\u029d\u029e\7q\2\2\u029e\u029f"+ - "\7p\2\2\u029f\u008a\3\2\2\2\u02a0\u02a1\7f\2\2\u02a1\u02a2\7c\2\2\u02a2"+ - "\u02a3\7{\2\2\u02a3\u02a4\7V\2\2\u02a4\u02a5\7k\2\2\u02a5\u02a6\7o\2\2"+ - "\u02a6\u02a7\7g\2\2\u02a7\u02a8\7F\2\2\u02a8\u02a9\7w\2\2\u02a9\u02aa"+ - "\7t\2\2\u02aa\u02ab\7c\2\2\u02ab\u02ac\7v\2\2\u02ac\u02ad\7k\2\2\u02ad"+ - "\u02ae\7q\2\2\u02ae\u02af\7p\2\2\u02af\u008c\3\2\2\2\u02b0\u02b1\7j\2"+ - "\2\u02b1\u02b2\7g\2\2\u02b2\u02b3\7z\2\2\u02b3\u02b4\7D\2\2\u02b4\u02b5"+ - "\7k\2\2\u02b5\u02b6\7p\2\2\u02b6\u02b7\7c\2\2\u02b7\u02b8\7t\2\2\u02b8"+ - "\u02b9\7{\2\2\u02b9\u008e\3\2\2\2\u02ba\u02bb\7d\2\2\u02bb\u02bc\7c\2"+ - "\2\u02bc\u02bd\7u\2\2\u02bd\u02be\7g\2\2\u02be\u02bf\78\2\2\u02bf\u02c0"+ - "\7\66\2\2\u02c0\u02c1\7D\2\2\u02c1\u02c2\7k\2\2\u02c2\u02c3\7p\2\2\u02c3"+ - "\u02c4\7c\2\2\u02c4\u02c5\7t\2\2\u02c5\u02c6\7{\2\2\u02c6\u0090\3\2\2"+ - "\2\u02c7\u02c8\7f\2\2\u02c8\u02c9\7c\2\2\u02c9\u02ca\7v\2\2\u02ca\u02cb"+ - "\7g\2\2\u02cb\u02cc\7V\2\2\u02cc\u02cd\7k\2\2\u02cd\u02ce\7o\2\2\u02ce"+ - "\u02cf\7g\2\2\u02cf\u0092\3\2\2\2\u02d0\u02d1\7f\2\2\u02d1\u02d2\7c\2"+ - "\2\u02d2\u02d3\7v\2\2\u02d3\u02d4\7g\2\2\u02d4\u0094\3\2\2\2\u02d5\u02d6"+ - "\7v\2\2\u02d6\u02d7\7k\2\2\u02d7\u02d8\7o\2\2\u02d8\u02d9\7g\2\2\u02d9"+ - "\u0096\3\2\2\2\u02da\u02db\7c\2\2\u02db\u02dc\7p\2\2\u02dc\u02dd\7{\2"+ - "\2\u02dd\u02de\7W\2\2\u02de\u02df\7T\2\2\u02df\u02e0\7K\2\2\u02e0\u0098"+ - "\3\2\2\2\u02e1\u02e2\7c\2\2\u02e2\u02e3\7v\2\2\u02e3\u02e4\7q\2\2\u02e4"+ - "\u02e5\7o\2\2\u02e5\u02e6\7k\2\2\u02e6\u02e7\7e\2\2\u02e7\u009a\3\2\2"+ - "\2\u02e8\u02e9\7h\2\2\u02e9\u02ea\7q\2\2\u02ea\u02eb\7t\2\2\u02eb\u009c"+ - "\3\2\2\2\u02ec\u02ed\7n\2\2\u02ed\u02ee\7g\2\2\u02ee\u02ef\7v\2\2\u02ef"+ - "\u009e\3\2\2\2\u02f0\u02f1\7y\2\2\u02f1\u02f2\7j\2\2\u02f2\u02f3\7g\2"+ - "\2\u02f3\u02f4\7t\2\2\u02f4\u02f5\7g\2\2\u02f5\u00a0\3\2\2\2\u02f6\u02f7"+ - "\7i\2\2\u02f7\u02f8\7t\2\2\u02f8\u02f9\7q\2\2\u02f9\u02fa\7w\2\2\u02fa"+ - "\u02fb\7r\2\2\u02fb\u00a2\3\2\2\2\u02fc\u02fd\7d\2\2\u02fd\u02fe\7{\2"+ - "\2\u02fe\u00a4\3\2\2\2\u02ff\u0300\7q\2\2\u0300\u0301\7t\2\2\u0301\u0302"+ - "\7f\2\2\u0302\u0303\7g\2\2\u0303\u0304\7t\2\2\u0304\u00a6\3\2\2\2\u0305"+ - "\u0306\7t\2\2\u0306\u0307\7g\2\2\u0307\u0308\7v\2\2\u0308\u0309\7w\2\2"+ - "\u0309\u030a\7t\2\2\u030a\u030b\7p\2\2\u030b\u00a8\3\2\2\2\u030c\u030d"+ - "\7k\2\2\u030d\u030e\7h\2\2\u030e\u00aa\3\2\2\2\u030f\u0310\7k\2\2\u0310"+ - "\u0311\7p\2\2\u0311\u00ac\3\2\2\2\u0312\u0313\7c\2\2\u0313\u0314\7u\2"+ - "\2\u0314\u00ae\3\2\2\2\u0315\u0316\7c\2\2\u0316\u0317\7v\2\2\u0317\u00b0"+ - "\3\2\2\2\u0318\u0319\7c\2\2\u0319\u031a\7n\2\2\u031a\u031b\7n\2\2\u031b"+ - "\u031c\7q\2\2\u031c\u031d\7y\2\2\u031d\u031e\7k\2\2\u031e\u031f\7p\2\2"+ - "\u031f\u0320\7i\2\2\u0320\u00b2\3\2\2\2\u0321\u0322\7g\2\2\u0322\u0323"+ - "\7o\2\2\u0323\u0324\7r\2\2\u0324\u0325\7v\2\2\u0325\u0326\7{\2\2\u0326"+ - "\u00b4\3\2\2\2\u0327\u0328\7e\2\2\u0328\u0329\7q\2\2\u0329\u032a\7w\2"+ - "\2\u032a\u032b\7p\2\2\u032b\u032c\7v\2\2\u032c\u00b6\3\2\2\2\u032d\u032e"+ - "\7u\2\2\u032e\u032f\7v\2\2\u032f\u0330\7c\2\2\u0330\u0331\7d\2\2\u0331"+ - "\u0332\7n\2\2\u0332\u0333\7g\2\2\u0333\u00b8\3\2\2\2\u0334\u0335\7c\2"+ - "\2\u0335\u0336\7u\2\2\u0336\u0337\7e\2\2\u0337\u0338\7g\2\2\u0338\u0339"+ - "\7p\2\2\u0339\u033a\7f\2\2\u033a\u033b\7k\2\2\u033b\u033c\7p\2\2\u033c"+ - "\u033d\7i\2\2\u033d\u00ba\3\2\2\2\u033e\u033f\7f\2\2\u033f\u0340\7g\2"+ - "\2\u0340\u0341\7u\2\2\u0341\u0342\7e\2\2\u0342\u0343\7g\2\2\u0343\u0344"+ - "\7p\2\2\u0344\u0345\7f\2\2\u0345\u0346\7k\2\2\u0346\u0347\7p\2\2\u0347"+ - "\u0348\7i\2\2\u0348\u00bc\3\2\2\2\u0349\u034a\7u\2\2\u034a\u034b\7q\2"+ - "\2\u034b\u034c\7o\2\2\u034c\u034d\7g\2\2\u034d\u00be\3\2\2\2\u034e\u034f"+ - "\7g\2\2\u034f\u0350\7x\2\2\u0350\u0351\7g\2\2\u0351\u0352\7t\2\2\u0352"+ - "\u0353\7{\2\2\u0353\u00c0\3\2\2\2\u0354\u0355\7u\2\2\u0355\u0356\7c\2"+ - "\2\u0356\u0357\7v\2\2\u0357\u0358\7k\2\2\u0358\u0359\7u\2\2\u0359\u035a"+ - "\7h\2\2\u035a\u035b\7k\2\2\u035b\u035c\7g\2\2\u035c\u035d\7u\2\2\u035d"+ - "\u00c2\3\2\2\2\u035e\u035f\7e\2\2\u035f\u0360\7q\2\2\u0360\u0361\7n\2"+ - "\2\u0361\u0362\7n\2\2\u0362\u0363\7c\2\2\u0363\u0364\7v\2\2\u0364\u0365"+ - "\7k\2\2\u0365\u0366\7q\2\2\u0366\u0367\7p\2\2\u0367\u00c4\3\2\2\2\u0368"+ - "\u0369\7i\2\2\u0369\u036a\7t\2\2\u036a\u036b\7g\2\2\u036b\u036c\7c\2\2"+ - "\u036c\u036d\7v\2\2\u036d\u036e\7g\2\2\u036e\u036f\7u\2\2\u036f\u0370"+ - "\7v\2\2\u0370\u00c6\3\2\2\2\u0371\u0372\7n\2\2\u0372\u0373\7g\2\2\u0373"+ - "\u0374\7c\2\2\u0374\u0375\7u\2\2\u0375\u0376\7v\2\2\u0376\u00c8\3\2\2"+ - "\2\u0377\u0378\7u\2\2\u0378\u0379\7y\2\2\u0379\u037a\7k\2\2\u037a\u037b"+ - "\7v\2\2\u037b\u037c\7e\2\2\u037c\u037d\7j\2\2\u037d\u00ca\3\2\2\2\u037e"+ - "\u037f\7e\2\2\u037f\u0380\7c\2\2\u0380\u0381\7u\2\2\u0381\u0382\7g\2\2"+ - "\u0382\u00cc\3\2\2\2\u0383\u0384\7v\2\2\u0384\u0385\7t\2\2\u0385\u0386"+ - "\7{\2\2\u0386\u00ce\3\2\2\2\u0387\u0388\7e\2\2\u0388\u0389\7c\2\2\u0389"+ - "\u038a\7v\2\2\u038a\u038b\7e\2\2\u038b\u038c\7j\2\2\u038c\u00d0\3\2\2"+ - "\2\u038d\u038e\7f\2\2\u038e\u038f\7g\2\2\u038f\u0390\7h\2\2\u0390\u0391"+ - "\7c\2\2\u0391\u0392\7w\2\2\u0392\u0393\7n\2\2\u0393\u0394\7v\2\2\u0394"+ - "\u00d2\3\2\2\2\u0395\u0396\7v\2\2\u0396\u0397\7j\2\2\u0397\u0398\7g\2"+ - "\2\u0398\u0399\7p\2\2\u0399\u00d4\3\2\2\2\u039a\u039b\7g\2\2\u039b\u039c"+ - "\7n\2\2\u039c\u039d\7u\2\2\u039d\u039e\7g\2\2\u039e\u00d6\3\2\2\2\u039f"+ - "\u03a0\7v\2\2\u03a0\u03a1\7{\2\2\u03a1\u03a2\7r\2\2\u03a2\u03a3\7g\2\2"+ - "\u03a3\u03a4\7u\2\2\u03a4\u03a5\7y\2\2\u03a5\u03a6\7k\2\2\u03a6\u03a7"+ - "\7v\2\2\u03a7\u03a8\7e\2\2\u03a8\u03a9\7j\2\2\u03a9\u00d8\3\2\2\2\u03aa"+ - "\u03ab\7q\2\2\u03ab\u03ac\7t\2\2\u03ac\u00da\3\2\2\2\u03ad\u03ae\7c\2"+ - "\2\u03ae\u03af\7p\2\2\u03af\u03b0\7f\2\2\u03b0\u00dc\3\2\2\2\u03b1\u03b2"+ - "\7p\2\2\u03b2\u03b3\7q\2\2\u03b3\u03b4\7v\2\2\u03b4\u00de\3\2\2\2\u03b5"+ - "\u03b6\7v\2\2\u03b6\u03b7\7q\2\2\u03b7\u00e0\3\2\2\2\u03b8\u03b9\7k\2"+ - "\2\u03b9\u03ba\7p\2\2\u03ba\u03bb\7u\2\2\u03bb\u03bc\7v\2\2\u03bc\u03bd"+ - "\7c\2\2\u03bd\u03be\7p\2\2\u03be\u03bf\7e\2\2\u03bf\u03c0\7g\2\2\u03c0"+ - "\u00e2\3\2\2\2\u03c1\u03c2\7q\2\2\u03c2\u03c3\7h\2\2\u03c3\u00e4\3\2\2"+ - "\2\u03c4\u03c5\7v\2\2\u03c5\u03c6\7t\2\2\u03c6\u03c7\7g\2\2\u03c7\u03c8"+ - "\7c\2\2\u03c8\u03c9\7v\2\2\u03c9\u00e6\3\2\2\2\u03ca\u03cb\7e\2\2\u03cb"+ - "\u03cc\7c\2\2\u03cc\u03cd\7u\2\2\u03cd\u03ce\7v\2\2\u03ce\u00e8\3\2\2"+ - "\2\u03cf\u03d0\7e\2\2\u03d0\u03d1\7c\2\2\u03d1\u03d2\7u\2\2\u03d2\u03d3"+ - "\7v\2\2\u03d3\u03d4\7c\2\2\u03d4\u03d5\7d\2\2\u03d5\u03d6\7n\2\2\u03d6"+ - "\u03d7\7g\2\2\u03d7\u00ea\3\2\2\2\u03d8\u03d9\7x\2\2\u03d9\u03da\7g\2"+ - "\2\u03da\u03db\7t\2\2\u03db\u03dc\7u\2\2\u03dc\u03dd\7k\2\2\u03dd\u03de"+ - "\7q\2\2\u03de\u03df\7p\2\2\u03df\u00ec\3\2\2\2\u03e0\u03e1\7l\2\2\u03e1"+ - "\u03e2\7u\2\2\u03e2\u03e3\7q\2\2\u03e3\u03e4\7p\2\2\u03e4\u03e5\7k\2\2"+ - "\u03e5\u03e6\7s\2\2\u03e6\u00ee\3\2\2\2\u03e7\u03e8\7l\2\2\u03e8\u03e9"+ - "\7u\2\2\u03e9\u03ea\7q\2\2\u03ea\u03eb\7p\2\2\u03eb\u03ec\7/\2\2\u03ec"+ - "\u03ed\7k\2\2\u03ed\u03ee\7v\2\2\u03ee\u03ef\7g\2\2\u03ef\u03f0\7o\2\2"+ - "\u03f0\u00f0\3\2\2\2\u03f1\u03f6\7$\2\2\u03f2\u03f5\5\u00f3z\2\u03f3\u03f5"+ - "\n\2\2\2\u03f4\u03f2\3\2\2\2\u03f4\u03f3\3\2\2\2\u03f5\u03f8\3\2\2\2\u03f6"+ - "\u03f4\3\2\2\2\u03f6\u03f7\3\2\2\2\u03f7\u03f9\3\2\2\2\u03f8\u03f6\3\2"+ - "\2\2\u03f9\u03fa\7$\2\2\u03fa\u00f2\3\2\2\2\u03fb\u03fe\7^\2\2\u03fc\u03ff"+ - "\t\3\2\2\u03fd\u03ff\5\u00f5{\2\u03fe\u03fc\3\2\2\2\u03fe\u03fd\3\2\2"+ - "\2\u03ff\u00f4\3\2\2\2\u0400\u0401\7w\2\2\u0401\u0402\5\u00f7|\2\u0402"+ - "\u0403\5\u00f7|\2\u0403\u0404\5\u00f7|\2\u0404\u0405\5\u00f7|\2\u0405"+ - "\u00f6\3\2\2\2\u0406\u0407\t\4\2\2\u0407\u00f8\3\2\2\2\u0408\u0409\7A"+ - "\2\2\u0409\u00fa\3\2\2\2\u040a\u040b\7p\2\2\u040b\u040c\7w\2\2\u040c\u040d"+ - "\7n\2\2\u040d\u040e\7n\2\2\u040e\u00fc\3\2\2\2\u040f\u0412\5\u00ff\u0080"+ - "\2\u0410\u0412\5\u0101\u0081\2\u0411\u040f\3\2\2\2\u0411\u0410\3\2\2\2"+ - "\u0412\u00fe\3\2\2\2\u0413\u0417\5\u0103\u0082\2\u0414\u0417\5\u0105\u0083"+ - "\2\u0415\u0417\5\u0107\u0084\2\u0416\u0413\3\2\2\2\u0416\u0414\3\2\2\2"+ - "\u0416\u0415\3\2\2\2\u0417\u0100\3\2\2\2\u0418\u0419\7v\2\2\u0419\u041a"+ - "\7t\2\2\u041a\u041b\7w\2\2\u041b\u0422\7g\2\2\u041c\u041d\7h\2\2\u041d"+ - "\u041e\7c\2\2\u041e\u041f\7n\2\2\u041f\u0420\7u\2\2\u0420\u0422\7g\2\2"+ - "\u0421\u0418\3\2\2\2\u0421\u041c\3\2\2\2\u0422\u0102\3\2\2\2\u0423\u0424"+ - "\5\u0109\u0085\2\u0424\u0104\3\2\2\2\u0425\u0426\7\60\2\2\u0426\u0430"+ - "\5\u0109\u0085\2\u0427\u0428\5\u0109\u0085\2\u0428\u042c\7\60\2\2\u0429"+ - "\u042b\t\5\2\2\u042a\u0429\3\2\2\2\u042b\u042e\3\2\2\2\u042c\u042a\3\2"+ - "\2\2\u042c\u042d\3\2\2\2\u042d\u0430\3\2\2\2\u042e\u042c\3\2\2\2\u042f"+ - "\u0425\3\2\2\2\u042f\u0427\3\2\2\2\u0430\u0106\3\2\2\2\u0431\u0432\7\60"+ - "\2\2\u0432\u043e\5\u0109\u0085\2\u0433\u043b\5\u0109\u0085\2\u0434\u0438"+ - "\7\60\2\2\u0435\u0437\t\5\2\2\u0436\u0435\3\2\2\2\u0437\u043a\3\2\2\2"+ - "\u0438\u0436\3\2\2\2\u0438\u0439\3\2\2\2\u0439\u043c\3\2\2\2\u043a\u0438"+ - "\3\2\2\2\u043b\u0434\3\2\2\2\u043b\u043c\3\2\2\2\u043c\u043e\3\2\2\2\u043d"+ - "\u0431\3\2\2\2\u043d\u0433\3\2\2\2\u043e\u043f\3\2\2\2\u043f\u0441\t\6"+ - "\2\2\u0440\u0442\t\7\2\2\u0441\u0440\3\2\2\2\u0441\u0442\3\2\2\2\u0442"+ - "\u0443\3\2\2\2\u0443\u0444\5\u0109\u0085\2\u0444\u0108\3\2\2\2\u0445\u0447"+ - "\t\5\2\2\u0446\u0445\3\2\2\2\u0447\u0448\3\2\2\2\u0448\u0446\3\2\2\2\u0448"+ - "\u0449\3\2\2\2\u0449\u010a\3\2\2\2\u044a\u044b\t\b\2\2\u044b\u044c\3\2"+ - "\2\2\u044c\u044d\b\u0086\2\2\u044d\u010c\3\2\2\2\u044e\u0452\5\u010f\u0088"+ - "\2\u044f\u0451\5\u0111\u0089\2\u0450\u044f\3\2\2\2\u0451\u0454\3\2\2\2"+ - "\u0452\u0450\3\2\2\2\u0452\u0453\3\2\2\2\u0453\u010e\3\2\2\2\u0454\u0452"+ - "\3\2\2\2\u0455\u0457\t\t\2\2\u0456\u0455\3\2\2\2\u0457\u0110\3\2\2\2\u0458"+ - "\u045b\5\u010f\u0088\2\u0459\u045b\t\n\2\2\u045a\u0458\3\2\2\2\u045a\u0459"+ - "\3\2\2\2\u045b\u0112\3\2\2\2\u045c\u045d\7*\2\2\u045d\u0466\7<\2\2\u045e"+ - "\u0465\5\u0113\u008a\2\u045f\u0460\7*\2\2\u0460\u0465\n\13\2\2\u0461\u0462"+ - "\7<\2\2\u0462\u0465\n\f\2\2\u0463\u0465\n\r\2\2\u0464\u045e\3\2\2\2\u0464"+ - "\u045f\3\2\2\2\u0464\u0461\3\2\2\2\u0464\u0463\3\2\2\2\u0465\u0468\3\2"+ - "\2\2\u0466\u0464\3\2\2\2\u0466\u0467\3\2\2\2\u0467\u046a\3\2\2\2\u0468"+ - "\u0466\3\2\2\2\u0469\u046b\7<\2\2\u046a\u0469\3\2\2\2\u046b\u046c\3\2"+ - "\2\2\u046c\u046a\3\2\2\2\u046c\u046d\3\2\2\2\u046d\u046e\3\2\2\2\u046e"+ - "\u046f\7+\2\2\u046f\u0470\3\2\2\2\u0470\u0471\b\u008a\2\2\u0471\u0114"+ - "\3\2\2\2\u0472\u0473\n\16\2\2\u0473\u0116\3\2\2\2\26\2\u03f4\u03f6\u03fe"+ - "\u0411\u0416\u0421\u042c\u042f\u0438\u043b\u043d\u0441\u0448\u0452\u0456"+ - "\u045a\u0464\u0466\u046c\3\2\3\2"; + "\2\2\u0107\3\2\2\2\2\u0109\3\2\2\2\2\u010b\3\2\2\2\2\u010f\3\2\2\2\2\u0111"+ + "\3\2\2\2\2\u0117\3\2\2\2\2\u0119\3\2\2\2\3\u011b\3\2\2\2\5\u011d\3\2\2"+ + "\2\7\u0124\3\2\2\2\t\u012e\3\2\2\2\13\u0130\3\2\2\2\r\u0138\3\2\2\2\17"+ + "\u0141\3\2\2\2\21\u0149\3\2\2\2\23\u0153\3\2\2\2\25\u0162\3\2\2\2\27\u0164"+ + "\3\2\2\2\31\u0176\3\2\2\2\33\u0189\3\2\2\2\35\u0192\3\2\2\2\37\u019d\3"+ + "\2\2\2!\u01a1\3\2\2\2#\u01a9\3\2\2\2%\u01b3\3\2\2\2\'\u01be\3\2\2\2)\u01c4"+ + "\3\2\2\2+\u01d6\3\2\2\2-\u01dd\3\2\2\2/\u01df\3\2\2\2\61\u01e8\3\2\2\2"+ + "\63\u01eb\3\2\2\2\65\u01f4\3\2\2\2\67\u01fd\3\2\2\29\u01ff\3\2\2\2;\u0201"+ + "\3\2\2\2=\u0203\3\2\2\2?\u0205\3\2\2\2A\u0207\3\2\2\2C\u0209\3\2\2\2E"+ + "\u020b\3\2\2\2G\u020e\3\2\2\2I\u0211\3\2\2\2K\u0214\3\2\2\2M\u0217\3\2"+ + "\2\2O\u021a\3\2\2\2Q\u021d\3\2\2\2S\u0220\3\2\2\2U\u0222\3\2\2\2W\u0225"+ + "\3\2\2\2Y\u0227\3\2\2\2[\u022a\3\2\2\2]\u022d\3\2\2\2_\u022f\3\2\2\2a"+ + "\u0231\3\2\2\2c\u0235\3\2\2\2e\u023a\3\2\2\2g\u023e\3\2\2\2i\u0240\3\2"+ + "\2\2k\u0242\3\2\2\2m\u0244\3\2\2\2o\u0246\3\2\2\2q\u0249\3\2\2\2s\u024b"+ + "\3\2\2\2u\u024e\3\2\2\2w\u0251\3\2\2\2y\u0256\3\2\2\2{\u025d\3\2\2\2}"+ + "\u0263\3\2\2\2\177\u026a\3\2\2\2\u0081\u0272\3\2\2\2\u0083\u027a\3\2\2"+ + "\2\u0085\u0281\3\2\2\2\u0087\u0289\3\2\2\2\u0089\u0292\3\2\2\2\u008b\u02a4"+ + "\3\2\2\2\u008d\u02b4\3\2\2\2\u008f\u02be\3\2\2\2\u0091\u02cb\3\2\2\2\u0093"+ + "\u02d4\3\2\2\2\u0095\u02d9\3\2\2\2\u0097\u02de\3\2\2\2\u0099\u02e5\3\2"+ + "\2\2\u009b\u02ec\3\2\2\2\u009d\u02f0\3\2\2\2\u009f\u02f4\3\2\2\2\u00a1"+ + "\u02fa\3\2\2\2\u00a3\u0300\3\2\2\2\u00a5\u0303\3\2\2\2\u00a7\u0309\3\2"+ + "\2\2\u00a9\u0310\3\2\2\2\u00ab\u0313\3\2\2\2\u00ad\u0316\3\2\2\2\u00af"+ + "\u0319\3\2\2\2\u00b1\u031c\3\2\2\2\u00b3\u0325\3\2\2\2\u00b5\u032b\3\2"+ + "\2\2\u00b7\u0331\3\2\2\2\u00b9\u0338\3\2\2\2\u00bb\u0342\3\2\2\2\u00bd"+ + "\u034d\3\2\2\2\u00bf\u0352\3\2\2\2\u00c1\u0358\3\2\2\2\u00c3\u0362\3\2"+ + "\2\2\u00c5\u036c\3\2\2\2\u00c7\u0375\3\2\2\2\u00c9\u037b\3\2\2\2\u00cb"+ + "\u0382\3\2\2\2\u00cd\u0387\3\2\2\2\u00cf\u038b\3\2\2\2\u00d1\u0391\3\2"+ + "\2\2\u00d3\u0399\3\2\2\2\u00d5\u039e\3\2\2\2\u00d7\u03a3\3\2\2\2\u00d9"+ + "\u03ae\3\2\2\2\u00db\u03b1\3\2\2\2\u00dd\u03b5\3\2\2\2\u00df\u03b9\3\2"+ + "\2\2\u00e1\u03bc\3\2\2\2\u00e3\u03c5\3\2\2\2\u00e5\u03c8\3\2\2\2\u00e7"+ + "\u03d3\3\2\2\2\u00e9\u03d6\3\2\2\2\u00eb\u03dc\3\2\2\2\u00ed\u03e1\3\2"+ + "\2\2\u00ef\u03ea\3\2\2\2\u00f1\u03f2\3\2\2\2\u00f3\u03f9\3\2\2\2\u00f5"+ + "\u0403\3\2\2\2\u00f7\u040d\3\2\2\2\u00f9\u0412\3\2\2\2\u00fb\u0418\3\2"+ + "\2\2\u00fd\u041a\3\2\2\2\u00ff\u041c\3\2\2\2\u0101\u0423\3\2\2\2\u0103"+ + "\u0428\3\2\2\2\u0105\u0433\3\2\2\2\u0107\u0435\3\2\2\2\u0109\u0441\3\2"+ + "\2\2\u010b\u044f\3\2\2\2\u010d\u0458\3\2\2\2\u010f\u045c\3\2\2\2\u0111"+ + "\u0460\3\2\2\2\u0113\u0468\3\2\2\2\u0115\u046c\3\2\2\2\u0117\u046e\3\2"+ + "\2\2\u0119\u0484\3\2\2\2\u011b\u011c\7=\2\2\u011c\4\3\2\2\2\u011d\u011e"+ + "\7o\2\2\u011e\u011f\7q\2\2\u011f\u0120\7f\2\2\u0120\u0121\7w\2\2\u0121"+ + "\u0122\7n\2\2\u0122\u0123\7g\2\2\u0123\6\3\2\2\2\u0124\u0125\7p\2\2\u0125"+ + "\u0126\7c\2\2\u0126\u0127\7o\2\2\u0127\u0128\7g\2\2\u0128\u0129\7u\2\2"+ + "\u0129\u012a\7r\2\2\u012a\u012b\7c\2\2\u012b\u012c\7e\2\2\u012c\u012d"+ + "\7g\2\2\u012d\b\3\2\2\2\u012e\u012f\7?\2\2\u012f\n\3\2\2\2\u0130\u0131"+ + "\7f\2\2\u0131\u0132\7g\2\2\u0132\u0133\7e\2\2\u0133\u0134\7n\2\2\u0134"+ + "\u0135\7c\2\2\u0135\u0136\7t\2\2\u0136\u0137\7g\2\2\u0137\f\3\2\2\2\u0138"+ + "\u0139\7q\2\2\u0139\u013a\7t\2\2\u013a\u013b\7f\2\2\u013b\u013c\7g\2\2"+ + "\u013c\u013d\7t\2\2\u013d\u013e\7k\2\2\u013e\u013f\7p\2\2\u013f\u0140"+ + "\7i\2\2\u0140\16\3\2\2\2\u0141\u0142\7q\2\2\u0142\u0143\7t\2\2\u0143\u0144"+ + "\7f\2\2\u0144\u0145\7g\2\2\u0145\u0146\7t\2\2\u0146\u0147\7g\2\2\u0147"+ + "\u0148\7f\2\2\u0148\20\3\2\2\2\u0149\u014a\7w\2\2\u014a\u014b\7p\2\2\u014b"+ + "\u014c\7q\2\2\u014c\u014d\7t\2\2\u014d\u014e\7f\2\2\u014e\u014f\7g\2\2"+ + "\u014f\u0150\7t\2\2\u0150\u0151\7g\2\2\u0151\u0152\7f\2\2\u0152\22\3\2"+ + "\2\2\u0153\u0154\7f\2\2\u0154\u0155\7g\2\2\u0155\u0156\7e\2\2\u0156\u0157"+ + "\7k\2\2\u0157\u0158\7o\2\2\u0158\u0159\7c\2\2\u0159\u015a\7n\2\2\u015a"+ + "\u015b\7/\2\2\u015b\u015c\7h\2\2\u015c\u015d\7q\2\2\u015d\u015e\7t\2\2"+ + "\u015e\u015f\7o\2\2\u015f\u0160\7c\2\2\u0160\u0161\7v\2\2\u0161\24\3\2"+ + "\2\2\u0162\u0163\7<\2\2\u0163\26\3\2\2\2\u0164\u0165\7f\2\2\u0165\u0166"+ + "\7g\2\2\u0166\u0167\7e\2\2\u0167\u0168\7k\2\2\u0168\u0169\7o\2\2\u0169"+ + "\u016a\7c\2\2\u016a\u016b\7n\2\2\u016b\u016c\7/\2\2\u016c\u016d\7u\2\2"+ + "\u016d\u016e\7g\2\2\u016e\u016f\7r\2\2\u016f\u0170\7c\2\2\u0170\u0171"+ + "\7t\2\2\u0171\u0172\7c\2\2\u0172\u0173\7v\2\2\u0173\u0174\7q\2\2\u0174"+ + "\u0175\7t\2\2\u0175\30\3\2\2\2\u0176\u0177\7i\2\2\u0177\u0178\7t\2\2\u0178"+ + "\u0179\7q\2\2\u0179\u017a\7w\2\2\u017a\u017b\7r\2\2\u017b\u017c\7k\2\2"+ + "\u017c\u017d\7p\2\2\u017d\u017e\7i\2\2\u017e\u017f\7/\2\2\u017f\u0180"+ + "\7u\2\2\u0180\u0181\7g\2\2\u0181\u0182\7r\2\2\u0182\u0183\7c\2\2\u0183"+ + "\u0184\7t\2\2\u0184\u0185\7c\2\2\u0185\u0186\7v\2\2\u0186\u0187\7q\2\2"+ + "\u0187\u0188\7t\2\2\u0188\32\3\2\2\2\u0189\u018a\7k\2\2\u018a\u018b\7"+ + "p\2\2\u018b\u018c\7h\2\2\u018c\u018d\7k\2\2\u018d\u018e\7p\2\2\u018e\u018f"+ + "\7k\2\2\u018f\u0190\7v\2\2\u0190\u0191\7{\2\2\u0191\34\3\2\2\2\u0192\u0193"+ + "\7o\2\2\u0193\u0194\7k\2\2\u0194\u0195\7p\2\2\u0195\u0196\7w\2\2\u0196"+ + "\u0197\7u\2\2\u0197\u0198\7/\2\2\u0198\u0199\7u\2\2\u0199\u019a\7k\2\2"+ + "\u019a\u019b\7i\2\2\u019b\u019c\7p\2\2\u019c\36\3\2\2\2\u019d\u019e\7"+ + "P\2\2\u019e\u019f\7c\2\2\u019f\u01a0\7P\2\2\u01a0 \3\2\2\2\u01a1\u01a2"+ + "\7r\2\2\u01a2\u01a3\7g\2\2\u01a3\u01a4\7t\2\2\u01a4\u01a5\7e\2\2\u01a5"+ + "\u01a6\7g\2\2\u01a6\u01a7\7p\2\2\u01a7\u01a8\7v\2\2\u01a8\"\3\2\2\2\u01a9"+ + "\u01aa\7r\2\2\u01aa\u01ab\7g\2\2\u01ab\u01ac\7t\2\2\u01ac\u01ad\7/\2\2"+ + "\u01ad\u01ae\7o\2\2\u01ae\u01af\7k\2\2\u01af\u01b0\7n\2\2\u01b0\u01b1"+ + "\7n\2\2\u01b1\u01b2\7g\2\2\u01b2$\3\2\2\2\u01b3\u01b4\7|\2\2\u01b4\u01b5"+ + "\7g\2\2\u01b5\u01b6\7t\2\2\u01b6\u01b7\7q\2\2\u01b7\u01b8\7/\2\2\u01b8"+ + "\u01b9\7f\2\2\u01b9\u01ba\7k\2\2\u01ba\u01bb\7i\2\2\u01bb\u01bc\7k\2\2"+ + "\u01bc\u01bd\7v\2\2\u01bd&\3\2\2\2\u01be\u01bf\7f\2\2\u01bf\u01c0\7k\2"+ + "\2\u01c0\u01c1\7i\2\2\u01c1\u01c2\7k\2\2\u01c2\u01c3\7v\2\2\u01c3(\3\2"+ + "\2\2\u01c4\u01c5\7r\2\2\u01c5\u01c6\7c\2\2\u01c6\u01c7\7v\2\2\u01c7\u01c8"+ + "\7v\2\2\u01c8\u01c9\7g\2\2\u01c9\u01ca\7t\2\2\u01ca\u01cb\7p\2\2\u01cb"+ + "\u01cc\7/\2\2\u01cc\u01cd\7u\2\2\u01cd\u01ce\7g\2\2\u01ce\u01cf\7r\2\2"+ + "\u01cf\u01d0\7c\2\2\u01d0\u01d1\7t\2\2\u01d1\u01d2\7c\2\2\u01d2\u01d3"+ + "\7v\2\2\u01d3\u01d4\7q\2\2\u01d4\u01d5\7t\2\2\u01d5*\3\2\2\2\u01d6\u01d7"+ + "\7k\2\2\u01d7\u01d8\7o\2\2\u01d8\u01d9\7r\2\2\u01d9\u01da\7q\2\2\u01da"+ + "\u01db\7t\2\2\u01db\u01dc\7v\2\2\u01dc,\3\2\2\2\u01dd\u01de\7.\2\2\u01de"+ + ".\3\2\2\2\u01df\u01e0\7x\2\2\u01e0\u01e1\7c\2\2\u01e1\u01e2\7t\2\2\u01e2"+ + "\u01e3\7k\2\2\u01e3\u01e4\7c\2\2\u01e4\u01e5\7d\2\2\u01e5\u01e6\7n\2\2"+ + "\u01e6\u01e7\7g\2\2\u01e7\60\3\2\2\2\u01e8\u01e9\7<\2\2\u01e9\u01ea\7"+ + "?\2\2\u01ea\62\3\2\2\2\u01eb\u01ec\7g\2\2\u01ec\u01ed\7z\2\2\u01ed\u01ee"+ + "\7v\2\2\u01ee\u01ef\7g\2\2\u01ef\u01f0\7t\2\2\u01f0\u01f1\7p\2\2\u01f1"+ + "\u01f2\7c\2\2\u01f2\u01f3\7n\2\2\u01f3\64\3\2\2\2\u01f4\u01f5\7h\2\2\u01f5"+ + "\u01f6\7w\2\2\u01f6\u01f7\7p\2\2\u01f7\u01f8\7e\2\2\u01f8\u01f9\7v\2\2"+ + "\u01f9\u01fa\7k\2\2\u01fa\u01fb\7q\2\2\u01fb\u01fc\7p\2\2\u01fc\66\3\2"+ + "\2\2\u01fd\u01fe\7*\2\2\u01fe8\3\2\2\2\u01ff\u0200\7+\2\2\u0200:\3\2\2"+ + "\2\u0201\u0202\7}\2\2\u0202<\3\2\2\2\u0203\u0204\7\177\2\2\u0204>\3\2"+ + "\2\2\u0205\u0206\7&\2\2\u0206@\3\2\2\2\u0207\u0208\7~\2\2\u0208B\3\2\2"+ + "\2\u0209\u020a\7,\2\2\u020aD\3\2\2\2\u020b\u020c\7g\2\2\u020c\u020d\7"+ + "s\2\2\u020dF\3\2\2\2\u020e\u020f\7p\2\2\u020f\u0210\7g\2\2\u0210H\3\2"+ + "\2\2\u0211\u0212\7n\2\2\u0212\u0213\7v\2\2\u0213J\3\2\2\2\u0214\u0215"+ + "\7n\2\2\u0215\u0216\7g\2\2\u0216L\3\2\2\2\u0217\u0218\7i\2\2\u0218\u0219"+ + "\7v\2\2\u0219N\3\2\2\2\u021a\u021b\7i\2\2\u021b\u021c\7g\2\2\u021cP\3"+ + "\2\2\2\u021d\u021e\7#\2\2\u021e\u021f\7?\2\2\u021fR\3\2\2\2\u0220\u0221"+ + "\7>\2\2\u0221T\3\2\2\2\u0222\u0223\7>\2\2\u0223\u0224\7?\2\2\u0224V\3"+ + "\2\2\2\u0225\u0226\7@\2\2\u0226X\3\2\2\2\u0227\u0228\7@\2\2\u0228\u0229"+ + "\7?\2\2\u0229Z\3\2\2\2\u022a\u022b\7~\2\2\u022b\u022c\7~\2\2\u022c\\\3"+ + "\2\2\2\u022d\u022e\7-\2\2\u022e^\3\2\2\2\u022f\u0230\7/\2\2\u0230`\3\2"+ + "\2\2\u0231\u0232\7f\2\2\u0232\u0233\7k\2\2\u0233\u0234\7x\2\2\u0234b\3"+ + "\2\2\2\u0235\u0236\7k\2\2\u0236\u0237\7f\2\2\u0237\u0238\7k\2\2\u0238"+ + "\u0239\7x\2\2\u0239d\3\2\2\2\u023a\u023b\7o\2\2\u023b\u023c\7q\2\2\u023c"+ + "\u023d\7f\2\2\u023df\3\2\2\2\u023e\u023f\7#\2\2\u023fh\3\2\2\2\u0240\u0241"+ + "\7]\2\2\u0241j\3\2\2\2\u0242\u0243\7_\2\2\u0243l\3\2\2\2\u0244\u0245\7"+ + "\60\2\2\u0245n\3\2\2\2\u0246\u0247\7&\2\2\u0247\u0248\7&\2\2\u0248p\3"+ + "\2\2\2\u0249\u024a\7%\2\2\u024ar\3\2\2\2\u024b\u024c\7}\2\2\u024c\u024d"+ + "\7~\2\2\u024dt\3\2\2\2\u024e\u024f\7~\2\2\u024f\u0250\7\177\2\2\u0250"+ + "v\3\2\2\2\u0251\u0252\7k\2\2\u0252\u0253\7v\2\2\u0253\u0254\7g\2\2\u0254"+ + "\u0255\7o\2\2\u0255x\3\2\2\2\u0256\u0257\7q\2\2\u0257\u0258\7d\2\2\u0258"+ + "\u0259\7l\2\2\u0259\u025a\7g\2\2\u025a\u025b\7e\2\2\u025b\u025c\7v\2\2"+ + "\u025cz\3\2\2\2\u025d\u025e\7c\2\2\u025e\u025f\7t\2\2\u025f\u0260\7t\2"+ + "\2\u0260\u0261\7c\2\2\u0261\u0262\7{\2\2\u0262|\3\2\2\2\u0263\u0264\7"+ + "u\2\2\u0264\u0265\7v\2\2\u0265\u0266\7t\2\2\u0266\u0267\7k\2\2\u0267\u0268"+ + "\7p\2\2\u0268\u0269\7i\2\2\u0269~\3\2\2\2\u026a\u026b\7k\2\2\u026b\u026c"+ + "\7p\2\2\u026c\u026d\7v\2\2\u026d\u026e\7g\2\2\u026e\u026f\7i\2\2\u026f"+ + "\u0270\7g\2\2\u0270\u0271\7t\2\2\u0271\u0080\3\2\2\2\u0272\u0273\7f\2"+ + "\2\u0273\u0274\7g\2\2\u0274\u0275\7e\2\2\u0275\u0276\7k\2\2\u0276\u0277"+ + "\7o\2\2\u0277\u0278\7c\2\2\u0278\u0279\7n\2\2\u0279\u0082\3\2\2\2\u027a"+ + "\u027b\7f\2\2\u027b\u027c\7q\2\2\u027c\u027d\7w\2\2\u027d\u027e\7d\2\2"+ + "\u027e\u027f\7n\2\2\u027f\u0280\7g\2\2\u0280\u0084\3\2\2\2\u0281\u0282"+ + "\7d\2\2\u0282\u0283\7q\2\2\u0283\u0284\7q\2\2\u0284\u0285\7n\2\2\u0285"+ + "\u0286\7g\2\2\u0286\u0287\7c\2\2\u0287\u0288\7p\2\2\u0288\u0086\3\2\2"+ + "\2\u0289\u028a\7f\2\2\u028a\u028b\7w\2\2\u028b\u028c\7t\2\2\u028c\u028d"+ + "\7c\2\2\u028d\u028e\7v\2\2\u028e\u028f\7k\2\2\u028f\u0290\7q\2\2\u0290"+ + "\u0291\7p\2\2\u0291\u0088\3\2\2\2\u0292\u0293\7{\2\2\u0293\u0294\7g\2"+ + "\2\u0294\u0295\7c\2\2\u0295\u0296\7t\2\2\u0296\u0297\7O\2\2\u0297\u0298"+ + "\7q\2\2\u0298\u0299\7p\2\2\u0299\u029a\7v\2\2\u029a\u029b\7j\2\2\u029b"+ + "\u029c\7F\2\2\u029c\u029d\7w\2\2\u029d\u029e\7t\2\2\u029e\u029f\7c\2\2"+ + "\u029f\u02a0\7v\2\2\u02a0\u02a1\7k\2\2\u02a1\u02a2\7q\2\2\u02a2\u02a3"+ + "\7p\2\2\u02a3\u008a\3\2\2\2\u02a4\u02a5\7f\2\2\u02a5\u02a6\7c\2\2\u02a6"+ + "\u02a7\7{\2\2\u02a7\u02a8\7V\2\2\u02a8\u02a9\7k\2\2\u02a9\u02aa\7o\2\2"+ + "\u02aa\u02ab\7g\2\2\u02ab\u02ac\7F\2\2\u02ac\u02ad\7w\2\2\u02ad\u02ae"+ + "\7t\2\2\u02ae\u02af\7c\2\2\u02af\u02b0\7v\2\2\u02b0\u02b1\7k\2\2\u02b1"+ + "\u02b2\7q\2\2\u02b2\u02b3\7p\2\2\u02b3\u008c\3\2\2\2\u02b4\u02b5\7j\2"+ + "\2\u02b5\u02b6\7g\2\2\u02b6\u02b7\7z\2\2\u02b7\u02b8\7D\2\2\u02b8\u02b9"+ + "\7k\2\2\u02b9\u02ba\7p\2\2\u02ba\u02bb\7c\2\2\u02bb\u02bc\7t\2\2\u02bc"+ + "\u02bd\7{\2\2\u02bd\u008e\3\2\2\2\u02be\u02bf\7d\2\2\u02bf\u02c0\7c\2"+ + "\2\u02c0\u02c1\7u\2\2\u02c1\u02c2\7g\2\2\u02c2\u02c3\78\2\2\u02c3\u02c4"+ + "\7\66\2\2\u02c4\u02c5\7D\2\2\u02c5\u02c6\7k\2\2\u02c6\u02c7\7p\2\2\u02c7"+ + "\u02c8\7c\2\2\u02c8\u02c9\7t\2\2\u02c9\u02ca\7{\2\2\u02ca\u0090\3\2\2"+ + "\2\u02cb\u02cc\7f\2\2\u02cc\u02cd\7c\2\2\u02cd\u02ce\7v\2\2\u02ce\u02cf"+ + "\7g\2\2\u02cf\u02d0\7V\2\2\u02d0\u02d1\7k\2\2\u02d1\u02d2\7o\2\2\u02d2"+ + "\u02d3\7g\2\2\u02d3\u0092\3\2\2\2\u02d4\u02d5\7f\2\2\u02d5\u02d6\7c\2"+ + "\2\u02d6\u02d7\7v\2\2\u02d7\u02d8\7g\2\2\u02d8\u0094\3\2\2\2\u02d9\u02da"+ + "\7v\2\2\u02da\u02db\7k\2\2\u02db\u02dc\7o\2\2\u02dc\u02dd\7g\2\2\u02dd"+ + "\u0096\3\2\2\2\u02de\u02df\7c\2\2\u02df\u02e0\7p\2\2\u02e0\u02e1\7{\2"+ + "\2\u02e1\u02e2\7W\2\2\u02e2\u02e3\7T\2\2\u02e3\u02e4\7K\2\2\u02e4\u0098"+ + "\3\2\2\2\u02e5\u02e6\7c\2\2\u02e6\u02e7\7v\2\2\u02e7\u02e8\7q\2\2\u02e8"+ + "\u02e9\7o\2\2\u02e9\u02ea\7k\2\2\u02ea\u02eb\7e\2\2\u02eb\u009a\3\2\2"+ + "\2\u02ec\u02ed\7h\2\2\u02ed\u02ee\7q\2\2\u02ee\u02ef\7t\2\2\u02ef\u009c"+ + "\3\2\2\2\u02f0\u02f1\7n\2\2\u02f1\u02f2\7g\2\2\u02f2\u02f3\7v\2\2\u02f3"+ + "\u009e\3\2\2\2\u02f4\u02f5\7y\2\2\u02f5\u02f6\7j\2\2\u02f6\u02f7\7g\2"+ + "\2\u02f7\u02f8\7t\2\2\u02f8\u02f9\7g\2\2\u02f9\u00a0\3\2\2\2\u02fa\u02fb"+ + "\7i\2\2\u02fb\u02fc\7t\2\2\u02fc\u02fd\7q\2\2\u02fd\u02fe\7w\2\2\u02fe"+ + "\u02ff\7r\2\2\u02ff\u00a2\3\2\2\2\u0300\u0301\7d\2\2\u0301\u0302\7{\2"+ + "\2\u0302\u00a4\3\2\2\2\u0303\u0304\7q\2\2\u0304\u0305\7t\2\2\u0305\u0306"+ + "\7f\2\2\u0306\u0307\7g\2\2\u0307\u0308\7t\2\2\u0308\u00a6\3\2\2\2\u0309"+ + "\u030a\7t\2\2\u030a\u030b\7g\2\2\u030b\u030c\7v\2\2\u030c\u030d\7w\2\2"+ + "\u030d\u030e\7t\2\2\u030e\u030f\7p\2\2\u030f\u00a8\3\2\2\2\u0310\u0311"+ + "\7k\2\2\u0311\u0312\7h\2\2\u0312\u00aa\3\2\2\2\u0313\u0314\7k\2\2\u0314"+ + "\u0315\7p\2\2\u0315\u00ac\3\2\2\2\u0316\u0317\7c\2\2\u0317\u0318\7u\2"+ + "\2\u0318\u00ae\3\2\2\2\u0319\u031a\7c\2\2\u031a\u031b\7v\2\2\u031b\u00b0"+ + "\3\2\2\2\u031c\u031d\7c\2\2\u031d\u031e\7n\2\2\u031e\u031f\7n\2\2\u031f"+ + "\u0320\7q\2\2\u0320\u0321\7y\2\2\u0321\u0322\7k\2\2\u0322\u0323\7p\2\2"+ + "\u0323\u0324\7i\2\2\u0324\u00b2\3\2\2\2\u0325\u0326\7g\2\2\u0326\u0327"+ + "\7o\2\2\u0327\u0328\7r\2\2\u0328\u0329\7v\2\2\u0329\u032a\7{\2\2\u032a"+ + "\u00b4\3\2\2\2\u032b\u032c\7e\2\2\u032c\u032d\7q\2\2\u032d\u032e\7w\2"+ + "\2\u032e\u032f\7p\2\2\u032f\u0330\7v\2\2\u0330\u00b6\3\2\2\2\u0331\u0332"+ + "\7u\2\2\u0332\u0333\7v\2\2\u0333\u0334\7c\2\2\u0334\u0335\7d\2\2\u0335"+ + "\u0336\7n\2\2\u0336\u0337\7g\2\2\u0337\u00b8\3\2\2\2\u0338\u0339\7c\2"+ + "\2\u0339\u033a\7u\2\2\u033a\u033b\7e\2\2\u033b\u033c\7g\2\2\u033c\u033d"+ + "\7p\2\2\u033d\u033e\7f\2\2\u033e\u033f\7k\2\2\u033f\u0340\7p\2\2\u0340"+ + "\u0341\7i\2\2\u0341\u00ba\3\2\2\2\u0342\u0343\7f\2\2\u0343\u0344\7g\2"+ + "\2\u0344\u0345\7u\2\2\u0345\u0346\7e\2\2\u0346\u0347\7g\2\2\u0347\u0348"+ + "\7p\2\2\u0348\u0349\7f\2\2\u0349\u034a\7k\2\2\u034a\u034b\7p\2\2\u034b"+ + "\u034c\7i\2\2\u034c\u00bc\3\2\2\2\u034d\u034e\7u\2\2\u034e\u034f\7q\2"+ + "\2\u034f\u0350\7o\2\2\u0350\u0351\7g\2\2\u0351\u00be\3\2\2\2\u0352\u0353"+ + "\7g\2\2\u0353\u0354\7x\2\2\u0354\u0355\7g\2\2\u0355\u0356\7t\2\2\u0356"+ + "\u0357\7{\2\2\u0357\u00c0\3\2\2\2\u0358\u0359\7u\2\2\u0359\u035a\7c\2"+ + "\2\u035a\u035b\7v\2\2\u035b\u035c\7k\2\2\u035c\u035d\7u\2\2\u035d\u035e"+ + "\7h\2\2\u035e\u035f\7k\2\2\u035f\u0360\7g\2\2\u0360\u0361\7u\2\2\u0361"+ + "\u00c2\3\2\2\2\u0362\u0363\7e\2\2\u0363\u0364\7q\2\2\u0364\u0365\7n\2"+ + "\2\u0365\u0366\7n\2\2\u0366\u0367\7c\2\2\u0367\u0368\7v\2\2\u0368\u0369"+ + "\7k\2\2\u0369\u036a\7q\2\2\u036a\u036b\7p\2\2\u036b\u00c4\3\2\2\2\u036c"+ + "\u036d\7i\2\2\u036d\u036e\7t\2\2\u036e\u036f\7g\2\2\u036f\u0370\7c\2\2"+ + "\u0370\u0371\7v\2\2\u0371\u0372\7g\2\2\u0372\u0373\7u\2\2\u0373\u0374"+ + "\7v\2\2\u0374\u00c6\3\2\2\2\u0375\u0376\7n\2\2\u0376\u0377\7g\2\2\u0377"+ + "\u0378\7c\2\2\u0378\u0379\7u\2\2\u0379\u037a\7v\2\2\u037a\u00c8\3\2\2"+ + "\2\u037b\u037c\7u\2\2\u037c\u037d\7y\2\2\u037d\u037e\7k\2\2\u037e\u037f"+ + "\7v\2\2\u037f\u0380\7e\2\2\u0380\u0381\7j\2\2\u0381\u00ca\3\2\2\2\u0382"+ + "\u0383\7e\2\2\u0383\u0384\7c\2\2\u0384\u0385\7u\2\2\u0385\u0386\7g\2\2"+ + "\u0386\u00cc\3\2\2\2\u0387\u0388\7v\2\2\u0388\u0389\7t\2\2\u0389\u038a"+ + "\7{\2\2\u038a\u00ce\3\2\2\2\u038b\u038c\7e\2\2\u038c\u038d\7c\2\2\u038d"+ + "\u038e\7v\2\2\u038e\u038f\7e\2\2\u038f\u0390\7j\2\2\u0390\u00d0\3\2\2"+ + "\2\u0391\u0392\7f\2\2\u0392\u0393\7g\2\2\u0393\u0394\7h\2\2\u0394\u0395"+ + "\7c\2\2\u0395\u0396\7w\2\2\u0396\u0397\7n\2\2\u0397\u0398\7v\2\2\u0398"+ + "\u00d2\3\2\2\2\u0399\u039a\7v\2\2\u039a\u039b\7j\2\2\u039b\u039c\7g\2"+ + "\2\u039c\u039d\7p\2\2\u039d\u00d4\3\2\2\2\u039e\u039f\7g\2\2\u039f\u03a0"+ + "\7n\2\2\u03a0\u03a1\7u\2\2\u03a1\u03a2\7g\2\2\u03a2\u00d6\3\2\2\2\u03a3"+ + "\u03a4\7v\2\2\u03a4\u03a5\7{\2\2\u03a5\u03a6\7r\2\2\u03a6\u03a7\7g\2\2"+ + "\u03a7\u03a8\7u\2\2\u03a8\u03a9\7y\2\2\u03a9\u03aa\7k\2\2\u03aa\u03ab"+ + "\7v\2\2\u03ab\u03ac\7e\2\2\u03ac\u03ad\7j\2\2\u03ad\u00d8\3\2\2\2\u03ae"+ + "\u03af\7q\2\2\u03af\u03b0\7t\2\2\u03b0\u00da\3\2\2\2\u03b1\u03b2\7c\2"+ + "\2\u03b2\u03b3\7p\2\2\u03b3\u03b4\7f\2\2\u03b4\u00dc\3\2\2\2\u03b5\u03b6"+ + "\7p\2\2\u03b6\u03b7\7q\2\2\u03b7\u03b8\7v\2\2\u03b8\u00de\3\2\2\2\u03b9"+ + "\u03ba\7v\2\2\u03ba\u03bb\7q\2\2\u03bb\u00e0\3\2\2\2\u03bc\u03bd\7k\2"+ + "\2\u03bd\u03be\7p\2\2\u03be\u03bf\7u\2\2\u03bf\u03c0\7v\2\2\u03c0\u03c1"+ + "\7c\2\2\u03c1\u03c2\7p\2\2\u03c2\u03c3\7e\2\2\u03c3\u03c4\7g\2\2\u03c4"+ + "\u00e2\3\2\2\2\u03c5\u03c6\7q\2\2\u03c6\u03c7\7h\2\2\u03c7\u00e4\3\2\2"+ + "\2\u03c8\u03c9\7u\2\2\u03c9\u03ca\7v\2\2\u03ca\u03cb\7c\2\2\u03cb\u03cc"+ + "\7v\2\2\u03cc\u03cd\7k\2\2\u03cd\u03ce\7e\2\2\u03ce\u03cf\7c\2\2\u03cf"+ + "\u03d0\7n\2\2\u03d0\u03d1\7n\2\2\u03d1\u03d2\7{\2\2\u03d2\u00e6\3\2\2"+ + "\2\u03d3\u03d4\7k\2\2\u03d4\u03d5\7u\2\2\u03d5\u00e8\3\2\2\2\u03d6\u03d7"+ + "\7v\2\2\u03d7\u03d8\7t\2\2\u03d8\u03d9\7g\2\2\u03d9\u03da\7c\2\2\u03da"+ + "\u03db\7v\2\2\u03db\u00ea\3\2\2\2\u03dc\u03dd\7e\2\2\u03dd\u03de\7c\2"+ + "\2\u03de\u03df\7u\2\2\u03df\u03e0\7v\2\2\u03e0\u00ec\3\2\2\2\u03e1\u03e2"+ + "\7e\2\2\u03e2\u03e3\7c\2\2\u03e3\u03e4\7u\2\2\u03e4\u03e5\7v\2\2\u03e5"+ + "\u03e6\7c\2\2\u03e6\u03e7\7d\2\2\u03e7\u03e8\7n\2\2\u03e8\u03e9\7g\2\2"+ + "\u03e9\u00ee\3\2\2\2\u03ea\u03eb\7x\2\2\u03eb\u03ec\7g\2\2\u03ec\u03ed"+ + "\7t\2\2\u03ed\u03ee\7u\2\2\u03ee\u03ef\7k\2\2\u03ef\u03f0\7q\2\2\u03f0"+ + "\u03f1\7p\2\2\u03f1\u00f0\3\2\2\2\u03f2\u03f3\7l\2\2\u03f3\u03f4\7u\2"+ + "\2\u03f4\u03f5\7q\2\2\u03f5\u03f6\7p\2\2\u03f6\u03f7\7k\2\2\u03f7\u03f8"+ + "\7s\2\2\u03f8\u00f2\3\2\2\2\u03f9\u03fa\7l\2\2\u03fa\u03fb\7u\2\2\u03fb"+ + "\u03fc\7q\2\2\u03fc\u03fd\7p\2\2\u03fd\u03fe\7/\2\2\u03fe\u03ff\7k\2\2"+ + "\u03ff\u0400\7v\2\2\u0400\u0401\7g\2\2\u0401\u0402\7o\2\2\u0402\u00f4"+ + "\3\2\2\2\u0403\u0408\7$\2\2\u0404\u0407\5\u00f7|\2\u0405\u0407\n\2\2\2"+ + "\u0406\u0404\3\2\2\2\u0406\u0405\3\2\2\2\u0407\u040a\3\2\2\2\u0408\u0406"+ + "\3\2\2\2\u0408\u0409\3\2\2\2\u0409\u040b\3\2\2\2\u040a\u0408\3\2\2\2\u040b"+ + "\u040c\7$\2\2\u040c\u00f6\3\2\2\2\u040d\u0410\7^\2\2\u040e\u0411\t\3\2"+ + "\2\u040f\u0411\5\u00f9}\2\u0410\u040e\3\2\2\2\u0410\u040f\3\2\2\2\u0411"+ + "\u00f8\3\2\2\2\u0412\u0413\7w\2\2\u0413\u0414\5\u00fb~\2\u0414\u0415\5"+ + "\u00fb~\2\u0415\u0416\5\u00fb~\2\u0416\u0417\5\u00fb~\2\u0417\u00fa\3"+ + "\2\2\2\u0418\u0419\t\4\2\2\u0419\u00fc\3\2\2\2\u041a\u041b\7A\2\2\u041b"+ + "\u00fe\3\2\2\2\u041c\u041d\7p\2\2\u041d\u041e\7w\2\2\u041e\u041f\7n\2"+ + "\2\u041f\u0420\7n\2\2\u0420\u0100\3\2\2\2\u0421\u0424\5\u0103\u0082\2"+ + "\u0422\u0424\5\u0105\u0083\2\u0423\u0421\3\2\2\2\u0423\u0422\3\2\2\2\u0424"+ + "\u0102\3\2\2\2\u0425\u0429\5\u0107\u0084\2\u0426\u0429\5\u0109\u0085\2"+ + "\u0427\u0429\5\u010b\u0086\2\u0428\u0425\3\2\2\2\u0428\u0426\3\2\2\2\u0428"+ + "\u0427\3\2\2\2\u0429\u0104\3\2\2\2\u042a\u042b\7v\2\2\u042b\u042c\7t\2"+ + "\2\u042c\u042d\7w\2\2\u042d\u0434\7g\2\2\u042e\u042f\7h\2\2\u042f\u0430"+ + "\7c\2\2\u0430\u0431\7n\2\2\u0431\u0432\7u\2\2\u0432\u0434\7g\2\2\u0433"+ + "\u042a\3\2\2\2\u0433\u042e\3\2\2\2\u0434\u0106\3\2\2\2\u0435\u0436\5\u010d"+ + "\u0087\2\u0436\u0108\3\2\2\2\u0437\u0438\7\60\2\2\u0438\u0442\5\u010d"+ + "\u0087\2\u0439\u043a\5\u010d\u0087\2\u043a\u043e\7\60\2\2\u043b\u043d"+ + "\t\5\2\2\u043c\u043b\3\2\2\2\u043d\u0440\3\2\2\2\u043e\u043c\3\2\2\2\u043e"+ + "\u043f\3\2\2\2\u043f\u0442\3\2\2\2\u0440\u043e\3\2\2\2\u0441\u0437\3\2"+ + "\2\2\u0441\u0439\3\2\2\2\u0442\u010a\3\2\2\2\u0443\u0444\7\60\2\2\u0444"+ + "\u0450\5\u010d\u0087\2\u0445\u044d\5\u010d\u0087\2\u0446\u044a\7\60\2"+ + "\2\u0447\u0449\t\5\2\2\u0448\u0447\3\2\2\2\u0449\u044c\3\2\2\2\u044a\u0448"+ + "\3\2\2\2\u044a\u044b\3\2\2\2\u044b\u044e\3\2\2\2\u044c\u044a\3\2\2\2\u044d"+ + "\u0446\3\2\2\2\u044d\u044e\3\2\2\2\u044e\u0450\3\2\2\2\u044f\u0443\3\2"+ + "\2\2\u044f\u0445\3\2\2\2\u0450\u0451\3\2\2\2\u0451\u0453\t\6\2\2\u0452"+ + "\u0454\t\7\2\2\u0453\u0452\3\2\2\2\u0453\u0454\3\2\2\2\u0454\u0455\3\2"+ + "\2\2\u0455\u0456\5\u010d\u0087\2\u0456\u010c\3\2\2\2\u0457\u0459\t\5\2"+ + "\2\u0458\u0457\3\2\2\2\u0459\u045a\3\2\2\2\u045a\u0458\3\2\2\2\u045a\u045b"+ + "\3\2\2\2\u045b\u010e\3\2\2\2\u045c\u045d\t\b\2\2\u045d\u045e\3\2\2\2\u045e"+ + "\u045f\b\u0088\2\2\u045f\u0110\3\2\2\2\u0460\u0464\5\u0113\u008a\2\u0461"+ + "\u0463\5\u0115\u008b\2\u0462\u0461\3\2\2\2\u0463\u0466\3\2\2\2\u0464\u0462"+ + "\3\2\2\2\u0464\u0465\3\2\2\2\u0465\u0112\3\2\2\2\u0466\u0464\3\2\2\2\u0467"+ + "\u0469\t\t\2\2\u0468\u0467\3\2\2\2\u0469\u0114\3\2\2\2\u046a\u046d\5\u0113"+ + "\u008a\2\u046b\u046d\t\n\2\2\u046c\u046a\3\2\2\2\u046c\u046b\3\2\2\2\u046d"+ + "\u0116\3\2\2\2\u046e\u046f\7*\2\2\u046f\u0478\7<\2\2\u0470\u0477\5\u0117"+ + "\u008c\2\u0471\u0472\7*\2\2\u0472\u0477\n\13\2\2\u0473\u0474\7<\2\2\u0474"+ + "\u0477\n\f\2\2\u0475\u0477\n\r\2\2\u0476\u0470\3\2\2\2\u0476\u0471\3\2"+ + "\2\2\u0476\u0473\3\2\2\2\u0476\u0475\3\2\2\2\u0477\u047a\3\2\2\2\u0478"+ + "\u0476\3\2\2\2\u0478\u0479\3\2\2\2\u0479\u047c\3\2\2\2\u047a\u0478\3\2"+ + "\2\2\u047b\u047d\7<\2\2\u047c\u047b\3\2\2\2\u047d\u047e\3\2\2\2\u047e"+ + "\u047c\3\2\2\2\u047e\u047f\3\2\2\2\u047f\u0480\3\2\2\2\u0480\u0481\7+"+ + "\2\2\u0481\u0482\3\2\2\2\u0482\u0483\b\u008c\2\2\u0483\u0118\3\2\2\2\u0484"+ + "\u0485\n\16\2\2\u0485\u011a\3\2\2\2\26\2\u0406\u0408\u0410\u0423\u0428"+ + "\u0433\u043e\u0441\u044a\u044d\u044f\u0453\u045a\u0464\u0468\u046c\u0476"+ + "\u0478\u047e\3\2\3\2"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/src/main/java/org/rumbledb/parser/JsoniqLexer.tokens b/src/main/java/org/rumbledb/parser/JsoniqLexer.tokens index 315c988809..7e4049a327 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqLexer.tokens +++ b/src/main/java/org/rumbledb/parser/JsoniqLexer.tokens @@ -111,25 +111,27 @@ Knot=110 Kto=111 Kinstance=112 Kof=113 -Ktreat=114 -Kcast=115 -Kcastable=116 -Kversion=117 -Kjsoniq=118 -Kjson=119 -STRING=120 -ArgumentPlaceholder=121 -NullLiteral=122 -Literal=123 -NumericLiteral=124 -BooleanLiteral=125 -IntegerLiteral=126 -DecimalLiteral=127 -DoubleLiteral=128 -WS=129 -NCName=130 -XQComment=131 -ContentChar=132 +Kstatically=114 +Kis=115 +Ktreat=116 +Kcast=117 +Kcastable=118 +Kversion=119 +Kjsoniq=120 +Kjson=121 +STRING=122 +ArgumentPlaceholder=123 +NullLiteral=124 +Literal=125 +NumericLiteral=126 +BooleanLiteral=127 +IntegerLiteral=128 +DecimalLiteral=129 +DoubleLiteral=130 +WS=131 +NCName=132 +XQComment=133 +ContentChar=134 ';'=1 'module'=2 'namespace'=3 @@ -243,11 +245,13 @@ ContentChar=132 'to'=111 'instance'=112 'of'=113 -'treat'=114 -'cast'=115 -'castable'=116 -'version'=117 -'jsoniq'=118 -'json-item'=119 -'?'=121 -'null'=122 +'statically'=114 +'is'=115 +'treat'=116 +'cast'=117 +'castable'=118 +'version'=119 +'jsoniq'=120 +'json-item'=121 +'?'=123 +'null'=124 diff --git a/src/main/java/org/rumbledb/parser/JsoniqParser.java b/src/main/java/org/rumbledb/parser/JsoniqParser.java index 0e9bc78b30..64dd404264 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqParser.java +++ b/src/main/java/org/rumbledb/parser/JsoniqParser.java @@ -46,11 +46,11 @@ public class JsoniqParser extends Parser { Kempty=89, Kcount=90, Kstable=91, Kascending=92, Kdescending=93, Ksome=94, Kevery=95, Ksatisfies=96, Kcollation=97, Kgreatest=98, Kleast=99, Kswitch=100, Kcase=101, Ktry=102, Kcatch=103, Kdefault=104, Kthen=105, Kelse=106, Ktypeswitch=107, - Kor=108, Kand=109, Knot=110, Kto=111, Kinstance=112, Kof=113, Ktreat=114, - Kcast=115, Kcastable=116, Kversion=117, Kjsoniq=118, Kjson=119, STRING=120, - ArgumentPlaceholder=121, NullLiteral=122, Literal=123, NumericLiteral=124, - BooleanLiteral=125, IntegerLiteral=126, DecimalLiteral=127, DoubleLiteral=128, - WS=129, NCName=130, XQComment=131, ContentChar=132, Kstatically=133, Kis=134; + Kor=108, Kand=109, Knot=110, Kto=111, Kinstance=112, Kof=113, Kstatically=114, + Kis=115, Ktreat=116, Kcast=117, Kcastable=118, Kversion=119, Kjsoniq=120, + Kjson=121, STRING=122, ArgumentPlaceholder=123, NullLiteral=124, Literal=125, + NumericLiteral=126, BooleanLiteral=127, IntegerLiteral=128, DecimalLiteral=129, + DoubleLiteral=130, WS=131, NCName=132, XQComment=133, ContentChar=134; public static final int RULE_moduleAndThisIsIt = 0, RULE_module = 1, RULE_mainModule = 2, RULE_libraryModule = 3, RULE_prolog = 4, RULE_setter = 5, RULE_namespaceDecl = 6, RULE_annotatedDecl = 7, @@ -124,8 +124,9 @@ public class JsoniqParser extends Parser { "'stable'", "'ascending'", "'descending'", "'some'", "'every'", "'satisfies'", "'collation'", "'greatest'", "'least'", "'switch'", "'case'", "'try'", "'catch'", "'default'", "'then'", "'else'", "'typeswitch'", "'or'", "'and'", - "'not'", "'to'", "'instance'", "'of'", "'treat'", "'cast'", "'castable'", - "'version'", "'jsoniq'", "'json-item'", null, "'?'", "'null'" + "'not'", "'to'", "'instance'", "'of'", "'statically'", "'is'", "'treat'", + "'cast'", "'castable'", "'version'", "'jsoniq'", "'json-item'", null, + "'?'", "'null'" }; private static final String[] _SYMBOLIC_NAMES = { null, null, null, null, null, null, null, null, null, null, null, null, @@ -139,10 +140,10 @@ public class JsoniqParser extends Parser { "Kcount", "Kstable", "Kascending", "Kdescending", "Ksome", "Kevery", "Ksatisfies", "Kcollation", "Kgreatest", "Kleast", "Kswitch", "Kcase", "Ktry", "Kcatch", "Kdefault", "Kthen", "Kelse", "Ktypeswitch", "Kor", "Kand", "Knot", "Kto", - "Kinstance", "Kof", "Ktreat", "Kcast", "Kcastable", "Kversion", "Kjsoniq", - "Kjson", "STRING", "ArgumentPlaceholder", "NullLiteral", "Literal", "NumericLiteral", - "BooleanLiteral", "IntegerLiteral", "DecimalLiteral", "DoubleLiteral", - "WS", "NCName", "XQComment", "ContentChar", "Kstatically", "Kis" + "Kinstance", "Kof", "Kstatically", "Kis", "Ktreat", "Kcast", "Kcastable", + "Kversion", "Kjsoniq", "Kjson", "STRING", "ArgumentPlaceholder", "NullLiteral", + "Literal", "NumericLiteral", "BooleanLiteral", "IntegerLiteral", "DecimalLiteral", + "DoubleLiteral", "WS", "NCName", "XQComment", "ContentChar" }; public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); @@ -352,6 +353,8 @@ public final ModuleContext module() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -1081,6 +1084,8 @@ public final QnameContext qname() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -1160,6 +1165,8 @@ public final QnameContext qname() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -3378,6 +3385,8 @@ public final CatchClauseContext catchClause() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -3463,6 +3472,8 @@ public final CatchClauseContext catchClause() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -4118,7 +4129,6 @@ public T accept(ParseTreeVisitor visitor) { public final StaticallyIsExprContext staticallyIsExpr() throws RecognitionException { StaticallyIsExprContext _localctx = new StaticallyIsExprContext(_ctx, getState()); enterRule(_localctx, 100, RULE_staticallyIsExpr); - int _la; try { enterOuterAlt(_localctx, 1); { @@ -4126,8 +4136,8 @@ public final StaticallyIsExprContext staticallyIsExpr() throws RecognitionExcept ((StaticallyIsExprContext)_localctx).main_expr = treatExpr(); setState(692); _errHandler.sync(this); - _la = _input.LA(1); - if (_la==Kstatically) { + switch ( getInterpreter().adaptivePredict(_input,66,_ctx) ) { + case 1: { setState(689); match(Kstatically); @@ -4136,8 +4146,8 @@ public final StaticallyIsExprContext staticallyIsExpr() throws RecognitionExcept setState(691); ((StaticallyIsExprContext)_localctx).seq = sequenceType(); } + break; } - } } catch (RecognitionException re) { @@ -4836,6 +4846,8 @@ public final ObjectLookupContext objectLookup() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -5126,7 +5138,7 @@ public final ParenthesizedExprContext parenthesizedExpr() throws RecognitionExce setState(791); _errHandler.sync(this); _la = _input.LA(1); - if (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { + if (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Kstatically - 71)) | (1L << (Kis - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { { setState(790); expr(); @@ -5339,7 +5351,7 @@ public final ArgumentListContext argumentList() throws RecognitionException { setState(817); _errHandler.sync(this); _la = _input.LA(1); - while (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (ArgumentPlaceholder - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { + while (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Kstatically - 71)) | (1L << (Kis - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (ArgumentPlaceholder - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { { { setState(811); @@ -5461,6 +5473,8 @@ public final ArgumentContext argument() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -5575,6 +5589,8 @@ public final FunctionItemExprContext functionItemExpr() throws RecognitionExcept case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -5735,7 +5751,7 @@ public final InlineFunctionExprContext inlineFunctionExpr() throws RecognitionEx public static class SequenceTypeContext extends ParserRuleContext { public ItemTypeContext item; - public Token s121; + public Token s123; public List question = new ArrayList(); public Token s33; public List star = new ArrayList(); @@ -5801,8 +5817,8 @@ public final SequenceTypeContext sequenceType() throws RecognitionException { case 1: { setState(851); - ((SequenceTypeContext)_localctx).s121 = match(ArgumentPlaceholder); - ((SequenceTypeContext)_localctx).question.add(((SequenceTypeContext)_localctx).s121); + ((SequenceTypeContext)_localctx).s123 = match(ArgumentPlaceholder); + ((SequenceTypeContext)_localctx).question.add(((SequenceTypeContext)_localctx).s123); } break; case 2: @@ -5876,7 +5892,7 @@ public final ObjectConstructorContext objectConstructor() throws RecognitionExce setState(867); _errHandler.sync(this); _la = _input.LA(1); - if (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { + if (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Kstatically - 71)) | (1L << (Kis - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { { setState(859); pairConstructor(); @@ -6689,7 +6705,7 @@ public final TypesKeywordsContext typesKeywords() throws RecognitionException { public static class SingleTypeContext extends ParserRuleContext { public AtomicTypeContext item; - public Token s121; + public Token s123; public List question = new ArrayList(); public AtomicTypeContext atomicType() { return getRuleContext(AtomicTypeContext.class,0); @@ -6719,8 +6735,8 @@ public final SingleTypeContext singleType() throws RecognitionException { case 1: { setState(928); - ((SingleTypeContext)_localctx).s121 = match(ArgumentPlaceholder); - ((SingleTypeContext)_localctx).question.add(((SingleTypeContext)_localctx).s121); + ((SingleTypeContext)_localctx).s123 = match(ArgumentPlaceholder); + ((SingleTypeContext)_localctx).question.add(((SingleTypeContext)_localctx).s123); } break; } @@ -6971,7 +6987,7 @@ public final ArrayConstructorContext arrayConstructor() throws RecognitionExcept setState(949); _errHandler.sync(this); _la = _input.LA(1); - if (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { + if (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Kstatically - 71)) | (1L << (Kis - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { { setState(948); expr(); @@ -7074,6 +7090,8 @@ public static class KeyWordsContext extends ParserRuleContext { public TerminalNode Kto() { return getToken(JsoniqParser.Kto, 0); } public TerminalNode Kinstance() { return getToken(JsoniqParser.Kinstance, 0); } public TerminalNode Kof() { return getToken(JsoniqParser.Kof, 0); } + public TerminalNode Kstatically() { return getToken(JsoniqParser.Kstatically, 0); } + public TerminalNode Kis() { return getToken(JsoniqParser.Kis, 0); } public TerminalNode Ktreat() { return getToken(JsoniqParser.Ktreat, 0); } public TerminalNode Kcast() { return getToken(JsoniqParser.Kcast, 0); } public TerminalNode Kcastable() { return getToken(JsoniqParser.Kcastable, 0); } @@ -7127,7 +7145,7 @@ public final KeyWordsContext keyWords() throws RecognitionException { { setState(957); _la = _input.LA(1); - if ( !(((((_la - 77)) & ~0x3f) == 0 && ((1L << (_la - 77)) & ((1L << (Kfor - 77)) | (1L << (Klet - 77)) | (1L << (Kwhere - 77)) | (1L << (Kgroup - 77)) | (1L << (Kby - 77)) | (1L << (Korder - 77)) | (1L << (Kreturn - 77)) | (1L << (Kif - 77)) | (1L << (Kin - 77)) | (1L << (Kas - 77)) | (1L << (Kat - 77)) | (1L << (Kallowing - 77)) | (1L << (Kempty - 77)) | (1L << (Kcount - 77)) | (1L << (Kstable - 77)) | (1L << (Kascending - 77)) | (1L << (Kdescending - 77)) | (1L << (Ksome - 77)) | (1L << (Kevery - 77)) | (1L << (Ksatisfies - 77)) | (1L << (Kcollation - 77)) | (1L << (Kgreatest - 77)) | (1L << (Kleast - 77)) | (1L << (Kswitch - 77)) | (1L << (Kcase - 77)) | (1L << (Ktry - 77)) | (1L << (Kcatch - 77)) | (1L << (Kdefault - 77)) | (1L << (Kthen - 77)) | (1L << (Kelse - 77)) | (1L << (Ktypeswitch - 77)) | (1L << (Kor - 77)) | (1L << (Kand - 77)) | (1L << (Knot - 77)) | (1L << (Kto - 77)) | (1L << (Kinstance - 77)) | (1L << (Kof - 77)) | (1L << (Ktreat - 77)) | (1L << (Kcast - 77)) | (1L << (Kcastable - 77)) | (1L << (Kversion - 77)) | (1L << (Kjsoniq - 77)) | (1L << (Kjson - 77)))) != 0)) ) { + if ( !(((((_la - 77)) & ~0x3f) == 0 && ((1L << (_la - 77)) & ((1L << (Kfor - 77)) | (1L << (Klet - 77)) | (1L << (Kwhere - 77)) | (1L << (Kgroup - 77)) | (1L << (Kby - 77)) | (1L << (Korder - 77)) | (1L << (Kreturn - 77)) | (1L << (Kif - 77)) | (1L << (Kin - 77)) | (1L << (Kas - 77)) | (1L << (Kat - 77)) | (1L << (Kallowing - 77)) | (1L << (Kempty - 77)) | (1L << (Kcount - 77)) | (1L << (Kstable - 77)) | (1L << (Kascending - 77)) | (1L << (Kdescending - 77)) | (1L << (Ksome - 77)) | (1L << (Kevery - 77)) | (1L << (Ksatisfies - 77)) | (1L << (Kcollation - 77)) | (1L << (Kgreatest - 77)) | (1L << (Kleast - 77)) | (1L << (Kswitch - 77)) | (1L << (Kcase - 77)) | (1L << (Ktry - 77)) | (1L << (Kcatch - 77)) | (1L << (Kdefault - 77)) | (1L << (Kthen - 77)) | (1L << (Kelse - 77)) | (1L << (Ktypeswitch - 77)) | (1L << (Kor - 77)) | (1L << (Kand - 77)) | (1L << (Knot - 77)) | (1L << (Kto - 77)) | (1L << (Kinstance - 77)) | (1L << (Kof - 77)) | (1L << (Kstatically - 77)) | (1L << (Kis - 77)) | (1L << (Ktreat - 77)) | (1L << (Kcast - 77)) | (1L << (Kcastable - 77)) | (1L << (Kversion - 77)) | (1L << (Kjsoniq - 77)) | (1L << (Kjson - 77)))) != 0)) ) { _errHandler.recoverInline(this); } else { @@ -7218,8 +7236,8 @@ public final KeyWordsContext keyWords() throws RecognitionException { "\u0084\u0086\u0088\u008a\u008c\u008e\u0090\u0092\u0094\u0096\u0098\u009a"+ "\u009c\u009e\u00a0\u00a2\u00a4\u00a6\u00a8\u00aa\u00ac\u00ae\u00b0\u00b2"+ "\u00b4\u00b6\u00b8\u00ba\u00bc\u00be\u00c0\u00c2\u00c4\u00c6\u00c8\u00ca"+ - "\2\13\3\2\t\n\3\2de\3\2\r\26\4\2\6\6$.\3\2\60\61\4\2##\62\64\4\2>?yy\4"+ - "\2\f\f{{\3\2Oy\2\u03eb\2\u00cc\3\2\2\2\4\u00d4\3\2\2\2\6\u00da\3\2\2\2"+ + "\2\13\3\2\t\n\3\2de\3\2\r\26\4\2\6\6$.\3\2\60\61\4\2##\62\64\4\2>?{{\4"+ + "\2\f\f}}\3\2O{\2\u03eb\2\u00cc\3\2\2\2\4\u00d4\3\2\2\2\6\u00da\3\2\2\2"+ "\b\u00dd\3\2\2\2\n\u00ee\3\2\2\2\f\u00fd\3\2\2\2\16\u00ff\3\2\2\2\20\u0107"+ "\3\2\2\2\22\u0109\3\2\2\2\24\u010e\3\2\2\2\26\u0112\3\2\2\2\30\u0118\3"+ "\2\2\2\32\u012d\3\2\2\2\34\u0133\3\2\2\2\36\u0135\3\2\2\2 \u0148\3\2\2"+ @@ -7245,12 +7263,12 @@ public final KeyWordsContext keyWords() throws RecognitionException { "\2\2\u00be\u03a8\3\2\2\2\u00c0\u03ac\3\2\2\2\u00c2\u03b0\3\2\2\2\u00c4"+ "\u03b5\3\2\2\2\u00c6\u03bb\3\2\2\2\u00c8\u03bd\3\2\2\2\u00ca\u03bf\3\2"+ "\2\2\u00cc\u00cd\5\4\3\2\u00cd\u00ce\7\2\2\3\u00ce\3\3\2\2\2\u00cf\u00d0"+ - "\7x\2\2\u00d0\u00d1\7w\2\2\u00d1\u00d2\5\u00c8e\2\u00d2\u00d3\7\3\2\2"+ + "\7z\2\2\u00d0\u00d1\7y\2\2\u00d1\u00d2\5\u00c8e\2\u00d2\u00d3\7\3\2\2"+ "\u00d3\u00d5\3\2\2\2\u00d4\u00cf\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5\u00d8"+ "\3\2\2\2\u00d6\u00d9\5\b\5\2\u00d7\u00d9\5\6\4\2\u00d8\u00d6\3\2\2\2\u00d8"+ "\u00d7\3\2\2\2\u00d9\5\3\2\2\2\u00da\u00db\5\n\6\2\u00db\u00dc\5(\25\2"+ "\u00dc\7\3\2\2\2\u00dd\u00de\7\4\2\2\u00de\u00df\7\5\2\2\u00df\u00e0\7"+ - "\u0084\2\2\u00e0\u00e1\7\6\2\2\u00e1\u00e2\5\u00c6d\2\u00e2\u00e3\7\3"+ + "\u0086\2\2\u00e0\u00e1\7\6\2\2\u00e1\u00e2\5\u00c6d\2\u00e2\u00e3\7\3"+ "\2\2\u00e3\u00e4\5\n\6\2\u00e4\t\3\2\2\2\u00e5\u00e9\5\f\7\2\u00e6\u00e9"+ "\5\16\b\2\u00e7\u00e9\5\36\20\2\u00e8\u00e5\3\2\2\2\u00e8\u00e6\3\2\2"+ "\2\u00e8\u00e7\3\2\2\2\u00e9\u00ea\3\2\2\2\u00ea\u00eb\7\3\2\2\u00eb\u00ed"+ @@ -7261,7 +7279,7 @@ public final KeyWordsContext keyWords() throws RecognitionException { "\2\u00f8\u00f6\3\2\2\2\u00f9\u00fe\5\22\n\2\u00fa\u00fe\5\24\13\2\u00fb"+ "\u00fe\5\26\f\2\u00fc\u00fe\5\30\r\2\u00fd\u00f9\3\2\2\2\u00fd\u00fa\3"+ "\2\2\2\u00fd\u00fb\3\2\2\2\u00fd\u00fc\3\2\2\2\u00fe\r\3\2\2\2\u00ff\u0100"+ - "\7\7\2\2\u0100\u0101\7\5\2\2\u0101\u0102\7\u0084\2\2\u0102\u0103\7\6\2"+ + "\7\7\2\2\u0100\u0101\7\5\2\2\u0101\u0102\7\u0086\2\2\u0102\u0103\7\6\2"+ "\2\u0103\u0104\5\u00c6d\2\u0104\17\3\2\2\2\u0105\u0108\5\"\22\2\u0106"+ "\u0108\5 \21\2\u0107\u0105\3\2\2\2\u0107\u0106\3\2\2\2\u0108\21\3\2\2"+ "\2\u0109\u010a\7\7\2\2\u010a\u010b\7j\2\2\u010b\u010c\7c\2\2\u010c\u010d"+ @@ -7273,12 +7291,12 @@ public final KeyWordsContext keyWords() throws RecognitionException { "\3\2\2\2\u011e\u0125\3\2\2\2\u011f\u0120\5\34\17\2\u0120\u0121\7\6\2\2"+ "\u0121\u0122\5\u00c8e\2\u0122\u0124\3\2\2\2\u0123\u011f\3\2\2\2\u0124"+ "\u0127\3\2\2\2\u0125\u0123\3\2\2\2\u0125\u0126\3\2\2\2\u0126\31\3\2\2"+ - "\2\u0127\u0125\3\2\2\2\u0128\u012b\7\u0084\2\2\u0129\u012b\5\u00caf\2"+ + "\2\u0127\u0125\3\2\2\2\u0128\u012b\7\u0086\2\2\u0129\u012b\5\u00caf\2"+ "\u012a\u0128\3\2\2\2\u012a\u0129\3\2\2\2\u012b\u012c\3\2\2\2\u012c\u012e"+ "\7\f\2\2\u012d\u012a\3\2\2\2\u012d\u012e\3\2\2\2\u012e\u0131\3\2\2\2\u012f"+ "\u0132\5\u00c0a\2\u0130\u0132\5\u00caf\2\u0131\u012f\3\2\2\2\u0131\u0130"+ "\3\2\2\2\u0132\33\3\2\2\2\u0133\u0134\t\4\2\2\u0134\35\3\2\2\2\u0135\u0136"+ - "\7\27\2\2\u0136\u013a\7\4\2\2\u0137\u0138\7\5\2\2\u0138\u0139\7\u0084"+ + "\7\27\2\2\u0136\u013a\7\4\2\2\u0137\u0138\7\5\2\2\u0138\u0139\7\u0086"+ "\2\2\u0139\u013b\7\6\2\2\u013a\u0137\3\2\2\2\u013a\u013b\3\2\2\2\u013b"+ "\u013c\3\2\2\2\u013c\u0146\5\u00c6d\2\u013d\u013e\7Y\2\2\u013e\u0143\5"+ "\u00c6d\2\u013f\u0140\7\30\2\2\u0140\u0142\5\u00c6d\2\u0141\u013f\3\2"+ @@ -7401,111 +7419,110 @@ public final KeyWordsContext keyWords() throws RecognitionException { "\2\2\u02a8\u02ab\3\2\2\2\u02a9\u02a7\3\2\2\2\u02a9\u02aa\3\2\2\2\u02aa"+ "c\3\2\2\2\u02ab\u02a9\3\2\2\2\u02ac\u02b0\5f\64\2\u02ad\u02ae\7r\2\2\u02ae"+ "\u02af\7s\2\2\u02af\u02b1\5\u0096L\2\u02b0\u02ad\3\2\2\2\u02b0\u02b1\3"+ - "\2\2\2\u02b1e\3\2\2\2\u02b2\u02b6\5h\65\2\u02b3\u02b4\7\u0087\2\2\u02b4"+ - "\u02b5\7\u0088\2\2\u02b5\u02b7\5\u0096L\2\u02b6\u02b3\3\2\2\2\u02b6\u02b7"+ - "\3\2\2\2\u02b7g\3\2\2\2\u02b8\u02bc\5j\66\2\u02b9\u02ba\7t\2\2\u02ba\u02bb"+ - "\7X\2\2\u02bb\u02bd\5\u0096L\2\u02bc\u02b9\3\2\2\2\u02bc\u02bd\3\2\2\2"+ - "\u02bdi\3\2\2\2\u02be\u02c2\5l\67\2\u02bf\u02c0\7v\2\2\u02c0\u02c1\7X"+ - "\2\2\u02c1\u02c3\5\u00bc_\2\u02c2\u02bf\3\2\2\2\u02c2\u02c3\3\2\2\2\u02c3"+ - "k\3\2\2\2\u02c4\u02c8\5n8\2\u02c5\u02c6\7u\2\2\u02c6\u02c7\7X\2\2\u02c7"+ - "\u02c9\5\u00bc_\2\u02c8\u02c5\3\2\2\2\u02c8\u02c9\3\2\2\2\u02c9m\3\2\2"+ - "\2\u02ca\u02d1\5p9\2\u02cb\u02cc\7\6\2\2\u02cc\u02cd\7-\2\2\u02cd\u02ce"+ - "\3\2\2\2\u02ce\u02d0\5\u008aF\2\u02cf\u02cb\3\2\2\2\u02d0\u02d3\3\2\2"+ - "\2\u02d1\u02cf\3\2\2\2\u02d1\u02d2\3\2\2\2\u02d2o\3\2\2\2\u02d3\u02d1"+ - "\3\2\2\2\u02d4\u02d6\t\6\2\2\u02d5\u02d4\3\2\2\2\u02d6\u02d9\3\2\2\2\u02d7"+ - "\u02d5\3\2\2\2\u02d7\u02d8\3\2\2\2\u02d8\u02da\3\2\2\2\u02d9\u02d7\3\2"+ - "\2\2\u02da\u02db\5r:\2\u02dbq\3\2\2\2\u02dc\u02e1\5t;\2\u02dd\u02de\7"+ - "\65\2\2\u02de\u02e0\5t;\2\u02df\u02dd\3\2\2\2\u02e0\u02e3\3\2\2\2\u02e1"+ - "\u02df\3\2\2\2\u02e1\u02e2\3\2\2\2\u02e2s\3\2\2\2\u02e3\u02e1\3\2\2\2"+ - "\u02e4\u02ec\5~@\2\u02e5\u02eb\5v<\2\u02e6\u02eb\5z>\2\u02e7\u02eb\5|"+ - "?\2\u02e8\u02eb\5x=\2\u02e9\u02eb\5\u008cG\2\u02ea\u02e5\3\2\2\2\u02ea"+ - "\u02e6\3\2\2\2\u02ea\u02e7\3\2\2\2\u02ea\u02e8\3\2\2\2\u02ea\u02e9\3\2"+ - "\2\2\u02eb\u02ee\3\2\2\2\u02ec\u02ea\3\2\2\2\u02ec\u02ed\3\2\2\2\u02ed"+ - "u\3\2\2\2\u02ee\u02ec\3\2\2\2\u02ef\u02f0\7\66\2\2\u02f0\u02f1\7\66\2"+ - "\2\u02f1\u02f2\5(\25\2\u02f2\u02f3\7\67\2\2\u02f3\u02f4\7\67\2\2\u02f4"+ - "w\3\2\2\2\u02f5\u02f6\7\66\2\2\u02f6\u02f7\7\67\2\2\u02f7y\3\2\2\2\u02f8"+ - "\u02f9\7\66\2\2\u02f9\u02fa\5(\25\2\u02fa\u02fb\7\67\2\2\u02fb{\3\2\2"+ - "\2\u02fc\u0304\78\2\2\u02fd\u0305\5\u00caf\2\u02fe\u0305\5\u00c8e\2\u02ff"+ - "\u0305\7\u0084\2\2\u0300\u0305\5\u0082B\2\u0301\u0305\5\u0080A\2\u0302"+ - "\u0305\5\u0084C\2\u0303\u0305\5\u00ba^\2\u0304\u02fd\3\2\2\2\u0304\u02fe"+ - "\3\2\2\2\u0304\u02ff\3\2\2\2\u0304\u0300\3\2\2\2\u0304\u0301\3\2\2\2\u0304"+ - "\u0302\3\2\2\2\u0304\u0303\3\2\2\2\u0305}\3\2\2\2\u0306\u0313\7|\2\2\u0307"+ - "\u0313\7}\2\2\u0308\u0313\5\u00c8e\2\u0309\u0313\5\u0080A\2\u030a\u0313"+ - "\5\u0082B\2\u030b\u0313\5\u0084C\2\u030c\u0313\5\u0098M\2\u030d\u0313"+ - "\5\u008aF\2\u030e\u0313\5\u0086D\2\u030f\u0313\5\u0088E\2\u0310\u0313"+ - "\5\u00c4c\2\u0311\u0313\5\u0090I\2\u0312\u0306\3\2\2\2\u0312\u0307\3\2"+ - "\2\2\u0312\u0308\3\2\2\2\u0312\u0309\3\2\2\2\u0312\u030a\3\2\2\2\u0312"+ - "\u030b\3\2\2\2\u0312\u030c\3\2\2\2\u0312\u030d\3\2\2\2\u0312\u030e\3\2"+ - "\2\2\u0312\u030f\3\2\2\2\u0312\u0310\3\2\2\2\u0312\u0311\3\2\2\2\u0313"+ - "\177\3\2\2\2\u0314\u0315\7!\2\2\u0315\u0316\5\32\16\2\u0316\u0081\3\2"+ - "\2\2\u0317\u0319\7\35\2\2\u0318\u031a\5(\25\2\u0319\u0318\3\2\2\2\u0319"+ - "\u031a\3\2\2\2\u031a\u031b\3\2\2\2\u031b\u031c\7\36\2\2\u031c\u0083\3"+ - "\2\2\2\u031d\u031e\79\2\2\u031e\u0085\3\2\2\2\u031f\u0320\7\t\2\2\u0320"+ - "\u0321\7\37\2\2\u0321\u0322\5(\25\2\u0322\u0323\7 \2\2\u0323\u0087\3\2"+ - "\2\2\u0324\u0325\7\n\2\2\u0325\u0326\7\37\2\2\u0326\u0327\5(\25\2\u0327"+ - "\u0328\7 \2\2\u0328\u0089\3\2\2\2\u0329\u032a\5\32\16\2\u032a\u032b\5"+ - "\u008cG\2\u032b\u008b\3\2\2\2\u032c\u0333\7\35\2\2\u032d\u032f\5\u008e"+ - "H\2\u032e\u0330\7\30\2\2\u032f\u032e\3\2\2\2\u032f\u0330\3\2\2\2\u0330"+ - "\u0332\3\2\2\2\u0331\u032d\3\2\2\2\u0332\u0335\3\2\2\2\u0333\u0331\3\2"+ - "\2\2\u0333\u0334\3\2\2\2\u0334\u0336\3\2\2\2\u0335\u0333\3\2\2\2\u0336"+ - "\u0337\7\36\2\2\u0337\u008d\3\2\2\2\u0338\u033b\5*\26\2\u0339\u033b\7"+ - "{\2\2\u033a\u0338\3\2\2\2\u033a\u0339\3\2\2\2\u033b\u008f\3\2\2\2\u033c"+ - "\u033f\5\u0092J\2\u033d\u033f\5\u0094K\2\u033e\u033c\3\2\2\2\u033e\u033d"+ - "\3\2\2\2\u033f\u0091\3\2\2\2\u0340\u0341\5\32\16\2\u0341\u0342\7:\2\2"+ - "\u0342\u0343\7}\2\2\u0343\u0093\3\2\2\2\u0344\u0345\7\34\2\2\u0345\u0347"+ - "\7\35\2\2\u0346\u0348\5$\23\2\u0347\u0346\3\2\2\2\u0347\u0348\3\2\2\2"+ - "\u0348\u0349\3\2\2\2\u0349\u034c\7\36\2\2\u034a\u034b\7X\2\2\u034b\u034d"+ - "\5\u0096L\2\u034c\u034a\3\2\2\2\u034c\u034d\3\2\2\2\u034d\u034e\3\2\2"+ - "\2\u034e\u034f\7\37\2\2\u034f\u0350\5(\25\2\u0350\u0351\7 \2\2\u0351\u0095"+ - "\3\2\2\2\u0352\u0353\7\35\2\2\u0353\u035b\7\36\2\2\u0354\u0358\5\u009a"+ - "N\2\u0355\u0359\7{\2\2\u0356\u0359\7#\2\2\u0357\u0359\7\60\2\2\u0358\u0355"+ - "\3\2\2\2\u0358\u0356\3\2\2\2\u0358\u0357\3\2\2\2\u0358\u0359\3\2\2\2\u0359"+ - "\u035b\3\2\2\2\u035a\u0352\3\2\2\2\u035a\u0354\3\2\2\2\u035b\u0097\3\2"+ - "\2\2\u035c\u0365\7\37\2\2\u035d\u0362\5\u00c2b\2\u035e\u035f\7\30\2\2"+ - "\u035f\u0361\5\u00c2b\2\u0360\u035e\3\2\2\2\u0361\u0364\3\2\2\2\u0362"+ - "\u0360\3\2\2\2\u0362\u0363\3\2\2\2\u0363\u0366\3\2\2\2\u0364\u0362\3\2"+ - "\2\2\u0365\u035d\3\2\2\2\u0365\u0366\3\2\2\2\u0366\u0367\3\2\2\2\u0367"+ - "\u036d\7 \2\2\u0368\u0369\7;\2\2\u0369\u036a\5(\25\2\u036a\u036b\7<\2"+ - "\2\u036b\u036d\3\2\2\2\u036c\u035c\3\2\2\2\u036c\u0368\3\2\2\2\u036d\u0099"+ - "\3\2\2\2\u036e\u0372\7=\2\2\u036f\u0372\5\u009cO\2\u0370\u0372\5\u00be"+ - "`\2\u0371\u036e\3\2\2\2\u0371\u036f\3\2\2\2\u0371\u0370\3\2\2\2\u0372"+ - "\u009b\3\2\2\2\u0373\u0374\t\b\2\2\u0374\u009d\3\2\2\2\u0375\u0376\7@"+ - "\2\2\u0376\u009f\3\2\2\2\u0377\u0378\7A\2\2\u0378\u00a1\3\2\2\2\u0379"+ - "\u037a\7B\2\2\u037a\u00a3\3\2\2\2\u037b\u037c\7C\2\2\u037c\u00a5\3\2\2"+ - "\2\u037d\u037e\7D\2\2\u037e\u00a7\3\2\2\2\u037f\u0380\7E\2\2\u0380\u00a9"+ - "\3\2\2\2\u0381\u0382\7F\2\2\u0382\u00ab\3\2\2\2\u0383\u0384\7G\2\2\u0384"+ - "\u00ad\3\2\2\2\u0385\u0386\7H\2\2\u0386\u00af\3\2\2\2\u0387\u0388\7I\2"+ - "\2\u0388\u00b1\3\2\2\2\u0389\u038a\7J\2\2\u038a\u00b3\3\2\2\2\u038b\u038c"+ - "\7K\2\2\u038c\u00b5\3\2\2\2\u038d\u038e\7L\2\2\u038e\u00b7\3\2\2\2\u038f"+ - "\u0390\7M\2\2\u0390\u00b9\3\2\2\2\u0391\u03a0\5\u009eP\2\u0392\u03a0\5"+ - "\u00a0Q\2\u0393\u03a0\5\u00a2R\2\u0394\u03a0\5\u00a4S\2\u0395\u03a0\5"+ - "\u00a6T\2\u0396\u03a0\5\u00a8U\2\u0397\u03a0\5\u00aaV\2\u0398\u03a0\5"+ - "\u00acW\2\u0399\u03a0\5\u00b2Z\2\u039a\u03a0\5\u00b4[\2\u039b\u03a0\5"+ - "\u00b6\\\2\u039c\u03a0\5\u00aeX\2\u039d\u03a0\5\u00b0Y\2\u039e\u03a0\5"+ - "\u00b8]\2\u039f\u0391\3\2\2\2\u039f\u0392\3\2\2\2\u039f\u0393\3\2\2\2"+ - "\u039f\u0394\3\2\2\2\u039f\u0395\3\2\2\2\u039f\u0396\3\2\2\2\u039f\u0397"+ - "\3\2\2\2\u039f\u0398\3\2\2\2\u039f\u0399\3\2\2\2\u039f\u039a\3\2\2\2\u039f"+ - "\u039b\3\2\2\2\u039f\u039c\3\2\2\2\u039f\u039d\3\2\2\2\u039f\u039e\3\2"+ - "\2\2\u03a0\u00bb\3\2\2\2\u03a1\u03a3\5\u00be`\2\u03a2\u03a4\7{\2\2\u03a3"+ - "\u03a2\3\2\2\2\u03a3\u03a4\3\2\2\2\u03a4\u00bd\3\2\2\2\u03a5\u03a9\7N"+ - "\2\2\u03a6\u03a9\5\u00ba^\2\u03a7\u03a9\7|\2\2\u03a8\u03a5\3\2\2\2\u03a8"+ - "\u03a6\3\2\2\2\u03a8\u03a7\3\2\2\2\u03a9\u00bf\3\2\2\2\u03aa\u03ad\7\u0084"+ - "\2\2\u03ab\u03ad\5\u00ba^\2\u03ac\u03aa\3\2\2\2\u03ac\u03ab\3\2\2\2\u03ad"+ - "\u00c1\3\2\2\2\u03ae\u03b1\5*\26\2\u03af\u03b1\7\u0084\2\2\u03b0\u03ae"+ - "\3\2\2\2\u03b0\u03af\3\2\2\2\u03b1\u03b2\3\2\2\2\u03b2\u03b3\t\t\2\2\u03b3"+ - "\u03b4\5*\26\2\u03b4\u00c3\3\2\2\2\u03b5\u03b7\7\66\2\2\u03b6\u03b8\5"+ - "(\25\2\u03b7\u03b6\3\2\2\2\u03b7\u03b8\3\2\2\2\u03b8\u03b9\3\2\2\2\u03b9"+ - "\u03ba\7\67\2\2\u03ba\u00c5\3\2\2\2\u03bb\u03bc\5\u00c8e\2\u03bc\u00c7"+ - "\3\2\2\2\u03bd\u03be\7z\2\2\u03be\u00c9\3\2\2\2\u03bf\u03c0\t\n\2\2\u03c0"+ - "\u00cb\3\2\2\2b\u00d4\u00d8\u00e8\u00ee\u00f6\u00fd\u0107\u011d\u0125"+ - "\u012a\u012d\u0131\u013a\u0143\u0146\u014d\u0154\u0156\u015d\u0162\u0169"+ - "\u0170\u0177\u017e\u0188\u018c\u0194\u0196\u01a2\u01a8\u01ac\u01b0\u01bb"+ - "\u01c1\u01d0\u01d6\u01da\u01de\u01e5\u01ec\u01f2\u01f7\u01f9\u01fd\u0204"+ - "\u020b\u0214\u0220\u022a\u0236\u023a\u0243\u024a\u0260\u0265\u026a\u026e"+ - "\u027a\u0282\u0286\u028d\u0294\u029a\u02a1\u02a9\u02b0\u02b6\u02bc\u02c2"+ - "\u02c8\u02d1\u02d7\u02e1\u02ea\u02ec\u0304\u0312\u0319\u032f\u0333\u033a"+ - "\u033e\u0347\u034c\u0358\u035a\u0362\u0365\u036c\u0371\u039f\u03a3\u03a8"+ - "\u03ac\u03b0\u03b7"; + "\2\2\2\u02b1e\3\2\2\2\u02b2\u02b6\5h\65\2\u02b3\u02b4\7t\2\2\u02b4\u02b5"+ + "\7u\2\2\u02b5\u02b7\5\u0096L\2\u02b6\u02b3\3\2\2\2\u02b6\u02b7\3\2\2\2"+ + "\u02b7g\3\2\2\2\u02b8\u02bc\5j\66\2\u02b9\u02ba\7v\2\2\u02ba\u02bb\7X"+ + "\2\2\u02bb\u02bd\5\u0096L\2\u02bc\u02b9\3\2\2\2\u02bc\u02bd\3\2\2\2\u02bd"+ + "i\3\2\2\2\u02be\u02c2\5l\67\2\u02bf\u02c0\7x\2\2\u02c0\u02c1\7X\2\2\u02c1"+ + "\u02c3\5\u00bc_\2\u02c2\u02bf\3\2\2\2\u02c2\u02c3\3\2\2\2\u02c3k\3\2\2"+ + "\2\u02c4\u02c8\5n8\2\u02c5\u02c6\7w\2\2\u02c6\u02c7\7X\2\2\u02c7\u02c9"+ + "\5\u00bc_\2\u02c8\u02c5\3\2\2\2\u02c8\u02c9\3\2\2\2\u02c9m\3\2\2\2\u02ca"+ + "\u02d1\5p9\2\u02cb\u02cc\7\6\2\2\u02cc\u02cd\7-\2\2\u02cd\u02ce\3\2\2"+ + "\2\u02ce\u02d0\5\u008aF\2\u02cf\u02cb\3\2\2\2\u02d0\u02d3\3\2\2\2\u02d1"+ + "\u02cf\3\2\2\2\u02d1\u02d2\3\2\2\2\u02d2o\3\2\2\2\u02d3\u02d1\3\2\2\2"+ + "\u02d4\u02d6\t\6\2\2\u02d5\u02d4\3\2\2\2\u02d6\u02d9\3\2\2\2\u02d7\u02d5"+ + "\3\2\2\2\u02d7\u02d8\3\2\2\2\u02d8\u02da\3\2\2\2\u02d9\u02d7\3\2\2\2\u02da"+ + "\u02db\5r:\2\u02dbq\3\2\2\2\u02dc\u02e1\5t;\2\u02dd\u02de\7\65\2\2\u02de"+ + "\u02e0\5t;\2\u02df\u02dd\3\2\2\2\u02e0\u02e3\3\2\2\2\u02e1\u02df\3\2\2"+ + "\2\u02e1\u02e2\3\2\2\2\u02e2s\3\2\2\2\u02e3\u02e1\3\2\2\2\u02e4\u02ec"+ + "\5~@\2\u02e5\u02eb\5v<\2\u02e6\u02eb\5z>\2\u02e7\u02eb\5|?\2\u02e8\u02eb"+ + "\5x=\2\u02e9\u02eb\5\u008cG\2\u02ea\u02e5\3\2\2\2\u02ea\u02e6\3\2\2\2"+ + "\u02ea\u02e7\3\2\2\2\u02ea\u02e8\3\2\2\2\u02ea\u02e9\3\2\2\2\u02eb\u02ee"+ + "\3\2\2\2\u02ec\u02ea\3\2\2\2\u02ec\u02ed\3\2\2\2\u02edu\3\2\2\2\u02ee"+ + "\u02ec\3\2\2\2\u02ef\u02f0\7\66\2\2\u02f0\u02f1\7\66\2\2\u02f1\u02f2\5"+ + "(\25\2\u02f2\u02f3\7\67\2\2\u02f3\u02f4\7\67\2\2\u02f4w\3\2\2\2\u02f5"+ + "\u02f6\7\66\2\2\u02f6\u02f7\7\67\2\2\u02f7y\3\2\2\2\u02f8\u02f9\7\66\2"+ + "\2\u02f9\u02fa\5(\25\2\u02fa\u02fb\7\67\2\2\u02fb{\3\2\2\2\u02fc\u0304"+ + "\78\2\2\u02fd\u0305\5\u00caf\2\u02fe\u0305\5\u00c8e\2\u02ff\u0305\7\u0086"+ + "\2\2\u0300\u0305\5\u0082B\2\u0301\u0305\5\u0080A\2\u0302\u0305\5\u0084"+ + "C\2\u0303\u0305\5\u00ba^\2\u0304\u02fd\3\2\2\2\u0304\u02fe\3\2\2\2\u0304"+ + "\u02ff\3\2\2\2\u0304\u0300\3\2\2\2\u0304\u0301\3\2\2\2\u0304\u0302\3\2"+ + "\2\2\u0304\u0303\3\2\2\2\u0305}\3\2\2\2\u0306\u0313\7~\2\2\u0307\u0313"+ + "\7\177\2\2\u0308\u0313\5\u00c8e\2\u0309\u0313\5\u0080A\2\u030a\u0313\5"+ + "\u0082B\2\u030b\u0313\5\u0084C\2\u030c\u0313\5\u0098M\2\u030d\u0313\5"+ + "\u008aF\2\u030e\u0313\5\u0086D\2\u030f\u0313\5\u0088E\2\u0310\u0313\5"+ + "\u00c4c\2\u0311\u0313\5\u0090I\2\u0312\u0306\3\2\2\2\u0312\u0307\3\2\2"+ + "\2\u0312\u0308\3\2\2\2\u0312\u0309\3\2\2\2\u0312\u030a\3\2\2\2\u0312\u030b"+ + "\3\2\2\2\u0312\u030c\3\2\2\2\u0312\u030d\3\2\2\2\u0312\u030e\3\2\2\2\u0312"+ + "\u030f\3\2\2\2\u0312\u0310\3\2\2\2\u0312\u0311\3\2\2\2\u0313\177\3\2\2"+ + "\2\u0314\u0315\7!\2\2\u0315\u0316\5\32\16\2\u0316\u0081\3\2\2\2\u0317"+ + "\u0319\7\35\2\2\u0318\u031a\5(\25\2\u0319\u0318\3\2\2\2\u0319\u031a\3"+ + "\2\2\2\u031a\u031b\3\2\2\2\u031b\u031c\7\36\2\2\u031c\u0083\3\2\2\2\u031d"+ + "\u031e\79\2\2\u031e\u0085\3\2\2\2\u031f\u0320\7\t\2\2\u0320\u0321\7\37"+ + "\2\2\u0321\u0322\5(\25\2\u0322\u0323\7 \2\2\u0323\u0087\3\2\2\2\u0324"+ + "\u0325\7\n\2\2\u0325\u0326\7\37\2\2\u0326\u0327\5(\25\2\u0327\u0328\7"+ + " \2\2\u0328\u0089\3\2\2\2\u0329\u032a\5\32\16\2\u032a\u032b\5\u008cG\2"+ + "\u032b\u008b\3\2\2\2\u032c\u0333\7\35\2\2\u032d\u032f\5\u008eH\2\u032e"+ + "\u0330\7\30\2\2\u032f\u032e\3\2\2\2\u032f\u0330\3\2\2\2\u0330\u0332\3"+ + "\2\2\2\u0331\u032d\3\2\2\2\u0332\u0335\3\2\2\2\u0333\u0331\3\2\2\2\u0333"+ + "\u0334\3\2\2\2\u0334\u0336\3\2\2\2\u0335\u0333\3\2\2\2\u0336\u0337\7\36"+ + "\2\2\u0337\u008d\3\2\2\2\u0338\u033b\5*\26\2\u0339\u033b\7}\2\2\u033a"+ + "\u0338\3\2\2\2\u033a\u0339\3\2\2\2\u033b\u008f\3\2\2\2\u033c\u033f\5\u0092"+ + "J\2\u033d\u033f\5\u0094K\2\u033e\u033c\3\2\2\2\u033e\u033d\3\2\2\2\u033f"+ + "\u0091\3\2\2\2\u0340\u0341\5\32\16\2\u0341\u0342\7:\2\2\u0342\u0343\7"+ + "\177\2\2\u0343\u0093\3\2\2\2\u0344\u0345\7\34\2\2\u0345\u0347\7\35\2\2"+ + "\u0346\u0348\5$\23\2\u0347\u0346\3\2\2\2\u0347\u0348\3\2\2\2\u0348\u0349"+ + "\3\2\2\2\u0349\u034c\7\36\2\2\u034a\u034b\7X\2\2\u034b\u034d\5\u0096L"+ + "\2\u034c\u034a\3\2\2\2\u034c\u034d\3\2\2\2\u034d\u034e\3\2\2\2\u034e\u034f"+ + "\7\37\2\2\u034f\u0350\5(\25\2\u0350\u0351\7 \2\2\u0351\u0095\3\2\2\2\u0352"+ + "\u0353\7\35\2\2\u0353\u035b\7\36\2\2\u0354\u0358\5\u009aN\2\u0355\u0359"+ + "\7}\2\2\u0356\u0359\7#\2\2\u0357\u0359\7\60\2\2\u0358\u0355\3\2\2\2\u0358"+ + "\u0356\3\2\2\2\u0358\u0357\3\2\2\2\u0358\u0359\3\2\2\2\u0359\u035b\3\2"+ + "\2\2\u035a\u0352\3\2\2\2\u035a\u0354\3\2\2\2\u035b\u0097\3\2\2\2\u035c"+ + "\u0365\7\37\2\2\u035d\u0362\5\u00c2b\2\u035e\u035f\7\30\2\2\u035f\u0361"+ + "\5\u00c2b\2\u0360\u035e\3\2\2\2\u0361\u0364\3\2\2\2\u0362\u0360\3\2\2"+ + "\2\u0362\u0363\3\2\2\2\u0363\u0366\3\2\2\2\u0364\u0362\3\2\2\2\u0365\u035d"+ + "\3\2\2\2\u0365\u0366\3\2\2\2\u0366\u0367\3\2\2\2\u0367\u036d\7 \2\2\u0368"+ + "\u0369\7;\2\2\u0369\u036a\5(\25\2\u036a\u036b\7<\2\2\u036b\u036d\3\2\2"+ + "\2\u036c\u035c\3\2\2\2\u036c\u0368\3\2\2\2\u036d\u0099\3\2\2\2\u036e\u0372"+ + "\7=\2\2\u036f\u0372\5\u009cO\2\u0370\u0372\5\u00be`\2\u0371\u036e\3\2"+ + "\2\2\u0371\u036f\3\2\2\2\u0371\u0370\3\2\2\2\u0372\u009b\3\2\2\2\u0373"+ + "\u0374\t\b\2\2\u0374\u009d\3\2\2\2\u0375\u0376\7@\2\2\u0376\u009f\3\2"+ + "\2\2\u0377\u0378\7A\2\2\u0378\u00a1\3\2\2\2\u0379\u037a\7B\2\2\u037a\u00a3"+ + "\3\2\2\2\u037b\u037c\7C\2\2\u037c\u00a5\3\2\2\2\u037d\u037e\7D\2\2\u037e"+ + "\u00a7\3\2\2\2\u037f\u0380\7E\2\2\u0380\u00a9\3\2\2\2\u0381\u0382\7F\2"+ + "\2\u0382\u00ab\3\2\2\2\u0383\u0384\7G\2\2\u0384\u00ad\3\2\2\2\u0385\u0386"+ + "\7H\2\2\u0386\u00af\3\2\2\2\u0387\u0388\7I\2\2\u0388\u00b1\3\2\2\2\u0389"+ + "\u038a\7J\2\2\u038a\u00b3\3\2\2\2\u038b\u038c\7K\2\2\u038c\u00b5\3\2\2"+ + "\2\u038d\u038e\7L\2\2\u038e\u00b7\3\2\2\2\u038f\u0390\7M\2\2\u0390\u00b9"+ + "\3\2\2\2\u0391\u03a0\5\u009eP\2\u0392\u03a0\5\u00a0Q\2\u0393\u03a0\5\u00a2"+ + "R\2\u0394\u03a0\5\u00a4S\2\u0395\u03a0\5\u00a6T\2\u0396\u03a0\5\u00a8"+ + "U\2\u0397\u03a0\5\u00aaV\2\u0398\u03a0\5\u00acW\2\u0399\u03a0\5\u00b2"+ + "Z\2\u039a\u03a0\5\u00b4[\2\u039b\u03a0\5\u00b6\\\2\u039c\u03a0\5\u00ae"+ + "X\2\u039d\u03a0\5\u00b0Y\2\u039e\u03a0\5\u00b8]\2\u039f\u0391\3\2\2\2"+ + "\u039f\u0392\3\2\2\2\u039f\u0393\3\2\2\2\u039f\u0394\3\2\2\2\u039f\u0395"+ + "\3\2\2\2\u039f\u0396\3\2\2\2\u039f\u0397\3\2\2\2\u039f\u0398\3\2\2\2\u039f"+ + "\u0399\3\2\2\2\u039f\u039a\3\2\2\2\u039f\u039b\3\2\2\2\u039f\u039c\3\2"+ + "\2\2\u039f\u039d\3\2\2\2\u039f\u039e\3\2\2\2\u03a0\u00bb\3\2\2\2\u03a1"+ + "\u03a3\5\u00be`\2\u03a2\u03a4\7}\2\2\u03a3\u03a2\3\2\2\2\u03a3\u03a4\3"+ + "\2\2\2\u03a4\u00bd\3\2\2\2\u03a5\u03a9\7N\2\2\u03a6\u03a9\5\u00ba^\2\u03a7"+ + "\u03a9\7~\2\2\u03a8\u03a5\3\2\2\2\u03a8\u03a6\3\2\2\2\u03a8\u03a7\3\2"+ + "\2\2\u03a9\u00bf\3\2\2\2\u03aa\u03ad\7\u0086\2\2\u03ab\u03ad\5\u00ba^"+ + "\2\u03ac\u03aa\3\2\2\2\u03ac\u03ab\3\2\2\2\u03ad\u00c1\3\2\2\2\u03ae\u03b1"+ + "\5*\26\2\u03af\u03b1\7\u0086\2\2\u03b0\u03ae\3\2\2\2\u03b0\u03af\3\2\2"+ + "\2\u03b1\u03b2\3\2\2\2\u03b2\u03b3\t\t\2\2\u03b3\u03b4\5*\26\2\u03b4\u00c3"+ + "\3\2\2\2\u03b5\u03b7\7\66\2\2\u03b6\u03b8\5(\25\2\u03b7\u03b6\3\2\2\2"+ + "\u03b7\u03b8\3\2\2\2\u03b8\u03b9\3\2\2\2\u03b9\u03ba\7\67\2\2\u03ba\u00c5"+ + "\3\2\2\2\u03bb\u03bc\5\u00c8e\2\u03bc\u00c7\3\2\2\2\u03bd\u03be\7|\2\2"+ + "\u03be\u00c9\3\2\2\2\u03bf\u03c0\t\n\2\2\u03c0\u00cb\3\2\2\2b\u00d4\u00d8"+ + "\u00e8\u00ee\u00f6\u00fd\u0107\u011d\u0125\u012a\u012d\u0131\u013a\u0143"+ + "\u0146\u014d\u0154\u0156\u015d\u0162\u0169\u0170\u0177\u017e\u0188\u018c"+ + "\u0194\u0196\u01a2\u01a8\u01ac\u01b0\u01bb\u01c1\u01d0\u01d6\u01da\u01de"+ + "\u01e5\u01ec\u01f2\u01f7\u01f9\u01fd\u0204\u020b\u0214\u0220\u022a\u0236"+ + "\u023a\u0243\u024a\u0260\u0265\u026a\u026e\u027a\u0282\u0286\u028d\u0294"+ + "\u029a\u02a1\u02a9\u02b0\u02b6\u02bc\u02c2\u02c8\u02d1\u02d7\u02e1\u02ea"+ + "\u02ec\u0304\u0312\u0319\u032f\u0333\u033a\u033e\u0347\u034c\u0358\u035a"+ + "\u0362\u0365\u036c\u0371\u039f\u03a3\u03a8\u03ac\u03b0\u03b7"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { From 28e156252564c83448d6b1db9fd827e11e6c12a0 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Fri, 6 Nov 2020 15:15:11 +0100 Subject: [PATCH 040/206] added 'statically is' visitor in static type inference --- .../rumbledb/compiler/InferTypeVisitor.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index b2f9c479e2..5ac7e19537 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -29,10 +29,7 @@ import org.rumbledb.expressions.primary.*; import org.rumbledb.expressions.quantifiers.QuantifiedExpression; import org.rumbledb.expressions.quantifiers.QuantifiedExpressionVar; -import org.rumbledb.expressions.typing.CastExpression; -import org.rumbledb.expressions.typing.CastableExpression; -import org.rumbledb.expressions.typing.InstanceOfExpression; -import org.rumbledb.expressions.typing.TreatExpression; +import org.rumbledb.expressions.typing.*; import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -391,6 +388,21 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex return argument; } + @Override + public StaticContext visitStaticallyIsExpr(StaticallyIsExpression expression, StaticContext argument) { + System.out.println("visiting StaticallyIs expression"); + visitDescendants(expression, argument); + + SequenceType inferred = expression.getMainExpression().getInferredSequenceType(); + SequenceType expected = expression.getSequenceType(); + if(!inferred.equals(expected)){ + throw new UnexpectedStaticTypeException("expected static type is " + expected + " instead " + inferred + " was inferred"); + } + + expression.setInferredSequenceType(expected); + return argument; + } + @Override public StaticContext visitInstanceOfExpression(InstanceOfExpression expression, StaticContext argument) { System.out.println("visiting InstanceOf expression"); From fe4a4f2de2862ffbeae88a929fffd4c880319481 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Fri, 6 Nov 2020 18:22:07 +0100 Subject: [PATCH 041/206] renamed expression "is statically" --- .../rumbledb/compiler/InferTypeVisitor.java | 8 +- .../rumbledb/compiler/TranslationVisitor.java | 6 +- .../expressions/AbstractNodeVisitor.java | 2 +- ...ssion.java => IsStaticallyExpression.java} | 6 +- src/main/java/org/rumbledb/parser/Jsoniq.g4 | 4 +- .../rumbledb/parser/JsoniqBaseVisitor.java | 2 +- .../org/rumbledb/parser/JsoniqParser.java | 40 ++-- .../org/rumbledb/parser/JsoniqVisitor.java | 4 +- src/test/java/iq/StaticTypeTests.java | 178 ++++++++++++++++++ .../static-typing/primary/integer.jq | 0 10 files changed, 215 insertions(+), 35 deletions(-) rename src/main/java/org/rumbledb/expressions/typing/{StaticallyIsExpression.java => IsStaticallyExpression.java} (91%) create mode 100644 src/test/java/iq/StaticTypeTests.java create mode 100644 src/test/resources/test_files/static-typing/primary/integer.jq diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 5ac7e19537..b9c87414dd 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -389,14 +389,16 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex } @Override - public StaticContext visitStaticallyIsExpr(StaticallyIsExpression expression, StaticContext argument) { + public StaticContext visitIsStaticallyExpr(IsStaticallyExpression expression, StaticContext argument) { System.out.println("visiting StaticallyIs expression"); visitDescendants(expression, argument); SequenceType inferred = expression.getMainExpression().getInferredSequenceType(); SequenceType expected = expression.getSequenceType(); - if(!inferred.equals(expected)){ - throw new UnexpectedStaticTypeException("expected static type is " + expected + " instead " + inferred + " was inferred"); + if (!inferred.equals(expected)) { + throw new UnexpectedStaticTypeException( + "expected static type is " + expected + " instead " + inferred + " was inferred" + ); } expression.setInferredSequenceType(expected); diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index cefd5b4c10..16ef273e30 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -810,7 +810,7 @@ public Node visitSimpleMapExpr(JsoniqParser.SimpleMapExprContext ctx) { @Override public Node visitInstanceOfExpr(JsoniqParser.InstanceOfExprContext ctx) { - Expression mainExpression = (Expression) this.visitStaticallyIsExpr(ctx.main_expr); + Expression mainExpression = (Expression) this.visitIsStaticallyExpr(ctx.main_expr); if (ctx.seq == null || ctx.seq.isEmpty()) { return mainExpression; } @@ -824,14 +824,14 @@ public Node visitInstanceOfExpr(JsoniqParser.InstanceOfExprContext ctx) { } @Override - public Node visitStaticallyIsExpr(JsoniqParser.StaticallyIsExprContext ctx) { + public Node visitIsStaticallyExpr(JsoniqParser.IsStaticallyExprContext ctx) { Expression mainExpression = (Expression) this.visitTreatExpr(ctx.main_expr); if (ctx.seq == null || ctx.seq.isEmpty()) { return mainExpression; } JsoniqParser.SequenceTypeContext child = ctx.seq; SequenceType sequenceType = this.processSequenceType(child); - return new StaticallyIsExpression( + return new IsStaticallyExpression( mainExpression, sequenceType, createMetadataFromContext(ctx) diff --git a/src/main/java/org/rumbledb/expressions/AbstractNodeVisitor.java b/src/main/java/org/rumbledb/expressions/AbstractNodeVisitor.java index 25b0039ebe..495a0f5202 100644 --- a/src/main/java/org/rumbledb/expressions/AbstractNodeVisitor.java +++ b/src/main/java/org/rumbledb/expressions/AbstractNodeVisitor.java @@ -262,7 +262,7 @@ public T visitInstanceOfExpression(InstanceOfExpression expression, T argument) return defaultAction(expression, argument); } - public T visitStaticallyIsExpr(StaticallyIsExpression expression, T argument) { + public T visitIsStaticallyExpr(IsStaticallyExpression expression, T argument) { return defaultAction(expression, argument); } diff --git a/src/main/java/org/rumbledb/expressions/typing/StaticallyIsExpression.java b/src/main/java/org/rumbledb/expressions/typing/IsStaticallyExpression.java similarity index 91% rename from src/main/java/org/rumbledb/expressions/typing/StaticallyIsExpression.java rename to src/main/java/org/rumbledb/expressions/typing/IsStaticallyExpression.java index 8e5932f9fd..4868e2cb67 100644 --- a/src/main/java/org/rumbledb/expressions/typing/StaticallyIsExpression.java +++ b/src/main/java/org/rumbledb/expressions/typing/IsStaticallyExpression.java @@ -10,11 +10,11 @@ import java.util.Collections; import java.util.List; -public class StaticallyIsExpression extends Expression { +public class IsStaticallyExpression extends Expression { private Expression mainExpression; private SequenceType sequenceType; - public StaticallyIsExpression( + public IsStaticallyExpression( Expression mainExpression, SequenceType sequenceType, ExceptionMetadata metadata @@ -29,7 +29,7 @@ public StaticallyIsExpression( @Override public T accept(AbstractNodeVisitor visitor, T argument) { - return visitor.visitStaticallyIsExpr(this, argument); + return visitor.visitIsStaticallyExpr(this, argument); } public SequenceType getSequenceType() { diff --git a/src/main/java/org/rumbledb/parser/Jsoniq.g4 b/src/main/java/org/rumbledb/parser/Jsoniq.g4 index 94e8f9dcac..d59983548d 100644 --- a/src/main/java/org/rumbledb/parser/Jsoniq.g4 +++ b/src/main/java/org/rumbledb/parser/Jsoniq.g4 @@ -150,9 +150,9 @@ additiveExpr : main_expr=multiplicativeExpr ( op+=('+' | '-') rhs+=mu multiplicativeExpr : main_expr=instanceOfExpr ( op+=('*' | 'div' | 'idiv' | 'mod') rhs+=instanceOfExpr )*; -instanceOfExpr : main_expr=staticallyIsExpr ( Kinstance Kof seq=sequenceType)?; +instanceOfExpr : main_expr=isStaticallyExpr ( Kinstance Kof seq=sequenceType)?; -staticallyIsExpr : main_expr=treatExpr ( Kstatically Kis seq=sequenceType)?; +isStaticallyExpr : main_expr=treatExpr ( Kis Kstatically seq=sequenceType)?; treatExpr : main_expr=castableExpr ( Ktreat Kas seq=sequenceType )?; diff --git a/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java b/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java index 30c77c1f3f..4db90da4f8 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java +++ b/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java @@ -370,7 +370,7 @@ public class JsoniqBaseVisitor extends AbstractParseTreeVisitor implements *

The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.

*/ - @Override public T visitStaticallyIsExpr(JsoniqParser.StaticallyIsExprContext ctx) { return visitChildren(ctx); } + @Override public T visitIsStaticallyExpr(JsoniqParser.IsStaticallyExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * diff --git a/src/main/java/org/rumbledb/parser/JsoniqParser.java b/src/main/java/org/rumbledb/parser/JsoniqParser.java index 64dd404264..81345d7177 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqParser.java +++ b/src/main/java/org/rumbledb/parser/JsoniqParser.java @@ -66,7 +66,7 @@ public class JsoniqParser extends Parser { RULE_ifExpr = 38, RULE_tryCatchExpr = 39, RULE_catchClause = 40, RULE_orExpr = 41, RULE_andExpr = 42, RULE_notExpr = 43, RULE_comparisonExpr = 44, RULE_stringConcatExpr = 45, RULE_rangeExpr = 46, RULE_additiveExpr = 47, RULE_multiplicativeExpr = 48, - RULE_instanceOfExpr = 49, RULE_staticallyIsExpr = 50, RULE_treatExpr = 51, + RULE_instanceOfExpr = 49, RULE_isStaticallyExpr = 50, RULE_treatExpr = 51, RULE_castableExpr = 52, RULE_castExpr = 53, RULE_arrowExpr = 54, RULE_unaryExpr = 55, RULE_simpleMapExpr = 56, RULE_postFixExpr = 57, RULE_arrayLookup = 58, RULE_arrayUnboxing = 59, RULE_predicate = 60, RULE_objectLookup = 61, @@ -93,7 +93,7 @@ public class JsoniqParser extends Parser { "quantifiedExpr", "quantifiedExprVar", "switchExpr", "switchCaseClause", "typeSwitchExpr", "caseClause", "ifExpr", "tryCatchExpr", "catchClause", "orExpr", "andExpr", "notExpr", "comparisonExpr", "stringConcatExpr", - "rangeExpr", "additiveExpr", "multiplicativeExpr", "instanceOfExpr", "staticallyIsExpr", + "rangeExpr", "additiveExpr", "multiplicativeExpr", "instanceOfExpr", "isStaticallyExpr", "treatExpr", "castableExpr", "castExpr", "arrowExpr", "unaryExpr", "simpleMapExpr", "postFixExpr", "arrayLookup", "arrayUnboxing", "predicate", "objectLookup", "primaryExpr", "varRef", "parenthesizedExpr", "contextItemExpr", "orderedExpr", @@ -4048,10 +4048,10 @@ public final MultiplicativeExprContext multiplicativeExpr() throws RecognitionEx } public static class InstanceOfExprContext extends ParserRuleContext { - public StaticallyIsExprContext main_expr; + public IsStaticallyExprContext main_expr; public SequenceTypeContext seq; - public StaticallyIsExprContext staticallyIsExpr() { - return getRuleContext(StaticallyIsExprContext.class,0); + public IsStaticallyExprContext isStaticallyExpr() { + return getRuleContext(IsStaticallyExprContext.class,0); } public TerminalNode Kinstance() { return getToken(JsoniqParser.Kinstance, 0); } public TerminalNode Kof() { return getToken(JsoniqParser.Kof, 0); } @@ -4076,7 +4076,7 @@ public final InstanceOfExprContext instanceOfExpr() throws RecognitionException enterOuterAlt(_localctx, 1); { setState(682); - ((InstanceOfExprContext)_localctx).main_expr = staticallyIsExpr(); + ((InstanceOfExprContext)_localctx).main_expr = isStaticallyExpr(); setState(686); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,65,_ctx) ) { @@ -4104,47 +4104,47 @@ public final InstanceOfExprContext instanceOfExpr() throws RecognitionException return _localctx; } - public static class StaticallyIsExprContext extends ParserRuleContext { + public static class IsStaticallyExprContext extends ParserRuleContext { public TreatExprContext main_expr; public SequenceTypeContext seq; public TreatExprContext treatExpr() { return getRuleContext(TreatExprContext.class,0); } - public TerminalNode Kstatically() { return getToken(JsoniqParser.Kstatically, 0); } public TerminalNode Kis() { return getToken(JsoniqParser.Kis, 0); } + public TerminalNode Kstatically() { return getToken(JsoniqParser.Kstatically, 0); } public SequenceTypeContext sequenceType() { return getRuleContext(SequenceTypeContext.class,0); } - public StaticallyIsExprContext(ParserRuleContext parent, int invokingState) { + public IsStaticallyExprContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - @Override public int getRuleIndex() { return RULE_staticallyIsExpr; } + @Override public int getRuleIndex() { return RULE_isStaticallyExpr; } @Override public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor)visitor).visitStaticallyIsExpr(this); + if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor)visitor).visitIsStaticallyExpr(this); else return visitor.visitChildren(this); } } - public final StaticallyIsExprContext staticallyIsExpr() throws RecognitionException { - StaticallyIsExprContext _localctx = new StaticallyIsExprContext(_ctx, getState()); - enterRule(_localctx, 100, RULE_staticallyIsExpr); + public final IsStaticallyExprContext isStaticallyExpr() throws RecognitionException { + IsStaticallyExprContext _localctx = new IsStaticallyExprContext(_ctx, getState()); + enterRule(_localctx, 100, RULE_isStaticallyExpr); try { enterOuterAlt(_localctx, 1); { setState(688); - ((StaticallyIsExprContext)_localctx).main_expr = treatExpr(); + ((IsStaticallyExprContext)_localctx).main_expr = treatExpr(); setState(692); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,66,_ctx) ) { case 1: { setState(689); - match(Kstatically); - setState(690); match(Kis); + setState(690); + match(Kstatically); setState(691); - ((StaticallyIsExprContext)_localctx).seq = sequenceType(); + ((IsStaticallyExprContext)_localctx).seq = sequenceType(); } break; } @@ -7419,8 +7419,8 @@ public final KeyWordsContext keyWords() throws RecognitionException { "\2\2\u02a8\u02ab\3\2\2\2\u02a9\u02a7\3\2\2\2\u02a9\u02aa\3\2\2\2\u02aa"+ "c\3\2\2\2\u02ab\u02a9\3\2\2\2\u02ac\u02b0\5f\64\2\u02ad\u02ae\7r\2\2\u02ae"+ "\u02af\7s\2\2\u02af\u02b1\5\u0096L\2\u02b0\u02ad\3\2\2\2\u02b0\u02b1\3"+ - "\2\2\2\u02b1e\3\2\2\2\u02b2\u02b6\5h\65\2\u02b3\u02b4\7t\2\2\u02b4\u02b5"+ - "\7u\2\2\u02b5\u02b7\5\u0096L\2\u02b6\u02b3\3\2\2\2\u02b6\u02b7\3\2\2\2"+ + "\2\2\2\u02b1e\3\2\2\2\u02b2\u02b6\5h\65\2\u02b3\u02b4\7u\2\2\u02b4\u02b5"+ + "\7t\2\2\u02b5\u02b7\5\u0096L\2\u02b6\u02b3\3\2\2\2\u02b6\u02b7\3\2\2\2"+ "\u02b7g\3\2\2\2\u02b8\u02bc\5j\66\2\u02b9\u02ba\7v\2\2\u02ba\u02bb\7X"+ "\2\2\u02bb\u02bd\5\u0096L\2\u02bc\u02b9\3\2\2\2\u02bc\u02bd\3\2\2\2\u02bd"+ "i\3\2\2\2\u02be\u02c2\5l\67\2\u02bf\u02c0\7x\2\2\u02c0\u02c1\7X\2\2\u02c1"+ diff --git a/src/main/java/org/rumbledb/parser/JsoniqVisitor.java b/src/main/java/org/rumbledb/parser/JsoniqVisitor.java index 95a6a9ae2f..da450bf57e 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqVisitor.java +++ b/src/main/java/org/rumbledb/parser/JsoniqVisitor.java @@ -314,11 +314,11 @@ public interface JsoniqVisitor extends ParseTreeVisitor { */ T visitInstanceOfExpr(JsoniqParser.InstanceOfExprContext ctx); /** - * Visit a parse tree produced by {@link JsoniqParser#staticallyIsExpr}. + * Visit a parse tree produced by {@link JsoniqParser#isStaticallyExpr}. * @param ctx the parse tree * @return the visitor result */ - T visitStaticallyIsExpr(JsoniqParser.StaticallyIsExprContext ctx); + T visitIsStaticallyExpr(JsoniqParser.IsStaticallyExprContext ctx); /** * Visit a parse tree produced by {@link JsoniqParser#treatExpr}. * @param ctx the parse tree diff --git a/src/test/java/iq/StaticTypeTests.java b/src/test/java/iq/StaticTypeTests.java new file mode 100644 index 0000000000..c465e66800 --- /dev/null +++ b/src/test/java/iq/StaticTypeTests.java @@ -0,0 +1,178 @@ +package iq; + +import iq.base.AnnotationsTestsBase; +import scala.util.Properties; + +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaRDD; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.rumbledb.api.Item; +import org.rumbledb.api.SequenceOfItems; +import sparksoniq.spark.SparkSessionManager; +import utils.FileManager; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +@RunWith(Parameterized.class) +public class RuntimeTests extends AnnotationsTestsBase { + + public static final File runtimeTestsDirectory = new File( + System.getProperty("user.dir") + + + "/src/test/resources/test_files/static-typing" + ); + public static final String javaVersion = + System.getProperty("java.version"); + public static final String scalaVersion = + Properties.scalaPropOrElse("version.number", "unknown"); + protected static List _testFiles = new ArrayList<>(); + protected final File testFile; + + public RuntimeTests(File testFile) { + this.testFile = testFile; + } + + public static void readFileList(File dir) { + FileManager.loadJiqFiles(dir).forEach(file -> RuntimeTests._testFiles.add(file)); + } + + @Parameterized.Parameters(name = "{index}:{0}") + public static Collection testFiles() { + List result = new ArrayList<>(); + RuntimeTests.readFileList(RuntimeTests.runtimeTestsDirectory); + RuntimeTests._testFiles.forEach(file -> result.add(new Object[] { file })); + return result; + } + + @BeforeClass + public static void setupSparkSession() { + System.err.println("Java version: " + javaVersion); + System.err.println("Scala version: " + scalaVersion); + SparkConf sparkConfiguration = new SparkConf(); + sparkConfiguration.setMaster("local[*]"); + sparkConfiguration.set("spark.submit.deployMode", "client"); + sparkConfiguration.set("spark.executor.extraClassPath", "lib/"); + sparkConfiguration.set("spark.driver.extraClassPath", "lib/"); + sparkConfiguration.set("spark.sql.crossJoin.enabled", "true"); // enables cartesian product + + // prevents spark from failing to start on MacOS when disconnected from the internet + sparkConfiguration.set("spark.driver.host", "127.0.0.1"); + + + // sparkConfiguration.set("spark.driver.memory", "2g"); + // sparkConfiguration.set("spark.executor.memory", "2g"); + // sparkConfiguration.set("spark.speculation", "true"); + // sparkConfiguration.set("spark.speculation.quantile", "0.5"); + SparkSessionManager.getInstance().initializeConfigurationAndSession(sparkConfiguration, true); + SparkSessionManager.COLLECT_ITEM_LIMIT = configuration.getResultSizeCap(); + System.err.println("Spark version: " + SparkSessionManager.getInstance().getJavaSparkContext().version()); + } + + @Test(timeout = 1000000) + public void testRuntimeIterators() throws Throwable { + System.err.println(AnnotationsTestsBase.counter++ + " : " + this.testFile); + testAnnotations(this.testFile.getAbsolutePath()); + } + + @Override + protected void checkExpectedOutput( + String expectedOutput, + SequenceOfItems sequence + ) { + String actualOutput; + if (!sequence.availableAsRDD()) { + actualOutput = runIterators(sequence); + } else { + actualOutput = getRDDResults(sequence); + } + Assert.assertTrue( + "Expected output: " + expectedOutput + "\nActual result: " + actualOutput, + expectedOutput.equals(actualOutput) + ); + // unorderedItemSequenceStringsAreEqual(expectedOutput, actualOutput)); + } + + protected String runIterators(SequenceOfItems sequence) { + String actualOutput = getIteratorOutput(sequence); + return actualOutput; + } + + protected String getIteratorOutput(SequenceOfItems sequence) { + sequence.open(); + Item result = null; + if (sequence.hasNext()) { + result = sequence.next(); + } + if (result == null) { + return ""; + } + String singleOutput = result.serialize(); + if (!sequence.hasNext()) { + return singleOutput; + } else { + int itemCount = 1; + StringBuilder sb = new StringBuilder(); + sb.append("("); + sb.append(result.serialize()); + sb.append(", "); + while ( + sequence.hasNext() + && + ((itemCount < AnnotationsTestsBase.configuration.getResultSizeCap() + && AnnotationsTestsBase.configuration.getResultSizeCap() > 0) + || + AnnotationsTestsBase.configuration.getResultSizeCap() == 0) + ) { + sb.append(sequence.next().serialize()); + sb.append(", "); + itemCount++; + } + if (sequence.hasNext() && itemCount == AnnotationsTestsBase.configuration.getResultSizeCap()) { + System.err.println( + "Warning! The output sequence contains a large number of items but its materialization was capped at " + + SparkSessionManager.COLLECT_ITEM_LIMIT + + " items. This value can be configured with the --result-size parameter at startup" + ); + } + // remove last comma + String output = sb.toString(); + output = output.substring(0, output.length() - 2); + output += ")"; + return output; + } + } + + private String getRDDResults(SequenceOfItems sequence) { + JavaRDD rdd = sequence.getAsRDD(); + JavaRDD output = rdd.map(o -> o.serialize()); + List collectedOutput = new ArrayList(); + SparkSessionManager.collectRDDwithLimitWarningOnly(output, collectedOutput); + + if (collectedOutput.isEmpty()) { + return ""; + } + + if (collectedOutput.size() == 1) { + return collectedOutput.get(0); + } + + StringBuilder sb = new StringBuilder(); + sb.append("("); + for (String item : collectedOutput) { + sb.append(item); + sb.append(", "); + } + + String result = sb.toString(); + result = result.substring(0, result.length() - 2); + result += ")"; + return result; + } +} diff --git a/src/test/resources/test_files/static-typing/primary/integer.jq b/src/test/resources/test_files/static-typing/primary/integer.jq new file mode 100644 index 0000000000..e69de29bb2 From ab562c27a1d82ad321220bf0bd1e40cef5d7a180 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 10 Nov 2020 10:11:22 +0100 Subject: [PATCH 042/206] small fixes --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 8 +++++++- .../static-typing/{primary/integer.jq => comma.jq} | 0 .../resources/test_files/static-typing/primary/array.jq | 2 ++ .../test_files/static-typing/primary/literals.jq | 2 ++ .../resources/test_files/static-typing/primary/object1.jq | 2 ++ .../resources/test_files/static-typing/primary/object2.jq | 0 .../resources/test_files/static-typing/primary/object3.jq | 0 .../static-typing/primary/staticFunctionCall1.jq | 2 ++ .../static-typing/primary/staticFunctionCall2.jq | 0 .../static-typing/primary/staticFunctionCall3.jq | 0 .../static-typing/primary/staticFunctionCall4.jq | 0 .../static-typing/primary/variableReference1.jq | 0 .../static-typing/primary/variableReference2.jq | 0 .../static-typing/primary/variableReference3.jq | 0 14 files changed, 15 insertions(+), 1 deletion(-) rename src/test/resources/test_files/static-typing/{primary/integer.jq => comma.jq} (100%) create mode 100644 src/test/resources/test_files/static-typing/primary/array.jq create mode 100644 src/test/resources/test_files/static-typing/primary/literals.jq create mode 100644 src/test/resources/test_files/static-typing/primary/object1.jq create mode 100644 src/test/resources/test_files/static-typing/primary/object2.jq create mode 100644 src/test/resources/test_files/static-typing/primary/object3.jq create mode 100644 src/test/resources/test_files/static-typing/primary/staticFunctionCall1.jq create mode 100644 src/test/resources/test_files/static-typing/primary/staticFunctionCall2.jq create mode 100644 src/test/resources/test_files/static-typing/primary/staticFunctionCall3.jq create mode 100644 src/test/resources/test_files/static-typing/primary/staticFunctionCall4.jq create mode 100644 src/test/resources/test_files/static-typing/primary/variableReference1.jq create mode 100644 src/test/resources/test_files/static-typing/primary/variableReference2.jq create mode 100644 src/test/resources/test_files/static-typing/primary/variableReference3.jq diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index b9c87414dd..64f3f46271 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -308,7 +308,6 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static SequenceType actualType = parameterExpressions.get(i).getInferredSequenceType(); SequenceType expectedType = parameterTypes.get(i); // check actual parameters is either a subtype of or can be promoted to expected type - // TODO: should i consider automatic prmotion as valid or not if (!actualType.isSubtypeOfOrCanBePromotedTo(expectedType)) { throw new UnexpectedStaticTypeException( "Argument " + i + " requires " + expectedType + " but " + actualType + " was found" @@ -339,6 +338,9 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static public StaticContext visitCastableExpression(CastableExpression expression, StaticContext argument) { System.out.println("visiting Castable expression"); visitDescendants(expression, argument); + if(expression.getSequenceType().getItemType().equals(ItemType.atomicItem)){ + throw new UnexpectedStaticTypeException("atomic item type is not allowed in castable expression", ErrorCode.CastableErrorCode); + } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); return argument; } @@ -352,6 +354,10 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex SequenceType expressionSequenceType = expression.getMainExpression().getInferredSequenceType(); SequenceType castedSequenceType = expression.getSequenceType(); + if(castedSequenceType.getItemType().equals(ItemType.atomicItem)){ + throw new UnexpectedStaticTypeException("atomic item type is not allowed in cast expression", ErrorCode.CastableErrorCode); + } + // Empty sequence check if (expressionSequenceType.isEmptySequence() && castedSequenceType.getArity() != SequenceType.Arity.OneOrZero) { throw new UnexpectedStaticTypeException( diff --git a/src/test/resources/test_files/static-typing/primary/integer.jq b/src/test/resources/test_files/static-typing/comma.jq similarity index 100% rename from src/test/resources/test_files/static-typing/primary/integer.jq rename to src/test/resources/test_files/static-typing/comma.jq diff --git a/src/test/resources/test_files/static-typing/primary/array.jq b/src/test/resources/test_files/static-typing/primary/array.jq new file mode 100644 index 0000000000..9210db1162 --- /dev/null +++ b/src/test/resources/test_files/static-typing/primary/array.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +[1,2,3] is statically array, [(1,2)] is statically array, [] is statically array \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/literals.jq b/src/test/resources/test_files/static-typing/primary/literals.jq new file mode 100644 index 0000000000..7bfa3a6564 --- /dev/null +++ b/src/test/resources/test_files/static-typing/primary/literals.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun; Output="4" :) +4 is statically integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/object1.jq b/src/test/resources/test_files/static-typing/primary/object1.jq new file mode 100644 index 0000000000..6e35e60141 --- /dev/null +++ b/src/test/resources/test_files/static-typing/primary/object1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +{"a" : 12} is statically object, { "a" treat as anyURI is statically anyURI : 12 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/object2.jq b/src/test/resources/test_files/static-typing/primary/object2.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/primary/object3.jq b/src/test/resources/test_files/static-typing/primary/object3.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/primary/staticFunctionCall1.jq b/src/test/resources/test_files/static-typing/primary/staticFunctionCall1.jq new file mode 100644 index 0000000000..3f985e5972 --- /dev/null +++ b/src/test/resources/test_files/static-typing/primary/staticFunctionCall1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +sum(1,2) is statically integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/staticFunctionCall2.jq b/src/test/resources/test_files/static-typing/primary/staticFunctionCall2.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/primary/staticFunctionCall3.jq b/src/test/resources/test_files/static-typing/primary/staticFunctionCall3.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/primary/staticFunctionCall4.jq b/src/test/resources/test_files/static-typing/primary/staticFunctionCall4.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/primary/variableReference1.jq b/src/test/resources/test_files/static-typing/primary/variableReference1.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/primary/variableReference2.jq b/src/test/resources/test_files/static-typing/primary/variableReference2.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/primary/variableReference3.jq b/src/test/resources/test_files/static-typing/primary/variableReference3.jq new file mode 100644 index 0000000000..e69de29bb2 From 8b7a7f25b7254d96bf110c8912904ad751f42784 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 10 Nov 2020 10:12:49 +0100 Subject: [PATCH 043/206] test infrastructure for type inference --- src/test/java/iq/FrontendTests.java | 4 +- src/test/java/iq/RuntimeTests.java | 2 +- src/test/java/iq/StaticTypeTests.java | 53 ++++++++++--------- .../java/iq/base/AnnotationsTestsBase.java | 6 +-- 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/test/java/iq/FrontendTests.java b/src/test/java/iq/FrontendTests.java index 4123cf13a2..d67f0b95aa 100644 --- a/src/test/java/iq/FrontendTests.java +++ b/src/test/java/iq/FrontendTests.java @@ -68,7 +68,7 @@ public void testGrammarAndParser() throws Throwable { for (File testFile : this.testFiles) { System.err.println(counter++ + " : " + testFile); // FileReader reader = getReaderForFile(testFile.getAbsolutePath()); - testAnnotations(testFile.getAbsolutePath()); + testAnnotations(testFile.getAbsolutePath(), AnnotationsTestsBase.configuration); } } @@ -103,7 +103,7 @@ public void testSematicChecks() throws Throwable { initializeTests(semanticTestsDirectory); for (File testFile : this.testFiles) { System.err.println(counter++ + " : " + testFile); - testAnnotations(testFile.getAbsolutePath()); + testAnnotations(testFile.getAbsolutePath(), AnnotationsTestsBase.configuration); if (Arrays.asList(manualSemanticChecksFiles).contains(testFile.getName())) { URI uri = FileSystemUtil.resolveURIAgainstWorkingDirectory( testFile.getAbsolutePath(), diff --git a/src/test/java/iq/RuntimeTests.java b/src/test/java/iq/RuntimeTests.java index 4b434a18bd..e43c349d5d 100644 --- a/src/test/java/iq/RuntimeTests.java +++ b/src/test/java/iq/RuntimeTests.java @@ -98,7 +98,7 @@ public static void setupSparkSession() { @Test(timeout = 1000000) public void testRuntimeIterators() throws Throwable { System.err.println(AnnotationsTestsBase.counter++ + " : " + this.testFile); - testAnnotations(this.testFile.getAbsolutePath()); + testAnnotations(this.testFile.getAbsolutePath(), AnnotationsTestsBase.configuration); } @Override diff --git a/src/test/java/iq/StaticTypeTests.java b/src/test/java/iq/StaticTypeTests.java index c465e66800..fb13c221a3 100644 --- a/src/test/java/iq/StaticTypeTests.java +++ b/src/test/java/iq/StaticTypeTests.java @@ -1,6 +1,7 @@ package iq; import iq.base.AnnotationsTestsBase; +import org.rumbledb.config.RumbleRuntimeConfiguration; import scala.util.Properties; import org.apache.spark.SparkConf; @@ -21,33 +22,37 @@ import java.util.List; @RunWith(Parameterized.class) -public class RuntimeTests extends AnnotationsTestsBase { +public class StaticTypeTests extends AnnotationsTestsBase { - public static final File runtimeTestsDirectory = new File( + protected static final RumbleRuntimeConfiguration configuration = new RumbleRuntimeConfiguration( + new String[] { "--print-iterator-tree", "yes", "--static-analysis", "yes" } + ); + + public static final File staticTypeTestsDirectory = new File( System.getProperty("user.dir") - + - "/src/test/resources/test_files/static-typing" + + + "/src/test/resources/test_files/static-typing" ); public static final String javaVersion = - System.getProperty("java.version"); + System.getProperty("java.version"); public static final String scalaVersion = - Properties.scalaPropOrElse("version.number", "unknown"); + Properties.scalaPropOrElse("version.number", "unknown"); protected static List _testFiles = new ArrayList<>(); protected final File testFile; - public RuntimeTests(File testFile) { + public StaticTypeTests(File testFile) { this.testFile = testFile; } public static void readFileList(File dir) { - FileManager.loadJiqFiles(dir).forEach(file -> RuntimeTests._testFiles.add(file)); + FileManager.loadJiqFiles(dir).forEach(file -> StaticTypeTests._testFiles.add(file)); } @Parameterized.Parameters(name = "{index}:{0}") public static Collection testFiles() { List result = new ArrayList<>(); - RuntimeTests.readFileList(RuntimeTests.runtimeTestsDirectory); - RuntimeTests._testFiles.forEach(file -> result.add(new Object[] { file })); + StaticTypeTests.readFileList(StaticTypeTests.staticTypeTestsDirectory); + StaticTypeTests._testFiles.forEach(file -> result.add(new Object[] { file })); return result; } @@ -78,7 +83,7 @@ public static void setupSparkSession() { @Test(timeout = 1000000) public void testRuntimeIterators() throws Throwable { System.err.println(AnnotationsTestsBase.counter++ + " : " + this.testFile); - testAnnotations(this.testFile.getAbsolutePath()); + testAnnotations(this.testFile.getAbsolutePath(), StaticTypeTests.configuration); } @Override @@ -86,17 +91,15 @@ protected void checkExpectedOutput( String expectedOutput, SequenceOfItems sequence ) { + // TODO: Should i get actual output even if i do not need it? String actualOutput; if (!sequence.availableAsRDD()) { actualOutput = runIterators(sequence); } else { actualOutput = getRDDResults(sequence); } - Assert.assertTrue( - "Expected output: " + expectedOutput + "\nActual result: " + actualOutput, - expectedOutput.equals(actualOutput) - ); - // unorderedItemSequenceStringsAreEqual(expectedOutput, actualOutput)); + // For static typing check we just need to check that the program run, no need to compare the output + Assert.assertTrue(true); } protected String runIterators(SequenceOfItems sequence) { @@ -123,12 +126,12 @@ protected String getIteratorOutput(SequenceOfItems sequence) { sb.append(result.serialize()); sb.append(", "); while ( - sequence.hasNext() - && - ((itemCount < AnnotationsTestsBase.configuration.getResultSizeCap() - && AnnotationsTestsBase.configuration.getResultSizeCap() > 0) - || - AnnotationsTestsBase.configuration.getResultSizeCap() == 0) + sequence.hasNext() + && + ((itemCount < AnnotationsTestsBase.configuration.getResultSizeCap() + && AnnotationsTestsBase.configuration.getResultSizeCap() > 0) + || + AnnotationsTestsBase.configuration.getResultSizeCap() == 0) ) { sb.append(sequence.next().serialize()); sb.append(", "); @@ -136,9 +139,9 @@ protected String getIteratorOutput(SequenceOfItems sequence) { } if (sequence.hasNext() && itemCount == AnnotationsTestsBase.configuration.getResultSizeCap()) { System.err.println( - "Warning! The output sequence contains a large number of items but its materialization was capped at " - + SparkSessionManager.COLLECT_ITEM_LIMIT - + " items. This value can be configured with the --result-size parameter at startup" + "Warning! The output sequence contains a large number of items but its materialization was capped at " + + SparkSessionManager.COLLECT_ITEM_LIMIT + + " items. This value can be configured with the --result-size parameter at startup" ); } // remove last comma diff --git a/src/test/java/iq/base/AnnotationsTestsBase.java b/src/test/java/iq/base/AnnotationsTestsBase.java index 763f7abdb5..bdc58b6c91 100644 --- a/src/test/java/iq/base/AnnotationsTestsBase.java +++ b/src/test/java/iq/base/AnnotationsTestsBase.java @@ -59,7 +59,7 @@ public void initializeTests(File dir) { /** * Tests annotations */ - protected void testAnnotations(String path) + protected void testAnnotations(String path, RumbleRuntimeConfiguration configuration) throws IOException { try { this.currentAnnotation = AnnotationProcessor.readAnnotation(new FileReader(path)); @@ -71,10 +71,10 @@ protected void testAnnotations(String path) try { URI uri = FileSystemUtil.resolveURIAgainstWorkingDirectory( path, - AnnotationsTestsBase.configuration, + configuration, ExceptionMetadata.EMPTY_METADATA ); - Rumble rumble = new Rumble(AnnotationsTestsBase.configuration); + Rumble rumble = new Rumble(configuration); sequence = rumble.runQuery(uri); } catch (ParsingException exception) { String errorOutput = exception.getMessage(); From 4cbb763bc883c277b6029e2a1fba09e684379719 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 10 Nov 2020 10:13:18 +0100 Subject: [PATCH 044/206] primary and comma expression tests --- src/test/resources/test_files/static-typing/comma.jq | 2 ++ .../resources/test_files/static-typing/primary/literals.jq | 4 ++-- .../resources/test_files/static-typing/primary/object1.jq | 2 +- .../resources/test_files/static-typing/primary/object2.jq | 2 ++ .../resources/test_files/static-typing/primary/object3.jq | 2 ++ .../test_files/static-typing/primary/staticFunctionCall1.jq | 3 ++- .../test_files/static-typing/primary/staticFunctionCall2.jq | 3 +++ .../test_files/static-typing/primary/staticFunctionCall3.jq | 3 +++ .../test_files/static-typing/primary/staticFunctionCall4.jq | 3 +++ .../test_files/static-typing/primary/variableReference1.jq | 6 ++++++ .../test_files/static-typing/primary/variableReference2.jq | 3 +++ .../test_files/static-typing/primary/variableReference3.jq | 3 +++ 12 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/test/resources/test_files/static-typing/comma.jq b/src/test/resources/test_files/static-typing/comma.jq index e69de29bb2..34507a3901 100644 --- a/src/test/resources/test_files/static-typing/comma.jq +++ b/src/test/resources/test_files/static-typing/comma.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +(1,2,3) is statically integer+ , (1) is statically integer, ("s",12) is statically atomic+, () is statically (), ((),()) is statically (), (1, (1,2)) is statically integer+, (1, (( )), ()) is statically integer, ((1,2,3)) is statically integer+, (null, null) is statically null+, (1 treat as integer?) is statically integer?, (1 treat as integer?, 2 treat as integer?) is statically integer* \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/literals.jq b/src/test/resources/test_files/static-typing/primary/literals.jq index 7bfa3a6564..0afa2f5214 100644 --- a/src/test/resources/test_files/static-typing/primary/literals.jq +++ b/src/test/resources/test_files/static-typing/primary/literals.jq @@ -1,2 +1,2 @@ -(:JIQS: ShouldRun; Output="4" :) -4 is statically integer \ No newline at end of file +(:JIQS: ShouldRun :) +(12 is statically integer, 12.33 is statically decimal, 12e4 is statically double, true is statically boolean, false is statically boolean, null is statically null, "qwerty" is statically string) is statically atomic+ \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/object1.jq b/src/test/resources/test_files/static-typing/primary/object1.jq index 6e35e60141..8236c25755 100644 --- a/src/test/resources/test_files/static-typing/primary/object1.jq +++ b/src/test/resources/test_files/static-typing/primary/object1.jq @@ -1,2 +1,2 @@ (:JIQS: ShouldRun :) -{"a" : 12} is statically object, { "a" treat as anyURI is statically anyURI : 12 \ No newline at end of file +{| {"a" : 12} is statically object, { "b" : 1} |} is statically object \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/object2.jq b/src/test/resources/test_files/static-typing/primary/object2.jq index e69de29bb2..9a0edf0c67 100644 --- a/src/test/resources/test_files/static-typing/primary/object2.jq +++ b/src/test/resources/test_files/static-typing/primary/object2.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +{ 12 : 13 } \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/object3.jq b/src/test/resources/test_files/static-typing/primary/object3.jq index e69de29bb2..bc0f5f0727 100644 --- a/src/test/resources/test_files/static-typing/primary/object3.jq +++ b/src/test/resources/test_files/static-typing/primary/object3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +{| 12, 3 |} \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/staticFunctionCall1.jq b/src/test/resources/test_files/static-typing/primary/staticFunctionCall1.jq index 3f985e5972..a688b18f60 100644 --- a/src/test/resources/test_files/static-typing/primary/staticFunctionCall1.jq +++ b/src/test/resources/test_files/static-typing/primary/staticFunctionCall1.jq @@ -1,2 +1,3 @@ (:JIQS: ShouldRun :) -sum(1,2) is statically integer \ No newline at end of file +declare function mySum($a as integer, $b as integer) as integer { $a + $b }; +mySum(2,2) is statically integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/staticFunctionCall2.jq b/src/test/resources/test_files/static-typing/primary/staticFunctionCall2.jq index e69de29bb2..c258b03440 100644 --- a/src/test/resources/test_files/static-typing/primary/staticFunctionCall2.jq +++ b/src/test/resources/test_files/static-typing/primary/staticFunctionCall2.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare function mySum($a as integer, $b as integer) as integer { $a + $b }; +mySum(2,"a") \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/staticFunctionCall3.jq b/src/test/resources/test_files/static-typing/primary/staticFunctionCall3.jq index e69de29bb2..5304f112bd 100644 --- a/src/test/resources/test_files/static-typing/primary/staticFunctionCall3.jq +++ b/src/test/resources/test_files/static-typing/primary/staticFunctionCall3.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare function mySum($a as integer, $b as integer) as integer { $a + $b }; +mySum(?,"a") \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/staticFunctionCall4.jq b/src/test/resources/test_files/static-typing/primary/staticFunctionCall4.jq index e69de29bb2..0bc83b6a38 100644 --- a/src/test/resources/test_files/static-typing/primary/staticFunctionCall4.jq +++ b/src/test/resources/test_files/static-typing/primary/staticFunctionCall4.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldRun :) +declare function mySum($a as double, $b as double) as double { $a + $b }; +mySum(2,2) is statically double \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/variableReference1.jq b/src/test/resources/test_files/static-typing/primary/variableReference1.jq index e69de29bb2..d589f15550 100644 --- a/src/test/resources/test_files/static-typing/primary/variableReference1.jq +++ b/src/test/resources/test_files/static-typing/primary/variableReference1.jq @@ -0,0 +1,6 @@ +(:JIQS: ShouldRun :) +declare variable $a := 12; +declare variable $b as decimal := 12; +declare variable $c := (1,3); +declare variable $d as integer? := 12; +$a is statically integer, $b is statically decimal, $c is statically integer+, $d is statically integer? \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/variableReference2.jq b/src/test/resources/test_files/static-typing/primary/variableReference2.jq index e69de29bb2..4426bbb737 100644 --- a/src/test/resources/test_files/static-typing/primary/variableReference2.jq +++ b/src/test/resources/test_files/static-typing/primary/variableReference2.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare variable $a as string := 12; +$a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/primary/variableReference3.jq b/src/test/resources/test_files/static-typing/primary/variableReference3.jq index e69de29bb2..b0376dfe26 100644 --- a/src/test/resources/test_files/static-typing/primary/variableReference3.jq +++ b/src/test/resources/test_files/static-typing/primary/variableReference3.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +declare variable $a := (); +$a \ No newline at end of file From 74ddc933b8086a598b3fdfb69824fc7edcd98e88 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 11 Nov 2020 10:43:23 +0100 Subject: [PATCH 045/206] added RBTY0001 error code --- .../org/rumbledb/compiler/InferTypeVisitor.java | 17 ++++++++++++----- .../java/org/rumbledb/errorcodes/ErrorCode.java | 2 ++ .../exceptions/IsStaticallyUnexpectedType.java | 11 +++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 src/main/java/org/rumbledb/exceptions/IsStaticallyUnexpectedType.java diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 64f3f46271..d7a00f65d6 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -6,6 +6,7 @@ import org.rumbledb.context.Name; import org.rumbledb.context.StaticContext; import org.rumbledb.errorcodes.ErrorCode; +import org.rumbledb.exceptions.IsStaticallyUnexpectedType; import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedStaticTypeException; import org.rumbledb.expressions.AbstractNodeVisitor; @@ -338,8 +339,11 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static public StaticContext visitCastableExpression(CastableExpression expression, StaticContext argument) { System.out.println("visiting Castable expression"); visitDescendants(expression, argument); - if(expression.getSequenceType().getItemType().equals(ItemType.atomicItem)){ - throw new UnexpectedStaticTypeException("atomic item type is not allowed in castable expression", ErrorCode.CastableErrorCode); + if (expression.getSequenceType().getItemType().equals(ItemType.atomicItem)) { + throw new UnexpectedStaticTypeException( + "atomic item type is not allowed in castable expression", + ErrorCode.CastableErrorCode + ); } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); return argument; @@ -354,8 +358,11 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex SequenceType expressionSequenceType = expression.getMainExpression().getInferredSequenceType(); SequenceType castedSequenceType = expression.getSequenceType(); - if(castedSequenceType.getItemType().equals(ItemType.atomicItem)){ - throw new UnexpectedStaticTypeException("atomic item type is not allowed in cast expression", ErrorCode.CastableErrorCode); + if (castedSequenceType.getItemType().equals(ItemType.atomicItem)) { + throw new UnexpectedStaticTypeException( + "atomic item type is not allowed in cast expression", + ErrorCode.CastableErrorCode + ); } // Empty sequence check @@ -402,7 +409,7 @@ public StaticContext visitIsStaticallyExpr(IsStaticallyExpression expression, St SequenceType inferred = expression.getMainExpression().getInferredSequenceType(); SequenceType expected = expression.getSequenceType(); if (!inferred.equals(expected)) { - throw new UnexpectedStaticTypeException( + throw new IsStaticallyUnexpectedType( "expected static type is " + expected + " instead " + inferred + " was inferred" ); } diff --git a/src/main/java/org/rumbledb/errorcodes/ErrorCode.java b/src/main/java/org/rumbledb/errorcodes/ErrorCode.java index 43a36ec8f0..d6de65e39a 100644 --- a/src/main/java/org/rumbledb/errorcodes/ErrorCode.java +++ b/src/main/java/org/rumbledb/errorcodes/ErrorCode.java @@ -67,6 +67,8 @@ public enum ErrorCode { JobWithinAJobErrorCode("RBST0003"), OurBadErrorCode("RBST0004"), + UnexpectedStaticType("RBTY0001"), + FunctionsNonSerializable("SENR0001"), diff --git a/src/main/java/org/rumbledb/exceptions/IsStaticallyUnexpectedType.java b/src/main/java/org/rumbledb/exceptions/IsStaticallyUnexpectedType.java new file mode 100644 index 0000000000..2ea3d4f72c --- /dev/null +++ b/src/main/java/org/rumbledb/exceptions/IsStaticallyUnexpectedType.java @@ -0,0 +1,11 @@ +package org.rumbledb.exceptions; + +import org.rumbledb.errorcodes.ErrorCode; + +public class IsStaticallyUnexpectedType extends RumbleException { + private static final long serialVersionUID = 1L; + + public IsStaticallyUnexpectedType(String message) { + super(message, ErrorCode.UnexpectedStaticType); + } +} From 85e465264a5bb015b0f0d76b0446a87f2b1216d3 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 11 Nov 2020 18:40:05 +0100 Subject: [PATCH 046/206] added typing expressions tests --- src/test/resources/test_files/static-typing/typing/cast1.jq | 2 ++ src/test/resources/test_files/static-typing/typing/cast2.jq | 6 ++++++ src/test/resources/test_files/static-typing/typing/cast3.jq | 2 ++ src/test/resources/test_files/static-typing/typing/cast4.jq | 2 ++ src/test/resources/test_files/static-typing/typing/cast5.jq | 2 ++ src/test/resources/test_files/static-typing/typing/cast6.jq | 2 ++ src/test/resources/test_files/static-typing/typing/cast7.jq | 2 ++ src/test/resources/test_files/static-typing/typing/cast8.jq | 2 ++ .../resources/test_files/static-typing/typing/castable1.jq | 2 ++ .../resources/test_files/static-typing/typing/castable2.jq | 2 ++ .../resources/test_files/static-typing/typing/castable3.jq | 2 ++ .../resources/test_files/static-typing/typing/castable4.jq | 2 ++ .../resources/test_files/static-typing/typing/instance.jq | 2 ++ src/test/resources/test_files/static-typing/typing/treat.jq | 2 ++ 14 files changed, 32 insertions(+) create mode 100644 src/test/resources/test_files/static-typing/typing/cast1.jq create mode 100644 src/test/resources/test_files/static-typing/typing/cast2.jq create mode 100644 src/test/resources/test_files/static-typing/typing/cast3.jq create mode 100644 src/test/resources/test_files/static-typing/typing/cast4.jq create mode 100644 src/test/resources/test_files/static-typing/typing/cast5.jq create mode 100644 src/test/resources/test_files/static-typing/typing/cast6.jq create mode 100644 src/test/resources/test_files/static-typing/typing/cast7.jq create mode 100644 src/test/resources/test_files/static-typing/typing/cast8.jq create mode 100644 src/test/resources/test_files/static-typing/typing/castable1.jq create mode 100644 src/test/resources/test_files/static-typing/typing/castable2.jq create mode 100644 src/test/resources/test_files/static-typing/typing/castable3.jq create mode 100644 src/test/resources/test_files/static-typing/typing/castable4.jq create mode 100644 src/test/resources/test_files/static-typing/typing/instance.jq create mode 100644 src/test/resources/test_files/static-typing/typing/treat.jq diff --git a/src/test/resources/test_files/static-typing/typing/cast1.jq b/src/test/resources/test_files/static-typing/typing/cast1.jq new file mode 100644 index 0000000000..46c2d6a16e --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/cast1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +(3 cast as decimal) is statically decimal, (3 cast as string) is statically string, (12 cast as double) is statically double, (33.23 cast as integer) is statically integer, (3 cast as boolean) is statically boolean, (false cast as integer) is statically integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/cast2.jq b/src/test/resources/test_files/static-typing/typing/cast2.jq new file mode 100644 index 0000000000..edaeb713a6 --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/cast2.jq @@ -0,0 +1,6 @@ +(:JIQS: ShouldRun :) +declare $date := '2020-02-12' cast as date +declare $dt := "2015-05-03T13:20:00" cast as dateTime +declare $hexb := "0cd7" cast as hexBinary +declare $base64b := "DNc=" cast as base64Binary +($base64b cast as hexBinary) is statically hexBinary, ($hexb cast as base64Binary) is statically base64Binary, ($dt cast as date) is statically date, ($dt cast as time) is statically time, ($date cast as dateTime) is statically dateTime, (null cast as null) is statically null, (3 cast as integer?) is statically integer? \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/cast3.jq b/src/test/resources/test_files/static-typing/typing/cast3.jq new file mode 100644 index 0000000000..6bedba3f87 --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/cast3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(12 treat as atomic) cast as integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/cast4.jq b/src/test/resources/test_files/static-typing/typing/cast4.jq new file mode 100644 index 0000000000..a88e18ee5f --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/cast4.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(12 treat as item) cast as integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/cast5.jq b/src/test/resources/test_files/static-typing/typing/cast5.jq new file mode 100644 index 0000000000..06f0b716ea --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/cast5.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +("13:20:00" cast as time) cast as dateTime \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/cast6.jq b/src/test/resources/test_files/static-typing/typing/cast6.jq new file mode 100644 index 0000000000..fd9e04aa7c --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/cast6.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(3 treat as integer?) cast as integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/cast7.jq b/src/test/resources/test_files/static-typing/typing/cast7.jq new file mode 100644 index 0000000000..0a987c255c --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/cast7.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0080" :) +3 cast as atomic \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/cast8.jq b/src/test/resources/test_files/static-typing/typing/cast8.jq new file mode 100644 index 0000000000..56f9a92930 --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/cast8.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="JNTY0004" :) +[] cast as integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/castable1.jq b/src/test/resources/test_files/static-typing/typing/castable1.jq new file mode 100644 index 0000000000..27becd2139 --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/castable1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +(3 castable as decimal?) is statically boolean \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/castable2.jq b/src/test/resources/test_files/static-typing/typing/castable2.jq new file mode 100644 index 0000000000..35dc437dd2 --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/castable2.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="JNTY0004" :) +[] castable as integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/castable3.jq b/src/test/resources/test_files/static-typing/typing/castable3.jq new file mode 100644 index 0000000000..8bd726d6ec --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/castable3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(3 treat as item) castable as integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/castable4.jq b/src/test/resources/test_files/static-typing/typing/castable4.jq new file mode 100644 index 0000000000..1e006b0143 --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/castable4.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0080" :) +2 castable as atomic \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/instance.jq b/src/test/resources/test_files/static-typing/typing/instance.jq new file mode 100644 index 0000000000..67465af8d4 --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/instance.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +(3 instance of array) is statically boolean, ("qwerty" instance of item*) is statically boolean, ((1,2,3) instance of integer+) is statically boolean diff --git a/src/test/resources/test_files/static-typing/typing/treat.jq b/src/test/resources/test_files/static-typing/typing/treat.jq new file mode 100644 index 0000000000..629b2241af --- /dev/null +++ b/src/test/resources/test_files/static-typing/typing/treat.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +(3 treat as object) is statically object, (4 treat as atomic+) is statically atomic+ From 048abc4668ff9e29331a9d789da63d6f10e84389 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 11 Nov 2020 21:02:50 +0100 Subject: [PATCH 047/206] added arithmetic tests --- .../resources/test_files/static-typing/arithmetic/add1.jq | 2 ++ .../resources/test_files/static-typing/arithmetic/add10.jq | 2 ++ .../resources/test_files/static-typing/arithmetic/add11.jq | 2 ++ .../resources/test_files/static-typing/arithmetic/add2.jq | 7 +++++++ .../resources/test_files/static-typing/arithmetic/add3.jq | 2 ++ .../resources/test_files/static-typing/arithmetic/add4.jq | 2 ++ .../resources/test_files/static-typing/arithmetic/add5.jq | 2 ++ .../resources/test_files/static-typing/arithmetic/add6.jq | 4 ++++ .../resources/test_files/static-typing/arithmetic/add7.jq | 4 ++++ .../resources/test_files/static-typing/arithmetic/add8.jq | 3 +++ .../resources/test_files/static-typing/arithmetic/add9.jq | 4 ++++ .../resources/test_files/static-typing/arithmetic/mul1.jq | 2 ++ .../resources/test_files/static-typing/arithmetic/mul10.jq | 2 ++ .../resources/test_files/static-typing/arithmetic/mul2.jq | 4 ++++ .../resources/test_files/static-typing/arithmetic/mul3.jq | 3 +++ .../resources/test_files/static-typing/arithmetic/mul4.jq | 3 +++ .../resources/test_files/static-typing/arithmetic/mul5.jq | 4 ++++ .../resources/test_files/static-typing/arithmetic/mul6.jq | 3 +++ .../resources/test_files/static-typing/arithmetic/mul7.jq | 2 ++ .../resources/test_files/static-typing/arithmetic/mul8.jq | 2 ++ .../resources/test_files/static-typing/arithmetic/mul9.jq | 2 ++ .../test_files/static-typing/arithmetic/unary1.jq | 2 ++ .../test_files/static-typing/arithmetic/unary2.jq | 2 ++ .../test_files/static-typing/arithmetic/unary3.jq | 2 ++ .../test_files/static-typing/arithmetic/unary4.jq | 2 ++ .../test_files/static-typing/arithmetic/unary5.jq | 2 ++ 26 files changed, 71 insertions(+) create mode 100644 src/test/resources/test_files/static-typing/arithmetic/add1.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/add10.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/add11.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/add2.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/add3.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/add4.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/add5.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/add6.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/add7.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/add8.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/add9.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/mul1.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/mul10.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/mul2.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/mul3.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/mul4.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/mul5.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/mul6.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/mul7.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/mul8.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/mul9.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/unary1.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/unary2.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/unary3.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/unary4.jq create mode 100644 src/test/resources/test_files/static-typing/arithmetic/unary5.jq diff --git a/src/test/resources/test_files/static-typing/arithmetic/add1.jq b/src/test/resources/test_files/static-typing/arithmetic/add1.jq new file mode 100644 index 0000000000..54fe7ffe9a --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/add1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +(3 + 3) is statically integer, (3 + 3.12) is statically decimal, (3 + 3e4) is statically double, (3.2 + 3e4) is statically double, (12 treat as integer? + 12) is statically integer?, (12 treat as integer? + 3.44) is statically decimal? \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add10.jq b/src/test/resources/test_files/static-typing/arithmetic/add10.jq new file mode 100644 index 0000000000..6cc2616709 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/add10.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +12 + "qwerty" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add11.jq b/src/test/resources/test_files/static-typing/arithmetic/add11.jq new file mode 100644 index 0000000000..41ef9acef3 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/add11.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +12 + "12" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add2.jq b/src/test/resources/test_files/static-typing/arithmetic/add2.jq new file mode 100644 index 0000000000..795dc19d1c --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/add2.jq @@ -0,0 +1,7 @@ +(:JIQS: ShouldRun :) +declare $date := '2020-02-12' cast as date +declare $dt := "2015-05-03T13:20:00" cast as dateTime +declare $time := "13:20:00" cast as time +declare $dtdur := "P2DT3H" cast as dayTimeDuration +declare $ymdur := "P1Y2M" cast as yearMonthDuration +($dt + $dtdur) is statically dateTime, ($dt + $ymdur) is statically dateTime, ($date + $dtdur) is statically date, ($date + $ymdur) is statically date, ($time + $dtdur) is statically time, ($dtdur + $dtdur) is statically dayTimeDuration, ($ymdur + $ymdur) is statically yearMonthDuration, ($dt - $dt) is statically dayTimeDuration, ($date - $date) is statically dayTimeDuration, ($time - $time) is statically dayTimeDuration \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add3.jq b/src/test/resources/test_files/static-typing/arithmetic/add3.jq new file mode 100644 index 0000000000..b50a5c6e9a --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/add3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(1,2) + 5 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add4.jq b/src/test/resources/test_files/static-typing/arithmetic/add4.jq new file mode 100644 index 0000000000..1bb1b575d8 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/add4.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +() + 12 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add5.jq b/src/test/resources/test_files/static-typing/arithmetic/add5.jq new file mode 100644 index 0000000000..4da9248edc --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/add5.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +() - "qwe" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add6.jq b/src/test/resources/test_files/static-typing/arithmetic/add6.jq new file mode 100644 index 0000000000..2af06cb83b --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/add6.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $time := "13:20:00" cast as time +declare $ymdur := "P1Y2M" cast as yearMonthDuration +$time + $ymdur \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add7.jq b/src/test/resources/test_files/static-typing/arithmetic/add7.jq new file mode 100644 index 0000000000..4a5be4628f --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/add7.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $dtdur := "P2DT3H" cast as dayTimeDuration +declare $ymdur := "P1Y2M" cast as yearMonthDuration +$dtdur + $ymdur \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add8.jq b/src/test/resources/test_files/static-typing/arithmetic/add8.jq new file mode 100644 index 0000000000..90b956f2a0 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/add8.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $dt := "2015-05-03T13:20:00" cast as dateTime +$dt + 3 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add9.jq b/src/test/resources/test_files/static-typing/arithmetic/add9.jq new file mode 100644 index 0000000000..842a6bdfdc --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/add9.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $date := '2020-02-12' cast as date +declare $dt := "2015-05-03T13:20:00" cast as dateTime +$dt - $date \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul1.jq b/src/test/resources/test_files/static-typing/arithmetic/mul1.jq new file mode 100644 index 0000000000..ae94144b34 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/mul1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +(3 * 12.2) is statically decimal, (3 treat as integer? * 12.2) is statically decimal?, (2 * 2) is statically integer, (6 idiv 5) is statically integer, (3.22 idiv 1.3) is statically integer, (3e4 idiv 14.44) is statically integer, ($dtdur idiv 2.22) is statically XPTY0004, (6 div 5) is statically decimal, (10 div 5) is statically decimal, (12 div 3.3) is statically decimal, (2e3 div 13) is statically double, (3 mod 1.2) is statically decimal, (34 mod 11) is statically integer, (3e4 mod 29) is statically double \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul10.jq b/src/test/resources/test_files/static-typing/arithmetic/mul10.jq new file mode 100644 index 0000000000..a0124b379b --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/mul10.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +"qwe" * () \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul2.jq b/src/test/resources/test_files/static-typing/arithmetic/mul2.jq new file mode 100644 index 0000000000..5666a9d14d --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/mul2.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +declare $dtdur := "P2DT3H" cast as dayTimeDuration +declare $ymdur := "P1Y2M" cast as yearMonthDuration +(3 * $ymdur) is statically yearMonthDuration, (3e4 * $ymdur) is statically yearMonthDuration, (2 * $dtdur) is statically dayTimeDuration, ($dtdur * 3.12) is statically dayTimeDuration, ($ymdur div 4.3) is statically yearMonthDuration, ($dtdur div 12) is statically dayTimeDuration, ($ymdur div $ymdur) is statically decimal, ($dtdur div $dtdur) is statically decimal \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul3.jq b/src/test/resources/test_files/static-typing/arithmetic/mul3.jq new file mode 100644 index 0000000000..875237403b --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/mul3.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $ymdur := "P1Y2M" cast as yearMonthDuration +$ymdur idiv 3 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul4.jq b/src/test/resources/test_files/static-typing/arithmetic/mul4.jq new file mode 100644 index 0000000000..feba00cd96 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/mul4.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $dtdur := "P2DT3H" cast as dayTimeDuration +$dtdur idiv 2.22 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul5.jq b/src/test/resources/test_files/static-typing/arithmetic/mul5.jq new file mode 100644 index 0000000000..50cbc57236 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/mul5.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $dtdur := "P2DT3H" cast as dayTimeDuration +declare $ymdur := "P1Y2M" cast as yearMonthDuration +$ymdur div $dtdur \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul6.jq b/src/test/resources/test_files/static-typing/arithmetic/mul6.jq new file mode 100644 index 0000000000..80f5780be1 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/mul6.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $dtdur := "P2DT3H" cast as dayTimeDuration +$dtdur mod 12 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul7.jq b/src/test/resources/test_files/static-typing/arithmetic/mul7.jq new file mode 100644 index 0000000000..a02327ceb5 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/mul7.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +"qwqw" * 3 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul8.jq b/src/test/resources/test_files/static-typing/arithmetic/mul8.jq new file mode 100644 index 0000000000..df21553a2e --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/mul8.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(1, 4, 7) * 8 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul9.jq b/src/test/resources/test_files/static-typing/arithmetic/mul9.jq new file mode 100644 index 0000000000..fb0d525229 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/mul9.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +3 * () \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/unary1.jq b/src/test/resources/test_files/static-typing/arithmetic/unary1.jq new file mode 100644 index 0000000000..7b4c0ed889 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/unary1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +(-12) is statically integer, (-12.44) is statically decimal, (+12e4) is statically double \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/unary2.jq b/src/test/resources/test_files/static-typing/arithmetic/unary2.jq new file mode 100644 index 0000000000..ade101e30a --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/unary2.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +- "qwerty" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/unary3.jq b/src/test/resources/test_files/static-typing/arithmetic/unary3.jq new file mode 100644 index 0000000000..f321a2b672 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/unary3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +- (1,2,3) \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/unary4.jq b/src/test/resources/test_files/static-typing/arithmetic/unary4.jq new file mode 100644 index 0000000000..211f146de3 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/unary4.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +- () \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/unary5.jq b/src/test/resources/test_files/static-typing/arithmetic/unary5.jq new file mode 100644 index 0000000000..341a478f92 --- /dev/null +++ b/src/test/resources/test_files/static-typing/arithmetic/unary5.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +- (12 treat as integer*) \ No newline at end of file From ec5aee88671646dda76eab44a69a96b63ce417bf Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 11 Nov 2020 21:24:37 +0100 Subject: [PATCH 048/206] added logic and misc tests --- src/test/resources/test_files/static-typing/logic1.jq | 2 ++ src/test/resources/test_files/static-typing/logic2.jq | 7 +++++++ src/test/resources/test_files/static-typing/logic3.jq | 2 ++ src/test/resources/test_files/static-typing/logic4.jq | 2 ++ .../resources/test_files/static-typing/misc/concat1.jq | 2 ++ .../resources/test_files/static-typing/misc/concat2.jq | 2 ++ .../resources/test_files/static-typing/misc/concat3.jq | 2 ++ .../resources/test_files/static-typing/misc/concat4.jq | 2 ++ .../resources/test_files/static-typing/misc/concat5.jq | 2 ++ .../resources/test_files/static-typing/misc/concat6.jq | 2 ++ src/test/resources/test_files/static-typing/misc/range1.jq | 2 ++ src/test/resources/test_files/static-typing/misc/range2.jq | 2 ++ src/test/resources/test_files/static-typing/misc/range3.jq | 2 ++ src/test/resources/test_files/static-typing/misc/range4.jq | 2 ++ src/test/resources/test_files/static-typing/misc/range5.jq | 2 ++ src/test/resources/test_files/static-typing/misc/range6.jq | 2 ++ 16 files changed, 37 insertions(+) create mode 100644 src/test/resources/test_files/static-typing/logic1.jq create mode 100644 src/test/resources/test_files/static-typing/logic2.jq create mode 100644 src/test/resources/test_files/static-typing/logic3.jq create mode 100644 src/test/resources/test_files/static-typing/logic4.jq create mode 100644 src/test/resources/test_files/static-typing/misc/concat1.jq create mode 100644 src/test/resources/test_files/static-typing/misc/concat2.jq create mode 100644 src/test/resources/test_files/static-typing/misc/concat3.jq create mode 100644 src/test/resources/test_files/static-typing/misc/concat4.jq create mode 100644 src/test/resources/test_files/static-typing/misc/concat5.jq create mode 100644 src/test/resources/test_files/static-typing/misc/concat6.jq create mode 100644 src/test/resources/test_files/static-typing/misc/range1.jq create mode 100644 src/test/resources/test_files/static-typing/misc/range2.jq create mode 100644 src/test/resources/test_files/static-typing/misc/range3.jq create mode 100644 src/test/resources/test_files/static-typing/misc/range4.jq create mode 100644 src/test/resources/test_files/static-typing/misc/range5.jq create mode 100644 src/test/resources/test_files/static-typing/misc/range6.jq diff --git a/src/test/resources/test_files/static-typing/logic1.jq b/src/test/resources/test_files/static-typing/logic1.jq new file mode 100644 index 0000000000..b649517fc3 --- /dev/null +++ b/src/test/resources/test_files/static-typing/logic1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +(() and 3 and 3.12 and 3e4 and false and null) is statically boolean, ("qwe" or "" or (12 treat as integer?) or ( [1, 2], {"a" : "b"} )) is statically boolean, (not [1, 4]) is statically boolean \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/logic2.jq b/src/test/resources/test_files/static-typing/logic2.jq new file mode 100644 index 0000000000..8afd1d3d16 --- /dev/null +++ b/src/test/resources/test_files/static-typing/logic2.jq @@ -0,0 +1,7 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $date := '2020-02-12' cast as date +declare $dt := "2015-05-03T13:20:00" cast as dateTime +declare $time := "13:20:00" cast as time +declare $hexb := "0cd7" cast as hexBinary +declare $base64b := "DNc=" cast as base64Binary +$date or $time or $dt or $hexb and $base64b \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/logic3.jq b/src/test/resources/test_files/static-typing/logic3.jq new file mode 100644 index 0000000000..a1b6f8dd9b --- /dev/null +++ b/src/test/resources/test_files/static-typing/logic3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(1, 3, 5) or ([1,2], "qwe") \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/logic4.jq b/src/test/resources/test_files/static-typing/logic4.jq new file mode 100644 index 0000000000..5e1d4e5d87 --- /dev/null +++ b/src/test/resources/test_files/static-typing/logic4.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +1 treat as integer* and false \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/concat1.jq b/src/test/resources/test_files/static-typing/misc/concat1.jq new file mode 100644 index 0000000000..d76098d852 --- /dev/null +++ b/src/test/resources/test_files/static-typing/misc/concat1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +("qwe" || "rty") is statically string, (() || ()) is statically string, (12 || $date) is statically string, (33.3 || $hexb) is statically string, (12 treat as atomic? || null) is statically string \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/concat2.jq b/src/test/resources/test_files/static-typing/misc/concat2.jq new file mode 100644 index 0000000000..c5bac06d63 --- /dev/null +++ b/src/test/resources/test_files/static-typing/misc/concat2.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +[] || "qwe" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/concat3.jq b/src/test/resources/test_files/static-typing/misc/concat3.jq new file mode 100644 index 0000000000..5c78dc41ec --- /dev/null +++ b/src/test/resources/test_files/static-typing/misc/concat3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +{"obj" : 12 } || "qwe" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/concat4.jq b/src/test/resources/test_files/static-typing/misc/concat4.jq new file mode 100644 index 0000000000..c810f3ae89 --- /dev/null +++ b/src/test/resources/test_files/static-typing/misc/concat4.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +"qwe" treat as item || "qwe" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/concat5.jq b/src/test/resources/test_files/static-typing/misc/concat5.jq new file mode 100644 index 0000000000..b809b1e499 --- /dev/null +++ b/src/test/resources/test_files/static-typing/misc/concat5.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +("q", "w") || "erty" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/concat6.jq b/src/test/resources/test_files/static-typing/misc/concat6.jq new file mode 100644 index 0000000000..cf2fcc810e --- /dev/null +++ b/src/test/resources/test_files/static-typing/misc/concat6.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +12 treat as integer* || "aaa" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/range1.jq b/src/test/resources/test_files/static-typing/misc/range1.jq new file mode 100644 index 0000000000..2dd82580bd --- /dev/null +++ b/src/test/resources/test_files/static-typing/misc/range1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +(3 to 7) is statically integer*, (10 to 4) is statically integer*, ((3 treat as integer?) to 22 ) is statically integer* \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/range2.jq b/src/test/resources/test_files/static-typing/misc/range2.jq new file mode 100644 index 0000000000..f97a37a311 --- /dev/null +++ b/src/test/resources/test_files/static-typing/misc/range2.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(3 treat as integer*) to 22 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/range3.jq b/src/test/resources/test_files/static-typing/misc/range3.jq new file mode 100644 index 0000000000..73385a3176 --- /dev/null +++ b/src/test/resources/test_files/static-typing/misc/range3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +10 to (20, 30) \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/range4.jq b/src/test/resources/test_files/static-typing/misc/range4.jq new file mode 100644 index 0000000000..d479e0eb6c --- /dev/null +++ b/src/test/resources/test_files/static-typing/misc/range4.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +12 to 22.22 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/range5.jq b/src/test/resources/test_files/static-typing/misc/range5.jq new file mode 100644 index 0000000000..ad9fb3d203 --- /dev/null +++ b/src/test/resources/test_files/static-typing/misc/range5.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +"12" to 18 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/range6.jq b/src/test/resources/test_files/static-typing/misc/range6.jq new file mode 100644 index 0000000000..f25219eaed --- /dev/null +++ b/src/test/resources/test_files/static-typing/misc/range6.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +() to 12 \ No newline at end of file From d39a411290899d74c4b3706ce15298c370d45f9d Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 11 Nov 2020 22:04:08 +0100 Subject: [PATCH 049/206] postfix, quantified and map expressions static types tests --- src/test/resources/test_files/static-typing/map1.jq | 2 ++ src/test/resources/test_files/static-typing/map2.jq | 2 ++ src/test/resources/test_files/static-typing/map3.jq | 2 ++ .../test_files/static-typing/postfix/arraylookup1.jq | 2 ++ .../test_files/static-typing/postfix/arraylookup2.jq | 2 ++ .../test_files/static-typing/postfix/arraylookup3.jq | 2 ++ .../test_files/static-typing/postfix/arraylookup4.jq | 2 ++ .../resources/test_files/static-typing/postfix/arrayunbox1.jq | 2 ++ .../resources/test_files/static-typing/postfix/arrayunbox2.jq | 2 ++ .../resources/test_files/static-typing/postfix/arrayunbox3.jq | 2 ++ .../resources/test_files/static-typing/postfix/arrayunbox4.jq | 2 ++ .../test_files/static-typing/postfix/dynamicfunc1.jq | 4 ++++ .../test_files/static-typing/postfix/dynamicfunc2.jq | 3 +++ .../resources/test_files/static-typing/postfix/filter1.jq | 2 ++ .../resources/test_files/static-typing/postfix/filter2.jq | 2 ++ .../resources/test_files/static-typing/postfix/filter3.jq | 2 ++ .../resources/test_files/static-typing/postfix/filter4.jq | 2 ++ .../resources/test_files/static-typing/postfix/filter5.jq | 2 ++ .../test_files/static-typing/postfix/objectlookup1.jq | 2 ++ .../test_files/static-typing/postfix/objectlookup2.jq | 2 ++ .../test_files/static-typing/postfix/objectlookup3.jq | 2 ++ .../test_files/static-typing/postfix/objectlookup4.jq | 2 ++ .../test_files/static-typing/postfix/objectlookup5.jq | 2 ++ .../test_files/static-typing/postfix/objectlookup6.jq | 2 ++ .../test_files/static-typing/postfix/objectlookup7.jq | 2 ++ src/test/resources/test_files/static-typing/quantified1.jq | 2 ++ src/test/resources/test_files/static-typing/quantified2.jq | 3 +++ 27 files changed, 58 insertions(+) create mode 100644 src/test/resources/test_files/static-typing/map1.jq create mode 100644 src/test/resources/test_files/static-typing/map2.jq create mode 100644 src/test/resources/test_files/static-typing/map3.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/arraylookup1.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/arraylookup2.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/arraylookup3.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/arraylookup4.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/arrayunbox1.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/arrayunbox2.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/arrayunbox3.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/arrayunbox4.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/dynamicfunc2.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/filter1.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/filter2.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/filter3.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/filter4.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/filter5.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/objectlookup1.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/objectlookup2.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/objectlookup3.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/objectlookup4.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/objectlookup5.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/objectlookup6.jq create mode 100644 src/test/resources/test_files/static-typing/postfix/objectlookup7.jq create mode 100644 src/test/resources/test_files/static-typing/quantified1.jq create mode 100644 src/test/resources/test_files/static-typing/quantified2.jq diff --git a/src/test/resources/test_files/static-typing/map1.jq b/src/test/resources/test_files/static-typing/map1.jq new file mode 100644 index 0000000000..9c368d8c43 --- /dev/null +++ b/src/test/resources/test_files/static-typing/map1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +((1,2,3) ! ($$ + 3)) is statically integer+, ((1) ! ($$ + 3)) is statically integer, ((1) ! ($$ + 2, $$ + 3)) is statically integer+, ((1 treat as integer?) ! ($$ + 1)) is statically integer?, ((1 treat as integer?) ! ( $$ + 1 , $$ + 2 )) is statically integer*, ((1,2,"qw") ! ($$ || "postfix")) is statically string+, ((1, 2.33) ! ($$)) is statically atomic+ \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/map2.jq b/src/test/resources/test_files/static-typing/map2.jq new file mode 100644 index 0000000000..23b0deddf0 --- /dev/null +++ b/src/test/resources/test_files/static-typing/map2.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +() ! "qwe" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/map3.jq b/src/test/resources/test_files/static-typing/map3.jq new file mode 100644 index 0000000000..eed173244c --- /dev/null +++ b/src/test/resources/test_files/static-typing/map3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +(1,2,3) ! () \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/arraylookup1.jq b/src/test/resources/test_files/static-typing/postfix/arraylookup1.jq new file mode 100644 index 0000000000..52346a389f --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/arraylookup1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +([1,2,3][[2]]) is statically item?, (([1,2,3], [1,2,3])[[1]]) is statically item*, ([1,2,3][[12]]) is statically item?, (({"a":12}, 3)[[4]]) is statically item* \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/arraylookup2.jq b/src/test/resources/test_files/static-typing/postfix/arraylookup2.jq new file mode 100644 index 0000000000..486ffba2b1 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/arraylookup2.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +(1,2,3)[[1]] \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/arraylookup3.jq b/src/test/resources/test_files/static-typing/postfix/arraylookup3.jq new file mode 100644 index 0000000000..cb433f9118 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/arraylookup3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +({"a":12})[[2]] \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/arraylookup4.jq b/src/test/resources/test_files/static-typing/postfix/arraylookup4.jq new file mode 100644 index 0000000000..b47377082a --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/arraylookup4.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +[1][["12"]] \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/arrayunbox1.jq b/src/test/resources/test_files/static-typing/postfix/arrayunbox1.jq new file mode 100644 index 0000000000..8e3922bae6 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/arrayunbox1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +([1,2,3][]) is statically item*, (([1,2],[3])[]) is statically item*, (({"a":12}, 3)[]) is statically item*, ([1,2,"a","b",{"a":12}][]) is statically item* \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/arrayunbox2.jq b/src/test/resources/test_files/static-typing/postfix/arrayunbox2.jq new file mode 100644 index 0000000000..5c29c1feb5 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/arrayunbox2.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +(1,2,3)[] \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/arrayunbox3.jq b/src/test/resources/test_files/static-typing/postfix/arrayunbox3.jq new file mode 100644 index 0000000000..4b4f500cda --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/arrayunbox3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +{"a":12}[] \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/arrayunbox4.jq b/src/test/resources/test_files/static-typing/postfix/arrayunbox4.jq new file mode 100644 index 0000000000..cbb58fe822 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/arrayunbox4.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +(1,2,"a")[] \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq b/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq new file mode 100644 index 0000000000..137d0a8fad --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +declare function a($b) { "a" || $b }; +declare variable $a := a#1; +$a(12) is statically item*, $a(?) is statically function \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/dynamicfunc2.jq b/src/test/resources/test_files/static-typing/postfix/dynamicfunc2.jq new file mode 100644 index 0000000000..6a88460e96 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/dynamicfunc2.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare variable $a := 12; +$a("a") \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/filter1.jq b/src/test/resources/test_files/static-typing/postfix/filter1.jq new file mode 100644 index 0000000000..46646bc603 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/filter1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +((1,2,3)[$$]) is statically item*, ((1)[$$ gt 12]) is statically item? \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/filter2.jq b/src/test/resources/test_files/static-typing/postfix/filter2.jq new file mode 100644 index 0000000000..c501d165b5 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/filter2.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +(1,2)[null] \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/filter3.jq b/src/test/resources/test_files/static-typing/postfix/filter3.jq new file mode 100644 index 0000000000..609f141d0c --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/filter3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +(1,2)[()] \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/filter4.jq b/src/test/resources/test_files/static-typing/postfix/filter4.jq new file mode 100644 index 0000000000..d224a49905 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/filter4.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +()[$$ gt 22] \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/filter5.jq b/src/test/resources/test_files/static-typing/postfix/filter5.jq new file mode 100644 index 0000000000..576c816a50 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/filter5.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(1 treat as item)[$$] \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/objectlookup1.jq b/src/test/resources/test_files/static-typing/postfix/objectlookup1.jq new file mode 100644 index 0000000000..71aaa546df --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/objectlookup1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +({"a":12}.a) is statically item?, ({"a":12}.b) is statically item?, (({"a": 15}, {"b":"qwe"}, {"a":12}).a) is statically item*, ({"a":12}.(12)) is statically item?, ({"a":12}.("a")) is statically item?, ((1, [12]).a) is statically item*, ((1, 2, {"a":12}).b) is statically item* \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/objectlookup2.jq b/src/test/resources/test_files/static-typing/postfix/objectlookup2.jq new file mode 100644 index 0000000000..884ef2c908 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/objectlookup2.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +{"a":12}.(12,13) \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/objectlookup3.jq b/src/test/resources/test_files/static-typing/postfix/objectlookup3.jq new file mode 100644 index 0000000000..3e1d3acb78 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/objectlookup3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +{"a":12}.() \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/objectlookup4.jq b/src/test/resources/test_files/static-typing/postfix/objectlookup4.jq new file mode 100644 index 0000000000..6358fc00b8 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/objectlookup4.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +{"a":12}.([1]) \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/objectlookup5.jq b/src/test/resources/test_files/static-typing/postfix/objectlookup5.jq new file mode 100644 index 0000000000..85ccd685a5 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/objectlookup5.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +{"a":12}.("a" treat as item) \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/objectlookup6.jq b/src/test/resources/test_files/static-typing/postfix/objectlookup6.jq new file mode 100644 index 0000000000..7bc7a3e03a --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/objectlookup6.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +(1,2,3).a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/objectlookup7.jq b/src/test/resources/test_files/static-typing/postfix/objectlookup7.jq new file mode 100644 index 0000000000..e24dfdf91b --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/objectlookup7.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +([1],[]).a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/quantified1.jq b/src/test/resources/test_files/static-typing/quantified1.jq new file mode 100644 index 0000000000..4ccd76f612 --- /dev/null +++ b/src/test/resources/test_files/static-typing/quantified1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +(some $a in (1, 2) satisfies $a gt 12) is statically boolean, (some $a in () satisfies $a div 5) is statically boolean \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/quantified2.jq b/src/test/resources/test_files/static-typing/quantified2.jq new file mode 100644 index 0000000000..f26629306b --- /dev/null +++ b/src/test/resources/test_files/static-typing/quantified2.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $hexb := "0cd7" cast as hexBinary +some $a in ($hexb) satisfies $a \ No newline at end of file From 6f403d7b4f13efa01388cb62aad6333aa1bf1ec8 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 11 Nov 2020 22:17:45 +0100 Subject: [PATCH 050/206] added comparison expression static type tests --- .../test_files/static-typing/comparison/comp1.jq | 2 ++ .../test_files/static-typing/comparison/comp10.jq | 4 ++++ .../test_files/static-typing/comparison/comp11.jq | 3 +++ .../test_files/static-typing/comparison/comp12.jq | 3 +++ .../test_files/static-typing/comparison/comp13.jq | 4 ++++ .../test_files/static-typing/comparison/comp14.jq | 2 ++ .../test_files/static-typing/comparison/comp15.jq | 2 ++ .../test_files/static-typing/comparison/comp16.jq | 2 ++ .../test_files/static-typing/comparison/comp17.jq | 2 ++ .../test_files/static-typing/comparison/comp18.jq | 2 ++ .../test_files/static-typing/comparison/comp19.jq | 2 ++ .../test_files/static-typing/comparison/comp2.jq | 9 +++++++++ .../test_files/static-typing/comparison/comp20.jq | 2 ++ .../test_files/static-typing/comparison/comp3.jq | 2 ++ .../test_files/static-typing/comparison/comp4.jq | 2 ++ .../test_files/static-typing/comparison/comp5.jq | 2 ++ .../test_files/static-typing/comparison/comp6.jq | 2 ++ .../test_files/static-typing/comparison/comp7.jq | 2 ++ .../test_files/static-typing/comparison/comp8.jq | 4 ++++ .../test_files/static-typing/comparison/comp9.jq | 4 ++++ 20 files changed, 57 insertions(+) create mode 100644 src/test/resources/test_files/static-typing/comparison/comp1.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp10.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp11.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp12.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp13.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp14.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp15.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp16.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp17.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp18.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp19.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp2.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp20.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp3.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp4.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp5.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp6.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp7.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp8.jq create mode 100644 src/test/resources/test_files/static-typing/comparison/comp9.jq diff --git a/src/test/resources/test_files/static-typing/comparison/comp1.jq b/src/test/resources/test_files/static-typing/comparison/comp1.jq new file mode 100644 index 0000000000..f09e656d52 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp1.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +(1 eq 2) is statically boolean, (1 eq (2 treat as integer?)) is statically boolean?, (1 eq 2.2) is statically boolean, (1 ge 3e4) is statically boolean, (2.2 gt 3e2) is statically boolean, (3.3 le 34) is statically boolean, (12 lt 23) is statically boolean, (13 ne 1.2) is statically boolean, ("ab" eq "we") is statically boolean, ("ad" gt "qw") is statically boolean, (("qw" treat as anyURI) gt "erty") is statically boolean, (true eq false) is statically boolean, (true gt false) is statically boolean \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp10.jq b/src/test/resources/test_files/static-typing/comparison/comp10.jq new file mode 100644 index 0000000000..add3000745 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp10.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $dtdur := "P2DT3H" cast as dayTimeDuration +declare $ymdur := "P1Y2M" cast as yearMonthDuration +$ymdur lt $dtdur \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp11.jq b/src/test/resources/test_files/static-typing/comparison/comp11.jq new file mode 100644 index 0000000000..b68406149d --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp11.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $hexb := "0cd7" cast as hexBinary +$hexb lt $hexb \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp12.jq b/src/test/resources/test_files/static-typing/comparison/comp12.jq new file mode 100644 index 0000000000..7b9f28e026 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp12.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $base64b := "DNc=" cast as base64Binary +$base64b lt $base64b \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp13.jq b/src/test/resources/test_files/static-typing/comparison/comp13.jq new file mode 100644 index 0000000000..4a8fb412e8 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp13.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $hexb := "0cd7" cast as hexBinary +declare $base64b := "DNc=" cast as base64Binary +$hexb eq $base64b \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp14.jq b/src/test/resources/test_files/static-typing/comparison/comp14.jq new file mode 100644 index 0000000000..953f01b089 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp14.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +("a" treat as atomic) eq "a" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp15.jq b/src/test/resources/test_files/static-typing/comparison/comp15.jq new file mode 100644 index 0000000000..7d47f91fac --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp15.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(1, 2, 3) eq 2 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp16.jq b/src/test/resources/test_files/static-typing/comparison/comp16.jq new file mode 100644 index 0000000000..baade0a1f3 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp16.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(1, 2, 3) ne (1, 2, 3) \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp17.jq b/src/test/resources/test_files/static-typing/comparison/comp17.jq new file mode 100644 index 0000000000..be35ba7b31 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp17.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(1 treat as integer*) eq 1 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp18.jq b/src/test/resources/test_files/static-typing/comparison/comp18.jq new file mode 100644 index 0000000000..12f3c7ecd7 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp18.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(1,2,3,"a") < (2,33) \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp19.jq b/src/test/resources/test_files/static-typing/comparison/comp19.jq new file mode 100644 index 0000000000..0c0798906a --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp19.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(1, 2.22) < (4, 4.3) \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp2.jq b/src/test/resources/test_files/static-typing/comparison/comp2.jq new file mode 100644 index 0000000000..426a565d4d --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp2.jq @@ -0,0 +1,9 @@ +(:JIQS: ShouldRun :) +declare $date := '2020-02-12' cast as date +declare $dt := "2015-05-03T13:20:00" cast as dateTime +declare $time := "13:20:00" cast as time +declare $dtdur := "P2DT3H" cast as dayTimeDuration +declare $ymdur := "P1Y2M" cast as yearMonthDuration +declare $hexb := "0cd7" cast as hexBinary +declare $base64b := "DNc=" cast as base64Binary +($date eq $date) is statically boolean, ($date lt $date) is statically boolean, ($dt eq $dt) is statically boolean, ($dt lt $dt) is statically boolean, ($time eq $time) is statically boolean, ($time gt $time) is statically boolean, ($ymdur eq $ymdur) is statically boolean, ($ymdur lt $ymdur) is statically boolean, ($dtdur eq $dtdur) is statically boolean, ($dtdur lt $dtdur) is statically boolean, ($ymdur eq $dtdur) is statically boolean, (($ymdur treat as duration) eq $dtdur) is statically boolean, ($hexb eq $hexb) is statically boolean, ($base64b eq $base64b) is statically boolean \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp20.jq b/src/test/resources/test_files/static-typing/comparison/comp20.jq new file mode 100644 index 0000000000..5e63473f3c --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp20.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +[1,2][] < [3,4][] \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp3.jq b/src/test/resources/test_files/static-typing/comparison/comp3.jq new file mode 100644 index 0000000000..f05c69edc6 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp3.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldRun :) +((1, 2, 3) = 2) is statically boolean, (() = 2) is statically boolean, ((1, 2, 3) <= (2, 33)) is statically boolean, ((1, 2.22) treat as decimal+ < (4, 8)) is statically boolean, ([1,2][] treat as integer+ < [3,4][] treat as integer+) is statically boolean \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp4.jq b/src/test/resources/test_files/static-typing/comparison/comp4.jq new file mode 100644 index 0000000000..442518cece --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp4.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +1 eq () \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp5.jq b/src/test/resources/test_files/static-typing/comparison/comp5.jq new file mode 100644 index 0000000000..b8761c8af7 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp5.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="JNTY0004" :) +[12] gt 3 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp6.jq b/src/test/resources/test_files/static-typing/comparison/comp6.jq new file mode 100644 index 0000000000..cc1e2a019d --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp6.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="JNTY0004" :) +{"a":23} gt 3 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp7.jq b/src/test/resources/test_files/static-typing/comparison/comp7.jq new file mode 100644 index 0000000000..6b50c1dc52 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp7.jq @@ -0,0 +1,2 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(12 treat as item) eq 22 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp8.jq b/src/test/resources/test_files/static-typing/comparison/comp8.jq new file mode 100644 index 0000000000..9c20b42ac3 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp8.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $date := '2020-02-12' cast as date +declare $dt := "2015-05-03T13:20:00" cast as dateTime +$date eq $dt \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp9.jq b/src/test/resources/test_files/static-typing/comparison/comp9.jq new file mode 100644 index 0000000000..3d9234db83 --- /dev/null +++ b/src/test/resources/test_files/static-typing/comparison/comp9.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $dt := "2015-05-03T13:20:00" cast as dateTime +declare $time := "13:20:00" cast as time +$dt eq $time \ No newline at end of file From 516addd163593e28f527909a31ee3417ff288e21 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 12 Nov 2020 10:17:28 +0100 Subject: [PATCH 051/206] added control static type tests --- src/test/resources/test_files/static-typing/control/if1.jq | 4 ++++ src/test/resources/test_files/static-typing/control/if2.jq | 4 ++++ src/test/resources/test_files/static-typing/control/if3.jq | 4 ++++ src/test/resources/test_files/static-typing/control/if4.jq | 4 ++++ src/test/resources/test_files/static-typing/control/if5.jq | 4 ++++ src/test/resources/test_files/static-typing/control/if6.jq | 4 ++++ src/test/resources/test_files/static-typing/control/if7.jq | 4 ++++ src/test/resources/test_files/static-typing/control/if8.jq | 4 ++++ src/test/resources/test_files/static-typing/control/if9.jq | 5 +++++ .../resources/test_files/static-typing/control/switch1.jq | 4 ++++ .../resources/test_files/static-typing/control/switch10.jq | 4 ++++ .../resources/test_files/static-typing/control/switch11.jq | 4 ++++ .../resources/test_files/static-typing/control/switch2.jq | 5 +++++ .../resources/test_files/static-typing/control/switch3.jq | 5 +++++ .../resources/test_files/static-typing/control/switch4.jq | 4 ++++ .../resources/test_files/static-typing/control/switch5.jq | 4 ++++ .../resources/test_files/static-typing/control/switch6.jq | 4 ++++ .../resources/test_files/static-typing/control/switch7.jq | 4 ++++ .../resources/test_files/static-typing/control/switch8.jq | 4 ++++ .../resources/test_files/static-typing/control/switch9.jq | 4 ++++ src/test/resources/test_files/static-typing/control/try1.jq | 3 +++ src/test/resources/test_files/static-typing/control/try2.jq | 3 +++ src/test/resources/test_files/static-typing/control/try3.jq | 3 +++ src/test/resources/test_files/static-typing/control/try4.jq | 3 +++ .../test_files/static-typing/control/typeswitch1.jq | 4 ++++ .../test_files/static-typing/control/typeswitch2.jq | 4 ++++ .../test_files/static-typing/control/typeswitch3.jq | 4 ++++ .../test_files/static-typing/control/typeswitch4.jq | 4 ++++ .../test_files/static-typing/control/typeswitch5.jq | 4 ++++ src/test/resources/test_files/static-typing/flwor/for1.jq | 0 src/test/resources/test_files/static-typing/flwor/for2.jq | 0 src/test/resources/test_files/static-typing/flwor/for3.jq | 0 src/test/resources/test_files/static-typing/flwor/for4.jq | 0 src/test/resources/test_files/static-typing/flwor/for5.jq | 0 src/test/resources/test_files/static-typing/flwor/for6.jq | 0 src/test/resources/test_files/static-typing/flwor/for7.jq | 0 src/test/resources/test_files/static-typing/flwor/for8.jq | 0 src/test/resources/test_files/static-typing/flwor/group1.jq | 0 src/test/resources/test_files/static-typing/flwor/group2.jq | 0 src/test/resources/test_files/static-typing/flwor/group3.jq | 0 src/test/resources/test_files/static-typing/flwor/let1.jq | 0 src/test/resources/test_files/static-typing/flwor/order1.jq | 0 src/test/resources/test_files/static-typing/flwor/order2.jq | 0 src/test/resources/test_files/static-typing/flwor/order3.jq | 0 src/test/resources/test_files/static-typing/flwor/order4.jq | 0 src/test/resources/test_files/static-typing/flwor/return1.jq | 0 src/test/resources/test_files/static-typing/flwor/where1.jq | 0 src/test/resources/test_files/static-typing/flwor/where2.jq | 0 src/test/resources/test_files/static-typing/flwor/where3.jq | 0 src/test/resources/test_files/static-typing/flwor/where4.jq | 0 50 files changed, 115 insertions(+) create mode 100644 src/test/resources/test_files/static-typing/control/if1.jq create mode 100644 src/test/resources/test_files/static-typing/control/if2.jq create mode 100644 src/test/resources/test_files/static-typing/control/if3.jq create mode 100644 src/test/resources/test_files/static-typing/control/if4.jq create mode 100644 src/test/resources/test_files/static-typing/control/if5.jq create mode 100644 src/test/resources/test_files/static-typing/control/if6.jq create mode 100644 src/test/resources/test_files/static-typing/control/if7.jq create mode 100644 src/test/resources/test_files/static-typing/control/if8.jq create mode 100644 src/test/resources/test_files/static-typing/control/if9.jq create mode 100644 src/test/resources/test_files/static-typing/control/switch1.jq create mode 100644 src/test/resources/test_files/static-typing/control/switch10.jq create mode 100644 src/test/resources/test_files/static-typing/control/switch11.jq create mode 100644 src/test/resources/test_files/static-typing/control/switch2.jq create mode 100644 src/test/resources/test_files/static-typing/control/switch3.jq create mode 100644 src/test/resources/test_files/static-typing/control/switch4.jq create mode 100644 src/test/resources/test_files/static-typing/control/switch5.jq create mode 100644 src/test/resources/test_files/static-typing/control/switch6.jq create mode 100644 src/test/resources/test_files/static-typing/control/switch7.jq create mode 100644 src/test/resources/test_files/static-typing/control/switch8.jq create mode 100644 src/test/resources/test_files/static-typing/control/switch9.jq create mode 100644 src/test/resources/test_files/static-typing/control/try1.jq create mode 100644 src/test/resources/test_files/static-typing/control/try2.jq create mode 100644 src/test/resources/test_files/static-typing/control/try3.jq create mode 100644 src/test/resources/test_files/static-typing/control/try4.jq create mode 100644 src/test/resources/test_files/static-typing/control/typeswitch1.jq create mode 100644 src/test/resources/test_files/static-typing/control/typeswitch2.jq create mode 100644 src/test/resources/test_files/static-typing/control/typeswitch3.jq create mode 100644 src/test/resources/test_files/static-typing/control/typeswitch4.jq create mode 100644 src/test/resources/test_files/static-typing/control/typeswitch5.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/for1.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/for2.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/for3.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/for4.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/for5.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/for6.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/for7.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/for8.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/group1.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/group2.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/group3.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/let1.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/order1.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/order2.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/order3.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/order4.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/return1.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/where1.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/where2.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/where3.jq create mode 100644 src/test/resources/test_files/static-typing/flwor/where4.jq diff --git a/src/test/resources/test_files/static-typing/control/if1.jq b/src/test/resources/test_files/static-typing/control/if1.jq new file mode 100644 index 0000000000..78e0d1fcb0 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/if1.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(if(true) +then 3 +else 4) is statically integer, \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/if2.jq b/src/test/resources/test_files/static-typing/control/if2.jq new file mode 100644 index 0000000000..73605d66e4 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/if2.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(if(true) +then 3 +else "str") is statically atomic \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/if3.jq b/src/test/resources/test_files/static-typing/control/if3.jq new file mode 100644 index 0000000000..4578edf471 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/if3.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(if(true) +then 3 +else (1,2,3)) is statically integer+ \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/if4.jq b/src/test/resources/test_files/static-typing/control/if4.jq new file mode 100644 index 0000000000..f5426887e9 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/if4.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(if(true) +then () +else (1,2,3)) is statically integer* \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/if5.jq b/src/test/resources/test_files/static-typing/control/if5.jq new file mode 100644 index 0000000000..1064ad1a39 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/if5.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(if(true) +then "qwr" +else (1,2,3)) is statically atomic+ \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/if6.jq b/src/test/resources/test_files/static-typing/control/if6.jq new file mode 100644 index 0000000000..426d503d9c --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/if6.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(if(true) +then [] +else (1,2,3)) is statically item+ \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/if7.jq b/src/test/resources/test_files/static-typing/control/if7.jq new file mode 100644 index 0000000000..37c2fe43b5 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/if7.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(if(()) +then "qwe" +else 1) is statically integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/if8.jq b/src/test/resources/test_files/static-typing/control/if8.jq new file mode 100644 index 0000000000..bbe216514c --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/if8.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(if(null) +then "qwe" +else 1) is statically integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/if9.jq b/src/test/resources/test_files/static-typing/control/if9.jq new file mode 100644 index 0000000000..7080606d5e --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/if9.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $dt := "2015-05-03T13:20:00" cast as dateTime +if($dt) +then 3 +else 4 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/switch1.jq b/src/test/resources/test_files/static-typing/control/switch1.jq new file mode 100644 index 0000000000..5aa7d8b72c --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/switch1.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(switch(3) +case "a" return "a" +default return "b") is statically string \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/switch10.jq b/src/test/resources/test_files/static-typing/control/switch10.jq new file mode 100644 index 0000000000..7e5bc47479 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/switch10.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="FOTY0015" :) +switch(3) +case concat#2 return "a" +default return "b" diff --git a/src/test/resources/test_files/static-typing/control/switch11.jq b/src/test/resources/test_files/static-typing/control/switch11.jq new file mode 100644 index 0000000000..5521fca0db --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/switch11.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="FOTY0015" :) +switch(concat#2) +case "a" return "a" +default return "b" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/switch2.jq b/src/test/resources/test_files/static-typing/control/switch2.jq new file mode 100644 index 0000000000..c650ffc645 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/switch2.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldRun :) +(switch(3) +case 12 return 12 +default return "not 12" +) is statically atomic \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/switch3.jq b/src/test/resources/test_files/static-typing/control/switch3.jq new file mode 100644 index 0000000000..907982821a --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/switch3.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldRun :) +(switch(3) +case "12" return 12 +default return "not 12" +) is statically string \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/switch4.jq b/src/test/resources/test_files/static-typing/control/switch4.jq new file mode 100644 index 0000000000..e24c91f72b --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/switch4.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +switch( (1, 2, 3) ) +case "a" return "a" +default return "b" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/switch5.jq b/src/test/resources/test_files/static-typing/control/switch5.jq new file mode 100644 index 0000000000..e632277b58 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/switch5.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +switch(3) +case (1,2,3) return "a" +default return "b" diff --git a/src/test/resources/test_files/static-typing/control/switch6.jq b/src/test/resources/test_files/static-typing/control/switch6.jq new file mode 100644 index 0000000000..3ae0840e1d --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/switch6.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="JNTY0004" :) +switch([]) +case "a" return "a" +default return "b" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/switch7.jq b/src/test/resources/test_files/static-typing/control/switch7.jq new file mode 100644 index 0000000000..af5f86aaca --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/switch7.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="JNTY0004" :) +switch(3) +case {} return "a" +default return "b" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/switch8.jq b/src/test/resources/test_files/static-typing/control/switch8.jq new file mode 100644 index 0000000000..6be21ed390 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/switch8.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +switch(3 treat as item) +case "a" return "a" +default return "b" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/switch9.jq b/src/test/resources/test_files/static-typing/control/switch9.jq new file mode 100644 index 0000000000..ba5d2e84e9 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/switch9.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +switch(3) +case ("a" treat as item) return "a" +default return "b" diff --git a/src/test/resources/test_files/static-typing/control/try1.jq b/src/test/resources/test_files/static-typing/control/try1.jq new file mode 100644 index 0000000000..3673290932 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/try1.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldRun :) +(try { 3 } +catch * { "str" }) is statically atomic \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/try2.jq b/src/test/resources/test_files/static-typing/control/try2.jq new file mode 100644 index 0000000000..b3d495baf5 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/try2.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldRun :) +(try { (1,2) } +catch * { "str" }) is statically atomic+ \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/try3.jq b/src/test/resources/test_files/static-typing/control/try3.jq new file mode 100644 index 0000000000..fd45268744 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/try3.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldRun :) +(try { "str1" } +catch * { "str" }) is statically string \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/try4.jq b/src/test/resources/test_files/static-typing/control/try4.jq new file mode 100644 index 0000000000..e99285bd84 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/try4.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldRun :) +(try { () } +catch * { "str" }) is statically string? \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/typeswitch1.jq b/src/test/resources/test_files/static-typing/control/typeswitch1.jq new file mode 100644 index 0000000000..8334cc03f1 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/typeswitch1.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(typeswitch(3) +case integer return 1 +default return 0) is statically integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/typeswitch2.jq b/src/test/resources/test_files/static-typing/control/typeswitch2.jq new file mode 100644 index 0000000000..2c4fc8ee43 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/typeswitch2.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(typeswitch(3) +case integer return 1 +default return "asd") is statically atomic \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/typeswitch3.jq b/src/test/resources/test_files/static-typing/control/typeswitch3.jq new file mode 100644 index 0000000000..b1f1985af8 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/typeswitch3.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(typeswitch(3) +case integer return 1 +default return ()) is statically integer? \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/typeswitch4.jq b/src/test/resources/test_files/static-typing/control/typeswitch4.jq new file mode 100644 index 0000000000..87187af512 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/typeswitch4.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(typeswitch((1,2,3)) +case integer* return 1 +default return 0) is statically integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/typeswitch5.jq b/src/test/resources/test_files/static-typing/control/typeswitch5.jq new file mode 100644 index 0000000000..6db3c31b7b --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/typeswitch5.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(typeswitch([]) +case array return 1 +default return 0) is statically integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/for1.jq b/src/test/resources/test_files/static-typing/flwor/for1.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/for2.jq b/src/test/resources/test_files/static-typing/flwor/for2.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/for3.jq b/src/test/resources/test_files/static-typing/flwor/for3.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/for4.jq b/src/test/resources/test_files/static-typing/flwor/for4.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/for5.jq b/src/test/resources/test_files/static-typing/flwor/for5.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/for6.jq b/src/test/resources/test_files/static-typing/flwor/for6.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/for7.jq b/src/test/resources/test_files/static-typing/flwor/for7.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/for8.jq b/src/test/resources/test_files/static-typing/flwor/for8.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/group1.jq b/src/test/resources/test_files/static-typing/flwor/group1.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/group2.jq b/src/test/resources/test_files/static-typing/flwor/group2.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/group3.jq b/src/test/resources/test_files/static-typing/flwor/group3.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/let1.jq b/src/test/resources/test_files/static-typing/flwor/let1.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/order1.jq b/src/test/resources/test_files/static-typing/flwor/order1.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/order2.jq b/src/test/resources/test_files/static-typing/flwor/order2.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/order3.jq b/src/test/resources/test_files/static-typing/flwor/order3.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/order4.jq b/src/test/resources/test_files/static-typing/flwor/order4.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/return1.jq b/src/test/resources/test_files/static-typing/flwor/return1.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/where1.jq b/src/test/resources/test_files/static-typing/flwor/where1.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/where2.jq b/src/test/resources/test_files/static-typing/flwor/where2.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/where3.jq b/src/test/resources/test_files/static-typing/flwor/where3.jq new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/resources/test_files/static-typing/flwor/where4.jq b/src/test/resources/test_files/static-typing/flwor/where4.jq new file mode 100644 index 0000000000..e69de29bb2 From 664af48a64f2a22a6108ba0877651b8d2add1f86 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 12 Nov 2020 10:17:50 +0100 Subject: [PATCH 052/206] added flwor static type tests --- src/test/resources/test_files/static-typing/flwor/for1.jq | 3 +++ src/test/resources/test_files/static-typing/flwor/for2.jq | 3 +++ src/test/resources/test_files/static-typing/flwor/for3.jq | 3 +++ src/test/resources/test_files/static-typing/flwor/for4.jq | 3 +++ src/test/resources/test_files/static-typing/flwor/for5.jq | 3 +++ src/test/resources/test_files/static-typing/flwor/for6.jq | 3 +++ src/test/resources/test_files/static-typing/flwor/for7.jq | 3 +++ src/test/resources/test_files/static-typing/flwor/for8.jq | 4 ++++ src/test/resources/test_files/static-typing/flwor/group1.jq | 4 ++++ src/test/resources/test_files/static-typing/flwor/group2.jq | 4 ++++ src/test/resources/test_files/static-typing/flwor/group3.jq | 4 ++++ src/test/resources/test_files/static-typing/flwor/let1.jq | 3 +++ src/test/resources/test_files/static-typing/flwor/order1.jq | 4 ++++ src/test/resources/test_files/static-typing/flwor/order2.jq | 5 +++++ src/test/resources/test_files/static-typing/flwor/order3.jq | 4 ++++ src/test/resources/test_files/static-typing/flwor/order4.jq | 4 ++++ src/test/resources/test_files/static-typing/flwor/return1.jq | 3 +++ src/test/resources/test_files/static-typing/flwor/where1.jq | 5 +++++ src/test/resources/test_files/static-typing/flwor/where2.jq | 4 ++++ src/test/resources/test_files/static-typing/flwor/where3.jq | 4 ++++ src/test/resources/test_files/static-typing/flwor/where4.jq | 4 ++++ 21 files changed, 77 insertions(+) diff --git a/src/test/resources/test_files/static-typing/flwor/for1.jq b/src/test/resources/test_files/static-typing/flwor/for1.jq index e69de29bb2..a47329b9f5 100644 --- a/src/test/resources/test_files/static-typing/flwor/for1.jq +++ b/src/test/resources/test_files/static-typing/flwor/for1.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldRun :) +(for $a in (1,2,3) +return $a) is statically integer+ \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/for2.jq b/src/test/resources/test_files/static-typing/flwor/for2.jq index e69de29bb2..37ae7438ac 100644 --- a/src/test/resources/test_files/static-typing/flwor/for2.jq +++ b/src/test/resources/test_files/static-typing/flwor/for2.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldRun :) +(for $a in (1,2,3) +return ($a treat as integer?)) is statically integer* \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/for3.jq b/src/test/resources/test_files/static-typing/flwor/for3.jq index e69de29bb2..a477a1f61f 100644 --- a/src/test/resources/test_files/static-typing/flwor/for3.jq +++ b/src/test/resources/test_files/static-typing/flwor/for3.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldRun :) +(for $a in ((1,2,3) treat as integer*) +return $a) is statically integer* \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/for4.jq b/src/test/resources/test_files/static-typing/flwor/for4.jq index e69de29bb2..e59857ce4d 100644 --- a/src/test/resources/test_files/static-typing/flwor/for4.jq +++ b/src/test/resources/test_files/static-typing/flwor/for4.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldRun :) +(for $a in (1,2,3) +return "aa") is statically string+ \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/for5.jq b/src/test/resources/test_files/static-typing/flwor/for5.jq index e69de29bb2..8efe78e0ad 100644 --- a/src/test/resources/test_files/static-typing/flwor/for5.jq +++ b/src/test/resources/test_files/static-typing/flwor/for5.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +for $a in () +return "aa" \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/for6.jq b/src/test/resources/test_files/static-typing/flwor/for6.jq index e69de29bb2..fc7f17662b 100644 --- a/src/test/resources/test_files/static-typing/flwor/for6.jq +++ b/src/test/resources/test_files/static-typing/flwor/for6.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldRun :) +(for $a allowing empty in () +return "aa") is statically string \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/for7.jq b/src/test/resources/test_files/static-typing/flwor/for7.jq index e69de29bb2..dfd55e63b9 100644 --- a/src/test/resources/test_files/static-typing/flwor/for7.jq +++ b/src/test/resources/test_files/static-typing/flwor/for7.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +for $a allowing empty in () +return $a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/for8.jq b/src/test/resources/test_files/static-typing/flwor/for8.jq index e69de29bb2..792567a71a 100644 --- a/src/test/resources/test_files/static-typing/flwor/for8.jq +++ b/src/test/resources/test_files/static-typing/flwor/for8.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(for $a in (1,2,3) +for $b in (1 treat as integer?) +return $a || $b) is statically string* \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/group1.jq b/src/test/resources/test_files/static-typing/flwor/group1.jq index e69de29bb2..9637c0e6f7 100644 --- a/src/test/resources/test_files/static-typing/flwor/group1.jq +++ b/src/test/resources/test_files/static-typing/flwor/group1.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(for $a in (1,2,3) +group by $b := $a mod 2 +return $b) is statically integer+ \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/group2.jq b/src/test/resources/test_files/static-typing/flwor/group2.jq index e69de29bb2..c2644166d8 100644 --- a/src/test/resources/test_files/static-typing/flwor/group2.jq +++ b/src/test/resources/test_files/static-typing/flwor/group2.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +for $a in ([],2,3) +group by $a +return $a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/group3.jq b/src/test/resources/test_files/static-typing/flwor/group3.jq index e69de29bb2..33508331ee 100644 --- a/src/test/resources/test_files/static-typing/flwor/group3.jq +++ b/src/test/resources/test_files/static-typing/flwor/group3.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="JNTY0004" :) +for $a in ([], {"a":2}) +group by $a +return $a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/let1.jq b/src/test/resources/test_files/static-typing/flwor/let1.jq index e69de29bb2..86a66edcc9 100644 --- a/src/test/resources/test_files/static-typing/flwor/let1.jq +++ b/src/test/resources/test_files/static-typing/flwor/let1.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +let $a as integer := "qwerty" +return $a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/order1.jq b/src/test/resources/test_files/static-typing/flwor/order1.jq index e69de29bb2..b99e32c243 100644 --- a/src/test/resources/test_files/static-typing/flwor/order1.jq +++ b/src/test/resources/test_files/static-typing/flwor/order1.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(for $a in (1,2,3) +order by $a +return $a) is statically integer+ \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/order2.jq b/src/test/resources/test_files/static-typing/flwor/order2.jq index e69de29bb2..20cd29a908 100644 --- a/src/test/resources/test_files/static-typing/flwor/order2.jq +++ b/src/test/resources/test_files/static-typing/flwor/order2.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $hexb := "0cd7" cast as hexBinary +for $a in ($hexb, $hexb) +order by $a +return $a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/order3.jq b/src/test/resources/test_files/static-typing/flwor/order3.jq index e69de29bb2..25e9ea4c0f 100644 --- a/src/test/resources/test_files/static-typing/flwor/order3.jq +++ b/src/test/resources/test_files/static-typing/flwor/order3.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="JNTY0004" :) +for $a in ([], {"a": 12}) +order by $a +return $a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/order4.jq b/src/test/resources/test_files/static-typing/flwor/order4.jq index e69de29bb2..fb6241c4ed 100644 --- a/src/test/resources/test_files/static-typing/flwor/order4.jq +++ b/src/test/resources/test_files/static-typing/flwor/order4.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +for $a in ((1,2,3) treat as item+) +order by $a +return $a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/return1.jq b/src/test/resources/test_files/static-typing/flwor/return1.jq index e69de29bb2..339f6f5077 100644 --- a/src/test/resources/test_files/static-typing/flwor/return1.jq +++ b/src/test/resources/test_files/static-typing/flwor/return1.jq @@ -0,0 +1,3 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +for $a in (1,2,3) +return () \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/where1.jq b/src/test/resources/test_files/static-typing/flwor/where1.jq index e69de29bb2..a49c0e740a 100644 --- a/src/test/resources/test_files/static-typing/flwor/where1.jq +++ b/src/test/resources/test_files/static-typing/flwor/where1.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +declare $ymdur := "P1Y2M" cast as yearMonthDuration +for $a in (1,2,3) +where $ymdur +return $a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/where2.jq b/src/test/resources/test_files/static-typing/flwor/where2.jq index e69de29bb2..c27d2ebf8b 100644 --- a/src/test/resources/test_files/static-typing/flwor/where2.jq +++ b/src/test/resources/test_files/static-typing/flwor/where2.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(for $a in (1,2,3) +where $a < -1 +return $a) is statically integer* \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/where3.jq b/src/test/resources/test_files/static-typing/flwor/where3.jq index e69de29bb2..e7a3e5dda4 100644 --- a/src/test/resources/test_files/static-typing/flwor/where3.jq +++ b/src/test/resources/test_files/static-typing/flwor/where3.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +for $a in (1,2,3) +where () +return $a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/where4.jq b/src/test/resources/test_files/static-typing/flwor/where4.jq index e69de29bb2..fa503a8dff 100644 --- a/src/test/resources/test_files/static-typing/flwor/where4.jq +++ b/src/test/resources/test_files/static-typing/flwor/where4.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPST0005" :) +for $a in (1,2,3) +where null +return $a \ No newline at end of file From a1809a7bf822e72103ffca5b9c5bab8d3bc644c7 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 16 Nov 2020 00:17:14 +0100 Subject: [PATCH 053/206] started basic native let clause --- .../org/rumbledb/runtime/RuntimeIterator.java | 9 +++++++ .../flwor/clauses/LetClauseSparkIterator.java | 25 +++++++++++++++++++ .../runtime/postfix/ObjectLookupIterator.java | 10 ++++++++ .../primary/VariableReferenceIterator.java | 5 ++++ .../runtime/typing/TreatIterator.java | 6 +++++ 5 files changed, 55 insertions(+) diff --git a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java index 75e845e8bc..4319f9f3d8 100644 --- a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java @@ -370,4 +370,13 @@ public RuntimeIterator deepCopy() { throw rumbleException; } } + + /** + * This function generate (if possible) a native spark-sql query that maps the inner working of the iterator + * + * @return a string representing the spark-sql native query to get an equivalent result of the iterator, or null if it is not possible + */ + public String generateNativeQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index 925de955d2..f462c34eb6 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -533,6 +533,28 @@ public static Dataset bindLetVariableInDataFrame( Collections.singletonList(newVariableName) ); + // if we can (depending on the expression) use let natively without UDF + + if(!hash){ + String nativeQuery = newVariableExpression.generateNativeQuery(); + System.out.println("native query returned " + nativeQuery); + if(nativeQuery != null){ + String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); + dataFrame.createOrReplaceTempView("input"); + return dataFrame.sparkSession() + .sql( + String.format( + "select %s (%s) as `%s` from input", + selectSQL, + nativeQuery, + newVariableName + ) + ); + } + } + + // was not possible, we use let udf + List UDFcolumns = FlworDataFrameUtils.getColumnNames( inputSchema, newVariableExpression.getVariableDependencies(), @@ -562,6 +584,9 @@ public static Dataset bindLetVariableInDataFrame( String UDFParameters = FlworDataFrameUtils.getUDFParameters(UDFcolumns); dataFrame.createOrReplaceTempView("input"); + + + if (!hash) { dataFrame = dataFrame.sparkSession() .sql( diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index ccd4e1d58f..be172eb1d6 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -216,6 +216,16 @@ public boolean implementsDataFrames() { return true; } + @Override + public String generateNativeQuery() { + String objectPart = this.iterator.generateNativeQuery(); + if(objectPart == null){ + return null; + } + initLookupKey(); + return objectPart + "." + this.lookupKey.getStringValue(); + } + public Dataset getDataFrame(DynamicContext context) { Dataset childDataFrame = this.children.get(0).getDataFrame(context); initLookupKey(); diff --git a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java index cd98dc50c0..9a89f055b3 100644 --- a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java @@ -77,6 +77,11 @@ protected boolean hasNextLocal() { return this.hasNext; } + @Override + public String generateNativeQuery() { + return this.variableName.toString(); + } + @Override public Item nextLocal() { if (!this.hasNext) { diff --git a/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java b/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java index fe7d18dc95..99de8316e5 100644 --- a/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java @@ -154,6 +154,12 @@ public JavaRDD getRDDAux(DynamicContext dynamicContext) { return childRDD.filter(transformation); } + @Override + public String generateNativeQuery() { + // TODO: do treat check how? + return this.iterator.generateNativeQuery(); + } + private void checkEmptySequence(int size) { if ( size == 0 From 3281ce7e6f7f2e57feda445c45a1ce5cf320e1bd Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 16 Nov 2020 00:17:35 +0100 Subject: [PATCH 054/206] added support for string concat --- .../runtime/operational/StringConcatIterator.java | 12 ++++++++++++ .../runtime/primary/StringRuntimeIterator.java | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java b/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java index c273a49a73..e723f17388 100644 --- a/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java @@ -88,4 +88,16 @@ public Item next() { throw new IteratorFlowException(RuntimeIterator.FLOW_EXCEPTION_MESSAGE, getMetadata()); } + + @Override + public String generateNativeQuery() { + // TODO: checks + String leftQuery = this.leftIterator.generateNativeQuery(); + String rightQuery = this.rightIterator.generateNativeQuery(); + if(leftQuery == null || rightQuery == null){ + return null; + } else { + return "concat( ("+leftQuery+"), ("+rightQuery+") )"; + } + } } diff --git a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java index 9b9490a96a..487c88dcc2 100644 --- a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java @@ -55,4 +55,9 @@ public Item next() { public Item materializeExactlyOneItem(DynamicContext context) throws NoItemException, MoreThanOneItemException { return this.item; } + + @Override + public String generateNativeQuery() { + return '"' + this.item.getStringValue() + '"'; + } } From b504e36d9aa11c2bef295da554bae6fcbaea66aa Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 19 Nov 2020 15:01:00 +0100 Subject: [PATCH 055/206] added struct info and context, and unboxing and array lookup expressions --- .../java/org/rumbledb/runtime/RuntimeIterator.java | 5 ++++- .../runtime/flwor/clauses/LetClauseSparkIterator.java | 2 +- .../runtime/operational/StringConcatIterator.java | 8 +++++--- .../rumbledb/runtime/postfix/ArrayLookupIterator.java | 10 ++++++++++ .../runtime/postfix/ArrayUnboxingIterator.java | 9 +++++++++ .../rumbledb/runtime/postfix/ObjectLookupIterator.java | 4 ++-- .../runtime/primary/StringRuntimeIterator.java | 3 ++- .../runtime/primary/VariableReferenceIterator.java | 3 ++- .../org/rumbledb/runtime/typing/TreatIterator.java | 5 +++-- 9 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java index 4319f9f3d8..abe8ab839a 100644 --- a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java @@ -27,6 +27,7 @@ import org.apache.spark.api.java.JavaRDD; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; +import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; import org.rumbledb.context.Name; @@ -375,8 +376,10 @@ public RuntimeIterator deepCopy() { * This function generate (if possible) a native spark-sql query that maps the inner working of the iterator * * @return a string representing the spark-sql native query to get an equivalent result of the iterator, or null if it is not possible + * @param inputSchema schema of the dataframe + * @param context context */ - public String generateNativeQuery() { + public String generateNativeQuery(StructType inputSchema, DynamicContext context) { return null; } } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index f462c34eb6..9df1bf023d 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -536,7 +536,7 @@ public static Dataset bindLetVariableInDataFrame( // if we can (depending on the expression) use let natively without UDF if(!hash){ - String nativeQuery = newVariableExpression.generateNativeQuery(); + String nativeQuery = newVariableExpression.generateNativeQuery(inputSchema, context); System.out.println("native query returned " + nativeQuery); if(nativeQuery != null){ String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); diff --git a/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java b/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java index e723f17388..4e57267811 100644 --- a/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java @@ -22,7 +22,9 @@ import java.util.Arrays; +import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; +import org.rumbledb.context.DynamicContext; import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; @@ -90,10 +92,10 @@ public Item next() { } @Override - public String generateNativeQuery() { + public String generateNativeQuery(StructType inputSchema, DynamicContext context) { // TODO: checks - String leftQuery = this.leftIterator.generateNativeQuery(); - String rightQuery = this.rightIterator.generateNativeQuery(); + String leftQuery = this.leftIterator.generateNativeQuery(inputSchema, context); + String rightQuery = this.rightIterator.generateNativeQuery(inputSchema, context); if(leftQuery == null || rightQuery == null){ return null; } else { diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java index 5be5e0ae80..266e258437 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java @@ -164,6 +164,16 @@ public boolean implementsDataFrames() { return true; } + @Override + public String generateNativeQuery(StructType inputSchema, DynamicContext context) { + String objectPart = this.iterator.generateNativeQuery(inputSchema, context); + if(objectPart == null){ + return null; + } + initLookupPosition(); + return objectPart + "[" + (this.lookup - 1) + "]"; + } + public Dataset getDataFrame(DynamicContext context) { Dataset childDataFrame = this.children.get(0).getDataFrame(context); initLookupPosition(); diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java index 94c6a7e7b2..d4b6a20a4e 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java @@ -128,6 +128,15 @@ public boolean implementsDataFrames() { return true; } + @Override + public String generateNativeQuery(StructType inputSchema, DynamicContext context) { + String objectPart = this.iterator.generateNativeQuery(inputSchema, context); + if(objectPart == null){ + return null; + } + return "explode( " + objectPart + " )"; + } + public Dataset getDataFrame(DynamicContext context) { Dataset childDataFrame = this.children.get(0).getDataFrame(context); childDataFrame.createOrReplaceTempView("array"); diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index be172eb1d6..72f76a08cb 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -217,8 +217,8 @@ public boolean implementsDataFrames() { } @Override - public String generateNativeQuery() { - String objectPart = this.iterator.generateNativeQuery(); + public String generateNativeQuery(StructType inputSchema, DynamicContext context) { + String objectPart = this.iterator.generateNativeQuery(inputSchema, context); if(objectPart == null){ return null; } diff --git a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java index 487c88dcc2..e413e571b1 100644 --- a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java @@ -21,6 +21,7 @@ package org.rumbledb.runtime.primary; import org.apache.commons.text.StringEscapeUtils; +import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; import org.rumbledb.exceptions.ExceptionMetadata; @@ -57,7 +58,7 @@ public Item materializeExactlyOneItem(DynamicContext context) throws NoItemExcep } @Override - public String generateNativeQuery() { + public String generateNativeQuery(StructType inputSchema, DynamicContext context) { return '"' + this.item.getStringValue() + '"'; } } diff --git a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java index 9a89f055b3..dcfbff6f35 100644 --- a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java @@ -23,6 +23,7 @@ import org.apache.spark.api.java.JavaRDD; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; +import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; import org.rumbledb.context.Name; @@ -78,7 +79,7 @@ protected boolean hasNextLocal() { } @Override - public String generateNativeQuery() { + public String generateNativeQuery(StructType inputSchema, DynamicContext context) { return this.variableName.toString(); } diff --git a/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java b/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java index 99de8316e5..9db1c9bce5 100644 --- a/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java @@ -2,6 +2,7 @@ import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.function.Function; +import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; import org.rumbledb.errorcodes.ErrorCode; @@ -155,9 +156,9 @@ public JavaRDD getRDDAux(DynamicContext dynamicContext) { } @Override - public String generateNativeQuery() { + public String generateNativeQuery(StructType inputSchema, DynamicContext context) { // TODO: do treat check how? - return this.iterator.generateNativeQuery(); + return this.iterator.generateNativeQuery(inputSchema, context); } private void checkEmptySequence(int size) { From 41c519015d5cd203ae410d2eeae2d2a2ed3bb730 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 19 Nov 2020 16:01:11 +0100 Subject: [PATCH 056/206] small test fixes --- .../resources/test_files/static-typing/comparison/comp19.jq | 4 ++-- .../resources/test_files/static-typing/postfix/filter1.jq | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/resources/test_files/static-typing/comparison/comp19.jq b/src/test/resources/test_files/static-typing/comparison/comp19.jq index 0c0798906a..593e1eb962 100644 --- a/src/test/resources/test_files/static-typing/comparison/comp19.jq +++ b/src/test/resources/test_files/static-typing/comparison/comp19.jq @@ -1,2 +1,2 @@ -(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -(1, 2.22) < (4, 4.3) \ No newline at end of file +(:JIQS: ShouldRun :) +(1, 2.22) < (4, 4.3) is statically boolean \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/filter1.jq b/src/test/resources/test_files/static-typing/postfix/filter1.jq index 46646bc603..8c3e8df4c7 100644 --- a/src/test/resources/test_files/static-typing/postfix/filter1.jq +++ b/src/test/resources/test_files/static-typing/postfix/filter1.jq @@ -1,2 +1,2 @@ (:JIQS: ShouldRun :) -((1,2,3)[$$]) is statically item*, ((1)[$$ gt 12]) is statically item? \ No newline at end of file +((1,2,3)[$$]) is statically integer*, ((1)[$$ gt 12]) is statically integer? \ No newline at end of file From 1f44df0254eaccce94822c4a2218bb0514e1889f Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 22 Nov 2020 11:19:46 +0100 Subject: [PATCH 057/206] new exception thrown in generate native query if it is not possible for the given expression, removed string concat, refactored try generate native query in function --- .../exceptions/NoNativeQueryException.java | 7 +++ .../org/rumbledb/runtime/RuntimeIterator.java | 10 +--- .../flwor/clauses/LetClauseSparkIterator.java | 56 ++++++++++++++----- .../operational/StringConcatIterator.java | 12 ---- .../runtime/postfix/ArrayLookupIterator.java | 3 - .../postfix/ArrayUnboxingIterator.java | 3 - .../runtime/postfix/ObjectLookupIterator.java | 3 - 7 files changed, 51 insertions(+), 43 deletions(-) create mode 100644 src/main/java/org/rumbledb/exceptions/NoNativeQueryException.java diff --git a/src/main/java/org/rumbledb/exceptions/NoNativeQueryException.java b/src/main/java/org/rumbledb/exceptions/NoNativeQueryException.java new file mode 100644 index 0000000000..988caf0408 --- /dev/null +++ b/src/main/java/org/rumbledb/exceptions/NoNativeQueryException.java @@ -0,0 +1,7 @@ +package org.rumbledb.exceptions; + +public class NoNativeQueryException extends RuntimeException { + public NoNativeQueryException(){ + super("It was not possible to generate a native sparkSQL query for this expression"); + } +} diff --git a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java index abe8ab839a..5fd093ebf7 100644 --- a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java @@ -32,13 +32,7 @@ import org.rumbledb.context.DynamicContext; import org.rumbledb.context.Name; import org.rumbledb.context.StaticContext; -import org.rumbledb.exceptions.ExceptionMetadata; -import org.rumbledb.exceptions.InvalidArgumentTypeException; -import org.rumbledb.exceptions.IteratorFlowException; -import org.rumbledb.exceptions.MoreThanOneItemException; -import org.rumbledb.exceptions.NoItemException; -import org.rumbledb.exceptions.OurBadException; -import org.rumbledb.exceptions.RumbleException; +import org.rumbledb.exceptions.*; import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.types.ItemType; @@ -380,6 +374,6 @@ public RuntimeIterator deepCopy() { * @param context context */ public String generateNativeQuery(StructType inputSchema, DynamicContext context) { - return null; + throw new NoNativeQueryException(); } } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index 9df1bf023d..7cdf3db441 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -536,20 +536,16 @@ public static Dataset bindLetVariableInDataFrame( // if we can (depending on the expression) use let natively without UDF if(!hash){ - String nativeQuery = newVariableExpression.generateNativeQuery(inputSchema, context); - System.out.println("native query returned " + nativeQuery); - if(nativeQuery != null){ - String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); - dataFrame.createOrReplaceTempView("input"); - return dataFrame.sparkSession() - .sql( - String.format( - "select %s (%s) as `%s` from input", - selectSQL, - nativeQuery, - newVariableName - ) - ); + Dataset nativeQueryResult = tryNativeQuery( + dataFrame, + newVariableName, + newVariableExpression, + allColumns, + inputSchema, + context + ); + if(nativeQueryResult != null){ + return nativeQueryResult; } } @@ -610,4 +606,36 @@ public static Dataset bindLetVariableInDataFrame( } return dataFrame; } + + /** + * Try to generate the native query for the let clause and run it, if successful return the resulting dataframe, otherwise it returns null + * + * @param dataFrame input dataframe for the query + * @param newVariableName name of the new bound variable + * @param iterator let variable assignment expression iterator + * @param allColumns other columns required in following clauses + * @param inputSchema input schema of the dataframe + * @param context current dynamic context of the dataframe + * @return resulting dataframe of the let clause if successful, null otherwise + */ + public static Dataset tryNativeQuery(Dataset dataFrame, + Name newVariableName, RuntimeIterator iterator, List allColumns, StructType inputSchema, DynamicContext context){ + try{ + String nativeQuery = iterator.generateNativeQuery(inputSchema, context); + System.out.println("native query returned " + nativeQuery); + String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); + dataFrame.createOrReplaceTempView("input"); + return dataFrame.sparkSession() + .sql( + String.format( + "select %s (%s) as `%s` from input", + selectSQL, + nativeQuery, + newVariableName + ) + ); + } catch (Exception e){ + return null; + } + } } diff --git a/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java b/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java index 4e57267811..30b102be6e 100644 --- a/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java @@ -90,16 +90,4 @@ public Item next() { throw new IteratorFlowException(RuntimeIterator.FLOW_EXCEPTION_MESSAGE, getMetadata()); } - - @Override - public String generateNativeQuery(StructType inputSchema, DynamicContext context) { - // TODO: checks - String leftQuery = this.leftIterator.generateNativeQuery(inputSchema, context); - String rightQuery = this.rightIterator.generateNativeQuery(inputSchema, context); - if(leftQuery == null || rightQuery == null){ - return null; - } else { - return "concat( ("+leftQuery+"), ("+rightQuery+") )"; - } - } } diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java index 266e258437..b0fe6fc4cb 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java @@ -167,9 +167,6 @@ public boolean implementsDataFrames() { @Override public String generateNativeQuery(StructType inputSchema, DynamicContext context) { String objectPart = this.iterator.generateNativeQuery(inputSchema, context); - if(objectPart == null){ - return null; - } initLookupPosition(); return objectPart + "[" + (this.lookup - 1) + "]"; } diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java index d4b6a20a4e..4400ff2cea 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java @@ -131,9 +131,6 @@ public boolean implementsDataFrames() { @Override public String generateNativeQuery(StructType inputSchema, DynamicContext context) { String objectPart = this.iterator.generateNativeQuery(inputSchema, context); - if(objectPart == null){ - return null; - } return "explode( " + objectPart + " )"; } diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index 72f76a08cb..3f20c0c7f7 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -219,9 +219,6 @@ public boolean implementsDataFrames() { @Override public String generateNativeQuery(StructType inputSchema, DynamicContext context) { String objectPart = this.iterator.generateNativeQuery(inputSchema, context); - if(objectPart == null){ - return null; - } initLookupKey(); return objectPart + "." + this.lookupKey.getStringValue(); } From 45ece3205709f8c7e3620f7476371d351c8abfe0 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 22 Nov 2020 11:20:25 +0100 Subject: [PATCH 058/206] spotless --- .../exceptions/NoNativeQueryException.java | 2 +- .../org/rumbledb/runtime/RuntimeIterator.java | 3 +- .../flwor/clauses/LetClauseSparkIterator.java | 53 +++++++++++-------- .../operational/StringConcatIterator.java | 2 - 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/rumbledb/exceptions/NoNativeQueryException.java b/src/main/java/org/rumbledb/exceptions/NoNativeQueryException.java index 988caf0408..954433acf4 100644 --- a/src/main/java/org/rumbledb/exceptions/NoNativeQueryException.java +++ b/src/main/java/org/rumbledb/exceptions/NoNativeQueryException.java @@ -1,7 +1,7 @@ package org.rumbledb.exceptions; public class NoNativeQueryException extends RuntimeException { - public NoNativeQueryException(){ + public NoNativeQueryException() { super("It was not possible to generate a native sparkSQL query for this expression"); } } diff --git a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java index 5fd093ebf7..c5a6a73b30 100644 --- a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java @@ -369,7 +369,8 @@ public RuntimeIterator deepCopy() { /** * This function generate (if possible) a native spark-sql query that maps the inner working of the iterator * - * @return a string representing the spark-sql native query to get an equivalent result of the iterator, or null if it is not possible + * @return a string representing the spark-sql native query to get an equivalent result of the iterator, or null if + * it is not possible * @param inputSchema schema of the dataframe * @param context context */ diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index 7cdf3db441..08579d7b8b 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -535,16 +535,16 @@ public static Dataset bindLetVariableInDataFrame( // if we can (depending on the expression) use let natively without UDF - if(!hash){ + if (!hash) { Dataset nativeQueryResult = tryNativeQuery( - dataFrame, - newVariableName, - newVariableExpression, - allColumns, - inputSchema, - context + dataFrame, + newVariableName, + newVariableExpression, + allColumns, + inputSchema, + context ); - if(nativeQueryResult != null){ + if (nativeQueryResult != null) { return nativeQueryResult; } } @@ -608,7 +608,8 @@ public static Dataset bindLetVariableInDataFrame( } /** - * Try to generate the native query for the let clause and run it, if successful return the resulting dataframe, otherwise it returns null + * Try to generate the native query for the let clause and run it, if successful return the resulting dataframe, + * otherwise it returns null * * @param dataFrame input dataframe for the query * @param newVariableName name of the new bound variable @@ -618,23 +619,29 @@ public static Dataset bindLetVariableInDataFrame( * @param context current dynamic context of the dataframe * @return resulting dataframe of the let clause if successful, null otherwise */ - public static Dataset tryNativeQuery(Dataset dataFrame, - Name newVariableName, RuntimeIterator iterator, List allColumns, StructType inputSchema, DynamicContext context){ - try{ + public static Dataset tryNativeQuery( + Dataset dataFrame, + Name newVariableName, + RuntimeIterator iterator, + List allColumns, + StructType inputSchema, + DynamicContext context + ) { + try { String nativeQuery = iterator.generateNativeQuery(inputSchema, context); System.out.println("native query returned " + nativeQuery); String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); - dataFrame.createOrReplaceTempView("input"); - return dataFrame.sparkSession() - .sql( - String.format( - "select %s (%s) as `%s` from input", - selectSQL, - nativeQuery, - newVariableName - ) - ); - } catch (Exception e){ + dataFrame.createOrReplaceTempView("input"); + return dataFrame.sparkSession() + .sql( + String.format( + "select %s (%s) as `%s` from input", + selectSQL, + nativeQuery, + newVariableName + ) + ); + } catch (Exception e) { return null; } } diff --git a/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java b/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java index 30b102be6e..c273a49a73 100644 --- a/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/StringConcatIterator.java @@ -22,9 +22,7 @@ import java.util.Arrays; -import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; -import org.rumbledb.context.DynamicContext; import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; From 225dba003b16a45c4617f25a27bd699ab52ea98f Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 22 Nov 2020 12:04:20 +0100 Subject: [PATCH 059/206] remove treat expression, don't go into that can of worms --- .gitlab-ci.yml | 0 .../java/org/rumbledb/runtime/typing/TreatIterator.java | 7 ------- 2 files changed, 7 deletions(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java b/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java index 9db1c9bce5..fe7d18dc95 100644 --- a/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java @@ -2,7 +2,6 @@ import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.function.Function; -import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; import org.rumbledb.errorcodes.ErrorCode; @@ -155,12 +154,6 @@ public JavaRDD getRDDAux(DynamicContext dynamicContext) { return childRDD.filter(transformation); } - @Override - public String generateNativeQuery(StructType inputSchema, DynamicContext context) { - // TODO: do treat check how? - return this.iterator.generateNativeQuery(inputSchema, context); - } - private void checkEmptySequence(int size) { if ( size == 0 From f62926e6bf857e313d6df8580d4c858f12df9dac Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 22 Nov 2020 12:04:49 +0100 Subject: [PATCH 060/206] started testing gitlab CI --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e69de29bb2..cdf8ed17ba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -0,0 +1,5 @@ +tests: + stage: build + image: bitnami/spark:2.4.5 + script: + - echo "hello" \ No newline at end of file From 1167e4af79937f6c82d7b24587624829c6ba77e0 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 22 Nov 2020 12:15:28 +0100 Subject: [PATCH 061/206] testing maven installation --- .gitlab-ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cdf8ed17ba..70c2f335ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,4 +2,10 @@ tests: stage: build image: bitnami/spark:2.4.5 script: - - echo "hello" \ No newline at end of file + - echo "hello" + - wget -P ~/ https://apache.mirror.digionline.de/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz + - tar xzvf apache-maven-3.6.3-bin.tar.gz + - echo "export MAVEN_HOME=~/apache-maven-3.6.3-bin" >> ~/.bashrc + - echo "export PATH=$PATH:$MAVEN_HOME/bin" >> ~/.bashrc + - source ~/.bashrc + - mvn --version \ No newline at end of file From ab8fd9037760495069f9e3ca8bef2a76407408a6 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 22 Nov 2020 12:31:32 +0100 Subject: [PATCH 062/206] added step to install wget --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 70c2f335ef..be9d2e87a5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,7 @@ tests: image: bitnami/spark:2.4.5 script: - echo "hello" + - apt-get --yes --force-yes install wget - wget -P ~/ https://apache.mirror.digionline.de/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz - tar xzvf apache-maven-3.6.3-bin.tar.gz - echo "export MAVEN_HOME=~/apache-maven-3.6.3-bin" >> ~/.bashrc From b0b0653f3a2457b77d9a01c6033642be0c12af97 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 22 Nov 2020 12:38:29 +0100 Subject: [PATCH 063/206] test fix --- .gitlab-ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index be9d2e87a5..f92155d10a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,12 @@ +image: bitnami/spark:2.4.5 + +pre-script: + - apt-get --yes --force-yes install wget + tests: stage: build - image: bitnami/spark:2.4.5 script: - echo "hello" - - apt-get --yes --force-yes install wget - wget -P ~/ https://apache.mirror.digionline.de/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz - tar xzvf apache-maven-3.6.3-bin.tar.gz - echo "export MAVEN_HOME=~/apache-maven-3.6.3-bin" >> ~/.bashrc From 81fc3b148feebfd6095a157bfa7d3ab20c777be3 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 22 Nov 2020 12:43:05 +0100 Subject: [PATCH 064/206] gitlab ci fix --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f92155d10a..cdc717842a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ image: bitnami/spark:2.4.5 -pre-script: +before-script: - apt-get --yes --force-yes install wget tests: From 1aa154054e003cf9965794e24f959690b2bf79a7 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 22 Nov 2020 12:47:49 +0100 Subject: [PATCH 065/206] gitlab ci fix --- .gitlab-ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cdc717842a..462db3eaa9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,9 @@ -image: bitnami/spark:2.4.5 - -before-script: - - apt-get --yes --force-yes install wget - tests: stage: build + image: bitnami/spark:2.4.5 script: - echo "hello" + - sudo apt-get --yes install wget - wget -P ~/ https://apache.mirror.digionline.de/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz - tar xzvf apache-maven-3.6.3-bin.tar.gz - echo "export MAVEN_HOME=~/apache-maven-3.6.3-bin" >> ~/.bashrc From 02bf3d8678f2b034cd45c4c5f82e3fb42e7fca13 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 23 Nov 2020 12:52:27 +0100 Subject: [PATCH 066/206] gitlab ci use new docker image --- .gitlab-ci.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 462db3eaa9..840d5ec9ce 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,8 @@ tests: stage: build - image: bitnami/spark:2.4.5 + image: marioarduini/rumble-source script: - - echo "hello" - - sudo apt-get --yes install wget - - wget -P ~/ https://apache.mirror.digionline.de/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz - - tar xzvf apache-maven-3.6.3-bin.tar.gz - - echo "export MAVEN_HOME=~/apache-maven-3.6.3-bin" >> ~/.bashrc - - echo "export PATH=$PATH:$MAVEN_HOME/bin" >> ~/.bashrc - - source ~/.bashrc - - mvn --version \ No newline at end of file + - mvn --version + - ant -version + - spark-submit --version + - ls From f171f6ec855e4f06844e35911f847e35f2903fd9 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 23 Nov 2020 12:57:01 +0100 Subject: [PATCH 067/206] gitlab ci try to assemble and test --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 840d5ec9ce..18d8116f9b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ tests: stage: build image: marioarduini/rumble-source script: - - mvn --version - - ant -version - - spark-submit --version - - ls + - ant -buildfile build_antlr_parser.xml generate-parser -Dantlr.jar=lib/antlr-4.7-complete.jar + - mvn clean compile assembly:single + - mvn -Dtest=FrontendTests test + From a60f291ecf429ee6705be4f1a725794b3f5a4e2c Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 23 Nov 2020 13:03:44 +0100 Subject: [PATCH 068/206] added all tests to gitlab ci --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 18d8116f9b..993478aedf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,4 +5,8 @@ tests: - ant -buildfile build_antlr_parser.xml generate-parser -Dantlr.jar=lib/antlr-4.7-complete.jar - mvn clean compile assembly:single - mvn -Dtest=FrontendTests test + - mvn -Dtest=RuntimeTests test + - mvn -Dtest=SparkRuntimeTests test + - mvn -Dtest=JavaAPITest test + - mvn spotless:check From 1564a9a27219602054dfcfead3078a315c51aa1e Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 23 Nov 2020 13:57:04 +0100 Subject: [PATCH 069/206] testing split in mutliple jobs --- .gitlab-ci.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 993478aedf..68617f6d7c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,14 @@ -tests: +build-rumble: stage: build image: marioarduini/rumble-source script: - ant -buildfile build_antlr_parser.xml generate-parser -Dantlr.jar=lib/antlr-4.7-complete.jar - mvn clean compile assembly:single + +frontend-test: + stage: test + image: marioarduini/rumble-source + script: - mvn -Dtest=FrontendTests test - - mvn -Dtest=RuntimeTests test - - mvn -Dtest=SparkRuntimeTests test - - mvn -Dtest=JavaAPITest test - - mvn spotless:check + From 50faf51ed5c8e14054fd4e14e28ef135c55c26aa Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 23 Nov 2020 14:05:32 +0100 Subject: [PATCH 070/206] added all parallel tests and change to tagged docker image --- .gitlab-ci.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 68617f6d7c..189b9e63cf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,14 +1,33 @@ +image: marioarduini/rumble-source:2020-11-13 + build-rumble: stage: build - image: marioarduini/rumble-source script: - ant -buildfile build_antlr_parser.xml generate-parser -Dantlr.jar=lib/antlr-4.7-complete.jar - mvn clean compile assembly:single frontend-test: stage: test - image: marioarduini/rumble-source script: - mvn -Dtest=FrontendTests test +runtime-test: + stage: test + script: + - mvn -Dtest=RuntimeTests test + +sparkruntime-test: + stage: test + script: + - mvn -Dtest=SparkRuntimeTests test + +javaapi-test: + stage: test + script: + - mvn -Dtest=JavaAPITest test + +spotless-test: + stage: test + script: + - mvn spotless:check From accde7bcd4795ed932cecf4d65d96759b0eecc96 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 23 Nov 2020 14:11:42 +0100 Subject: [PATCH 071/206] switched to untagged image --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 189b9e63cf..2a54362def 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: marioarduini/rumble-source:2020-11-13 +image: marioarduini/rumble-source build-rumble: stage: build From 4ee95a0461d97b4f0e01dd347ff4b285519f7ef9 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 23 Nov 2020 14:32:19 +0100 Subject: [PATCH 072/206] fixed tag --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2a54362def..93cef44574 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: marioarduini/rumble-source +image: marioarduini/rumble-source:2020-11-23 build-rumble: stage: build From fdf0fad3099c22b13d6ccfd2d316bb0ca2ee0f0f Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 09:36:04 +0100 Subject: [PATCH 073/206] fixed variable declaration in static tests --- .../test_files/static-typing/arithmetic/add2.jq | 10 +++++----- .../test_files/static-typing/arithmetic/add6.jq | 4 ++-- .../test_files/static-typing/arithmetic/add7.jq | 4 ++-- .../test_files/static-typing/arithmetic/add8.jq | 2 +- .../test_files/static-typing/arithmetic/add9.jq | 4 ++-- .../test_files/static-typing/arithmetic/mul2.jq | 4 ++-- .../test_files/static-typing/arithmetic/mul3.jq | 2 +- .../test_files/static-typing/arithmetic/mul4.jq | 2 +- .../test_files/static-typing/arithmetic/mul5.jq | 4 ++-- .../test_files/static-typing/arithmetic/mul6.jq | 2 +- .../test_files/static-typing/comparison/comp10.jq | 4 ++-- .../test_files/static-typing/comparison/comp11.jq | 2 +- .../test_files/static-typing/comparison/comp12.jq | 2 +- .../test_files/static-typing/comparison/comp13.jq | 4 ++-- .../test_files/static-typing/comparison/comp2.jq | 14 +++++++------- .../test_files/static-typing/comparison/comp8.jq | 4 ++-- .../test_files/static-typing/comparison/comp9.jq | 4 ++-- .../test_files/static-typing/control/if9.jq | 2 +- .../test_files/static-typing/flwor/order2.jq | 2 +- .../test_files/static-typing/flwor/where1.jq | 2 +- .../resources/test_files/static-typing/logic2.jq | 10 +++++----- .../test_files/static-typing/quantified2.jq | 2 +- .../test_files/static-typing/typing/cast2.jq | 8 ++++---- 23 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/test/resources/test_files/static-typing/arithmetic/add2.jq b/src/test/resources/test_files/static-typing/arithmetic/add2.jq index 795dc19d1c..d643fb5c04 100644 --- a/src/test/resources/test_files/static-typing/arithmetic/add2.jq +++ b/src/test/resources/test_files/static-typing/arithmetic/add2.jq @@ -1,7 +1,7 @@ (:JIQS: ShouldRun :) -declare $date := '2020-02-12' cast as date -declare $dt := "2015-05-03T13:20:00" cast as dateTime -declare $time := "13:20:00" cast as time -declare $dtdur := "P2DT3H" cast as dayTimeDuration -declare $ymdur := "P1Y2M" cast as yearMonthDuration +declare variable $date := "2020-02-12" cast as date; +declare variable $dt := "2015-05-03T13:20:00" cast as dateTime; +declare variable $time := "13:20:00" cast as time; +declare variable $dtdur := "P2DT3H" cast as dayTimeDuration; +declare variable $ymdur := "P1Y2M" cast as yearMonthDuration; ($dt + $dtdur) is statically dateTime, ($dt + $ymdur) is statically dateTime, ($date + $dtdur) is statically date, ($date + $ymdur) is statically date, ($time + $dtdur) is statically time, ($dtdur + $dtdur) is statically dayTimeDuration, ($ymdur + $ymdur) is statically yearMonthDuration, ($dt - $dt) is statically dayTimeDuration, ($date - $date) is statically dayTimeDuration, ($time - $time) is statically dayTimeDuration \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add6.jq b/src/test/resources/test_files/static-typing/arithmetic/add6.jq index 2af06cb83b..15cc4e269f 100644 --- a/src/test/resources/test_files/static-typing/arithmetic/add6.jq +++ b/src/test/resources/test_files/static-typing/arithmetic/add6.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $time := "13:20:00" cast as time -declare $ymdur := "P1Y2M" cast as yearMonthDuration +declare variable $time := "13:20:00" cast as time; +declare variable $ymdur := "P1Y2M" cast as yearMonthDuration; $time + $ymdur \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add7.jq b/src/test/resources/test_files/static-typing/arithmetic/add7.jq index 4a5be4628f..5eb47e3df2 100644 --- a/src/test/resources/test_files/static-typing/arithmetic/add7.jq +++ b/src/test/resources/test_files/static-typing/arithmetic/add7.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $dtdur := "P2DT3H" cast as dayTimeDuration -declare $ymdur := "P1Y2M" cast as yearMonthDuration +declare variable $dtdur := "P2DT3H" cast as dayTimeDuration; +declare variable $ymdur := "P1Y2M" cast as yearMonthDuration; $dtdur + $ymdur \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add8.jq b/src/test/resources/test_files/static-typing/arithmetic/add8.jq index 90b956f2a0..8f00df1307 100644 --- a/src/test/resources/test_files/static-typing/arithmetic/add8.jq +++ b/src/test/resources/test_files/static-typing/arithmetic/add8.jq @@ -1,3 +1,3 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $dt := "2015-05-03T13:20:00" cast as dateTime +declare variable $dt := "2015-05-03T13:20:00" cast as dateTime; $dt + 3 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/add9.jq b/src/test/resources/test_files/static-typing/arithmetic/add9.jq index 842a6bdfdc..bf3cbae782 100644 --- a/src/test/resources/test_files/static-typing/arithmetic/add9.jq +++ b/src/test/resources/test_files/static-typing/arithmetic/add9.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $date := '2020-02-12' cast as date -declare $dt := "2015-05-03T13:20:00" cast as dateTime +declare variable $date := "2020-02-12" cast as date; +declare variable $dt := "2015-05-03T13:20:00" cast as dateTime; $dt - $date \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul2.jq b/src/test/resources/test_files/static-typing/arithmetic/mul2.jq index 5666a9d14d..6020890e95 100644 --- a/src/test/resources/test_files/static-typing/arithmetic/mul2.jq +++ b/src/test/resources/test_files/static-typing/arithmetic/mul2.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldRun :) -declare $dtdur := "P2DT3H" cast as dayTimeDuration -declare $ymdur := "P1Y2M" cast as yearMonthDuration +declare variable $dtdur := "P2DT3H" cast as dayTimeDuration; +declare variable $ymdur := "P1Y2M" cast as yearMonthDuration; (3 * $ymdur) is statically yearMonthDuration, (3e4 * $ymdur) is statically yearMonthDuration, (2 * $dtdur) is statically dayTimeDuration, ($dtdur * 3.12) is statically dayTimeDuration, ($ymdur div 4.3) is statically yearMonthDuration, ($dtdur div 12) is statically dayTimeDuration, ($ymdur div $ymdur) is statically decimal, ($dtdur div $dtdur) is statically decimal \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul3.jq b/src/test/resources/test_files/static-typing/arithmetic/mul3.jq index 875237403b..a54d4804a8 100644 --- a/src/test/resources/test_files/static-typing/arithmetic/mul3.jq +++ b/src/test/resources/test_files/static-typing/arithmetic/mul3.jq @@ -1,3 +1,3 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $ymdur := "P1Y2M" cast as yearMonthDuration +declare variable $ymdur := "P1Y2M" cast as yearMonthDuration; $ymdur idiv 3 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul4.jq b/src/test/resources/test_files/static-typing/arithmetic/mul4.jq index feba00cd96..4d5f6dfd7a 100644 --- a/src/test/resources/test_files/static-typing/arithmetic/mul4.jq +++ b/src/test/resources/test_files/static-typing/arithmetic/mul4.jq @@ -1,3 +1,3 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $dtdur := "P2DT3H" cast as dayTimeDuration +declare variable $dtdur := "P2DT3H" cast as dayTimeDuration; $dtdur idiv 2.22 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul5.jq b/src/test/resources/test_files/static-typing/arithmetic/mul5.jq index 50cbc57236..8f7b67997e 100644 --- a/src/test/resources/test_files/static-typing/arithmetic/mul5.jq +++ b/src/test/resources/test_files/static-typing/arithmetic/mul5.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $dtdur := "P2DT3H" cast as dayTimeDuration -declare $ymdur := "P1Y2M" cast as yearMonthDuration +declare variable $dtdur := "P2DT3H" cast as dayTimeDuration; +declare variable $ymdur := "P1Y2M" cast as yearMonthDuration; $ymdur div $dtdur \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul6.jq b/src/test/resources/test_files/static-typing/arithmetic/mul6.jq index 80f5780be1..fb4cf50c60 100644 --- a/src/test/resources/test_files/static-typing/arithmetic/mul6.jq +++ b/src/test/resources/test_files/static-typing/arithmetic/mul6.jq @@ -1,3 +1,3 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $dtdur := "P2DT3H" cast as dayTimeDuration +declare variable $dtdur := "P2DT3H" cast as dayTimeDuration; $dtdur mod 12 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp10.jq b/src/test/resources/test_files/static-typing/comparison/comp10.jq index add3000745..6ec3cd030b 100644 --- a/src/test/resources/test_files/static-typing/comparison/comp10.jq +++ b/src/test/resources/test_files/static-typing/comparison/comp10.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $dtdur := "P2DT3H" cast as dayTimeDuration -declare $ymdur := "P1Y2M" cast as yearMonthDuration +declare variable $dtdur := "P2DT3H" cast as dayTimeDuration; +declare variable $ymdur := "P1Y2M" cast as yearMonthDuration; $ymdur lt $dtdur \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp11.jq b/src/test/resources/test_files/static-typing/comparison/comp11.jq index b68406149d..c21afca4da 100644 --- a/src/test/resources/test_files/static-typing/comparison/comp11.jq +++ b/src/test/resources/test_files/static-typing/comparison/comp11.jq @@ -1,3 +1,3 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $hexb := "0cd7" cast as hexBinary +declare variable $hexb := "0cd7" cast as hexBinary; $hexb lt $hexb \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp12.jq b/src/test/resources/test_files/static-typing/comparison/comp12.jq index 7b9f28e026..22496cd589 100644 --- a/src/test/resources/test_files/static-typing/comparison/comp12.jq +++ b/src/test/resources/test_files/static-typing/comparison/comp12.jq @@ -1,3 +1,3 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $base64b := "DNc=" cast as base64Binary +declare variable $base64b := "DNc=" cast as base64Binary; $base64b lt $base64b \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp13.jq b/src/test/resources/test_files/static-typing/comparison/comp13.jq index 4a8fb412e8..5773644945 100644 --- a/src/test/resources/test_files/static-typing/comparison/comp13.jq +++ b/src/test/resources/test_files/static-typing/comparison/comp13.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $hexb := "0cd7" cast as hexBinary -declare $base64b := "DNc=" cast as base64Binary +declare variable $hexb := "0cd7" cast as hexBinary; +declare variable $base64b := "DNc=" cast as base64Binary; $hexb eq $base64b \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp2.jq b/src/test/resources/test_files/static-typing/comparison/comp2.jq index 426a565d4d..83c8ba8228 100644 --- a/src/test/resources/test_files/static-typing/comparison/comp2.jq +++ b/src/test/resources/test_files/static-typing/comparison/comp2.jq @@ -1,9 +1,9 @@ (:JIQS: ShouldRun :) -declare $date := '2020-02-12' cast as date -declare $dt := "2015-05-03T13:20:00" cast as dateTime -declare $time := "13:20:00" cast as time -declare $dtdur := "P2DT3H" cast as dayTimeDuration -declare $ymdur := "P1Y2M" cast as yearMonthDuration -declare $hexb := "0cd7" cast as hexBinary -declare $base64b := "DNc=" cast as base64Binary +declare variable $date := "2020-02-12" cast as date; +declare variable $dt := "2015-05-03T13:20:00" cast as dateTime; +declare variable $time := "13:20:00" cast as time; +declare variable $dtdur := "P2DT3H" cast as dayTimeDuration; +declare variable $ymdur := "P1Y2M" cast as yearMonthDuration; +declare variable $hexb := "0cd7" cast as hexBinary; +declare variable $base64b := "DNc=" cast as base64Binary; ($date eq $date) is statically boolean, ($date lt $date) is statically boolean, ($dt eq $dt) is statically boolean, ($dt lt $dt) is statically boolean, ($time eq $time) is statically boolean, ($time gt $time) is statically boolean, ($ymdur eq $ymdur) is statically boolean, ($ymdur lt $ymdur) is statically boolean, ($dtdur eq $dtdur) is statically boolean, ($dtdur lt $dtdur) is statically boolean, ($ymdur eq $dtdur) is statically boolean, (($ymdur treat as duration) eq $dtdur) is statically boolean, ($hexb eq $hexb) is statically boolean, ($base64b eq $base64b) is statically boolean \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp8.jq b/src/test/resources/test_files/static-typing/comparison/comp8.jq index 9c20b42ac3..c81dc8137f 100644 --- a/src/test/resources/test_files/static-typing/comparison/comp8.jq +++ b/src/test/resources/test_files/static-typing/comparison/comp8.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $date := '2020-02-12' cast as date -declare $dt := "2015-05-03T13:20:00" cast as dateTime +declare variable $date := "2020-02-12" cast as date; +declare variable $dt := "2015-05-03T13:20:00" cast as dateTime; $date eq $dt \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/comparison/comp9.jq b/src/test/resources/test_files/static-typing/comparison/comp9.jq index 3d9234db83..e33c4ba807 100644 --- a/src/test/resources/test_files/static-typing/comparison/comp9.jq +++ b/src/test/resources/test_files/static-typing/comparison/comp9.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $dt := "2015-05-03T13:20:00" cast as dateTime -declare $time := "13:20:00" cast as time +declare variable $dt := "2015-05-03T13:20:00" cast as dateTime; +declare variable $time := "13:20:00" cast as time; $dt eq $time \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/if9.jq b/src/test/resources/test_files/static-typing/control/if9.jq index 7080606d5e..b9c7c4f9b7 100644 --- a/src/test/resources/test_files/static-typing/control/if9.jq +++ b/src/test/resources/test_files/static-typing/control/if9.jq @@ -1,5 +1,5 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $dt := "2015-05-03T13:20:00" cast as dateTime +declare variable $dt := "2015-05-03T13:20:00" cast as dateTime; if($dt) then 3 else 4 \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/order2.jq b/src/test/resources/test_files/static-typing/flwor/order2.jq index 20cd29a908..d29f4c3dc9 100644 --- a/src/test/resources/test_files/static-typing/flwor/order2.jq +++ b/src/test/resources/test_files/static-typing/flwor/order2.jq @@ -1,5 +1,5 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $hexb := "0cd7" cast as hexBinary +declare variable $hexb := "0cd7" cast as hexBinary; for $a in ($hexb, $hexb) order by $a return $a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/flwor/where1.jq b/src/test/resources/test_files/static-typing/flwor/where1.jq index a49c0e740a..bd9bb19b77 100644 --- a/src/test/resources/test_files/static-typing/flwor/where1.jq +++ b/src/test/resources/test_files/static-typing/flwor/where1.jq @@ -1,5 +1,5 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $ymdur := "P1Y2M" cast as yearMonthDuration +declare variable $ymdur := "P1Y2M" cast as yearMonthDuration; for $a in (1,2,3) where $ymdur return $a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/logic2.jq b/src/test/resources/test_files/static-typing/logic2.jq index 8afd1d3d16..d889fb95b9 100644 --- a/src/test/resources/test_files/static-typing/logic2.jq +++ b/src/test/resources/test_files/static-typing/logic2.jq @@ -1,7 +1,7 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $date := '2020-02-12' cast as date -declare $dt := "2015-05-03T13:20:00" cast as dateTime -declare $time := "13:20:00" cast as time -declare $hexb := "0cd7" cast as hexBinary -declare $base64b := "DNc=" cast as base64Binary +declare variable $date := "2020-02-12" cast as date; +declare variable $dt := "2015-05-03T13:20:00" cast as dateTime; +declare variable $time := "13:20:00" cast as time; +declare variable $hexb := "0cd7" cast as hexBinary; +declare variable $base64b := "DNc=" cast as base64Binary; $date or $time or $dt or $hexb and $base64b \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/quantified2.jq b/src/test/resources/test_files/static-typing/quantified2.jq index f26629306b..1e7369b8e7 100644 --- a/src/test/resources/test_files/static-typing/quantified2.jq +++ b/src/test/resources/test_files/static-typing/quantified2.jq @@ -1,3 +1,3 @@ (:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) -declare $hexb := "0cd7" cast as hexBinary +declare variable $hexb := "0cd7" cast as hexBinary; some $a in ($hexb) satisfies $a \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/cast2.jq b/src/test/resources/test_files/static-typing/typing/cast2.jq index edaeb713a6..1aa54f5010 100644 --- a/src/test/resources/test_files/static-typing/typing/cast2.jq +++ b/src/test/resources/test_files/static-typing/typing/cast2.jq @@ -1,6 +1,6 @@ (:JIQS: ShouldRun :) -declare $date := '2020-02-12' cast as date -declare $dt := "2015-05-03T13:20:00" cast as dateTime -declare $hexb := "0cd7" cast as hexBinary -declare $base64b := "DNc=" cast as base64Binary +declare variable $date := "2020-02-12" cast as date; +declare variable $dt := "2015-05-03T13:20:00" cast as dateTime; +declare variable $hexb := "0cd7" cast as hexBinary; +declare variable $base64b := "DNc=" cast as base64Binary; ($base64b cast as hexBinary) is statically hexBinary, ($hexb cast as base64Binary) is statically base64Binary, ($dt cast as date) is statically date, ($dt cast as time) is statically time, ($date cast as dateTime) is statically dateTime, (null cast as null) is statically null, (3 cast as integer?) is statically integer? \ No newline at end of file From 1a7ee08ec092fdd7cdc7a8e0fbafc6ce5af2cf71 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 09:57:50 +0100 Subject: [PATCH 074/206] fix quantified type inference, single arity version of inferred type is bound or check in the variable --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index d7a00f65d6..4f9641a8ff 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1098,9 +1098,10 @@ public StaticContext visitQuantifiedExpression(QuantifiedExpression expression, if (inferredType.isEmptySequence()) { skipTestInference = true; } else { + // we use the single arity version of the inferred type checkVariableType( varType, - inferredType, + new SequenceType(inferredType.getItemType()), evaluationExpression.getStaticContext(), expression.getClass().getSimpleName(), var.getVariableName() From 046ff72f0d886d7a802b298feb2d148147ae667a Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 10:17:13 +0100 Subject: [PATCH 075/206] where clause affect flwor clause arity by including possibility of zero --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 4f9641a8ff..dc63106cef 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1332,6 +1332,13 @@ public StaticContext visitFlowrExpression(FlworExpression expression, StaticCont if (!forType.isEmptySequence()) { forArities = forType.getArity().multiplyWith(forArities); } + } else if(clause.getClauseType() == FLWOR_CLAUSES.WHERE){ + // where clause could reject all tuples so arity change from + => * and 1 => ? + if(forArities == SequenceType.Arity.One){ + forArities = SequenceType.Arity.OneOrZero; + } else if(forArities == SequenceType.Arity.OneOrMore){ + forArities = SequenceType.Arity.ZeroOrMore; + } } clause = clause.getNextClause(); } From d8cade22e46b06e7b06b600fbe4691b3db23e8aa Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 10:42:31 +0100 Subject: [PATCH 076/206] added checks for JNTY0004 error --- .../rumbledb/compiler/InferTypeVisitor.java | 33 ++++++++++++++++++- .../java/org/rumbledb/types/SequenceType.java | 2 ++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index dc63106cef..ff9fa90bb1 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -339,12 +339,19 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static public StaticContext visitCastableExpression(CastableExpression expression, StaticContext argument) { System.out.println("visiting Castable expression"); visitDescendants(expression, argument); - if (expression.getSequenceType().getItemType().equals(ItemType.atomicItem)) { + ItemType itemType = expression.getSequenceType().getItemType(); + if (itemType.equals(ItemType.atomicItem)) { throw new UnexpectedStaticTypeException( "atomic item type is not allowed in castable expression", ErrorCode.CastableErrorCode ); } + if(!itemType.isSubtypeOf(ItemType.atomicItem)) { + throw new UnexpectedStaticTypeException( + "non-atomic item types are allowed in castable expression, found " + itemType, + itemType.isSubtypeOf(ItemType.JSONItem) ? ErrorCode.NonAtomicElementErrorCode : ErrorCode.UnexpectedTypeErrorCode + ); + } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); return argument; } @@ -387,6 +394,13 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex } // ItemType static castability check + if(expressionSequenceType.getItemType().isSubtypeOf(ItemType.JSONItem)){ + throw new UnexpectedStaticTypeException( + "It is never possible to cast a non-atomic sequence type: " + + + expressionSequenceType, ErrorCode.NonAtomicElementErrorCode + ); + } if (!expressionSequenceType.getItemType().staticallyCastableAs(castedSequenceType.getItemType())) { throw new UnexpectedStaticTypeException( "It is never possible to cast a " @@ -786,6 +800,9 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static ItemType rightItemType = rightInferredType.getItemType(); // Type must be a strict subtype of atomic + if (leftItemType.isSubtypeOf(ItemType.JSONItem) || rightItemType.isSubtypeOf(ItemType.JSONItem)){ + throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types", ErrorCode.NonAtomicElementErrorCode); + } if ( !leftItemType.isSubtypeOf(ItemType.atomicItem) || !rightItemType.isSubtypeOf(ItemType.atomicItem) @@ -1463,6 +1480,14 @@ public StaticContext visitGroupByClause(GroupByClause expression, StaticContext expectedType = expression.getStaticContext().getVariableSequenceType(groupByVar.getVariableName()); } // check that expectedType is a subtype of atomic? + if(expectedType.isSubtypeOf(SequenceType.createSequenceType("json-item*"))){ + throw new UnexpectedStaticTypeException( + "group by variable " + + groupByVar.getVariableName() + + " must match atomic? instead found " + + expectedType, ErrorCode.NonAtomicElementErrorCode + ); + } if (!expectedType.isSubtypeOf(SequenceType.createSequenceType("atomic?"))) { throw new UnexpectedStaticTypeException( "group by variable " @@ -1488,6 +1513,12 @@ public StaticContext visitOrderByClause(OrderByClause expression, StaticContext for (OrderByClauseSortingKey orderClause : expression.getSortingKeys()) { SequenceType orderType = orderClause.getExpression().getInferredSequenceType(); basicChecks(orderType, expression.getClass().getSimpleName(), true, false); + if(orderType.isSubtypeOf(SequenceType.createSequenceType("json-item*"))){ + throw new UnexpectedStaticTypeException( + "order by sorting expression's type must match atomic? and be comparable using 'gt' operator (so duration, hexBinary, base64Binary and atomic item type are not allowed), instead inferred: " + + orderType, ErrorCode.NonAtomicElementErrorCode + ); + } if ( !orderType.isSubtypeOf(SequenceType.createSequenceType("atomic?")) || diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index f1ec7aa285..b688189826 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -278,6 +278,8 @@ public String toString() { sequenceTypes.put("object+", new SequenceType(ItemType.objectItem, SequenceType.Arity.OneOrMore)); sequenceTypes.put("object*", new SequenceType(ItemType.objectItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("json-item*", new SequenceType(ItemType.JSONItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("array?", new SequenceType(ItemType.arrayItem, SequenceType.Arity.OneOrZero)); sequenceTypes.put("array*", new SequenceType(ItemType.arrayItem, Arity.ZeroOrMore)); From fb91b88d6e38e08603c98f92e1d438fc2fe2a072 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 10:58:43 +0100 Subject: [PATCH 077/206] integer is now subtype of decimal as by spec, and when checking variable assignment promotion is no longer allowed --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 4 +--- src/main/java/org/rumbledb/types/ItemType.java | 3 ++- src/main/java/org/rumbledb/types/SequenceType.java | 4 +--- .../resources/test_files/static-typing/comparison/comp19.jq | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index ff9fa90bb1..1cf5ee05b3 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1561,9 +1561,7 @@ public void checkVariableType( // type context.replaceVariableSequenceType(variableName, inferredType); } else { - // the expression we get is a treat expression by design so we need to extract the inferred type of its main - // expression - if (!inferredType.isSubtypeOfOrCanBePromotedTo(declaredType)) { + if (!inferredType.isSubtypeOf(declaredType)) { throw new UnexpectedStaticTypeException( "In a " + nodeName diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index e0003eda86..ac2003277e 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -1080,7 +1080,6 @@ public boolean equals(Object other) { // Returns true if [this] is a subtype of [superType], any type is considered a subtype of itself public boolean isSubtypeOf(ItemType superType) { - // TODO: what about Dates/Durations, base64, hex and anyURI if (superType.equals(item)) { return true; } else if (superType.equals(JSONItem)) { @@ -1108,6 +1107,8 @@ public boolean isSubtypeOf(ItemType superType) { return this.equals(yearMonthDurationItem) || this.equals(dayTimeDurationItem) || this.equals(durationItem); + } else if (superType.equals(decimalItem)) { + return this.equals(integerItem) || this.equals(decimalItem); } return this.equals(superType); } diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index b688189826..7d7e665225 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -94,9 +94,7 @@ public boolean isSubtypeOfOrCanBePromotedTo(SequenceType superType) { || (this.itemType.canBePromotedToString() && superType.itemType.equals(ItemType.stringItem)) || - (this.itemType.isNumeric() && superType.itemType.equals(ItemType.doubleItem)) - || - (this.itemType.equals(ItemType.integerItem) && superType.itemType.equals(ItemType.decimalItem))); + (this.itemType.isNumeric() && superType.itemType.equals(ItemType.doubleItem))); } // check if the arity of a sequence type is subtype of another arity, assume [this] is a non-empty sequence diff --git a/src/test/resources/test_files/static-typing/comparison/comp19.jq b/src/test/resources/test_files/static-typing/comparison/comp19.jq index 593e1eb962..0c50604ce7 100644 --- a/src/test/resources/test_files/static-typing/comparison/comp19.jq +++ b/src/test/resources/test_files/static-typing/comparison/comp19.jq @@ -1,2 +1,2 @@ (:JIQS: ShouldRun :) -(1, 2.22) < (4, 4.3) is statically boolean \ No newline at end of file +((1, 2.22) < (4, 4.3)) is statically boolean \ No newline at end of file From 4eb69d131e5babb1bf53572a1ea75f01d858a290 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 11:13:54 +0100 Subject: [PATCH 078/206] fixed comparison static type now deals properly with general comparison and empty sequence --- .../rumbledb/compiler/InferTypeVisitor.java | 104 +++++++++--------- 1 file changed, 55 insertions(+), 49 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 1cf5ee05b3..47af2e6981 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -796,58 +796,64 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static } } - ItemType leftItemType = leftInferredType.getItemType(); - ItemType rightItemType = rightInferredType.getItemType(); + // if any of the element is the empty sequence, we set its sequence type to the other, if both are we do not need additional checks + boolean isLeftEmpty = leftInferredType.isEmptySequence(); + boolean isRightEmpty = rightInferredType.isEmptySequence(); + if(!isLeftEmpty || !isRightEmpty) { - // Type must be a strict subtype of atomic - if (leftItemType.isSubtypeOf(ItemType.JSONItem) || rightItemType.isSubtypeOf(ItemType.JSONItem)){ - throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types", ErrorCode.NonAtomicElementErrorCode); - } - if ( - !leftItemType.isSubtypeOf(ItemType.atomicItem) - || !rightItemType.isSubtypeOf(ItemType.atomicItem) - || leftItemType.equals(ItemType.atomicItem) - || rightItemType.equals(ItemType.atomicItem) - ) { - throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types"); - } + ItemType leftItemType = isLeftEmpty ? rightInferredType.getItemType() : leftInferredType.getItemType(); + ItemType rightItemType = isRightEmpty ? leftInferredType.getItemType() : rightInferredType.getItemType(); - // Type must match exactly or be both numeric or both promotable to string or both durations - if ( - !leftItemType.equals(rightItemType) - && - !(leftItemType.isNumeric() && rightItemType.isNumeric()) - && - !(leftItemType.isSubtypeOf(ItemType.durationItem) && rightItemType.isSubtypeOf(ItemType.durationItem)) - && - !(leftItemType.canBePromotedToString() && rightItemType.canBePromotedToString()) - ) { - throw new UnexpectedStaticTypeException( - "It is not possible to compare these types: " + leftItemType + " and " + rightItemType - ); - } + // Type must be a strict subtype of atomic + if (leftItemType.isSubtypeOf(ItemType.JSONItem) || rightItemType.isSubtypeOf(ItemType.JSONItem)) { + throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types", ErrorCode.NonAtomicElementErrorCode); + } + if ( + !leftItemType.isSubtypeOf(ItemType.atomicItem) + || !rightItemType.isSubtypeOf(ItemType.atomicItem) + || leftItemType.equals(ItemType.atomicItem) + || rightItemType.equals(ItemType.atomicItem) + ) { + throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types"); + } - // Inequality is not defined for hexBinary and base64binary or for duration of different types - if ( - (operator != ComparisonExpression.ComparisonOperator.VC_EQ - && - operator != ComparisonExpression.ComparisonOperator.VC_NE - && - operator != ComparisonExpression.ComparisonOperator.GC_EQ - && - operator != ComparisonExpression.ComparisonOperator.GC_NE) - && (leftItemType.equals(ItemType.hexBinaryItem) - || leftItemType.equals(ItemType.base64BinaryItem) - || - leftItemType.equals(ItemType.durationItem) - || rightItemType.equals(ItemType.durationItem) - || - ((leftItemType.equals(ItemType.dayTimeDurationItem) - || leftItemType.equals(ItemType.yearMonthDurationItem)) && !rightItemType.equals(leftItemType))) - ) { - throw new UnexpectedStaticTypeException( - "It is not possible to compare these types: " + leftItemType + " " + operator + " " + rightItemType - ); + // Type must match exactly or be both numeric or both promotable to string or both durations + if ( + !leftItemType.equals(rightItemType) + && + !(leftItemType.isNumeric() && rightItemType.isNumeric()) + && + !(leftItemType.isSubtypeOf(ItemType.durationItem) && rightItemType.isSubtypeOf(ItemType.durationItem)) + && + !(leftItemType.canBePromotedToString() && rightItemType.canBePromotedToString()) + ) { + throw new UnexpectedStaticTypeException( + "It is not possible to compare these types: " + leftItemType + " and " + rightItemType + ); + } + + // Inequality is not defined for hexBinary and base64binary or for duration of different types + if ( + (operator != ComparisonExpression.ComparisonOperator.VC_EQ + && + operator != ComparisonExpression.ComparisonOperator.VC_NE + && + operator != ComparisonExpression.ComparisonOperator.GC_EQ + && + operator != ComparisonExpression.ComparisonOperator.GC_NE) + && (leftItemType.equals(ItemType.hexBinaryItem) + || leftItemType.equals(ItemType.base64BinaryItem) + || + leftItemType.equals(ItemType.durationItem) + || rightItemType.equals(ItemType.durationItem) + || + ((leftItemType.equals(ItemType.dayTimeDurationItem) + || leftItemType.equals(ItemType.yearMonthDurationItem)) && !rightItemType.equals(leftItemType))) + ) { + throw new UnexpectedStaticTypeException( + "It is not possible to compare these types: " + leftItemType + " " + operator + " " + rightItemType + ); + } } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); From 9b5bd6d20407faa21c6f292bb2dcde808c2da251 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 11:33:58 +0100 Subject: [PATCH 079/206] added optional inferred arity in value comparison type inference when possible --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 6 ++++-- .../resources/test_files/static-typing/comparison/comp1.jq | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 47af2e6981..a508594723 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -771,6 +771,7 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static List childrenExpressions = expression.getChildren(); SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); + SequenceType.Arity returnArity = SequenceType.Arity.One; if (leftInferredType == null || rightInferredType == null) { throw new UnexpectedStaticTypeException( @@ -789,7 +790,8 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression ); } - if (resolveArities(leftInferredType.getArity(), rightInferredType.getArity()) == null) { + returnArity = resolveArities(leftInferredType.getArity(), rightInferredType.getArity()); + if (returnArity == null) { throw new UnexpectedStaticTypeException( "'+' and '*' arities are not allowed for this comparison operator: " + operator ); @@ -856,7 +858,7 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static } } - expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem, returnArity)); return argument; } diff --git a/src/test/resources/test_files/static-typing/comparison/comp1.jq b/src/test/resources/test_files/static-typing/comparison/comp1.jq index f09e656d52..29b3774bc9 100644 --- a/src/test/resources/test_files/static-typing/comparison/comp1.jq +++ b/src/test/resources/test_files/static-typing/comparison/comp1.jq @@ -1,2 +1,2 @@ (:JIQS: ShouldRun :) -(1 eq 2) is statically boolean, (1 eq (2 treat as integer?)) is statically boolean?, (1 eq 2.2) is statically boolean, (1 ge 3e4) is statically boolean, (2.2 gt 3e2) is statically boolean, (3.3 le 34) is statically boolean, (12 lt 23) is statically boolean, (13 ne 1.2) is statically boolean, ("ab" eq "we") is statically boolean, ("ad" gt "qw") is statically boolean, (("qw" treat as anyURI) gt "erty") is statically boolean, (true eq false) is statically boolean, (true gt false) is statically boolean \ No newline at end of file +(1 eq 2) is statically boolean, (1 eq (2 treat as integer?)) is statically boolean?, (1 eq 2.2) is statically boolean, (1 ge 3e4) is statically boolean, (2.2 gt 3e2) is statically boolean, (3.3 le 34) is statically boolean, (12 lt 23) is statically boolean, (13 ne 1.2) is statically boolean, ("ab" eq "we") is statically boolean, ("ad" gt "qw") is statically boolean, (("qw" cast as anyURI) gt "erty") is statically boolean, (true eq false) is statically boolean, (true gt false) is statically boolean \ No newline at end of file From b9f97345d891ab44b712c4cc3b8f77d9c787dfef Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 13:02:10 +0100 Subject: [PATCH 080/206] fixed bug in setting returning arity in filter expression --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index a508594723..a77394bcf3 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1279,7 +1279,7 @@ public StaticContext visitFilterExpression(FilterExpression expression, StaticCo // if we are filter one or less items or we use an integer to select a specific position we return at most one // element, otherwise * SequenceType.Arity inferredArity = (mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) - || mainType.getItemType().equals(ItemType.integerItem)) + || predicateType.getItemType().equals(ItemType.integerItem)) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; expression.setInferredSequenceType(new SequenceType(mainType.getItemType(), inferredArity)); From 38d2ba6b29f940d6c1ae0bce59fa1c2eb4dbd559 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 13:18:01 +0100 Subject: [PATCH 081/206] fixed bug in array and object lookup static typing, now return item item type instead of array and object respectevely --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 4 ++-- .../test_files/static-typing/postfix/dynamicfunc1.jq | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index a77394bcf3..2d911a0287 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1184,7 +1184,7 @@ public StaticContext visitArrayLookupExpression(ArrayLookupExpression expression SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; - expression.setInferredSequenceType(new SequenceType(ItemType.arrayItem, inferredArity)); + expression.setInferredSequenceType(new SequenceType(ItemType.item, inferredArity)); System.out.println("visiting ArrayLookup expression, type set to: " + expression.getInferredSequenceType()); return argument; } @@ -1219,7 +1219,7 @@ public StaticContext visitObjectLookupExpression(ObjectLookupExpression expressi SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; - expression.setInferredSequenceType(new SequenceType(ItemType.objectItem, inferredArity)); + expression.setInferredSequenceType(new SequenceType(ItemType.item, inferredArity)); System.out.println("visiting ObjectLookup expression, type set to: " + expression.getInferredSequenceType()); return argument; } diff --git a/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq b/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq index 137d0a8fad..b55ecc5909 100644 --- a/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq +++ b/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldRun :) -declare function a($b) { "a" || $b }; +declare function a($b as atomic) { "a" || $b }; declare variable $a := a#1; $a(12) is statically item*, $a(?) is statically function \ No newline at end of file From f5a204d28abdfa30ded92d5954a432e00922ba99 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 13:31:05 +0100 Subject: [PATCH 082/206] fixed castable inference bug --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 2d911a0287..ee114eca6c 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -346,9 +346,11 @@ public StaticContext visitCastableExpression(CastableExpression expression, Stat ErrorCode.CastableErrorCode ); } - if(!itemType.isSubtypeOf(ItemType.atomicItem)) { + SequenceType expressionType = expression.getMainExpression().getInferredSequenceType(); + basicChecks(expressionType, expression.getClass().getSimpleName(), true, false); + if(!expressionType.isEmptySequence() && !expressionType.getItemType().isSubtypeOf(ItemType.atomicItem)) { throw new UnexpectedStaticTypeException( - "non-atomic item types are allowed in castable expression, found " + itemType, + "non-atomic item types are not allowed in castable expression, found " + itemType, itemType.isSubtypeOf(ItemType.JSONItem) ? ErrorCode.NonAtomicElementErrorCode : ErrorCode.UnexpectedTypeErrorCode ); } From 16e133dc8ee50275c2c75cb0e26697e0f43d2b82 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 13:43:55 +0100 Subject: [PATCH 083/206] fixed multiplication type inference for duration */div numeric --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 2 +- src/test/resources/test_files/static-typing/arithmetic/mul1.jq | 2 +- src/test/resources/test_files/static-typing/misc/concat1.jq | 2 ++ src/test/resources/test_files/static-typing/typing/treat.jq | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index ee114eca6c..9d5d27b592 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -615,7 +615,7 @@ public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression || expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV) ) { - inferredType = rightItemType; + inferredType = leftItemType; } else if (rightItemType.equals(leftItemType) && !leftItemType.equals(ItemType.durationItem)) { inferredType = ItemType.decimalItem; } diff --git a/src/test/resources/test_files/static-typing/arithmetic/mul1.jq b/src/test/resources/test_files/static-typing/arithmetic/mul1.jq index ae94144b34..a95188cbd2 100644 --- a/src/test/resources/test_files/static-typing/arithmetic/mul1.jq +++ b/src/test/resources/test_files/static-typing/arithmetic/mul1.jq @@ -1,2 +1,2 @@ (:JIQS: ShouldRun :) -(3 * 12.2) is statically decimal, (3 treat as integer? * 12.2) is statically decimal?, (2 * 2) is statically integer, (6 idiv 5) is statically integer, (3.22 idiv 1.3) is statically integer, (3e4 idiv 14.44) is statically integer, ($dtdur idiv 2.22) is statically XPTY0004, (6 div 5) is statically decimal, (10 div 5) is statically decimal, (12 div 3.3) is statically decimal, (2e3 div 13) is statically double, (3 mod 1.2) is statically decimal, (34 mod 11) is statically integer, (3e4 mod 29) is statically double \ No newline at end of file +(3 * 12.2) is statically decimal, (3 treat as integer? * 12.2) is statically decimal?, (2 * 2) is statically integer, (6 idiv 5) is statically integer, (3.22 idiv 1.3) is statically integer, (3e4 idiv 14.44) is statically integer, (6 div 5) is statically decimal, (10 div 5) is statically decimal, (12 div 3.3) is statically decimal, (2e3 div 13) is statically double, (3 mod 1.2) is statically decimal, (34 mod 11) is statically integer, (3e4 mod 29) is statically double \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/misc/concat1.jq b/src/test/resources/test_files/static-typing/misc/concat1.jq index d76098d852..1a3f108a10 100644 --- a/src/test/resources/test_files/static-typing/misc/concat1.jq +++ b/src/test/resources/test_files/static-typing/misc/concat1.jq @@ -1,2 +1,4 @@ (:JIQS: ShouldRun :) +declare variable $date := "2020-02-12" cast as date; +declare variable $hexb := "0cd7" cast as hexBinary; ("qwe" || "rty") is statically string, (() || ()) is statically string, (12 || $date) is statically string, (33.3 || $hexb) is statically string, (12 treat as atomic? || null) is statically string \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/treat.jq b/src/test/resources/test_files/static-typing/typing/treat.jq index 629b2241af..7ad2e14833 100644 --- a/src/test/resources/test_files/static-typing/typing/treat.jq +++ b/src/test/resources/test_files/static-typing/typing/treat.jq @@ -1,2 +1,2 @@ (:JIQS: ShouldRun :) -(3 treat as object) is statically object, (4 treat as atomic+) is statically atomic+ +(3 treat as item) is statically item, (4 treat as atomic+) is statically atomic+ From b139dc436c014c9299a8c2770d8a1310eff6f0ab Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 13:53:46 +0100 Subject: [PATCH 084/206] added smart branch inference to conditional expression --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 7 +++++-- src/test/resources/test_files/static-typing/control/if1.jq | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 9d5d27b592..0285696508 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -888,14 +888,17 @@ public StaticContext visitConditionalExpression(ConditionalExpression expression ); } - if (thenType.isEmptySequence() && elseType.isEmptySequence()) { + // if the if branch is false at static time (i.e. subtype of null?) we only use else branch + SequenceType resultingType = ifType.isSubtypeOf(SequenceType.createSequenceType("null?")) ? elseType : thenType.leastCommonSupertypeWith(elseType); + + if (resultingType.isEmptySequence()) { throw new UnexpectedStaticTypeException( "Inferred type is empty sequence and this is not a CommaExpression", ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression ); } - expression.setInferredSequenceType(thenType.leastCommonSupertypeWith(elseType)); + expression.setInferredSequenceType(resultingType); System.out.println("visiting Conditional expression, type set to: " + expression.getInferredSequenceType()); return argument; } diff --git a/src/test/resources/test_files/static-typing/control/if1.jq b/src/test/resources/test_files/static-typing/control/if1.jq index 78e0d1fcb0..8201a157d2 100644 --- a/src/test/resources/test_files/static-typing/control/if1.jq +++ b/src/test/resources/test_files/static-typing/control/if1.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldRun :) (if(true) then 3 -else 4) is statically integer, \ No newline at end of file +else 4) is statically integer \ No newline at end of file From 4368c05cc67bd16d4d5044035c3655877b5073fc Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 14:02:45 +0100 Subject: [PATCH 085/206] fixed bug in switch inference for cases and test arities --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 0285696508..5b2fbe0dfe 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -911,7 +911,7 @@ public void checkSwitchType(SequenceType type) { if (type.isEmptySequence()) { return; // no further check is required } - if (type.getArity() == SequenceType.Arity.OneOrZero || type.getArity() == SequenceType.Arity.ZeroOrMore) { + if (type.getArity() == SequenceType.Arity.OneOrMore || type.getArity() == SequenceType.Arity.ZeroOrMore) { throw new UnexpectedStaticTypeException( "+ and * arities are not allowed for the expressions of switch test condition and cases" ); From 9578e5caaf043c20626d2dea56d5c49ea73f451c Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 15:12:18 +0100 Subject: [PATCH 086/206] minor fixes --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 4 ++-- src/test/resources/test_files/static-typing/map1.jq | 2 +- .../resources/test_files/static-typing/postfix/filter1.jq | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 5b2fbe0dfe..e41020d272 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -350,8 +350,8 @@ public StaticContext visitCastableExpression(CastableExpression expression, Stat basicChecks(expressionType, expression.getClass().getSimpleName(), true, false); if(!expressionType.isEmptySequence() && !expressionType.getItemType().isSubtypeOf(ItemType.atomicItem)) { throw new UnexpectedStaticTypeException( - "non-atomic item types are not allowed in castable expression, found " + itemType, - itemType.isSubtypeOf(ItemType.JSONItem) ? ErrorCode.NonAtomicElementErrorCode : ErrorCode.UnexpectedTypeErrorCode + "non-atomic item types are not allowed in castable expression, found " + expressionType.getItemType(), + expressionType.getItemType().isSubtypeOf(ItemType.JSONItem) ? ErrorCode.NonAtomicElementErrorCode : ErrorCode.UnexpectedTypeErrorCode ); } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); diff --git a/src/test/resources/test_files/static-typing/map1.jq b/src/test/resources/test_files/static-typing/map1.jq index 9c368d8c43..2bfa8ddc77 100644 --- a/src/test/resources/test_files/static-typing/map1.jq +++ b/src/test/resources/test_files/static-typing/map1.jq @@ -1,2 +1,2 @@ (:JIQS: ShouldRun :) -((1,2,3) ! ($$ + 3)) is statically integer+, ((1) ! ($$ + 3)) is statically integer, ((1) ! ($$ + 2, $$ + 3)) is statically integer+, ((1 treat as integer?) ! ($$ + 1)) is statically integer?, ((1 treat as integer?) ! ( $$ + 1 , $$ + 2 )) is statically integer*, ((1,2,"qw") ! ($$ || "postfix")) is statically string+, ((1, 2.33) ! ($$)) is statically atomic+ \ No newline at end of file +((1,2,3) ! ($$ + 3)) is statically integer+, ((1) ! ($$ + 3)) is statically integer, ((1) ! ($$ + 2, $$ + 3)) is statically integer+, ((1 treat as integer?) ! ($$ + 1)) is statically integer?, ((1 treat as integer?) ! ( $$ + 1 , $$ + 2 )) is statically integer*, ((1,2,"qw") ! ($$ || "postfix")) is statically string+, ((1, 2.33) ! ($$)) is statically decimal+ \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/filter1.jq b/src/test/resources/test_files/static-typing/postfix/filter1.jq index 8c3e8df4c7..807067731b 100644 --- a/src/test/resources/test_files/static-typing/postfix/filter1.jq +++ b/src/test/resources/test_files/static-typing/postfix/filter1.jq @@ -1,2 +1,2 @@ (:JIQS: ShouldRun :) -((1,2,3)[$$]) is statically integer*, ((1)[$$ gt 12]) is statically integer? \ No newline at end of file +((1,2,3)[$$ gt 12]) is statically integer*, ((1)[$$ gt 12]) is statically integer? \ No newline at end of file From de32a430e3c3bf676eacb6a27ae36cdc935b0c59 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 16:46:02 +0100 Subject: [PATCH 087/206] spotless --- .../rumbledb/compiler/InferTypeVisitor.java | 111 ++++++++++-------- 1 file changed, 65 insertions(+), 46 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index e41020d272..2de3d1183b 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -348,10 +348,13 @@ public StaticContext visitCastableExpression(CastableExpression expression, Stat } SequenceType expressionType = expression.getMainExpression().getInferredSequenceType(); basicChecks(expressionType, expression.getClass().getSimpleName(), true, false); - if(!expressionType.isEmptySequence() && !expressionType.getItemType().isSubtypeOf(ItemType.atomicItem)) { + if (!expressionType.isEmptySequence() && !expressionType.getItemType().isSubtypeOf(ItemType.atomicItem)) { throw new UnexpectedStaticTypeException( - "non-atomic item types are not allowed in castable expression, found " + expressionType.getItemType(), - expressionType.getItemType().isSubtypeOf(ItemType.JSONItem) ? ErrorCode.NonAtomicElementErrorCode : ErrorCode.UnexpectedTypeErrorCode + "non-atomic item types are not allowed in castable expression, found " + + expressionType.getItemType(), + expressionType.getItemType().isSubtypeOf(ItemType.JSONItem) + ? ErrorCode.NonAtomicElementErrorCode + : ErrorCode.UnexpectedTypeErrorCode ); } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); @@ -396,11 +399,12 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex } // ItemType static castability check - if(expressionSequenceType.getItemType().isSubtypeOf(ItemType.JSONItem)){ + if (expressionSequenceType.getItemType().isSubtypeOf(ItemType.JSONItem)) { throw new UnexpectedStaticTypeException( "It is never possible to cast a non-atomic sequence type: " - + - expressionSequenceType, ErrorCode.NonAtomicElementErrorCode + + + expressionSequenceType, + ErrorCode.NonAtomicElementErrorCode ); } if (!expressionSequenceType.getItemType().staticallyCastableAs(castedSequenceType.getItemType())) { @@ -800,36 +804,41 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static } } - // if any of the element is the empty sequence, we set its sequence type to the other, if both are we do not need additional checks + // if any of the element is the empty sequence, we set its sequence type to the other, if both are we do not + // need additional checks boolean isLeftEmpty = leftInferredType.isEmptySequence(); boolean isRightEmpty = rightInferredType.isEmptySequence(); - if(!isLeftEmpty || !isRightEmpty) { + if (!isLeftEmpty || !isRightEmpty) { ItemType leftItemType = isLeftEmpty ? rightInferredType.getItemType() : leftInferredType.getItemType(); ItemType rightItemType = isRightEmpty ? leftInferredType.getItemType() : rightInferredType.getItemType(); // Type must be a strict subtype of atomic if (leftItemType.isSubtypeOf(ItemType.JSONItem) || rightItemType.isSubtypeOf(ItemType.JSONItem)) { - throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types", ErrorCode.NonAtomicElementErrorCode); + throw new UnexpectedStaticTypeException( + "It is not possible to compare with non-atomic types", + ErrorCode.NonAtomicElementErrorCode + ); } if ( - !leftItemType.isSubtypeOf(ItemType.atomicItem) - || !rightItemType.isSubtypeOf(ItemType.atomicItem) - || leftItemType.equals(ItemType.atomicItem) - || rightItemType.equals(ItemType.atomicItem) + !leftItemType.isSubtypeOf(ItemType.atomicItem) + || !rightItemType.isSubtypeOf(ItemType.atomicItem) + || leftItemType.equals(ItemType.atomicItem) + || rightItemType.equals(ItemType.atomicItem) ) { throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types"); } // Type must match exactly or be both numeric or both promotable to string or both durations if ( - !leftItemType.equals(rightItemType) - && - !(leftItemType.isNumeric() && rightItemType.isNumeric()) - && - !(leftItemType.isSubtypeOf(ItemType.durationItem) && rightItemType.isSubtypeOf(ItemType.durationItem)) - && - !(leftItemType.canBePromotedToString() && rightItemType.canBePromotedToString()) + !leftItemType.equals(rightItemType) + && + !(leftItemType.isNumeric() && rightItemType.isNumeric()) + && + !(leftItemType.isSubtypeOf(ItemType.durationItem) + && rightItemType.isSubtypeOf(ItemType.durationItem)) + && + !(leftItemType.canBePromotedToString() && rightItemType.canBePromotedToString()) ) { throw new UnexpectedStaticTypeException( "It is not possible to compare these types: " + leftItemType + " and " + rightItemType @@ -838,24 +847,30 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static // Inequality is not defined for hexBinary and base64binary or for duration of different types if ( - (operator != ComparisonExpression.ComparisonOperator.VC_EQ - && - operator != ComparisonExpression.ComparisonOperator.VC_NE - && - operator != ComparisonExpression.ComparisonOperator.GC_EQ - && - operator != ComparisonExpression.ComparisonOperator.GC_NE) - && (leftItemType.equals(ItemType.hexBinaryItem) - || leftItemType.equals(ItemType.base64BinaryItem) - || - leftItemType.equals(ItemType.durationItem) - || rightItemType.equals(ItemType.durationItem) - || - ((leftItemType.equals(ItemType.dayTimeDurationItem) - || leftItemType.equals(ItemType.yearMonthDurationItem)) && !rightItemType.equals(leftItemType))) + (operator != ComparisonExpression.ComparisonOperator.VC_EQ + && + operator != ComparisonExpression.ComparisonOperator.VC_NE + && + operator != ComparisonExpression.ComparisonOperator.GC_EQ + && + operator != ComparisonExpression.ComparisonOperator.GC_NE) + && (leftItemType.equals(ItemType.hexBinaryItem) + || leftItemType.equals(ItemType.base64BinaryItem) + || + leftItemType.equals(ItemType.durationItem) + || rightItemType.equals(ItemType.durationItem) + || + ((leftItemType.equals(ItemType.dayTimeDurationItem) + || leftItemType.equals(ItemType.yearMonthDurationItem)) + && !rightItemType.equals(leftItemType))) ) { throw new UnexpectedStaticTypeException( - "It is not possible to compare these types: " + leftItemType + " " + operator + " " + rightItemType + "It is not possible to compare these types: " + + leftItemType + + " " + + operator + + " " + + rightItemType ); } } @@ -889,7 +904,9 @@ public StaticContext visitConditionalExpression(ConditionalExpression expression } // if the if branch is false at static time (i.e. subtype of null?) we only use else branch - SequenceType resultingType = ifType.isSubtypeOf(SequenceType.createSequenceType("null?")) ? elseType : thenType.leastCommonSupertypeWith(elseType); + SequenceType resultingType = ifType.isSubtypeOf(SequenceType.createSequenceType("null?")) + ? elseType + : thenType.leastCommonSupertypeWith(elseType); if (resultingType.isEmptySequence()) { throw new UnexpectedStaticTypeException( @@ -1362,11 +1379,11 @@ public StaticContext visitFlowrExpression(FlworExpression expression, StaticCont if (!forType.isEmptySequence()) { forArities = forType.getArity().multiplyWith(forArities); } - } else if(clause.getClauseType() == FLWOR_CLAUSES.WHERE){ + } else if (clause.getClauseType() == FLWOR_CLAUSES.WHERE) { // where clause could reject all tuples so arity change from + => * and 1 => ? - if(forArities == SequenceType.Arity.One){ + if (forArities == SequenceType.Arity.One) { forArities = SequenceType.Arity.OneOrZero; - } else if(forArities == SequenceType.Arity.OneOrMore){ + } else if (forArities == SequenceType.Arity.OneOrMore) { forArities = SequenceType.Arity.ZeroOrMore; } } @@ -1493,12 +1510,13 @@ public StaticContext visitGroupByClause(GroupByClause expression, StaticContext expectedType = expression.getStaticContext().getVariableSequenceType(groupByVar.getVariableName()); } // check that expectedType is a subtype of atomic? - if(expectedType.isSubtypeOf(SequenceType.createSequenceType("json-item*"))){ + if (expectedType.isSubtypeOf(SequenceType.createSequenceType("json-item*"))) { throw new UnexpectedStaticTypeException( "group by variable " - + groupByVar.getVariableName() - + " must match atomic? instead found " - + expectedType, ErrorCode.NonAtomicElementErrorCode + + groupByVar.getVariableName() + + " must match atomic? instead found " + + expectedType, + ErrorCode.NonAtomicElementErrorCode ); } if (!expectedType.isSubtypeOf(SequenceType.createSequenceType("atomic?"))) { @@ -1526,10 +1544,11 @@ public StaticContext visitOrderByClause(OrderByClause expression, StaticContext for (OrderByClauseSortingKey orderClause : expression.getSortingKeys()) { SequenceType orderType = orderClause.getExpression().getInferredSequenceType(); basicChecks(orderType, expression.getClass().getSimpleName(), true, false); - if(orderType.isSubtypeOf(SequenceType.createSequenceType("json-item*"))){ + if (orderType.isSubtypeOf(SequenceType.createSequenceType("json-item*"))) { throw new UnexpectedStaticTypeException( "order by sorting expression's type must match atomic? and be comparable using 'gt' operator (so duration, hexBinary, base64Binary and atomic item type are not allowed), instead inferred: " - + orderType, ErrorCode.NonAtomicElementErrorCode + + orderType, + ErrorCode.NonAtomicElementErrorCode ); } if ( From e0c41352c9bf46e8f6630fb623b4ed5a4f82ee13 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 24 Nov 2020 18:40:46 +0100 Subject: [PATCH 088/206] added control tests with multiple branches --- .../resources/test_files/static-typing/control/switch12.jq | 5 +++++ src/test/resources/test_files/static-typing/control/try5.jq | 4 ++++ .../test_files/static-typing/control/typeswitch6.jq | 5 +++++ 3 files changed, 14 insertions(+) create mode 100644 src/test/resources/test_files/static-typing/control/switch12.jq create mode 100644 src/test/resources/test_files/static-typing/control/try5.jq create mode 100644 src/test/resources/test_files/static-typing/control/typeswitch6.jq diff --git a/src/test/resources/test_files/static-typing/control/switch12.jq b/src/test/resources/test_files/static-typing/control/switch12.jq new file mode 100644 index 0000000000..6f9e3779f1 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/switch12.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldRun :) +(switch(3) +case 2 case 3 return "a" +case 4 return 12 +default return 12.4) is statically atomic \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/try5.jq b/src/test/resources/test_files/static-typing/control/try5.jq new file mode 100644 index 0000000000..9cee46c1c9 --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/try5.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun :) +(try{ 3 } +catch XPTY0004 { 12.3 } +catch * { "asd" }) is statically atomic \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/control/typeswitch6.jq b/src/test/resources/test_files/static-typing/control/typeswitch6.jq new file mode 100644 index 0000000000..68d464c40d --- /dev/null +++ b/src/test/resources/test_files/static-typing/control/typeswitch6.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldRun :) +(typeswitch(3) +case decimal return "asd" +case integer return 1 +default return 12.2) is statically atomic From 97296349ecb3e0dc6d9fa466eaa6064a0a4cdf5b Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 26 Nov 2020 12:21:46 +0100 Subject: [PATCH 089/206] corrected castable and cast static behaviour to raiseatomization errors and cast behaviour with 'atomic' expression type, corrected and added tests about this --- .../rumbledb/compiler/InferTypeVisitor.java | 28 ++++++++++--------- .../org/rumbledb/errorcodes/ErrorCode.java | 1 + .../java/org/rumbledb/types/ItemType.java | 18 +++++------- .../test_files/static-typing/typing/cast1.jq | 2 +- .../test_files/static-typing/typing/cast4.jq | 2 +- .../static-typing/typing/castable3.jq | 2 +- 6 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 2de3d1183b..ea7b569c31 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -354,7 +354,7 @@ public StaticContext visitCastableExpression(CastableExpression expression, Stat + expressionType.getItemType(), expressionType.getItemType().isSubtypeOf(ItemType.JSONItem) ? ErrorCode.NonAtomicElementErrorCode - : ErrorCode.UnexpectedTypeErrorCode + : ErrorCode.AtomizationError ); } expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); @@ -377,20 +377,22 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex ); } - // Empty sequence check - if (expressionSequenceType.isEmptySequence() && castedSequenceType.getArity() != SequenceType.Arity.OneOrZero) { - throw new UnexpectedStaticTypeException( - "Empty sequence cannot be cast to type with quantifier different from '?'" - ); + // Empty sequence case + if (expressionSequenceType.isEmptySequence()){ + if(castedSequenceType.getArity() != SequenceType.Arity.OneOrZero) { + throw new UnexpectedStaticTypeException( + "Empty sequence cannot be cast to type with quantifier different from '?'" + ); + } else { + // no additional check is needed + expression.setInferredSequenceType(castedSequenceType); + return argument; + } } - // Arity check - if (!castedSequenceType.isAritySubtypeOf(SequenceType.Arity.OneOrZero)) { - throw new UnexpectedStaticTypeException("It is possible to cast only to types with arity '1' or '?'"); - } if (!expressionSequenceType.isAritySubtypeOf(castedSequenceType.getArity())) { throw new UnexpectedStaticTypeException( - "It is never possible to cast a " + "with static type feature it is not possible to cast a " + expressionSequenceType + " as " @@ -399,12 +401,12 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex } // ItemType static castability check - if (expressionSequenceType.getItemType().isSubtypeOf(ItemType.JSONItem)) { + if (!expressionSequenceType.getItemType().isSubtypeOf(ItemType.atomicItem)) { throw new UnexpectedStaticTypeException( "It is never possible to cast a non-atomic sequence type: " + expressionSequenceType, - ErrorCode.NonAtomicElementErrorCode + expressionSequenceType.getItemType().isSubtypeOf(ItemType.JSONItem) ? ErrorCode.NonAtomicElementErrorCode : ErrorCode.AtomizationError ); } if (!expressionSequenceType.getItemType().staticallyCastableAs(castedSequenceType.getItemType())) { diff --git a/src/main/java/org/rumbledb/errorcodes/ErrorCode.java b/src/main/java/org/rumbledb/errorcodes/ErrorCode.java index d6de65e39a..82b0030526 100644 --- a/src/main/java/org/rumbledb/errorcodes/ErrorCode.java +++ b/src/main/java/org/rumbledb/errorcodes/ErrorCode.java @@ -106,6 +106,7 @@ public enum ErrorCode { PositionalVariableNameSameAsForVariable("XQST0089"), InvalidGroupVariableErrorCode("XQST0094"), + AtomizationError("FOTY0012"), UnexpectedFunctionITem("FOTY0015"), InvalidTimezoneValue("FODT0003"); diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index ac2003277e..3e3fd53a56 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -1129,22 +1129,18 @@ public ItemType findCommonSuperType(ItemType other) { } } + /** + * Check at static time if [this] could be casted to [other] item type, requires [this] to be an atomic type + * + * @param other a strict subtype of atomic item type to which we are trying to cast + * @return true if it is possible at static time to cast [this] to [other], false otherwise + */ public boolean staticallyCastableAs(ItemType other) { - // JSON items cannot be cast from and to, nor function items, nor we can cast to atomic or item - if ( - this.isSubtypeOf(JSONItem) - || other.isSubtypeOf(JSONItem) - || this.equals(functionItem) - || other.equals(functionItem) - || other.equals(atomicItem) - || other.equals(item) - ) - return false; // anything can be casted to itself if (this.equals(other)) return true; // anything can be casted from and to a string (or from one of its supertype) - if (this.equals(stringItem) || this.equals(item) || this.equals(atomicItem) || other.equals(stringItem)) + if (this.equals(stringItem) || other.equals(stringItem)) return true; // boolean and numeric can be cast between themselves if ( diff --git a/src/test/resources/test_files/static-typing/typing/cast1.jq b/src/test/resources/test_files/static-typing/typing/cast1.jq index 46c2d6a16e..a1d80cc199 100644 --- a/src/test/resources/test_files/static-typing/typing/cast1.jq +++ b/src/test/resources/test_files/static-typing/typing/cast1.jq @@ -1,2 +1,2 @@ (:JIQS: ShouldRun :) -(3 cast as decimal) is statically decimal, (3 cast as string) is statically string, (12 cast as double) is statically double, (33.23 cast as integer) is statically integer, (3 cast as boolean) is statically boolean, (false cast as integer) is statically integer \ No newline at end of file +(3 cast as decimal) is statically decimal, (3 cast as string) is statically string, ((12 treat as atomic) cast as string) is statically string, (12 cast as double) is statically double, (33.23 cast as integer) is statically integer, (3 cast as boolean) is statically boolean, (false cast as integer) is statically integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/cast4.jq b/src/test/resources/test_files/static-typing/typing/cast4.jq index a88e18ee5f..cbb6d2d298 100644 --- a/src/test/resources/test_files/static-typing/typing/cast4.jq +++ b/src/test/resources/test_files/static-typing/typing/cast4.jq @@ -1,2 +1,2 @@ -(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(:JIQS: ShouldCrash; ErrorCode="FOTY0012" :) (12 treat as item) cast as integer \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/typing/castable3.jq b/src/test/resources/test_files/static-typing/typing/castable3.jq index 8bd726d6ec..e0a63c54b8 100644 --- a/src/test/resources/test_files/static-typing/typing/castable3.jq +++ b/src/test/resources/test_files/static-typing/typing/castable3.jq @@ -1,2 +1,2 @@ -(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +(:JIQS: ShouldCrash; ErrorCode="FOTY0012" :) (3 treat as item) castable as integer \ No newline at end of file From 10e225681d659792d5e5ff962d276c6647832f14 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 1 Dec 2020 07:52:45 +0100 Subject: [PATCH 090/206] small fixes in dynamic function static test, plus spotless and log for using udf in let spark iterator --- .../rumbledb/compiler/InferTypeVisitor.java | 24 ++++++++++--------- .../flwor/clauses/LetClauseSparkIterator.java | 1 + .../static-typing/postfix/dynamicfunc1.jq | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index ea7b569c31..1a1e0b6345 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -378,16 +378,16 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex } // Empty sequence case - if (expressionSequenceType.isEmptySequence()){ - if(castedSequenceType.getArity() != SequenceType.Arity.OneOrZero) { - throw new UnexpectedStaticTypeException( - "Empty sequence cannot be cast to type with quantifier different from '?'" - ); - } else { - // no additional check is needed - expression.setInferredSequenceType(castedSequenceType); - return argument; - } + if (expressionSequenceType.isEmptySequence()) { + if (castedSequenceType.getArity() != SequenceType.Arity.OneOrZero) { + throw new UnexpectedStaticTypeException( + "Empty sequence cannot be cast to type with quantifier different from '?'" + ); + } else { + // no additional check is needed + expression.setInferredSequenceType(castedSequenceType); + return argument; + } } if (!expressionSequenceType.isAritySubtypeOf(castedSequenceType.getArity())) { @@ -406,7 +406,9 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex "It is never possible to cast a non-atomic sequence type: " + expressionSequenceType, - expressionSequenceType.getItemType().isSubtypeOf(ItemType.JSONItem) ? ErrorCode.NonAtomicElementErrorCode : ErrorCode.AtomizationError + expressionSequenceType.getItemType().isSubtypeOf(ItemType.JSONItem) + ? ErrorCode.NonAtomicElementErrorCode + : ErrorCode.AtomizationError ); } if (!expressionSequenceType.getItemType().staticallyCastableAs(castedSequenceType.getItemType())) { diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index 08579d7b8b..1fe832398e 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -550,6 +550,7 @@ public static Dataset bindLetVariableInDataFrame( } // was not possible, we use let udf + System.out.println("using UDF"); List UDFcolumns = FlworDataFrameUtils.getColumnNames( inputSchema, diff --git a/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq b/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq index b55ecc5909..14d9cc4bf5 100644 --- a/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq +++ b/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldRun :) declare function a($b as atomic) { "a" || $b }; declare variable $a := a#1; -$a(12) is statically item*, $a(?) is statically function \ No newline at end of file +$a(12) is statically item*, $a(?) is statically function(*) \ No newline at end of file From ed66c8fcbb341ea732f3c39b0b0af48285173b3f Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 1 Dec 2020 08:49:59 +0100 Subject: [PATCH 091/206] fixed bug in multiplicative expression, duration * numeric not allowed anymore --- .../rumbledb/compiler/InferTypeVisitor.java | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 1a1e0b6345..0b6ea61df9 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -567,20 +567,12 @@ public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); - // if any of the child expression has null inferred type throw error - if (leftInferredType == null || rightInferredType == null) { - throw new UnexpectedStaticTypeException( - "A child expression of a MultiplicativeExpression has no inferred type" - ); - } - - // if any of the children is the empty sequence throw error XPST0005 - if (leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()) { - throw new UnexpectedStaticTypeException( - "Inferred type is empty sequence and this is not a CommaExpression", - ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression - ); - } + basicChecks( + Arrays.asList(leftInferredType, rightInferredType), + expression.getClass().getSimpleName(), + true, + true + ); ItemType inferredType = null; SequenceType.Arity inferredArity = resolveArities(leftInferredType.getArity(), rightInferredType.getArity()); @@ -611,12 +603,13 @@ public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression } } else if ( rightItemType.isSubtypeOf(ItemType.durationItem) + && !rightItemType.equals(ItemType.durationItem) && expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL ) { inferredType = rightItemType; } - } else if (leftItemType.isSubtypeOf(ItemType.durationItem)) { + } else if (leftItemType.isSubtypeOf(ItemType.durationItem) && !leftItemType.equals(ItemType.durationItem)) { if ( rightItemType.isNumeric() && (expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL @@ -624,7 +617,7 @@ public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV) ) { inferredType = leftItemType; - } else if (rightItemType.equals(leftItemType) && !leftItemType.equals(ItemType.durationItem)) { + } else if (rightItemType.equals(leftItemType)) { inferredType = ItemType.decimalItem; } } From 6d6c567e5464c712af1c59716b5e134b1538aa7f Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 1 Dec 2020 09:53:13 +0100 Subject: [PATCH 092/206] added function test to the grammar --- src/main/java/org/rumbledb/parser/Jsoniq.g4 | 9 +- .../rumbledb/parser/JsoniqBaseVisitor.java | 21 + .../org/rumbledb/parser/JsoniqParser.java | 2067 +++++++++-------- .../org/rumbledb/parser/JsoniqVisitor.java | 18 + 4 files changed, 1179 insertions(+), 936 deletions(-) diff --git a/src/main/java/org/rumbledb/parser/Jsoniq.g4 b/src/main/java/org/rumbledb/parser/Jsoniq.g4 index d59983548d..9e8d49f923 100644 --- a/src/main/java/org/rumbledb/parser/Jsoniq.g4 +++ b/src/main/java/org/rumbledb/parser/Jsoniq.g4 @@ -225,7 +225,14 @@ objectConstructor : '{' ( pairConstructor (',' pairConstructor)* )? '}' itemType : 'item' | jSONItemTest - | atomicType; + | atomicType + | functionTest; + +functionTest : (anyFunctionTest | typedFunctionTest); + +anyFunctionTest : 'function' '(' '*' ')'; + +typedFunctionTest : 'function' '(' (st+=sequenceType (',' st+=sequenceType)*)? ')' 'as' rt=sequenceType; jSONItemTest : 'object' | 'array' diff --git a/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java b/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java index 4db90da4f8..7bb328ce6c 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java +++ b/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java @@ -553,6 +553,27 @@ public class JsoniqBaseVisitor extends AbstractParseTreeVisitor implements * {@link #visitChildren} on {@code ctx}.

*/ @Override public T visitItemType(JsoniqParser.ItemTypeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFunctionTest(JsoniqParser.FunctionTestContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAnyFunctionTest(JsoniqParser.AnyFunctionTestContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTypedFunctionTest(JsoniqParser.TypedFunctionTestContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * diff --git a/src/main/java/org/rumbledb/parser/JsoniqParser.java b/src/main/java/org/rumbledb/parser/JsoniqParser.java index 81345d7177..8de08371df 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqParser.java +++ b/src/main/java/org/rumbledb/parser/JsoniqParser.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Iterator; import org.antlr.v4.runtime.NoViableAltException; import org.antlr.v4.runtime.Parser; @@ -74,15 +75,16 @@ public class JsoniqParser extends Parser { RULE_contextItemExpr = 65, RULE_orderedExpr = 66, RULE_unorderedExpr = 67, RULE_functionCall = 68, RULE_argumentList = 69, RULE_argument = 70, RULE_functionItemExpr = 71, RULE_namedFunctionRef = 72, RULE_inlineFunctionExpr = 73, RULE_sequenceType = 74, - RULE_objectConstructor = 75, RULE_itemType = 76, RULE_jSONItemTest = 77, - RULE_keyWordString = 78, RULE_keyWordInteger = 79, RULE_keyWordDecimal = 80, - RULE_keyWordDouble = 81, RULE_keyWordBoolean = 82, RULE_keyWordDuration = 83, - RULE_keyWordYearMonthDuration = 84, RULE_keyWordDayTimeDuration = 85, - RULE_keyWordHexBinary = 86, RULE_keyWordBase64Binary = 87, RULE_keyWordDateTime = 88, - RULE_keyWordDate = 89, RULE_keyWordTime = 90, RULE_keyWordAnyURI = 91, - RULE_typesKeywords = 92, RULE_singleType = 93, RULE_atomicType = 94, RULE_nCNameOrKeyWord = 95, - RULE_pairConstructor = 96, RULE_arrayConstructor = 97, RULE_uriLiteral = 98, - RULE_stringLiteral = 99, RULE_keyWords = 100; + RULE_objectConstructor = 75, RULE_itemType = 76, RULE_functionTest = 77, + RULE_anyFunctionTest = 78, RULE_typedFunctionTest = 79, RULE_jSONItemTest = 80, + RULE_keyWordString = 81, RULE_keyWordInteger = 82, RULE_keyWordDecimal = 83, + RULE_keyWordDouble = 84, RULE_keyWordBoolean = 85, RULE_keyWordDuration = 86, + RULE_keyWordYearMonthDuration = 87, RULE_keyWordDayTimeDuration = 88, + RULE_keyWordHexBinary = 89, RULE_keyWordBase64Binary = 90, RULE_keyWordDateTime = 91, + RULE_keyWordDate = 92, RULE_keyWordTime = 93, RULE_keyWordAnyURI = 94, + RULE_typesKeywords = 95, RULE_singleType = 96, RULE_atomicType = 97, RULE_nCNameOrKeyWord = 98, + RULE_pairConstructor = 99, RULE_arrayConstructor = 100, RULE_uriLiteral = 101, + RULE_stringLiteral = 102, RULE_keyWords = 103; public static final String[] ruleNames = { "moduleAndThisIsIt", "module", "mainModule", "libraryModule", "prolog", "setter", "namespaceDecl", "annotatedDecl", "defaultCollationDecl", "orderingModeDecl", @@ -99,12 +101,13 @@ public class JsoniqParser extends Parser { "primaryExpr", "varRef", "parenthesizedExpr", "contextItemExpr", "orderedExpr", "unorderedExpr", "functionCall", "argumentList", "argument", "functionItemExpr", "namedFunctionRef", "inlineFunctionExpr", "sequenceType", "objectConstructor", - "itemType", "jSONItemTest", "keyWordString", "keyWordInteger", "keyWordDecimal", - "keyWordDouble", "keyWordBoolean", "keyWordDuration", "keyWordYearMonthDuration", - "keyWordDayTimeDuration", "keyWordHexBinary", "keyWordBase64Binary", "keyWordDateTime", - "keyWordDate", "keyWordTime", "keyWordAnyURI", "typesKeywords", "singleType", - "atomicType", "nCNameOrKeyWord", "pairConstructor", "arrayConstructor", - "uriLiteral", "stringLiteral", "keyWords" + "itemType", "functionTest", "anyFunctionTest", "typedFunctionTest", "jSONItemTest", + "keyWordString", "keyWordInteger", "keyWordDecimal", "keyWordDouble", + "keyWordBoolean", "keyWordDuration", "keyWordYearMonthDuration", "keyWordDayTimeDuration", + "keyWordHexBinary", "keyWordBase64Binary", "keyWordDateTime", "keyWordDate", + "keyWordTime", "keyWordAnyURI", "typesKeywords", "singleType", "atomicType", + "nCNameOrKeyWord", "pairConstructor", "arrayConstructor", "uriLiteral", + "stringLiteral", "keyWords" }; private static final String[] _LITERAL_NAMES = { @@ -216,9 +219,9 @@ public final ModuleAndThisIsItContext moduleAndThisIsIt() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(202); + setState(208); module(); - setState(203); + setState(209); match(EOF); } } @@ -264,28 +267,28 @@ public final ModuleContext module() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(210); + setState(216); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,0,_ctx) ) { case 1: { - setState(205); + setState(211); match(Kjsoniq); - setState(206); + setState(212); match(Kversion); - setState(207); + setState(213); ((ModuleContext)_localctx).vers = stringLiteral(); - setState(208); + setState(214); match(T__0); } break; } - setState(214); + setState(220); _errHandler.sync(this); switch (_input.LA(1)) { case T__1: { - setState(212); + setState(218); libraryModule(); } break; @@ -366,7 +369,7 @@ public final ModuleContext module() throws RecognitionException { case Literal: case NCName: { - setState(213); + setState(219); ((ModuleContext)_localctx).main = mainModule(); } break; @@ -410,9 +413,9 @@ public final MainModuleContext mainModule() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(216); + setState(222); prolog(); - setState(217); + setState(223); expr(); } } @@ -452,19 +455,19 @@ public final LibraryModuleContext libraryModule() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(219); + setState(225); match(T__1); - setState(220); + setState(226); match(T__2); - setState(221); + setState(227); match(NCName); - setState(222); + setState(228); match(T__3); - setState(223); + setState(229); uriLiteral(); - setState(224); + setState(230); match(T__0); - setState(225); + setState(231); prolog(); } } @@ -523,57 +526,57 @@ public final PrologContext prolog() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(236); + setState(242); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,3,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(230); + setState(236); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) { case 1: { - setState(227); + setState(233); setter(); } break; case 2: { - setState(228); + setState(234); namespaceDecl(); } break; case 3: { - setState(229); + setState(235); moduleImport(); } break; } - setState(232); + setState(238); match(T__0); } } } - setState(238); + setState(244); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,3,_ctx); } - setState(244); + setState(250); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__4) { { { - setState(239); + setState(245); annotatedDecl(); - setState(240); + setState(246); match(T__0); } } - setState(246); + setState(252); _errHandler.sync(this); _la = _input.LA(1); } @@ -618,34 +621,34 @@ public final SetterContext setter() throws RecognitionException { SetterContext _localctx = new SetterContext(_ctx, getState()); enterRule(_localctx, 10, RULE_setter); try { - setState(251); + setState(257); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,5,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(247); + setState(253); defaultCollationDecl(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(248); + setState(254); orderingModeDecl(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(249); + setState(255); emptyOrderDecl(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(250); + setState(256); decimalFormatDecl(); } break; @@ -684,15 +687,15 @@ public final NamespaceDeclContext namespaceDecl() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(253); + setState(259); match(T__4); - setState(254); + setState(260); match(T__2); - setState(255); + setState(261); match(NCName); - setState(256); + setState(262); match(T__3); - setState(257); + setState(263); uriLiteral(); } } @@ -729,20 +732,20 @@ public final AnnotatedDeclContext annotatedDecl() throws RecognitionException { AnnotatedDeclContext _localctx = new AnnotatedDeclContext(_ctx, getState()); enterRule(_localctx, 14, RULE_annotatedDecl); try { - setState(261); + setState(267); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(259); + setState(265); functionDecl(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(260); + setState(266); varDecl(); } break; @@ -782,13 +785,13 @@ public final DefaultCollationDeclContext defaultCollationDecl() throws Recogniti try { enterOuterAlt(_localctx, 1); { - setState(263); + setState(269); match(T__4); - setState(264); + setState(270); match(Kdefault); - setState(265); + setState(271); match(Kcollation); - setState(266); + setState(272); uriLiteral(); } } @@ -822,11 +825,11 @@ public final OrderingModeDeclContext orderingModeDecl() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(268); + setState(274); match(T__4); - setState(269); + setState(275); match(T__5); - setState(270); + setState(276); _la = _input.LA(1); if ( !(_la==T__6 || _la==T__7) ) { _errHandler.recoverInline(this); @@ -873,16 +876,16 @@ public final EmptyOrderDeclContext emptyOrderDecl() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(272); + setState(278); match(T__4); - setState(273); + setState(279); match(Kdefault); - setState(274); + setState(280); match(Korder); - setState(275); + setState(281); match(Kempty); { - setState(276); + setState(282); ((EmptyOrderDeclContext)_localctx).emptySequenceOrder = _input.LT(1); _la = _input.LA(1); if ( !(_la==Kgreatest || _la==Kleast) ) { @@ -942,17 +945,17 @@ public final DecimalFormatDeclContext decimalFormatDecl() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(278); + setState(284); match(T__4); - setState(283); + setState(289); _errHandler.sync(this); switch (_input.LA(1)) { case T__8: { { - setState(279); + setState(285); match(T__8); - setState(280); + setState(286); qname(); } } @@ -960,9 +963,9 @@ public final DecimalFormatDeclContext decimalFormatDecl() throws RecognitionExce case Kdefault: { { - setState(281); + setState(287); match(Kdefault); - setState(282); + setState(288); match(T__8); } } @@ -970,21 +973,21 @@ public final DecimalFormatDeclContext decimalFormatDecl() throws RecognitionExce default: throw new NoViableAltException(this); } - setState(291); + setState(297); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__14) | (1L << T__15) | (1L << T__16) | (1L << T__17) | (1L << T__18) | (1L << T__19))) != 0)) { { { - setState(285); + setState(291); dfPropertyName(); - setState(286); + setState(292); match(T__3); - setState(287); + setState(293); stringLiteral(); } } - setState(293); + setState(299); _errHandler.sync(this); _la = _input.LA(1); } @@ -1033,17 +1036,17 @@ public final QnameContext qname() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(299); + setState(305); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,10,_ctx) ) { case 1: { - setState(296); + setState(302); _errHandler.sync(this); switch (_input.LA(1)) { case NCName: { - setState(294); + setState(300); ((QnameContext)_localctx).ns = match(NCName); } break; @@ -1093,19 +1096,19 @@ public final QnameContext qname() throws RecognitionException { case Kjsoniq: case Kjson: { - setState(295); + setState(301); ((QnameContext)_localctx).nskw = keyWords(); } break; default: throw new NoViableAltException(this); } - setState(298); + setState(304); match(T__9); } break; } - setState(303); + setState(309); _errHandler.sync(this); switch (_input.LA(1)) { case T__61: @@ -1124,7 +1127,7 @@ public final QnameContext qname() throws RecognitionException { case T__74: case NCName: { - setState(301); + setState(307); ((QnameContext)_localctx).local_name = nCNameOrKeyWord(); } break; @@ -1174,7 +1177,7 @@ public final QnameContext qname() throws RecognitionException { case Kjsoniq: case Kjson: { - setState(302); + setState(308); ((QnameContext)_localctx).local_namekw = keyWords(); } break; @@ -1213,7 +1216,7 @@ public final DfPropertyNameContext dfPropertyName() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(305); + setState(311); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__14) | (1L << T__15) | (1L << T__16) | (1L << T__17) | (1L << T__18) | (1L << T__19))) != 0)) ) { _errHandler.recoverInline(this); @@ -1265,48 +1268,48 @@ public final ModuleImportContext moduleImport() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(307); + setState(313); match(T__20); - setState(308); + setState(314); match(T__1); - setState(312); + setState(318); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__2) { { - setState(309); + setState(315); match(T__2); - setState(310); + setState(316); ((ModuleImportContext)_localctx).prefix = match(NCName); - setState(311); + setState(317); match(T__3); } } - setState(314); + setState(320); ((ModuleImportContext)_localctx).targetNamespace = uriLiteral(); - setState(324); + setState(330); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kat) { { - setState(315); + setState(321); match(Kat); - setState(316); + setState(322); uriLiteral(); - setState(321); + setState(327); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(317); + setState(323); match(T__21); - setState(318); + setState(324); uriLiteral(); } } - setState(323); + setState(329); _errHandler.sync(this); _la = _input.LA(1); } @@ -1356,33 +1359,33 @@ public final VarDeclContext varDecl() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(326); + setState(332); match(T__4); - setState(327); + setState(333); match(T__22); - setState(328); + setState(334); varRef(); - setState(331); + setState(337); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(329); + setState(335); match(Kas); - setState(330); + setState(336); sequenceType(); } } - setState(340); + setState(346); _errHandler.sync(this); switch (_input.LA(1)) { case T__23: { { - setState(333); + setState(339); match(T__23); - setState(334); + setState(340); exprSingle(); } } @@ -1390,16 +1393,16 @@ public final VarDeclContext varDecl() throws RecognitionException { case T__24: { { - setState(335); + setState(341); ((VarDeclContext)_localctx).external = match(T__24); - setState(338); + setState(344); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__23) { { - setState(336); + setState(342); match(T__23); - setState(337); + setState(343); exprSingle(); } } @@ -1458,54 +1461,54 @@ public final FunctionDeclContext functionDecl() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(342); + setState(348); match(T__4); - setState(343); + setState(349); match(T__25); - setState(344); + setState(350); ((FunctionDeclContext)_localctx).fn_name = qname(); - setState(345); + setState(351); match(T__26); - setState(347); + setState(353); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(346); + setState(352); paramList(); } } - setState(349); + setState(355); match(T__27); - setState(352); + setState(358); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(350); + setState(356); match(Kas); - setState(351); + setState(357); ((FunctionDeclContext)_localctx).return_type = sequenceType(); } } - setState(359); + setState(365); _errHandler.sync(this); switch (_input.LA(1)) { case T__28: { - setState(354); + setState(360); match(T__28); - setState(355); + setState(361); ((FunctionDeclContext)_localctx).fn_body = expr(); - setState(356); + setState(362); match(T__29); } break; case T__24: { - setState(358); + setState(364); match(T__24); } break; @@ -1550,21 +1553,21 @@ public final ParamListContext paramList() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(361); + setState(367); param(); - setState(366); + setState(372); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(362); + setState(368); match(T__21); - setState(363); + setState(369); param(); } } - setState(368); + setState(374); _errHandler.sync(this); _la = _input.LA(1); } @@ -1607,18 +1610,18 @@ public final ParamContext param() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(369); + setState(375); match(T__30); - setState(370); + setState(376); qname(); - setState(373); + setState(379); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(371); + setState(377); match(Kas); - setState(372); + setState(378); sequenceType(); } } @@ -1661,21 +1664,21 @@ public final ExprContext expr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(375); + setState(381); exprSingle(); - setState(380); + setState(386); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(376); + setState(382); match(T__21); - setState(377); + setState(383); exprSingle(); } } - setState(382); + setState(388); _errHandler.sync(this); _la = _input.LA(1); } @@ -1729,55 +1732,55 @@ public final ExprSingleContext exprSingle() throws RecognitionException { ExprSingleContext _localctx = new ExprSingleContext(_ctx, getState()); enterRule(_localctx, 40, RULE_exprSingle); try { - setState(390); + setState(396); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,24,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(383); + setState(389); flowrExpr(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(384); + setState(390); quantifiedExpr(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(385); + setState(391); switchExpr(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(386); + setState(392); typeSwitchExpr(); } break; case 5: enterOuterAlt(_localctx, 5); { - setState(387); + setState(393); ifExpr(); } break; case 6: enterOuterAlt(_localctx, 6); { - setState(388); + setState(394); tryCatchExpr(); } break; case 7: enterOuterAlt(_localctx, 7); { - setState(389); + setState(395); orExpr(); } break; @@ -1856,66 +1859,66 @@ public final FlowrExprContext flowrExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(394); + setState(400); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: { - setState(392); + setState(398); ((FlowrExprContext)_localctx).start_for = forClause(); } break; case Klet: { - setState(393); + setState(399); ((FlowrExprContext)_localctx).start_let = letClause(); } break; default: throw new NoViableAltException(this); } - setState(404); + setState(410); _errHandler.sync(this); _la = _input.LA(1); while (((((_la - 77)) & ~0x3f) == 0 && ((1L << (_la - 77)) & ((1L << (Kfor - 77)) | (1L << (Klet - 77)) | (1L << (Kwhere - 77)) | (1L << (Kgroup - 77)) | (1L << (Korder - 77)) | (1L << (Kcount - 77)) | (1L << (Kstable - 77)))) != 0)) { { - setState(402); + setState(408); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: { - setState(396); + setState(402); forClause(); } break; case Kwhere: { - setState(397); + setState(403); whereClause(); } break; case Klet: { - setState(398); + setState(404); letClause(); } break; case Kgroup: { - setState(399); + setState(405); groupByClause(); } break; case Korder: case Kstable: { - setState(400); + setState(406); orderByClause(); } break; case Kcount: { - setState(401); + setState(407); countClause(); } break; @@ -1923,13 +1926,13 @@ public final FlowrExprContext flowrExpr() throws RecognitionException { throw new NoViableAltException(this); } } - setState(406); + setState(412); _errHandler.sync(this); _la = _input.LA(1); } - setState(407); + setState(413); match(Kreturn); - setState(408); + setState(414); ((FlowrExprContext)_localctx).return_expr = exprSingle(); } } @@ -1972,25 +1975,25 @@ public final ForClauseContext forClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(410); + setState(416); match(Kfor); - setState(411); + setState(417); ((ForClauseContext)_localctx).forVar = forVar(); ((ForClauseContext)_localctx).vars.add(((ForClauseContext)_localctx).forVar); - setState(416); + setState(422); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(412); + setState(418); match(T__21); - setState(413); + setState(419); ((ForClauseContext)_localctx).forVar = forVar(); ((ForClauseContext)_localctx).vars.add(((ForClauseContext)_localctx).forVar); } } - setState(418); + setState(424); _errHandler.sync(this); _la = _input.LA(1); } @@ -2048,47 +2051,47 @@ public final ForVarContext forVar() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(419); + setState(425); ((ForVarContext)_localctx).var_ref = varRef(); - setState(422); + setState(428); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(420); + setState(426); match(Kas); - setState(421); + setState(427); ((ForVarContext)_localctx).seq = sequenceType(); } } - setState(426); + setState(432); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kallowing) { { - setState(424); + setState(430); ((ForVarContext)_localctx).flag = match(Kallowing); - setState(425); + setState(431); match(Kempty); } } - setState(430); + setState(436); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kat) { { - setState(428); + setState(434); match(Kat); - setState(429); + setState(435); ((ForVarContext)_localctx).at = varRef(); } } - setState(432); + setState(438); match(Kin); - setState(433); + setState(439); ((ForVarContext)_localctx).ex = exprSingle(); } } @@ -2131,25 +2134,25 @@ public final LetClauseContext letClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(435); + setState(441); match(Klet); - setState(436); + setState(442); ((LetClauseContext)_localctx).letVar = letVar(); ((LetClauseContext)_localctx).vars.add(((LetClauseContext)_localctx).letVar); - setState(441); + setState(447); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(437); + setState(443); match(T__21); - setState(438); + setState(444); ((LetClauseContext)_localctx).letVar = letVar(); ((LetClauseContext)_localctx).vars.add(((LetClauseContext)_localctx).letVar); } } - setState(443); + setState(449); _errHandler.sync(this); _la = _input.LA(1); } @@ -2198,23 +2201,23 @@ public final LetVarContext letVar() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(444); + setState(450); ((LetVarContext)_localctx).var_ref = varRef(); - setState(447); + setState(453); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(445); + setState(451); match(Kas); - setState(446); + setState(452); ((LetVarContext)_localctx).seq = sequenceType(); } } - setState(449); + setState(455); match(T__23); - setState(450); + setState(456); ((LetVarContext)_localctx).ex = exprSingle(); } } @@ -2251,9 +2254,9 @@ public final WhereClauseContext whereClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(452); + setState(458); match(Kwhere); - setState(453); + setState(459); exprSingle(); } } @@ -2297,27 +2300,27 @@ public final GroupByClauseContext groupByClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(455); + setState(461); match(Kgroup); - setState(456); + setState(462); match(Kby); - setState(457); + setState(463); ((GroupByClauseContext)_localctx).groupByVar = groupByVar(); ((GroupByClauseContext)_localctx).vars.add(((GroupByClauseContext)_localctx).groupByVar); - setState(462); + setState(468); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(458); + setState(464); match(T__21); - setState(459); + setState(465); ((GroupByClauseContext)_localctx).groupByVar = groupByVar(); ((GroupByClauseContext)_localctx).vars.add(((GroupByClauseContext)_localctx).groupByVar); } } - setState(464); + setState(470); _errHandler.sync(this); _la = _input.LA(1); } @@ -2372,40 +2375,40 @@ public final GroupByVarContext groupByVar() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(465); + setState(471); ((GroupByVarContext)_localctx).var_ref = varRef(); - setState(472); + setState(478); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__23 || _la==Kas) { { - setState(468); + setState(474); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(466); + setState(472); match(Kas); - setState(467); + setState(473); ((GroupByVarContext)_localctx).seq = sequenceType(); } } - setState(470); + setState(476); ((GroupByVarContext)_localctx).decl = match(T__23); - setState(471); + setState(477); ((GroupByVarContext)_localctx).ex = exprSingle(); } } - setState(476); + setState(482); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kcollation) { { - setState(474); + setState(480); match(Kcollation); - setState(475); + setState(481); ((GroupByVarContext)_localctx).uri = uriLiteral(); } } @@ -2452,15 +2455,15 @@ public final OrderByClauseContext orderByClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(483); + setState(489); _errHandler.sync(this); switch (_input.LA(1)) { case Korder: { { - setState(478); + setState(484); match(Korder); - setState(479); + setState(485); match(Kby); } } @@ -2468,11 +2471,11 @@ public final OrderByClauseContext orderByClause() throws RecognitionException { case Kstable: { { - setState(480); + setState(486); ((OrderByClauseContext)_localctx).stb = match(Kstable); - setState(481); + setState(487); match(Korder); - setState(482); + setState(488); match(Kby); } } @@ -2480,21 +2483,21 @@ public final OrderByClauseContext orderByClause() throws RecognitionException { default: throw new NoViableAltException(this); } - setState(485); + setState(491); orderByExpr(); - setState(490); + setState(496); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(486); + setState(492); match(T__21); - setState(487); + setState(493); orderByExpr(); } } - setState(492); + setState(498); _errHandler.sync(this); _la = _input.LA(1); } @@ -2547,20 +2550,20 @@ public final OrderByExprContext orderByExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(493); + setState(499); ((OrderByExprContext)_localctx).ex = exprSingle(); - setState(496); + setState(502); _errHandler.sync(this); switch (_input.LA(1)) { case Kascending: { - setState(494); + setState(500); match(Kascending); } break; case Kdescending: { - setState(495); + setState(501); ((OrderByExprContext)_localctx).desc = match(Kdescending); } break; @@ -2579,25 +2582,25 @@ public final OrderByExprContext orderByExpr() throws RecognitionException { default: break; } - setState(503); + setState(509); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kempty) { { - setState(498); + setState(504); match(Kempty); - setState(501); + setState(507); _errHandler.sync(this); switch (_input.LA(1)) { case Kgreatest: { - setState(499); + setState(505); ((OrderByExprContext)_localctx).gr = match(Kgreatest); } break; case Kleast: { - setState(500); + setState(506); ((OrderByExprContext)_localctx).ls = match(Kleast); } break; @@ -2607,14 +2610,14 @@ public final OrderByExprContext orderByExpr() throws RecognitionException { } } - setState(507); + setState(513); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kcollation) { { - setState(505); + setState(511); match(Kcollation); - setState(506); + setState(512); ((OrderByExprContext)_localctx).uril = uriLiteral(); } } @@ -2654,9 +2657,9 @@ public final CountClauseContext countClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(509); + setState(515); match(Kcount); - setState(510); + setState(516); varRef(); } } @@ -2706,47 +2709,47 @@ public final QuantifiedExprContext quantifiedExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(514); + setState(520); _errHandler.sync(this); switch (_input.LA(1)) { case Ksome: { - setState(512); + setState(518); ((QuantifiedExprContext)_localctx).so = match(Ksome); } break; case Kevery: { - setState(513); + setState(519); ((QuantifiedExprContext)_localctx).ev = match(Kevery); } break; default: throw new NoViableAltException(this); } - setState(516); + setState(522); ((QuantifiedExprContext)_localctx).quantifiedExprVar = quantifiedExprVar(); ((QuantifiedExprContext)_localctx).vars.add(((QuantifiedExprContext)_localctx).quantifiedExprVar); - setState(521); + setState(527); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(517); + setState(523); match(T__21); - setState(518); + setState(524); ((QuantifiedExprContext)_localctx).quantifiedExprVar = quantifiedExprVar(); ((QuantifiedExprContext)_localctx).vars.add(((QuantifiedExprContext)_localctx).quantifiedExprVar); } } - setState(523); + setState(529); _errHandler.sync(this); _la = _input.LA(1); } - setState(524); + setState(530); match(Ksatisfies); - setState(525); + setState(531); exprSingle(); } } @@ -2791,23 +2794,23 @@ public final QuantifiedExprVarContext quantifiedExprVar() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(527); + setState(533); varRef(); - setState(530); + setState(536); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(528); + setState(534); match(Kas); - setState(529); + setState(535); sequenceType(); } } - setState(532); + setState(538); match(Kin); - setState(533); + setState(539); exprSingle(); } } @@ -2860,34 +2863,34 @@ public final SwitchExprContext switchExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(535); + setState(541); match(Kswitch); - setState(536); + setState(542); match(T__26); - setState(537); + setState(543); ((SwitchExprContext)_localctx).cond = expr(); - setState(538); + setState(544); match(T__27); - setState(540); + setState(546); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(539); + setState(545); ((SwitchExprContext)_localctx).switchCaseClause = switchCaseClause(); ((SwitchExprContext)_localctx).cases.add(((SwitchExprContext)_localctx).switchCaseClause); } } - setState(542); + setState(548); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Kcase ); - setState(544); + setState(550); match(Kdefault); - setState(545); + setState(551); match(Kreturn); - setState(546); + setState(552); ((SwitchExprContext)_localctx).def = exprSingle(); } } @@ -2935,26 +2938,26 @@ public final SwitchCaseClauseContext switchCaseClause() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(550); + setState(556); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(548); + setState(554); match(Kcase); - setState(549); + setState(555); ((SwitchCaseClauseContext)_localctx).exprSingle = exprSingle(); ((SwitchCaseClauseContext)_localctx).cond.add(((SwitchCaseClauseContext)_localctx).exprSingle); } } - setState(552); + setState(558); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Kcase ); - setState(554); + setState(560); match(Kreturn); - setState(555); + setState(561); ((SwitchCaseClauseContext)_localctx).ret = exprSingle(); } } @@ -3011,44 +3014,44 @@ public final TypeSwitchExprContext typeSwitchExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(557); + setState(563); match(Ktypeswitch); - setState(558); + setState(564); match(T__26); - setState(559); + setState(565); ((TypeSwitchExprContext)_localctx).cond = expr(); - setState(560); + setState(566); match(T__27); - setState(562); + setState(568); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(561); + setState(567); ((TypeSwitchExprContext)_localctx).caseClause = caseClause(); ((TypeSwitchExprContext)_localctx).cses.add(((TypeSwitchExprContext)_localctx).caseClause); } } - setState(564); + setState(570); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Kcase ); - setState(566); + setState(572); match(Kdefault); - setState(568); + setState(574); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(567); + setState(573); ((TypeSwitchExprContext)_localctx).var_ref = varRef(); } } - setState(570); + setState(576); match(Kreturn); - setState(571); + setState(577); ((TypeSwitchExprContext)_localctx).def = exprSingle(); } } @@ -3101,43 +3104,43 @@ public final CaseClauseContext caseClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(573); + setState(579); match(Kcase); - setState(577); + setState(583); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(574); + setState(580); ((CaseClauseContext)_localctx).var_ref = varRef(); - setState(575); + setState(581); match(Kas); } } - setState(579); + setState(585); ((CaseClauseContext)_localctx).sequenceType = sequenceType(); ((CaseClauseContext)_localctx).union.add(((CaseClauseContext)_localctx).sequenceType); - setState(584); + setState(590); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__31) { { { - setState(580); + setState(586); match(T__31); - setState(581); + setState(587); ((CaseClauseContext)_localctx).sequenceType = sequenceType(); ((CaseClauseContext)_localctx).union.add(((CaseClauseContext)_localctx).sequenceType); } } - setState(586); + setState(592); _errHandler.sync(this); _la = _input.LA(1); } - setState(587); + setState(593); match(Kreturn); - setState(588); + setState(594); ((CaseClauseContext)_localctx).ret = exprSingle(); } } @@ -3185,21 +3188,21 @@ public final IfExprContext ifExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(590); + setState(596); match(Kif); - setState(591); + setState(597); match(T__26); - setState(592); + setState(598); ((IfExprContext)_localctx).test_condition = expr(); - setState(593); + setState(599); match(T__27); - setState(594); + setState(600); match(Kthen); - setState(595); + setState(601); ((IfExprContext)_localctx).branch = exprSingle(); - setState(596); + setState(602); match(Kelse); - setState(597); + setState(603); ((IfExprContext)_localctx).else_branch = exprSingle(); } } @@ -3246,15 +3249,15 @@ public final TryCatchExprContext tryCatchExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(599); + setState(605); match(Ktry); - setState(600); + setState(606); match(T__28); - setState(601); + setState(607); ((TryCatchExprContext)_localctx).try_expression = expr(); - setState(602); + setState(608); match(T__29); - setState(604); + setState(610); _errHandler.sync(this); _alt = 1; do { @@ -3262,7 +3265,7 @@ public final TryCatchExprContext tryCatchExpr() throws RecognitionException { case 1: { { - setState(603); + setState(609); ((TryCatchExprContext)_localctx).catchClause = catchClause(); ((TryCatchExprContext)_localctx).catches.add(((TryCatchExprContext)_localctx).catchClause); } @@ -3271,7 +3274,7 @@ public final TryCatchExprContext tryCatchExpr() throws RecognitionException { default: throw new NoViableAltException(this); } - setState(606); + setState(612); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,53,_ctx); } while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); @@ -3322,14 +3325,14 @@ public final CatchClauseContext catchClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(608); + setState(614); match(Kcatch); - setState(611); + setState(617); _errHandler.sync(this); switch (_input.LA(1)) { case T__32: { - setState(609); + setState(615); ((CatchClauseContext)_localctx).s33 = match(T__32); ((CatchClauseContext)_localctx).jokers.add(((CatchClauseContext)_localctx).s33); } @@ -3395,7 +3398,7 @@ public final CatchClauseContext catchClause() throws RecognitionException { case Kjson: case NCName: { - setState(610); + setState(616); ((CatchClauseContext)_localctx).qname = qname(); ((CatchClauseContext)_localctx).errors.add(((CatchClauseContext)_localctx).qname); } @@ -3403,20 +3406,20 @@ public final CatchClauseContext catchClause() throws RecognitionException { default: throw new NoViableAltException(this); } - setState(620); + setState(626); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__31) { { { - setState(613); + setState(619); match(T__31); - setState(616); + setState(622); _errHandler.sync(this); switch (_input.LA(1)) { case T__32: { - setState(614); + setState(620); ((CatchClauseContext)_localctx).s33 = match(T__32); ((CatchClauseContext)_localctx).jokers.add(((CatchClauseContext)_localctx).s33); } @@ -3482,7 +3485,7 @@ public final CatchClauseContext catchClause() throws RecognitionException { case Kjson: case NCName: { - setState(615); + setState(621); ((CatchClauseContext)_localctx).qname = qname(); ((CatchClauseContext)_localctx).errors.add(((CatchClauseContext)_localctx).qname); } @@ -3492,15 +3495,15 @@ public final CatchClauseContext catchClause() throws RecognitionException { } } } - setState(622); + setState(628); _errHandler.sync(this); _la = _input.LA(1); } - setState(623); + setState(629); match(T__28); - setState(624); + setState(630); ((CatchClauseContext)_localctx).catch_expression = expr(); - setState(625); + setState(631); match(T__29); } } @@ -3547,24 +3550,24 @@ public final OrExprContext orExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(627); + setState(633); ((OrExprContext)_localctx).main_expr = andExpr(); - setState(632); + setState(638); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,57,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(628); + setState(634); match(Kor); - setState(629); + setState(635); ((OrExprContext)_localctx).andExpr = andExpr(); ((OrExprContext)_localctx).rhs.add(((OrExprContext)_localctx).andExpr); } } } - setState(634); + setState(640); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,57,_ctx); } @@ -3613,24 +3616,24 @@ public final AndExprContext andExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(635); + setState(641); ((AndExprContext)_localctx).main_expr = notExpr(); - setState(640); + setState(646); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,58,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(636); + setState(642); match(Kand); - setState(637); + setState(643); ((AndExprContext)_localctx).notExpr = notExpr(); ((AndExprContext)_localctx).rhs.add(((AndExprContext)_localctx).notExpr); } } } - setState(642); + setState(648); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,58,_ctx); } @@ -3672,18 +3675,18 @@ public final NotExprContext notExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(644); + setState(650); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,59,_ctx) ) { case 1: { - setState(643); + setState(649); ((NotExprContext)_localctx).Knot = match(Knot); ((NotExprContext)_localctx).op.add(((NotExprContext)_localctx).Knot); } break; } - setState(646); + setState(652); ((NotExprContext)_localctx).main_expr = comparisonExpr(); } } @@ -3740,14 +3743,14 @@ public final ComparisonExprContext comparisonExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(648); + setState(654); ((ComparisonExprContext)_localctx).main_expr = stringConcatExpr(); - setState(651); + setState(657); _errHandler.sync(this); _la = _input.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40) | (1L << T__41) | (1L << T__42) | (1L << T__43))) != 0)) { { - setState(649); + setState(655); ((ComparisonExprContext)_localctx)._tset1157 = _input.LT(1); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40) | (1L << T__41) | (1L << T__42) | (1L << T__43))) != 0)) ) { @@ -3759,7 +3762,7 @@ public final ComparisonExprContext comparisonExpr() throws RecognitionException consume(); } ((ComparisonExprContext)_localctx).op.add(((ComparisonExprContext)_localctx)._tset1157); - setState(650); + setState(656); ((ComparisonExprContext)_localctx).stringConcatExpr = stringConcatExpr(); ((ComparisonExprContext)_localctx).rhs.add(((ComparisonExprContext)_localctx).stringConcatExpr); } @@ -3806,22 +3809,22 @@ public final StringConcatExprContext stringConcatExpr() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(653); + setState(659); ((StringConcatExprContext)_localctx).main_expr = rangeExpr(); - setState(658); + setState(664); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__44) { { { - setState(654); + setState(660); match(T__44); - setState(655); + setState(661); ((StringConcatExprContext)_localctx).rangeExpr = rangeExpr(); ((StringConcatExprContext)_localctx).rhs.add(((StringConcatExprContext)_localctx).rangeExpr); } } - setState(660); + setState(666); _errHandler.sync(this); _la = _input.LA(1); } @@ -3866,16 +3869,16 @@ public final RangeExprContext rangeExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(661); + setState(667); ((RangeExprContext)_localctx).main_expr = additiveExpr(); - setState(664); + setState(670); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,62,_ctx) ) { case 1: { - setState(662); + setState(668); match(Kto); - setState(663); + setState(669); ((RangeExprContext)_localctx).additiveExpr = additiveExpr(); ((RangeExprContext)_localctx).rhs.add(((RangeExprContext)_localctx).additiveExpr); } @@ -3927,16 +3930,16 @@ public final AdditiveExprContext additiveExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(666); + setState(672); ((AdditiveExprContext)_localctx).main_expr = multiplicativeExpr(); - setState(671); + setState(677); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,63,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(667); + setState(673); ((AdditiveExprContext)_localctx)._tset1266 = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__45 || _la==T__46) ) { @@ -3948,13 +3951,13 @@ public final AdditiveExprContext additiveExpr() throws RecognitionException { consume(); } ((AdditiveExprContext)_localctx).op.add(((AdditiveExprContext)_localctx)._tset1266); - setState(668); + setState(674); ((AdditiveExprContext)_localctx).multiplicativeExpr = multiplicativeExpr(); ((AdditiveExprContext)_localctx).rhs.add(((AdditiveExprContext)_localctx).multiplicativeExpr); } } } - setState(673); + setState(679); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,63,_ctx); } @@ -4005,15 +4008,15 @@ public final MultiplicativeExprContext multiplicativeExpr() throws RecognitionEx try { enterOuterAlt(_localctx, 1); { - setState(674); + setState(680); ((MultiplicativeExprContext)_localctx).main_expr = instanceOfExpr(); - setState(679); + setState(685); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__32) | (1L << T__47) | (1L << T__48) | (1L << T__49))) != 0)) { { { - setState(675); + setState(681); ((MultiplicativeExprContext)_localctx)._tset1294 = _input.LT(1); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__32) | (1L << T__47) | (1L << T__48) | (1L << T__49))) != 0)) ) { @@ -4025,12 +4028,12 @@ public final MultiplicativeExprContext multiplicativeExpr() throws RecognitionEx consume(); } ((MultiplicativeExprContext)_localctx).op.add(((MultiplicativeExprContext)_localctx)._tset1294); - setState(676); + setState(682); ((MultiplicativeExprContext)_localctx).instanceOfExpr = instanceOfExpr(); ((MultiplicativeExprContext)_localctx).rhs.add(((MultiplicativeExprContext)_localctx).instanceOfExpr); } } - setState(681); + setState(687); _errHandler.sync(this); _la = _input.LA(1); } @@ -4075,18 +4078,18 @@ public final InstanceOfExprContext instanceOfExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(682); + setState(688); ((InstanceOfExprContext)_localctx).main_expr = isStaticallyExpr(); - setState(686); + setState(692); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,65,_ctx) ) { case 1: { - setState(683); + setState(689); match(Kinstance); - setState(684); + setState(690); match(Kof); - setState(685); + setState(691); ((InstanceOfExprContext)_localctx).seq = sequenceType(); } break; @@ -4132,18 +4135,18 @@ public final IsStaticallyExprContext isStaticallyExpr() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(688); + setState(694); ((IsStaticallyExprContext)_localctx).main_expr = treatExpr(); - setState(692); + setState(698); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,66,_ctx) ) { case 1: { - setState(689); + setState(695); match(Kis); - setState(690); + setState(696); match(Kstatically); - setState(691); + setState(697); ((IsStaticallyExprContext)_localctx).seq = sequenceType(); } break; @@ -4189,18 +4192,18 @@ public final TreatExprContext treatExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(694); + setState(700); ((TreatExprContext)_localctx).main_expr = castableExpr(); - setState(698); + setState(704); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,67,_ctx) ) { case 1: { - setState(695); + setState(701); match(Ktreat); - setState(696); + setState(702); match(Kas); - setState(697); + setState(703); ((TreatExprContext)_localctx).seq = sequenceType(); } break; @@ -4246,18 +4249,18 @@ public final CastableExprContext castableExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(700); + setState(706); ((CastableExprContext)_localctx).main_expr = castExpr(); - setState(704); + setState(710); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,68,_ctx) ) { case 1: { - setState(701); + setState(707); match(Kcastable); - setState(702); + setState(708); match(Kas); - setState(703); + setState(709); ((CastableExprContext)_localctx).single = singleType(); } break; @@ -4303,18 +4306,18 @@ public final CastExprContext castExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(706); + setState(712); ((CastExprContext)_localctx).main_expr = arrowExpr(); - setState(710); + setState(716); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,69,_ctx) ) { case 1: { - setState(707); + setState(713); match(Kcast); - setState(708); + setState(714); match(Kas); - setState(709); + setState(715); ((CastExprContext)_localctx).single = singleType(); } break; @@ -4363,9 +4366,9 @@ public final ArrowExprContext arrowExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(712); + setState(718); ((ArrowExprContext)_localctx).main_expr = unaryExpr(); - setState(719); + setState(725); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,70,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { @@ -4373,18 +4376,18 @@ public final ArrowExprContext arrowExpr() throws RecognitionException { { { { - setState(713); + setState(719); match(T__3); - setState(714); + setState(720); match(T__42); } - setState(716); + setState(722); ((ArrowExprContext)_localctx).functionCall = functionCall(); ((ArrowExprContext)_localctx).function_call_expr.add(((ArrowExprContext)_localctx).functionCall); } } } - setState(721); + setState(727); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,70,_ctx); } @@ -4428,13 +4431,13 @@ public final UnaryExprContext unaryExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(725); + setState(731); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__45 || _la==T__46) { { { - setState(722); + setState(728); ((UnaryExprContext)_localctx)._tset1454 = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__45 || _la==T__46) ) { @@ -4448,11 +4451,11 @@ public final UnaryExprContext unaryExpr() throws RecognitionException { ((UnaryExprContext)_localctx).op.add(((UnaryExprContext)_localctx)._tset1454); } } - setState(727); + setState(733); _errHandler.sync(this); _la = _input.LA(1); } - setState(728); + setState(734); ((UnaryExprContext)_localctx).main_expr = simpleMapExpr(); } } @@ -4495,22 +4498,22 @@ public final SimpleMapExprContext simpleMapExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(730); + setState(736); ((SimpleMapExprContext)_localctx).main_expr = postFixExpr(); - setState(735); + setState(741); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__50) { { { - setState(731); + setState(737); match(T__50); - setState(732); + setState(738); ((SimpleMapExprContext)_localctx).postFixExpr = postFixExpr(); ((SimpleMapExprContext)_localctx).map_expr.add(((SimpleMapExprContext)_localctx).postFixExpr); } } - setState(737); + setState(743); _errHandler.sync(this); _la = _input.LA(1); } @@ -4580,51 +4583,51 @@ public final PostFixExprContext postFixExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(738); + setState(744); ((PostFixExprContext)_localctx).main_expr = primaryExpr(); - setState(746); + setState(752); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,74,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { - setState(744); + setState(750); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,73,_ctx) ) { case 1: { - setState(739); + setState(745); arrayLookup(); } break; case 2: { - setState(740); + setState(746); predicate(); } break; case 3: { - setState(741); + setState(747); objectLookup(); } break; case 4: { - setState(742); + setState(748); arrayUnboxing(); } break; case 5: { - setState(743); + setState(749); argumentList(); } break; } } } - setState(748); + setState(754); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,74,_ctx); } @@ -4662,15 +4665,15 @@ public final ArrayLookupContext arrayLookup() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(749); + setState(755); match(T__51); - setState(750); + setState(756); match(T__51); - setState(751); + setState(757); expr(); - setState(752); + setState(758); match(T__52); - setState(753); + setState(759); match(T__52); } } @@ -4703,9 +4706,9 @@ public final ArrayUnboxingContext arrayUnboxing() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(755); + setState(761); match(T__51); - setState(756); + setState(762); match(T__52); } } @@ -4741,11 +4744,11 @@ public final PredicateContext predicate() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(758); + setState(764); match(T__51); - setState(759); + setState(765); expr(); - setState(760); + setState(766); match(T__52); } } @@ -4804,9 +4807,9 @@ public final ObjectLookupContext objectLookup() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(762); + setState(768); match(T__53); - setState(770); + setState(776); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: @@ -4855,37 +4858,37 @@ public final ObjectLookupContext objectLookup() throws RecognitionException { case Kjsoniq: case Kjson: { - setState(763); + setState(769); ((ObjectLookupContext)_localctx).kw = keyWords(); } break; case STRING: { - setState(764); + setState(770); ((ObjectLookupContext)_localctx).lt = stringLiteral(); } break; case NCName: { - setState(765); + setState(771); ((ObjectLookupContext)_localctx).nc = match(NCName); } break; case T__26: { - setState(766); + setState(772); ((ObjectLookupContext)_localctx).pe = parenthesizedExpr(); } break; case T__30: { - setState(767); + setState(773); ((ObjectLookupContext)_localctx).vr = varRef(); } break; case T__54: { - setState(768); + setState(774); ((ObjectLookupContext)_localctx).ci = contextItemExpr(); } break; @@ -4904,7 +4907,7 @@ public final ObjectLookupContext objectLookup() throws RecognitionException { case T__73: case T__74: { - setState(769); + setState(775); ((ObjectLookupContext)_localctx).tkw = typesKeywords(); } break; @@ -4972,90 +4975,90 @@ public final PrimaryExprContext primaryExpr() throws RecognitionException { PrimaryExprContext _localctx = new PrimaryExprContext(_ctx, getState()); enterRule(_localctx, 124, RULE_primaryExpr); try { - setState(784); + setState(790); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,76,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(772); + setState(778); match(NullLiteral); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(773); + setState(779); match(Literal); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(774); + setState(780); stringLiteral(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(775); + setState(781); varRef(); } break; case 5: enterOuterAlt(_localctx, 5); { - setState(776); + setState(782); parenthesizedExpr(); } break; case 6: enterOuterAlt(_localctx, 6); { - setState(777); + setState(783); contextItemExpr(); } break; case 7: enterOuterAlt(_localctx, 7); { - setState(778); + setState(784); objectConstructor(); } break; case 8: enterOuterAlt(_localctx, 8); { - setState(779); + setState(785); functionCall(); } break; case 9: enterOuterAlt(_localctx, 9); { - setState(780); + setState(786); orderedExpr(); } break; case 10: enterOuterAlt(_localctx, 10); { - setState(781); + setState(787); unorderedExpr(); } break; case 11: enterOuterAlt(_localctx, 11); { - setState(782); + setState(788); arrayConstructor(); } break; case 12: enterOuterAlt(_localctx, 12); { - setState(783); + setState(789); functionItemExpr(); } break; @@ -5094,9 +5097,9 @@ public final VarRefContext varRef() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(786); + setState(792); match(T__30); - setState(787); + setState(793); ((VarRefContext)_localctx).var_name = qname(); } } @@ -5133,19 +5136,19 @@ public final ParenthesizedExprContext parenthesizedExpr() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(789); + setState(795); match(T__26); - setState(791); + setState(797); _errHandler.sync(this); _la = _input.LA(1); if (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Kstatically - 71)) | (1L << (Kis - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { { - setState(790); + setState(796); expr(); } } - setState(793); + setState(799); match(T__27); } } @@ -5178,7 +5181,7 @@ public final ContextItemExprContext contextItemExpr() throws RecognitionExceptio try { enterOuterAlt(_localctx, 1); { - setState(795); + setState(801); match(T__54); } } @@ -5214,13 +5217,13 @@ public final OrderedExprContext orderedExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(797); + setState(803); match(T__6); - setState(798); + setState(804); match(T__28); - setState(799); + setState(805); expr(); - setState(800); + setState(806); match(T__29); } } @@ -5256,13 +5259,13 @@ public final UnorderedExprContext unorderedExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(802); + setState(808); match(T__7); - setState(803); + setState(809); match(T__28); - setState(804); + setState(810); expr(); - setState(805); + setState(811); match(T__29); } } @@ -5302,9 +5305,9 @@ public final FunctionCallContext functionCall() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(807); + setState(813); ((FunctionCallContext)_localctx).fn_name = qname(); - setState(808); + setState(814); argumentList(); } } @@ -5346,34 +5349,34 @@ public final ArgumentListContext argumentList() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(810); + setState(816); match(T__26); - setState(817); + setState(823); _errHandler.sync(this); _la = _input.LA(1); while (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Kstatically - 71)) | (1L << (Kis - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (ArgumentPlaceholder - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { { { - setState(811); + setState(817); ((ArgumentListContext)_localctx).argument = argument(); ((ArgumentListContext)_localctx).args.add(((ArgumentListContext)_localctx).argument); - setState(813); + setState(819); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__21) { { - setState(812); + setState(818); match(T__21); } } } } - setState(819); + setState(825); _errHandler.sync(this); _la = _input.LA(1); } - setState(820); + setState(826); match(T__27); } } @@ -5408,7 +5411,7 @@ public final ArgumentContext argument() throws RecognitionException { ArgumentContext _localctx = new ArgumentContext(_ctx, getState()); enterRule(_localctx, 140, RULE_argument); try { - setState(824); + setState(830); _errHandler.sync(this); switch (_input.LA(1)) { case T__6: @@ -5487,14 +5490,14 @@ public final ArgumentContext argument() throws RecognitionException { case NCName: enterOuterAlt(_localctx, 1); { - setState(822); + setState(828); exprSingle(); } break; case ArgumentPlaceholder: enterOuterAlt(_localctx, 2); { - setState(823); + setState(829); match(ArgumentPlaceholder); } break; @@ -5535,7 +5538,7 @@ public final FunctionItemExprContext functionItemExpr() throws RecognitionExcept FunctionItemExprContext _localctx = new FunctionItemExprContext(_ctx, getState()); enterRule(_localctx, 142, RULE_functionItemExpr); try { - setState(828); + setState(834); _errHandler.sync(this); switch (_input.LA(1)) { case T__61: @@ -5600,14 +5603,14 @@ public final FunctionItemExprContext functionItemExpr() throws RecognitionExcept case NCName: enterOuterAlt(_localctx, 1); { - setState(826); + setState(832); namedFunctionRef(); } break; case T__25: enterOuterAlt(_localctx, 2); { - setState(827); + setState(833); inlineFunctionExpr(); } break; @@ -5650,11 +5653,11 @@ public final NamedFunctionRefContext namedFunctionRef() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(830); + setState(836); ((NamedFunctionRefContext)_localctx).fn_name = qname(); - setState(831); + setState(837); match(T__55); - setState(832); + setState(838); ((NamedFunctionRefContext)_localctx).arity = match(Literal); } } @@ -5700,40 +5703,40 @@ public final InlineFunctionExprContext inlineFunctionExpr() throws RecognitionEx try { enterOuterAlt(_localctx, 1); { - setState(834); + setState(840); match(T__25); - setState(835); + setState(841); match(T__26); - setState(837); + setState(843); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(836); + setState(842); paramList(); } } - setState(839); + setState(845); match(T__27); - setState(842); + setState(848); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(840); + setState(846); match(Kas); - setState(841); + setState(847); ((InlineFunctionExprContext)_localctx).return_type = sequenceType(); } } { - setState(844); + setState(850); match(T__28); - setState(845); + setState(851); ((InlineFunctionExprContext)_localctx).fn_body = expr(); - setState(846); + setState(852); match(T__29); } } @@ -5775,18 +5778,19 @@ public final SequenceTypeContext sequenceType() throws RecognitionException { SequenceTypeContext _localctx = new SequenceTypeContext(_ctx, getState()); enterRule(_localctx, 148, RULE_sequenceType); try { - setState(856); + setState(862); _errHandler.sync(this); switch (_input.LA(1)) { case T__26: enterOuterAlt(_localctx, 1); { - setState(848); + setState(854); match(T__26); - setState(849); + setState(855); match(T__27); } break; + case T__25: case T__58: case T__59: case T__60: @@ -5809,28 +5813,28 @@ public final SequenceTypeContext sequenceType() throws RecognitionException { case NullLiteral: enterOuterAlt(_localctx, 2); { - setState(850); + setState(856); ((SequenceTypeContext)_localctx).item = itemType(); - setState(854); + setState(860); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,84,_ctx) ) { case 1: { - setState(851); + setState(857); ((SequenceTypeContext)_localctx).s123 = match(ArgumentPlaceholder); ((SequenceTypeContext)_localctx).question.add(((SequenceTypeContext)_localctx).s123); } break; case 2: { - setState(852); + setState(858); ((SequenceTypeContext)_localctx).s33 = match(T__32); ((SequenceTypeContext)_localctx).star.add(((SequenceTypeContext)_localctx).s33); } break; case 3: { - setState(853); + setState(859); ((SequenceTypeContext)_localctx).s46 = match(T__45); ((SequenceTypeContext)_localctx).plus.add(((SequenceTypeContext)_localctx).s46); } @@ -5881,53 +5885,53 @@ public final ObjectConstructorContext objectConstructor() throws RecognitionExce enterRule(_localctx, 150, RULE_objectConstructor); int _la; try { - setState(874); + setState(880); _errHandler.sync(this); switch (_input.LA(1)) { case T__28: enterOuterAlt(_localctx, 1); { - setState(858); + setState(864); match(T__28); - setState(867); + setState(873); _errHandler.sync(this); _la = _input.LA(1); if (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Kstatically - 71)) | (1L << (Kis - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { { - setState(859); + setState(865); pairConstructor(); - setState(864); + setState(870); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(860); + setState(866); match(T__21); - setState(861); + setState(867); pairConstructor(); } } - setState(866); + setState(872); _errHandler.sync(this); _la = _input.LA(1); } } } - setState(869); + setState(875); match(T__29); } break; case T__56: enterOuterAlt(_localctx, 2); { - setState(870); + setState(876); ((ObjectConstructorContext)_localctx).s57 = match(T__56); ((ObjectConstructorContext)_localctx).merge_operator.add(((ObjectConstructorContext)_localctx).s57); - setState(871); + setState(877); expr(); - setState(872); + setState(878); match(T__57); } break; @@ -5953,6 +5957,9 @@ public JSONItemTestContext jSONItemTest() { public AtomicTypeContext atomicType() { return getRuleContext(AtomicTypeContext.class,0); } + public FunctionTestContext functionTest() { + return getRuleContext(FunctionTestContext.class,0); + } public ItemTypeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -5968,13 +5975,13 @@ public final ItemTypeContext itemType() throws RecognitionException { ItemTypeContext _localctx = new ItemTypeContext(_ctx, getState()); enterRule(_localctx, 152, RULE_itemType); try { - setState(879); + setState(886); _errHandler.sync(this); switch (_input.LA(1)) { case T__58: enterOuterAlt(_localctx, 1); { - setState(876); + setState(882); match(T__58); } break; @@ -5983,7 +5990,7 @@ public final ItemTypeContext itemType() throws RecognitionException { case Kjson: enterOuterAlt(_localctx, 2); { - setState(877); + setState(883); jSONItemTest(); } break; @@ -6005,10 +6012,17 @@ public final ItemTypeContext itemType() throws RecognitionException { case NullLiteral: enterOuterAlt(_localctx, 3); { - setState(878); + setState(884); atomicType(); } break; + case T__25: + enterOuterAlt(_localctx, 4); + { + setState(885); + functionTest(); + } + break; default: throw new NoViableAltException(this); } @@ -6024,6 +6038,177 @@ public final ItemTypeContext itemType() throws RecognitionException { return _localctx; } + public static class FunctionTestContext extends ParserRuleContext { + public AnyFunctionTestContext anyFunctionTest() { + return getRuleContext(AnyFunctionTestContext.class,0); + } + public TypedFunctionTestContext typedFunctionTest() { + return getRuleContext(TypedFunctionTestContext.class,0); + } + public FunctionTestContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_functionTest; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor)visitor).visitFunctionTest(this); + else return visitor.visitChildren(this); + } + } + + public final FunctionTestContext functionTest() throws RecognitionException { + FunctionTestContext _localctx = new FunctionTestContext(_ctx, getState()); + enterRule(_localctx, 154, RULE_functionTest); + try { + enterOuterAlt(_localctx, 1); + { + setState(890); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,90,_ctx) ) { + case 1: + { + setState(888); + anyFunctionTest(); + } + break; + case 2: + { + setState(889); + typedFunctionTest(); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class AnyFunctionTestContext extends ParserRuleContext { + public AnyFunctionTestContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_anyFunctionTest; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor)visitor).visitAnyFunctionTest(this); + else return visitor.visitChildren(this); + } + } + + public final AnyFunctionTestContext anyFunctionTest() throws RecognitionException { + AnyFunctionTestContext _localctx = new AnyFunctionTestContext(_ctx, getState()); + enterRule(_localctx, 156, RULE_anyFunctionTest); + try { + enterOuterAlt(_localctx, 1); + { + setState(892); + match(T__25); + setState(893); + match(T__26); + setState(894); + match(T__32); + setState(895); + match(T__27); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class TypedFunctionTestContext extends ParserRuleContext { + public SequenceTypeContext sequenceType; + public List st = new ArrayList(); + public SequenceTypeContext rt; + public List sequenceType() { + return getRuleContexts(SequenceTypeContext.class); + } + public SequenceTypeContext sequenceType(int i) { + return getRuleContext(SequenceTypeContext.class,i); + } + public TypedFunctionTestContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_typedFunctionTest; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor)visitor).visitTypedFunctionTest(this); + else return visitor.visitChildren(this); + } + } + + public final TypedFunctionTestContext typedFunctionTest() throws RecognitionException { + TypedFunctionTestContext _localctx = new TypedFunctionTestContext(_ctx, getState()); + enterRule(_localctx, 158, RULE_typedFunctionTest); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(897); + match(T__25); + setState(898); + match(T__26); + setState(907); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__25) | (1L << T__26) | (1L << T__58) | (1L << T__59) | (1L << T__60) | (1L << T__61) | (1L << T__62))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (T__63 - 64)) | (1L << (T__64 - 64)) | (1L << (T__65 - 64)) | (1L << (T__66 - 64)) | (1L << (T__67 - 64)) | (1L << (T__68 - 64)) | (1L << (T__69 - 64)) | (1L << (T__70 - 64)) | (1L << (T__71 - 64)) | (1L << (T__72 - 64)) | (1L << (T__73 - 64)) | (1L << (T__74 - 64)) | (1L << (T__75 - 64)) | (1L << (Kjson - 64)) | (1L << (NullLiteral - 64)))) != 0)) { + { + setState(899); + ((TypedFunctionTestContext)_localctx).sequenceType = sequenceType(); + ((TypedFunctionTestContext)_localctx).st.add(((TypedFunctionTestContext)_localctx).sequenceType); + setState(904); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__21) { + { + { + setState(900); + match(T__21); + setState(901); + ((TypedFunctionTestContext)_localctx).sequenceType = sequenceType(); + ((TypedFunctionTestContext)_localctx).st.add(((TypedFunctionTestContext)_localctx).sequenceType); + } + } + setState(906); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(909); + match(T__27); + setState(910); + match(Kas); + setState(911); + ((TypedFunctionTestContext)_localctx).rt = sequenceType(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + public static class JSONItemTestContext extends ParserRuleContext { public TerminalNode Kjson() { return getToken(JsoniqParser.Kjson, 0); } public JSONItemTestContext(ParserRuleContext parent, int invokingState) { @@ -6039,12 +6224,12 @@ public T accept(ParseTreeVisitor visitor) { public final JSONItemTestContext jSONItemTest() throws RecognitionException { JSONItemTestContext _localctx = new JSONItemTestContext(_ctx, getState()); - enterRule(_localctx, 154, RULE_jSONItemTest); + enterRule(_localctx, 160, RULE_jSONItemTest); int _la; try { enterOuterAlt(_localctx, 1); { - setState(881); + setState(913); _la = _input.LA(1); if ( !(((((_la - 60)) & ~0x3f) == 0 && ((1L << (_la - 60)) & ((1L << (T__59 - 60)) | (1L << (T__60 - 60)) | (1L << (Kjson - 60)))) != 0)) ) { _errHandler.recoverInline(this); @@ -6081,11 +6266,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordStringContext keyWordString() throws RecognitionException { KeyWordStringContext _localctx = new KeyWordStringContext(_ctx, getState()); - enterRule(_localctx, 156, RULE_keyWordString); + enterRule(_localctx, 162, RULE_keyWordString); try { enterOuterAlt(_localctx, 1); { - setState(883); + setState(915); match(T__61); } } @@ -6114,11 +6299,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordIntegerContext keyWordInteger() throws RecognitionException { KeyWordIntegerContext _localctx = new KeyWordIntegerContext(_ctx, getState()); - enterRule(_localctx, 158, RULE_keyWordInteger); + enterRule(_localctx, 164, RULE_keyWordInteger); try { enterOuterAlt(_localctx, 1); { - setState(885); + setState(917); match(T__62); } } @@ -6147,11 +6332,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordDecimalContext keyWordDecimal() throws RecognitionException { KeyWordDecimalContext _localctx = new KeyWordDecimalContext(_ctx, getState()); - enterRule(_localctx, 160, RULE_keyWordDecimal); + enterRule(_localctx, 166, RULE_keyWordDecimal); try { enterOuterAlt(_localctx, 1); { - setState(887); + setState(919); match(T__63); } } @@ -6180,11 +6365,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordDoubleContext keyWordDouble() throws RecognitionException { KeyWordDoubleContext _localctx = new KeyWordDoubleContext(_ctx, getState()); - enterRule(_localctx, 162, RULE_keyWordDouble); + enterRule(_localctx, 168, RULE_keyWordDouble); try { enterOuterAlt(_localctx, 1); { - setState(889); + setState(921); match(T__64); } } @@ -6213,11 +6398,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordBooleanContext keyWordBoolean() throws RecognitionException { KeyWordBooleanContext _localctx = new KeyWordBooleanContext(_ctx, getState()); - enterRule(_localctx, 164, RULE_keyWordBoolean); + enterRule(_localctx, 170, RULE_keyWordBoolean); try { enterOuterAlt(_localctx, 1); { - setState(891); + setState(923); match(T__65); } } @@ -6246,11 +6431,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordDurationContext keyWordDuration() throws RecognitionException { KeyWordDurationContext _localctx = new KeyWordDurationContext(_ctx, getState()); - enterRule(_localctx, 166, RULE_keyWordDuration); + enterRule(_localctx, 172, RULE_keyWordDuration); try { enterOuterAlt(_localctx, 1); { - setState(893); + setState(925); match(T__66); } } @@ -6279,11 +6464,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordYearMonthDurationContext keyWordYearMonthDuration() throws RecognitionException { KeyWordYearMonthDurationContext _localctx = new KeyWordYearMonthDurationContext(_ctx, getState()); - enterRule(_localctx, 168, RULE_keyWordYearMonthDuration); + enterRule(_localctx, 174, RULE_keyWordYearMonthDuration); try { enterOuterAlt(_localctx, 1); { - setState(895); + setState(927); match(T__67); } } @@ -6312,11 +6497,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordDayTimeDurationContext keyWordDayTimeDuration() throws RecognitionException { KeyWordDayTimeDurationContext _localctx = new KeyWordDayTimeDurationContext(_ctx, getState()); - enterRule(_localctx, 170, RULE_keyWordDayTimeDuration); + enterRule(_localctx, 176, RULE_keyWordDayTimeDuration); try { enterOuterAlt(_localctx, 1); { - setState(897); + setState(929); match(T__68); } } @@ -6345,11 +6530,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordHexBinaryContext keyWordHexBinary() throws RecognitionException { KeyWordHexBinaryContext _localctx = new KeyWordHexBinaryContext(_ctx, getState()); - enterRule(_localctx, 172, RULE_keyWordHexBinary); + enterRule(_localctx, 178, RULE_keyWordHexBinary); try { enterOuterAlt(_localctx, 1); { - setState(899); + setState(931); match(T__69); } } @@ -6378,11 +6563,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordBase64BinaryContext keyWordBase64Binary() throws RecognitionException { KeyWordBase64BinaryContext _localctx = new KeyWordBase64BinaryContext(_ctx, getState()); - enterRule(_localctx, 174, RULE_keyWordBase64Binary); + enterRule(_localctx, 180, RULE_keyWordBase64Binary); try { enterOuterAlt(_localctx, 1); { - setState(901); + setState(933); match(T__70); } } @@ -6411,11 +6596,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordDateTimeContext keyWordDateTime() throws RecognitionException { KeyWordDateTimeContext _localctx = new KeyWordDateTimeContext(_ctx, getState()); - enterRule(_localctx, 176, RULE_keyWordDateTime); + enterRule(_localctx, 182, RULE_keyWordDateTime); try { enterOuterAlt(_localctx, 1); { - setState(903); + setState(935); match(T__71); } } @@ -6444,11 +6629,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordDateContext keyWordDate() throws RecognitionException { KeyWordDateContext _localctx = new KeyWordDateContext(_ctx, getState()); - enterRule(_localctx, 178, RULE_keyWordDate); + enterRule(_localctx, 184, RULE_keyWordDate); try { enterOuterAlt(_localctx, 1); { - setState(905); + setState(937); match(T__72); } } @@ -6477,11 +6662,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordTimeContext keyWordTime() throws RecognitionException { KeyWordTimeContext _localctx = new KeyWordTimeContext(_ctx, getState()); - enterRule(_localctx, 180, RULE_keyWordTime); + enterRule(_localctx, 186, RULE_keyWordTime); try { enterOuterAlt(_localctx, 1); { - setState(907); + setState(939); match(T__73); } } @@ -6510,11 +6695,11 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordAnyURIContext keyWordAnyURI() throws RecognitionException { KeyWordAnyURIContext _localctx = new KeyWordAnyURIContext(_ctx, getState()); - enterRule(_localctx, 182, RULE_keyWordAnyURI); + enterRule(_localctx, 188, RULE_keyWordAnyURI); try { enterOuterAlt(_localctx, 1); { - setState(909); + setState(941); match(T__74); } } @@ -6585,106 +6770,106 @@ public T accept(ParseTreeVisitor visitor) { public final TypesKeywordsContext typesKeywords() throws RecognitionException { TypesKeywordsContext _localctx = new TypesKeywordsContext(_ctx, getState()); - enterRule(_localctx, 184, RULE_typesKeywords); + enterRule(_localctx, 190, RULE_typesKeywords); try { - setState(925); + setState(957); _errHandler.sync(this); switch (_input.LA(1)) { case T__61: enterOuterAlt(_localctx, 1); { - setState(911); + setState(943); keyWordString(); } break; case T__62: enterOuterAlt(_localctx, 2); { - setState(912); + setState(944); keyWordInteger(); } break; case T__63: enterOuterAlt(_localctx, 3); { - setState(913); + setState(945); keyWordDecimal(); } break; case T__64: enterOuterAlt(_localctx, 4); { - setState(914); + setState(946); keyWordDouble(); } break; case T__65: enterOuterAlt(_localctx, 5); { - setState(915); + setState(947); keyWordBoolean(); } break; case T__66: enterOuterAlt(_localctx, 6); { - setState(916); + setState(948); keyWordDuration(); } break; case T__67: enterOuterAlt(_localctx, 7); { - setState(917); + setState(949); keyWordYearMonthDuration(); } break; case T__68: enterOuterAlt(_localctx, 8); { - setState(918); + setState(950); keyWordDayTimeDuration(); } break; case T__71: enterOuterAlt(_localctx, 9); { - setState(919); + setState(951); keyWordDateTime(); } break; case T__72: enterOuterAlt(_localctx, 10); { - setState(920); + setState(952); keyWordDate(); } break; case T__73: enterOuterAlt(_localctx, 11); { - setState(921); + setState(953); keyWordTime(); } break; case T__69: enterOuterAlt(_localctx, 12); { - setState(922); + setState(954); keyWordHexBinary(); } break; case T__70: enterOuterAlt(_localctx, 13); { - setState(923); + setState(955); keyWordBase64Binary(); } break; case T__74: enterOuterAlt(_localctx, 14); { - setState(924); + setState(956); keyWordAnyURI(); } break; @@ -6723,18 +6908,18 @@ public T accept(ParseTreeVisitor visitor) { public final SingleTypeContext singleType() throws RecognitionException { SingleTypeContext _localctx = new SingleTypeContext(_ctx, getState()); - enterRule(_localctx, 186, RULE_singleType); + enterRule(_localctx, 192, RULE_singleType); try { enterOuterAlt(_localctx, 1); { - setState(927); + setState(959); ((SingleTypeContext)_localctx).item = atomicType(); - setState(929); + setState(961); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,91,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,94,_ctx) ) { case 1: { - setState(928); + setState(960); ((SingleTypeContext)_localctx).s123 = match(ArgumentPlaceholder); ((SingleTypeContext)_localctx).question.add(((SingleTypeContext)_localctx).s123); } @@ -6771,15 +6956,15 @@ public T accept(ParseTreeVisitor visitor) { public final AtomicTypeContext atomicType() throws RecognitionException { AtomicTypeContext _localctx = new AtomicTypeContext(_ctx, getState()); - enterRule(_localctx, 188, RULE_atomicType); + enterRule(_localctx, 194, RULE_atomicType); try { - setState(934); + setState(966); _errHandler.sync(this); switch (_input.LA(1)) { case T__75: enterOuterAlt(_localctx, 1); { - setState(931); + setState(963); match(T__75); } break; @@ -6799,14 +6984,14 @@ public final AtomicTypeContext atomicType() throws RecognitionException { case T__74: enterOuterAlt(_localctx, 2); { - setState(932); + setState(964); typesKeywords(); } break; case NullLiteral: enterOuterAlt(_localctx, 3); { - setState(933); + setState(965); match(NullLiteral); } break; @@ -6843,15 +7028,15 @@ public T accept(ParseTreeVisitor visitor) { public final NCNameOrKeyWordContext nCNameOrKeyWord() throws RecognitionException { NCNameOrKeyWordContext _localctx = new NCNameOrKeyWordContext(_ctx, getState()); - enterRule(_localctx, 190, RULE_nCNameOrKeyWord); + enterRule(_localctx, 196, RULE_nCNameOrKeyWord); try { - setState(938); + setState(970); _errHandler.sync(this); switch (_input.LA(1)) { case NCName: enterOuterAlt(_localctx, 1); { - setState(936); + setState(968); match(NCName); } break; @@ -6871,7 +7056,7 @@ public final NCNameOrKeyWordContext nCNameOrKeyWord() throws RecognitionExceptio case T__74: enterOuterAlt(_localctx, 2); { - setState(937); + setState(969); typesKeywords(); } break; @@ -6914,28 +7099,28 @@ public T accept(ParseTreeVisitor visitor) { public final PairConstructorContext pairConstructor() throws RecognitionException { PairConstructorContext _localctx = new PairConstructorContext(_ctx, getState()); - enterRule(_localctx, 192, RULE_pairConstructor); + enterRule(_localctx, 198, RULE_pairConstructor); int _la; try { enterOuterAlt(_localctx, 1); { - setState(942); + setState(974); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,94,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,97,_ctx) ) { case 1: { - setState(940); + setState(972); ((PairConstructorContext)_localctx).lhs = exprSingle(); } break; case 2: { - setState(941); + setState(973); ((PairConstructorContext)_localctx).name = match(NCName); } break; } - setState(944); + setState(976); _la = _input.LA(1); if ( !(_la==T__9 || _la==ArgumentPlaceholder) ) { _errHandler.recoverInline(this); @@ -6945,7 +7130,7 @@ public final PairConstructorContext pairConstructor() throws RecognitionExceptio _errHandler.reportMatch(this); consume(); } - setState(945); + setState(977); ((PairConstructorContext)_localctx).rhs = exprSingle(); } } @@ -6977,24 +7162,24 @@ public T accept(ParseTreeVisitor visitor) { public final ArrayConstructorContext arrayConstructor() throws RecognitionException { ArrayConstructorContext _localctx = new ArrayConstructorContext(_ctx, getState()); - enterRule(_localctx, 194, RULE_arrayConstructor); + enterRule(_localctx, 200, RULE_arrayConstructor); int _la; try { enterOuterAlt(_localctx, 1); { - setState(947); + setState(979); match(T__51); - setState(949); + setState(981); _errHandler.sync(this); _la = _input.LA(1); if (((((_la - 7)) & ~0x3f) == 0 && ((1L << (_la - 7)) & ((1L << (T__6 - 7)) | (1L << (T__7 - 7)) | (1L << (T__25 - 7)) | (1L << (T__26 - 7)) | (1L << (T__28 - 7)) | (1L << (T__30 - 7)) | (1L << (T__45 - 7)) | (1L << (T__46 - 7)) | (1L << (T__51 - 7)) | (1L << (T__54 - 7)) | (1L << (T__56 - 7)) | (1L << (T__61 - 7)) | (1L << (T__62 - 7)) | (1L << (T__63 - 7)) | (1L << (T__64 - 7)) | (1L << (T__65 - 7)) | (1L << (T__66 - 7)) | (1L << (T__67 - 7)) | (1L << (T__68 - 7)) | (1L << (T__69 - 7)))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1L << (_la - 71)) & ((1L << (T__70 - 71)) | (1L << (T__71 - 71)) | (1L << (T__72 - 71)) | (1L << (T__73 - 71)) | (1L << (T__74 - 71)) | (1L << (Kfor - 71)) | (1L << (Klet - 71)) | (1L << (Kwhere - 71)) | (1L << (Kgroup - 71)) | (1L << (Kby - 71)) | (1L << (Korder - 71)) | (1L << (Kreturn - 71)) | (1L << (Kif - 71)) | (1L << (Kin - 71)) | (1L << (Kas - 71)) | (1L << (Kat - 71)) | (1L << (Kallowing - 71)) | (1L << (Kempty - 71)) | (1L << (Kcount - 71)) | (1L << (Kstable - 71)) | (1L << (Kascending - 71)) | (1L << (Kdescending - 71)) | (1L << (Ksome - 71)) | (1L << (Kevery - 71)) | (1L << (Ksatisfies - 71)) | (1L << (Kcollation - 71)) | (1L << (Kgreatest - 71)) | (1L << (Kleast - 71)) | (1L << (Kswitch - 71)) | (1L << (Kcase - 71)) | (1L << (Ktry - 71)) | (1L << (Kcatch - 71)) | (1L << (Kdefault - 71)) | (1L << (Kthen - 71)) | (1L << (Kelse - 71)) | (1L << (Ktypeswitch - 71)) | (1L << (Kor - 71)) | (1L << (Kand - 71)) | (1L << (Knot - 71)) | (1L << (Kto - 71)) | (1L << (Kinstance - 71)) | (1L << (Kof - 71)) | (1L << (Kstatically - 71)) | (1L << (Kis - 71)) | (1L << (Ktreat - 71)) | (1L << (Kcast - 71)) | (1L << (Kcastable - 71)) | (1L << (Kversion - 71)) | (1L << (Kjsoniq - 71)) | (1L << (Kjson - 71)) | (1L << (STRING - 71)) | (1L << (NullLiteral - 71)) | (1L << (Literal - 71)) | (1L << (NCName - 71)))) != 0)) { { - setState(948); + setState(980); expr(); } } - setState(951); + setState(983); match(T__52); } } @@ -7026,11 +7211,11 @@ public T accept(ParseTreeVisitor visitor) { public final UriLiteralContext uriLiteral() throws RecognitionException { UriLiteralContext _localctx = new UriLiteralContext(_ctx, getState()); - enterRule(_localctx, 196, RULE_uriLiteral); + enterRule(_localctx, 202, RULE_uriLiteral); try { enterOuterAlt(_localctx, 1); { - setState(953); + setState(985); stringLiteral(); } } @@ -7060,11 +7245,11 @@ public T accept(ParseTreeVisitor visitor) { public final StringLiteralContext stringLiteral() throws RecognitionException { StringLiteralContext _localctx = new StringLiteralContext(_ctx, getState()); - enterRule(_localctx, 198, RULE_stringLiteral); + enterRule(_localctx, 204, RULE_stringLiteral); try { enterOuterAlt(_localctx, 1); { - setState(955); + setState(987); match(STRING); } } @@ -7138,12 +7323,12 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordsContext keyWords() throws RecognitionException { KeyWordsContext _localctx = new KeyWordsContext(_ctx, getState()); - enterRule(_localctx, 200, RULE_keyWords); + enterRule(_localctx, 206, RULE_keyWords); int _la; try { enterOuterAlt(_localctx, 1); { - setState(957); + setState(989); _la = _input.LA(1); if ( !(((((_la - 77)) & ~0x3f) == 0 && ((1L << (_la - 77)) & ((1L << (Kfor - 77)) | (1L << (Klet - 77)) | (1L << (Kwhere - 77)) | (1L << (Kgroup - 77)) | (1L << (Kby - 77)) | (1L << (Korder - 77)) | (1L << (Kreturn - 77)) | (1L << (Kif - 77)) | (1L << (Kin - 77)) | (1L << (Kas - 77)) | (1L << (Kat - 77)) | (1L << (Kallowing - 77)) | (1L << (Kempty - 77)) | (1L << (Kcount - 77)) | (1L << (Kstable - 77)) | (1L << (Kascending - 77)) | (1L << (Kdescending - 77)) | (1L << (Ksome - 77)) | (1L << (Kevery - 77)) | (1L << (Ksatisfies - 77)) | (1L << (Kcollation - 77)) | (1L << (Kgreatest - 77)) | (1L << (Kleast - 77)) | (1L << (Kswitch - 77)) | (1L << (Kcase - 77)) | (1L << (Ktry - 77)) | (1L << (Kcatch - 77)) | (1L << (Kdefault - 77)) | (1L << (Kthen - 77)) | (1L << (Kelse - 77)) | (1L << (Ktypeswitch - 77)) | (1L << (Kor - 77)) | (1L << (Kand - 77)) | (1L << (Knot - 77)) | (1L << (Kto - 77)) | (1L << (Kinstance - 77)) | (1L << (Kof - 77)) | (1L << (Kstatically - 77)) | (1L << (Kis - 77)) | (1L << (Ktreat - 77)) | (1L << (Kcast - 77)) | (1L << (Kcastable - 77)) | (1L << (Kversion - 77)) | (1L << (Kjsoniq - 77)) | (1L << (Kjson - 77)))) != 0)) ) { _errHandler.recoverInline(this); @@ -7167,7 +7352,7 @@ public final KeyWordsContext keyWords() throws RecognitionException { } public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\u0088\u03c2\4\2\t"+ + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\u0088\u03e2\4\2\t"+ "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ @@ -7178,351 +7363,363 @@ public final KeyWordsContext keyWords() throws RecognitionException { "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I"+ "\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT"+ "\4U\tU\4V\tV\4W\tW\4X\tX\4Y\tY\4Z\tZ\4[\t[\4\\\t\\\4]\t]\4^\t^\4_\t_\4"+ - "`\t`\4a\ta\4b\tb\4c\tc\4d\td\4e\te\4f\tf\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3"+ - "\3\5\3\u00d5\n\3\3\3\3\3\5\3\u00d9\n\3\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5"+ - "\3\5\3\5\3\5\3\6\3\6\3\6\5\6\u00e9\n\6\3\6\3\6\7\6\u00ed\n\6\f\6\16\6"+ - "\u00f0\13\6\3\6\3\6\3\6\7\6\u00f5\n\6\f\6\16\6\u00f8\13\6\3\7\3\7\3\7"+ - "\3\7\5\7\u00fe\n\7\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3\t\5\t\u0108\n\t\3\n\3"+ - "\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r"+ - "\3\r\3\r\5\r\u011e\n\r\3\r\3\r\3\r\3\r\7\r\u0124\n\r\f\r\16\r\u0127\13"+ - "\r\3\16\3\16\5\16\u012b\n\16\3\16\5\16\u012e\n\16\3\16\3\16\5\16\u0132"+ - "\n\16\3\17\3\17\3\20\3\20\3\20\3\20\3\20\5\20\u013b\n\20\3\20\3\20\3\20"+ - "\3\20\3\20\7\20\u0142\n\20\f\20\16\20\u0145\13\20\5\20\u0147\n\20\3\21"+ - "\3\21\3\21\3\21\3\21\5\21\u014e\n\21\3\21\3\21\3\21\3\21\3\21\5\21\u0155"+ - "\n\21\5\21\u0157\n\21\3\22\3\22\3\22\3\22\3\22\5\22\u015e\n\22\3\22\3"+ - "\22\3\22\5\22\u0163\n\22\3\22\3\22\3\22\3\22\3\22\5\22\u016a\n\22\3\23"+ - "\3\23\3\23\7\23\u016f\n\23\f\23\16\23\u0172\13\23\3\24\3\24\3\24\3\24"+ - "\5\24\u0178\n\24\3\25\3\25\3\25\7\25\u017d\n\25\f\25\16\25\u0180\13\25"+ - "\3\26\3\26\3\26\3\26\3\26\3\26\3\26\5\26\u0189\n\26\3\27\3\27\5\27\u018d"+ - "\n\27\3\27\3\27\3\27\3\27\3\27\3\27\7\27\u0195\n\27\f\27\16\27\u0198\13"+ - "\27\3\27\3\27\3\27\3\30\3\30\3\30\3\30\7\30\u01a1\n\30\f\30\16\30\u01a4"+ - "\13\30\3\31\3\31\3\31\5\31\u01a9\n\31\3\31\3\31\5\31\u01ad\n\31\3\31\3"+ - "\31\5\31\u01b1\n\31\3\31\3\31\3\31\3\32\3\32\3\32\3\32\7\32\u01ba\n\32"+ - "\f\32\16\32\u01bd\13\32\3\33\3\33\3\33\5\33\u01c2\n\33\3\33\3\33\3\33"+ - "\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\7\35\u01cf\n\35\f\35\16\35\u01d2"+ - "\13\35\3\36\3\36\3\36\5\36\u01d7\n\36\3\36\3\36\5\36\u01db\n\36\3\36\3"+ - "\36\5\36\u01df\n\36\3\37\3\37\3\37\3\37\3\37\5\37\u01e6\n\37\3\37\3\37"+ - "\3\37\7\37\u01eb\n\37\f\37\16\37\u01ee\13\37\3 \3 \3 \5 \u01f3\n \3 \3"+ - " \3 \5 \u01f8\n \5 \u01fa\n \3 \3 \5 \u01fe\n \3!\3!\3!\3\"\3\"\5\"\u0205"+ - "\n\"\3\"\3\"\3\"\7\"\u020a\n\"\f\"\16\"\u020d\13\"\3\"\3\"\3\"\3#\3#\3"+ - "#\5#\u0215\n#\3#\3#\3#\3$\3$\3$\3$\3$\6$\u021f\n$\r$\16$\u0220\3$\3$\3"+ - "$\3$\3%\3%\6%\u0229\n%\r%\16%\u022a\3%\3%\3%\3&\3&\3&\3&\3&\6&\u0235\n"+ - "&\r&\16&\u0236\3&\3&\5&\u023b\n&\3&\3&\3&\3\'\3\'\3\'\3\'\5\'\u0244\n"+ - "\'\3\'\3\'\3\'\7\'\u0249\n\'\f\'\16\'\u024c\13\'\3\'\3\'\3\'\3(\3(\3("+ - "\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\6)\u025f\n)\r)\16)\u0260\3*\3*\3*\5"+ - "*\u0266\n*\3*\3*\3*\5*\u026b\n*\7*\u026d\n*\f*\16*\u0270\13*\3*\3*\3*"+ - "\3*\3+\3+\3+\7+\u0279\n+\f+\16+\u027c\13+\3,\3,\3,\7,\u0281\n,\f,\16,"+ - "\u0284\13,\3-\5-\u0287\n-\3-\3-\3.\3.\3.\5.\u028e\n.\3/\3/\3/\7/\u0293"+ - "\n/\f/\16/\u0296\13/\3\60\3\60\3\60\5\60\u029b\n\60\3\61\3\61\3\61\7\61"+ - "\u02a0\n\61\f\61\16\61\u02a3\13\61\3\62\3\62\3\62\7\62\u02a8\n\62\f\62"+ - "\16\62\u02ab\13\62\3\63\3\63\3\63\3\63\5\63\u02b1\n\63\3\64\3\64\3\64"+ - "\3\64\5\64\u02b7\n\64\3\65\3\65\3\65\3\65\5\65\u02bd\n\65\3\66\3\66\3"+ - "\66\3\66\5\66\u02c3\n\66\3\67\3\67\3\67\3\67\5\67\u02c9\n\67\38\38\38"+ - "\38\38\78\u02d0\n8\f8\168\u02d3\138\39\79\u02d6\n9\f9\169\u02d9\139\3"+ - "9\39\3:\3:\3:\7:\u02e0\n:\f:\16:\u02e3\13:\3;\3;\3;\3;\3;\3;\7;\u02eb"+ - "\n;\f;\16;\u02ee\13;\3<\3<\3<\3<\3<\3<\3=\3=\3=\3>\3>\3>\3>\3?\3?\3?\3"+ - "?\3?\3?\3?\3?\5?\u0305\n?\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\5@\u0313"+ - "\n@\3A\3A\3A\3B\3B\5B\u031a\nB\3B\3B\3C\3C\3D\3D\3D\3D\3D\3E\3E\3E\3E"+ - "\3E\3F\3F\3F\3G\3G\3G\5G\u0330\nG\7G\u0332\nG\fG\16G\u0335\13G\3G\3G\3"+ - "H\3H\5H\u033b\nH\3I\3I\5I\u033f\nI\3J\3J\3J\3J\3K\3K\3K\5K\u0348\nK\3"+ - "K\3K\3K\5K\u034d\nK\3K\3K\3K\3K\3L\3L\3L\3L\3L\3L\5L\u0359\nL\5L\u035b"+ - "\nL\3M\3M\3M\3M\7M\u0361\nM\fM\16M\u0364\13M\5M\u0366\nM\3M\3M\3M\3M\3"+ - "M\5M\u036d\nM\3N\3N\3N\5N\u0372\nN\3O\3O\3P\3P\3Q\3Q\3R\3R\3S\3S\3T\3"+ - "T\3U\3U\3V\3V\3W\3W\3X\3X\3Y\3Y\3Z\3Z\3[\3[\3\\\3\\\3]\3]\3^\3^\3^\3^"+ - "\3^\3^\3^\3^\3^\3^\3^\3^\3^\3^\5^\u03a0\n^\3_\3_\5_\u03a4\n_\3`\3`\3`"+ - "\5`\u03a9\n`\3a\3a\5a\u03ad\na\3b\3b\5b\u03b1\nb\3b\3b\3b\3c\3c\5c\u03b8"+ - "\nc\3c\3c\3d\3d\3e\3e\3f\3f\3f\2\2g\2\4\6\b\n\f\16\20\22\24\26\30\32\34"+ - "\36 \"$&(*,.\60\62\64\668:<>@BDFHJLNPRTVXZ\\^`bdfhjlnprtvxz|~\u0080\u0082"+ - "\u0084\u0086\u0088\u008a\u008c\u008e\u0090\u0092\u0094\u0096\u0098\u009a"+ - "\u009c\u009e\u00a0\u00a2\u00a4\u00a6\u00a8\u00aa\u00ac\u00ae\u00b0\u00b2"+ - "\u00b4\u00b6\u00b8\u00ba\u00bc\u00be\u00c0\u00c2\u00c4\u00c6\u00c8\u00ca"+ - "\2\13\3\2\t\n\3\2de\3\2\r\26\4\2\6\6$.\3\2\60\61\4\2##\62\64\4\2>?{{\4"+ - "\2\f\f}}\3\2O{\2\u03eb\2\u00cc\3\2\2\2\4\u00d4\3\2\2\2\6\u00da\3\2\2\2"+ - "\b\u00dd\3\2\2\2\n\u00ee\3\2\2\2\f\u00fd\3\2\2\2\16\u00ff\3\2\2\2\20\u0107"+ - "\3\2\2\2\22\u0109\3\2\2\2\24\u010e\3\2\2\2\26\u0112\3\2\2\2\30\u0118\3"+ - "\2\2\2\32\u012d\3\2\2\2\34\u0133\3\2\2\2\36\u0135\3\2\2\2 \u0148\3\2\2"+ - "\2\"\u0158\3\2\2\2$\u016b\3\2\2\2&\u0173\3\2\2\2(\u0179\3\2\2\2*\u0188"+ - "\3\2\2\2,\u018c\3\2\2\2.\u019c\3\2\2\2\60\u01a5\3\2\2\2\62\u01b5\3\2\2"+ - "\2\64\u01be\3\2\2\2\66\u01c6\3\2\2\28\u01c9\3\2\2\2:\u01d3\3\2\2\2<\u01e5"+ - "\3\2\2\2>\u01ef\3\2\2\2@\u01ff\3\2\2\2B\u0204\3\2\2\2D\u0211\3\2\2\2F"+ - "\u0219\3\2\2\2H\u0228\3\2\2\2J\u022f\3\2\2\2L\u023f\3\2\2\2N\u0250\3\2"+ - "\2\2P\u0259\3\2\2\2R\u0262\3\2\2\2T\u0275\3\2\2\2V\u027d\3\2\2\2X\u0286"+ - "\3\2\2\2Z\u028a\3\2\2\2\\\u028f\3\2\2\2^\u0297\3\2\2\2`\u029c\3\2\2\2"+ - "b\u02a4\3\2\2\2d\u02ac\3\2\2\2f\u02b2\3\2\2\2h\u02b8\3\2\2\2j\u02be\3"+ - "\2\2\2l\u02c4\3\2\2\2n\u02ca\3\2\2\2p\u02d7\3\2\2\2r\u02dc\3\2\2\2t\u02e4"+ - "\3\2\2\2v\u02ef\3\2\2\2x\u02f5\3\2\2\2z\u02f8\3\2\2\2|\u02fc\3\2\2\2~"+ - "\u0312\3\2\2\2\u0080\u0314\3\2\2\2\u0082\u0317\3\2\2\2\u0084\u031d\3\2"+ - "\2\2\u0086\u031f\3\2\2\2\u0088\u0324\3\2\2\2\u008a\u0329\3\2\2\2\u008c"+ - "\u032c\3\2\2\2\u008e\u033a\3\2\2\2\u0090\u033e\3\2\2\2\u0092\u0340\3\2"+ - "\2\2\u0094\u0344\3\2\2\2\u0096\u035a\3\2\2\2\u0098\u036c\3\2\2\2\u009a"+ - "\u0371\3\2\2\2\u009c\u0373\3\2\2\2\u009e\u0375\3\2\2\2\u00a0\u0377\3\2"+ - "\2\2\u00a2\u0379\3\2\2\2\u00a4\u037b\3\2\2\2\u00a6\u037d\3\2\2\2\u00a8"+ - "\u037f\3\2\2\2\u00aa\u0381\3\2\2\2\u00ac\u0383\3\2\2\2\u00ae\u0385\3\2"+ - "\2\2\u00b0\u0387\3\2\2\2\u00b2\u0389\3\2\2\2\u00b4\u038b\3\2\2\2\u00b6"+ - "\u038d\3\2\2\2\u00b8\u038f\3\2\2\2\u00ba\u039f\3\2\2\2\u00bc\u03a1\3\2"+ - "\2\2\u00be\u03a8\3\2\2\2\u00c0\u03ac\3\2\2\2\u00c2\u03b0\3\2\2\2\u00c4"+ - "\u03b5\3\2\2\2\u00c6\u03bb\3\2\2\2\u00c8\u03bd\3\2\2\2\u00ca\u03bf\3\2"+ - "\2\2\u00cc\u00cd\5\4\3\2\u00cd\u00ce\7\2\2\3\u00ce\3\3\2\2\2\u00cf\u00d0"+ - "\7z\2\2\u00d0\u00d1\7y\2\2\u00d1\u00d2\5\u00c8e\2\u00d2\u00d3\7\3\2\2"+ - "\u00d3\u00d5\3\2\2\2\u00d4\u00cf\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5\u00d8"+ - "\3\2\2\2\u00d6\u00d9\5\b\5\2\u00d7\u00d9\5\6\4\2\u00d8\u00d6\3\2\2\2\u00d8"+ - "\u00d7\3\2\2\2\u00d9\5\3\2\2\2\u00da\u00db\5\n\6\2\u00db\u00dc\5(\25\2"+ - "\u00dc\7\3\2\2\2\u00dd\u00de\7\4\2\2\u00de\u00df\7\5\2\2\u00df\u00e0\7"+ - "\u0086\2\2\u00e0\u00e1\7\6\2\2\u00e1\u00e2\5\u00c6d\2\u00e2\u00e3\7\3"+ - "\2\2\u00e3\u00e4\5\n\6\2\u00e4\t\3\2\2\2\u00e5\u00e9\5\f\7\2\u00e6\u00e9"+ - "\5\16\b\2\u00e7\u00e9\5\36\20\2\u00e8\u00e5\3\2\2\2\u00e8\u00e6\3\2\2"+ - "\2\u00e8\u00e7\3\2\2\2\u00e9\u00ea\3\2\2\2\u00ea\u00eb\7\3\2\2\u00eb\u00ed"+ - "\3\2\2\2\u00ec\u00e8\3\2\2\2\u00ed\u00f0\3\2\2\2\u00ee\u00ec\3\2\2\2\u00ee"+ - "\u00ef\3\2\2\2\u00ef\u00f6\3\2\2\2\u00f0\u00ee\3\2\2\2\u00f1\u00f2\5\20"+ - "\t\2\u00f2\u00f3\7\3\2\2\u00f3\u00f5\3\2\2\2\u00f4\u00f1\3\2\2\2\u00f5"+ - "\u00f8\3\2\2\2\u00f6\u00f4\3\2\2\2\u00f6\u00f7\3\2\2\2\u00f7\13\3\2\2"+ - "\2\u00f8\u00f6\3\2\2\2\u00f9\u00fe\5\22\n\2\u00fa\u00fe\5\24\13\2\u00fb"+ - "\u00fe\5\26\f\2\u00fc\u00fe\5\30\r\2\u00fd\u00f9\3\2\2\2\u00fd\u00fa\3"+ - "\2\2\2\u00fd\u00fb\3\2\2\2\u00fd\u00fc\3\2\2\2\u00fe\r\3\2\2\2\u00ff\u0100"+ - "\7\7\2\2\u0100\u0101\7\5\2\2\u0101\u0102\7\u0086\2\2\u0102\u0103\7\6\2"+ - "\2\u0103\u0104\5\u00c6d\2\u0104\17\3\2\2\2\u0105\u0108\5\"\22\2\u0106"+ - "\u0108\5 \21\2\u0107\u0105\3\2\2\2\u0107\u0106\3\2\2\2\u0108\21\3\2\2"+ - "\2\u0109\u010a\7\7\2\2\u010a\u010b\7j\2\2\u010b\u010c\7c\2\2\u010c\u010d"+ - "\5\u00c6d\2\u010d\23\3\2\2\2\u010e\u010f\7\7\2\2\u010f\u0110\7\b\2\2\u0110"+ - "\u0111\t\2\2\2\u0111\25\3\2\2\2\u0112\u0113\7\7\2\2\u0113\u0114\7j\2\2"+ - "\u0114\u0115\7T\2\2\u0115\u0116\7[\2\2\u0116\u0117\t\3\2\2\u0117\27\3"+ - "\2\2\2\u0118\u011d\7\7\2\2\u0119\u011a\7\13\2\2\u011a\u011e\5\32\16\2"+ - "\u011b\u011c\7j\2\2\u011c\u011e\7\13\2\2\u011d\u0119\3\2\2\2\u011d\u011b"+ - "\3\2\2\2\u011e\u0125\3\2\2\2\u011f\u0120\5\34\17\2\u0120\u0121\7\6\2\2"+ - "\u0121\u0122\5\u00c8e\2\u0122\u0124\3\2\2\2\u0123\u011f\3\2\2\2\u0124"+ - "\u0127\3\2\2\2\u0125\u0123\3\2\2\2\u0125\u0126\3\2\2\2\u0126\31\3\2\2"+ - "\2\u0127\u0125\3\2\2\2\u0128\u012b\7\u0086\2\2\u0129\u012b\5\u00caf\2"+ - "\u012a\u0128\3\2\2\2\u012a\u0129\3\2\2\2\u012b\u012c\3\2\2\2\u012c\u012e"+ - "\7\f\2\2\u012d\u012a\3\2\2\2\u012d\u012e\3\2\2\2\u012e\u0131\3\2\2\2\u012f"+ - "\u0132\5\u00c0a\2\u0130\u0132\5\u00caf\2\u0131\u012f\3\2\2\2\u0131\u0130"+ - "\3\2\2\2\u0132\33\3\2\2\2\u0133\u0134\t\4\2\2\u0134\35\3\2\2\2\u0135\u0136"+ - "\7\27\2\2\u0136\u013a\7\4\2\2\u0137\u0138\7\5\2\2\u0138\u0139\7\u0086"+ - "\2\2\u0139\u013b\7\6\2\2\u013a\u0137\3\2\2\2\u013a\u013b\3\2\2\2\u013b"+ - "\u013c\3\2\2\2\u013c\u0146\5\u00c6d\2\u013d\u013e\7Y\2\2\u013e\u0143\5"+ - "\u00c6d\2\u013f\u0140\7\30\2\2\u0140\u0142\5\u00c6d\2\u0141\u013f\3\2"+ - "\2\2\u0142\u0145\3\2\2\2\u0143\u0141\3\2\2\2\u0143\u0144\3\2\2\2\u0144"+ - "\u0147\3\2\2\2\u0145\u0143\3\2\2\2\u0146\u013d\3\2\2\2\u0146\u0147\3\2"+ - "\2\2\u0147\37\3\2\2\2\u0148\u0149\7\7\2\2\u0149\u014a\7\31\2\2\u014a\u014d"+ - "\5\u0080A\2\u014b\u014c\7X\2\2\u014c\u014e\5\u0096L\2\u014d\u014b\3\2"+ - "\2\2\u014d\u014e\3\2\2\2\u014e\u0156\3\2\2\2\u014f\u0150\7\32\2\2\u0150"+ - "\u0157\5*\26\2\u0151\u0154\7\33\2\2\u0152\u0153\7\32\2\2\u0153\u0155\5"+ - "*\26\2\u0154\u0152\3\2\2\2\u0154\u0155\3\2\2\2\u0155\u0157\3\2\2\2\u0156"+ - "\u014f\3\2\2\2\u0156\u0151\3\2\2\2\u0157!\3\2\2\2\u0158\u0159\7\7\2\2"+ - "\u0159\u015a\7\34\2\2\u015a\u015b\5\32\16\2\u015b\u015d\7\35\2\2\u015c"+ - "\u015e\5$\23\2\u015d\u015c\3\2\2\2\u015d\u015e\3\2\2\2\u015e\u015f\3\2"+ - "\2\2\u015f\u0162\7\36\2\2\u0160\u0161\7X\2\2\u0161\u0163\5\u0096L\2\u0162"+ - "\u0160\3\2\2\2\u0162\u0163\3\2\2\2\u0163\u0169\3\2\2\2\u0164\u0165\7\37"+ - "\2\2\u0165\u0166\5(\25\2\u0166\u0167\7 \2\2\u0167\u016a\3\2\2\2\u0168"+ - "\u016a\7\33\2\2\u0169\u0164\3\2\2\2\u0169\u0168\3\2\2\2\u016a#\3\2\2\2"+ - "\u016b\u0170\5&\24\2\u016c\u016d\7\30\2\2\u016d\u016f\5&\24\2\u016e\u016c"+ - "\3\2\2\2\u016f\u0172\3\2\2\2\u0170\u016e\3\2\2\2\u0170\u0171\3\2\2\2\u0171"+ - "%\3\2\2\2\u0172\u0170\3\2\2\2\u0173\u0174\7!\2\2\u0174\u0177\5\32\16\2"+ - "\u0175\u0176\7X\2\2\u0176\u0178\5\u0096L\2\u0177\u0175\3\2\2\2\u0177\u0178"+ - "\3\2\2\2\u0178\'\3\2\2\2\u0179\u017e\5*\26\2\u017a\u017b\7\30\2\2\u017b"+ - "\u017d\5*\26\2\u017c\u017a\3\2\2\2\u017d\u0180\3\2\2\2\u017e\u017c\3\2"+ - "\2\2\u017e\u017f\3\2\2\2\u017f)\3\2\2\2\u0180\u017e\3\2\2\2\u0181\u0189"+ - "\5,\27\2\u0182\u0189\5B\"\2\u0183\u0189\5F$\2\u0184\u0189\5J&\2\u0185"+ - "\u0189\5N(\2\u0186\u0189\5P)\2\u0187\u0189\5T+\2\u0188\u0181\3\2\2\2\u0188"+ - "\u0182\3\2\2\2\u0188\u0183\3\2\2\2\u0188\u0184\3\2\2\2\u0188\u0185\3\2"+ - "\2\2\u0188\u0186\3\2\2\2\u0188\u0187\3\2\2\2\u0189+\3\2\2\2\u018a\u018d"+ - "\5.\30\2\u018b\u018d\5\62\32\2\u018c\u018a\3\2\2\2\u018c\u018b\3\2\2\2"+ - "\u018d\u0196\3\2\2\2\u018e\u0195\5.\30\2\u018f\u0195\5\66\34\2\u0190\u0195"+ - "\5\62\32\2\u0191\u0195\58\35\2\u0192\u0195\5<\37\2\u0193\u0195\5@!\2\u0194"+ - "\u018e\3\2\2\2\u0194\u018f\3\2\2\2\u0194\u0190\3\2\2\2\u0194\u0191\3\2"+ - "\2\2\u0194\u0192\3\2\2\2\u0194\u0193\3\2\2\2\u0195\u0198\3\2\2\2\u0196"+ - "\u0194\3\2\2\2\u0196\u0197\3\2\2\2\u0197\u0199\3\2\2\2\u0198\u0196\3\2"+ - "\2\2\u0199\u019a\7U\2\2\u019a\u019b\5*\26\2\u019b-\3\2\2\2\u019c\u019d"+ - "\7O\2\2\u019d\u01a2\5\60\31\2\u019e\u019f\7\30\2\2\u019f\u01a1\5\60\31"+ - "\2\u01a0\u019e\3\2\2\2\u01a1\u01a4\3\2\2\2\u01a2\u01a0\3\2\2\2\u01a2\u01a3"+ - "\3\2\2\2\u01a3/\3\2\2\2\u01a4\u01a2\3\2\2\2\u01a5\u01a8\5\u0080A\2\u01a6"+ - "\u01a7\7X\2\2\u01a7\u01a9\5\u0096L\2\u01a8\u01a6\3\2\2\2\u01a8\u01a9\3"+ - "\2\2\2\u01a9\u01ac\3\2\2\2\u01aa\u01ab\7Z\2\2\u01ab\u01ad\7[\2\2\u01ac"+ - "\u01aa\3\2\2\2\u01ac\u01ad\3\2\2\2\u01ad\u01b0\3\2\2\2\u01ae\u01af\7Y"+ - "\2\2\u01af\u01b1\5\u0080A\2\u01b0\u01ae\3\2\2\2\u01b0\u01b1\3\2\2\2\u01b1"+ - "\u01b2\3\2\2\2\u01b2\u01b3\7W\2\2\u01b3\u01b4\5*\26\2\u01b4\61\3\2\2\2"+ - "\u01b5\u01b6\7P\2\2\u01b6\u01bb\5\64\33\2\u01b7\u01b8\7\30\2\2\u01b8\u01ba"+ - "\5\64\33\2\u01b9\u01b7\3\2\2\2\u01ba\u01bd\3\2\2\2\u01bb\u01b9\3\2\2\2"+ - "\u01bb\u01bc\3\2\2\2\u01bc\63\3\2\2\2\u01bd\u01bb\3\2\2\2\u01be\u01c1"+ - "\5\u0080A\2\u01bf\u01c0\7X\2\2\u01c0\u01c2\5\u0096L\2\u01c1\u01bf\3\2"+ - "\2\2\u01c1\u01c2\3\2\2\2\u01c2\u01c3\3\2\2\2\u01c3\u01c4\7\32\2\2\u01c4"+ - "\u01c5\5*\26\2\u01c5\65\3\2\2\2\u01c6\u01c7\7Q\2\2\u01c7\u01c8\5*\26\2"+ - "\u01c8\67\3\2\2\2\u01c9\u01ca\7R\2\2\u01ca\u01cb\7S\2\2\u01cb\u01d0\5"+ - ":\36\2\u01cc\u01cd\7\30\2\2\u01cd\u01cf\5:\36\2\u01ce\u01cc\3\2\2\2\u01cf"+ - "\u01d2\3\2\2\2\u01d0\u01ce\3\2\2\2\u01d0\u01d1\3\2\2\2\u01d19\3\2\2\2"+ - "\u01d2\u01d0\3\2\2\2\u01d3\u01da\5\u0080A\2\u01d4\u01d5\7X\2\2\u01d5\u01d7"+ - "\5\u0096L\2\u01d6\u01d4\3\2\2\2\u01d6\u01d7\3\2\2\2\u01d7\u01d8\3\2\2"+ - "\2\u01d8\u01d9\7\32\2\2\u01d9\u01db\5*\26\2\u01da\u01d6\3\2\2\2\u01da"+ - "\u01db\3\2\2\2\u01db\u01de\3\2\2\2\u01dc\u01dd\7c\2\2\u01dd\u01df\5\u00c6"+ - "d\2\u01de\u01dc\3\2\2\2\u01de\u01df\3\2\2\2\u01df;\3\2\2\2\u01e0\u01e1"+ - "\7T\2\2\u01e1\u01e6\7S\2\2\u01e2\u01e3\7]\2\2\u01e3\u01e4\7T\2\2\u01e4"+ - "\u01e6\7S\2\2\u01e5\u01e0\3\2\2\2\u01e5\u01e2\3\2\2\2\u01e6\u01e7\3\2"+ - "\2\2\u01e7\u01ec\5> \2\u01e8\u01e9\7\30\2\2\u01e9\u01eb\5> \2\u01ea\u01e8"+ - "\3\2\2\2\u01eb\u01ee\3\2\2\2\u01ec\u01ea\3\2\2\2\u01ec\u01ed\3\2\2\2\u01ed"+ - "=\3\2\2\2\u01ee\u01ec\3\2\2\2\u01ef\u01f2\5*\26\2\u01f0\u01f3\7^\2\2\u01f1"+ - "\u01f3\7_\2\2\u01f2\u01f0\3\2\2\2\u01f2\u01f1\3\2\2\2\u01f2\u01f3\3\2"+ - "\2\2\u01f3\u01f9\3\2\2\2\u01f4\u01f7\7[\2\2\u01f5\u01f8\7d\2\2\u01f6\u01f8"+ - "\7e\2\2\u01f7\u01f5\3\2\2\2\u01f7\u01f6\3\2\2\2\u01f8\u01fa\3\2\2\2\u01f9"+ - "\u01f4\3\2\2\2\u01f9\u01fa\3\2\2\2\u01fa\u01fd\3\2\2\2\u01fb\u01fc\7c"+ - "\2\2\u01fc\u01fe\5\u00c6d\2\u01fd\u01fb\3\2\2\2\u01fd\u01fe\3\2\2\2\u01fe"+ - "?\3\2\2\2\u01ff\u0200\7\\\2\2\u0200\u0201\5\u0080A\2\u0201A\3\2\2\2\u0202"+ - "\u0205\7`\2\2\u0203\u0205\7a\2\2\u0204\u0202\3\2\2\2\u0204\u0203\3\2\2"+ - "\2\u0205\u0206\3\2\2\2\u0206\u020b\5D#\2\u0207\u0208\7\30\2\2\u0208\u020a"+ - "\5D#\2\u0209\u0207\3\2\2\2\u020a\u020d\3\2\2\2\u020b\u0209\3\2\2\2\u020b"+ - "\u020c\3\2\2\2\u020c\u020e\3\2\2\2\u020d\u020b\3\2\2\2\u020e\u020f\7b"+ - "\2\2\u020f\u0210\5*\26\2\u0210C\3\2\2\2\u0211\u0214\5\u0080A\2\u0212\u0213"+ - "\7X\2\2\u0213\u0215\5\u0096L\2\u0214\u0212\3\2\2\2\u0214\u0215\3\2\2\2"+ - "\u0215\u0216\3\2\2\2\u0216\u0217\7W\2\2\u0217\u0218\5*\26\2\u0218E\3\2"+ - "\2\2\u0219\u021a\7f\2\2\u021a\u021b\7\35\2\2\u021b\u021c\5(\25\2\u021c"+ - "\u021e\7\36\2\2\u021d\u021f\5H%\2\u021e\u021d\3\2\2\2\u021f\u0220\3\2"+ - "\2\2\u0220\u021e\3\2\2\2\u0220\u0221\3\2\2\2\u0221\u0222\3\2\2\2\u0222"+ - "\u0223\7j\2\2\u0223\u0224\7U\2\2\u0224\u0225\5*\26\2\u0225G\3\2\2\2\u0226"+ - "\u0227\7g\2\2\u0227\u0229\5*\26\2\u0228\u0226\3\2\2\2\u0229\u022a\3\2"+ - "\2\2\u022a\u0228\3\2\2\2\u022a\u022b\3\2\2\2\u022b\u022c\3\2\2\2\u022c"+ - "\u022d\7U\2\2\u022d\u022e\5*\26\2\u022eI\3\2\2\2\u022f\u0230\7m\2\2\u0230"+ - "\u0231\7\35\2\2\u0231\u0232\5(\25\2\u0232\u0234\7\36\2\2\u0233\u0235\5"+ - "L\'\2\u0234\u0233\3\2\2\2\u0235\u0236\3\2\2\2\u0236\u0234\3\2\2\2\u0236"+ - "\u0237\3\2\2\2\u0237\u0238\3\2\2\2\u0238\u023a\7j\2\2\u0239\u023b\5\u0080"+ - "A\2\u023a\u0239\3\2\2\2\u023a\u023b\3\2\2\2\u023b\u023c\3\2\2\2\u023c"+ - "\u023d\7U\2\2\u023d\u023e\5*\26\2\u023eK\3\2\2\2\u023f\u0243\7g\2\2\u0240"+ - "\u0241\5\u0080A\2\u0241\u0242\7X\2\2\u0242\u0244\3\2\2\2\u0243\u0240\3"+ - "\2\2\2\u0243\u0244\3\2\2\2\u0244\u0245\3\2\2\2\u0245\u024a\5\u0096L\2"+ - "\u0246\u0247\7\"\2\2\u0247\u0249\5\u0096L\2\u0248\u0246\3\2\2\2\u0249"+ - "\u024c\3\2\2\2\u024a\u0248\3\2\2\2\u024a\u024b\3\2\2\2\u024b\u024d\3\2"+ - "\2\2\u024c\u024a\3\2\2\2\u024d\u024e\7U\2\2\u024e\u024f\5*\26\2\u024f"+ - "M\3\2\2\2\u0250\u0251\7V\2\2\u0251\u0252\7\35\2\2\u0252\u0253\5(\25\2"+ - "\u0253\u0254\7\36\2\2\u0254\u0255\7k\2\2\u0255\u0256\5*\26\2\u0256\u0257"+ - "\7l\2\2\u0257\u0258\5*\26\2\u0258O\3\2\2\2\u0259\u025a\7h\2\2\u025a\u025b"+ - "\7\37\2\2\u025b\u025c\5(\25\2\u025c\u025e\7 \2\2\u025d\u025f\5R*\2\u025e"+ - "\u025d\3\2\2\2\u025f\u0260\3\2\2\2\u0260\u025e\3\2\2\2\u0260\u0261\3\2"+ - "\2\2\u0261Q\3\2\2\2\u0262\u0265\7i\2\2\u0263\u0266\7#\2\2\u0264\u0266"+ - "\5\32\16\2\u0265\u0263\3\2\2\2\u0265\u0264\3\2\2\2\u0266\u026e\3\2\2\2"+ - "\u0267\u026a\7\"\2\2\u0268\u026b\7#\2\2\u0269\u026b\5\32\16\2\u026a\u0268"+ - "\3\2\2\2\u026a\u0269\3\2\2\2\u026b\u026d\3\2\2\2\u026c\u0267\3\2\2\2\u026d"+ - "\u0270\3\2\2\2\u026e\u026c\3\2\2\2\u026e\u026f\3\2\2\2\u026f\u0271\3\2"+ - "\2\2\u0270\u026e\3\2\2\2\u0271\u0272\7\37\2\2\u0272\u0273\5(\25\2\u0273"+ - "\u0274\7 \2\2\u0274S\3\2\2\2\u0275\u027a\5V,\2\u0276\u0277\7n\2\2\u0277"+ - "\u0279\5V,\2\u0278\u0276\3\2\2\2\u0279\u027c\3\2\2\2\u027a\u0278\3\2\2"+ - "\2\u027a\u027b\3\2\2\2\u027bU\3\2\2\2\u027c\u027a\3\2\2\2\u027d\u0282"+ - "\5X-\2\u027e\u027f\7o\2\2\u027f\u0281\5X-\2\u0280\u027e\3\2\2\2\u0281"+ - "\u0284\3\2\2\2\u0282\u0280\3\2\2\2\u0282\u0283\3\2\2\2\u0283W\3\2\2\2"+ - "\u0284\u0282\3\2\2\2\u0285\u0287\7p\2\2\u0286\u0285\3\2\2\2\u0286\u0287"+ - "\3\2\2\2\u0287\u0288\3\2\2\2\u0288\u0289\5Z.\2\u0289Y\3\2\2\2\u028a\u028d"+ - "\5\\/\2\u028b\u028c\t\5\2\2\u028c\u028e\5\\/\2\u028d\u028b\3\2\2\2\u028d"+ - "\u028e\3\2\2\2\u028e[\3\2\2\2\u028f\u0294\5^\60\2\u0290\u0291\7/\2\2\u0291"+ - "\u0293\5^\60\2\u0292\u0290\3\2\2\2\u0293\u0296\3\2\2\2\u0294\u0292\3\2"+ - "\2\2\u0294\u0295\3\2\2\2\u0295]\3\2\2\2\u0296\u0294\3\2\2\2\u0297\u029a"+ - "\5`\61\2\u0298\u0299\7q\2\2\u0299\u029b\5`\61\2\u029a\u0298\3\2\2\2\u029a"+ - "\u029b\3\2\2\2\u029b_\3\2\2\2\u029c\u02a1\5b\62\2\u029d\u029e\t\6\2\2"+ - "\u029e\u02a0\5b\62\2\u029f\u029d\3\2\2\2\u02a0\u02a3\3\2\2\2\u02a1\u029f"+ - "\3\2\2\2\u02a1\u02a2\3\2\2\2\u02a2a\3\2\2\2\u02a3\u02a1\3\2\2\2\u02a4"+ - "\u02a9\5d\63\2\u02a5\u02a6\t\7\2\2\u02a6\u02a8\5d\63\2\u02a7\u02a5\3\2"+ - "\2\2\u02a8\u02ab\3\2\2\2\u02a9\u02a7\3\2\2\2\u02a9\u02aa\3\2\2\2\u02aa"+ - "c\3\2\2\2\u02ab\u02a9\3\2\2\2\u02ac\u02b0\5f\64\2\u02ad\u02ae\7r\2\2\u02ae"+ - "\u02af\7s\2\2\u02af\u02b1\5\u0096L\2\u02b0\u02ad\3\2\2\2\u02b0\u02b1\3"+ - "\2\2\2\u02b1e\3\2\2\2\u02b2\u02b6\5h\65\2\u02b3\u02b4\7u\2\2\u02b4\u02b5"+ - "\7t\2\2\u02b5\u02b7\5\u0096L\2\u02b6\u02b3\3\2\2\2\u02b6\u02b7\3\2\2\2"+ - "\u02b7g\3\2\2\2\u02b8\u02bc\5j\66\2\u02b9\u02ba\7v\2\2\u02ba\u02bb\7X"+ - "\2\2\u02bb\u02bd\5\u0096L\2\u02bc\u02b9\3\2\2\2\u02bc\u02bd\3\2\2\2\u02bd"+ - "i\3\2\2\2\u02be\u02c2\5l\67\2\u02bf\u02c0\7x\2\2\u02c0\u02c1\7X\2\2\u02c1"+ - "\u02c3\5\u00bc_\2\u02c2\u02bf\3\2\2\2\u02c2\u02c3\3\2\2\2\u02c3k\3\2\2"+ - "\2\u02c4\u02c8\5n8\2\u02c5\u02c6\7w\2\2\u02c6\u02c7\7X\2\2\u02c7\u02c9"+ - "\5\u00bc_\2\u02c8\u02c5\3\2\2\2\u02c8\u02c9\3\2\2\2\u02c9m\3\2\2\2\u02ca"+ - "\u02d1\5p9\2\u02cb\u02cc\7\6\2\2\u02cc\u02cd\7-\2\2\u02cd\u02ce\3\2\2"+ - "\2\u02ce\u02d0\5\u008aF\2\u02cf\u02cb\3\2\2\2\u02d0\u02d3\3\2\2\2\u02d1"+ - "\u02cf\3\2\2\2\u02d1\u02d2\3\2\2\2\u02d2o\3\2\2\2\u02d3\u02d1\3\2\2\2"+ - "\u02d4\u02d6\t\6\2\2\u02d5\u02d4\3\2\2\2\u02d6\u02d9\3\2\2\2\u02d7\u02d5"+ - "\3\2\2\2\u02d7\u02d8\3\2\2\2\u02d8\u02da\3\2\2\2\u02d9\u02d7\3\2\2\2\u02da"+ - "\u02db\5r:\2\u02dbq\3\2\2\2\u02dc\u02e1\5t;\2\u02dd\u02de\7\65\2\2\u02de"+ - "\u02e0\5t;\2\u02df\u02dd\3\2\2\2\u02e0\u02e3\3\2\2\2\u02e1\u02df\3\2\2"+ - "\2\u02e1\u02e2\3\2\2\2\u02e2s\3\2\2\2\u02e3\u02e1\3\2\2\2\u02e4\u02ec"+ - "\5~@\2\u02e5\u02eb\5v<\2\u02e6\u02eb\5z>\2\u02e7\u02eb\5|?\2\u02e8\u02eb"+ - "\5x=\2\u02e9\u02eb\5\u008cG\2\u02ea\u02e5\3\2\2\2\u02ea\u02e6\3\2\2\2"+ - "\u02ea\u02e7\3\2\2\2\u02ea\u02e8\3\2\2\2\u02ea\u02e9\3\2\2\2\u02eb\u02ee"+ - "\3\2\2\2\u02ec\u02ea\3\2\2\2\u02ec\u02ed\3\2\2\2\u02edu\3\2\2\2\u02ee"+ - "\u02ec\3\2\2\2\u02ef\u02f0\7\66\2\2\u02f0\u02f1\7\66\2\2\u02f1\u02f2\5"+ - "(\25\2\u02f2\u02f3\7\67\2\2\u02f3\u02f4\7\67\2\2\u02f4w\3\2\2\2\u02f5"+ - "\u02f6\7\66\2\2\u02f6\u02f7\7\67\2\2\u02f7y\3\2\2\2\u02f8\u02f9\7\66\2"+ - "\2\u02f9\u02fa\5(\25\2\u02fa\u02fb\7\67\2\2\u02fb{\3\2\2\2\u02fc\u0304"+ - "\78\2\2\u02fd\u0305\5\u00caf\2\u02fe\u0305\5\u00c8e\2\u02ff\u0305\7\u0086"+ - "\2\2\u0300\u0305\5\u0082B\2\u0301\u0305\5\u0080A\2\u0302\u0305\5\u0084"+ - "C\2\u0303\u0305\5\u00ba^\2\u0304\u02fd\3\2\2\2\u0304\u02fe\3\2\2\2\u0304"+ - "\u02ff\3\2\2\2\u0304\u0300\3\2\2\2\u0304\u0301\3\2\2\2\u0304\u0302\3\2"+ - "\2\2\u0304\u0303\3\2\2\2\u0305}\3\2\2\2\u0306\u0313\7~\2\2\u0307\u0313"+ - "\7\177\2\2\u0308\u0313\5\u00c8e\2\u0309\u0313\5\u0080A\2\u030a\u0313\5"+ - "\u0082B\2\u030b\u0313\5\u0084C\2\u030c\u0313\5\u0098M\2\u030d\u0313\5"+ - "\u008aF\2\u030e\u0313\5\u0086D\2\u030f\u0313\5\u0088E\2\u0310\u0313\5"+ - "\u00c4c\2\u0311\u0313\5\u0090I\2\u0312\u0306\3\2\2\2\u0312\u0307\3\2\2"+ - "\2\u0312\u0308\3\2\2\2\u0312\u0309\3\2\2\2\u0312\u030a\3\2\2\2\u0312\u030b"+ - "\3\2\2\2\u0312\u030c\3\2\2\2\u0312\u030d\3\2\2\2\u0312\u030e\3\2\2\2\u0312"+ - "\u030f\3\2\2\2\u0312\u0310\3\2\2\2\u0312\u0311\3\2\2\2\u0313\177\3\2\2"+ - "\2\u0314\u0315\7!\2\2\u0315\u0316\5\32\16\2\u0316\u0081\3\2\2\2\u0317"+ - "\u0319\7\35\2\2\u0318\u031a\5(\25\2\u0319\u0318\3\2\2\2\u0319\u031a\3"+ - "\2\2\2\u031a\u031b\3\2\2\2\u031b\u031c\7\36\2\2\u031c\u0083\3\2\2\2\u031d"+ - "\u031e\79\2\2\u031e\u0085\3\2\2\2\u031f\u0320\7\t\2\2\u0320\u0321\7\37"+ - "\2\2\u0321\u0322\5(\25\2\u0322\u0323\7 \2\2\u0323\u0087\3\2\2\2\u0324"+ - "\u0325\7\n\2\2\u0325\u0326\7\37\2\2\u0326\u0327\5(\25\2\u0327\u0328\7"+ - " \2\2\u0328\u0089\3\2\2\2\u0329\u032a\5\32\16\2\u032a\u032b\5\u008cG\2"+ - "\u032b\u008b\3\2\2\2\u032c\u0333\7\35\2\2\u032d\u032f\5\u008eH\2\u032e"+ - "\u0330\7\30\2\2\u032f\u032e\3\2\2\2\u032f\u0330\3\2\2\2\u0330\u0332\3"+ - "\2\2\2\u0331\u032d\3\2\2\2\u0332\u0335\3\2\2\2\u0333\u0331\3\2\2\2\u0333"+ - "\u0334\3\2\2\2\u0334\u0336\3\2\2\2\u0335\u0333\3\2\2\2\u0336\u0337\7\36"+ - "\2\2\u0337\u008d\3\2\2\2\u0338\u033b\5*\26\2\u0339\u033b\7}\2\2\u033a"+ - "\u0338\3\2\2\2\u033a\u0339\3\2\2\2\u033b\u008f\3\2\2\2\u033c\u033f\5\u0092"+ - "J\2\u033d\u033f\5\u0094K\2\u033e\u033c\3\2\2\2\u033e\u033d\3\2\2\2\u033f"+ - "\u0091\3\2\2\2\u0340\u0341\5\32\16\2\u0341\u0342\7:\2\2\u0342\u0343\7"+ - "\177\2\2\u0343\u0093\3\2\2\2\u0344\u0345\7\34\2\2\u0345\u0347\7\35\2\2"+ - "\u0346\u0348\5$\23\2\u0347\u0346\3\2\2\2\u0347\u0348\3\2\2\2\u0348\u0349"+ - "\3\2\2\2\u0349\u034c\7\36\2\2\u034a\u034b\7X\2\2\u034b\u034d\5\u0096L"+ - "\2\u034c\u034a\3\2\2\2\u034c\u034d\3\2\2\2\u034d\u034e\3\2\2\2\u034e\u034f"+ - "\7\37\2\2\u034f\u0350\5(\25\2\u0350\u0351\7 \2\2\u0351\u0095\3\2\2\2\u0352"+ - "\u0353\7\35\2\2\u0353\u035b\7\36\2\2\u0354\u0358\5\u009aN\2\u0355\u0359"+ - "\7}\2\2\u0356\u0359\7#\2\2\u0357\u0359\7\60\2\2\u0358\u0355\3\2\2\2\u0358"+ - "\u0356\3\2\2\2\u0358\u0357\3\2\2\2\u0358\u0359\3\2\2\2\u0359\u035b\3\2"+ - "\2\2\u035a\u0352\3\2\2\2\u035a\u0354\3\2\2\2\u035b\u0097\3\2\2\2\u035c"+ - "\u0365\7\37\2\2\u035d\u0362\5\u00c2b\2\u035e\u035f\7\30\2\2\u035f\u0361"+ - "\5\u00c2b\2\u0360\u035e\3\2\2\2\u0361\u0364\3\2\2\2\u0362\u0360\3\2\2"+ - "\2\u0362\u0363\3\2\2\2\u0363\u0366\3\2\2\2\u0364\u0362\3\2\2\2\u0365\u035d"+ - "\3\2\2\2\u0365\u0366\3\2\2\2\u0366\u0367\3\2\2\2\u0367\u036d\7 \2\2\u0368"+ - "\u0369\7;\2\2\u0369\u036a\5(\25\2\u036a\u036b\7<\2\2\u036b\u036d\3\2\2"+ - "\2\u036c\u035c\3\2\2\2\u036c\u0368\3\2\2\2\u036d\u0099\3\2\2\2\u036e\u0372"+ - "\7=\2\2\u036f\u0372\5\u009cO\2\u0370\u0372\5\u00be`\2\u0371\u036e\3\2"+ - "\2\2\u0371\u036f\3\2\2\2\u0371\u0370\3\2\2\2\u0372\u009b\3\2\2\2\u0373"+ - "\u0374\t\b\2\2\u0374\u009d\3\2\2\2\u0375\u0376\7@\2\2\u0376\u009f\3\2"+ - "\2\2\u0377\u0378\7A\2\2\u0378\u00a1\3\2\2\2\u0379\u037a\7B\2\2\u037a\u00a3"+ - "\3\2\2\2\u037b\u037c\7C\2\2\u037c\u00a5\3\2\2\2\u037d\u037e\7D\2\2\u037e"+ - "\u00a7\3\2\2\2\u037f\u0380\7E\2\2\u0380\u00a9\3\2\2\2\u0381\u0382\7F\2"+ - "\2\u0382\u00ab\3\2\2\2\u0383\u0384\7G\2\2\u0384\u00ad\3\2\2\2\u0385\u0386"+ - "\7H\2\2\u0386\u00af\3\2\2\2\u0387\u0388\7I\2\2\u0388\u00b1\3\2\2\2\u0389"+ - "\u038a\7J\2\2\u038a\u00b3\3\2\2\2\u038b\u038c\7K\2\2\u038c\u00b5\3\2\2"+ - "\2\u038d\u038e\7L\2\2\u038e\u00b7\3\2\2\2\u038f\u0390\7M\2\2\u0390\u00b9"+ - "\3\2\2\2\u0391\u03a0\5\u009eP\2\u0392\u03a0\5\u00a0Q\2\u0393\u03a0\5\u00a2"+ - "R\2\u0394\u03a0\5\u00a4S\2\u0395\u03a0\5\u00a6T\2\u0396\u03a0\5\u00a8"+ - "U\2\u0397\u03a0\5\u00aaV\2\u0398\u03a0\5\u00acW\2\u0399\u03a0\5\u00b2"+ - "Z\2\u039a\u03a0\5\u00b4[\2\u039b\u03a0\5\u00b6\\\2\u039c\u03a0\5\u00ae"+ - "X\2\u039d\u03a0\5\u00b0Y\2\u039e\u03a0\5\u00b8]\2\u039f\u0391\3\2\2\2"+ - "\u039f\u0392\3\2\2\2\u039f\u0393\3\2\2\2\u039f\u0394\3\2\2\2\u039f\u0395"+ - "\3\2\2\2\u039f\u0396\3\2\2\2\u039f\u0397\3\2\2\2\u039f\u0398\3\2\2\2\u039f"+ - "\u0399\3\2\2\2\u039f\u039a\3\2\2\2\u039f\u039b\3\2\2\2\u039f\u039c\3\2"+ - "\2\2\u039f\u039d\3\2\2\2\u039f\u039e\3\2\2\2\u03a0\u00bb\3\2\2\2\u03a1"+ - "\u03a3\5\u00be`\2\u03a2\u03a4\7}\2\2\u03a3\u03a2\3\2\2\2\u03a3\u03a4\3"+ - "\2\2\2\u03a4\u00bd\3\2\2\2\u03a5\u03a9\7N\2\2\u03a6\u03a9\5\u00ba^\2\u03a7"+ - "\u03a9\7~\2\2\u03a8\u03a5\3\2\2\2\u03a8\u03a6\3\2\2\2\u03a8\u03a7\3\2"+ - "\2\2\u03a9\u00bf\3\2\2\2\u03aa\u03ad\7\u0086\2\2\u03ab\u03ad\5\u00ba^"+ - "\2\u03ac\u03aa\3\2\2\2\u03ac\u03ab\3\2\2\2\u03ad\u00c1\3\2\2\2\u03ae\u03b1"+ - "\5*\26\2\u03af\u03b1\7\u0086\2\2\u03b0\u03ae\3\2\2\2\u03b0\u03af\3\2\2"+ - "\2\u03b1\u03b2\3\2\2\2\u03b2\u03b3\t\t\2\2\u03b3\u03b4\5*\26\2\u03b4\u00c3"+ - "\3\2\2\2\u03b5\u03b7\7\66\2\2\u03b6\u03b8\5(\25\2\u03b7\u03b6\3\2\2\2"+ - "\u03b7\u03b8\3\2\2\2\u03b8\u03b9\3\2\2\2\u03b9\u03ba\7\67\2\2\u03ba\u00c5"+ - "\3\2\2\2\u03bb\u03bc\5\u00c8e\2\u03bc\u00c7\3\2\2\2\u03bd\u03be\7|\2\2"+ - "\u03be\u00c9\3\2\2\2\u03bf\u03c0\t\n\2\2\u03c0\u00cb\3\2\2\2b\u00d4\u00d8"+ - "\u00e8\u00ee\u00f6\u00fd\u0107\u011d\u0125\u012a\u012d\u0131\u013a\u0143"+ - "\u0146\u014d\u0154\u0156\u015d\u0162\u0169\u0170\u0177\u017e\u0188\u018c"+ - "\u0194\u0196\u01a2\u01a8\u01ac\u01b0\u01bb\u01c1\u01d0\u01d6\u01da\u01de"+ - "\u01e5\u01ec\u01f2\u01f7\u01f9\u01fd\u0204\u020b\u0214\u0220\u022a\u0236"+ - "\u023a\u0243\u024a\u0260\u0265\u026a\u026e\u027a\u0282\u0286\u028d\u0294"+ - "\u029a\u02a1\u02a9\u02b0\u02b6\u02bc\u02c2\u02c8\u02d1\u02d7\u02e1\u02ea"+ - "\u02ec\u0304\u0312\u0319\u032f\u0333\u033a\u033e\u0347\u034c\u0358\u035a"+ - "\u0362\u0365\u036c\u0371\u039f\u03a3\u03a8\u03ac\u03b0\u03b7"; + "`\t`\4a\ta\4b\tb\4c\tc\4d\td\4e\te\4f\tf\4g\tg\4h\th\4i\ti\3\2\3\2\3\2"+ + "\3\3\3\3\3\3\3\3\3\3\5\3\u00db\n\3\3\3\3\3\5\3\u00df\n\3\3\4\3\4\3\4\3"+ + "\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\5\6\u00ef\n\6\3\6\3\6\7\6\u00f3"+ + "\n\6\f\6\16\6\u00f6\13\6\3\6\3\6\3\6\7\6\u00fb\n\6\f\6\16\6\u00fe\13\6"+ + "\3\7\3\7\3\7\3\7\5\7\u0104\n\7\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3\t\5\t\u010e"+ + "\n\t\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3"+ + "\r\3\r\3\r\3\r\3\r\5\r\u0124\n\r\3\r\3\r\3\r\3\r\7\r\u012a\n\r\f\r\16"+ + "\r\u012d\13\r\3\16\3\16\5\16\u0131\n\16\3\16\5\16\u0134\n\16\3\16\3\16"+ + "\5\16\u0138\n\16\3\17\3\17\3\20\3\20\3\20\3\20\3\20\5\20\u0141\n\20\3"+ + "\20\3\20\3\20\3\20\3\20\7\20\u0148\n\20\f\20\16\20\u014b\13\20\5\20\u014d"+ + "\n\20\3\21\3\21\3\21\3\21\3\21\5\21\u0154\n\21\3\21\3\21\3\21\3\21\3\21"+ + "\5\21\u015b\n\21\5\21\u015d\n\21\3\22\3\22\3\22\3\22\3\22\5\22\u0164\n"+ + "\22\3\22\3\22\3\22\5\22\u0169\n\22\3\22\3\22\3\22\3\22\3\22\5\22\u0170"+ + "\n\22\3\23\3\23\3\23\7\23\u0175\n\23\f\23\16\23\u0178\13\23\3\24\3\24"+ + "\3\24\3\24\5\24\u017e\n\24\3\25\3\25\3\25\7\25\u0183\n\25\f\25\16\25\u0186"+ + "\13\25\3\26\3\26\3\26\3\26\3\26\3\26\3\26\5\26\u018f\n\26\3\27\3\27\5"+ + "\27\u0193\n\27\3\27\3\27\3\27\3\27\3\27\3\27\7\27\u019b\n\27\f\27\16\27"+ + "\u019e\13\27\3\27\3\27\3\27\3\30\3\30\3\30\3\30\7\30\u01a7\n\30\f\30\16"+ + "\30\u01aa\13\30\3\31\3\31\3\31\5\31\u01af\n\31\3\31\3\31\5\31\u01b3\n"+ + "\31\3\31\3\31\5\31\u01b7\n\31\3\31\3\31\3\31\3\32\3\32\3\32\3\32\7\32"+ + "\u01c0\n\32\f\32\16\32\u01c3\13\32\3\33\3\33\3\33\5\33\u01c8\n\33\3\33"+ + "\3\33\3\33\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\7\35\u01d5\n\35\f\35"+ + "\16\35\u01d8\13\35\3\36\3\36\3\36\5\36\u01dd\n\36\3\36\3\36\5\36\u01e1"+ + "\n\36\3\36\3\36\5\36\u01e5\n\36\3\37\3\37\3\37\3\37\3\37\5\37\u01ec\n"+ + "\37\3\37\3\37\3\37\7\37\u01f1\n\37\f\37\16\37\u01f4\13\37\3 \3 \3 \5 "+ + "\u01f9\n \3 \3 \3 \5 \u01fe\n \5 \u0200\n \3 \3 \5 \u0204\n \3!\3!\3!"+ + "\3\"\3\"\5\"\u020b\n\"\3\"\3\"\3\"\7\"\u0210\n\"\f\"\16\"\u0213\13\"\3"+ + "\"\3\"\3\"\3#\3#\3#\5#\u021b\n#\3#\3#\3#\3$\3$\3$\3$\3$\6$\u0225\n$\r"+ + "$\16$\u0226\3$\3$\3$\3$\3%\3%\6%\u022f\n%\r%\16%\u0230\3%\3%\3%\3&\3&"+ + "\3&\3&\3&\6&\u023b\n&\r&\16&\u023c\3&\3&\5&\u0241\n&\3&\3&\3&\3\'\3\'"+ + "\3\'\3\'\5\'\u024a\n\'\3\'\3\'\3\'\7\'\u024f\n\'\f\'\16\'\u0252\13\'\3"+ + "\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\6)\u0265\n)\r)\16"+ + ")\u0266\3*\3*\3*\5*\u026c\n*\3*\3*\3*\5*\u0271\n*\7*\u0273\n*\f*\16*\u0276"+ + "\13*\3*\3*\3*\3*\3+\3+\3+\7+\u027f\n+\f+\16+\u0282\13+\3,\3,\3,\7,\u0287"+ + "\n,\f,\16,\u028a\13,\3-\5-\u028d\n-\3-\3-\3.\3.\3.\5.\u0294\n.\3/\3/\3"+ + "/\7/\u0299\n/\f/\16/\u029c\13/\3\60\3\60\3\60\5\60\u02a1\n\60\3\61\3\61"+ + "\3\61\7\61\u02a6\n\61\f\61\16\61\u02a9\13\61\3\62\3\62\3\62\7\62\u02ae"+ + "\n\62\f\62\16\62\u02b1\13\62\3\63\3\63\3\63\3\63\5\63\u02b7\n\63\3\64"+ + "\3\64\3\64\3\64\5\64\u02bd\n\64\3\65\3\65\3\65\3\65\5\65\u02c3\n\65\3"+ + "\66\3\66\3\66\3\66\5\66\u02c9\n\66\3\67\3\67\3\67\3\67\5\67\u02cf\n\67"+ + "\38\38\38\38\38\78\u02d6\n8\f8\168\u02d9\138\39\79\u02dc\n9\f9\169\u02df"+ + "\139\39\39\3:\3:\3:\7:\u02e6\n:\f:\16:\u02e9\13:\3;\3;\3;\3;\3;\3;\7;"+ + "\u02f1\n;\f;\16;\u02f4\13;\3<\3<\3<\3<\3<\3<\3=\3=\3=\3>\3>\3>\3>\3?\3"+ + "?\3?\3?\3?\3?\3?\3?\5?\u030b\n?\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\5"+ + "@\u0319\n@\3A\3A\3A\3B\3B\5B\u0320\nB\3B\3B\3C\3C\3D\3D\3D\3D\3D\3E\3"+ + "E\3E\3E\3E\3F\3F\3F\3G\3G\3G\5G\u0336\nG\7G\u0338\nG\fG\16G\u033b\13G"+ + "\3G\3G\3H\3H\5H\u0341\nH\3I\3I\5I\u0345\nI\3J\3J\3J\3J\3K\3K\3K\5K\u034e"+ + "\nK\3K\3K\3K\5K\u0353\nK\3K\3K\3K\3K\3L\3L\3L\3L\3L\3L\5L\u035f\nL\5L"+ + "\u0361\nL\3M\3M\3M\3M\7M\u0367\nM\fM\16M\u036a\13M\5M\u036c\nM\3M\3M\3"+ + "M\3M\3M\5M\u0373\nM\3N\3N\3N\3N\5N\u0379\nN\3O\3O\5O\u037d\nO\3P\3P\3"+ + "P\3P\3P\3Q\3Q\3Q\3Q\3Q\7Q\u0389\nQ\fQ\16Q\u038c\13Q\5Q\u038e\nQ\3Q\3Q"+ + "\3Q\3Q\3R\3R\3S\3S\3T\3T\3U\3U\3V\3V\3W\3W\3X\3X\3Y\3Y\3Z\3Z\3[\3[\3\\"+ + "\3\\\3]\3]\3^\3^\3_\3_\3`\3`\3a\3a\3a\3a\3a\3a\3a\3a\3a\3a\3a\3a\3a\3"+ + "a\5a\u03c0\na\3b\3b\5b\u03c4\nb\3c\3c\3c\5c\u03c9\nc\3d\3d\5d\u03cd\n"+ + "d\3e\3e\5e\u03d1\ne\3e\3e\3e\3f\3f\5f\u03d8\nf\3f\3f\3g\3g\3h\3h\3i\3"+ + "i\3i\2\2j\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&(*,.\60\62\64\66"+ + "8:<>@BDFHJLNPRTVXZ\\^`bdfhjlnprtvxz|~\u0080\u0082\u0084\u0086\u0088\u008a"+ + "\u008c\u008e\u0090\u0092\u0094\u0096\u0098\u009a\u009c\u009e\u00a0\u00a2"+ + "\u00a4\u00a6\u00a8\u00aa\u00ac\u00ae\u00b0\u00b2\u00b4\u00b6\u00b8\u00ba"+ + "\u00bc\u00be\u00c0\u00c2\u00c4\u00c6\u00c8\u00ca\u00cc\u00ce\u00d0\2\13"+ + "\3\2\t\n\3\2de\3\2\r\26\4\2\6\6$.\3\2\60\61\4\2##\62\64\4\2>?{{\4\2\f"+ + "\f}}\3\2O{\2\u040c\2\u00d2\3\2\2\2\4\u00da\3\2\2\2\6\u00e0\3\2\2\2\b\u00e3"+ + "\3\2\2\2\n\u00f4\3\2\2\2\f\u0103\3\2\2\2\16\u0105\3\2\2\2\20\u010d\3\2"+ + "\2\2\22\u010f\3\2\2\2\24\u0114\3\2\2\2\26\u0118\3\2\2\2\30\u011e\3\2\2"+ + "\2\32\u0133\3\2\2\2\34\u0139\3\2\2\2\36\u013b\3\2\2\2 \u014e\3\2\2\2\""+ + "\u015e\3\2\2\2$\u0171\3\2\2\2&\u0179\3\2\2\2(\u017f\3\2\2\2*\u018e\3\2"+ + "\2\2,\u0192\3\2\2\2.\u01a2\3\2\2\2\60\u01ab\3\2\2\2\62\u01bb\3\2\2\2\64"+ + "\u01c4\3\2\2\2\66\u01cc\3\2\2\28\u01cf\3\2\2\2:\u01d9\3\2\2\2<\u01eb\3"+ + "\2\2\2>\u01f5\3\2\2\2@\u0205\3\2\2\2B\u020a\3\2\2\2D\u0217\3\2\2\2F\u021f"+ + "\3\2\2\2H\u022e\3\2\2\2J\u0235\3\2\2\2L\u0245\3\2\2\2N\u0256\3\2\2\2P"+ + "\u025f\3\2\2\2R\u0268\3\2\2\2T\u027b\3\2\2\2V\u0283\3\2\2\2X\u028c\3\2"+ + "\2\2Z\u0290\3\2\2\2\\\u0295\3\2\2\2^\u029d\3\2\2\2`\u02a2\3\2\2\2b\u02aa"+ + "\3\2\2\2d\u02b2\3\2\2\2f\u02b8\3\2\2\2h\u02be\3\2\2\2j\u02c4\3\2\2\2l"+ + "\u02ca\3\2\2\2n\u02d0\3\2\2\2p\u02dd\3\2\2\2r\u02e2\3\2\2\2t\u02ea\3\2"+ + "\2\2v\u02f5\3\2\2\2x\u02fb\3\2\2\2z\u02fe\3\2\2\2|\u0302\3\2\2\2~\u0318"+ + "\3\2\2\2\u0080\u031a\3\2\2\2\u0082\u031d\3\2\2\2\u0084\u0323\3\2\2\2\u0086"+ + "\u0325\3\2\2\2\u0088\u032a\3\2\2\2\u008a\u032f\3\2\2\2\u008c\u0332\3\2"+ + "\2\2\u008e\u0340\3\2\2\2\u0090\u0344\3\2\2\2\u0092\u0346\3\2\2\2\u0094"+ + "\u034a\3\2\2\2\u0096\u0360\3\2\2\2\u0098\u0372\3\2\2\2\u009a\u0378\3\2"+ + "\2\2\u009c\u037c\3\2\2\2\u009e\u037e\3\2\2\2\u00a0\u0383\3\2\2\2\u00a2"+ + "\u0393\3\2\2\2\u00a4\u0395\3\2\2\2\u00a6\u0397\3\2\2\2\u00a8\u0399\3\2"+ + "\2\2\u00aa\u039b\3\2\2\2\u00ac\u039d\3\2\2\2\u00ae\u039f\3\2\2\2\u00b0"+ + "\u03a1\3\2\2\2\u00b2\u03a3\3\2\2\2\u00b4\u03a5\3\2\2\2\u00b6\u03a7\3\2"+ + "\2\2\u00b8\u03a9\3\2\2\2\u00ba\u03ab\3\2\2\2\u00bc\u03ad\3\2\2\2\u00be"+ + "\u03af\3\2\2\2\u00c0\u03bf\3\2\2\2\u00c2\u03c1\3\2\2\2\u00c4\u03c8\3\2"+ + "\2\2\u00c6\u03cc\3\2\2\2\u00c8\u03d0\3\2\2\2\u00ca\u03d5\3\2\2\2\u00cc"+ + "\u03db\3\2\2\2\u00ce\u03dd\3\2\2\2\u00d0\u03df\3\2\2\2\u00d2\u00d3\5\4"+ + "\3\2\u00d3\u00d4\7\2\2\3\u00d4\3\3\2\2\2\u00d5\u00d6\7z\2\2\u00d6\u00d7"+ + "\7y\2\2\u00d7\u00d8\5\u00ceh\2\u00d8\u00d9\7\3\2\2\u00d9\u00db\3\2\2\2"+ + "\u00da\u00d5\3\2\2\2\u00da\u00db\3\2\2\2\u00db\u00de\3\2\2\2\u00dc\u00df"+ + "\5\b\5\2\u00dd\u00df\5\6\4\2\u00de\u00dc\3\2\2\2\u00de\u00dd\3\2\2\2\u00df"+ + "\5\3\2\2\2\u00e0\u00e1\5\n\6\2\u00e1\u00e2\5(\25\2\u00e2\7\3\2\2\2\u00e3"+ + "\u00e4\7\4\2\2\u00e4\u00e5\7\5\2\2\u00e5\u00e6\7\u0086\2\2\u00e6\u00e7"+ + "\7\6\2\2\u00e7\u00e8\5\u00ccg\2\u00e8\u00e9\7\3\2\2\u00e9\u00ea\5\n\6"+ + "\2\u00ea\t\3\2\2\2\u00eb\u00ef\5\f\7\2\u00ec\u00ef\5\16\b\2\u00ed\u00ef"+ + "\5\36\20\2\u00ee\u00eb\3\2\2\2\u00ee\u00ec\3\2\2\2\u00ee\u00ed\3\2\2\2"+ + "\u00ef\u00f0\3\2\2\2\u00f0\u00f1\7\3\2\2\u00f1\u00f3\3\2\2\2\u00f2\u00ee"+ + "\3\2\2\2\u00f3\u00f6\3\2\2\2\u00f4\u00f2\3\2\2\2\u00f4\u00f5\3\2\2\2\u00f5"+ + "\u00fc\3\2\2\2\u00f6\u00f4\3\2\2\2\u00f7\u00f8\5\20\t\2\u00f8\u00f9\7"+ + "\3\2\2\u00f9\u00fb\3\2\2\2\u00fa\u00f7\3\2\2\2\u00fb\u00fe\3\2\2\2\u00fc"+ + "\u00fa\3\2\2\2\u00fc\u00fd\3\2\2\2\u00fd\13\3\2\2\2\u00fe\u00fc\3\2\2"+ + "\2\u00ff\u0104\5\22\n\2\u0100\u0104\5\24\13\2\u0101\u0104\5\26\f\2\u0102"+ + "\u0104\5\30\r\2\u0103\u00ff\3\2\2\2\u0103\u0100\3\2\2\2\u0103\u0101\3"+ + "\2\2\2\u0103\u0102\3\2\2\2\u0104\r\3\2\2\2\u0105\u0106\7\7\2\2\u0106\u0107"+ + "\7\5\2\2\u0107\u0108\7\u0086\2\2\u0108\u0109\7\6\2\2\u0109\u010a\5\u00cc"+ + "g\2\u010a\17\3\2\2\2\u010b\u010e\5\"\22\2\u010c\u010e\5 \21\2\u010d\u010b"+ + "\3\2\2\2\u010d\u010c\3\2\2\2\u010e\21\3\2\2\2\u010f\u0110\7\7\2\2\u0110"+ + "\u0111\7j\2\2\u0111\u0112\7c\2\2\u0112\u0113\5\u00ccg\2\u0113\23\3\2\2"+ + "\2\u0114\u0115\7\7\2\2\u0115\u0116\7\b\2\2\u0116\u0117\t\2\2\2\u0117\25"+ + "\3\2\2\2\u0118\u0119\7\7\2\2\u0119\u011a\7j\2\2\u011a\u011b\7T\2\2\u011b"+ + "\u011c\7[\2\2\u011c\u011d\t\3\2\2\u011d\27\3\2\2\2\u011e\u0123\7\7\2\2"+ + "\u011f\u0120\7\13\2\2\u0120\u0124\5\32\16\2\u0121\u0122\7j\2\2\u0122\u0124"+ + "\7\13\2\2\u0123\u011f\3\2\2\2\u0123\u0121\3\2\2\2\u0124\u012b\3\2\2\2"+ + "\u0125\u0126\5\34\17\2\u0126\u0127\7\6\2\2\u0127\u0128\5\u00ceh\2\u0128"+ + "\u012a\3\2\2\2\u0129\u0125\3\2\2\2\u012a\u012d\3\2\2\2\u012b\u0129\3\2"+ + "\2\2\u012b\u012c\3\2\2\2\u012c\31\3\2\2\2\u012d\u012b\3\2\2\2\u012e\u0131"+ + "\7\u0086\2\2\u012f\u0131\5\u00d0i\2\u0130\u012e\3\2\2\2\u0130\u012f\3"+ + "\2\2\2\u0131\u0132\3\2\2\2\u0132\u0134\7\f\2\2\u0133\u0130\3\2\2\2\u0133"+ + "\u0134\3\2\2\2\u0134\u0137\3\2\2\2\u0135\u0138\5\u00c6d\2\u0136\u0138"+ + "\5\u00d0i\2\u0137\u0135\3\2\2\2\u0137\u0136\3\2\2\2\u0138\33\3\2\2\2\u0139"+ + "\u013a\t\4\2\2\u013a\35\3\2\2\2\u013b\u013c\7\27\2\2\u013c\u0140\7\4\2"+ + "\2\u013d\u013e\7\5\2\2\u013e\u013f\7\u0086\2\2\u013f\u0141\7\6\2\2\u0140"+ + "\u013d\3\2\2\2\u0140\u0141\3\2\2\2\u0141\u0142\3\2\2\2\u0142\u014c\5\u00cc"+ + "g\2\u0143\u0144\7Y\2\2\u0144\u0149\5\u00ccg\2\u0145\u0146\7\30\2\2\u0146"+ + "\u0148\5\u00ccg\2\u0147\u0145\3\2\2\2\u0148\u014b\3\2\2\2\u0149\u0147"+ + "\3\2\2\2\u0149\u014a\3\2\2\2\u014a\u014d\3\2\2\2\u014b\u0149\3\2\2\2\u014c"+ + "\u0143\3\2\2\2\u014c\u014d\3\2\2\2\u014d\37\3\2\2\2\u014e\u014f\7\7\2"+ + "\2\u014f\u0150\7\31\2\2\u0150\u0153\5\u0080A\2\u0151\u0152\7X\2\2\u0152"+ + "\u0154\5\u0096L\2\u0153\u0151\3\2\2\2\u0153\u0154\3\2\2\2\u0154\u015c"+ + "\3\2\2\2\u0155\u0156\7\32\2\2\u0156\u015d\5*\26\2\u0157\u015a\7\33\2\2"+ + "\u0158\u0159\7\32\2\2\u0159\u015b\5*\26\2\u015a\u0158\3\2\2\2\u015a\u015b"+ + "\3\2\2\2\u015b\u015d\3\2\2\2\u015c\u0155\3\2\2\2\u015c\u0157\3\2\2\2\u015d"+ + "!\3\2\2\2\u015e\u015f\7\7\2\2\u015f\u0160\7\34\2\2\u0160\u0161\5\32\16"+ + "\2\u0161\u0163\7\35\2\2\u0162\u0164\5$\23\2\u0163\u0162\3\2\2\2\u0163"+ + "\u0164\3\2\2\2\u0164\u0165\3\2\2\2\u0165\u0168\7\36\2\2\u0166\u0167\7"+ + "X\2\2\u0167\u0169\5\u0096L\2\u0168\u0166\3\2\2\2\u0168\u0169\3\2\2\2\u0169"+ + "\u016f\3\2\2\2\u016a\u016b\7\37\2\2\u016b\u016c\5(\25\2\u016c\u016d\7"+ + " \2\2\u016d\u0170\3\2\2\2\u016e\u0170\7\33\2\2\u016f\u016a\3\2\2\2\u016f"+ + "\u016e\3\2\2\2\u0170#\3\2\2\2\u0171\u0176\5&\24\2\u0172\u0173\7\30\2\2"+ + "\u0173\u0175\5&\24\2\u0174\u0172\3\2\2\2\u0175\u0178\3\2\2\2\u0176\u0174"+ + "\3\2\2\2\u0176\u0177\3\2\2\2\u0177%\3\2\2\2\u0178\u0176\3\2\2\2\u0179"+ + "\u017a\7!\2\2\u017a\u017d\5\32\16\2\u017b\u017c\7X\2\2\u017c\u017e\5\u0096"+ + "L\2\u017d\u017b\3\2\2\2\u017d\u017e\3\2\2\2\u017e\'\3\2\2\2\u017f\u0184"+ + "\5*\26\2\u0180\u0181\7\30\2\2\u0181\u0183\5*\26\2\u0182\u0180\3\2\2\2"+ + "\u0183\u0186\3\2\2\2\u0184\u0182\3\2\2\2\u0184\u0185\3\2\2\2\u0185)\3"+ + "\2\2\2\u0186\u0184\3\2\2\2\u0187\u018f\5,\27\2\u0188\u018f\5B\"\2\u0189"+ + "\u018f\5F$\2\u018a\u018f\5J&\2\u018b\u018f\5N(\2\u018c\u018f\5P)\2\u018d"+ + "\u018f\5T+\2\u018e\u0187\3\2\2\2\u018e\u0188\3\2\2\2\u018e\u0189\3\2\2"+ + "\2\u018e\u018a\3\2\2\2\u018e\u018b\3\2\2\2\u018e\u018c\3\2\2\2\u018e\u018d"+ + "\3\2\2\2\u018f+\3\2\2\2\u0190\u0193\5.\30\2\u0191\u0193\5\62\32\2\u0192"+ + "\u0190\3\2\2\2\u0192\u0191\3\2\2\2\u0193\u019c\3\2\2\2\u0194\u019b\5."+ + "\30\2\u0195\u019b\5\66\34\2\u0196\u019b\5\62\32\2\u0197\u019b\58\35\2"+ + "\u0198\u019b\5<\37\2\u0199\u019b\5@!\2\u019a\u0194\3\2\2\2\u019a\u0195"+ + "\3\2\2\2\u019a\u0196\3\2\2\2\u019a\u0197\3\2\2\2\u019a\u0198\3\2\2\2\u019a"+ + "\u0199\3\2\2\2\u019b\u019e\3\2\2\2\u019c\u019a\3\2\2\2\u019c\u019d\3\2"+ + "\2\2\u019d\u019f\3\2\2\2\u019e\u019c\3\2\2\2\u019f\u01a0\7U\2\2\u01a0"+ + "\u01a1\5*\26\2\u01a1-\3\2\2\2\u01a2\u01a3\7O\2\2\u01a3\u01a8\5\60\31\2"+ + "\u01a4\u01a5\7\30\2\2\u01a5\u01a7\5\60\31\2\u01a6\u01a4\3\2\2\2\u01a7"+ + "\u01aa\3\2\2\2\u01a8\u01a6\3\2\2\2\u01a8\u01a9\3\2\2\2\u01a9/\3\2\2\2"+ + "\u01aa\u01a8\3\2\2\2\u01ab\u01ae\5\u0080A\2\u01ac\u01ad\7X\2\2\u01ad\u01af"+ + "\5\u0096L\2\u01ae\u01ac\3\2\2\2\u01ae\u01af\3\2\2\2\u01af\u01b2\3\2\2"+ + "\2\u01b0\u01b1\7Z\2\2\u01b1\u01b3\7[\2\2\u01b2\u01b0\3\2\2\2\u01b2\u01b3"+ + "\3\2\2\2\u01b3\u01b6\3\2\2\2\u01b4\u01b5\7Y\2\2\u01b5\u01b7\5\u0080A\2"+ + "\u01b6\u01b4\3\2\2\2\u01b6\u01b7\3\2\2\2\u01b7\u01b8\3\2\2\2\u01b8\u01b9"+ + "\7W\2\2\u01b9\u01ba\5*\26\2\u01ba\61\3\2\2\2\u01bb\u01bc\7P\2\2\u01bc"+ + "\u01c1\5\64\33\2\u01bd\u01be\7\30\2\2\u01be\u01c0\5\64\33\2\u01bf\u01bd"+ + "\3\2\2\2\u01c0\u01c3\3\2\2\2\u01c1\u01bf\3\2\2\2\u01c1\u01c2\3\2\2\2\u01c2"+ + "\63\3\2\2\2\u01c3\u01c1\3\2\2\2\u01c4\u01c7\5\u0080A\2\u01c5\u01c6\7X"+ + "\2\2\u01c6\u01c8\5\u0096L\2\u01c7\u01c5\3\2\2\2\u01c7\u01c8\3\2\2\2\u01c8"+ + "\u01c9\3\2\2\2\u01c9\u01ca\7\32\2\2\u01ca\u01cb\5*\26\2\u01cb\65\3\2\2"+ + "\2\u01cc\u01cd\7Q\2\2\u01cd\u01ce\5*\26\2\u01ce\67\3\2\2\2\u01cf\u01d0"+ + "\7R\2\2\u01d0\u01d1\7S\2\2\u01d1\u01d6\5:\36\2\u01d2\u01d3\7\30\2\2\u01d3"+ + "\u01d5\5:\36\2\u01d4\u01d2\3\2\2\2\u01d5\u01d8\3\2\2\2\u01d6\u01d4\3\2"+ + "\2\2\u01d6\u01d7\3\2\2\2\u01d79\3\2\2\2\u01d8\u01d6\3\2\2\2\u01d9\u01e0"+ + "\5\u0080A\2\u01da\u01db\7X\2\2\u01db\u01dd\5\u0096L\2\u01dc\u01da\3\2"+ + "\2\2\u01dc\u01dd\3\2\2\2\u01dd\u01de\3\2\2\2\u01de\u01df\7\32\2\2\u01df"+ + "\u01e1\5*\26\2\u01e0\u01dc\3\2\2\2\u01e0\u01e1\3\2\2\2\u01e1\u01e4\3\2"+ + "\2\2\u01e2\u01e3\7c\2\2\u01e3\u01e5\5\u00ccg\2\u01e4\u01e2\3\2\2\2\u01e4"+ + "\u01e5\3\2\2\2\u01e5;\3\2\2\2\u01e6\u01e7\7T\2\2\u01e7\u01ec\7S\2\2\u01e8"+ + "\u01e9\7]\2\2\u01e9\u01ea\7T\2\2\u01ea\u01ec\7S\2\2\u01eb\u01e6\3\2\2"+ + "\2\u01eb\u01e8\3\2\2\2\u01ec\u01ed\3\2\2\2\u01ed\u01f2\5> \2\u01ee\u01ef"+ + "\7\30\2\2\u01ef\u01f1\5> \2\u01f0\u01ee\3\2\2\2\u01f1\u01f4\3\2\2\2\u01f2"+ + "\u01f0\3\2\2\2\u01f2\u01f3\3\2\2\2\u01f3=\3\2\2\2\u01f4\u01f2\3\2\2\2"+ + "\u01f5\u01f8\5*\26\2\u01f6\u01f9\7^\2\2\u01f7\u01f9\7_\2\2\u01f8\u01f6"+ + "\3\2\2\2\u01f8\u01f7\3\2\2\2\u01f8\u01f9\3\2\2\2\u01f9\u01ff\3\2\2\2\u01fa"+ + "\u01fd\7[\2\2\u01fb\u01fe\7d\2\2\u01fc\u01fe\7e\2\2\u01fd\u01fb\3\2\2"+ + "\2\u01fd\u01fc\3\2\2\2\u01fe\u0200\3\2\2\2\u01ff\u01fa\3\2\2\2\u01ff\u0200"+ + "\3\2\2\2\u0200\u0203\3\2\2\2\u0201\u0202\7c\2\2\u0202\u0204\5\u00ccg\2"+ + "\u0203\u0201\3\2\2\2\u0203\u0204\3\2\2\2\u0204?\3\2\2\2\u0205\u0206\7"+ + "\\\2\2\u0206\u0207\5\u0080A\2\u0207A\3\2\2\2\u0208\u020b\7`\2\2\u0209"+ + "\u020b\7a\2\2\u020a\u0208\3\2\2\2\u020a\u0209\3\2\2\2\u020b\u020c\3\2"+ + "\2\2\u020c\u0211\5D#\2\u020d\u020e\7\30\2\2\u020e\u0210\5D#\2\u020f\u020d"+ + "\3\2\2\2\u0210\u0213\3\2\2\2\u0211\u020f\3\2\2\2\u0211\u0212\3\2\2\2\u0212"+ + "\u0214\3\2\2\2\u0213\u0211\3\2\2\2\u0214\u0215\7b\2\2\u0215\u0216\5*\26"+ + "\2\u0216C\3\2\2\2\u0217\u021a\5\u0080A\2\u0218\u0219\7X\2\2\u0219\u021b"+ + "\5\u0096L\2\u021a\u0218\3\2\2\2\u021a\u021b\3\2\2\2\u021b\u021c\3\2\2"+ + "\2\u021c\u021d\7W\2\2\u021d\u021e\5*\26\2\u021eE\3\2\2\2\u021f\u0220\7"+ + "f\2\2\u0220\u0221\7\35\2\2\u0221\u0222\5(\25\2\u0222\u0224\7\36\2\2\u0223"+ + "\u0225\5H%\2\u0224\u0223\3\2\2\2\u0225\u0226\3\2\2\2\u0226\u0224\3\2\2"+ + "\2\u0226\u0227\3\2\2\2\u0227\u0228\3\2\2\2\u0228\u0229\7j\2\2\u0229\u022a"+ + "\7U\2\2\u022a\u022b\5*\26\2\u022bG\3\2\2\2\u022c\u022d\7g\2\2\u022d\u022f"+ + "\5*\26\2\u022e\u022c\3\2\2\2\u022f\u0230\3\2\2\2\u0230\u022e\3\2\2\2\u0230"+ + "\u0231\3\2\2\2\u0231\u0232\3\2\2\2\u0232\u0233\7U\2\2\u0233\u0234\5*\26"+ + "\2\u0234I\3\2\2\2\u0235\u0236\7m\2\2\u0236\u0237\7\35\2\2\u0237\u0238"+ + "\5(\25\2\u0238\u023a\7\36\2\2\u0239\u023b\5L\'\2\u023a\u0239\3\2\2\2\u023b"+ + "\u023c\3\2\2\2\u023c\u023a\3\2\2\2\u023c\u023d\3\2\2\2\u023d\u023e\3\2"+ + "\2\2\u023e\u0240\7j\2\2\u023f\u0241\5\u0080A\2\u0240\u023f\3\2\2\2\u0240"+ + "\u0241\3\2\2\2\u0241\u0242\3\2\2\2\u0242\u0243\7U\2\2\u0243\u0244\5*\26"+ + "\2\u0244K\3\2\2\2\u0245\u0249\7g\2\2\u0246\u0247\5\u0080A\2\u0247\u0248"+ + "\7X\2\2\u0248\u024a\3\2\2\2\u0249\u0246\3\2\2\2\u0249\u024a\3\2\2\2\u024a"+ + "\u024b\3\2\2\2\u024b\u0250\5\u0096L\2\u024c\u024d\7\"\2\2\u024d\u024f"+ + "\5\u0096L\2\u024e\u024c\3\2\2\2\u024f\u0252\3\2\2\2\u0250\u024e\3\2\2"+ + "\2\u0250\u0251\3\2\2\2\u0251\u0253\3\2\2\2\u0252\u0250\3\2\2\2\u0253\u0254"+ + "\7U\2\2\u0254\u0255\5*\26\2\u0255M\3\2\2\2\u0256\u0257\7V\2\2\u0257\u0258"+ + "\7\35\2\2\u0258\u0259\5(\25\2\u0259\u025a\7\36\2\2\u025a\u025b\7k\2\2"+ + "\u025b\u025c\5*\26\2\u025c\u025d\7l\2\2\u025d\u025e\5*\26\2\u025eO\3\2"+ + "\2\2\u025f\u0260\7h\2\2\u0260\u0261\7\37\2\2\u0261\u0262\5(\25\2\u0262"+ + "\u0264\7 \2\2\u0263\u0265\5R*\2\u0264\u0263\3\2\2\2\u0265\u0266\3\2\2"+ + "\2\u0266\u0264\3\2\2\2\u0266\u0267\3\2\2\2\u0267Q\3\2\2\2\u0268\u026b"+ + "\7i\2\2\u0269\u026c\7#\2\2\u026a\u026c\5\32\16\2\u026b\u0269\3\2\2\2\u026b"+ + "\u026a\3\2\2\2\u026c\u0274\3\2\2\2\u026d\u0270\7\"\2\2\u026e\u0271\7#"+ + "\2\2\u026f\u0271\5\32\16\2\u0270\u026e\3\2\2\2\u0270\u026f\3\2\2\2\u0271"+ + "\u0273\3\2\2\2\u0272\u026d\3\2\2\2\u0273\u0276\3\2\2\2\u0274\u0272\3\2"+ + "\2\2\u0274\u0275\3\2\2\2\u0275\u0277\3\2\2\2\u0276\u0274\3\2\2\2\u0277"+ + "\u0278\7\37\2\2\u0278\u0279\5(\25\2\u0279\u027a\7 \2\2\u027aS\3\2\2\2"+ + "\u027b\u0280\5V,\2\u027c\u027d\7n\2\2\u027d\u027f\5V,\2\u027e\u027c\3"+ + "\2\2\2\u027f\u0282\3\2\2\2\u0280\u027e\3\2\2\2\u0280\u0281\3\2\2\2\u0281"+ + "U\3\2\2\2\u0282\u0280\3\2\2\2\u0283\u0288\5X-\2\u0284\u0285\7o\2\2\u0285"+ + "\u0287\5X-\2\u0286\u0284\3\2\2\2\u0287\u028a\3\2\2\2\u0288\u0286\3\2\2"+ + "\2\u0288\u0289\3\2\2\2\u0289W\3\2\2\2\u028a\u0288\3\2\2\2\u028b\u028d"+ + "\7p\2\2\u028c\u028b\3\2\2\2\u028c\u028d\3\2\2\2\u028d\u028e\3\2\2\2\u028e"+ + "\u028f\5Z.\2\u028fY\3\2\2\2\u0290\u0293\5\\/\2\u0291\u0292\t\5\2\2\u0292"+ + "\u0294\5\\/\2\u0293\u0291\3\2\2\2\u0293\u0294\3\2\2\2\u0294[\3\2\2\2\u0295"+ + "\u029a\5^\60\2\u0296\u0297\7/\2\2\u0297\u0299\5^\60\2\u0298\u0296\3\2"+ + "\2\2\u0299\u029c\3\2\2\2\u029a\u0298\3\2\2\2\u029a\u029b\3\2\2\2\u029b"+ + "]\3\2\2\2\u029c\u029a\3\2\2\2\u029d\u02a0\5`\61\2\u029e\u029f\7q\2\2\u029f"+ + "\u02a1\5`\61\2\u02a0\u029e\3\2\2\2\u02a0\u02a1\3\2\2\2\u02a1_\3\2\2\2"+ + "\u02a2\u02a7\5b\62\2\u02a3\u02a4\t\6\2\2\u02a4\u02a6\5b\62\2\u02a5\u02a3"+ + "\3\2\2\2\u02a6\u02a9\3\2\2\2\u02a7\u02a5\3\2\2\2\u02a7\u02a8\3\2\2\2\u02a8"+ + "a\3\2\2\2\u02a9\u02a7\3\2\2\2\u02aa\u02af\5d\63\2\u02ab\u02ac\t\7\2\2"+ + "\u02ac\u02ae\5d\63\2\u02ad\u02ab\3\2\2\2\u02ae\u02b1\3\2\2\2\u02af\u02ad"+ + "\3\2\2\2\u02af\u02b0\3\2\2\2\u02b0c\3\2\2\2\u02b1\u02af\3\2\2\2\u02b2"+ + "\u02b6\5f\64\2\u02b3\u02b4\7r\2\2\u02b4\u02b5\7s\2\2\u02b5\u02b7\5\u0096"+ + "L\2\u02b6\u02b3\3\2\2\2\u02b6\u02b7\3\2\2\2\u02b7e\3\2\2\2\u02b8\u02bc"+ + "\5h\65\2\u02b9\u02ba\7u\2\2\u02ba\u02bb\7t\2\2\u02bb\u02bd\5\u0096L\2"+ + "\u02bc\u02b9\3\2\2\2\u02bc\u02bd\3\2\2\2\u02bdg\3\2\2\2\u02be\u02c2\5"+ + "j\66\2\u02bf\u02c0\7v\2\2\u02c0\u02c1\7X\2\2\u02c1\u02c3\5\u0096L\2\u02c2"+ + "\u02bf\3\2\2\2\u02c2\u02c3\3\2\2\2\u02c3i\3\2\2\2\u02c4\u02c8\5l\67\2"+ + "\u02c5\u02c6\7x\2\2\u02c6\u02c7\7X\2\2\u02c7\u02c9\5\u00c2b\2\u02c8\u02c5"+ + "\3\2\2\2\u02c8\u02c9\3\2\2\2\u02c9k\3\2\2\2\u02ca\u02ce\5n8\2\u02cb\u02cc"+ + "\7w\2\2\u02cc\u02cd\7X\2\2\u02cd\u02cf\5\u00c2b\2\u02ce\u02cb\3\2\2\2"+ + "\u02ce\u02cf\3\2\2\2\u02cfm\3\2\2\2\u02d0\u02d7\5p9\2\u02d1\u02d2\7\6"+ + "\2\2\u02d2\u02d3\7-\2\2\u02d3\u02d4\3\2\2\2\u02d4\u02d6\5\u008aF\2\u02d5"+ + "\u02d1\3\2\2\2\u02d6\u02d9\3\2\2\2\u02d7\u02d5\3\2\2\2\u02d7\u02d8\3\2"+ + "\2\2\u02d8o\3\2\2\2\u02d9\u02d7\3\2\2\2\u02da\u02dc\t\6\2\2\u02db\u02da"+ + "\3\2\2\2\u02dc\u02df\3\2\2\2\u02dd\u02db\3\2\2\2\u02dd\u02de\3\2\2\2\u02de"+ + "\u02e0\3\2\2\2\u02df\u02dd\3\2\2\2\u02e0\u02e1\5r:\2\u02e1q\3\2\2\2\u02e2"+ + "\u02e7\5t;\2\u02e3\u02e4\7\65\2\2\u02e4\u02e6\5t;\2\u02e5\u02e3\3\2\2"+ + "\2\u02e6\u02e9\3\2\2\2\u02e7\u02e5\3\2\2\2\u02e7\u02e8\3\2\2\2\u02e8s"+ + "\3\2\2\2\u02e9\u02e7\3\2\2\2\u02ea\u02f2\5~@\2\u02eb\u02f1\5v<\2\u02ec"+ + "\u02f1\5z>\2\u02ed\u02f1\5|?\2\u02ee\u02f1\5x=\2\u02ef\u02f1\5\u008cG"+ + "\2\u02f0\u02eb\3\2\2\2\u02f0\u02ec\3\2\2\2\u02f0\u02ed\3\2\2\2\u02f0\u02ee"+ + "\3\2\2\2\u02f0\u02ef\3\2\2\2\u02f1\u02f4\3\2\2\2\u02f2\u02f0\3\2\2\2\u02f2"+ + "\u02f3\3\2\2\2\u02f3u\3\2\2\2\u02f4\u02f2\3\2\2\2\u02f5\u02f6\7\66\2\2"+ + "\u02f6\u02f7\7\66\2\2\u02f7\u02f8\5(\25\2\u02f8\u02f9\7\67\2\2\u02f9\u02fa"+ + "\7\67\2\2\u02faw\3\2\2\2\u02fb\u02fc\7\66\2\2\u02fc\u02fd\7\67\2\2\u02fd"+ + "y\3\2\2\2\u02fe\u02ff\7\66\2\2\u02ff\u0300\5(\25\2\u0300\u0301\7\67\2"+ + "\2\u0301{\3\2\2\2\u0302\u030a\78\2\2\u0303\u030b\5\u00d0i\2\u0304\u030b"+ + "\5\u00ceh\2\u0305\u030b\7\u0086\2\2\u0306\u030b\5\u0082B\2\u0307\u030b"+ + "\5\u0080A\2\u0308\u030b\5\u0084C\2\u0309\u030b\5\u00c0a\2\u030a\u0303"+ + "\3\2\2\2\u030a\u0304\3\2\2\2\u030a\u0305\3\2\2\2\u030a\u0306\3\2\2\2\u030a"+ + "\u0307\3\2\2\2\u030a\u0308\3\2\2\2\u030a\u0309\3\2\2\2\u030b}\3\2\2\2"+ + "\u030c\u0319\7~\2\2\u030d\u0319\7\177\2\2\u030e\u0319\5\u00ceh\2\u030f"+ + "\u0319\5\u0080A\2\u0310\u0319\5\u0082B\2\u0311\u0319\5\u0084C\2\u0312"+ + "\u0319\5\u0098M\2\u0313\u0319\5\u008aF\2\u0314\u0319\5\u0086D\2\u0315"+ + "\u0319\5\u0088E\2\u0316\u0319\5\u00caf\2\u0317\u0319\5\u0090I\2\u0318"+ + "\u030c\3\2\2\2\u0318\u030d\3\2\2\2\u0318\u030e\3\2\2\2\u0318\u030f\3\2"+ + "\2\2\u0318\u0310\3\2\2\2\u0318\u0311\3\2\2\2\u0318\u0312\3\2\2\2\u0318"+ + "\u0313\3\2\2\2\u0318\u0314\3\2\2\2\u0318\u0315\3\2\2\2\u0318\u0316\3\2"+ + "\2\2\u0318\u0317\3\2\2\2\u0319\177\3\2\2\2\u031a\u031b\7!\2\2\u031b\u031c"+ + "\5\32\16\2\u031c\u0081\3\2\2\2\u031d\u031f\7\35\2\2\u031e\u0320\5(\25"+ + "\2\u031f\u031e\3\2\2\2\u031f\u0320\3\2\2\2\u0320\u0321\3\2\2\2\u0321\u0322"+ + "\7\36\2\2\u0322\u0083\3\2\2\2\u0323\u0324\79\2\2\u0324\u0085\3\2\2\2\u0325"+ + "\u0326\7\t\2\2\u0326\u0327\7\37\2\2\u0327\u0328\5(\25\2\u0328\u0329\7"+ + " \2\2\u0329\u0087\3\2\2\2\u032a\u032b\7\n\2\2\u032b\u032c\7\37\2\2\u032c"+ + "\u032d\5(\25\2\u032d\u032e\7 \2\2\u032e\u0089\3\2\2\2\u032f\u0330\5\32"+ + "\16\2\u0330\u0331\5\u008cG\2\u0331\u008b\3\2\2\2\u0332\u0339\7\35\2\2"+ + "\u0333\u0335\5\u008eH\2\u0334\u0336\7\30\2\2\u0335\u0334\3\2\2\2\u0335"+ + "\u0336\3\2\2\2\u0336\u0338\3\2\2\2\u0337\u0333\3\2\2\2\u0338\u033b\3\2"+ + "\2\2\u0339\u0337\3\2\2\2\u0339\u033a\3\2\2\2\u033a\u033c\3\2\2\2\u033b"+ + "\u0339\3\2\2\2\u033c\u033d\7\36\2\2\u033d\u008d\3\2\2\2\u033e\u0341\5"+ + "*\26\2\u033f\u0341\7}\2\2\u0340\u033e\3\2\2\2\u0340\u033f\3\2\2\2\u0341"+ + "\u008f\3\2\2\2\u0342\u0345\5\u0092J\2\u0343\u0345\5\u0094K\2\u0344\u0342"+ + "\3\2\2\2\u0344\u0343\3\2\2\2\u0345\u0091\3\2\2\2\u0346\u0347\5\32\16\2"+ + "\u0347\u0348\7:\2\2\u0348\u0349\7\177\2\2\u0349\u0093\3\2\2\2\u034a\u034b"+ + "\7\34\2\2\u034b\u034d\7\35\2\2\u034c\u034e\5$\23\2\u034d\u034c\3\2\2\2"+ + "\u034d\u034e\3\2\2\2\u034e\u034f\3\2\2\2\u034f\u0352\7\36\2\2\u0350\u0351"+ + "\7X\2\2\u0351\u0353\5\u0096L\2\u0352\u0350\3\2\2\2\u0352\u0353\3\2\2\2"+ + "\u0353\u0354\3\2\2\2\u0354\u0355\7\37\2\2\u0355\u0356\5(\25\2\u0356\u0357"+ + "\7 \2\2\u0357\u0095\3\2\2\2\u0358\u0359\7\35\2\2\u0359\u0361\7\36\2\2"+ + "\u035a\u035e\5\u009aN\2\u035b\u035f\7}\2\2\u035c\u035f\7#\2\2\u035d\u035f"+ + "\7\60\2\2\u035e\u035b\3\2\2\2\u035e\u035c\3\2\2\2\u035e\u035d\3\2\2\2"+ + "\u035e\u035f\3\2\2\2\u035f\u0361\3\2\2\2\u0360\u0358\3\2\2\2\u0360\u035a"+ + "\3\2\2\2\u0361\u0097\3\2\2\2\u0362\u036b\7\37\2\2\u0363\u0368\5\u00c8"+ + "e\2\u0364\u0365\7\30\2\2\u0365\u0367\5\u00c8e\2\u0366\u0364\3\2\2\2\u0367"+ + "\u036a\3\2\2\2\u0368\u0366\3\2\2\2\u0368\u0369\3\2\2\2\u0369\u036c\3\2"+ + "\2\2\u036a\u0368\3\2\2\2\u036b\u0363\3\2\2\2\u036b\u036c\3\2\2\2\u036c"+ + "\u036d\3\2\2\2\u036d\u0373\7 \2\2\u036e\u036f\7;\2\2\u036f\u0370\5(\25"+ + "\2\u0370\u0371\7<\2\2\u0371\u0373\3\2\2\2\u0372\u0362\3\2\2\2\u0372\u036e"+ + "\3\2\2\2\u0373\u0099\3\2\2\2\u0374\u0379\7=\2\2\u0375\u0379\5\u00a2R\2"+ + "\u0376\u0379\5\u00c4c\2\u0377\u0379\5\u009cO\2\u0378\u0374\3\2\2\2\u0378"+ + "\u0375\3\2\2\2\u0378\u0376\3\2\2\2\u0378\u0377\3\2\2\2\u0379\u009b\3\2"+ + "\2\2\u037a\u037d\5\u009eP\2\u037b\u037d\5\u00a0Q\2\u037c\u037a\3\2\2\2"+ + "\u037c\u037b\3\2\2\2\u037d\u009d\3\2\2\2\u037e\u037f\7\34\2\2\u037f\u0380"+ + "\7\35\2\2\u0380\u0381\7#\2\2\u0381\u0382\7\36\2\2\u0382\u009f\3\2\2\2"+ + "\u0383\u0384\7\34\2\2\u0384\u038d\7\35\2\2\u0385\u038a\5\u0096L\2\u0386"+ + "\u0387\7\30\2\2\u0387\u0389\5\u0096L\2\u0388\u0386\3\2\2\2\u0389\u038c"+ + "\3\2\2\2\u038a\u0388\3\2\2\2\u038a\u038b\3\2\2\2\u038b\u038e\3\2\2\2\u038c"+ + "\u038a\3\2\2\2\u038d\u0385\3\2\2\2\u038d\u038e\3\2\2\2\u038e\u038f\3\2"+ + "\2\2\u038f\u0390\7\36\2\2\u0390\u0391\7X\2\2\u0391\u0392\5\u0096L\2\u0392"+ + "\u00a1\3\2\2\2\u0393\u0394\t\b\2\2\u0394\u00a3\3\2\2\2\u0395\u0396\7@"+ + "\2\2\u0396\u00a5\3\2\2\2\u0397\u0398\7A\2\2\u0398\u00a7\3\2\2\2\u0399"+ + "\u039a\7B\2\2\u039a\u00a9\3\2\2\2\u039b\u039c\7C\2\2\u039c\u00ab\3\2\2"+ + "\2\u039d\u039e\7D\2\2\u039e\u00ad\3\2\2\2\u039f\u03a0\7E\2\2\u03a0\u00af"+ + "\3\2\2\2\u03a1\u03a2\7F\2\2\u03a2\u00b1\3\2\2\2\u03a3\u03a4\7G\2\2\u03a4"+ + "\u00b3\3\2\2\2\u03a5\u03a6\7H\2\2\u03a6\u00b5\3\2\2\2\u03a7\u03a8\7I\2"+ + "\2\u03a8\u00b7\3\2\2\2\u03a9\u03aa\7J\2\2\u03aa\u00b9\3\2\2\2\u03ab\u03ac"+ + "\7K\2\2\u03ac\u00bb\3\2\2\2\u03ad\u03ae\7L\2\2\u03ae\u00bd\3\2\2\2\u03af"+ + "\u03b0\7M\2\2\u03b0\u00bf\3\2\2\2\u03b1\u03c0\5\u00a4S\2\u03b2\u03c0\5"+ + "\u00a6T\2\u03b3\u03c0\5\u00a8U\2\u03b4\u03c0\5\u00aaV\2\u03b5\u03c0\5"+ + "\u00acW\2\u03b6\u03c0\5\u00aeX\2\u03b7\u03c0\5\u00b0Y\2\u03b8\u03c0\5"+ + "\u00b2Z\2\u03b9\u03c0\5\u00b8]\2\u03ba\u03c0\5\u00ba^\2\u03bb\u03c0\5"+ + "\u00bc_\2\u03bc\u03c0\5\u00b4[\2\u03bd\u03c0\5\u00b6\\\2\u03be\u03c0\5"+ + "\u00be`\2\u03bf\u03b1\3\2\2\2\u03bf\u03b2\3\2\2\2\u03bf\u03b3\3\2\2\2"+ + "\u03bf\u03b4\3\2\2\2\u03bf\u03b5\3\2\2\2\u03bf\u03b6\3\2\2\2\u03bf\u03b7"+ + "\3\2\2\2\u03bf\u03b8\3\2\2\2\u03bf\u03b9\3\2\2\2\u03bf\u03ba\3\2\2\2\u03bf"+ + "\u03bb\3\2\2\2\u03bf\u03bc\3\2\2\2\u03bf\u03bd\3\2\2\2\u03bf\u03be\3\2"+ + "\2\2\u03c0\u00c1\3\2\2\2\u03c1\u03c3\5\u00c4c\2\u03c2\u03c4\7}\2\2\u03c3"+ + "\u03c2\3\2\2\2\u03c3\u03c4\3\2\2\2\u03c4\u00c3\3\2\2\2\u03c5\u03c9\7N"+ + "\2\2\u03c6\u03c9\5\u00c0a\2\u03c7\u03c9\7~\2\2\u03c8\u03c5\3\2\2\2\u03c8"+ + "\u03c6\3\2\2\2\u03c8\u03c7\3\2\2\2\u03c9\u00c5\3\2\2\2\u03ca\u03cd\7\u0086"+ + "\2\2\u03cb\u03cd\5\u00c0a\2\u03cc\u03ca\3\2\2\2\u03cc\u03cb\3\2\2\2\u03cd"+ + "\u00c7\3\2\2\2\u03ce\u03d1\5*\26\2\u03cf\u03d1\7\u0086\2\2\u03d0\u03ce"+ + "\3\2\2\2\u03d0\u03cf\3\2\2\2\u03d1\u03d2\3\2\2\2\u03d2\u03d3\t\t\2\2\u03d3"+ + "\u03d4\5*\26\2\u03d4\u00c9\3\2\2\2\u03d5\u03d7\7\66\2\2\u03d6\u03d8\5"+ + "(\25\2\u03d7\u03d6\3\2\2\2\u03d7\u03d8\3\2\2\2\u03d8\u03d9\3\2\2\2\u03d9"+ + "\u03da\7\67\2\2\u03da\u00cb\3\2\2\2\u03db\u03dc\5\u00ceh\2\u03dc\u00cd"+ + "\3\2\2\2\u03dd\u03de\7|\2\2\u03de\u00cf\3\2\2\2\u03df\u03e0\t\n\2\2\u03e0"+ + "\u00d1\3\2\2\2e\u00da\u00de\u00ee\u00f4\u00fc\u0103\u010d\u0123\u012b"+ + "\u0130\u0133\u0137\u0140\u0149\u014c\u0153\u015a\u015c\u0163\u0168\u016f"+ + "\u0176\u017d\u0184\u018e\u0192\u019a\u019c\u01a8\u01ae\u01b2\u01b6\u01c1"+ + "\u01c7\u01d6\u01dc\u01e0\u01e4\u01eb\u01f2\u01f8\u01fd\u01ff\u0203\u020a"+ + "\u0211\u021a\u0226\u0230\u023c\u0240\u0249\u0250\u0266\u026b\u0270\u0274"+ + "\u0280\u0288\u028c\u0293\u029a\u02a0\u02a7\u02af\u02b6\u02bc\u02c2\u02c8"+ + "\u02ce\u02d7\u02dd\u02e7\u02f0\u02f2\u030a\u0318\u031f\u0335\u0339\u0340"+ + "\u0344\u034d\u0352\u035e\u0360\u0368\u036b\u0372\u0378\u037c\u038a\u038d"+ + "\u03bf\u03c3\u03c8\u03cc\u03d0\u03d7"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/src/main/java/org/rumbledb/parser/JsoniqVisitor.java b/src/main/java/org/rumbledb/parser/JsoniqVisitor.java index da450bf57e..8436026f06 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqVisitor.java +++ b/src/main/java/org/rumbledb/parser/JsoniqVisitor.java @@ -475,6 +475,24 @@ public interface JsoniqVisitor extends ParseTreeVisitor { * @return the visitor result */ T visitItemType(JsoniqParser.ItemTypeContext ctx); + /** + * Visit a parse tree produced by {@link JsoniqParser#functionTest}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunctionTest(JsoniqParser.FunctionTestContext ctx); + /** + * Visit a parse tree produced by {@link JsoniqParser#anyFunctionTest}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAnyFunctionTest(JsoniqParser.AnyFunctionTestContext ctx); + /** + * Visit a parse tree produced by {@link JsoniqParser#typedFunctionTest}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTypedFunctionTest(JsoniqParser.TypedFunctionTestContext ctx); /** * Visit a parse tree produced by {@link JsoniqParser#jSONItemTest}. * @param ctx the parse tree From dfe3eaadc9e8970723a41b5adcb66b2676fc9f19 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 1 Dec 2020 10:22:06 +0100 Subject: [PATCH 093/206] refactored huge addition and subtraction table into easier to read code inside visitor, created access method for add and mult expressions to avoid casting in code --- .../rumbledb/compiler/InferTypeVisitor.java | 76 +- .../arithmetic/AdditiveExpression.java | 8 + .../arithmetic/MultiplicativeExpression.java | 8 + .../java/org/rumbledb/types/ItemType.java | 946 ------------------ 4 files changed, 71 insertions(+), 967 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 0b6ea61df9..c05562c175 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -477,24 +477,17 @@ public StaticContext visitTreatExpression(TreatExpression expression, StaticCont public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticContext argument) { visitDescendants(expression, argument); - List childrenExpressions = expression.getChildren(); - SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); - SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); - - // if any of the child expression has null inferred type throw error - if (leftInferredType == null || rightInferredType == null) { - throw new UnexpectedStaticTypeException("A child expression of a AdditiveExpression has no inferred type"); - } + SequenceType leftInferredType = expression.getLeftExpression().getInferredSequenceType(); + SequenceType rightInferredType = expression.getRightExpression().getInferredSequenceType(); - // if any of the children is the empty sequence throw error XPST0005 - if (leftInferredType.isEmptySequence() || rightInferredType.isEmptySequence()) { - throw new UnexpectedStaticTypeException( - "Inferred type is empty sequence and this is not a CommaExpression", - ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression - ); - } + basicChecks( + Arrays.asList(leftInferredType, rightInferredType), + expression.getClass().getSimpleName(), + true, + true + ); - ItemType inferredType; + ItemType inferredType = null; SequenceType.Arity inferredArity = resolveArities(leftInferredType.getArity(), rightInferredType.getArity()); // arity check @@ -502,8 +495,50 @@ public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticCont throw new UnexpectedStaticTypeException("'+' and '*' arities are not allowed for additive expressions"); } - inferredType = leftInferredType.getItemType() - .staticallyAddTo(rightInferredType.getItemType(), expression.isMinus()); + ItemType leftItemType = leftInferredType.getItemType(); + ItemType rightItemType = rightInferredType.getItemType(); + + // check item type combination + if (leftItemType.isNumeric()) { + if (rightItemType.isNumeric()) { + inferredType = resolveNumericType(leftItemType, rightItemType); + } + } else if (leftItemType.equals(ItemType.dateItem) || leftItemType.equals(ItemType.dateTimeItem)) { + if ( + rightItemType.equals(ItemType.dayTimeDurationItem) + || rightItemType.equals(ItemType.yearMonthDurationItem) + ) { + inferredType = leftItemType; + } else if (expression.isMinus() && rightItemType.equals(leftItemType)) { + inferredType = ItemType.dayTimeDurationItem; + } + } else if (leftItemType.equals(ItemType.timeItem)) { + if (rightItemType.equals(ItemType.dayTimeDurationItem)) { + inferredType = leftItemType; + } else if (expression.isMinus() && rightItemType.equals(leftItemType)) { + inferredType = ItemType.dayTimeDurationItem; + } + } else if (leftItemType.equals(ItemType.dayTimeDurationItem)) { + if (rightItemType.equals(leftItemType)) { + inferredType = leftItemType; + } else if ( + !expression.isMinus() + && (rightItemType.equals(ItemType.dateTimeItem) + || rightItemType.equals(ItemType.dateItem) + || rightItemType.equals(ItemType.timeItem)) + ) { + inferredType = rightItemType; + } + } else if (leftItemType.equals(ItemType.yearMonthDurationItem)) { + if (rightItemType.equals(leftItemType)) { + inferredType = leftItemType; + } else if ( + !expression.isMinus() + && (rightItemType.equals(ItemType.dateTimeItem) || rightItemType.equals(ItemType.dateItem)) + ) { + inferredType = rightItemType; + } + } if (inferredType == null) { if (inferredArity == SequenceType.Arity.OneOrZero) { @@ -563,9 +598,8 @@ private SequenceType.Arity resolveArities(SequenceType.Arity left, SequenceType. public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression, StaticContext argument) { visitDescendants(expression, argument); - List childrenExpressions = expression.getChildren(); - SequenceType leftInferredType = ((Expression) childrenExpressions.get(0)).getInferredSequenceType(); - SequenceType rightInferredType = ((Expression) childrenExpressions.get(1)).getInferredSequenceType(); + SequenceType leftInferredType = expression.getLeftExpression().getInferredSequenceType(); + SequenceType rightInferredType = expression.getRightExpression().getInferredSequenceType(); basicChecks( Arrays.asList(leftInferredType, rightInferredType), diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java index 4350884ae2..895dfbec1c 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/AdditiveExpression.java @@ -56,6 +56,14 @@ public List getChildren() { return Arrays.asList(this.leftExpression, this.rightExpression); } + public Expression getLeftExpression() { + return this.leftExpression; + } + + public Expression getRightExpression() { + return this.rightExpression; + } + public boolean isMinus() { return this.isMinus; } diff --git a/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java b/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java index 3273663047..44143189aa 100644 --- a/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java +++ b/src/main/java/org/rumbledb/expressions/arithmetic/MultiplicativeExpression.java @@ -92,6 +92,14 @@ public List getChildren() { return Arrays.asList(this.leftExpression, this.rightExpression); } + public Expression getLeftExpression() { + return this.leftExpression; + } + + public Expression getRightExpression() { + return this.rightExpression; + } + public MultiplicativeOperator getMultiplicativeOperator() { return this.multiplicativeOperator; } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 3e3fd53a56..81465e41f8 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -61,942 +61,6 @@ private ItemType(String name, int index) { this.index = index; } - // resulting type of [row] + [col] - private static ItemType addTable[][] = { - // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex - // any-uri base64 json-item object array function - /* item */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* atomic */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* string */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* integer */ { - null, - null, - null, - integerItem, - decimalItem, - doubleItem, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* decimal */ { - null, - null, - null, - decimalItem, - decimalItem, - doubleItem, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* double */ { - null, - null, - null, - doubleItem, - doubleItem, - doubleItem, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* bool */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* null */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* duration */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - dateTimeItem, - dateItem, - null, - null, - null, - null, - null, - null, - null, - null }, - /* y-m-dur */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - yearMonthDurationItem, - null, - dateTimeItem, - dateItem, - null, - null, - null, - null, - null, - null, - null, - null }, - /* d-t-dur */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - dayTimeDurationItem, - dateTimeItem, - dateItem, - timeItem, - null, - null, - null, - null, - null, - null, - null }, - /* date-time */ { - null, - null, - null, - null, - null, - null, - null, - null, - dateTimeItem, - dateTimeItem, - dateTimeItem, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* date */ { - null, - null, - null, - null, - null, - null, - null, - null, - dateItem, - dateItem, - dateItem, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* time */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - timeItem, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* hex */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* any-uri */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* base64 */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* json-item */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* object */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* array */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* function */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - }; - - // resulting type of [row] - [col] - private static ItemType subTable[][] = { - // item atomic string integer decimal double bool null duration y-m-dur d-time-dur date-time date time hex - // any-uri base64 json-item object array function - /* item */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* atomic */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* string */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* integer */ { - null, - null, - null, - integerItem, - decimalItem, - doubleItem, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* decimal */ { - null, - null, - null, - decimalItem, - decimalItem, - doubleItem, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* double */ { - null, - null, - null, - doubleItem, - doubleItem, - doubleItem, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* bool */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* null */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* duration */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* y-m-dur */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - yearMonthDurationItem, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* d-t-dur */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - dayTimeDurationItem, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* date-time */ { - null, - null, - null, - null, - null, - null, - null, - null, - dateTimeItem, - dateTimeItem, - dateTimeItem, - dayTimeDurationItem, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* date */ { - null, - null, - null, - null, - null, - null, - null, - null, - dateItem, - dateItem, - dateItem, - null, - dayTimeDurationItem, - null, - null, - null, - null, - null, - null, - null, - null }, - /* time */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - timeItem, - null, - null, - dayTimeDurationItem, - null, - null, - null, - null, - null, - null, - null }, - /* hex */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* any-uri */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* base64 */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* json-item */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* object */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* array */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - /* function */ { - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null }, - }; - public String getName() { return this.name; } @@ -1195,16 +259,6 @@ public boolean staticallyCastableAs(ItemType other) { return false; } - // return the resulting statically inferred ItemType from adding [this] to [other], return null in case of - // incompatible inferred static types - public ItemType staticallyAddTo(ItemType other, boolean isMinus) { - if (isMinus) { - return subTable[this.getIndex()][other.getIndex()]; - } else { - return addTable[this.getIndex()][other.getIndex()]; - } - } - // return [true] if this is a numeric type (i.e. [integerItem], [decimalItem] or [doubleItem]), false otherwise public boolean isNumeric() { return this.equals(integerItem) || this.equals(decimalItem) || this.equals(doubleItem); From 2c6e645e43f8c2446f0ad7dbbe7854e09df8ae1c Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 1 Dec 2020 10:55:59 +0100 Subject: [PATCH 094/206] removed unused index attribute from itemtype --- .../java/org/rumbledb/types/ItemType.java | 50 ++++++++----------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 81465e41f8..18ceaed313 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -29,46 +29,40 @@ public class ItemType implements Serializable { private static final long serialVersionUID = 1L; private String name; - private int index; // for private matrix operation - public static final ItemType item = new ItemType("item", 0); - public static final ItemType atomicItem = new ItemType("atomic", 1); - public static final ItemType stringItem = new ItemType("string", 2); - public static final ItemType integerItem = new ItemType("integer", 3); - public static final ItemType decimalItem = new ItemType("decimal", 4); - public static final ItemType doubleItem = new ItemType("double", 5); - public static final ItemType booleanItem = new ItemType("boolean", 6); - public static final ItemType nullItem = new ItemType("null", 7); - public static final ItemType durationItem = new ItemType("duration", 8); - public static final ItemType yearMonthDurationItem = new ItemType("yearMonthDuration", 9); - public static final ItemType dayTimeDurationItem = new ItemType("dayTimeDuration", 10); - public static final ItemType dateTimeItem = new ItemType("dateTime", 11); - public static final ItemType dateItem = new ItemType("date", 12); - public static final ItemType timeItem = new ItemType("time", 13); - public static final ItemType hexBinaryItem = new ItemType("hexBinary", 14); - public static final ItemType anyURIItem = new ItemType("anyURI", 15); - public static final ItemType base64BinaryItem = new ItemType("base64Binary", 16); - public static final ItemType JSONItem = new ItemType("json-item", 17); - public static final ItemType objectItem = new ItemType("object", 18); - public static final ItemType arrayItem = new ItemType("array", 19); - public static final ItemType functionItem = new ItemType("function", 20); + public static final ItemType item = new ItemType("item"); + public static final ItemType atomicItem = new ItemType("atomic"); + public static final ItemType stringItem = new ItemType("string"); + public static final ItemType integerItem = new ItemType("integer"); + public static final ItemType decimalItem = new ItemType("decimal"); + public static final ItemType doubleItem = new ItemType("double"); + public static final ItemType booleanItem = new ItemType("boolean"); + public static final ItemType nullItem = new ItemType("null"); + public static final ItemType durationItem = new ItemType("duration"); + public static final ItemType yearMonthDurationItem = new ItemType("yearMonthDuration"); + public static final ItemType dayTimeDurationItem = new ItemType("dayTimeDuration"); + public static final ItemType dateTimeItem = new ItemType("dateTime"); + public static final ItemType dateItem = new ItemType("date"); + public static final ItemType timeItem = new ItemType("time"); + public static final ItemType hexBinaryItem = new ItemType("hexBinary"); + public static final ItemType anyURIItem = new ItemType("anyURI"); + public static final ItemType base64BinaryItem = new ItemType("base64Binary"); + public static final ItemType JSONItem = new ItemType("json-item"); + public static final ItemType objectItem = new ItemType("object"); + public static final ItemType arrayItem = new ItemType("array"); + public static final ItemType functionItem = new ItemType("function"); public ItemType() { } - private ItemType(String name, int index) { + private ItemType(String name) { this.name = name; - this.index = index; } public String getName() { return this.name; } - public int getIndex() { - return this.index; - } - public static ItemType getItemTypeByName(String name) { if (name.equals(objectItem.name)) { return objectItem; From f3ec9f37d57dde8ede3ec828afcde01bf14bc696 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 1 Dec 2020 20:56:33 +0100 Subject: [PATCH 095/206] refactored itemType to separate it from AtomicItemType --- src/main/java/org/rumbledb/api/Item.java | 1 + .../compiler/DynamicContextVisitor.java | 3 +- .../rumbledb/compiler/InferTypeVisitor.java | 140 ++++++----- .../compiler/StaticContextVisitor.java | 5 +- .../rumbledb/compiler/TranslationVisitor.java | 1 + .../org/rumbledb/errorcodes/ErrorCode.java | 2 +- .../quantifiers/QuantifiedExpressionVar.java | 1 + .../java/org/rumbledb/items/AnyURIItem.java | 13 +- .../java/org/rumbledb/items/ArrayItem.java | 5 +- .../java/org/rumbledb/items/AtomicItem.java | 3 +- .../org/rumbledb/items/Base64BinaryItem.java | 17 +- .../java/org/rumbledb/items/BooleanItem.java | 19 +- .../java/org/rumbledb/items/DateItem.java | 19 +- .../java/org/rumbledb/items/DateTimeItem.java | 35 +-- .../rumbledb/items/DayTimeDurationItem.java | 23 +- .../java/org/rumbledb/items/DecimalItem.java | 21 +- .../java/org/rumbledb/items/DoubleItem.java | 21 +- .../java/org/rumbledb/items/DurationItem.java | 41 +-- .../java/org/rumbledb/items/FunctionItem.java | 1 + .../org/rumbledb/items/HexBinaryItem.java | 17 +- src/main/java/org/rumbledb/items/IntItem.java | 23 +- .../java/org/rumbledb/items/IntegerItem.java | 23 +- .../java/org/rumbledb/items/JsonItem.java | 3 +- .../java/org/rumbledb/items/NullItem.java | 13 +- .../java/org/rumbledb/items/ObjectItem.java | 5 +- .../java/org/rumbledb/items/StringItem.java | 81 +++--- .../java/org/rumbledb/items/TimeItem.java | 15 +- .../rumbledb/items/YearMonthDurationItem.java | 23 +- .../rumbledb/items/parsing/ItemParser.java | 37 +-- .../org/rumbledb/runtime/RuntimeIterator.java | 3 +- .../runtime/flwor/FlworDataFrameUtils.java | 1 + .../clauses/OrderByClauseSparkIterator.java | 63 ++--- .../udfs/OrderClauseCreateColumnsUDF.java | 23 +- .../DayTimeDurationFunctionIterator.java | 3 +- .../durations/DurationFunctionIterator.java | 3 +- .../YearMonthDurationFunctionIterator.java | 3 +- .../numerics/DecimalFunctionIterator.java | 5 +- .../numerics/DoubleFunctionIterator.java | 5 +- .../numerics/IntegerFunctionIterator.java | 5 +- .../numerics/NumberFunctionIterator.java | 5 +- .../resources/AnyURIFunctionIterator.java | 3 +- .../sequences/general/InstanceOfClosure.java | 1 + .../strings/StringFunctionIterator.java | 5 +- .../runtime/typing/CastableIterator.java | 3 +- .../runtime/typing/InstanceOfIterator.java | 1 + .../runtime/typing/TreatIterator.java | 1 + .../org/rumbledb/types/AtomicItemType.java | 158 ++++++++++++ .../java/org/rumbledb/types/ItemType.java | 238 +++++------------- .../java/org/rumbledb/types/SequenceType.java | 76 +++--- .../ml/ApplyEstimatorRuntimeIterator.java | 5 +- .../ml/GetEstimatorFunctionIterator.java | 3 +- .../ml/GetTransformerFunctionIterator.java | 5 +- .../sparksoniq/spark/ml/RumbleMLUtils.java | 11 +- src/test/java/iq/FrontendTests.java | 9 +- 54 files changed, 672 insertions(+), 577 deletions(-) create mode 100644 src/main/java/org/rumbledb/types/AtomicItemType.java diff --git a/src/main/java/org/rumbledb/api/Item.java b/src/main/java/org/rumbledb/api/Item.java index 3cae7e07c3..5bdf379660 100644 --- a/src/main/java/org/rumbledb/api/Item.java +++ b/src/main/java/org/rumbledb/api/Item.java @@ -30,6 +30,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression; import org.rumbledb.items.ItemFactory; import org.rumbledb.types.FunctionSignature; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.io.IOException; import java.io.ObjectInputStream; diff --git a/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java b/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java index 73cfa56989..5a39348e3f 100644 --- a/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java @@ -45,6 +45,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.input.FileSystemUtil; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; @@ -183,7 +184,7 @@ public DynamicContext visitVariableDeclaration(VariableDeclaration variableDecla Item item = null; if ( !sequenceType.equals(SequenceType.EMPTY_SEQUENCE) - && sequenceType.getItemType().equals(ItemType.anyURIItem) + && sequenceType.getItemType().equals(AtomicItemType.anyURIItem) ) { URI resolvedURI = FileSystemUtil.resolveURIAgainstWorkingDirectory( value, diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index c05562c175..c5fa55da08 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -31,7 +31,9 @@ import org.rumbledb.expressions.quantifiers.QuantifiedExpression; import org.rumbledb.expressions.quantifiers.QuantifiedExpressionVar; import org.rumbledb.expressions.typing.*; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.FunctionSignature; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -155,42 +157,42 @@ public StaticContext visitCommaExpression(CommaExpression expression, StaticCont @Override public StaticContext visitString(StringLiteralExpression expression, StaticContext argument) { System.out.println("visiting String literal"); - expression.setInferredSequenceType(new SequenceType(ItemType.stringItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.stringItem)); return argument; } @Override public StaticContext visitInteger(IntegerLiteralExpression expression, StaticContext argument) { System.out.println("visiting Int literal"); - expression.setInferredSequenceType(new SequenceType(ItemType.integerItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.integerItem)); return argument; } @Override public StaticContext visitDouble(DoubleLiteralExpression expression, StaticContext argument) { System.out.println("visiting Double literal"); - expression.setInferredSequenceType(new SequenceType(ItemType.doubleItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.doubleItem)); return argument; } @Override public StaticContext visitDecimal(DecimalLiteralExpression expression, StaticContext argument) { System.out.println("visiting Decimal literal"); - expression.setInferredSequenceType(new SequenceType(ItemType.decimalItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.decimalItem)); return argument; } @Override public StaticContext visitNull(NullLiteralExpression expression, StaticContext argument) { System.out.println("visiting Null literal"); - expression.setInferredSequenceType(new SequenceType(ItemType.nullItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.nullItem)); return argument; } @Override public StaticContext visitBoolean(BooleanLiteralExpression expression, StaticContext argument) { System.out.println("visiting Boolean literal"); - expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem)); return argument; } @@ -214,7 +216,7 @@ public StaticContext visitVariableReference(VariableReferenceExpression expressi public StaticContext visitArrayConstructor(ArrayConstructorExpression expression, StaticContext argument) { System.out.println("visiting Array constructor literal"); visitDescendants(expression, argument); - expression.setInferredSequenceType(new SequenceType(ItemType.arrayItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.arrayItem)); return argument; } @@ -252,7 +254,7 @@ public StaticContext visitObjectConstructor(ObjectConstructorExpression expressi } } } - expression.setInferredSequenceType(new SequenceType(ItemType.objectItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.objectItem)); return argument; } @@ -340,7 +342,7 @@ public StaticContext visitCastableExpression(CastableExpression expression, Stat System.out.println("visiting Castable expression"); visitDescendants(expression, argument); ItemType itemType = expression.getSequenceType().getItemType(); - if (itemType.equals(ItemType.atomicItem)) { + if (itemType.equals(AtomicItemType.atomicItem)) { throw new UnexpectedStaticTypeException( "atomic item type is not allowed in castable expression", ErrorCode.CastableErrorCode @@ -348,16 +350,16 @@ public StaticContext visitCastableExpression(CastableExpression expression, Stat } SequenceType expressionType = expression.getMainExpression().getInferredSequenceType(); basicChecks(expressionType, expression.getClass().getSimpleName(), true, false); - if (!expressionType.isEmptySequence() && !expressionType.getItemType().isSubtypeOf(ItemType.atomicItem)) { + if (!expressionType.isEmptySequence() && !expressionType.getItemType().isSubtypeOf(AtomicItemType.atomicItem)) { throw new UnexpectedStaticTypeException( "non-atomic item types are not allowed in castable expression, found " + expressionType.getItemType(), - expressionType.getItemType().isSubtypeOf(ItemType.JSONItem) + expressionType.getItemType().isSubtypeOf(AtomicItemType.JSONItem) ? ErrorCode.NonAtomicElementErrorCode : ErrorCode.AtomizationError ); } - expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem)); return argument; } @@ -370,7 +372,7 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex SequenceType expressionSequenceType = expression.getMainExpression().getInferredSequenceType(); SequenceType castedSequenceType = expression.getSequenceType(); - if (castedSequenceType.getItemType().equals(ItemType.atomicItem)) { + if (castedSequenceType.getItemType().equals(AtomicItemType.atomicItem)) { throw new UnexpectedStaticTypeException( "atomic item type is not allowed in cast expression", ErrorCode.CastableErrorCode @@ -401,12 +403,12 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex } // ItemType static castability check - if (!expressionSequenceType.getItemType().isSubtypeOf(ItemType.atomicItem)) { + if (!expressionSequenceType.getItemType().isSubtypeOf(AtomicItemType.atomicItem)) { throw new UnexpectedStaticTypeException( "It is never possible to cast a non-atomic sequence type: " + expressionSequenceType, - expressionSequenceType.getItemType().isSubtypeOf(ItemType.JSONItem) + expressionSequenceType.getItemType().isSubtypeOf(AtomicItemType.JSONItem) ? ErrorCode.NonAtomicElementErrorCode : ErrorCode.AtomizationError ); @@ -446,7 +448,7 @@ public StaticContext visitIsStaticallyExpr(IsStaticallyExpression expression, St public StaticContext visitInstanceOfExpression(InstanceOfExpression expression, StaticContext argument) { System.out.println("visiting InstanceOf expression"); visitDescendants(expression, argument); - expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem)); return argument; } @@ -503,38 +505,38 @@ public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticCont if (rightItemType.isNumeric()) { inferredType = resolveNumericType(leftItemType, rightItemType); } - } else if (leftItemType.equals(ItemType.dateItem) || leftItemType.equals(ItemType.dateTimeItem)) { + } else if (leftItemType.equals(AtomicItemType.dateItem) || leftItemType.equals(AtomicItemType.dateTimeItem)) { if ( - rightItemType.equals(ItemType.dayTimeDurationItem) - || rightItemType.equals(ItemType.yearMonthDurationItem) + rightItemType.equals(AtomicItemType.dayTimeDurationItem) + || rightItemType.equals(AtomicItemType.yearMonthDurationItem) ) { inferredType = leftItemType; } else if (expression.isMinus() && rightItemType.equals(leftItemType)) { - inferredType = ItemType.dayTimeDurationItem; + inferredType = AtomicItemType.dayTimeDurationItem; } - } else if (leftItemType.equals(ItemType.timeItem)) { - if (rightItemType.equals(ItemType.dayTimeDurationItem)) { + } else if (leftItemType.equals(AtomicItemType.timeItem)) { + if (rightItemType.equals(AtomicItemType.dayTimeDurationItem)) { inferredType = leftItemType; } else if (expression.isMinus() && rightItemType.equals(leftItemType)) { - inferredType = ItemType.dayTimeDurationItem; + inferredType = AtomicItemType.dayTimeDurationItem; } - } else if (leftItemType.equals(ItemType.dayTimeDurationItem)) { + } else if (leftItemType.equals(AtomicItemType.dayTimeDurationItem)) { if (rightItemType.equals(leftItemType)) { inferredType = leftItemType; } else if ( !expression.isMinus() - && (rightItemType.equals(ItemType.dateTimeItem) - || rightItemType.equals(ItemType.dateItem) - || rightItemType.equals(ItemType.timeItem)) + && (rightItemType.equals(AtomicItemType.dateTimeItem) + || rightItemType.equals(AtomicItemType.dateItem) + || rightItemType.equals(AtomicItemType.timeItem)) ) { inferredType = rightItemType; } - } else if (leftItemType.equals(ItemType.yearMonthDurationItem)) { + } else if (leftItemType.equals(AtomicItemType.yearMonthDurationItem)) { if (rightItemType.equals(leftItemType)) { inferredType = leftItemType; } else if ( !expression.isMinus() - && (rightItemType.equals(ItemType.dateTimeItem) || rightItemType.equals(ItemType.dateItem)) + && (rightItemType.equals(AtomicItemType.dateTimeItem) || rightItemType.equals(AtomicItemType.dateItem)) ) { inferredType = rightItemType; } @@ -564,12 +566,12 @@ public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticCont // This function assume 2 numeric ItemType private ItemType resolveNumericType(ItemType left, ItemType right) { - if (left.equals(ItemType.doubleItem) || right.equals(ItemType.doubleItem)) { - return ItemType.doubleItem; - } else if (left.equals(ItemType.decimalItem) || right.equals(ItemType.decimalItem)) { - return ItemType.decimalItem; + if (left.equals(AtomicItemType.doubleItem) || right.equals(AtomicItemType.doubleItem)) { + return AtomicItemType.doubleItem; + } else if (left.equals(AtomicItemType.decimalItem) || right.equals(AtomicItemType.decimalItem)) { + return AtomicItemType.decimalItem; } else { - return ItemType.integerItem; + return AtomicItemType.integerItem; } } @@ -624,26 +626,26 @@ public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression if (leftItemType.isNumeric()) { if (rightItemType.isNumeric()) { if (expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.IDIV) { - inferredType = ItemType.integerItem; + inferredType = AtomicItemType.integerItem; } else if ( expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV ) { inferredType = resolveNumericType( - ItemType.decimalItem, + AtomicItemType.decimalItem, resolveNumericType(leftItemType, rightItemType) ); } else { inferredType = resolveNumericType(leftItemType, rightItemType); } } else if ( - rightItemType.isSubtypeOf(ItemType.durationItem) - && !rightItemType.equals(ItemType.durationItem) + rightItemType.isSubtypeOf(AtomicItemType.durationItem) + && !rightItemType.equals(AtomicItemType.durationItem) && expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL ) { inferredType = rightItemType; } - } else if (leftItemType.isSubtypeOf(ItemType.durationItem) && !leftItemType.equals(ItemType.durationItem)) { + } else if (leftItemType.isSubtypeOf(AtomicItemType.durationItem) && !leftItemType.equals(AtomicItemType.durationItem)) { if ( rightItemType.isNumeric() && (expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL @@ -652,7 +654,7 @@ public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression ) { inferredType = leftItemType; } else if (rightItemType.equals(leftItemType)) { - inferredType = ItemType.decimalItem; + inferredType = AtomicItemType.decimalItem; } } @@ -763,7 +765,7 @@ private StaticContext visitAndOrExpr(Expression expression, StaticContext argume ); } - expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem)); return argument; } @@ -793,7 +795,7 @@ public StaticContext visitNotExpr(NotExpression expression, StaticContext argume ); } - expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem)); return argument; } @@ -845,17 +847,17 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static ItemType rightItemType = isRightEmpty ? leftInferredType.getItemType() : rightInferredType.getItemType(); // Type must be a strict subtype of atomic - if (leftItemType.isSubtypeOf(ItemType.JSONItem) || rightItemType.isSubtypeOf(ItemType.JSONItem)) { + if (leftItemType.isSubtypeOf(AtomicItemType.JSONItem) || rightItemType.isSubtypeOf(AtomicItemType.JSONItem)) { throw new UnexpectedStaticTypeException( "It is not possible to compare with non-atomic types", ErrorCode.NonAtomicElementErrorCode ); } if ( - !leftItemType.isSubtypeOf(ItemType.atomicItem) - || !rightItemType.isSubtypeOf(ItemType.atomicItem) - || leftItemType.equals(ItemType.atomicItem) - || rightItemType.equals(ItemType.atomicItem) + !leftItemType.isSubtypeOf(AtomicItemType.atomicItem) + || !rightItemType.isSubtypeOf(AtomicItemType.atomicItem) + || leftItemType.equals(AtomicItemType.atomicItem) + || rightItemType.equals(AtomicItemType.atomicItem) ) { throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types"); } @@ -866,8 +868,8 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static && !(leftItemType.isNumeric() && rightItemType.isNumeric()) && - !(leftItemType.isSubtypeOf(ItemType.durationItem) - && rightItemType.isSubtypeOf(ItemType.durationItem)) + !(leftItemType.isSubtypeOf(AtomicItemType.durationItem) + && rightItemType.isSubtypeOf(AtomicItemType.durationItem)) && !(leftItemType.canBePromotedToString() && rightItemType.canBePromotedToString()) ) { @@ -885,14 +887,14 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static operator != ComparisonExpression.ComparisonOperator.GC_EQ && operator != ComparisonExpression.ComparisonOperator.GC_NE) - && (leftItemType.equals(ItemType.hexBinaryItem) - || leftItemType.equals(ItemType.base64BinaryItem) + && (leftItemType.equals(AtomicItemType.hexBinaryItem) + || leftItemType.equals(AtomicItemType.base64BinaryItem) || - leftItemType.equals(ItemType.durationItem) - || rightItemType.equals(ItemType.durationItem) + leftItemType.equals(AtomicItemType.durationItem) + || rightItemType.equals(AtomicItemType.durationItem) || - ((leftItemType.equals(ItemType.dayTimeDurationItem) - || leftItemType.equals(ItemType.yearMonthDurationItem)) + ((leftItemType.equals(AtomicItemType.dayTimeDurationItem) + || leftItemType.equals(AtomicItemType.yearMonthDurationItem)) && !rightItemType.equals(leftItemType))) ) { throw new UnexpectedStaticTypeException( @@ -906,7 +908,7 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static } } - expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem, returnArity)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem, returnArity)); return argument; } @@ -968,17 +970,17 @@ public void checkSwitchType(SequenceType type) { if (itemType.isSubtypeOf(ItemType.functionItem)) { throw new UnexpectedStaticTypeException( "function item not allowed for the expressions of switch test condition and cases", - ErrorCode.UnexpectedFunctionITem + ErrorCode.UnexpectedFunctionItem ); } - if (itemType.isSubtypeOf(ItemType.JSONItem)) { + if (itemType.isSubtypeOf(AtomicItemType.JSONItem)) { throw new UnexpectedStaticTypeException( "switch test condition and cases expressions' item type must match atomic, instead inferred: " + itemType, ErrorCode.NonAtomicElementErrorCode ); } - if (!itemType.isSubtypeOf(ItemType.atomicItem)) { + if (!itemType.isSubtypeOf(AtomicItemType.atomicItem)) { throw new UnexpectedStaticTypeException( "switch test condition and cases expressions' item type must match atomic, instead inferred: " + itemType @@ -1116,7 +1118,7 @@ public StaticContext visitRangeExpr(RangeExpression expression, StaticContext ar ); } - SequenceType intOpt = new SequenceType(ItemType.integerItem, SequenceType.Arity.OneOrZero); + SequenceType intOpt = new SequenceType(AtomicItemType.integerItem, SequenceType.Arity.OneOrZero); if (!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)) { throw new UnexpectedStaticTypeException( "operands of the range expression must match type integer? instead found: " @@ -1126,7 +1128,7 @@ public StaticContext visitRangeExpr(RangeExpression expression, StaticContext ar ); } - expression.setInferredSequenceType(new SequenceType(ItemType.integerItem, SequenceType.Arity.ZeroOrMore)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.integerItem, SequenceType.Arity.ZeroOrMore)); System.out.println("visiting Range expression, type set to: " + expression.getInferredSequenceType()); return argument; } @@ -1143,7 +1145,7 @@ public StaticContext visitStringConcatExpr(StringConcatExpression expression, St throw new OurBadException("A child expression of a ConcatExpression has no inferred type"); } - SequenceType intOpt = new SequenceType(ItemType.atomicItem, SequenceType.Arity.OneOrZero); + SequenceType intOpt = new SequenceType(AtomicItemType.atomicItem, SequenceType.Arity.OneOrZero); if (!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)) { throw new UnexpectedStaticTypeException( "operands of the concat expression must match type atomic? instead found: " @@ -1153,7 +1155,7 @@ public StaticContext visitStringConcatExpr(StringConcatExpression expression, St ); } - expression.setInferredSequenceType(new SequenceType(ItemType.stringItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.stringItem)); System.out.println("visiting Concat expression, type set to: " + expression.getInferredSequenceType()); return argument; } @@ -1200,7 +1202,7 @@ public StaticContext visitQuantifiedExpression(QuantifiedExpression expression, } } - expression.setInferredSequenceType(new SequenceType(ItemType.booleanItem)); + expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem)); System.out.println("visiting Quantified expression, type set to: " + expression.getInferredSequenceType()); return argument; } @@ -1332,7 +1334,7 @@ public StaticContext visitFilterExpression(FilterExpression expression, StaticCo // if we are filter one or less items or we use an integer to select a specific position we return at most one // element, otherwise * SequenceType.Arity inferredArity = (mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) - || predicateType.getItemType().equals(ItemType.integerItem)) + || predicateType.getItemType().equals(AtomicItemType.integerItem)) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; expression.setInferredSequenceType(new SequenceType(mainType.getItemType(), inferredArity)); @@ -1585,13 +1587,13 @@ public StaticContext visitOrderByClause(OrderByClause expression, StaticContext if ( !orderType.isSubtypeOf(SequenceType.createSequenceType("atomic?")) || - orderType.getItemType().equals(ItemType.atomicItem) + orderType.getItemType().equals(AtomicItemType.atomicItem) || - orderType.getItemType().equals(ItemType.durationItem) + orderType.getItemType().equals(AtomicItemType.durationItem) || - orderType.getItemType().equals(ItemType.hexBinaryItem) + orderType.getItemType().equals(AtomicItemType.hexBinaryItem) || - orderType.getItemType().equals(ItemType.base64BinaryItem) + orderType.getItemType().equals(AtomicItemType.base64BinaryItem) ) { throw new UnexpectedStaticTypeException( "order by sorting expression's type must match atomic? and be comparable using 'gt' operator (so duration, hexBinary, base64Binary and atomic item type are not allowed), instead inferred: " diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index 7094ba6a94..05292ba073 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -54,6 +54,7 @@ import org.rumbledb.expressions.primary.VariableReferenceExpression; import org.rumbledb.expressions.quantifiers.QuantifiedExpression; import org.rumbledb.expressions.quantifiers.QuantifiedExpressionVar; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; @@ -271,7 +272,7 @@ public StaticContext visitForClause(ForClause clause, StaticContext argument) { if (clause.getPositionalVariableName() != null) { result.addVariable( clause.getPositionalVariableName(), - new SequenceType(ItemType.integerItem), + new SequenceType(AtomicItemType.integerItem), clause.getMetadata(), ExecutionMode.LOCAL ); @@ -325,7 +326,7 @@ public StaticContext visitCountClause(CountClause expression, StaticContext argu StaticContext result = new StaticContext(argument); result.addVariable( expression.getCountVariable().getVariableName(), - new SequenceType(ItemType.integerItem, SequenceType.Arity.One), + new SequenceType(AtomicItemType.integerItem, SequenceType.Arity.One), expression.getMetadata(), ExecutionMode.LOCAL ); diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 16ef273e30..986f3f3fa4 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -109,6 +109,7 @@ import org.rumbledb.parser.JsoniqParser.SetterContext; import org.rumbledb.parser.JsoniqParser.UriLiteralContext; import org.rumbledb.runtime.functions.input.FileSystemUtil; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/errorcodes/ErrorCode.java b/src/main/java/org/rumbledb/errorcodes/ErrorCode.java index 82b0030526..9ae78d54f9 100644 --- a/src/main/java/org/rumbledb/errorcodes/ErrorCode.java +++ b/src/main/java/org/rumbledb/errorcodes/ErrorCode.java @@ -107,7 +107,7 @@ public enum ErrorCode { InvalidGroupVariableErrorCode("XQST0094"), AtomizationError("FOTY0012"), - UnexpectedFunctionITem("FOTY0015"), + UnexpectedFunctionItem("FOTY0015"), InvalidTimezoneValue("FODT0003"); diff --git a/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpressionVar.java b/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpressionVar.java index d5f86dbdb5..d71da364bb 100644 --- a/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpressionVar.java +++ b/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpressionVar.java @@ -22,6 +22,7 @@ import org.rumbledb.context.Name; import org.rumbledb.expressions.Expression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/items/AnyURIItem.java b/src/main/java/org/rumbledb/items/AnyURIItem.java index c820f96f8c..e8bab41ab4 100644 --- a/src/main/java/org/rumbledb/items/AnyURIItem.java +++ b/src/main/java/org/rumbledb/items/AnyURIItem.java @@ -24,6 +24,7 @@ import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; import org.rumbledb.api.Item; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.net.URI; @@ -92,15 +93,15 @@ public URI getValue() { @Override public boolean canBePromotedTo(ItemType type) { - return type.equals(ItemType.stringItem); + return type.equals(AtomicItemType.stringItem); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(this.getStringValue()); } - if (itemType.equals(ItemType.anyURIItem)) { + if (itemType.equals(AtomicItemType.anyURIItem)) { return this; } throw new ClassCastException(); @@ -108,7 +109,7 @@ public Item castAs(ItemType itemType) { @Override public boolean isCastableAs(ItemType itemType) { - return (itemType.equals(ItemType.anyURIItem) || itemType.equals(ItemType.stringItem)); + return (itemType.equals(AtomicItemType.anyURIItem) || itemType.equals(AtomicItemType.stringItem)); } @Override @@ -133,11 +134,11 @@ public boolean isAnyURI() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.anyURIItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.anyURIItem) || super.isTypeOf(type); } @Override public ItemType getDynamicType() { - return ItemType.anyURIItem; + return AtomicItemType.anyURIItem; } } diff --git a/src/main/java/org/rumbledb/items/ArrayItem.java b/src/main/java/org/rumbledb/items/ArrayItem.java index b630870031..37abb5785c 100644 --- a/src/main/java/org/rumbledb/items/ArrayItem.java +++ b/src/main/java/org/rumbledb/items/ArrayItem.java @@ -25,6 +25,7 @@ import com.esotericsoftware.kryo.io.Output; import org.apache.commons.text.StringEscapeUtils; import org.rumbledb.api.Item; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.ArrayList; import java.util.List; @@ -76,7 +77,7 @@ public int getSize() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.arrayItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.arrayItem) || super.isTypeOf(type); } @Override @@ -143,6 +144,6 @@ public int hashCode() { @Override public ItemType getDynamicType() { - return ItemType.arrayItem; + return AtomicItemType.arrayItem; } } diff --git a/src/main/java/org/rumbledb/items/AtomicItem.java b/src/main/java/org/rumbledb/items/AtomicItem.java index 40e4b20b73..4c1880bd68 100644 --- a/src/main/java/org/rumbledb/items/AtomicItem.java +++ b/src/main/java/org/rumbledb/items/AtomicItem.java @@ -21,6 +21,7 @@ package org.rumbledb.items; import org.rumbledb.api.Item; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; public abstract class AtomicItem extends Item { @@ -38,7 +39,7 @@ public boolean isAtomic() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.atomicItem) || type.equals(ItemType.item); + return type.equals(AtomicItemType.atomicItem) || type.equals(ItemType.item); } @Override diff --git a/src/main/java/org/rumbledb/items/Base64BinaryItem.java b/src/main/java/org/rumbledb/items/Base64BinaryItem.java index f796de65be..2ab4e3ad3d 100644 --- a/src/main/java/org/rumbledb/items/Base64BinaryItem.java +++ b/src/main/java/org/rumbledb/items/Base64BinaryItem.java @@ -11,6 +11,7 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import javax.xml.bind.DatatypeConverter; import java.util.Arrays; @@ -72,7 +73,7 @@ static byte[] parseBase64BinaryString(String base64BinaryString) throws IllegalA @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.base64BinaryItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.base64BinaryItem) || super.isTypeOf(type); } @Override @@ -87,22 +88,22 @@ public boolean isBase64Binary() { @Override public boolean isCastableAs(ItemType itemType) { - return itemType.equals(ItemType.base64BinaryItem) + return itemType.equals(AtomicItemType.base64BinaryItem) || - itemType.equals(ItemType.hexBinaryItem) + itemType.equals(AtomicItemType.hexBinaryItem) || - itemType.equals(ItemType.stringItem); + itemType.equals(AtomicItemType.stringItem); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(this.getStringValue()); } - if (itemType.equals(ItemType.base64BinaryItem)) { + if (itemType.equals(AtomicItemType.base64BinaryItem)) { return this; } - if (itemType.equals(ItemType.hexBinaryItem)) { + if (itemType.equals(AtomicItemType.hexBinaryItem)) { return ItemFactory.getInstance().createHexBinaryItem(Hex.encodeHexString(this.value)); } throw new ClassCastException(); @@ -203,6 +204,6 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return ItemType.base64BinaryItem; + return AtomicItemType.base64BinaryItem; } } diff --git a/src/main/java/org/rumbledb/items/BooleanItem.java b/src/main/java/org/rumbledb/items/BooleanItem.java index bcbd6b2fd5..a9833a8359 100644 --- a/src/main/java/org/rumbledb/items/BooleanItem.java +++ b/src/main/java/org/rumbledb/items/BooleanItem.java @@ -27,6 +27,7 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.math.BigDecimal; @@ -66,24 +67,24 @@ public boolean isBoolean() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.booleanItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.booleanItem) || super.isTypeOf(type); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.booleanItem)) { + if (itemType.equals(AtomicItemType.booleanItem)) { return this; } - if (itemType.equals(ItemType.doubleItem)) { + if (itemType.equals(AtomicItemType.doubleItem)) { return ItemFactory.getInstance().createDoubleItem(this.hashCode()); } - if (itemType.equals(ItemType.decimalItem)) { + if (itemType.equals(AtomicItemType.decimalItem)) { return ItemFactory.getInstance().createDecimalItem(BigDecimal.valueOf(this.hashCode())); } - if (itemType.equals(ItemType.integerItem)) { + if (itemType.equals(AtomicItemType.integerItem)) { return ItemFactory.getInstance().createIntItem(this.hashCode()); } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(String.valueOf(this.getBooleanValue())); } throw new ClassCastException(); @@ -91,9 +92,9 @@ public Item castAs(ItemType itemType) { @Override public boolean isCastableAs(ItemType itemType) { - return !itemType.equals(ItemType.atomicItem) + return !itemType.equals(AtomicItemType.atomicItem) && - !itemType.equals(ItemType.nullItem); + !itemType.equals(AtomicItemType.nullItem); } @Override @@ -152,6 +153,6 @@ public Item compareItem( @Override public ItemType getDynamicType() { - return ItemType.booleanItem; + return AtomicItemType.booleanItem; } } diff --git a/src/main/java/org/rumbledb/items/DateItem.java b/src/main/java/org/rumbledb/items/DateItem.java index 1817361301..88e5a75027 100644 --- a/src/main/java/org/rumbledb/items/DateItem.java +++ b/src/main/java/org/rumbledb/items/DateItem.java @@ -12,6 +12,7 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; public class DateItem extends AtomicItem { @@ -31,7 +32,7 @@ public DateItem() { } DateItem(String dateTimeString) { - this.value = DateTimeItem.parseDateTime(dateTimeString, ItemType.dateItem); + this.value = DateTimeItem.parseDateTime(dateTimeString, AtomicItemType.dateItem); if (!dateTimeString.endsWith("Z") && this.value.getZone() == DateTimeZone.getDefault()) { this.hasTimeZone = false; this.value = this.value.withZoneRetainFields(DateTimeZone.UTC); @@ -86,22 +87,22 @@ public int hashCode() { @Override public boolean isCastableAs(ItemType itemType) { - return itemType.equals(ItemType.dateItem) + return itemType.equals(AtomicItemType.dateItem) || - itemType.equals(ItemType.dateTimeItem) + itemType.equals(AtomicItemType.dateTimeItem) || - itemType.equals(ItemType.stringItem); + itemType.equals(AtomicItemType.stringItem); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.dateItem)) { + if (itemType.equals(AtomicItemType.dateItem)) { return this; } - if (itemType.equals(ItemType.dateTimeItem)) { + if (itemType.equals(AtomicItemType.dateTimeItem)) { return ItemFactory.getInstance().createDateTimeItem(this.getValue(), this.hasTimeZone); } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(this.serialize()); } throw new ClassCastException(); @@ -109,7 +110,7 @@ public Item castAs(ItemType itemType) { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.dateItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.dateItem) || super.isTypeOf(type); } @Override @@ -195,6 +196,6 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return ItemType.dateItem; + return AtomicItemType.dateItem; } } diff --git a/src/main/java/org/rumbledb/items/DateTimeItem.java b/src/main/java/org/rumbledb/items/DateTimeItem.java index 5c7b276509..7809632521 100644 --- a/src/main/java/org/rumbledb/items/DateTimeItem.java +++ b/src/main/java/org/rumbledb/items/DateTimeItem.java @@ -16,6 +16,7 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.regex.Pattern; @@ -67,7 +68,7 @@ public DateTimeItem() { } DateTimeItem(String dateTimeString) { - this.value = parseDateTime(dateTimeString, ItemType.dateTimeItem); + this.value = parseDateTime(dateTimeString, AtomicItemType.dateTimeItem); if (!dateTimeString.endsWith("Z") && this.value.getZone() == DateTimeZone.getDefault()) { this.hasTimeZone = false; this.value = this.value.withZoneRetainFields(DateTimeZone.UTC); @@ -105,16 +106,16 @@ public boolean hasDateTime() { @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(this.serialize()); } - if (itemType.equals(ItemType.dateTimeItem)) { + if (itemType.equals(AtomicItemType.dateTimeItem)) { return this; } - if (itemType.equals(ItemType.dateItem)) { + if (itemType.equals(AtomicItemType.dateItem)) { return ItemFactory.getInstance().createDateItem(this.getDateTimeValue(), this.hasTimeZone); } - if (itemType.equals(ItemType.timeItem)) { + if (itemType.equals(AtomicItemType.timeItem)) { return ItemFactory.getInstance().createTimeItem(this.getDateTimeValue(), this.hasTimeZone); } throw new ClassCastException(); @@ -122,10 +123,10 @@ public Item castAs(ItemType itemType) { @Override public boolean isCastableAs(ItemType itemType) { - return itemType.equals(ItemType.dateTimeItem) - || itemType.equals(ItemType.dateItem) - || itemType.equals(ItemType.timeItem) - || itemType.equals(ItemType.stringItem); + return itemType.equals(AtomicItemType.dateTimeItem) + || itemType.equals(AtomicItemType.dateItem) + || itemType.equals(AtomicItemType.timeItem) + || itemType.equals(AtomicItemType.stringItem); } @Override @@ -152,7 +153,7 @@ public int hashCode() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.dateTimeItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.dateTimeItem) || super.isTypeOf(type); } @Override @@ -184,10 +185,10 @@ public void read(Kryo kryo, Input input) { } private static DateTimeFormatter getDateTimeFormatter(ItemType dateTimeType) { - if (dateTimeType.equals(ItemType.dateTimeItem)) { + if (dateTimeType.equals(AtomicItemType.dateTimeItem)) { return ISODateTimeFormat.dateTimeParser().withOffsetParsed(); } - if (dateTimeType.equals(ItemType.dateItem)) { + if (dateTimeType.equals(AtomicItemType.dateItem)) { DateTimeParser dtParser = new DateTimeFormatterBuilder().appendOptional( ((new DateTimeFormatterBuilder()).appendTimeZoneOffset("Z", true, 2, 4).toFormatter()).getParser() ).toParser(); @@ -196,20 +197,20 @@ private static DateTimeFormatter getDateTimeFormatter(ItemType dateTimeType) { .toFormatter() .withOffsetParsed(); } - if (dateTimeType.equals(ItemType.timeItem)) { + if (dateTimeType.equals(AtomicItemType.timeItem)) { return ISODateTimeFormat.timeParser().withOffsetParsed(); } throw new IllegalArgumentException(); } private static boolean checkInvalidDateTimeFormat(String dateTime, ItemType dateTimeType) { - if (dateTimeType.equals(ItemType.dateTimeItem)) { + if (dateTimeType.equals(AtomicItemType.dateTimeItem)) { return dateTimePattern.matcher(dateTime).matches(); } - if (dateTimeType.equals(ItemType.dateItem)) { + if (dateTimeType.equals(AtomicItemType.dateItem)) { return datePattern.matcher(dateTime).matches(); } - if (dateTimeType.equals(ItemType.timeItem)) { + if (dateTimeType.equals(AtomicItemType.timeItem)) { return timePattern.matcher(dateTime).matches(); } return false; @@ -317,6 +318,6 @@ public Item compareItem( @Override public ItemType getDynamicType() { - return ItemType.dateTimeItem; + return AtomicItemType.dateTimeItem; } } diff --git a/src/main/java/org/rumbledb/items/DayTimeDurationItem.java b/src/main/java/org/rumbledb/items/DayTimeDurationItem.java index 63d1a4bab3..c35aad8f77 100644 --- a/src/main/java/org/rumbledb/items/DayTimeDurationItem.java +++ b/src/main/java/org/rumbledb/items/DayTimeDurationItem.java @@ -9,6 +9,7 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.math.BigDecimal; @@ -48,12 +49,12 @@ public boolean isDayTimeDuration() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.dayTimeDurationItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.dayTimeDurationItem) || super.isTypeOf(type); } @Override public void read(Kryo kryo, Input input) { - this.value = getDurationFromString(input.readString(), ItemType.dayTimeDurationItem).normalizedStandard( + this.value = getDurationFromString(input.readString(), AtomicItemType.dayTimeDurationItem).normalizedStandard( PeriodType.dayTime() ); this.isNegative = this.value.toString().contains("-"); @@ -61,27 +62,27 @@ public void read(Kryo kryo, Input input) { @Override public boolean isCastableAs(ItemType itemType) { - return itemType.equals(ItemType.dayTimeDurationItem) + return itemType.equals(AtomicItemType.dayTimeDurationItem) || - itemType.equals(ItemType.yearMonthDurationItem) + itemType.equals(AtomicItemType.yearMonthDurationItem) || - itemType.equals(ItemType.durationItem) + itemType.equals(AtomicItemType.durationItem) || - itemType.equals(ItemType.stringItem); + itemType.equals(AtomicItemType.stringItem); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.durationItem)) { + if (itemType.equals(AtomicItemType.durationItem)) { return ItemFactory.getInstance().createDurationItem(this.getValue()); } - if (itemType.equals(ItemType.dayTimeDurationItem)) { + if (itemType.equals(AtomicItemType.dayTimeDurationItem)) { return this; } - if (itemType.equals(ItemType.yearMonthDurationItem)) { + if (itemType.equals(AtomicItemType.yearMonthDurationItem)) { return ItemFactory.getInstance().createYearMonthDurationItem(this.getValue()); } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(this.serialize()); } throw new ClassCastException(); @@ -166,6 +167,6 @@ public Item divide(Item other) { @Override public ItemType getDynamicType() { - return ItemType.dayTimeDurationItem; + return AtomicItemType.dayTimeDurationItem; } } diff --git a/src/main/java/org/rumbledb/items/DecimalItem.java b/src/main/java/org/rumbledb/items/DecimalItem.java index cdc3ba24a8..e04e912c21 100644 --- a/src/main/java/org/rumbledb/items/DecimalItem.java +++ b/src/main/java/org/rumbledb/items/DecimalItem.java @@ -30,6 +30,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.math.BigDecimal; import java.math.BigInteger; @@ -88,29 +89,29 @@ public boolean isDecimal() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.decimalItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.decimalItem) || super.isTypeOf(type); } @Override public boolean canBePromotedTo(ItemType type) { - return type.equals(ItemType.doubleItem) || super.canBePromotedTo(type); + return type.equals(AtomicItemType.doubleItem) || super.canBePromotedTo(type); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.booleanItem)) { + if (itemType.equals(AtomicItemType.booleanItem)) { return ItemFactory.getInstance().createBooleanItem(!this.getDecimalValue().equals(BigDecimal.ZERO)); } - if (itemType.equals(ItemType.doubleItem)) { + if (itemType.equals(AtomicItemType.doubleItem)) { return ItemFactory.getInstance().createDoubleItem(this.castToDoubleValue()); } - if (itemType.equals(ItemType.decimalItem)) { + if (itemType.equals(AtomicItemType.decimalItem)) { return this; } - if (itemType.equals(ItemType.integerItem)) { + if (itemType.equals(AtomicItemType.integerItem)) { return ItemFactory.getInstance().createIntegerItem(this.castToIntegerValue()); } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(String.valueOf(this.getDecimalValue())); } throw new ClassCastException(); @@ -118,9 +119,9 @@ public Item castAs(ItemType itemType) { @Override public boolean isCastableAs(ItemType itemType) { - return !itemType.equals(ItemType.atomicItem) + return !itemType.equals(AtomicItemType.atomicItem) && - !itemType.equals(ItemType.nullItem); + !itemType.equals(AtomicItemType.nullItem); } @Override @@ -266,6 +267,6 @@ public Item idivide(Item other) { @Override public ItemType getDynamicType() { - return ItemType.decimalItem; + return AtomicItemType.decimalItem; } } diff --git a/src/main/java/org/rumbledb/items/DoubleItem.java b/src/main/java/org/rumbledb/items/DoubleItem.java index df99688d96..fdda5828e4 100644 --- a/src/main/java/org/rumbledb/items/DoubleItem.java +++ b/src/main/java/org/rumbledb/items/DoubleItem.java @@ -30,6 +30,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.math.BigDecimal; import java.math.BigInteger; @@ -88,24 +89,24 @@ public boolean isDouble() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.doubleItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.doubleItem) || super.isTypeOf(type); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.booleanItem)) { + if (itemType.equals(AtomicItemType.booleanItem)) { return ItemFactory.getInstance().createBooleanItem(this.getDoubleValue() != 0); } - if (itemType.equals(ItemType.doubleItem)) { + if (itemType.equals(AtomicItemType.doubleItem)) { return this; } - if (itemType.equals(ItemType.decimalItem)) { + if (itemType.equals(AtomicItemType.decimalItem)) { return ItemFactory.getInstance().createDecimalItem(this.castToDecimalValue()); } - if (itemType.equals(ItemType.integerItem)) { + if (itemType.equals(AtomicItemType.integerItem)) { return ItemFactory.getInstance().createIntegerItem(this.castToIntegerValue()); } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(String.valueOf(this.getDoubleValue())); } throw new ClassCastException(); @@ -113,11 +114,11 @@ public Item castAs(ItemType itemType) { @Override public boolean isCastableAs(ItemType itemType) { - if (itemType.equals(ItemType.atomicItem) || itemType.equals(ItemType.nullItem)) { + if (itemType.equals(AtomicItemType.atomicItem) || itemType.equals(AtomicItemType.nullItem)) { return false; - } else if (itemType.equals(ItemType.decimalItem)) { + } else if (itemType.equals(AtomicItemType.decimalItem)) { return !Double.isInfinite(this.getValue()); - } else if (itemType.equals(ItemType.integerItem)) { + } else if (itemType.equals(AtomicItemType.integerItem)) { return !(Integer.MAX_VALUE < this.getValue()) && !(Integer.MIN_VALUE > this.getValue()); } return true; @@ -230,6 +231,6 @@ public Item idivide(Item other) { @Override public ItemType getDynamicType() { - return ItemType.doubleItem; + return AtomicItemType.doubleItem; } } diff --git a/src/main/java/org/rumbledb/items/DurationItem.java b/src/main/java/org/rumbledb/items/DurationItem.java index 3eadfd9b72..780c9f04be 100644 --- a/src/main/java/org/rumbledb/items/DurationItem.java +++ b/src/main/java/org/rumbledb/items/DurationItem.java @@ -15,6 +15,7 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.regex.Pattern; @@ -121,32 +122,32 @@ public int hashCode() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.durationItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.durationItem) || super.isTypeOf(type); } @Override public boolean isCastableAs(ItemType itemType) { - return itemType.equals(ItemType.durationItem) + return itemType.equals(AtomicItemType.durationItem) || - itemType.equals(ItemType.yearMonthDurationItem) + itemType.equals(AtomicItemType.yearMonthDurationItem) || - itemType.equals(ItemType.dayTimeDurationItem) + itemType.equals(AtomicItemType.dayTimeDurationItem) || - itemType.equals(ItemType.stringItem); + itemType.equals(AtomicItemType.stringItem); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.durationItem)) { + if (itemType.equals(AtomicItemType.durationItem)) { return this; } - if (itemType.equals(ItemType.yearMonthDurationItem)) { + if (itemType.equals(AtomicItemType.yearMonthDurationItem)) { return ItemFactory.getInstance().createYearMonthDurationItem(this.getValue()); } - if (itemType.equals(ItemType.dayTimeDurationItem)) { + if (itemType.equals(AtomicItemType.dayTimeDurationItem)) { return ItemFactory.getInstance().createDayTimeDurationItem(this.getValue()); } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(this.serialize()); } throw new ClassCastException(); @@ -167,17 +168,17 @@ public void write(Kryo kryo, Output output) { @Override public void read(Kryo kryo, Input input) { - this.value = getDurationFromString(input.readString(), ItemType.durationItem).normalizedStandard( + this.value = getDurationFromString(input.readString(), AtomicItemType.durationItem).normalizedStandard( PeriodType.yearMonthDayTime() ); this.isNegative = this.value.toString().contains("-"); } private static PeriodFormatter getPeriodFormatter(ItemType durationType) { - if (durationType.equals(ItemType.durationItem)) { + if (durationType.equals(AtomicItemType.durationItem)) { return ISOPeriodFormat.standard(); } - if (durationType.equals(ItemType.yearMonthDurationItem)) { + if (durationType.equals(AtomicItemType.yearMonthDurationItem)) { return new PeriodFormatterBuilder().appendLiteral("P") .appendYears() .appendSuffix("Y") @@ -186,7 +187,7 @@ private static PeriodFormatter getPeriodFormatter(ItemType durationType) { .toFormatter(); } - if (durationType.equals(ItemType.dayTimeDurationItem)) { + if (durationType.equals(AtomicItemType.dayTimeDurationItem)) { return new PeriodFormatterBuilder().appendLiteral("P") .appendDays() .appendSuffix("D") @@ -203,28 +204,28 @@ private static PeriodFormatter getPeriodFormatter(ItemType durationType) { } private static PeriodType getPeriodType(ItemType durationType) { - if (durationType.equals(ItemType.durationItem)) { + if (durationType.equals(AtomicItemType.durationItem)) { return PeriodType.yearMonthDayTime(); } - if (durationType.equals(ItemType.yearMonthDurationItem)) { + if (durationType.equals(AtomicItemType.yearMonthDurationItem)) { return PeriodType.forFields( new DurationFieldType[] { DurationFieldType.years(), DurationFieldType.months() } ); } - if (durationType.equals(ItemType.dayTimeDurationItem)) { + if (durationType.equals(AtomicItemType.dayTimeDurationItem)) { return PeriodType.dayTime(); } throw new IllegalArgumentException(); } private static boolean checkInvalidDurationFormat(String duration, ItemType durationType) { - if (durationType.equals(ItemType.durationItem)) { + if (durationType.equals(AtomicItemType.durationItem)) { return durationPattern.matcher(duration).matches(); } - if (durationType.equals(ItemType.yearMonthDurationItem)) { + if (durationType.equals(AtomicItemType.yearMonthDurationItem)) { return yearMonthDurationPattern.matcher(duration).matches(); } - if (durationType.equals(ItemType.dayTimeDurationItem)) { + if (durationType.equals(AtomicItemType.dayTimeDurationItem)) { return dayTimeDurationPattern.matcher(duration).matches(); } return false; @@ -304,6 +305,6 @@ public Item compareItem( @Override public ItemType getDynamicType() { - return ItemType.durationItem; + return AtomicItemType.durationItem; } } diff --git a/src/main/java/org/rumbledb/items/FunctionItem.java b/src/main/java/org/rumbledb/items/FunctionItem.java index ea2c124316..793f2b0fdb 100644 --- a/src/main/java/org/rumbledb/items/FunctionItem.java +++ b/src/main/java/org/rumbledb/items/FunctionItem.java @@ -36,6 +36,7 @@ import org.rumbledb.exceptions.RumbleException; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.types.FunctionSignature; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/items/HexBinaryItem.java b/src/main/java/org/rumbledb/items/HexBinaryItem.java index 6ec65fa56a..82c1d30ab6 100644 --- a/src/main/java/org/rumbledb/items/HexBinaryItem.java +++ b/src/main/java/org/rumbledb/items/HexBinaryItem.java @@ -11,6 +11,7 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.Arrays; import java.util.regex.Pattern; @@ -66,7 +67,7 @@ static byte[] parseHexBinaryString(String hexBinaryString) throws IllegalArgumen @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.hexBinaryItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.hexBinaryItem) || super.isTypeOf(type); } @Override @@ -81,22 +82,22 @@ public boolean isHexBinary() { @Override public boolean isCastableAs(ItemType itemType) { - return itemType.equals(ItemType.hexBinaryItem) + return itemType.equals(AtomicItemType.hexBinaryItem) || - itemType.equals(ItemType.base64BinaryItem) + itemType.equals(AtomicItemType.base64BinaryItem) || - itemType.equals(ItemType.stringItem); + itemType.equals(AtomicItemType.stringItem); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.hexBinaryItem)) { + if (itemType.equals(AtomicItemType.hexBinaryItem)) { return this; } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(this.getStringValue()); } - if (itemType.equals(ItemType.base64BinaryItem)) { + if (itemType.equals(AtomicItemType.base64BinaryItem)) { return ItemFactory.getInstance().createBase64BinaryItem(Base64.encodeBase64String(this.value)); } throw new ClassCastException(); @@ -197,6 +198,6 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return ItemType.hexBinaryItem; + return AtomicItemType.hexBinaryItem; } } diff --git a/src/main/java/org/rumbledb/items/IntItem.java b/src/main/java/org/rumbledb/items/IntItem.java index 6115a918b4..9e6a8b95d4 100644 --- a/src/main/java/org/rumbledb/items/IntItem.java +++ b/src/main/java/org/rumbledb/items/IntItem.java @@ -30,6 +30,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.math.BigDecimal; import java.math.BigInteger; @@ -93,31 +94,31 @@ public boolean isInt() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.integerItem) - || type.equals(ItemType.decimalItem) + return type.equals(AtomicItemType.integerItem) + || type.equals(AtomicItemType.decimalItem) || super.isTypeOf(type); } @Override public boolean canBePromotedTo(ItemType type) { - return type.equals(ItemType.doubleItem) || super.canBePromotedTo(type); + return type.equals(AtomicItemType.doubleItem) || super.canBePromotedTo(type); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.booleanItem)) { + if (itemType.equals(AtomicItemType.booleanItem)) { return ItemFactory.getInstance().createBooleanItem(this.value != 0); } - if (itemType.equals(ItemType.doubleItem)) { + if (itemType.equals(AtomicItemType.doubleItem)) { return ItemFactory.getInstance().createDoubleItem(this.castToDoubleValue()); } - if (itemType.equals(ItemType.decimalItem)) { + if (itemType.equals(AtomicItemType.decimalItem)) { return ItemFactory.getInstance().createDecimalItem(this.castToDecimalValue()); } - if (itemType.equals(ItemType.integerItem)) { + if (itemType.equals(AtomicItemType.integerItem)) { return this; } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(String.valueOf(this.value)); } throw new ClassCastException(); @@ -125,9 +126,9 @@ public Item castAs(ItemType itemType) { @Override public boolean isCastableAs(ItemType itemType) { - return !itemType.equals(ItemType.atomicItem) + return !itemType.equals(AtomicItemType.atomicItem) && - !itemType.equals(ItemType.nullItem); + !itemType.equals(AtomicItemType.nullItem); } @Override @@ -345,6 +346,6 @@ public Item idivide(Item other) { @Override public ItemType getDynamicType() { - return ItemType.integerItem; + return AtomicItemType.integerItem; } } diff --git a/src/main/java/org/rumbledb/items/IntegerItem.java b/src/main/java/org/rumbledb/items/IntegerItem.java index 0224683a17..d99a346930 100644 --- a/src/main/java/org/rumbledb/items/IntegerItem.java +++ b/src/main/java/org/rumbledb/items/IntegerItem.java @@ -30,6 +30,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.math.BigDecimal; import java.math.BigInteger; @@ -87,31 +88,31 @@ public boolean isInteger() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.integerItem) - || type.equals(ItemType.decimalItem) + return type.equals(AtomicItemType.integerItem) + || type.equals(AtomicItemType.decimalItem) || super.isTypeOf(type); } @Override public boolean canBePromotedTo(ItemType type) { - return type.equals(ItemType.doubleItem) || super.canBePromotedTo(type); + return type.equals(AtomicItemType.doubleItem) || super.canBePromotedTo(type); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.booleanItem)) { + if (itemType.equals(AtomicItemType.booleanItem)) { return ItemFactory.getInstance().createBooleanItem(!this.value.equals(BigInteger.ZERO)); } - if (itemType.equals(ItemType.doubleItem)) { + if (itemType.equals(AtomicItemType.doubleItem)) { return ItemFactory.getInstance().createDoubleItem(this.castToDoubleValue()); } - if (itemType.equals(ItemType.decimalItem)) { + if (itemType.equals(AtomicItemType.decimalItem)) { return ItemFactory.getInstance().createDecimalItem(this.castToDecimalValue()); } - if (itemType.equals(ItemType.integerItem)) { + if (itemType.equals(AtomicItemType.integerItem)) { return this; } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(this.value.toString()); } throw new ClassCastException(); @@ -119,9 +120,9 @@ public Item castAs(ItemType itemType) { @Override public boolean isCastableAs(ItemType itemType) { - return !itemType.equals(ItemType.atomicItem) + return !itemType.equals(AtomicItemType.atomicItem) && - !itemType.equals(ItemType.nullItem); + !itemType.equals(AtomicItemType.nullItem); } @Override @@ -291,6 +292,6 @@ public Item idivide(Item other) { @Override public ItemType getDynamicType() { - return ItemType.integerItem; + return AtomicItemType.integerItem; } } diff --git a/src/main/java/org/rumbledb/items/JsonItem.java b/src/main/java/org/rumbledb/items/JsonItem.java index f0307fee31..a544c1c1a9 100644 --- a/src/main/java/org/rumbledb/items/JsonItem.java +++ b/src/main/java/org/rumbledb/items/JsonItem.java @@ -21,6 +21,7 @@ package org.rumbledb.items; import org.rumbledb.api.Item; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; public abstract class JsonItem extends Item { @@ -44,6 +45,6 @@ public boolean isAtomic() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.JSONItem) || type.equals(ItemType.item); + return type.equals(AtomicItemType.JSONItem) || type.equals(ItemType.item); } } diff --git a/src/main/java/org/rumbledb/items/NullItem.java b/src/main/java/org/rumbledb/items/NullItem.java index 29de8d5042..446b564138 100644 --- a/src/main/java/org/rumbledb/items/NullItem.java +++ b/src/main/java/org/rumbledb/items/NullItem.java @@ -26,6 +26,7 @@ import org.rumbledb.api.Item; import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; public class NullItem extends AtomicItem { @@ -49,22 +50,22 @@ public boolean getEffectiveBooleanValue() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.nullItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.nullItem) || super.isTypeOf(type); } @Override public boolean isCastableAs(ItemType itemType) { - return itemType.equals(ItemType.nullItem) + return itemType.equals(AtomicItemType.nullItem) || - itemType.equals(ItemType.stringItem); + itemType.equals(AtomicItemType.stringItem); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.nullItem)) { + if (itemType.equals(AtomicItemType.nullItem)) { return this; } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(this.serialize()); } throw new ClassCastException(); @@ -117,6 +118,6 @@ public Item compareItem( @Override public ItemType getDynamicType() { - return ItemType.nullItem; + return AtomicItemType.nullItem; } } diff --git a/src/main/java/org/rumbledb/items/ObjectItem.java b/src/main/java/org/rumbledb/items/ObjectItem.java index d81728ab3c..f78e7c42a7 100644 --- a/src/main/java/org/rumbledb/items/ObjectItem.java +++ b/src/main/java/org/rumbledb/items/ObjectItem.java @@ -27,6 +27,7 @@ import org.rumbledb.api.Item; import org.rumbledb.exceptions.DuplicateObjectKeyException; import org.rumbledb.exceptions.ExceptionMetadata; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.ArrayList; import java.util.HashMap; @@ -130,7 +131,7 @@ public boolean isObject() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.objectItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.objectItem) || super.isTypeOf(type); } @Override @@ -213,7 +214,7 @@ public int hashCode() { @Override public ItemType getDynamicType() { - return ItemType.objectItem; + return AtomicItemType.objectItem; } } diff --git a/src/main/java/org/rumbledb/items/StringItem.java b/src/main/java/org/rumbledb/items/StringItem.java index b461d568a6..4b5aa3bc30 100644 --- a/src/main/java/org/rumbledb/items/StringItem.java +++ b/src/main/java/org/rumbledb/items/StringItem.java @@ -27,6 +27,7 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.math.BigDecimal; import java.math.BigInteger; @@ -86,58 +87,58 @@ public boolean isString() { @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.booleanItem)) { + if (itemType.equals(AtomicItemType.booleanItem)) { return ItemFactory.getInstance().createBooleanItem(Boolean.parseBoolean(this.getStringValue())); } - if (itemType.equals(ItemType.doubleItem)) { + if (itemType.equals(AtomicItemType.doubleItem)) { return ItemFactory.getInstance().createDoubleItem(Double.parseDouble(this.getStringValue())); } - if (itemType.equals(ItemType.decimalItem)) { + if (itemType.equals(AtomicItemType.decimalItem)) { return ItemFactory.getInstance().createDecimalItem(new BigDecimal(this.getStringValue())); } - if (itemType.equals(ItemType.integerItem)) { + if (itemType.equals(AtomicItemType.integerItem)) { return ItemFactory.getInstance().createIntegerItem(this.getStringValue()); } - if (itemType.equals(ItemType.nullItem)) { + if (itemType.equals(AtomicItemType.nullItem)) { return ItemFactory.getInstance().createNullItem(); } - if (itemType.equals(ItemType.durationItem)) { + if (itemType.equals(AtomicItemType.durationItem)) { return ItemFactory.getInstance() .createDurationItem( - DurationItem.getDurationFromString(this.getStringValue(), ItemType.durationItem) + DurationItem.getDurationFromString(this.getStringValue(), AtomicItemType.durationItem) ); } - if (itemType.equals(ItemType.yearMonthDurationItem)) { + if (itemType.equals(AtomicItemType.yearMonthDurationItem)) { return ItemFactory.getInstance() .createYearMonthDurationItem( - DurationItem.getDurationFromString(this.getStringValue(), ItemType.yearMonthDurationItem) + DurationItem.getDurationFromString(this.getStringValue(), AtomicItemType.yearMonthDurationItem) ); } - if (itemType.equals(ItemType.dayTimeDurationItem)) { + if (itemType.equals(AtomicItemType.dayTimeDurationItem)) { return ItemFactory.getInstance() .createDayTimeDurationItem( - DurationItem.getDurationFromString(this.getStringValue(), ItemType.dayTimeDurationItem) + DurationItem.getDurationFromString(this.getStringValue(), AtomicItemType.dayTimeDurationItem) ); } - if (itemType.equals(ItemType.dateTimeItem)) { + if (itemType.equals(AtomicItemType.dateTimeItem)) { return ItemFactory.getInstance().createDateTimeItem(this.getStringValue()); } - if (itemType.equals(ItemType.dateItem)) { + if (itemType.equals(AtomicItemType.dateItem)) { return ItemFactory.getInstance().createDateItem(this.getStringValue()); } - if (itemType.equals(ItemType.timeItem)) { + if (itemType.equals(AtomicItemType.timeItem)) { return ItemFactory.getInstance().createTimeItem(this.getStringValue()); } - if (itemType.equals(ItemType.hexBinaryItem)) { + if (itemType.equals(AtomicItemType.hexBinaryItem)) { return ItemFactory.getInstance().createHexBinaryItem(this.getStringValue()); } - if (itemType.equals(ItemType.base64BinaryItem)) { + if (itemType.equals(AtomicItemType.base64BinaryItem)) { return ItemFactory.getInstance().createBase64BinaryItem(this.getStringValue()); } - if (itemType.equals(ItemType.anyURIItem)) { + if (itemType.equals(AtomicItemType.anyURIItem)) { return ItemFactory.getInstance().createAnyURIItem(this.getStringValue()); } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return this; } throw new ClassCastException(); @@ -149,43 +150,43 @@ public boolean getEffectiveBooleanValue() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.stringItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.stringItem) || super.isTypeOf(type); } @Override public boolean isCastableAs(ItemType itemType) { - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return true; } try { - if (itemType.equals(ItemType.integerItem)) { + if (itemType.equals(AtomicItemType.integerItem)) { Integer.parseInt(this.getValue()); - } else if (itemType.equals(ItemType.anyURIItem)) { + } else if (itemType.equals(AtomicItemType.anyURIItem)) { AnyURIItem.parseAnyURIString(this.getValue()); - } else if (itemType.equals(ItemType.decimalItem)) { + } else if (itemType.equals(AtomicItemType.decimalItem)) { if (this.getValue().contains("e") || this.getValue().contains("E")) { return false; } Float.parseFloat(this.getValue()); - } else if (itemType.equals(ItemType.doubleItem)) { + } else if (itemType.equals(AtomicItemType.doubleItem)) { Double.parseDouble(this.getValue()); - } else if (itemType.equals(ItemType.nullItem)) { + } else if (itemType.equals(AtomicItemType.nullItem)) { return isNullLiteral(this.getValue()); - } else if (itemType.equals(ItemType.durationItem)) { - DurationItem.getDurationFromString(this.value, ItemType.durationItem); - } else if (itemType.equals(ItemType.yearMonthDurationItem)) { - DurationItem.getDurationFromString(this.getValue(), ItemType.yearMonthDurationItem); - } else if (itemType.equals(ItemType.dayTimeDurationItem)) { - DurationItem.getDurationFromString(this.getValue(), ItemType.dayTimeDurationItem); - } else if (itemType.equals(ItemType.dateTimeItem)) { - DateTimeItem.parseDateTime(this.getValue(), ItemType.dateTimeItem); - } else if (itemType.equals(ItemType.dateItem)) { - DateTimeItem.parseDateTime(this.getValue(), ItemType.dateItem); - } else if (itemType.equals(ItemType.timeItem)) { - DateTimeItem.parseDateTime(this.getValue(), ItemType.timeItem); - } else if (itemType.equals(ItemType.hexBinaryItem)) { + } else if (itemType.equals(AtomicItemType.durationItem)) { + DurationItem.getDurationFromString(this.value, AtomicItemType.durationItem); + } else if (itemType.equals(AtomicItemType.yearMonthDurationItem)) { + DurationItem.getDurationFromString(this.getValue(), AtomicItemType.yearMonthDurationItem); + } else if (itemType.equals(AtomicItemType.dayTimeDurationItem)) { + DurationItem.getDurationFromString(this.getValue(), AtomicItemType.dayTimeDurationItem); + } else if (itemType.equals(AtomicItemType.dateTimeItem)) { + DateTimeItem.parseDateTime(this.getValue(), AtomicItemType.dateTimeItem); + } else if (itemType.equals(AtomicItemType.dateItem)) { + DateTimeItem.parseDateTime(this.getValue(), AtomicItemType.dateItem); + } else if (itemType.equals(AtomicItemType.timeItem)) { + DateTimeItem.parseDateTime(this.getValue(), AtomicItemType.timeItem); + } else if (itemType.equals(AtomicItemType.hexBinaryItem)) { HexBinaryItem.parseHexBinaryString(this.getValue()); - } else if (itemType.equals(ItemType.base64BinaryItem)) { + } else if (itemType.equals(AtomicItemType.base64BinaryItem)) { Base64BinaryItem.parseBase64BinaryString(this.getValue()); } else { return isBooleanLiteral(this.getValue()); @@ -251,6 +252,6 @@ public Item compareItem( @Override public ItemType getDynamicType() { - return ItemType.stringItem; + return AtomicItemType.stringItem; } } diff --git a/src/main/java/org/rumbledb/items/TimeItem.java b/src/main/java/org/rumbledb/items/TimeItem.java index f77489179b..54f5c7a114 100644 --- a/src/main/java/org/rumbledb/items/TimeItem.java +++ b/src/main/java/org/rumbledb/items/TimeItem.java @@ -12,6 +12,7 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; @@ -32,7 +33,7 @@ public TimeItem() { } TimeItem(String dateTimeString) { - this.value = DateTimeItem.parseDateTime(dateTimeString, ItemType.timeItem); + this.value = DateTimeItem.parseDateTime(dateTimeString, AtomicItemType.timeItem); if (!dateTimeString.endsWith("Z") && this.value.getZone() == DateTimeZone.getDefault()) { this.hasTimeZone = false; this.value = this.value.withZoneRetainFields(DateTimeZone.UTC); @@ -87,17 +88,17 @@ public int hashCode() { @Override public boolean isCastableAs(ItemType itemType) { - return itemType.equals(ItemType.timeItem) + return itemType.equals(AtomicItemType.timeItem) || - itemType.equals(ItemType.stringItem); + itemType.equals(AtomicItemType.stringItem); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(this.serialize()); } - if (itemType.equals(ItemType.timeItem)) { + if (itemType.equals(AtomicItemType.timeItem)) { return this; } throw new ClassCastException(); @@ -105,7 +106,7 @@ public Item castAs(ItemType itemType) { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.timeItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.timeItem) || super.isTypeOf(type); } @Override @@ -193,6 +194,6 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return ItemType.timeItem; + return AtomicItemType.timeItem; } } diff --git a/src/main/java/org/rumbledb/items/YearMonthDurationItem.java b/src/main/java/org/rumbledb/items/YearMonthDurationItem.java index 40d97c4247..6121d2bc7e 100644 --- a/src/main/java/org/rumbledb/items/YearMonthDurationItem.java +++ b/src/main/java/org/rumbledb/items/YearMonthDurationItem.java @@ -10,6 +10,7 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.math.BigDecimal; import java.math.RoundingMode; @@ -50,12 +51,12 @@ public boolean isYearMonthDuration() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.yearMonthDurationItem) || super.isTypeOf(type); + return type.equals(AtomicItemType.yearMonthDurationItem) || super.isTypeOf(type); } @Override public void read(Kryo kryo, Input input) { - this.value = getDurationFromString(input.readString(), ItemType.yearMonthDurationItem).normalizedStandard( + this.value = getDurationFromString(input.readString(), AtomicItemType.yearMonthDurationItem).normalizedStandard( yearMonthPeriodType ); this.isNegative = this.value.toString().contains("-"); @@ -63,27 +64,27 @@ public void read(Kryo kryo, Input input) { @Override public boolean isCastableAs(ItemType itemType) { - return itemType.equals(ItemType.yearMonthDurationItem) + return itemType.equals(AtomicItemType.yearMonthDurationItem) || - itemType.equals(ItemType.dayTimeDurationItem) + itemType.equals(AtomicItemType.dayTimeDurationItem) || - itemType.equals(ItemType.durationItem) + itemType.equals(AtomicItemType.durationItem) || - itemType.equals(ItemType.stringItem); + itemType.equals(AtomicItemType.stringItem); } @Override public Item castAs(ItemType itemType) { - if (itemType.equals(ItemType.durationItem)) { + if (itemType.equals(AtomicItemType.durationItem)) { return ItemFactory.getInstance().createDurationItem(this.getValue()); } - if (itemType.equals(ItemType.yearMonthDurationItem)) { + if (itemType.equals(AtomicItemType.yearMonthDurationItem)) { return this; } - if (itemType.equals(ItemType.dayTimeDurationItem)) { + if (itemType.equals(AtomicItemType.dayTimeDurationItem)) { return ItemFactory.getInstance().createDayTimeDurationItem(this.getValue()); } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return ItemFactory.getInstance().createStringItem(this.serialize()); } throw new ClassCastException(); @@ -158,6 +159,6 @@ public Item divide(Item other) { @Override public ItemType getDynamicType() { - return ItemType.yearMonthDurationItem; + return AtomicItemType.yearMonthDurationItem; } } diff --git a/src/main/java/org/rumbledb/items/parsing/ItemParser.java b/src/main/java/org/rumbledb/items/parsing/ItemParser.java index b46d94182a..823c31d971 100644 --- a/src/main/java/org/rumbledb/items/parsing/ItemParser.java +++ b/src/main/java/org/rumbledb/items/parsing/ItemParser.java @@ -42,6 +42,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.ParsingException; import org.rumbledb.items.ItemFactory; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import scala.collection.mutable.WrappedArray; import sparksoniq.spark.SparkSessionManager; @@ -305,31 +306,31 @@ private static Item convertValueToItem( } public static DataType getDataFrameDataTypeFromItemTypeName(String itemTypeName) { - if (itemTypeName.equals(ItemType.booleanItem.getName())) { + if (itemTypeName.equals(AtomicItemType.booleanItem.getName())) { return DataTypes.BooleanType; } - if (itemTypeName.equals(ItemType.integerItem.getName())) { + if (itemTypeName.equals(AtomicItemType.integerItem.getName())) { return DataTypes.IntegerType; } - if (itemTypeName.equals(ItemType.doubleItem.getName())) { + if (itemTypeName.equals(AtomicItemType.doubleItem.getName())) { return DataTypes.DoubleType; } - if (itemTypeName.equals(ItemType.decimalItem.getName())) { + if (itemTypeName.equals(AtomicItemType.decimalItem.getName())) { return decimalType; } - if (itemTypeName.equals(ItemType.stringItem.getName())) { + if (itemTypeName.equals(AtomicItemType.stringItem.getName())) { return DataTypes.StringType; } - if (itemTypeName.equals(ItemType.nullItem.getName())) { + if (itemTypeName.equals(AtomicItemType.nullItem.getName())) { return DataTypes.NullType; } - if (itemTypeName.equals(ItemType.dateItem.getName())) { + if (itemTypeName.equals(AtomicItemType.dateItem.getName())) { return DataTypes.DateType; } - if (itemTypeName.equals(ItemType.dateTimeItem.getName())) { + if (itemTypeName.equals(AtomicItemType.dateTimeItem.getName())) { return DataTypes.TimestampType; } - if (itemTypeName.equals(ItemType.hexBinaryItem.getName())) { + if (itemTypeName.equals(AtomicItemType.hexBinaryItem.getName())) { return DataTypes.BinaryType; } if (itemTypeName.equals("object")) { @@ -340,31 +341,31 @@ public static DataType getDataFrameDataTypeFromItemTypeName(String itemTypeName) public static String getItemTypeNameFromDataFrameDataType(DataType dataType) { if (DataTypes.BooleanType.equals(dataType)) { - return ItemType.booleanItem.getName(); + return AtomicItemType.booleanItem.getName(); } if (DataTypes.IntegerType.equals(dataType) || DataTypes.ShortType.equals(dataType)) { - return ItemType.integerItem.getName(); + return AtomicItemType.integerItem.getName(); } if (DataTypes.DoubleType.equals(dataType) || DataTypes.FloatType.equals(dataType)) { - return ItemType.doubleItem.getName(); + return AtomicItemType.doubleItem.getName(); } if (dataType.equals(decimalType) || DataTypes.LongType.equals(dataType)) { - return ItemType.decimalItem.getName(); + return AtomicItemType.decimalItem.getName(); } if (DataTypes.StringType.equals(dataType)) { - return ItemType.stringItem.getName(); + return AtomicItemType.stringItem.getName(); } if (DataTypes.NullType.equals(dataType)) { - return ItemType.nullItem.getName(); + return AtomicItemType.nullItem.getName(); } if (DataTypes.DateType.equals(dataType)) { - return ItemType.dateItem.getName(); + return AtomicItemType.dateItem.getName(); } if (DataTypes.TimestampType.equals(dataType)) { - return ItemType.dateTimeItem.getName(); + return AtomicItemType.dateTimeItem.getName(); } if (DataTypes.BinaryType.equals(dataType)) { - return ItemType.hexBinaryItem.getName(); + return AtomicItemType.hexBinaryItem.getName(); } if (vectorType.equals(dataType)) { return "object"; diff --git a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java index c5a6a73b30..5fe4c9e48b 100644 --- a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java @@ -34,6 +34,7 @@ import org.rumbledb.context.StaticContext; import org.rumbledb.exceptions.*; import org.rumbledb.expressions.ExecutionMode; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.io.ByteArrayInputStream; @@ -122,7 +123,7 @@ public static boolean getEffectiveBooleanValueOrCheckPosition(RuntimeIterator it } } else if (item.isNull()) { result = false; - } else if (item.canBePromotedTo(ItemType.stringItem)) { + } else if (item.canBePromotedTo(AtomicItemType.stringItem)) { result = !item.getStringValue().isEmpty(); } else if (item.isObject()) { return true; diff --git a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java index eddb7eb92a..c877380ca1 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java +++ b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java @@ -54,6 +54,7 @@ import org.rumbledb.items.StringItem; import org.rumbledb.items.TimeItem; import org.rumbledb.items.YearMonthDurationItem; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index ecc99933dd..ee55f54329 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -43,6 +43,7 @@ import org.rumbledb.runtime.flwor.expression.OrderByClauseAnnotatedChildIterator; import org.rumbledb.runtime.flwor.udfs.OrderClauseCreateColumnsUDF; import org.rumbledb.runtime.flwor.udfs.OrderClauseDetermineTypeUDF; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import sparksoniq.jsoniq.tuple.FlworKey; @@ -282,41 +283,41 @@ public Dataset getDataFrame( for (int columnIndex = 0; columnIndex < columnsTypesOfRowAsList.size(); columnIndex++) { String columnType = (String) columnsTypesOfRowAsList.get(columnIndex); - if (!columnType.equals(StringFlagForEmptySequence) && !columnType.equals(ItemType.nullItem.getName())) { + if (!columnType.equals(StringFlagForEmptySequence) && !columnType.equals(AtomicItemType.nullItem.getName())) { String currentColumnType = typesForAllColumns.get(columnIndex); if (currentColumnType == null) { typesForAllColumns.put(columnIndex, columnType); } else if ( - (currentColumnType.equals(ItemType.integerItem.getName()) - || currentColumnType.equals(ItemType.doubleItem.getName()) - || currentColumnType.equals(ItemType.decimalItem.getName())) - && (columnType.equals(ItemType.integerItem.getName()) - || columnType.equals(ItemType.doubleItem.getName()) - || columnType.equals(ItemType.decimalItem.getName())) + (currentColumnType.equals(AtomicItemType.integerItem.getName()) + || currentColumnType.equals(AtomicItemType.doubleItem.getName()) + || currentColumnType.equals(AtomicItemType.decimalItem.getName())) + && (columnType.equals(AtomicItemType.integerItem.getName()) + || columnType.equals(AtomicItemType.doubleItem.getName()) + || columnType.equals(AtomicItemType.decimalItem.getName())) ) { // the numeric type calculation is identical to Item::getNumericResultType() if ( - currentColumnType.equals(ItemType.doubleItem.getName()) - || columnType.equals(ItemType.doubleItem.getName()) + currentColumnType.equals(AtomicItemType.doubleItem.getName()) + || columnType.equals(AtomicItemType.doubleItem.getName()) ) { - typesForAllColumns.put(columnIndex, ItemType.doubleItem.getName()); + typesForAllColumns.put(columnIndex, AtomicItemType.doubleItem.getName()); } else if ( - currentColumnType.equals(ItemType.decimalItem.getName()) - || columnType.equals(ItemType.decimalItem.getName()) + currentColumnType.equals(AtomicItemType.decimalItem.getName()) + || columnType.equals(AtomicItemType.decimalItem.getName()) ) { - typesForAllColumns.put(columnIndex, ItemType.decimalItem.getName()); + typesForAllColumns.put(columnIndex, AtomicItemType.decimalItem.getName()); } else { // do nothing, type is already set to integer } } else if ( - (currentColumnType.equals(ItemType.dayTimeDurationItem.getName()) - || currentColumnType.equals(ItemType.yearMonthDurationItem.getName()) - || currentColumnType.equals(ItemType.durationItem.getName())) - && (columnType.equals(ItemType.dayTimeDurationItem.getName()) - || columnType.equals(ItemType.yearMonthDurationItem.getName()) - || columnType.equals(ItemType.durationItem.getName())) + (currentColumnType.equals(AtomicItemType.dayTimeDurationItem.getName()) + || currentColumnType.equals(AtomicItemType.yearMonthDurationItem.getName()) + || currentColumnType.equals(AtomicItemType.durationItem.getName())) + && (columnType.equals(AtomicItemType.dayTimeDurationItem.getName()) + || columnType.equals(AtomicItemType.yearMonthDurationItem.getName()) + || columnType.equals(AtomicItemType.durationItem.getName())) ) { - typesForAllColumns.put(columnIndex, ItemType.durationItem.getName()); + typesForAllColumns.put(columnIndex, AtomicItemType.durationItem.getName()); } else if (!currentColumnType.equals(columnType)) { throw new UnexpectedTypeException( "Order by variable must contain values of a single type.", @@ -342,24 +343,24 @@ public Dataset getDataFrame( // create fields for the given value types columnName = columnIndex + "-valueField"; - if (columnTypeString.equals(ItemType.booleanItem.getName())) { + if (columnTypeString.equals(AtomicItemType.booleanItem.getName())) { columnType = DataTypes.BooleanType; - } else if (columnTypeString.equals(ItemType.stringItem.getName())) { + } else if (columnTypeString.equals(AtomicItemType.stringItem.getName())) { columnType = DataTypes.StringType; - } else if (columnTypeString.equals(ItemType.integerItem.getName())) { + } else if (columnTypeString.equals(AtomicItemType.integerItem.getName())) { columnType = DataTypes.IntegerType; - } else if (columnTypeString.equals(ItemType.doubleItem.getName())) { + } else if (columnTypeString.equals(AtomicItemType.doubleItem.getName())) { columnType = DataTypes.DoubleType; - } else if (columnTypeString.equals(ItemType.decimalItem.getName())) { + } else if (columnTypeString.equals(AtomicItemType.decimalItem.getName())) { columnType = decimalType; // columnType = DataTypes.createDecimalType(); } else if ( - columnTypeString.equals(ItemType.durationItem.getName()) - || columnTypeString.equals(ItemType.yearMonthDurationItem.getName()) - || columnTypeString.equals(ItemType.dayTimeDurationItem.getName()) - || columnTypeString.equals(ItemType.dateTimeItem.getName()) - || columnTypeString.equals(ItemType.dateItem.getName()) - || columnTypeString.equals(ItemType.timeItem.getName()) + columnTypeString.equals(AtomicItemType.durationItem.getName()) + || columnTypeString.equals(AtomicItemType.yearMonthDurationItem.getName()) + || columnTypeString.equals(AtomicItemType.dayTimeDurationItem.getName()) + || columnTypeString.equals(AtomicItemType.dateTimeItem.getName()) + || columnTypeString.equals(AtomicItemType.dateItem.getName()) + || columnTypeString.equals(AtomicItemType.timeItem.getName()) ) { columnType = DataTypes.LongType; } else { diff --git a/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java b/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java index 7defc1a46d..7b424a9857 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java +++ b/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java @@ -32,6 +32,7 @@ import org.rumbledb.items.NullItem; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.expression.OrderByClauseAnnotatedChildIterator; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.ArrayList; import java.util.List; @@ -117,28 +118,28 @@ private void createColumnsForItem(Item nextItem, int expressionIndex) { // extract type information for the sorting column String typeName = this.sortingKeyTypes.get(expressionIndex); try { - if (typeName.equals(ItemType.booleanItem.getName())) { + if (typeName.equals(AtomicItemType.booleanItem.getName())) { this.results.add(nextItem.getBooleanValue()); - } else if (typeName.equals(ItemType.stringItem.getName())) { + } else if (typeName.equals(AtomicItemType.stringItem.getName())) { this.results.add(nextItem.getStringValue()); - } else if (typeName.equals(ItemType.integerItem.getName())) { + } else if (typeName.equals(AtomicItemType.integerItem.getName())) { this.results.add(nextItem.castToIntValue()); - } else if (typeName.equals(ItemType.doubleItem.getName())) { + } else if (typeName.equals(AtomicItemType.doubleItem.getName())) { this.results.add(nextItem.castToDoubleValue()); - } else if (typeName.equals(ItemType.decimalItem.getName())) { + } else if (typeName.equals(AtomicItemType.decimalItem.getName())) { this.results.add(nextItem.castToDecimalValue()); } else if ( - typeName.equals(ItemType.durationItem.getName()) - || typeName.equals(ItemType.yearMonthDurationItem.getName()) - || typeName.equals(ItemType.dayTimeDurationItem.getName()) + typeName.equals(AtomicItemType.durationItem.getName()) + || typeName.equals(AtomicItemType.yearMonthDurationItem.getName()) + || typeName.equals(AtomicItemType.dayTimeDurationItem.getName()) ) { this.results.add( nextItem.getDurationValue().toDurationFrom(Instant.now()).getMillis() ); } else if ( - typeName.equals(ItemType.dateTimeItem.getName()) - || typeName.equals(ItemType.dateItem.getName()) - || typeName.equals(ItemType.timeItem.getName()) + typeName.equals(AtomicItemType.dateTimeItem.getName()) + || typeName.equals(AtomicItemType.dateItem.getName()) + || typeName.equals(AtomicItemType.timeItem.getName()) ) { this.results.add(nextItem.getDateTimeValue().getMillis()); } else { diff --git a/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java index 2d40eb775c..0e3d83b00a 100644 --- a/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java @@ -11,6 +11,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.List; @@ -35,7 +36,7 @@ public Item next() { try { Period period = DurationItem.getDurationFromString( this.durationStringItem.getStringValue(), - ItemType.dayTimeDurationItem + AtomicItemType.dayTimeDurationItem ); return ItemFactory.getInstance().createDayTimeDurationItem(period); } catch (UnsupportedOperationException | IllegalArgumentException e) { diff --git a/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java index ab9b5f9ac4..9234f79e55 100644 --- a/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java @@ -11,6 +11,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.List; @@ -35,7 +36,7 @@ public Item next() { try { Period period = DurationItem.getDurationFromString( this.durationStringItem.getStringValue(), - ItemType.durationItem + AtomicItemType.durationItem ); return ItemFactory.getInstance().createDurationItem(period); } catch (UnsupportedOperationException | IllegalArgumentException e) { diff --git a/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java index 016cc64113..de5fc9da13 100644 --- a/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java @@ -11,6 +11,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.List; @@ -35,7 +36,7 @@ public Item next() { try { Period period = DurationItem.getDurationFromString( this.durationStringItem.getStringValue(), - ItemType.yearMonthDurationItem + AtomicItemType.yearMonthDurationItem ); return ItemFactory.getInstance().createYearMonthDurationItem(period); } catch (UnsupportedOperationException | IllegalArgumentException e) { diff --git a/src/main/java/org/rumbledb/runtime/functions/numerics/DecimalFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/numerics/DecimalFunctionIterator.java index 96a0fbc739..eda02b8989 100644 --- a/src/main/java/org/rumbledb/runtime/functions/numerics/DecimalFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/numerics/DecimalFunctionIterator.java @@ -12,6 +12,7 @@ import org.rumbledb.items.AtomicItem; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.List; @@ -50,9 +51,9 @@ public Item next() { if (atomicItem.isNull()) { throw new InvalidLexicalValueException(message, getMetadata()); } - if (atomicItem.isCastableAs(ItemType.decimalItem)) { + if (atomicItem.isCastableAs(AtomicItemType.decimalItem)) { try { - return atomicItem.castAs(ItemType.decimalItem); + return atomicItem.castAs(AtomicItemType.decimalItem); } catch (ClassCastException e) { throw new UnexpectedTypeException(message, getMetadata()); } diff --git a/src/main/java/org/rumbledb/runtime/functions/numerics/DoubleFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/numerics/DoubleFunctionIterator.java index cb9d8a5408..e98593b34e 100644 --- a/src/main/java/org/rumbledb/runtime/functions/numerics/DoubleFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/numerics/DoubleFunctionIterator.java @@ -12,6 +12,7 @@ import org.rumbledb.items.AtomicItem; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.List; @@ -50,9 +51,9 @@ public Item next() { if (atomicItem.isNull()) { throw new InvalidLexicalValueException(message, getMetadata()); } - if (atomicItem.isCastableAs(ItemType.doubleItem)) { + if (atomicItem.isCastableAs(AtomicItemType.doubleItem)) { try { - return atomicItem.castAs(ItemType.doubleItem); + return atomicItem.castAs(AtomicItemType.doubleItem); } catch (ClassCastException e) { throw new UnexpectedTypeException(message, getMetadata()); } diff --git a/src/main/java/org/rumbledb/runtime/functions/numerics/IntegerFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/numerics/IntegerFunctionIterator.java index b1d8efe374..4d64b23f00 100644 --- a/src/main/java/org/rumbledb/runtime/functions/numerics/IntegerFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/numerics/IntegerFunctionIterator.java @@ -12,6 +12,7 @@ import org.rumbledb.items.AtomicItem; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.List; @@ -51,9 +52,9 @@ public Item next() { if (atomicItem.isNull()) { throw new InvalidLexicalValueException(message, getMetadata()); } - if (atomicItem.isCastableAs(ItemType.integerItem)) { + if (atomicItem.isCastableAs(AtomicItemType.integerItem)) { try { - return atomicItem.castAs(ItemType.integerItem); + return atomicItem.castAs(AtomicItemType.integerItem); } catch (ClassCastException e) { throw new UnexpectedTypeException(message, getMetadata()); } diff --git a/src/main/java/org/rumbledb/runtime/functions/numerics/NumberFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/numerics/NumberFunctionIterator.java index f6e55dc3c6..42487fd074 100644 --- a/src/main/java/org/rumbledb/runtime/functions/numerics/NumberFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/numerics/NumberFunctionIterator.java @@ -28,6 +28,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.List; @@ -54,9 +55,9 @@ public Item next() { } AtomicItem atomicItem = (AtomicItem) anyItem; - if (atomicItem.isCastableAs(ItemType.doubleItem)) { + if (atomicItem.isCastableAs(AtomicItemType.doubleItem)) { try { - return atomicItem.castAs(ItemType.doubleItem); + return atomicItem.castAs(AtomicItemType.doubleItem); } catch (ClassCastException e) { return ItemFactory.getInstance().createDoubleItem(Double.NaN); } diff --git a/src/main/java/org/rumbledb/runtime/functions/resources/AnyURIFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/resources/AnyURIFunctionIterator.java index 3bfdcc46a0..b2ef3865b5 100644 --- a/src/main/java/org/rumbledb/runtime/functions/resources/AnyURIFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/resources/AnyURIFunctionIterator.java @@ -10,6 +10,7 @@ import org.rumbledb.items.AtomicItem; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; @@ -35,7 +36,7 @@ public Item next() { AtomicItem atomicItem = (AtomicItem) this.anyItem; String message; if (atomicItem.isAnyURI()) { - return atomicItem.castAs(ItemType.anyURIItem); + return atomicItem.castAs(AtomicItemType.anyURIItem); } else if (atomicItem.isString()) { try { return ItemFactory.getInstance().createAnyURIItem(atomicItem.getStringValue()); diff --git a/src/main/java/org/rumbledb/runtime/functions/sequences/general/InstanceOfClosure.java b/src/main/java/org/rumbledb/runtime/functions/sequences/general/InstanceOfClosure.java index 7f2f9b5844..50067648d8 100644 --- a/src/main/java/org/rumbledb/runtime/functions/sequences/general/InstanceOfClosure.java +++ b/src/main/java/org/rumbledb/runtime/functions/sequences/general/InstanceOfClosure.java @@ -2,6 +2,7 @@ import org.apache.spark.api.java.function.Function; import org.rumbledb.api.Item; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; public class InstanceOfClosure implements Function { diff --git a/src/main/java/org/rumbledb/runtime/functions/strings/StringFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/strings/StringFunctionIterator.java index e09ae1fd8b..1dc4f06a3c 100644 --- a/src/main/java/org/rumbledb/runtime/functions/strings/StringFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/strings/StringFunctionIterator.java @@ -11,6 +11,7 @@ import org.rumbledb.items.AtomicItem; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.List; @@ -47,9 +48,9 @@ public Item next() { ": value of type " + this.item.getDynamicType().toString() + " is not castable to type string."; - if (atomicItem.isCastableAs(ItemType.stringItem)) { + if (atomicItem.isCastableAs(AtomicItemType.stringItem)) { try { - return atomicItem.castAs(ItemType.stringItem); + return atomicItem.castAs(AtomicItemType.stringItem); } catch (ClassCastException e) { throw new UnexpectedTypeException(message, getMetadata()); } diff --git a/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java b/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java index d616e0d15a..9bfa9ff90c 100644 --- a/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java @@ -10,6 +10,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.LocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; @@ -70,7 +71,7 @@ public Item next() { } static AtomicItem checkInvalidCastable(Item item, ExceptionMetadata metadata, SequenceType type) { - if (type.getItemType().equals(ItemType.atomicItem)) { + if (type.getItemType().equals(AtomicItemType.atomicItem)) { throw new CastableException("\"atomic\": invalid type for \"cast\" or \"castable\" expression", metadata); } AtomicItem atomicItem; diff --git a/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java b/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java index c924ce7402..3d41ad91b8 100644 --- a/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java @@ -29,6 +29,7 @@ import org.rumbledb.runtime.LocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.sequences.general.InstanceOfClosure; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java b/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java index fe7d18dc95..d6acf21b01 100644 --- a/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java @@ -14,6 +14,7 @@ import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.sequences.general.TreatAsClosure; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java new file mode 100644 index 0000000000..2c4c4de13e --- /dev/null +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -0,0 +1,158 @@ +package org.rumbledb.types; + +import java.io.Serializable; + +public class AtomicItemType extends ItemType implements Serializable { + + // TODO: extract array and object into its own types + public static final AtomicItemType atomicItem = new AtomicItemType("atomic"); + public static final AtomicItemType stringItem = new AtomicItemType("string"); + public static final AtomicItemType integerItem = new AtomicItemType("integer"); + public static final AtomicItemType decimalItem = new AtomicItemType("decimal"); + public static final AtomicItemType doubleItem = new AtomicItemType("double"); + public static final AtomicItemType booleanItem = new AtomicItemType("boolean"); + public static final AtomicItemType nullItem = new AtomicItemType("null"); + public static final AtomicItemType durationItem = new AtomicItemType("duration"); + public static final AtomicItemType yearMonthDurationItem = new AtomicItemType("yearMonthDuration"); + public static final AtomicItemType dayTimeDurationItem = new AtomicItemType("dayTimeDuration"); + public static final AtomicItemType dateTimeItem = new AtomicItemType("dateTime"); + public static final AtomicItemType dateItem = new AtomicItemType("date"); + public static final AtomicItemType timeItem = new AtomicItemType("time"); + public static final AtomicItemType hexBinaryItem = new AtomicItemType("hexBinary"); + public static final AtomicItemType anyURIItem = new AtomicItemType("anyURI"); + public static final AtomicItemType base64BinaryItem = new AtomicItemType("base64Binary"); + public static final AtomicItemType JSONItem = new AtomicItemType("json-item"); + public static final AtomicItemType objectItem = new AtomicItemType("object"); + public static final AtomicItemType arrayItem = new AtomicItemType("array"); + + public AtomicItemType() { + } + + private AtomicItemType(String name) { + super(name); + } + + // Returns true if [this] is a subtype of [superType], any type is considered a subtype of itself + @Override + public boolean isSubtypeOf(ItemType superType) { + if (superType.equals(ItemType.item)) { + return true; + } else if (superType.equals(JSONItem)) { + return this.equals(objectItem) + || this.equals(arrayItem) + || this.equals(JSONItem); + } else if (superType.equals(atomicItem)) { + return this.equals(stringItem) + || this.equals(integerItem) + || this.equals(decimalItem) + || this.equals(doubleItem) + || this.equals(booleanItem) + || this.equals(nullItem) + || this.equals(anyURIItem) + || this.equals(hexBinaryItem) + || this.equals(base64BinaryItem) + || this.equals(dateTimeItem) + || this.equals(dateItem) + || this.equals(timeItem) + || this.equals(durationItem) + || this.equals(yearMonthDurationItem) + || this.equals(dayTimeDurationItem) + || this.equals(atomicItem); + } else if (superType.equals(durationItem)) { + return this.equals(yearMonthDurationItem) + || this.equals(dayTimeDurationItem) + || this.equals(durationItem); + } else if (superType.equals(decimalItem)) { + return this.equals(integerItem) || this.equals(decimalItem); + } + return this.equals(superType); + } + + @Override + public ItemType findCommonSuperType(ItemType other) { + if (other.isSubtypeOf(this)) { + return this; + } else if (this.isSubtypeOf(other)) { + return other; + } else if (this.isSubtypeOf(durationItem) && other.isSubtypeOf(durationItem)) { + return durationItem; + } else if (this.isSubtypeOf(atomicItem) && other.isSubtypeOf(atomicItem)) { + return atomicItem; + } else if (this.isSubtypeOf(JSONItem) && other.isSubtypeOf(JSONItem)) { + return JSONItem; + } else { + return ItemType.item; + } + } + + @Override + public boolean staticallyCastableAs(ItemType other) { + // anything can be casted to itself + if (this.equals(other)) + return true; + // anything can be casted from and to a string (or from one of its supertype) + if (this.equals(stringItem) || other.equals(stringItem)) + return true; + // boolean and numeric can be cast between themselves + if ( + this.equals(booleanItem) || this.equals(integerItem) || this.equals(doubleItem) || this.equals(decimalItem) + ) { + if ( + other.equals(integerItem) + || + other.equals(doubleItem) + || + other.equals(decimalItem) + || + other.equals(booleanItem) + ) + return true; + else + return false; + } + // base64 and hex can be cast between themselves + if (this.equals(base64BinaryItem) || this.equals(hexBinaryItem)) { + if ( + other.equals(base64BinaryItem) + || + other.equals(hexBinaryItem) + ) + return true; + else + return false; + } + // durations can be cast between themselves + if (this.isSubtypeOf(durationItem)) { + if (other.isSubtypeOf(durationItem)) + return true; + else + return false; + } + // DateTime can be cast also to Date or Time + if (this.equals(dateTimeItem)) { + if (other.equals(dateItem) || other.equals(timeItem)) + return true; + else + return false; + } + // Date can be cast also to DateTime + if (this.equals(dateItem)) { + if (other.equals(dateTimeItem)) + return true; + else + return false; + } + // Otherwise this cannot be casted to other + return false; + } + + @Override + public boolean isNumeric() { + return this.equals(integerItem) || this.equals(decimalItem) || this.equals(doubleItem); + } + + @Override + public boolean canBePromotedToString() { + return this.equals(stringItem) || this.equals(anyURIItem); + } +} diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 18ceaed313..6355d2ba43 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -27,99 +27,63 @@ public class ItemType implements Serializable { - private static final long serialVersionUID = 1L; - private String name; - - public static final ItemType item = new ItemType("item"); - public static final ItemType atomicItem = new ItemType("atomic"); - public static final ItemType stringItem = new ItemType("string"); - public static final ItemType integerItem = new ItemType("integer"); - public static final ItemType decimalItem = new ItemType("decimal"); - public static final ItemType doubleItem = new ItemType("double"); - public static final ItemType booleanItem = new ItemType("boolean"); - public static final ItemType nullItem = new ItemType("null"); - public static final ItemType durationItem = new ItemType("duration"); - public static final ItemType yearMonthDurationItem = new ItemType("yearMonthDuration"); - public static final ItemType dayTimeDurationItem = new ItemType("dayTimeDuration"); - public static final ItemType dateTimeItem = new ItemType("dateTime"); - public static final ItemType dateItem = new ItemType("date"); - public static final ItemType timeItem = new ItemType("time"); - public static final ItemType hexBinaryItem = new ItemType("hexBinary"); - public static final ItemType anyURIItem = new ItemType("anyURI"); - public static final ItemType base64BinaryItem = new ItemType("base64Binary"); - public static final ItemType JSONItem = new ItemType("json-item"); - public static final ItemType objectItem = new ItemType("object"); - public static final ItemType arrayItem = new ItemType("array"); - public static final ItemType functionItem = new ItemType("function"); - - public ItemType() { - } - - private ItemType(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - public static ItemType getItemTypeByName(String name) { - if (name.equals(objectItem.name)) { - return objectItem; + if (name.equals(AtomicItemType.objectItem.getName())) { + return AtomicItemType.objectItem; } - if (name.equals(atomicItem.name)) { - return atomicItem; + if (name.equals(AtomicItemType.atomicItem.getName())) { + return AtomicItemType.atomicItem; } - if (name.equals(stringItem.name)) { - return stringItem; + if (name.equals(AtomicItemType.stringItem.getName())) { + return AtomicItemType.stringItem; } - if (name.equals(integerItem.name)) { - return integerItem; + if (name.equals(AtomicItemType.integerItem.getName())) { + return AtomicItemType.integerItem; } - if (name.equals(decimalItem.name)) { - return decimalItem; + if (name.equals(AtomicItemType.decimalItem.getName())) { + return AtomicItemType.decimalItem; } - if (name.equals(doubleItem.name)) { - return doubleItem; + if (name.equals(AtomicItemType.doubleItem.getName())) { + return AtomicItemType.doubleItem; } - if (name.equals(booleanItem.name)) { - return booleanItem; + if (name.equals(AtomicItemType.booleanItem.getName())) { + return AtomicItemType.booleanItem; } - if (name.equals(nullItem.name)) { - return nullItem; + if (name.equals(AtomicItemType.nullItem.getName())) { + return AtomicItemType.nullItem; } - if (name.equals(arrayItem.name)) { - return arrayItem; + if (name.equals(AtomicItemType.arrayItem.getName())) { + return AtomicItemType.arrayItem; } - if (name.equals(JSONItem.name)) { - return JSONItem; + if (name.equals(AtomicItemType.JSONItem.getName())) { + return AtomicItemType.JSONItem; } - if (name.equals(durationItem.name)) { - return durationItem; + if (name.equals(AtomicItemType.durationItem.getName())) { + return AtomicItemType.durationItem; } - if (name.equals(yearMonthDurationItem.name)) { - return yearMonthDurationItem; + if (name.equals(AtomicItemType.yearMonthDurationItem.getName())) { + return AtomicItemType.yearMonthDurationItem; } - if (name.equals(dayTimeDurationItem.name)) { - return dayTimeDurationItem; + if (name.equals(AtomicItemType.dayTimeDurationItem.getName())) { + return AtomicItemType.dayTimeDurationItem; } - if (name.equals(dateTimeItem.name)) { - return dateTimeItem; + if (name.equals(AtomicItemType.dateTimeItem.getName())) { + return AtomicItemType.dateTimeItem; } - if (name.equals(dateItem.name)) { - return dateItem; + if (name.equals(AtomicItemType.dateItem.getName())) { + return AtomicItemType.dateItem; } - if (name.equals(timeItem.name)) { - return timeItem; + if (name.equals(AtomicItemType.timeItem.getName())) { + return AtomicItemType.timeItem; } - if (name.equals(anyURIItem.name)) { - return anyURIItem; + if (name.equals(AtomicItemType.anyURIItem.getName())) { + return AtomicItemType.anyURIItem; } - if (name.equals(hexBinaryItem.name)) { - return hexBinaryItem; + if (name.equals(AtomicItemType.hexBinaryItem.getName())) { + return AtomicItemType.hexBinaryItem; } - if (name.equals(base64BinaryItem.name)) { - return base64BinaryItem; + if (name.equals(AtomicItemType.base64BinaryItem.getName())) { + return AtomicItemType.base64BinaryItem; } if (name.equals(item.name)) { return item; @@ -127,64 +91,40 @@ public static ItemType getItemTypeByName(String name) { throw new OurBadException("Type unrecognized: " + name); } + protected static final long serialVersionUID = 1L; + protected String name; + + public static final ItemType item = new ItemType("item"); + public static final ItemType functionItem = new ItemType("function"); + + public ItemType() { + } + + protected ItemType(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + @Override public boolean equals(Object other) { if (!(other instanceof ItemType)) { return false; } - return this.name.equals(((ItemType) other).getName()); + return this.name.equals(other.toString()); } // Returns true if [this] is a subtype of [superType], any type is considered a subtype of itself public boolean isSubtypeOf(ItemType superType) { - if (superType.equals(item)) { - return true; - } else if (superType.equals(JSONItem)) { - return this.equals(objectItem) - || this.equals(arrayItem) - || this.equals(JSONItem); - } else if (superType.equals(atomicItem)) { - return this.equals(stringItem) - || this.equals(integerItem) - || this.equals(decimalItem) - || this.equals(doubleItem) - || this.equals(booleanItem) - || this.equals(nullItem) - || this.equals(anyURIItem) - || this.equals(hexBinaryItem) - || this.equals(base64BinaryItem) - || this.equals(dateTimeItem) - || this.equals(dateItem) - || this.equals(timeItem) - || this.equals(durationItem) - || this.equals(yearMonthDurationItem) - || this.equals(dayTimeDurationItem) - || this.equals(atomicItem); - } else if (superType.equals(durationItem)) { - return this.equals(yearMonthDurationItem) - || this.equals(dayTimeDurationItem) - || this.equals(durationItem); - } else if (superType.equals(decimalItem)) { - return this.equals(integerItem) || this.equals(decimalItem); - } return this.equals(superType); } public ItemType findCommonSuperType(ItemType other) { - if (other.isSubtypeOf(this)) { - return this; - } else if (this.isSubtypeOf(other)) { - return other; - } else if (this.isSubtypeOf(durationItem) && other.isSubtypeOf(durationItem)) { - return durationItem; - } else if (this.isSubtypeOf(atomicItem) && other.isSubtypeOf(atomicItem)) { - return atomicItem; - } else if (this.isSubtypeOf(JSONItem) && other.isSubtypeOf(JSONItem)) { - return JSONItem; - } else { - return item; - } + // item is the most generic type + return this; } /** @@ -194,73 +134,19 @@ public ItemType findCommonSuperType(ItemType other) { * @return true if it is possible at static time to cast [this] to [other], false otherwise */ public boolean staticallyCastableAs(ItemType other) { - // anything can be casted to itself - if (this.equals(other)) - return true; - // anything can be casted from and to a string (or from one of its supertype) - if (this.equals(stringItem) || other.equals(stringItem)) - return true; - // boolean and numeric can be cast between themselves - if ( - this.equals(booleanItem) || this.equals(integerItem) || this.equals(doubleItem) || this.equals(decimalItem) - ) { - if ( - other.equals(integerItem) - || - other.equals(doubleItem) - || - other.equals(decimalItem) - || - other.equals(booleanItem) - ) - return true; - else - return false; - } - // base64 and hex can be cast between themselves - if (this.equals(base64BinaryItem) || this.equals(hexBinaryItem)) { - if ( - other.equals(base64BinaryItem) - || - other.equals(hexBinaryItem) - ) - return true; - else - return false; - } - // durations can be cast between themselves - if (this.isSubtypeOf(durationItem)) { - if (other.isSubtypeOf(durationItem)) - return true; - else - return false; - } - // DateTime can be cast also to Date or Time - if (this.equals(dateTimeItem)) { - if (other.equals(dateItem) || other.equals(timeItem)) - return true; - else - return false; - } - // Date can be cast also to DateTime - if (this.equals(dateItem)) { - if (other.equals(dateTimeItem)) - return true; - else - return false; - } - // Otherwise this cannot be casted to other + // this is not atomic and therefore cannot be casted + // TODO: consider throwing error here return false; } // return [true] if this is a numeric type (i.e. [integerItem], [decimalItem] or [doubleItem]), false otherwise public boolean isNumeric() { - return this.equals(integerItem) || this.equals(decimalItem) || this.equals(doubleItem); + return false; } // returns [true] if this can be promoted to string public boolean canBePromotedToString() { - return this.equals(stringItem) || this.equals(anyURIItem); + return false; } @Override diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index 7d7e665225..26dec09354 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -92,9 +92,9 @@ public boolean isSubtypeOfOrCanBePromotedTo(SequenceType superType) { return this.isAritySubtypeOf(superType.arity) && (this.itemType.isSubtypeOf(superType.getItemType()) || - (this.itemType.canBePromotedToString() && superType.itemType.equals(ItemType.stringItem)) + (this.itemType.canBePromotedToString() && superType.itemType.equals(AtomicItemType.stringItem)) || - (this.itemType.isNumeric() && superType.itemType.equals(ItemType.doubleItem))); + (this.itemType.isNumeric() && superType.itemType.equals(AtomicItemType.doubleItem))); } // check if the arity of a sequence type is subtype of another arity, assume [this] is a non-empty sequence @@ -106,19 +106,19 @@ public boolean isAritySubtypeOf(Arity superArity) { public boolean hasEffectiveBooleanValue() { if (this.isEmptySequence) { return true; - } else if (this.itemType.isSubtypeOf(ItemType.JSONItem)) { + } else if (this.itemType.isSubtypeOf(AtomicItemType.JSONItem)) { return true; } else if ( (this.arity == Arity.One || this.arity == Arity.OneOrZero) && (this.itemType.isNumeric() || - this.itemType.equals(ItemType.stringItem) + this.itemType.equals(AtomicItemType.stringItem) || - this.itemType.equals(ItemType.anyURIItem) + this.itemType.equals(AtomicItemType.anyURIItem) || - this.itemType.equals(ItemType.nullItem) + this.itemType.equals(AtomicItemType.nullItem) || - this.itemType.equals(ItemType.booleanItem)) + this.itemType.equals(AtomicItemType.booleanItem)) ) { return true; } else { @@ -272,64 +272,64 @@ public String toString() { sequenceTypes.put("item*", new SequenceType(ItemType.item, SequenceType.Arity.ZeroOrMore)); sequenceTypes.put("item+", new SequenceType(ItemType.item, SequenceType.Arity.OneOrMore)); - sequenceTypes.put("object", new SequenceType(ItemType.objectItem, SequenceType.Arity.One)); - sequenceTypes.put("object+", new SequenceType(ItemType.objectItem, SequenceType.Arity.OneOrMore)); - sequenceTypes.put("object*", new SequenceType(ItemType.objectItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("object", new SequenceType(AtomicItemType.objectItem, SequenceType.Arity.One)); + sequenceTypes.put("object+", new SequenceType(AtomicItemType.objectItem, SequenceType.Arity.OneOrMore)); + sequenceTypes.put("object*", new SequenceType(AtomicItemType.objectItem, SequenceType.Arity.ZeroOrMore)); - sequenceTypes.put("json-item*", new SequenceType(ItemType.JSONItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("json-item*", new SequenceType(AtomicItemType.JSONItem, SequenceType.Arity.ZeroOrMore)); - sequenceTypes.put("array?", new SequenceType(ItemType.arrayItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("array*", new SequenceType(ItemType.arrayItem, Arity.ZeroOrMore)); + sequenceTypes.put("array?", new SequenceType(AtomicItemType.arrayItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("array*", new SequenceType(AtomicItemType.arrayItem, Arity.ZeroOrMore)); - sequenceTypes.put("atomic", new SequenceType(ItemType.atomicItem, SequenceType.Arity.One)); - sequenceTypes.put("atomic?", new SequenceType(ItemType.atomicItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("atomic*", new SequenceType(ItemType.atomicItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("atomic", new SequenceType(AtomicItemType.atomicItem, SequenceType.Arity.One)); + sequenceTypes.put("atomic?", new SequenceType(AtomicItemType.atomicItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("atomic*", new SequenceType(AtomicItemType.atomicItem, SequenceType.Arity.ZeroOrMore)); - sequenceTypes.put("string", new SequenceType(ItemType.stringItem, SequenceType.Arity.One)); - sequenceTypes.put("string?", new SequenceType(ItemType.stringItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("string*", new SequenceType(ItemType.stringItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("string", new SequenceType(AtomicItemType.stringItem, SequenceType.Arity.One)); + sequenceTypes.put("string?", new SequenceType(AtomicItemType.stringItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("string*", new SequenceType(AtomicItemType.stringItem, SequenceType.Arity.ZeroOrMore)); - sequenceTypes.put("integer", new SequenceType(ItemType.integerItem, SequenceType.Arity.One)); - sequenceTypes.put("integer?", new SequenceType(ItemType.integerItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("integer*", new SequenceType(ItemType.integerItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("integer", new SequenceType(AtomicItemType.integerItem, SequenceType.Arity.One)); + sequenceTypes.put("integer?", new SequenceType(AtomicItemType.integerItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("integer*", new SequenceType(AtomicItemType.integerItem, SequenceType.Arity.ZeroOrMore)); - sequenceTypes.put("decimal?", new SequenceType(ItemType.decimalItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("decimal?", new SequenceType(AtomicItemType.decimalItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("double", new SequenceType(ItemType.doubleItem, SequenceType.Arity.One)); - sequenceTypes.put("double?", new SequenceType(ItemType.doubleItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("double", new SequenceType(AtomicItemType.doubleItem, SequenceType.Arity.One)); + sequenceTypes.put("double?", new SequenceType(AtomicItemType.doubleItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("boolean", new SequenceType(ItemType.booleanItem, SequenceType.Arity.One)); - sequenceTypes.put("boolean?", new SequenceType(ItemType.booleanItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("boolean", new SequenceType(AtomicItemType.booleanItem, SequenceType.Arity.One)); + sequenceTypes.put("boolean?", new SequenceType(AtomicItemType.booleanItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("duration?", new SequenceType(ItemType.durationItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("duration?", new SequenceType(AtomicItemType.durationItem, SequenceType.Arity.OneOrZero)); sequenceTypes.put( "yearMonthDuration?", - new SequenceType(ItemType.yearMonthDurationItem, SequenceType.Arity.OneOrZero) + new SequenceType(AtomicItemType.yearMonthDurationItem, SequenceType.Arity.OneOrZero) ); sequenceTypes.put( "dayTimeDuration?", - new SequenceType(ItemType.dayTimeDurationItem, SequenceType.Arity.OneOrZero) + new SequenceType(AtomicItemType.dayTimeDurationItem, SequenceType.Arity.OneOrZero) ); - sequenceTypes.put("dateTime?", new SequenceType(ItemType.dateTimeItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("dateTime?", new SequenceType(AtomicItemType.dateTimeItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("date?", new SequenceType(ItemType.dateItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("date?", new SequenceType(AtomicItemType.dateItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("time?", new SequenceType(ItemType.timeItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("time?", new SequenceType(AtomicItemType.timeItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("anyURI", new SequenceType(ItemType.anyURIItem)); - sequenceTypes.put("anyURI?", new SequenceType(ItemType.anyURIItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("anyURI", new SequenceType(AtomicItemType.anyURIItem)); + sequenceTypes.put("anyURI?", new SequenceType(AtomicItemType.anyURIItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("hexBinary?", new SequenceType(ItemType.hexBinaryItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("hexBinary?", new SequenceType(AtomicItemType.hexBinaryItem, SequenceType.Arity.OneOrZero)); sequenceTypes.put( "base64Binary?", - new SequenceType(ItemType.base64BinaryItem, SequenceType.Arity.OneOrZero) + new SequenceType(AtomicItemType.base64BinaryItem, SequenceType.Arity.OneOrZero) ); - sequenceTypes.put("null?", new SequenceType(ItemType.nullItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("null?", new SequenceType(AtomicItemType.nullItem, SequenceType.Arity.OneOrZero)); } public static SequenceType createSequenceType(String userFriendlyName) { diff --git a/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java b/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java index c1c4f9ce45..2614917831 100644 --- a/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java +++ b/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java @@ -23,6 +23,7 @@ import org.rumbledb.runtime.LocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.types.FunctionSignature; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -250,13 +251,13 @@ private Item generateTransformerFunctionItem(Transformer fittedModel) { SequenceType.Arity.ZeroOrMore ), new SequenceType( - ItemType.objectItem, + AtomicItemType.objectItem, SequenceType.Arity.One ) ) ); SequenceType returnType = new SequenceType( - ItemType.objectItem, + AtomicItemType.objectItem, SequenceType.Arity.ZeroOrMore ); diff --git a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java index 5b1290902e..0e2f1fca82 100644 --- a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java +++ b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java @@ -34,6 +34,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.types.FunctionSignature; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -120,7 +121,7 @@ public Item next() { SequenceType.Arity.ZeroOrMore ), new SequenceType( - ItemType.objectItem, + AtomicItemType.objectItem, SequenceType.Arity.One ) ) diff --git a/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java b/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java index df8eb5c86d..b60fe4debe 100644 --- a/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java +++ b/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java @@ -34,6 +34,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.types.FunctionSignature; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -120,13 +121,13 @@ public Item next() { SequenceType.Arity.ZeroOrMore ), new SequenceType( - ItemType.objectItem, + AtomicItemType.objectItem, SequenceType.Arity.One ) ) ); SequenceType returnType = new SequenceType( - ItemType.objectItem, + AtomicItemType.objectItem, SequenceType.Arity.ZeroOrMore ); diff --git a/src/main/java/sparksoniq/spark/ml/RumbleMLUtils.java b/src/main/java/sparksoniq/spark/ml/RumbleMLUtils.java index 2e7f82eacc..01f6a303ac 100644 --- a/src/main/java/sparksoniq/spark/ml/RumbleMLUtils.java +++ b/src/main/java/sparksoniq/spark/ml/RumbleMLUtils.java @@ -14,6 +14,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.items.ArrayItem; import org.rumbledb.items.AtomicItem; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.items.ItemFactory; @@ -166,15 +167,15 @@ private static boolean expectedJavaTypeMatchesRumbleAtomic(String javaTypeName) private static Object convertRumbleAtomicToJava(AtomicItem atomicItem, String javaTypeName) { switch (javaTypeName) { case "boolean": - return atomicItem.castAs(ItemType.booleanItem).getBooleanValue(); + return atomicItem.castAs(AtomicItemType.booleanItem).getBooleanValue(); case "String": - return atomicItem.castAs(ItemType.stringItem).getStringValue(); + return atomicItem.castAs(AtomicItemType.stringItem).getStringValue(); case "int": - return atomicItem.castAs(ItemType.integerItem).getIntValue(); + return atomicItem.castAs(AtomicItemType.integerItem).getIntValue(); case "double": - return atomicItem.castAs(ItemType.doubleItem).getDoubleValue(); + return atomicItem.castAs(AtomicItemType.doubleItem).getDoubleValue(); case "long": - return atomicItem.castAs(ItemType.decimalItem).getDecimalValue().longValue(); + return atomicItem.castAs(AtomicItemType.decimalItem).getDecimalValue().longValue(); default: throw new OurBadException( "Unrecognized Java type name found \"" diff --git a/src/test/java/iq/FrontendTests.java b/src/test/java/iq/FrontendTests.java index d67f0b95aa..ca088ce39a 100644 --- a/src/test/java/iq/FrontendTests.java +++ b/src/test/java/iq/FrontendTests.java @@ -31,6 +31,7 @@ import org.rumbledb.expressions.module.MainModule; import org.rumbledb.expressions.primary.VariableReferenceExpression; import org.rumbledb.runtime.functions.input.FileSystemUtil; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.io.File; import java.net.URI; @@ -206,7 +207,7 @@ private void testVariableTypes(File testFile, MainModule mainModule) { ); vars.forEach( var -> Assert.assertTrue( - ((VariableReferenceExpression) var).getType().getItemType().equals(ItemType.integerItem) + ((VariableReferenceExpression) var).getType().getItemType().equals(AtomicItemType.integerItem) ) ); @@ -220,7 +221,7 @@ private void testVariableTypes(File testFile, MainModule mainModule) { j -> Assert.assertTrue( ((VariableReferenceExpression) j).getType().getItemType().equals(ItemType.item) || - ((VariableReferenceExpression) j).getType().getItemType().equals(ItemType.stringItem) + ((VariableReferenceExpression) j).getType().getItemType().equals(AtomicItemType.stringItem) ) ); @@ -232,7 +233,7 @@ private void testVariableTypes(File testFile, MainModule mainModule) { ); internals.forEach( j -> Assert.assertTrue( - ((VariableReferenceExpression) j).getType().getItemType().equals(ItemType.integerItem) + ((VariableReferenceExpression) j).getType().getItemType().equals(AtomicItemType.integerItem) ) ); @@ -244,7 +245,7 @@ private void testVariableTypes(File testFile, MainModule mainModule) { ); arry.forEach( j -> Assert.assertTrue( - ((VariableReferenceExpression) j).getType().getItemType().equals(ItemType.arrayItem) + ((VariableReferenceExpression) j).getType().getItemType().equals(AtomicItemType.arrayItem) ) ); From 1fbb492be84854e0536a9355d144051861092816 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 2 Dec 2020 12:19:51 +0100 Subject: [PATCH 096/206] added function item type --- .../rumbledb/compiler/TranslationVisitor.java | 26 +++++++-- .../org/rumbledb/types/FunctionItemType.java | 55 +++++++++++++++++++ .../java/org/rumbledb/types/ItemType.java | 4 ++ 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 src/main/java/org/rumbledb/types/FunctionItemType.java diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 986f3f3fa4..708a243b75 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -109,9 +109,7 @@ import org.rumbledb.parser.JsoniqParser.SetterContext; import org.rumbledb.parser.JsoniqParser.UriLiteralContext; import org.rumbledb.runtime.functions.input.FileSystemUtil; -import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.ItemType; -import org.rumbledb.types.SequenceType; +import org.rumbledb.types.*; import static org.rumbledb.types.SequenceType.MOST_GENERAL_SEQUENCE_TYPE; @@ -125,6 +123,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; /** @@ -1118,7 +1117,26 @@ public SequenceType processSequenceType(JsoniqParser.SequenceTypeContext ctx) { if (ctx.item == null) { return SequenceType.EMPTY_SEQUENCE; } - ItemType itemType = ItemType.getItemTypeByName(ctx.item.getText()); + ItemType itemType; + JsoniqParser.FunctionTestContext fnCtx = ctx.item.functionTest(); + if(fnCtx == null){ + // non-function item type + itemType = ItemType.getItemTypeByName(ctx.item.getText()); + } else { + // function item type + JsoniqParser.TypedFunctionTestContext typedFnCtx = fnCtx.typedFunctionTest(); + if(typedFnCtx == null){ + // function(*) + itemType = FunctionItemType.ANYFUNCTION; + } else { + // typed function + SequenceType rt = processSequenceType(typedFnCtx.rt); + List st = typedFnCtx.st.stream().map(this::processSequenceType).collect(Collectors.toList()); + FunctionSignature signature = new FunctionSignature(st, rt); + itemType = new FunctionItemType(signature); + } + } + if (ctx.question.size() > 0) { return new SequenceType( itemType, diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java new file mode 100644 index 0000000000..11b71055a5 --- /dev/null +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -0,0 +1,55 @@ +package org.rumbledb.types; + +import org.rumbledb.exceptions.OurBadException; + +public class FunctionItemType extends ItemType { + + private boolean isGeneric; + private FunctionSignature signature; + public static FunctionItemType ANYFUNCTION = new FunctionItemType(true); + + public FunctionItemType(FunctionSignature signature){ + if(signature == null){ + throw new OurBadException("a new function item type must have a signature"); + } + this.isGeneric = false; + this.signature = signature; + this.name = signature.toString(); + } + + // we have a parameter because the empty one is public and inherited + private FunctionItemType(boolean isGeneric){ + this.isGeneric = true; + this.signature = null; + this.name = "function(*)"; + } + + @Override + public boolean isFunctionItem() { + return true; + } + + @Override + public boolean equals(Object other) { + if(!(other instanceof ItemType)){ + return false; + } + return this.name.equals(other.toString()); + } + + @Override + public boolean isSubtypeOf(ItemType superType) { + return this.equals(superType) || superType.equals(ANYFUNCTION) || superType.equals(ItemType.item); + } + + @Override + public ItemType findCommonSuperType(ItemType other) { + if(this.equals(other)){ + return this; + } + if(other.isFunctionItem()){ + return ANYFUNCTION; + } + return ItemType.item; + } +} diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 6355d2ba43..2ebe9ec7f3 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -116,6 +116,10 @@ public boolean equals(Object other) { return this.name.equals(other.toString()); } + // Returns true if [this] is a function item + public boolean isFunctionItem() { + return false; + } // Returns true if [this] is a subtype of [superType], any type is considered a subtype of itself public boolean isSubtypeOf(ItemType superType) { From 33bf0081dbdcd0fe84e140fbd307777dc7cac586 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 3 Dec 2020 00:14:42 +0100 Subject: [PATCH 097/206] refactored to use the new FunctionItemType --- .../rumbledb/compiler/InferTypeVisitor.java | 106 ++++++++++++------ .../java/org/rumbledb/items/FunctionItem.java | 10 +- .../org/rumbledb/types/FunctionItemType.java | 5 + .../java/org/rumbledb/types/ItemType.java | 5 + .../static-typing/postfix/dynamicfunc1.jq | 2 +- .../static-typing/postfix/dynamicfunc3.jq | 4 + 6 files changed, 93 insertions(+), 39 deletions(-) create mode 100644 src/test/resources/test_files/static-typing/postfix/dynamicfunc3.jq diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index c5fa55da08..080b10d2e9 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1,10 +1,7 @@ package org.rumbledb.compiler; import org.rumbledb.config.RumbleRuntimeConfiguration; -import org.rumbledb.context.BuiltinFunction; -import org.rumbledb.context.BuiltinFunctionCatalogue; -import org.rumbledb.context.Name; -import org.rumbledb.context.StaticContext; +import org.rumbledb.context.*; import org.rumbledb.errorcodes.ErrorCode; import org.rumbledb.exceptions.IsStaticallyUnexpectedType; import org.rumbledb.exceptions.OurBadException; @@ -31,13 +28,11 @@ import org.rumbledb.expressions.quantifiers.QuantifiedExpression; import org.rumbledb.expressions.quantifiers.QuantifiedExpressionVar; import org.rumbledb.expressions.typing.*; +import org.rumbledb.types.*; import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.FunctionSignature; -import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.ItemType; -import org.rumbledb.types.SequenceType; import java.util.*; +import java.util.stream.Collectors; /** * This visitor infers a static SequenceType for each expression in the query @@ -272,15 +267,40 @@ public StaticContext visitContextExpr(ContextItemExpression expression, StaticCo @Override public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression, StaticContext argument) { visitDescendants(expression, argument); - expression.setInferredSequenceType(new SequenceType(ItemType.functionItem)); + SequenceType returnType = expression.getActualReturnType(); + if(returnType == null){ + returnType = expression.getBody().getInferredSequenceType(); + } + List params = new ArrayList<>(expression.getParams().values()); + FunctionSignature signature = new FunctionSignature(params, returnType); + expression.setInferredSequenceType(new SequenceType(new FunctionItemType(signature))); System.out.println("Visited inline function expression"); return argument; } + private FunctionSignature getSignature(FunctionIdentifier identifier, StaticContext staticContext){ + BuiltinFunction function = null; + FunctionSignature signature = null; + try { + function = BuiltinFunctionCatalogue.getBuiltinFunction(identifier); + } catch (OurBadException exception) { + signature = staticContext.getFunctionSignature(identifier); + } + + if (function != null) { + signature = function.getSignature(); + } + + return signature; + } + @Override public StaticContext visitNamedFunctionRef(NamedFunctionReferenceExpression expression, StaticContext argument) { visitDescendants(expression, argument); - expression.setInferredSequenceType(new SequenceType(ItemType.functionItem)); + + FunctionSignature signature = getSignature(expression.getIdentifier(), expression.getStaticContext()); + + expression.setInferredSequenceType(new SequenceType(new FunctionItemType(signature))); System.out.println("Visited named function expression"); return argument; } @@ -289,21 +309,11 @@ public StaticContext visitNamedFunctionRef(NamedFunctionReferenceExpression expr public StaticContext visitFunctionCall(FunctionCallExpression expression, StaticContext argument) { visitDescendants(expression, argument); - BuiltinFunction function = null; - FunctionSignature signature = null; - try { - function = BuiltinFunctionCatalogue.getBuiltinFunction(expression.getFunctionIdentifier()); - } catch (OurBadException exception) { - signature = expression.getStaticContext().getFunctionSignature(expression.getFunctionIdentifier()); - } - - + FunctionSignature signature = getSignature(expression.getFunctionIdentifier(), expression.getStaticContext()); List parameterExpressions = expression.getArguments(); - if (function != null) { - signature = function.getSignature(); - } List parameterTypes = signature.getParameterTypes(); + List partialParams = new ArrayList<>(); int paramsLength = parameterExpressions.size(); for (int i = 0; i < paramsLength; ++i) { @@ -316,11 +326,14 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static "Argument " + i + " requires " + expectedType + " but " + actualType + " was found" ); } + } else { + partialParams.add(parameterTypes.get(i)); } } if (expression.isPartialApplication()) { - expression.setInferredSequenceType(new SequenceType(ItemType.functionItem)); + FunctionSignature partialSignature = new FunctionSignature(partialParams, signature.getReturnType()); + expression.setInferredSequenceType(new SequenceType(new FunctionItemType(partialSignature))); } else { SequenceType returnType = signature.getReturnType(); if (returnType == null) { @@ -967,7 +980,7 @@ public void checkSwitchType(SequenceType type) { ); } ItemType itemType = type.getItemType(); - if (itemType.isSubtypeOf(ItemType.functionItem)) { + if (itemType.isFunctionItem()) { throw new UnexpectedStaticTypeException( "function item not allowed for the expressions of switch test condition and cases", ErrorCode.UnexpectedFunctionItem @@ -1342,6 +1355,20 @@ public StaticContext visitFilterExpression(FilterExpression expression, StaticCo return argument; } + // return [true] if [types] are subtype of or can be promoted to expected types, [false] otherwise + public boolean checkArguments(List expectedTypes, List types){ + int length = expectedTypes.size(); + if(length != types.size()){ + return false; + } + for(int i = 0; i < length; ++i){ + if(!types.get(i).isSubtypeOfOrCanBePromotedTo(expectedTypes.get(i))){ + return false; + } + } + return true; + } + @Override public StaticContext visitDynamicFunctionCallExpression( DynamicFunctionCallExpression expression, @@ -1352,18 +1379,33 @@ public StaticContext visitDynamicFunctionCallExpression( SequenceType mainType = expression.getMainExpression().getInferredSequenceType(); basicChecks(mainType, expression.getClass().getSimpleName(), true, false); - if (!mainType.equals(new SequenceType(ItemType.functionItem))) { - throw new UnexpectedStaticTypeException( - "the type of a dynamic function call main expression must be function, instead inferred " + mainType + + FunctionSignature signature = null; + boolean isAnyFunction = false; + if(!mainType.isEmptySequence()){ + ItemType type = mainType.getItemType(); + if(type.isFunctionItem()){ + if(type.equals(FunctionItemType.ANYFUNCTION)){ + isAnyFunction = true; + } else { + signature = type.getSignature(); + } + } + } + + List argsType = expression.getArguments().stream().map(expr -> expr.getInferredSequenceType()).collect(Collectors.toList()); + if(isAnyFunction || (signature != null && checkArguments(signature.getParameterTypes(), argsType))){ + // TODO: need to add support for partial application + expression.setInferredSequenceType(signature.getReturnType()); + System.out.println( + "visiting DynamicFunctionCall expression, type set to: " + expression.getInferredSequenceType() ); + return argument; } - // TODO: need to add support for partial application - expression.setInferredSequenceType(SequenceType.MOST_GENERAL_SEQUENCE_TYPE); - System.out.println( - "visiting DynamicFunctionCall expression, type set to: " + expression.getInferredSequenceType() + throw new UnexpectedStaticTypeException( + "the type of a dynamic function call main expression must be function, instead inferred " + mainType ); - return argument; } @Override diff --git a/src/main/java/org/rumbledb/items/FunctionItem.java b/src/main/java/org/rumbledb/items/FunctionItem.java index 793f2b0fdb..980ae61f9e 100644 --- a/src/main/java/org/rumbledb/items/FunctionItem.java +++ b/src/main/java/org/rumbledb/items/FunctionItem.java @@ -35,10 +35,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.RumbleException; import org.rumbledb.runtime.RuntimeIterator; -import org.rumbledb.types.FunctionSignature; -import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.ItemType; -import org.rumbledb.types.SequenceType; +import org.rumbledb.types.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -182,7 +179,7 @@ public boolean isAtomic() { @Override public boolean isTypeOf(ItemType type) { - return type.equals(ItemType.functionItem) || type.equals(ItemType.item); + return type.isFunctionItem() || type.equals(ItemType.item); } @Override @@ -289,7 +286,8 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return ItemType.functionItem; + // TODO: consider storing the itemType in the FunctionItem + return new FunctionItemType(this.signature); } public FunctionItem deepCopy() { diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index 11b71055a5..c32cb048bc 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -29,6 +29,11 @@ public boolean isFunctionItem() { return true; } + @Override + public FunctionSignature getSignature() { + return this.signature; + } + @Override public boolean equals(Object other) { if(!(other instanceof ItemType)){ diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 2ebe9ec7f3..3182be1ff8 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -121,6 +121,11 @@ public boolean isFunctionItem() { return false; } + // Returns the signature of a function item + public FunctionSignature getSignature() { + throw new OurBadException("called getSignature on a non-function item"); + } + // Returns true if [this] is a subtype of [superType], any type is considered a subtype of itself public boolean isSubtypeOf(ItemType superType) { return this.equals(superType); diff --git a/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq b/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq index 14d9cc4bf5..81f0bcb7c3 100644 --- a/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq +++ b/src/test/resources/test_files/static-typing/postfix/dynamicfunc1.jq @@ -1,4 +1,4 @@ (:JIQS: ShouldRun :) declare function a($b as atomic) { "a" || $b }; declare variable $a := a#1; -$a(12) is statically item*, $a(?) is statically function(*) \ No newline at end of file +$a(12) is statically string \ No newline at end of file diff --git a/src/test/resources/test_files/static-typing/postfix/dynamicfunc3.jq b/src/test/resources/test_files/static-typing/postfix/dynamicfunc3.jq new file mode 100644 index 0000000000..03c286d7d0 --- /dev/null +++ b/src/test/resources/test_files/static-typing/postfix/dynamicfunc3.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="SENR0001" :) +declare function a($b as atomic) { "a" || $b }; +declare variable $a := a#1; +$a is statically function(atomic) as string \ No newline at end of file From 64919b795dea481c650e194629ae889e16b88ab3 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 3 Dec 2020 09:46:54 +0100 Subject: [PATCH 098/206] completely substituted ItemType.functionItem --- src/main/java/org/rumbledb/types/ItemType.java | 1 - .../sparksoniq/spark/ml/GetEstimatorFunctionIterator.java | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 3182be1ff8..3cd02e17be 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -95,7 +95,6 @@ public static ItemType getItemTypeByName(String name) { protected String name; public static final ItemType item = new ItemType("item"); - public static final ItemType functionItem = new ItemType("function"); public ItemType() { } diff --git a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java index 0e2f1fca82..61781c4949 100644 --- a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java +++ b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java @@ -33,10 +33,7 @@ import org.rumbledb.items.FunctionItem; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; -import org.rumbledb.types.FunctionSignature; -import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.ItemType; -import org.rumbledb.types.SequenceType; +import org.rumbledb.types.*; import java.util.ArrayList; import java.util.Arrays; @@ -127,7 +124,7 @@ public Item next() { ) ); SequenceType returnType = new SequenceType( - ItemType.functionItem, + FunctionItemType.ANYFUNCTION, SequenceType.Arity.One ); From 6ad6712bb8f97a3f83997811d2f94507e63bd075 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 7 Dec 2020 09:57:41 +0100 Subject: [PATCH 099/206] fix in incrementArities --- src/main/java/org/rumbledb/context/StaticContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/context/StaticContext.java b/src/main/java/org/rumbledb/context/StaticContext.java index 10b7a3ee87..87f800e535 100644 --- a/src/main/java/org/rumbledb/context/StaticContext.java +++ b/src/main/java/org/rumbledb/context/StaticContext.java @@ -311,7 +311,7 @@ public void setContextItemStaticType(SequenceType contextItemStaticType) { // used by groupBy cluse public void incrementArities(StaticContext stopContext, Set varToExclude) { this.inScopeVariables.replaceAll( - (key, value) -> varToExclude.contains(value) + (key, value) -> varToExclude.contains(key) ? value : new InScopeVariable( value.getName(), From 8ad3078b5b35482eac3170d16df024cf46da038b Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 7 Dec 2020 09:59:05 +0100 Subject: [PATCH 100/206] added function hierarchy in subtypes --- .../org/rumbledb/types/FunctionItemType.java | 8 +++++++- .../org/rumbledb/types/FunctionSignature.java | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index c32cb048bc..d05a6fa9d6 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -44,7 +44,13 @@ public boolean equals(Object other) { @Override public boolean isSubtypeOf(ItemType superType) { - return this.equals(superType) || superType.equals(ANYFUNCTION) || superType.equals(ItemType.item); + if(this.equals(superType) || superType.equals(ANYFUNCTION) || superType.equals(ItemType.item)){ + return true; + } + if(superType.isFunctionItem() && this.signature.isSubtypeOf(superType.getSignature())){ + return true; + } + return false; } @Override diff --git a/src/main/java/org/rumbledb/types/FunctionSignature.java b/src/main/java/org/rumbledb/types/FunctionSignature.java index aebf635a54..1b9421512f 100644 --- a/src/main/java/org/rumbledb/types/FunctionSignature.java +++ b/src/main/java/org/rumbledb/types/FunctionSignature.java @@ -52,6 +52,26 @@ public boolean equals(Object instance) { && this.getReturnType() == ((FunctionSignature) instance).getReturnType(); } + public boolean isSubtypeOf(FunctionSignature other){ + // a signature is a subtype of another signature if it always respect its contract typewise (i.e. no static type errors) + // this return type must be a subtype of other return type + if(!this.returnType.isSubtypeOf(other.returnType)){ + return false; + } + int paramsLength = this.parameterTypes.size(); + // must have same number of parameters + if(paramsLength != other.parameterTypes.size()){ + return false; + } + for(int i = 0; i < paramsLength; ++i){ + // any parameter type of other must be a subtype of the corresponding parameter of this + if(!other.parameterTypes.get(i).isSubtypeOf(this.parameterTypes.get(i))){ + return false; + } + } + return true; + } + @Override public int hashCode() { return this.getParameterTypes().hashCode() + this.getReturnType().hashCode(); From 9e7b9d0d52b62440e1d4d892bf423725080e6dad Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 7 Dec 2020 22:11:21 +0100 Subject: [PATCH 101/206] added NativeClauseContext and removed Exception for native clause optimization --- .../exceptions/NoNativeQueryException.java | 7 --- .../org/rumbledb/runtime/RuntimeIterator.java | 10 ++-- .../runtime/flwor/NativeClauseContext.java | 48 +++++++++++++++++++ .../flwor/clauses/LetClauseSparkIterator.java | 12 +++-- .../runtime/postfix/ArrayLookupIterator.java | 12 +++-- .../runtime/postfix/ObjectLookupIterator.java | 12 +++-- .../primary/StringRuntimeIterator.java | 5 +- .../primary/VariableReferenceIterator.java | 5 +- 8 files changed, 84 insertions(+), 27 deletions(-) delete mode 100644 src/main/java/org/rumbledb/exceptions/NoNativeQueryException.java create mode 100644 src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java diff --git a/src/main/java/org/rumbledb/exceptions/NoNativeQueryException.java b/src/main/java/org/rumbledb/exceptions/NoNativeQueryException.java deleted file mode 100644 index 954433acf4..0000000000 --- a/src/main/java/org/rumbledb/exceptions/NoNativeQueryException.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.rumbledb.exceptions; - -public class NoNativeQueryException extends RuntimeException { - public NoNativeQueryException() { - super("It was not possible to generate a native sparkSQL query for this expression"); - } -} diff --git a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java index 5fe4c9e48b..955dd52674 100644 --- a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java @@ -34,6 +34,7 @@ import org.rumbledb.context.StaticContext; import org.rumbledb.exceptions.*; import org.rumbledb.expressions.ExecutionMode; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; @@ -370,12 +371,11 @@ public RuntimeIterator deepCopy() { /** * This function generate (if possible) a native spark-sql query that maps the inner working of the iterator * - * @return a string representing the spark-sql native query to get an equivalent result of the iterator, or null if + * @return a native clause context with the spark-sql native query to get an equivalent result of the iterator, or [NativeClauseContext.NoNativeQuery] if * it is not possible - * @param inputSchema schema of the dataframe - * @param context context + * @param nativeClauseContext context information to generate the native query */ - public String generateNativeQuery(StructType inputSchema, DynamicContext context) { - throw new NoNativeQueryException(); + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java new file mode 100644 index 0000000000..d3f596bdc0 --- /dev/null +++ b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java @@ -0,0 +1,48 @@ +package org.rumbledb.runtime.flwor; + +import org.apache.spark.sql.types.StructType; +import org.rumbledb.context.DynamicContext; +import org.rumbledb.expressions.flowr.FLWOR_CLAUSES; + +/** + * This class describes the context of a native clause and is used when processing FLWOR expressions without UDF + */ +public class NativeClauseContext { + public static NativeClauseContext NoNativeQuery = new NativeClauseContext(); + + private FLWOR_CLAUSES clauseType; + private StructType schema; + private DynamicContext context; + private String selectPart; + + private NativeClauseContext() {} + + public NativeClauseContext(FLWOR_CLAUSES clauseType, StructType schema, DynamicContext context){ + this.clauseType = clauseType; + this.schema = schema; + this.context = context; + this.selectPart = ""; + } + + public NativeClauseContext(NativeClauseContext parent){ + this.clauseType = parent.clauseType; + this.schema = parent.schema; + this.context = parent.context; + this.selectPart = parent.selectPart; + } + + public NativeClauseContext(NativeClauseContext parent, String newSelectPart){ + this.clauseType = parent.clauseType; + this.schema = parent.schema; + this.context = parent.context; + this.selectPart = newSelectPart; + } + + public void setSelectPart(String selectPart) { + this.selectPart = selectPart; + } + + public String getSelectPart(){ + return this.selectPart; + } +} diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index 1fe832398e..d1fec8fc29 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -34,9 +34,11 @@ import org.rumbledb.exceptions.JobWithinAJobException; import org.rumbledb.exceptions.UnsupportedFeatureException; import org.rumbledb.expressions.ExecutionMode; +import org.rumbledb.expressions.flowr.FLWOR_CLAUSES; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.RuntimeTupleIterator; import org.rumbledb.runtime.flwor.FlworDataFrameUtils; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.runtime.flwor.udfs.GroupClauseSerializeAggregateResultsUDF; import org.rumbledb.runtime.flwor.udfs.HashUDF; import org.rumbledb.runtime.flwor.udfs.LetClauseUDF; @@ -629,8 +631,12 @@ public static Dataset tryNativeQuery( DynamicContext context ) { try { - String nativeQuery = iterator.generateNativeQuery(inputSchema, context); - System.out.println("native query returned " + nativeQuery); + NativeClauseContext letContext = new NativeClauseContext(FLWOR_CLAUSES.LET, inputSchema, context); + NativeClauseContext nativeQuery = iterator.generateNativeQuery(letContext); + if(nativeQuery == NativeClauseContext.NoNativeQuery){ + return null; + } + System.out.println("native query returned " + nativeQuery.getSelectPart()); String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); dataFrame.createOrReplaceTempView("input"); return dataFrame.sparkSession() @@ -638,7 +644,7 @@ public static Dataset tryNativeQuery( String.format( "select %s (%s) as `%s` from input", selectSQL, - nativeQuery, + nativeQuery.getSelectPart(), newVariableName ) ); diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java index b0fe6fc4cb..48b8948810 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java @@ -41,6 +41,7 @@ import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; import sparksoniq.spark.SparkSessionManager; import java.util.Arrays; @@ -165,10 +166,13 @@ public boolean implementsDataFrames() { } @Override - public String generateNativeQuery(StructType inputSchema, DynamicContext context) { - String objectPart = this.iterator.generateNativeQuery(inputSchema, context); - initLookupPosition(); - return objectPart + "[" + (this.lookup - 1) + "]"; + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); + if(newContext != NativeClauseContext.NoNativeQuery){ + initLookupPosition(); + newContext.setSelectPart(newContext.getSelectPart() + "[" + (this.lookup - 1) + "]"); + } + return newContext; } public Dataset getDataFrame(DynamicContext context) { diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index 3f20c0c7f7..eaf96833dd 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -40,6 +40,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.runtime.primary.ContextExpressionIterator; import sparksoniq.spark.SparkSessionManager; @@ -217,10 +218,13 @@ public boolean implementsDataFrames() { } @Override - public String generateNativeQuery(StructType inputSchema, DynamicContext context) { - String objectPart = this.iterator.generateNativeQuery(inputSchema, context); - initLookupKey(); - return objectPart + "." + this.lookupKey.getStringValue(); + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); + if(newContext != NativeClauseContext.NoNativeQuery){ + initLookupKey(); + newContext.setSelectPart(newContext.getSelectPart() + "." + this.lookupKey.getStringValue()); + } + return newContext; } public Dataset getDataFrame(DynamicContext context) { diff --git a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java index e413e571b1..1bd5f75409 100644 --- a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java @@ -31,6 +31,7 @@ import org.rumbledb.exceptions.NoItemException; import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; public class StringRuntimeIterator extends AtomicRuntimeIterator { @@ -58,7 +59,7 @@ public Item materializeExactlyOneItem(DynamicContext context) throws NoItemExcep } @Override - public String generateNativeQuery(StructType inputSchema, DynamicContext context) { - return '"' + this.item.getStringValue() + '"'; + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + return new NativeClauseContext(nativeClauseContext, '"' + this.item.getStringValue() + '"'); } } diff --git a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java index dcfbff6f35..165b57c016 100644 --- a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java @@ -32,6 +32,7 @@ import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.SequenceType; import java.util.List; @@ -79,8 +80,8 @@ protected boolean hasNextLocal() { } @Override - public String generateNativeQuery(StructType inputSchema, DynamicContext context) { - return this.variableName.toString(); + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + return new NativeClauseContext(nativeClauseContext, this.variableName.toString()); } @Override From a9f4abe73d7c8eb9178370a7c94c6c5fe332b8d2 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 7 Dec 2020 22:11:51 +0100 Subject: [PATCH 102/206] removed array unboxing iterator in let clause optimization --- .../org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java index 4400ff2cea..94c6a7e7b2 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java @@ -128,12 +128,6 @@ public boolean implementsDataFrames() { return true; } - @Override - public String generateNativeQuery(StructType inputSchema, DynamicContext context) { - String objectPart = this.iterator.generateNativeQuery(inputSchema, context); - return "explode( " + objectPart + " )"; - } - public Dataset getDataFrame(DynamicContext context) { Dataset childDataFrame = this.children.get(0).getDataFrame(context); childDataFrame.createOrReplaceTempView("array"); From e17a7ea1c7de6956893a71d7d5ec4ab9c72bb8ca Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 8 Dec 2020 11:52:10 +0100 Subject: [PATCH 103/206] added schema checks to lookup operations --- .../runtime/flwor/NativeClauseContext.java | 11 +++++++++- .../runtime/postfix/ArrayLookupIterator.java | 6 ++++++ .../runtime/postfix/ObjectLookupIterator.java | 16 ++++++++++++++- .../primary/VariableReferenceIterator.java | 20 ++++++++++++++++++- 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java index d3f596bdc0..877b726732 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java +++ b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java @@ -1,5 +1,6 @@ package org.rumbledb.runtime.flwor; +import org.apache.spark.sql.types.DataType; import org.apache.spark.sql.types.StructType; import org.rumbledb.context.DynamicContext; import org.rumbledb.expressions.flowr.FLWOR_CLAUSES; @@ -11,7 +12,7 @@ public class NativeClauseContext { public static NativeClauseContext NoNativeQuery = new NativeClauseContext(); private FLWOR_CLAUSES clauseType; - private StructType schema; + private DataType schema; private DynamicContext context; private String selectPart; @@ -45,4 +46,12 @@ public void setSelectPart(String selectPart) { public String getSelectPart(){ return this.selectPart; } + + public DataType getSchema() { + return this.schema; + } + + public void setSchema(DataType schema) { + this.schema = schema; + } } diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java index 48b8948810..18db3891da 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java @@ -170,6 +170,12 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); if(newContext != NativeClauseContext.NoNativeQuery){ initLookupPosition(); + DataType schema = newContext.getSchema(); + if(!(schema instanceof ArrayType)){ + return NativeClauseContext.NoNativeQuery; + } + ArrayType arraySchema = (ArrayType) schema; + newContext.setSchema(arraySchema.elementType()); newContext.setSelectPart(newContext.getSelectPart() + "[" + (this.lookup - 1) + "]"); } return newContext; diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index eaf96833dd..a903209c6f 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -20,6 +20,7 @@ package org.rumbledb.runtime.postfix; +import org.apache.commons.lang3.ArrayUtils; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.function.FlatMapFunction; import org.apache.spark.sql.Dataset; @@ -27,6 +28,7 @@ import org.apache.spark.sql.types.DataType; import org.apache.spark.sql.types.StructField; import org.apache.spark.sql.types.StructType; +import org.mortbay.util.SingletonList; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; import org.rumbledb.context.Name; @@ -222,7 +224,19 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); if(newContext != NativeClauseContext.NoNativeQuery){ initLookupKey(); - newContext.setSelectPart(newContext.getSelectPart() + "." + this.lookupKey.getStringValue()); + String key = this.lookupKey.getStringValue(); + DataType schema = newContext.getSchema(); + if(!(schema instanceof StructType)){ + return NativeClauseContext.NoNativeQuery; + } + StructType structSchema = (StructType) schema; + if(Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(key))){ + newContext.setSelectPart(newContext.getSelectPart() + "." + key); + StructField field = structSchema.fields()[structSchema.fieldIndex(key)]; + newContext.setSchema(field.dataType()); + } else { + return NativeClauseContext.NoNativeQuery; + } } return newContext; } diff --git a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java index 165b57c016..0ad6f5b4f4 100644 --- a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java @@ -20,9 +20,12 @@ package org.rumbledb.runtime.primary; +import org.apache.commons.lang3.ArrayUtils; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; +import org.apache.spark.sql.types.DataType; +import org.apache.spark.sql.types.StructField; import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; @@ -35,6 +38,7 @@ import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.SequenceType; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -81,7 +85,21 @@ protected boolean hasNextLocal() { @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - return new NativeClauseContext(nativeClauseContext, this.variableName.toString()); + String name = this.variableName.toString(); + DataType schema = nativeClauseContext.getSchema(); + if(!(schema instanceof StructType)){ + return NativeClauseContext.NoNativeQuery; + } + // check if name is in the schema + StructType structSchema = (StructType) schema; + if(Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(name))){ + NativeClauseContext newContext = new NativeClauseContext(nativeClauseContext, name); + StructField field = structSchema.fields()[structSchema.fieldIndex(name)]; + newContext.setSchema(field.dataType()); + return newContext; + } else { + return NativeClauseContext.NoNativeQuery; + } } @Override From f1039c052b972ceeeb9201d9f2b8df22db0ac0d5 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 8 Dec 2020 16:05:54 +0100 Subject: [PATCH 104/206] added support for variable lookup --- .../java/org/rumbledb/runtime/flwor/NativeClauseContext.java | 4 ++++ .../org/rumbledb/runtime/postfix/ArrayLookupIterator.java | 2 ++ .../org/rumbledb/runtime/postfix/ObjectLookupIterator.java | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java index 877b726732..367cd5f350 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java +++ b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java @@ -54,4 +54,8 @@ public DataType getSchema() { public void setSchema(DataType schema) { this.schema = schema; } + + public DynamicContext getContext() { + return this.context; + } } diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java index 18db3891da..b04d6cc47d 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java @@ -169,7 +169,9 @@ public boolean implementsDataFrames() { public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); if(newContext != NativeClauseContext.NoNativeQuery){ + this.currentDynamicContextForLocalExecution = newContext.getContext(); initLookupPosition(); + this.currentDynamicContextForLocalExecution = null; DataType schema = newContext.getSchema(); if(!(schema instanceof ArrayType)){ return NativeClauseContext.NoNativeQuery; diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index a903209c6f..9a48572f78 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -223,7 +223,9 @@ public boolean implementsDataFrames() { public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); if(newContext != NativeClauseContext.NoNativeQuery){ + this.currentDynamicContextForLocalExecution = newContext.getContext(); initLookupKey(); + this.currentDynamicContextForLocalExecution = null; String key = this.lookupKey.getStringValue(); DataType schema = newContext.getSchema(); if(!(schema instanceof StructType)){ From 961a83580168655583ad70b78a9fb56488ce7f1c Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 10 Dec 2020 12:43:31 +0100 Subject: [PATCH 105/206] refactor selectPart into resultQuery --- .../runtime/flwor/NativeClauseContext.java | 16 ++++++++-------- .../flwor/clauses/LetClauseSparkIterator.java | 5 +++-- .../runtime/postfix/ArrayLookupIterator.java | 2 +- .../runtime/postfix/ObjectLookupIterator.java | 4 +--- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java index 367cd5f350..16e78f1810 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java +++ b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java @@ -14,7 +14,7 @@ public class NativeClauseContext { private FLWOR_CLAUSES clauseType; private DataType schema; private DynamicContext context; - private String selectPart; + private String resultingQuery; private NativeClauseContext() {} @@ -22,29 +22,29 @@ public NativeClauseContext(FLWOR_CLAUSES clauseType, StructType schema, DynamicC this.clauseType = clauseType; this.schema = schema; this.context = context; - this.selectPart = ""; + this.resultingQuery = ""; } public NativeClauseContext(NativeClauseContext parent){ this.clauseType = parent.clauseType; this.schema = parent.schema; this.context = parent.context; - this.selectPart = parent.selectPart; + this.resultingQuery = parent.resultingQuery; } public NativeClauseContext(NativeClauseContext parent, String newSelectPart){ this.clauseType = parent.clauseType; this.schema = parent.schema; this.context = parent.context; - this.selectPart = newSelectPart; + this.resultingQuery = newSelectPart; } - public void setSelectPart(String selectPart) { - this.selectPart = selectPart; + public void setResultingQuery(String resultingQuery) { + this.resultingQuery = resultingQuery; } - public String getSelectPart(){ - return this.selectPart; + public String getResultingQuery(){ + return this.resultingQuery; } public DataType getSchema() { diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index d1fec8fc29..e7cce81124 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -630,13 +630,14 @@ public static Dataset tryNativeQuery( StructType inputSchema, DynamicContext context ) { + // the try catch block is required because of the query that are not supported by sparksql like using a field to decide which field to use (e.g. $i.($i.fieldToUse) ) try { NativeClauseContext letContext = new NativeClauseContext(FLWOR_CLAUSES.LET, inputSchema, context); NativeClauseContext nativeQuery = iterator.generateNativeQuery(letContext); if(nativeQuery == NativeClauseContext.NoNativeQuery){ return null; } - System.out.println("native query returned " + nativeQuery.getSelectPart()); + System.out.println("native query returned " + nativeQuery.getResultingQuery()); String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); dataFrame.createOrReplaceTempView("input"); return dataFrame.sparkSession() @@ -644,7 +645,7 @@ public static Dataset tryNativeQuery( String.format( "select %s (%s) as `%s` from input", selectSQL, - nativeQuery.getSelectPart(), + nativeQuery.getResultingQuery(), newVariableName ) ); diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java index b04d6cc47d..76207f1cf8 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java @@ -178,7 +178,7 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC } ArrayType arraySchema = (ArrayType) schema; newContext.setSchema(arraySchema.elementType()); - newContext.setSelectPart(newContext.getSelectPart() + "[" + (this.lookup - 1) + "]"); + newContext.setResultingQuery(newContext.getResultingQuery() + "[" + (this.lookup - 1) + "]"); } return newContext; } diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index 9a48572f78..f696ee3100 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -20,7 +20,6 @@ package org.rumbledb.runtime.postfix; -import org.apache.commons.lang3.ArrayUtils; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.function.FlatMapFunction; import org.apache.spark.sql.Dataset; @@ -28,7 +27,6 @@ import org.apache.spark.sql.types.DataType; import org.apache.spark.sql.types.StructField; import org.apache.spark.sql.types.StructType; -import org.mortbay.util.SingletonList; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; import org.rumbledb.context.Name; @@ -233,7 +231,7 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC } StructType structSchema = (StructType) schema; if(Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(key))){ - newContext.setSelectPart(newContext.getSelectPart() + "." + key); + newContext.setResultingQuery(newContext.getResultingQuery() + "." + key); StructField field = structSchema.fields()[structSchema.fieldIndex(key)]; newContext.setSchema(field.dataType()); } else { From 8c688007b3528db3c9b35fd6023554e3dd3f04b0 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 10 Dec 2020 12:44:20 +0100 Subject: [PATCH 106/206] added whereclause native approach --- .../clauses/WhereClauseSparkIterator.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java index 9c1b28d415..1384f98526 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java @@ -31,9 +31,11 @@ import org.rumbledb.exceptions.JobWithinAJobException; import org.rumbledb.exceptions.OurBadException; import org.rumbledb.expressions.ExecutionMode; +import org.rumbledb.expressions.flowr.FLWOR_CLAUSES; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.RuntimeTupleIterator; import org.rumbledb.runtime.flwor.FlworDataFrameUtils; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.runtime.flwor.udfs.WhereClauseUDF; import sparksoniq.jsoniq.tuple.FlworTuple; @@ -202,6 +204,19 @@ public Dataset getDataFrame( Dataset df = this.child.getDataFrame(context, getProjection(parentProjection)); StructType inputSchema = df.schema(); + Dataset nativeQueryResult = tryNativeQuery( + df, + this.expression, + inputSchema, + context + ); + if (nativeQueryResult != null) { + return nativeQueryResult; + } + + // was not possible, we use let udf + System.out.println("using UDF"); + List UDFcolumns = FlworDataFrameUtils.getColumnNames( inputSchema, this.expression.getVariableDependencies(), @@ -274,4 +289,41 @@ public Map getProjection( } return projection; } + + /** + * Try to generate the native query for the let clause and run it, if successful return the resulting dataframe, + * otherwise it returns null + * + * @param dataFrame input dataframe for the query + * @param iterator where filtering expression iterator + * @param inputSchema input schema of the dataframe + * @param context current dynamic context of the dataframe + * @return resulting dataframe of the let clause if successful, null otherwise + */ + public static Dataset tryNativeQuery( + Dataset dataFrame, + RuntimeIterator iterator, + StructType inputSchema, + DynamicContext context + ) { + // the try catch block is required because of the query that are not supported by sparksql like using a field to decide which field to use (e.g. $i.($i.fieldToUse) ) + try { + NativeClauseContext letContext = new NativeClauseContext(FLWOR_CLAUSES.WHERE, inputSchema, context); + NativeClauseContext nativeQuery = iterator.generateNativeQuery(letContext); + if(nativeQuery == NativeClauseContext.NoNativeQuery){ + return null; + } + System.out.println("native query returned " + nativeQuery.getResultingQuery()); + dataFrame.createOrReplaceTempView("input"); + return dataFrame.sparkSession() + .sql( + String.format( + "select * from input where %s", + nativeQuery.getResultingQuery() + ) + ); + } catch (Exception e) { + return null; + } + } } From ea4b32cef53a68eb7874c6d46d4c37b4478a457d Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 10 Dec 2020 12:45:43 +0100 Subject: [PATCH 107/206] added mapping for numeric literals --- .../rumbledb/runtime/primary/DecimalRuntimeIterator.java | 6 ++++++ .../org/rumbledb/runtime/primary/DoubleRuntimeIterator.java | 6 ++++++ .../rumbledb/runtime/primary/IntegerRuntimeIterator.java | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java index 54497d6f7c..dc988bf6d0 100644 --- a/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java @@ -29,6 +29,7 @@ import org.rumbledb.exceptions.NoItemException; import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; import java.math.BigDecimal; @@ -58,4 +59,9 @@ public Item next() { public Item materializeExactlyOneItem(DynamicContext context) throws NoItemException, MoreThanOneItemException { return this.item; } + + @Override + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + return new NativeClauseContext(nativeClauseContext, "" + this.item.getDecimalValue()); + } } diff --git a/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java index ceb17c6687..96dff652c6 100644 --- a/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java @@ -29,6 +29,7 @@ import org.rumbledb.exceptions.NoItemException; import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; public class DoubleRuntimeIterator extends AtomicRuntimeIterator { @@ -56,4 +57,9 @@ public Item next() { public Item materializeExactlyOneItem(DynamicContext context) throws NoItemException, MoreThanOneItemException { return this.item; } + + @Override + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + return new NativeClauseContext(nativeClauseContext, "" + this.item.getDoubleValue()); + } } diff --git a/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java index 5b4ca99e4d..43d65fbb87 100644 --- a/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java @@ -29,6 +29,7 @@ import org.rumbledb.exceptions.NoItemException; import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; public class IntegerRuntimeIterator extends AtomicRuntimeIterator { @@ -58,4 +59,9 @@ public Item next() { public Item materializeExactlyOneItem(DynamicContext context) throws NoItemException, MoreThanOneItemException { return this.item; } + + @Override + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + return new NativeClauseContext(nativeClauseContext, "" + this.item.getIntValue()); + } } From 8a429ffec0eed8b52db4c84602094fb1e27ee785 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 10 Dec 2020 12:46:13 +0100 Subject: [PATCH 108/206] native comparison and logical operations --- .../operational/AndOperationIterator.java | 13 +++++++++ .../ComparisonOperationIterator.java | 27 +++++++++++++++++++ .../operational/NotOperationIterator.java | 12 +++++++++ .../operational/OrOperationIterator.java | 13 +++++++++ 4 files changed, 65 insertions(+) diff --git a/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java index 8b02ba7d6f..32d54bd621 100644 --- a/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java @@ -29,6 +29,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.LocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; public class AndOperationIterator extends LocalRuntimeIterator { @@ -73,4 +74,16 @@ public Item next() { throw new IteratorFlowException(RuntimeIterator.FLOW_EXCEPTION_MESSAGE, getMetadata()); } + + @Override + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + NativeClauseContext leftResult = this.leftIterator.generateNativeQuery(nativeClauseContext); + NativeClauseContext rightResult = this.rightIterator.generateNativeQuery(nativeClauseContext); + if(leftResult == NativeClauseContext.NoNativeQuery || rightResult == NativeClauseContext.NoNativeQuery){ + return NativeClauseContext.NoNativeQuery; + } + + String resultingQuery = "( " + leftResult.getResultingQuery() + " AND " + rightResult.getResultingQuery() + " )"; + return new NativeClauseContext(nativeClauseContext, resultingQuery); + } } diff --git a/src/main/java/org/rumbledb/runtime/operational/ComparisonOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/ComparisonOperationIterator.java index 51423f81a9..46f43de22f 100644 --- a/src/main/java/org/rumbledb/runtime/operational/ComparisonOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/ComparisonOperationIterator.java @@ -31,6 +31,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.LocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; import java.util.ArrayList; import java.util.Arrays; @@ -183,4 +184,30 @@ private Item comparePair(Item left, Item right) { } return left.compareItem(right, this.comparisonOperator, getMetadata()); } + + @Override + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + if(this.comparisonOperator.isValueComparison()){ + NativeClauseContext leftResult = this.leftIterator.generateNativeQuery(nativeClauseContext); + NativeClauseContext rightResult = this.rightIterator.generateNativeQuery(nativeClauseContext); + + if(leftResult == NativeClauseContext.NoNativeQuery || rightResult == NativeClauseContext.NoNativeQuery){ + return NativeClauseContext.NoNativeQuery; + } + + String operator = " = "; + switch (this.comparisonOperator.name()){ + case "eq": operator = " = "; break; + case "ne": operator = " <> "; break; + case "le": operator = " <= "; break; + case "lt": operator = " < "; break; + case "ge": operator = " >= "; break; + case "gt": operator = " > "; break; + } + String query = "( " + leftResult.getResultingQuery() + operator + rightResult.getResultingQuery() + " )"; + return new NativeClauseContext(nativeClauseContext, query); + } else { + return NativeClauseContext.NoNativeQuery; + } + } } diff --git a/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java index 144d29c0dd..7429184d13 100644 --- a/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java @@ -28,6 +28,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.LocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; public class NotOperationIterator extends LocalRuntimeIterator { @@ -51,4 +52,15 @@ public Item next() { this.hasNext = false; return ItemFactory.getInstance().createBooleanItem(!(effectiveBooleanValue)); } + + @Override + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + NativeClauseContext childResult = this.child.generateNativeQuery(nativeClauseContext); + if(childResult == NativeClauseContext.NoNativeQuery){ + return NativeClauseContext.NoNativeQuery; + } + + String resultingQuery = "( NOT " + childResult.getResultingQuery() + " )"; + return new NativeClauseContext(nativeClauseContext, resultingQuery); + } } diff --git a/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java index f433fb5bf3..1b82e10611 100644 --- a/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java @@ -28,6 +28,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.LocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; public class OrOperationIterator extends LocalRuntimeIterator { @@ -60,4 +61,16 @@ public Item next() { this.hasNext = false; return ItemFactory.getInstance().createBooleanItem((leftEffectiveBooleanValue || rightEffectiveBooleanValue)); } + + @Override + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + NativeClauseContext leftResult = this.leftIterator.generateNativeQuery(nativeClauseContext); + NativeClauseContext rightResult = this.rightIterator.generateNativeQuery(nativeClauseContext); + if(leftResult == NativeClauseContext.NoNativeQuery || rightResult == NativeClauseContext.NoNativeQuery){ + return NativeClauseContext.NoNativeQuery; + } + + String resultingQuery = "( " + leftResult.getResultingQuery() + " OR " + rightResult.getResultingQuery() + " )"; + return new NativeClauseContext(nativeClauseContext, resultingQuery); + } } From 71a6e46b74654af9f07411722dcc548c3ce0e1a7 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 10 Dec 2020 14:57:47 +0100 Subject: [PATCH 109/206] added support dynamic context variable reference --- src/main/java/org/rumbledb/api/Item.java | 6 ++++++ src/main/java/org/rumbledb/items/DecimalItem.java | 5 +++++ src/main/java/org/rumbledb/items/DoubleItem.java | 5 +++++ src/main/java/org/rumbledb/items/IntItem.java | 5 +++++ src/main/java/org/rumbledb/items/IntegerItem.java | 5 +++++ src/main/java/org/rumbledb/items/StringItem.java | 5 +++++ .../runtime/primary/VariableReferenceIterator.java | 11 ++++++++++- 7 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/api/Item.java b/src/main/java/org/rumbledb/api/Item.java index 5bdf379660..9584e849dd 100644 --- a/src/main/java/org/rumbledb/api/Item.java +++ b/src/main/java/org/rumbledb/api/Item.java @@ -657,4 +657,10 @@ public List getParameterNames() { public FunctionSignature getSignature() { throw new UnsupportedOperationException("Operation not defined"); } + + /** + * Get sparkSql string for the item + * @return String representing the item in a sparksql query or null if it is not supported for the item + */ + public String getSparkSqlQuery() { return null; } } diff --git a/src/main/java/org/rumbledb/items/DecimalItem.java b/src/main/java/org/rumbledb/items/DecimalItem.java index e04e912c21..198d1b03b0 100644 --- a/src/main/java/org/rumbledb/items/DecimalItem.java +++ b/src/main/java/org/rumbledb/items/DecimalItem.java @@ -269,4 +269,9 @@ public Item idivide(Item other) { public ItemType getDynamicType() { return AtomicItemType.decimalItem; } + + @Override + public String getSparkSqlQuery() { + return this.value.toString(); + } } diff --git a/src/main/java/org/rumbledb/items/DoubleItem.java b/src/main/java/org/rumbledb/items/DoubleItem.java index fdda5828e4..7fe692d1b9 100644 --- a/src/main/java/org/rumbledb/items/DoubleItem.java +++ b/src/main/java/org/rumbledb/items/DoubleItem.java @@ -233,4 +233,9 @@ public Item idivide(Item other) { public ItemType getDynamicType() { return AtomicItemType.doubleItem; } + + @Override + public String getSparkSqlQuery() { + return "" + this.value; + } } diff --git a/src/main/java/org/rumbledb/items/IntItem.java b/src/main/java/org/rumbledb/items/IntItem.java index 9e6a8b95d4..5d09b16b12 100644 --- a/src/main/java/org/rumbledb/items/IntItem.java +++ b/src/main/java/org/rumbledb/items/IntItem.java @@ -348,4 +348,9 @@ public Item idivide(Item other) { public ItemType getDynamicType() { return AtomicItemType.integerItem; } + + @Override + public String getSparkSqlQuery() { + return "" + this.value; + } } diff --git a/src/main/java/org/rumbledb/items/IntegerItem.java b/src/main/java/org/rumbledb/items/IntegerItem.java index d99a346930..d8b5b46867 100644 --- a/src/main/java/org/rumbledb/items/IntegerItem.java +++ b/src/main/java/org/rumbledb/items/IntegerItem.java @@ -294,4 +294,9 @@ public Item idivide(Item other) { public ItemType getDynamicType() { return AtomicItemType.integerItem; } + + @Override + public String getSparkSqlQuery() { + return this.value.toString(); + } } diff --git a/src/main/java/org/rumbledb/items/StringItem.java b/src/main/java/org/rumbledb/items/StringItem.java index 4b5aa3bc30..b0501fcd53 100644 --- a/src/main/java/org/rumbledb/items/StringItem.java +++ b/src/main/java/org/rumbledb/items/StringItem.java @@ -254,4 +254,9 @@ public Item compareItem( public ItemType getDynamicType() { return AtomicItemType.stringItem; } + + @Override + public String getSparkSqlQuery() { + return '"' + this.value + '"'; + } } diff --git a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java index 0ad6f5b4f4..e100f82479 100644 --- a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java @@ -98,7 +98,16 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC newContext.setSchema(field.dataType()); return newContext; } else { - return NativeClauseContext.NoNativeQuery; + List items = nativeClauseContext.getContext().getVariableValues().getLocalVariableValue(this.variableName, getMetadata()); + if(items.size() != 1) { + // only possible to turn into native, sequence of length 1 + return NativeClauseContext.NoNativeQuery; + } + String itemQuery = items.get(0).getSparkSqlQuery(); + if(itemQuery == null){ + return NativeClauseContext.NoNativeQuery; + } + return new NativeClauseContext(nativeClauseContext, itemQuery); } } From dd0cf6b8b55d8ee9a1cabacc0972421f82d54bae Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 14 Dec 2020 10:02:16 +0100 Subject: [PATCH 110/206] added check for binary type in variable reference --- .../rumbledb/runtime/primary/VariableReferenceIterator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java index e100f82479..bfa5cc87ff 100644 --- a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java @@ -95,7 +95,11 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC if(Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(name))){ NativeClauseContext newContext = new NativeClauseContext(nativeClauseContext, name); StructField field = structSchema.fields()[structSchema.fieldIndex(name)]; - newContext.setSchema(field.dataType()); + DataType fieldType = field.dataType(); + if(fieldType.typeName().equals("binary")){ + return NativeClauseContext.NoNativeQuery; + } + newContext.setSchema(fieldType); return newContext; } else { List items = nativeClauseContext.getContext().getVariableValues().getLocalVariableValue(this.variableName, getMetadata()); From c1249d864214fc5e605962e82e82be652014632c Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 14 Dec 2020 11:18:00 +0100 Subject: [PATCH 111/206] added for native query --- .../flwor/clauses/ForClauseSparkIterator.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index 595764ade4..109aa4a077 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -38,11 +38,13 @@ import org.rumbledb.exceptions.JobWithinAJobException; import org.rumbledb.exceptions.UnsupportedFeatureException; import org.rumbledb.expressions.ExecutionMode; +import org.rumbledb.expressions.flowr.FLWOR_CLAUSES; import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.CommaExpressionIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.RuntimeTupleIterator; import org.rumbledb.runtime.flwor.FlworDataFrameUtils; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.runtime.flwor.closures.ItemsToBinaryColumn; import org.rumbledb.runtime.flwor.udfs.DataFrameContext; import org.rumbledb.runtime.flwor.udfs.ForClauseUDF; @@ -861,6 +863,23 @@ private Dataset getDataFrameInParallel( null, variableNamesToExclude ); + + // TODO: Useless because here is local for + Dataset nativeQueryResult = tryNativeQuery( + df, + this.variableName, + this.positionalVariableName, + this.allowingEmpty, + this.assignmentIterator, + allColumns, + inputSchema, + context + ); + if (nativeQueryResult != null) { + return nativeQueryResult; + } + System.out.println("using UDF"); + List UDFcolumns; if (this.child != null) { UDFcolumns = FlworDataFrameUtils.getColumnNames( @@ -1167,4 +1186,66 @@ public Map getProjection( } return projection; } + + /** + * Try to generate the native query for the for clause and run it, if successful return the resulting dataframe, + * otherwise it returns null + * + * @param dataFrame input dataframe for the query + * @param newVariableName name of the new bound variable + * @param positionalVariableName name of the positional variable (or null if absent) + * @param allowingEmpty boolean signaling allowing empty flag in expression + * @param iterator for variable assignment expression iterator + * @param allColumns other columns required in following clauses + * @param inputSchema input schema of the dataframe + * @param context current dynamic context of the dataframe + * @return resulting dataframe of the for clause if successful, null otherwise + */ + public static Dataset tryNativeQuery( + Dataset dataFrame, + Name newVariableName, + Name positionalVariableName, + boolean allowingEmpty, + RuntimeIterator iterator, + List allColumns, + StructType inputSchema, + DynamicContext context + ) { + // the try catch block is required because of the query that are not supported by sparksql like using a field to decide which field to use (e.g. $i.($i.fieldToUse) ) + try { + NativeClauseContext forContext = new NativeClauseContext(FLWOR_CLAUSES.FOR, inputSchema, context); + NativeClauseContext nativeQuery = iterator.generateNativeQuery(forContext); + if(nativeQuery == NativeClauseContext.NoNativeQuery){ + return null; + } + System.out.println("native query returned " + nativeQuery.getResultingQuery()); + String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); + dataFrame.createOrReplaceTempView("input"); + + // let's distinguish 4 cases + if (positionalVariableName == null) { + if (allowingEmpty) { + return null; + } else { + return dataFrame.sparkSession() + .sql( + String.format( + "select %s explode(%s) as `%s` from input", + selectSQL, + nativeQuery.getResultingQuery(), + newVariableName + ) + ); + } + } else { + if(allowingEmpty) { + return null; + } else { + return null; + } + } + } catch (Exception e) { + return null; + } + } } From d1044b8cc3602b3ba92097d55c9be5e28ffa6e5e Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 15 Dec 2020 16:26:59 +0100 Subject: [PATCH 112/206] resolved conflicts --- .../rumbledb/items/parsing/ItemParser.java | 30 +++++++++---------- .../operational/TypePromotionIterator.java | 4 ++- .../runtime/postfix/ObjectLookupIterator.java | 4 +-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/rumbledb/items/parsing/ItemParser.java b/src/main/java/org/rumbledb/items/parsing/ItemParser.java index a0c3fdce57..84fafa1557 100644 --- a/src/main/java/org/rumbledb/items/parsing/ItemParser.java +++ b/src/main/java/org/rumbledb/items/parsing/ItemParser.java @@ -143,37 +143,37 @@ public static Item convertValueToItem( public static ItemType convertDataTypeToItemType(DataType dt) { if (dt instanceof StructType) { - return ItemType.objectItem; + return AtomicItemType.objectItem; } if (dt instanceof ArrayType) { - return ItemType.arrayItem; + return AtomicItemType.arrayItem; } if (dt.equals(DataTypes.StringType)) { - return ItemType.stringItem; + return AtomicItemType.stringItem; } else if (dt.equals(DataTypes.BooleanType)) { - return ItemType.booleanItem; + return AtomicItemType.booleanItem; } else if (dt.equals(DataTypes.DoubleType)) { - return ItemType.doubleItem; + return AtomicItemType.doubleItem; } else if (dt.equals(DataTypes.IntegerType)) { - return ItemType.integerItem; + return AtomicItemType.integerItem; } else if (dt.equals(DataTypes.FloatType)) { - return ItemType.doubleItem; + return AtomicItemType.doubleItem; } else if (dt.equals(decimalType)) { - return ItemType.decimalItem; + return AtomicItemType.decimalItem; } else if (dt.equals(DataTypes.LongType)) { - return ItemType.integerItem; + return AtomicItemType.integerItem; } else if (dt.equals(DataTypes.NullType)) { - return ItemType.nullItem; + return AtomicItemType.nullItem; } else if (dt.equals(DataTypes.ShortType)) { - return ItemType.integerItem; + return AtomicItemType.integerItem; } else if (dt.equals(DataTypes.TimestampType)) { - return ItemType.dateTimeItem; + return AtomicItemType.dateTimeItem; } else if (dt.equals(DataTypes.DateType)) { - return ItemType.dateItem; + return AtomicItemType.dateItem; } else if (dt.equals(DataTypes.BinaryType)) { - return ItemType.hexBinaryItem; + return AtomicItemType.hexBinaryItem; } else if (dt instanceof VectorUDT) { - return ItemType.arrayItem; + return AtomicItemType.arrayItem; } throw new OurBadException("DataFrame type unsupported: " + dt); } diff --git a/src/main/java/org/rumbledb/runtime/operational/TypePromotionIterator.java b/src/main/java/org/rumbledb/runtime/operational/TypePromotionIterator.java index e3f41024d0..34d3314c5b 100644 --- a/src/main/java/org/rumbledb/runtime/operational/TypePromotionIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/TypePromotionIterator.java @@ -11,10 +11,12 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.ExecutionMode; +import org.rumbledb.items.AtomicItem; import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.sequences.general.TypePromotionClosure; import org.rumbledb.runtime.typing.TreatIterator; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; @@ -188,7 +190,7 @@ public Dataset getDataFrame(DynamicContext dynamicContext) { return df; } ItemType dataItemType = TreatIterator.getItemType(df); - if (dataItemType.isSubtypeOf(ItemType.decimalItem) && this.itemType.equals(ItemType.doubleItem)) { + if (dataItemType.isSubtypeOf(AtomicItemType.decimalItem) && this.itemType.equals(AtomicItemType.doubleItem)) { df.createOrReplaceTempView("input"); df = df.sparkSession() .sql( diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index ced5cc432d..7fb0089c9e 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -221,9 +221,7 @@ public boolean implementsDataFrames() { public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); if(newContext != NativeClauseContext.NoNativeQuery){ - this.currentDynamicContextForLocalExecution = newContext.getContext(); - initLookupKey(); - this.currentDynamicContextForLocalExecution = null; + initLookupKey(newContext.getContext()); String key = this.lookupKey.getStringValue(); DataType schema = newContext.getSchema(); if(!(schema instanceof StructType)){ From 679155ab168c1b86ec6d5ff6f4bd4ceece94bf3e Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 16 Dec 2020 11:56:44 +0100 Subject: [PATCH 113/206] added orderby native optimization --- .../clauses/OrderByClauseSparkIterator.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index ee55f54329..699016d973 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -37,9 +37,12 @@ import org.rumbledb.exceptions.RumbleException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.ExecutionMode; +import org.rumbledb.expressions.flowr.FLWOR_CLAUSES; +import org.rumbledb.expressions.flowr.OrderByClause; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.RuntimeTupleIterator; import org.rumbledb.runtime.flwor.FlworDataFrameUtils; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.runtime.flwor.expression.OrderByClauseAnnotatedChildIterator; import org.rumbledb.runtime.flwor.udfs.OrderClauseCreateColumnsUDF; import org.rumbledb.runtime.flwor.udfs.OrderClauseDetermineTypeUDF; @@ -247,6 +250,20 @@ public Dataset getDataFrame( null ); + Dataset nativeQueryResult = tryNativeQuery( + df, + this.expressionsWithIterator, + allColumns, + inputSchema, + context + ); + if (nativeQueryResult != null) { + return nativeQueryResult; + } + + // was not possible, we use order udf + System.out.println("using UDF"); + df.sparkSession() .udf() .register( @@ -484,4 +501,57 @@ public Map getProjection( } return projection; } + + /** + * Try to generate the native query for the order by clause and run it, if successful return the resulting dataframe, + * otherwise it returns null + * + * @param dataFrame input dataframe for the query + * @param expressionsWithIterator list of ordering iterators + * @param allColumns other columns required in following clauses + * @param inputSchema input schema of the dataframe + * @param context current dynamic context of the dataframe + * @return resulting dataframe of the order by clause if successful, null otherwise + */ + public static Dataset tryNativeQuery( + Dataset dataFrame, + List expressionsWithIterator, + List allColumns, + StructType inputSchema, + DynamicContext context + ) { + // the try catch block is required because of the query that are not supported by sparksql like using a field to decide which field to use (e.g. $i.($i.fieldToUse) ) + try { + NativeClauseContext orderContext = new NativeClauseContext(FLWOR_CLAUSES.ORDER_BY, inputSchema, context); + StringBuilder orderSql = new StringBuilder(); + String orderSeparator = ""; + NativeClauseContext nativeQuery; + for(OrderByClauseAnnotatedChildIterator orderIterator : expressionsWithIterator){ + nativeQuery = orderIterator.getIterator().generateNativeQuery(orderContext); + if(nativeQuery == NativeClauseContext.NoNativeQuery){ + return null; + } + orderSql.append(orderSeparator); + orderSeparator = ", "; + orderSql.append(nativeQuery.getResultingQuery()); + if(!orderIterator.isAscending()){ + orderSql.append(" desc"); + } + } + + System.out.println("native query returned: " + orderSql); + String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, false); + dataFrame.createOrReplaceTempView("input"); + return dataFrame.sparkSession() + .sql( + String.format( + "select %s from input order by %s", + selectSQL, + orderSql + ) + ); + } catch (Exception e) { + return null; + } + } } From 5a9d291a46f990985e66fb556e36de9c696e4164 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 29 Dec 2020 10:42:05 +0100 Subject: [PATCH 114/206] added non-tested properly group by native optimization --- .../clauses/GroupByClauseSparkIterator.java | 88 ++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java index 6aa724811c..3bcb97fe80 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java @@ -302,10 +302,25 @@ public Dataset getDataFrame( } inputSchema = df.schema(); - Map groupingVariables = new TreeMap<>(); df.createOrReplaceTempView("input"); + Dataset nativeQueryResult = tryNativeQuery( + df, + variableAccessNames, + this.dependencies, + inputSchema, + context + ); + if (nativeQueryResult != null) { + return nativeQueryResult; + } + + // was not possible, we use let udf + System.out.println("using UDF"); + + Map groupingVariables = new TreeMap<>(); + // Determine the return type for grouping UDF List typedFields = new ArrayList<>(); String appendedGroupingColumnsName = "grouping_columns"; @@ -460,4 +475,75 @@ public Map getProjection( } return projection; } + + /** + * Try to generate the native query for the group by clause and run it, if successful return the resulting dataframe, + * otherwise it returns null (expect `input` table to be already available) + * + * @param dataFrame input dataframe for the query + * @param groupingVariables group by variables + * @param dependencies dependencies to forward to the next clause (select variables) + * @param inputSchema input schema of the dataframe + * @param context current dynamic context of the dataframe + * @return resulting dataframe of the group by clause if successful, null otherwise + */ + private Dataset tryNativeQuery(Dataset dataFrame, List groupingVariables, Map dependencies, StructType inputSchema, DynamicContext context) { + try{ + StringBuilder groupByString = new StringBuilder(); + String sep = " "; + for(Name groupingVar : groupingVariables){ + StructField field = inputSchema.fields()[inputSchema.fieldIndex(groupingVar.toString())]; + if(field.dataType().equals(DataTypes.BinaryType)){ + // we got a non-native type for grouping, switch to udf version + return null; + } + + groupByString.append(sep); + sep = ", "; + groupByString.append(groupingVar.toString()); + } + StringBuilder selectString = new StringBuilder(); + sep = " "; + for(Map.Entry entry : dependencies.entrySet()){ + selectString.append(sep); + sep = ", "; + // TODO: what about precomputed count + if(entry.getValue() == DynamicContext.VariableDependency.COUNT){ + // we need a count + selectString.append("count(`"); + selectString.append(entry.getKey().toString()); + selectString.append("`) as `"); + selectString.append(entry.getKey().toString()); + selectString.append(".count`)"); + } else if(groupingVariables.contains(entry.getKey())){ + // we are considering one of the grouping variables + selectString.append(entry.getKey().toString()); + } else { + // we collect all the values, if it is a binary object we just switch over to udf + String columnName = entry.getKey().toString(); + StructField field = inputSchema.fields()[inputSchema.fieldIndex(columnName)]; + if(field.dataType().equals(DataTypes.BinaryType)){ + return null; + } + selectString.append("collect_list(`"); + selectString.append(columnName); + selectString.append("`) as `"); + selectString.append(columnName); + selectString.append("`"); + } + } + System.out.println("select part got returned: "+selectString); + System.out.println("groupby part got returned: "+groupByString); + return dataFrame.sparkSession() + .sql( + String.format( + "select %s from input group by %s", + selectString, + groupByString + ) + ); + } catch (Exception e) { + return null; + } + } } From f3ba44faf88694df0c1d4513c97e7b888d237a1d Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 29 Dec 2020 12:01:00 +0100 Subject: [PATCH 115/206] after merge compilable again --- .../runtime/postfix/ArrayLookupIterator.java | 4 +- .../runtime/typing/InstanceOfIterator.java | 40 +++++++++---------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java index 8870c5e2b0..102da70b34 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java @@ -165,9 +165,7 @@ public boolean implementsDataFrames() { public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); if(newContext != NativeClauseContext.NoNativeQuery){ - this.currentDynamicContextForLocalExecution = newContext.getContext(); - initLookupPosition(); - this.currentDynamicContextForLocalExecution = null; + initLookupPosition(newContext.getContext()); DataType schema = newContext.getSchema(); if(!(schema instanceof ArrayType)){ return NativeClauseContext.NoNativeQuery; diff --git a/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java b/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java index a7a0bddb20..e23db67afe 100644 --- a/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java @@ -128,64 +128,64 @@ public static boolean doesItemTypeMatchItem(ItemType itemType, Item itemToMatch) if (itemType.equals(ItemType.item)) { return true; } - if (itemType.equals(ItemType.objectItem)) { + if (itemType.equals(AtomicItemType.objectItem)) { return itemToMatch.isObject(); } - if (itemType.equals(ItemType.atomicItem)) { + if (itemType.equals(AtomicItemType.atomicItem)) { return itemToMatch.isAtomic(); } - if (itemType.equals(ItemType.stringItem)) { + if (itemType.equals(AtomicItemType.stringItem)) { return itemToMatch.isString(); } - if (itemType.equals(ItemType.integerItem)) { + if (itemType.equals(AtomicItemType.integerItem)) { return itemToMatch.isInteger(); } - if (itemType.equals(ItemType.decimalItem)) { + if (itemType.equals(AtomicItemType.decimalItem)) { return itemToMatch.isDecimal(); } - if (itemType.equals(ItemType.doubleItem)) { + if (itemType.equals(AtomicItemType.doubleItem)) { return itemToMatch.isDouble(); } - if (itemType.equals(ItemType.booleanItem)) { + if (itemType.equals(AtomicItemType.booleanItem)) { return itemToMatch.isBoolean(); } - if (itemType.equals(ItemType.nullItem)) { + if (itemType.equals(AtomicItemType.nullItem)) { return itemToMatch.isNull(); } - if (itemType.equals(ItemType.arrayItem)) { + if (itemType.equals(AtomicItemType.arrayItem)) { return itemToMatch.isArray(); } - if (itemType.equals(ItemType.JSONItem)) { + if (itemType.equals(AtomicItemType.JSONItem)) { return itemToMatch.isObject() || itemToMatch.isArray(); } - if (itemType.equals(ItemType.durationItem)) { + if (itemType.equals(AtomicItemType.durationItem)) { return itemToMatch.isDuration(); } - if (itemType.equals(ItemType.yearMonthDurationItem)) { + if (itemType.equals(AtomicItemType.yearMonthDurationItem)) { return itemToMatch.isYearMonthDuration(); } - if (itemType.equals(ItemType.dayTimeDurationItem)) { + if (itemType.equals(AtomicItemType.dayTimeDurationItem)) { return itemToMatch.isDayTimeDuration(); } - if (itemType.equals(ItemType.dateTimeItem)) { + if (itemType.equals(AtomicItemType.dateTimeItem)) { return itemToMatch.isDateTime(); } - if (itemType.equals(ItemType.dateItem)) { + if (itemType.equals(AtomicItemType.dateItem)) { return itemToMatch.isDate(); } - if (itemType.equals(ItemType.timeItem)) { + if (itemType.equals(AtomicItemType.timeItem)) { return itemToMatch.isTime(); } - if (itemType.equals(ItemType.anyURIItem)) { + if (itemType.equals(AtomicItemType.anyURIItem)) { return itemToMatch.isAnyURI(); } - if (itemType.equals(ItemType.hexBinaryItem)) { + if (itemType.equals(AtomicItemType.hexBinaryItem)) { return itemToMatch.isHexBinary(); } - if (itemType.equals(ItemType.base64BinaryItem)) { + if (itemType.equals(AtomicItemType.base64BinaryItem)) { return itemToMatch.isBase64Binary(); } - if (itemType.equals(ItemType.functionItem)) { + if (itemType.isFunctionItem()) { return itemToMatch.isFunction(); } throw new OurBadException("Type unrecognized: " + itemType); From 9f7a5fede5f4786673785a59e507820a354ea41c Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 29 Dec 2020 12:48:54 +0100 Subject: [PATCH 116/206] passing all tests and spotless --- src/main/java/org/rumbledb/api/Item.java | 2 +- .../compiler/DynamicContextVisitor.java | 1 - .../rumbledb/compiler/InferTypeVisitor.java | 38 +++++++----- .../compiler/StaticContextVisitor.java | 1 - .../rumbledb/compiler/TranslationVisitor.java | 8 ++- .../config/RumbleRuntimeConfiguration.java | 2 +- .../quantifiers/QuantifiedExpressionVar.java | 1 - .../java/org/rumbledb/items/AnyURIItem.java | 4 +- .../java/org/rumbledb/items/ArrayItem.java | 4 +- .../org/rumbledb/items/Base64BinaryItem.java | 4 +- .../java/org/rumbledb/items/BooleanItem.java | 4 +- .../java/org/rumbledb/items/DateItem.java | 4 +- .../java/org/rumbledb/items/DateTimeItem.java | 4 +- .../rumbledb/items/DayTimeDurationItem.java | 4 +- .../java/org/rumbledb/items/DurationItem.java | 4 +- .../java/org/rumbledb/items/FunctionItem.java | 4 +- .../org/rumbledb/items/HexBinaryItem.java | 4 +- .../java/org/rumbledb/items/NullItem.java | 4 +- .../java/org/rumbledb/items/ObjectItem.java | 4 +- .../java/org/rumbledb/items/TimeItem.java | 4 +- .../org/rumbledb/runtime/RuntimeIterator.java | 5 +- .../runtime/flwor/FlworDataFrameUtils.java | 1 - .../runtime/flwor/NativeClauseContext.java | 11 ++-- .../flwor/clauses/ForClauseSparkIterator.java | 39 ++++++------ .../clauses/GroupByClauseSparkIterator.java | 53 +++++++++------- .../flwor/clauses/LetClauseSparkIterator.java | 5 +- .../clauses/OrderByClauseSparkIterator.java | 43 ++++++------- .../clauses/WhereClauseSparkIterator.java | 25 ++++---- .../udfs/OrderClauseCreateColumnsUDF.java | 1 - .../DayTimeDurationFunctionIterator.java | 1 - .../durations/DurationFunctionIterator.java | 1 - .../YearMonthDurationFunctionIterator.java | 1 - .../resources/AnyURIFunctionIterator.java | 1 - .../operational/AndOperationIterator.java | 8 ++- .../ComparisonOperationIterator.java | 30 +++++++--- .../operational/NotOperationIterator.java | 2 +- .../operational/OrOperationIterator.java | 2 +- .../operational/TypePromotionIterator.java | 1 - .../runtime/postfix/ArrayLookupIterator.java | 4 +- .../runtime/postfix/ObjectLookupIterator.java | 6 +- .../primary/StringRuntimeIterator.java | 1 - .../primary/VariableReferenceIterator.java | 15 ++--- .../runtime/typing/TreatIterator.java | 1 - .../org/rumbledb/types/AtomicItemType.java | 60 +++++++++---------- .../org/rumbledb/types/FunctionItemType.java | 16 ++--- .../org/rumbledb/types/FunctionSignature.java | 13 ++-- .../java/org/rumbledb/types/ItemType.java | 38 ++++++------ 47 files changed, 272 insertions(+), 217 deletions(-) diff --git a/src/main/java/org/rumbledb/api/Item.java b/src/main/java/org/rumbledb/api/Item.java index 0fb59092c6..7c033e79df 100644 --- a/src/main/java/org/rumbledb/api/Item.java +++ b/src/main/java/org/rumbledb/api/Item.java @@ -18,7 +18,6 @@ import org.rumbledb.expressions.comparison.ComparisonExpression; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.types.FunctionSignature; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import com.esotericsoftware.kryo.KryoSerializable; @@ -518,6 +517,7 @@ Item compareItem( /** * Get sparkSql string for the item + * * @return String representing the item in a sparksql query or null if it is not supported for the item */ String getSparkSqlQuery(); diff --git a/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java b/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java index 55754e1ad0..45c352f54e 100644 --- a/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java @@ -47,7 +47,6 @@ import org.rumbledb.runtime.functions.input.FileSystemUtil; import org.rumbledb.types.AtomicItemType; import org.rumbledb.runtime.typing.InstanceOfIterator; -import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 080b10d2e9..e6e6f98c85 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -268,7 +268,7 @@ public StaticContext visitContextExpr(ContextItemExpression expression, StaticCo public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression, StaticContext argument) { visitDescendants(expression, argument); SequenceType returnType = expression.getActualReturnType(); - if(returnType == null){ + if (returnType == null) { returnType = expression.getBody().getInferredSequenceType(); } List params = new ArrayList<>(expression.getParams().values()); @@ -278,7 +278,7 @@ public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression return argument; } - private FunctionSignature getSignature(FunctionIdentifier identifier, StaticContext staticContext){ + private FunctionSignature getSignature(FunctionIdentifier identifier, StaticContext staticContext) { BuiltinFunction function = null; FunctionSignature signature = null; try { @@ -549,7 +549,8 @@ public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticCont inferredType = leftItemType; } else if ( !expression.isMinus() - && (rightItemType.equals(AtomicItemType.dateTimeItem) || rightItemType.equals(AtomicItemType.dateItem)) + && (rightItemType.equals(AtomicItemType.dateTimeItem) + || rightItemType.equals(AtomicItemType.dateItem)) ) { inferredType = rightItemType; } @@ -658,7 +659,9 @@ public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression ) { inferredType = rightItemType; } - } else if (leftItemType.isSubtypeOf(AtomicItemType.durationItem) && !leftItemType.equals(AtomicItemType.durationItem)) { + } else if ( + leftItemType.isSubtypeOf(AtomicItemType.durationItem) && !leftItemType.equals(AtomicItemType.durationItem) + ) { if ( rightItemType.isNumeric() && (expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL @@ -860,7 +863,9 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static ItemType rightItemType = isRightEmpty ? leftInferredType.getItemType() : rightInferredType.getItemType(); // Type must be a strict subtype of atomic - if (leftItemType.isSubtypeOf(AtomicItemType.JSONItem) || rightItemType.isSubtypeOf(AtomicItemType.JSONItem)) { + if ( + leftItemType.isSubtypeOf(AtomicItemType.JSONItem) || rightItemType.isSubtypeOf(AtomicItemType.JSONItem) + ) { throw new UnexpectedStaticTypeException( "It is not possible to compare with non-atomic types", ErrorCode.NonAtomicElementErrorCode @@ -1356,13 +1361,13 @@ public StaticContext visitFilterExpression(FilterExpression expression, StaticCo } // return [true] if [types] are subtype of or can be promoted to expected types, [false] otherwise - public boolean checkArguments(List expectedTypes, List types){ + public boolean checkArguments(List expectedTypes, List types) { int length = expectedTypes.size(); - if(length != types.size()){ + if (length != types.size()) { return false; } - for(int i = 0; i < length; ++i){ - if(!types.get(i).isSubtypeOfOrCanBePromotedTo(expectedTypes.get(i))){ + for (int i = 0; i < length; ++i) { + if (!types.get(i).isSubtypeOfOrCanBePromotedTo(expectedTypes.get(i))) { return false; } } @@ -1382,10 +1387,10 @@ public StaticContext visitDynamicFunctionCallExpression( FunctionSignature signature = null; boolean isAnyFunction = false; - if(!mainType.isEmptySequence()){ + if (!mainType.isEmptySequence()) { ItemType type = mainType.getItemType(); - if(type.isFunctionItem()){ - if(type.equals(FunctionItemType.ANYFUNCTION)){ + if (type.isFunctionItem()) { + if (type.equals(FunctionItemType.ANYFUNCTION)) { isAnyFunction = true; } else { signature = type.getSignature(); @@ -1393,12 +1398,15 @@ public StaticContext visitDynamicFunctionCallExpression( } } - List argsType = expression.getArguments().stream().map(expr -> expr.getInferredSequenceType()).collect(Collectors.toList()); - if(isAnyFunction || (signature != null && checkArguments(signature.getParameterTypes(), argsType))){ + List argsType = expression.getArguments() + .stream() + .map(expr -> expr.getInferredSequenceType()) + .collect(Collectors.toList()); + if (isAnyFunction || (signature != null && checkArguments(signature.getParameterTypes(), argsType))) { // TODO: need to add support for partial application expression.setInferredSequenceType(signature.getReturnType()); System.out.println( - "visiting DynamicFunctionCall expression, type set to: " + expression.getInferredSequenceType() + "visiting DynamicFunctionCall expression, type set to: " + expression.getInferredSequenceType() ); return argument; } diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index 05292ba073..97fd890d54 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -55,7 +55,6 @@ import org.rumbledb.expressions.quantifiers.QuantifiedExpression; import org.rumbledb.expressions.quantifiers.QuantifiedExpressionVar; import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 88e58548f1..ae0300342a 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -1124,19 +1124,21 @@ public SequenceType processSequenceType(JsoniqParser.SequenceTypeContext ctx) { } ItemType itemType; JsoniqParser.FunctionTestContext fnCtx = ctx.item.functionTest(); - if(fnCtx == null){ + if (fnCtx == null) { // non-function item type itemType = ItemType.getItemTypeByName(ctx.item.getText()); } else { // function item type JsoniqParser.TypedFunctionTestContext typedFnCtx = fnCtx.typedFunctionTest(); - if(typedFnCtx == null){ + if (typedFnCtx == null) { // function(*) itemType = FunctionItemType.ANYFUNCTION; } else { // typed function SequenceType rt = processSequenceType(typedFnCtx.rt); - List st = typedFnCtx.st.stream().map(this::processSequenceType).collect(Collectors.toList()); + List st = typedFnCtx.st.stream() + .map(this::processSequenceType) + .collect(Collectors.toList()); FunctionSignature signature = new FunctionSignature(st, rt); itemType = new FunctionItemType(signature); } diff --git a/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java b/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java index 1c7ccff8c4..958d1c984b 100644 --- a/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java +++ b/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java @@ -297,7 +297,7 @@ public boolean doStaticAnalysis() { public boolean printInferredTypes() { return this.arguments.containsKey("print-inferred-types") - && this.arguments.get("print-inferred-types").equals("yes"); + && this.arguments.get("print-inferred-types").equals("yes"); } public boolean getDeactivateJsoniterStreaming() { diff --git a/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpressionVar.java b/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpressionVar.java index d71da364bb..d5f86dbdb5 100644 --- a/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpressionVar.java +++ b/src/main/java/org/rumbledb/expressions/quantifiers/QuantifiedExpressionVar.java @@ -22,7 +22,6 @@ import org.rumbledb.context.Name; import org.rumbledb.expressions.Expression; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/items/AnyURIItem.java b/src/main/java/org/rumbledb/items/AnyURIItem.java index ab56dede37..e3b546f1d8 100644 --- a/src/main/java/org/rumbledb/items/AnyURIItem.java +++ b/src/main/java/org/rumbledb/items/AnyURIItem.java @@ -143,5 +143,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/items/ArrayItem.java b/src/main/java/org/rumbledb/items/ArrayItem.java index 510e4b158d..0c2f6fdbe4 100644 --- a/src/main/java/org/rumbledb/items/ArrayItem.java +++ b/src/main/java/org/rumbledb/items/ArrayItem.java @@ -159,5 +159,7 @@ public boolean isCastableAs(ItemType itemType) { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/items/Base64BinaryItem.java b/src/main/java/org/rumbledb/items/Base64BinaryItem.java index 0d69240ba4..10be736ffe 100644 --- a/src/main/java/org/rumbledb/items/Base64BinaryItem.java +++ b/src/main/java/org/rumbledb/items/Base64BinaryItem.java @@ -208,5 +208,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/items/BooleanItem.java b/src/main/java/org/rumbledb/items/BooleanItem.java index f416dcf765..69bd84f7d3 100644 --- a/src/main/java/org/rumbledb/items/BooleanItem.java +++ b/src/main/java/org/rumbledb/items/BooleanItem.java @@ -157,5 +157,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/items/DateItem.java b/src/main/java/org/rumbledb/items/DateItem.java index 0040a7303d..259a80b687 100644 --- a/src/main/java/org/rumbledb/items/DateItem.java +++ b/src/main/java/org/rumbledb/items/DateItem.java @@ -200,5 +200,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/items/DateTimeItem.java b/src/main/java/org/rumbledb/items/DateTimeItem.java index fbc59f5ef2..95f4113d3e 100644 --- a/src/main/java/org/rumbledb/items/DateTimeItem.java +++ b/src/main/java/org/rumbledb/items/DateTimeItem.java @@ -322,5 +322,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/items/DayTimeDurationItem.java b/src/main/java/org/rumbledb/items/DayTimeDurationItem.java index a19299a71a..9220a7749d 100644 --- a/src/main/java/org/rumbledb/items/DayTimeDurationItem.java +++ b/src/main/java/org/rumbledb/items/DayTimeDurationItem.java @@ -135,5 +135,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/items/DurationItem.java b/src/main/java/org/rumbledb/items/DurationItem.java index 65f503c47b..fe7afe0771 100644 --- a/src/main/java/org/rumbledb/items/DurationItem.java +++ b/src/main/java/org/rumbledb/items/DurationItem.java @@ -309,5 +309,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/items/FunctionItem.java b/src/main/java/org/rumbledb/items/FunctionItem.java index 8d6ac4b2db..c9a5f423c2 100644 --- a/src/main/java/org/rumbledb/items/FunctionItem.java +++ b/src/main/java/org/rumbledb/items/FunctionItem.java @@ -341,5 +341,7 @@ public boolean isCastableAs(ItemType itemType) { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/items/HexBinaryItem.java b/src/main/java/org/rumbledb/items/HexBinaryItem.java index 090406c8c6..35203b3a22 100644 --- a/src/main/java/org/rumbledb/items/HexBinaryItem.java +++ b/src/main/java/org/rumbledb/items/HexBinaryItem.java @@ -202,5 +202,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/items/NullItem.java b/src/main/java/org/rumbledb/items/NullItem.java index eda5f32019..2dffa21700 100644 --- a/src/main/java/org/rumbledb/items/NullItem.java +++ b/src/main/java/org/rumbledb/items/NullItem.java @@ -122,5 +122,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/items/ObjectItem.java b/src/main/java/org/rumbledb/items/ObjectItem.java index 644548f6fa..d4cc13dcab 100644 --- a/src/main/java/org/rumbledb/items/ObjectItem.java +++ b/src/main/java/org/rumbledb/items/ObjectItem.java @@ -229,6 +229,8 @@ public boolean isCastableAs(ItemType itemType) { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/items/TimeItem.java b/src/main/java/org/rumbledb/items/TimeItem.java index 7dcc169ad2..ed32c8bcd9 100644 --- a/src/main/java/org/rumbledb/items/TimeItem.java +++ b/src/main/java/org/rumbledb/items/TimeItem.java @@ -198,5 +198,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { return null; } + public String getSparkSqlQuery() { + return null; + } } diff --git a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java index 7bc039e30f..e2b49718ed 100644 --- a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java @@ -27,7 +27,6 @@ import org.apache.spark.api.java.JavaRDD; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; -import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; import org.rumbledb.context.Name; @@ -36,7 +35,6 @@ import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.ItemType; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -379,7 +377,8 @@ public RuntimeIterator deepCopy() { /** * This function generate (if possible) a native spark-sql query that maps the inner working of the iterator * - * @return a native clause context with the spark-sql native query to get an equivalent result of the iterator, or [NativeClauseContext.NoNativeQuery] if + * @return a native clause context with the spark-sql native query to get an equivalent result of the iterator, or + * [NativeClauseContext.NoNativeQuery] if * it is not possible * @param nativeClauseContext context information to generate the native query */ diff --git a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java index 73b2c274a3..b6dd0ea624 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java +++ b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java @@ -54,7 +54,6 @@ import org.rumbledb.items.StringItem; import org.rumbledb.items.TimeItem; import org.rumbledb.items.YearMonthDurationItem; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java index 16e78f1810..f1e188160d 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java +++ b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java @@ -16,23 +16,24 @@ public class NativeClauseContext { private DynamicContext context; private String resultingQuery; - private NativeClauseContext() {} + private NativeClauseContext() { + } - public NativeClauseContext(FLWOR_CLAUSES clauseType, StructType schema, DynamicContext context){ + public NativeClauseContext(FLWOR_CLAUSES clauseType, StructType schema, DynamicContext context) { this.clauseType = clauseType; this.schema = schema; this.context = context; this.resultingQuery = ""; } - public NativeClauseContext(NativeClauseContext parent){ + public NativeClauseContext(NativeClauseContext parent) { this.clauseType = parent.clauseType; this.schema = parent.schema; this.context = parent.context; this.resultingQuery = parent.resultingQuery; } - public NativeClauseContext(NativeClauseContext parent, String newSelectPart){ + public NativeClauseContext(NativeClauseContext parent, String newSelectPart) { this.clauseType = parent.clauseType; this.schema = parent.schema; this.context = parent.context; @@ -43,7 +44,7 @@ public void setResultingQuery(String resultingQuery) { this.resultingQuery = resultingQuery; } - public String getResultingQuery(){ + public String getResultingQuery() { return this.resultingQuery; } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index 7b61ff8410..85f5a18ad7 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -866,14 +866,14 @@ private Dataset getDataFrameInParallel( // TODO: Useless because here is local for Dataset nativeQueryResult = tryNativeQuery( - df, - this.variableName, - this.positionalVariableName, - this.allowingEmpty, - this.assignmentIterator, - allColumns, - inputSchema, - context + df, + this.variableName, + this.positionalVariableName, + this.allowingEmpty, + this.assignmentIterator, + allColumns, + inputSchema, + context ); if (nativeQueryResult != null) { return nativeQueryResult; @@ -1211,11 +1211,12 @@ public static Dataset tryNativeQuery( StructType inputSchema, DynamicContext context ) { - // the try catch block is required because of the query that are not supported by sparksql like using a field to decide which field to use (e.g. $i.($i.fieldToUse) ) + // the try catch block is required because of the query that are not supported by sparksql like using a field to + // decide which field to use (e.g. $i.($i.fieldToUse) ) try { NativeClauseContext forContext = new NativeClauseContext(FLWOR_CLAUSES.FOR, inputSchema, context); NativeClauseContext nativeQuery = iterator.generateNativeQuery(forContext); - if(nativeQuery == NativeClauseContext.NoNativeQuery){ + if (nativeQuery == NativeClauseContext.NoNativeQuery) { return null; } System.out.println("native query returned " + nativeQuery.getResultingQuery()); @@ -1228,17 +1229,17 @@ public static Dataset tryNativeQuery( return null; } else { return dataFrame.sparkSession() - .sql( - String.format( - "select %s explode(%s) as `%s` from input", - selectSQL, - nativeQuery.getResultingQuery(), - newVariableName - ) - ); + .sql( + String.format( + "select %s explode(%s) as `%s` from input", + selectSQL, + nativeQuery.getResultingQuery(), + newVariableName + ) + ); } } else { - if(allowingEmpty) { + if (allowingEmpty) { return null; } else { return null; diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java index 81bdbfd23d..535f9d5155 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java @@ -306,11 +306,11 @@ public Dataset getDataFrame( df.createOrReplaceTempView("input"); Dataset nativeQueryResult = tryNativeQuery( - df, - variableAccessNames, - this.dependencies, - inputSchema, - context + df, + variableAccessNames, + this.dependencies, + inputSchema, + context ); if (nativeQueryResult != null) { return nativeQueryResult; @@ -477,7 +477,8 @@ public Map getProjection( } /** - * Try to generate the native query for the group by clause and run it, if successful return the resulting dataframe, + * Try to generate the native query for the group by clause and run it, if successful return the resulting + * dataframe, * otherwise it returns null (expect `input` table to be already available) * * @param dataFrame input dataframe for the query @@ -487,13 +488,19 @@ public Map getProjection( * @param context current dynamic context of the dataframe * @return resulting dataframe of the group by clause if successful, null otherwise */ - private Dataset tryNativeQuery(Dataset dataFrame, List groupingVariables, Map dependencies, StructType inputSchema, DynamicContext context) { - try{ + private Dataset tryNativeQuery( + Dataset dataFrame, + List groupingVariables, + Map dependencies, + StructType inputSchema, + DynamicContext context + ) { + try { StringBuilder groupByString = new StringBuilder(); String sep = " "; - for(Name groupingVar : groupingVariables){ + for (Name groupingVar : groupingVariables) { StructField field = inputSchema.fields()[inputSchema.fieldIndex(groupingVar.toString())]; - if(field.dataType().equals(DataTypes.BinaryType)){ + if (field.dataType().equals(DataTypes.BinaryType)) { // we got a non-native type for grouping, switch to udf version return null; } @@ -504,25 +511,25 @@ private Dataset tryNativeQuery(Dataset dataFrame, List groupingV } StringBuilder selectString = new StringBuilder(); sep = " "; - for(Map.Entry entry : dependencies.entrySet()){ + for (Map.Entry entry : dependencies.entrySet()) { selectString.append(sep); sep = ", "; // TODO: what about precomputed count - if(entry.getValue() == DynamicContext.VariableDependency.COUNT){ + if (entry.getValue() == DynamicContext.VariableDependency.COUNT) { // we need a count selectString.append("count(`"); selectString.append(entry.getKey().toString()); selectString.append("`) as `"); selectString.append(entry.getKey().toString()); selectString.append(".count`)"); - } else if(groupingVariables.contains(entry.getKey())){ + } else if (groupingVariables.contains(entry.getKey())) { // we are considering one of the grouping variables selectString.append(entry.getKey().toString()); } else { // we collect all the values, if it is a binary object we just switch over to udf String columnName = entry.getKey().toString(); StructField field = inputSchema.fields()[inputSchema.fieldIndex(columnName)]; - if(field.dataType().equals(DataTypes.BinaryType)){ + if (field.dataType().equals(DataTypes.BinaryType)) { return null; } selectString.append("collect_list(`"); @@ -532,16 +539,16 @@ private Dataset tryNativeQuery(Dataset dataFrame, List groupingV selectString.append("`"); } } - System.out.println("select part got returned: "+selectString); - System.out.println("groupby part got returned: "+groupByString); + System.out.println("select part got returned: " + selectString); + System.out.println("groupby part got returned: " + groupByString); return dataFrame.sparkSession() - .sql( - String.format( - "select %s from input group by %s", - selectString, - groupByString - ) - ); + .sql( + String.format( + "select %s from input group by %s", + selectString, + groupByString + ) + ); } catch (Exception e) { return null; } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index 5ea900bc3b..9eb364d6c9 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -630,11 +630,12 @@ public static Dataset tryNativeQuery( StructType inputSchema, DynamicContext context ) { - // the try catch block is required because of the query that are not supported by sparksql like using a field to decide which field to use (e.g. $i.($i.fieldToUse) ) + // the try catch block is required because of the query that are not supported by sparksql like using a field to + // decide which field to use (e.g. $i.($i.fieldToUse) ) try { NativeClauseContext letContext = new NativeClauseContext(FLWOR_CLAUSES.LET, inputSchema, context); NativeClauseContext nativeQuery = iterator.generateNativeQuery(letContext); - if(nativeQuery == NativeClauseContext.NoNativeQuery){ + if (nativeQuery == NativeClauseContext.NoNativeQuery) { return null; } System.out.println("native query returned " + nativeQuery.getResultingQuery()); diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index bcc9889b60..f7f9f4c217 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -38,7 +38,6 @@ import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.expressions.flowr.FLWOR_CLAUSES; -import org.rumbledb.expressions.flowr.OrderByClause; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.RuntimeTupleIterator; import org.rumbledb.runtime.flwor.FlworDataFrameUtils; @@ -47,7 +46,6 @@ import org.rumbledb.runtime.flwor.udfs.OrderClauseCreateColumnsUDF; import org.rumbledb.runtime.flwor.udfs.OrderClauseDetermineTypeUDF; import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.ItemType; import sparksoniq.jsoniq.tuple.FlworKey; import sparksoniq.jsoniq.tuple.FlworKeyComparator; @@ -251,11 +249,11 @@ public Dataset getDataFrame( ); Dataset nativeQueryResult = tryNativeQuery( - df, - this.expressionsWithIterator, - allColumns, - inputSchema, - context + df, + this.expressionsWithIterator, + allColumns, + inputSchema, + context ); if (nativeQueryResult != null) { return nativeQueryResult; @@ -300,7 +298,10 @@ public Dataset getDataFrame( for (int columnIndex = 0; columnIndex < columnsTypesOfRowAsList.size(); columnIndex++) { String columnType = (String) columnsTypesOfRowAsList.get(columnIndex); - if (!columnType.equals(StringFlagForEmptySequence) && !columnType.equals(AtomicItemType.nullItem.getName())) { + if ( + !columnType.equals(StringFlagForEmptySequence) + && !columnType.equals(AtomicItemType.nullItem.getName()) + ) { String currentColumnType = typesForAllColumns.get(columnIndex); if (currentColumnType == null) { typesForAllColumns.put(columnIndex, columnType); @@ -503,7 +504,8 @@ public Map getProjection( } /** - * Try to generate the native query for the order by clause and run it, if successful return the resulting dataframe, + * Try to generate the native query for the order by clause and run it, if successful return the resulting + * dataframe, * otherwise it returns null * * @param dataFrame input dataframe for the query @@ -520,21 +522,22 @@ public static Dataset tryNativeQuery( StructType inputSchema, DynamicContext context ) { - // the try catch block is required because of the query that are not supported by sparksql like using a field to decide which field to use (e.g. $i.($i.fieldToUse) ) + // the try catch block is required because of the query that are not supported by sparksql like using a field to + // decide which field to use (e.g. $i.($i.fieldToUse) ) try { NativeClauseContext orderContext = new NativeClauseContext(FLWOR_CLAUSES.ORDER_BY, inputSchema, context); StringBuilder orderSql = new StringBuilder(); String orderSeparator = ""; NativeClauseContext nativeQuery; - for(OrderByClauseAnnotatedChildIterator orderIterator : expressionsWithIterator){ + for (OrderByClauseAnnotatedChildIterator orderIterator : expressionsWithIterator) { nativeQuery = orderIterator.getIterator().generateNativeQuery(orderContext); - if(nativeQuery == NativeClauseContext.NoNativeQuery){ + if (nativeQuery == NativeClauseContext.NoNativeQuery) { return null; } orderSql.append(orderSeparator); orderSeparator = ", "; orderSql.append(nativeQuery.getResultingQuery()); - if(!orderIterator.isAscending()){ + if (!orderIterator.isAscending()) { orderSql.append(" desc"); } } @@ -543,13 +546,13 @@ public static Dataset tryNativeQuery( String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, false); dataFrame.createOrReplaceTempView("input"); return dataFrame.sparkSession() - .sql( - String.format( - "select %s from input order by %s", - selectSQL, - orderSql - ) - ); + .sql( + String.format( + "select %s from input order by %s", + selectSQL, + orderSql + ) + ); } catch (Exception e) { return null; } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java index f4b282113a..d72986f34d 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java @@ -204,10 +204,10 @@ public Dataset getDataFrame( StructType inputSchema = df.schema(); Dataset nativeQueryResult = tryNativeQuery( - df, - this.expression, - inputSchema, - context + df, + this.expression, + inputSchema, + context ); if (nativeQueryResult != null) { return nativeQueryResult; @@ -305,22 +305,23 @@ public static Dataset tryNativeQuery( StructType inputSchema, DynamicContext context ) { - // the try catch block is required because of the query that are not supported by sparksql like using a field to decide which field to use (e.g. $i.($i.fieldToUse) ) + // the try catch block is required because of the query that are not supported by sparksql like using a field to + // decide which field to use (e.g. $i.($i.fieldToUse) ) try { NativeClauseContext letContext = new NativeClauseContext(FLWOR_CLAUSES.WHERE, inputSchema, context); NativeClauseContext nativeQuery = iterator.generateNativeQuery(letContext); - if(nativeQuery == NativeClauseContext.NoNativeQuery){ + if (nativeQuery == NativeClauseContext.NoNativeQuery) { return null; } System.out.println("native query returned " + nativeQuery.getResultingQuery()); dataFrame.createOrReplaceTempView("input"); return dataFrame.sparkSession() - .sql( - String.format( - "select * from input where %s", - nativeQuery.getResultingQuery() - ) - ); + .sql( + String.format( + "select * from input where %s", + nativeQuery.getResultingQuery() + ) + ); } catch (Exception e) { return null; } diff --git a/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java b/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java index 7b424a9857..6f83602a71 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java +++ b/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java @@ -33,7 +33,6 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.expression.OrderByClauseAnnotatedChildIterator; import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.ItemType; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java index 0e3d83b00a..ce78afc04b 100644 --- a/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java @@ -12,7 +12,6 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.ItemType; import java.util.List; diff --git a/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java index 9234f79e55..0de803b8e7 100644 --- a/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java @@ -12,7 +12,6 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.ItemType; import java.util.List; diff --git a/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java index de5fc9da13..659eb19ca9 100644 --- a/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java @@ -12,7 +12,6 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.ItemType; import java.util.List; diff --git a/src/main/java/org/rumbledb/runtime/functions/resources/AnyURIFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/resources/AnyURIFunctionIterator.java index 6a86b3e952..6815e53d50 100644 --- a/src/main/java/org/rumbledb/runtime/functions/resources/AnyURIFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/resources/AnyURIFunctionIterator.java @@ -10,7 +10,6 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.ItemType; import java.util.List; diff --git a/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java index 32d54bd621..1c323fcd10 100644 --- a/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java @@ -79,11 +79,15 @@ public Item next() { public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext leftResult = this.leftIterator.generateNativeQuery(nativeClauseContext); NativeClauseContext rightResult = this.rightIterator.generateNativeQuery(nativeClauseContext); - if(leftResult == NativeClauseContext.NoNativeQuery || rightResult == NativeClauseContext.NoNativeQuery){ + if (leftResult == NativeClauseContext.NoNativeQuery || rightResult == NativeClauseContext.NoNativeQuery) { return NativeClauseContext.NoNativeQuery; } - String resultingQuery = "( " + leftResult.getResultingQuery() + " AND " + rightResult.getResultingQuery() + " )"; + String resultingQuery = "( " + + leftResult.getResultingQuery() + + " AND " + + rightResult.getResultingQuery() + + " )"; return new NativeClauseContext(nativeClauseContext, resultingQuery); } } diff --git a/src/main/java/org/rumbledb/runtime/operational/ComparisonOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/ComparisonOperationIterator.java index 46f43de22f..b4f22947cb 100644 --- a/src/main/java/org/rumbledb/runtime/operational/ComparisonOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/ComparisonOperationIterator.java @@ -187,22 +187,34 @@ private Item comparePair(Item left, Item right) { @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - if(this.comparisonOperator.isValueComparison()){ + if (this.comparisonOperator.isValueComparison()) { NativeClauseContext leftResult = this.leftIterator.generateNativeQuery(nativeClauseContext); NativeClauseContext rightResult = this.rightIterator.generateNativeQuery(nativeClauseContext); - if(leftResult == NativeClauseContext.NoNativeQuery || rightResult == NativeClauseContext.NoNativeQuery){ + if (leftResult == NativeClauseContext.NoNativeQuery || rightResult == NativeClauseContext.NoNativeQuery) { return NativeClauseContext.NoNativeQuery; } String operator = " = "; - switch (this.comparisonOperator.name()){ - case "eq": operator = " = "; break; - case "ne": operator = " <> "; break; - case "le": operator = " <= "; break; - case "lt": operator = " < "; break; - case "ge": operator = " >= "; break; - case "gt": operator = " > "; break; + switch (this.comparisonOperator.name()) { + case "eq": + operator = " = "; + break; + case "ne": + operator = " <> "; + break; + case "le": + operator = " <= "; + break; + case "lt": + operator = " < "; + break; + case "ge": + operator = " >= "; + break; + case "gt": + operator = " > "; + break; } String query = "( " + leftResult.getResultingQuery() + operator + rightResult.getResultingQuery() + " )"; return new NativeClauseContext(nativeClauseContext, query); diff --git a/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java index 7429184d13..9f196c9060 100644 --- a/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java @@ -56,7 +56,7 @@ public Item next() { @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext childResult = this.child.generateNativeQuery(nativeClauseContext); - if(childResult == NativeClauseContext.NoNativeQuery){ + if (childResult == NativeClauseContext.NoNativeQuery) { return NativeClauseContext.NoNativeQuery; } diff --git a/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java index 1b82e10611..6a87d8aa15 100644 --- a/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java @@ -66,7 +66,7 @@ public Item next() { public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext leftResult = this.leftIterator.generateNativeQuery(nativeClauseContext); NativeClauseContext rightResult = this.rightIterator.generateNativeQuery(nativeClauseContext); - if(leftResult == NativeClauseContext.NoNativeQuery || rightResult == NativeClauseContext.NoNativeQuery){ + if (leftResult == NativeClauseContext.NoNativeQuery || rightResult == NativeClauseContext.NoNativeQuery) { return NativeClauseContext.NoNativeQuery; } diff --git a/src/main/java/org/rumbledb/runtime/operational/TypePromotionIterator.java b/src/main/java/org/rumbledb/runtime/operational/TypePromotionIterator.java index 7d040bb472..7503e50972 100644 --- a/src/main/java/org/rumbledb/runtime/operational/TypePromotionIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/TypePromotionIterator.java @@ -11,7 +11,6 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.ExecutionMode; -import org.rumbledb.items.AtomicItem; import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.sequences.general.TypePromotionClosure; diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java index 102da70b34..8952fd1eed 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java @@ -164,10 +164,10 @@ public boolean implementsDataFrames() { @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); - if(newContext != NativeClauseContext.NoNativeQuery){ + if (newContext != NativeClauseContext.NoNativeQuery) { initLookupPosition(newContext.getContext()); DataType schema = newContext.getSchema(); - if(!(schema instanceof ArrayType)){ + if (!(schema instanceof ArrayType)) { return NativeClauseContext.NoNativeQuery; } ArrayType arraySchema = (ArrayType) schema; diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index 716cccad78..2a1529cc63 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -220,15 +220,15 @@ public boolean implementsDataFrames() { @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); - if(newContext != NativeClauseContext.NoNativeQuery){ + if (newContext != NativeClauseContext.NoNativeQuery) { initLookupKey(newContext.getContext()); String key = this.lookupKey.getStringValue(); DataType schema = newContext.getSchema(); - if(!(schema instanceof StructType)){ + if (!(schema instanceof StructType)) { return NativeClauseContext.NoNativeQuery; } StructType structSchema = (StructType) schema; - if(Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(key))){ + if (Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(key))) { newContext.setResultingQuery(newContext.getResultingQuery() + "." + key); StructField field = structSchema.fields()[structSchema.fieldIndex(key)]; newContext.setSchema(field.dataType()); diff --git a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java index 1bd5f75409..959acea780 100644 --- a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java @@ -21,7 +21,6 @@ package org.rumbledb.runtime.primary; import org.apache.commons.text.StringEscapeUtils; -import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; import org.rumbledb.exceptions.ExceptionMetadata; diff --git a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java index bfa5cc87ff..27e1868904 100644 --- a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java @@ -20,7 +20,6 @@ package org.rumbledb.runtime.primary; -import org.apache.commons.lang3.ArrayUtils; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; @@ -87,28 +86,30 @@ protected boolean hasNextLocal() { public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { String name = this.variableName.toString(); DataType schema = nativeClauseContext.getSchema(); - if(!(schema instanceof StructType)){ + if (!(schema instanceof StructType)) { return NativeClauseContext.NoNativeQuery; } // check if name is in the schema StructType structSchema = (StructType) schema; - if(Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(name))){ + if (Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(name))) { NativeClauseContext newContext = new NativeClauseContext(nativeClauseContext, name); StructField field = structSchema.fields()[structSchema.fieldIndex(name)]; DataType fieldType = field.dataType(); - if(fieldType.typeName().equals("binary")){ + if (fieldType.typeName().equals("binary")) { return NativeClauseContext.NoNativeQuery; } newContext.setSchema(fieldType); return newContext; } else { - List items = nativeClauseContext.getContext().getVariableValues().getLocalVariableValue(this.variableName, getMetadata()); - if(items.size() != 1) { + List items = nativeClauseContext.getContext() + .getVariableValues() + .getLocalVariableValue(this.variableName, getMetadata()); + if (items.size() != 1) { // only possible to turn into native, sequence of length 1 return NativeClauseContext.NoNativeQuery; } String itemQuery = items.get(0).getSparkSqlQuery(); - if(itemQuery == null){ + if (itemQuery == null) { return NativeClauseContext.NoNativeQuery; } return new NativeClauseContext(nativeClauseContext, itemQuery); diff --git a/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java b/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java index 3ed7daad31..b0b6b858e7 100644 --- a/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/TreatIterator.java @@ -20,7 +20,6 @@ import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.sequences.general.TreatAsClosure; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 2c4c4de13e..8e1ef14215 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -39,29 +39,29 @@ public boolean isSubtypeOf(ItemType superType) { return true; } else if (superType.equals(JSONItem)) { return this.equals(objectItem) - || this.equals(arrayItem) - || this.equals(JSONItem); + || this.equals(arrayItem) + || this.equals(JSONItem); } else if (superType.equals(atomicItem)) { return this.equals(stringItem) - || this.equals(integerItem) - || this.equals(decimalItem) - || this.equals(doubleItem) - || this.equals(booleanItem) - || this.equals(nullItem) - || this.equals(anyURIItem) - || this.equals(hexBinaryItem) - || this.equals(base64BinaryItem) - || this.equals(dateTimeItem) - || this.equals(dateItem) - || this.equals(timeItem) - || this.equals(durationItem) - || this.equals(yearMonthDurationItem) - || this.equals(dayTimeDurationItem) - || this.equals(atomicItem); + || this.equals(integerItem) + || this.equals(decimalItem) + || this.equals(doubleItem) + || this.equals(booleanItem) + || this.equals(nullItem) + || this.equals(anyURIItem) + || this.equals(hexBinaryItem) + || this.equals(base64BinaryItem) + || this.equals(dateTimeItem) + || this.equals(dateItem) + || this.equals(timeItem) + || this.equals(durationItem) + || this.equals(yearMonthDurationItem) + || this.equals(dayTimeDurationItem) + || this.equals(atomicItem); } else if (superType.equals(durationItem)) { return this.equals(yearMonthDurationItem) - || this.equals(dayTimeDurationItem) - || this.equals(durationItem); + || this.equals(dayTimeDurationItem) + || this.equals(durationItem); } else if (superType.equals(decimalItem)) { return this.equals(integerItem) || this.equals(decimalItem); } @@ -95,16 +95,16 @@ public boolean staticallyCastableAs(ItemType other) { return true; // boolean and numeric can be cast between themselves if ( - this.equals(booleanItem) || this.equals(integerItem) || this.equals(doubleItem) || this.equals(decimalItem) + this.equals(booleanItem) || this.equals(integerItem) || this.equals(doubleItem) || this.equals(decimalItem) ) { if ( - other.equals(integerItem) - || - other.equals(doubleItem) - || - other.equals(decimalItem) - || - other.equals(booleanItem) + other.equals(integerItem) + || + other.equals(doubleItem) + || + other.equals(decimalItem) + || + other.equals(booleanItem) ) return true; else @@ -113,9 +113,9 @@ public boolean staticallyCastableAs(ItemType other) { // base64 and hex can be cast between themselves if (this.equals(base64BinaryItem) || this.equals(hexBinaryItem)) { if ( - other.equals(base64BinaryItem) - || - other.equals(hexBinaryItem) + other.equals(base64BinaryItem) + || + other.equals(hexBinaryItem) ) return true; else diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index d05a6fa9d6..b3c990c633 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -8,8 +8,8 @@ public class FunctionItemType extends ItemType { private FunctionSignature signature; public static FunctionItemType ANYFUNCTION = new FunctionItemType(true); - public FunctionItemType(FunctionSignature signature){ - if(signature == null){ + public FunctionItemType(FunctionSignature signature) { + if (signature == null) { throw new OurBadException("a new function item type must have a signature"); } this.isGeneric = false; @@ -18,7 +18,7 @@ public FunctionItemType(FunctionSignature signature){ } // we have a parameter because the empty one is public and inherited - private FunctionItemType(boolean isGeneric){ + private FunctionItemType(boolean isGeneric) { this.isGeneric = true; this.signature = null; this.name = "function(*)"; @@ -36,7 +36,7 @@ public FunctionSignature getSignature() { @Override public boolean equals(Object other) { - if(!(other instanceof ItemType)){ + if (!(other instanceof ItemType)) { return false; } return this.name.equals(other.toString()); @@ -44,10 +44,10 @@ public boolean equals(Object other) { @Override public boolean isSubtypeOf(ItemType superType) { - if(this.equals(superType) || superType.equals(ANYFUNCTION) || superType.equals(ItemType.item)){ + if (this.equals(superType) || superType.equals(ANYFUNCTION) || superType.equals(ItemType.item)) { return true; } - if(superType.isFunctionItem() && this.signature.isSubtypeOf(superType.getSignature())){ + if (superType.isFunctionItem() && this.signature.isSubtypeOf(superType.getSignature())) { return true; } return false; @@ -55,10 +55,10 @@ public boolean isSubtypeOf(ItemType superType) { @Override public ItemType findCommonSuperType(ItemType other) { - if(this.equals(other)){ + if (this.equals(other)) { return this; } - if(other.isFunctionItem()){ + if (other.isFunctionItem()) { return ANYFUNCTION; } return ItemType.item; diff --git a/src/main/java/org/rumbledb/types/FunctionSignature.java b/src/main/java/org/rumbledb/types/FunctionSignature.java index 1b9421512f..be9defb075 100644 --- a/src/main/java/org/rumbledb/types/FunctionSignature.java +++ b/src/main/java/org/rumbledb/types/FunctionSignature.java @@ -52,20 +52,21 @@ public boolean equals(Object instance) { && this.getReturnType() == ((FunctionSignature) instance).getReturnType(); } - public boolean isSubtypeOf(FunctionSignature other){ - // a signature is a subtype of another signature if it always respect its contract typewise (i.e. no static type errors) + public boolean isSubtypeOf(FunctionSignature other) { + // a signature is a subtype of another signature if it always respect its contract typewise (i.e. no static type + // errors) // this return type must be a subtype of other return type - if(!this.returnType.isSubtypeOf(other.returnType)){ + if (!this.returnType.isSubtypeOf(other.returnType)) { return false; } int paramsLength = this.parameterTypes.size(); // must have same number of parameters - if(paramsLength != other.parameterTypes.size()){ + if (paramsLength != other.parameterTypes.size()) { return false; } - for(int i = 0; i < paramsLength; ++i){ + for (int i = 0; i < paramsLength; ++i) { // any parameter type of other must be a subtype of the corresponding parameter of this - if(!other.parameterTypes.get(i).isSubtypeOf(this.parameterTypes.get(i))){ + if (!other.parameterTypes.get(i).isSubtypeOf(this.parameterTypes.get(i))) { return false; } } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 3cd02e17be..2fba43a658 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -28,61 +28,61 @@ public class ItemType implements Serializable { public static ItemType getItemTypeByName(String name) { - if (name.equals(AtomicItemType.objectItem.getName())) { + if (name.equals(AtomicItemType.objectItem.getName())) { return AtomicItemType.objectItem; } - if (name.equals(AtomicItemType.atomicItem.getName())) { + if (name.equals(AtomicItemType.atomicItem.getName())) { return AtomicItemType.atomicItem; } - if (name.equals(AtomicItemType.stringItem.getName())) { + if (name.equals(AtomicItemType.stringItem.getName())) { return AtomicItemType.stringItem; } - if (name.equals(AtomicItemType.integerItem.getName())) { + if (name.equals(AtomicItemType.integerItem.getName())) { return AtomicItemType.integerItem; } - if (name.equals(AtomicItemType.decimalItem.getName())) { + if (name.equals(AtomicItemType.decimalItem.getName())) { return AtomicItemType.decimalItem; } - if (name.equals(AtomicItemType.doubleItem.getName())) { + if (name.equals(AtomicItemType.doubleItem.getName())) { return AtomicItemType.doubleItem; } - if (name.equals(AtomicItemType.booleanItem.getName())) { + if (name.equals(AtomicItemType.booleanItem.getName())) { return AtomicItemType.booleanItem; } - if (name.equals(AtomicItemType.nullItem.getName())) { + if (name.equals(AtomicItemType.nullItem.getName())) { return AtomicItemType.nullItem; } - if (name.equals(AtomicItemType.arrayItem.getName())) { + if (name.equals(AtomicItemType.arrayItem.getName())) { return AtomicItemType.arrayItem; } - if (name.equals(AtomicItemType.JSONItem.getName())) { + if (name.equals(AtomicItemType.JSONItem.getName())) { return AtomicItemType.JSONItem; } - if (name.equals(AtomicItemType.durationItem.getName())) { + if (name.equals(AtomicItemType.durationItem.getName())) { return AtomicItemType.durationItem; } - if (name.equals(AtomicItemType.yearMonthDurationItem.getName())) { + if (name.equals(AtomicItemType.yearMonthDurationItem.getName())) { return AtomicItemType.yearMonthDurationItem; } - if (name.equals(AtomicItemType.dayTimeDurationItem.getName())) { + if (name.equals(AtomicItemType.dayTimeDurationItem.getName())) { return AtomicItemType.dayTimeDurationItem; } - if (name.equals(AtomicItemType.dateTimeItem.getName())) { + if (name.equals(AtomicItemType.dateTimeItem.getName())) { return AtomicItemType.dateTimeItem; } - if (name.equals(AtomicItemType.dateItem.getName())) { + if (name.equals(AtomicItemType.dateItem.getName())) { return AtomicItemType.dateItem; } - if (name.equals(AtomicItemType.timeItem.getName())) { + if (name.equals(AtomicItemType.timeItem.getName())) { return AtomicItemType.timeItem; } - if (name.equals(AtomicItemType.anyURIItem.getName())) { + if (name.equals(AtomicItemType.anyURIItem.getName())) { return AtomicItemType.anyURIItem; } - if (name.equals(AtomicItemType.hexBinaryItem.getName())) { + if (name.equals(AtomicItemType.hexBinaryItem.getName())) { return AtomicItemType.hexBinaryItem; } - if (name.equals(AtomicItemType.base64BinaryItem.getName())) { + if (name.equals(AtomicItemType.base64BinaryItem.getName())) { return AtomicItemType.base64BinaryItem; } if (name.equals(item.name)) { From 440dffa221f6ff28505365ca503d5bdef599c9a6 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 29 Dec 2020 14:49:59 +0100 Subject: [PATCH 117/206] corrected group by behaviour --- .../runtime/flwor/clauses/GroupByClauseSparkIterator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java index 535f9d5155..86ac094518 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java @@ -308,7 +308,7 @@ public Dataset getDataFrame( Dataset nativeQueryResult = tryNativeQuery( df, variableAccessNames, - this.dependencies, + parentProjection, inputSchema, context ); @@ -521,7 +521,7 @@ private Dataset tryNativeQuery( selectString.append(entry.getKey().toString()); selectString.append("`) as `"); selectString.append(entry.getKey().toString()); - selectString.append(".count`)"); + selectString.append(".count`"); } else if (groupingVariables.contains(entry.getKey())) { // we are considering one of the grouping variables selectString.append(entry.getKey().toString()); From 5b87ef42ea6dd1a288f2311e2fac8a33db8f8658 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 30 Dec 2020 12:45:58 +0100 Subject: [PATCH 118/206] added and tested for clause without allowing empty, no positional variable, added support for at most one unboxing operation, anywhere in the expression --- .../runtime/flwor/NativeClauseContext.java | 14 ++++++++ .../flwor/clauses/ForClauseSparkIterator.java | 36 +++++++++++++------ .../postfix/ArrayUnboxingIterator.java | 22 ++++++++++++ 3 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java index f1e188160d..768719efc7 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java +++ b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java @@ -15,6 +15,7 @@ public class NativeClauseContext { private DataType schema; private DynamicContext context; private String resultingQuery; + private String lateralViewPart; // used in array unboxing to generate the correct lateral view private NativeClauseContext() { } @@ -24,6 +25,7 @@ public NativeClauseContext(FLWOR_CLAUSES clauseType, StructType schema, DynamicC this.schema = schema; this.context = context; this.resultingQuery = ""; + this.lateralViewPart = ""; } public NativeClauseContext(NativeClauseContext parent) { @@ -40,6 +42,10 @@ public NativeClauseContext(NativeClauseContext parent, String newSelectPart) { this.resultingQuery = newSelectPart; } + public FLWOR_CLAUSES getClauseType() { + return this.clauseType; + } + public void setResultingQuery(String resultingQuery) { this.resultingQuery = resultingQuery; } @@ -59,4 +65,12 @@ public void setSchema(DataType schema) { public DynamicContext getContext() { return this.context; } + + public String getLateralViewPart() { + return this.lateralViewPart; + } + + public void setLateralViewPart(String lateralViewPart) { + this.lateralViewPart = lateralViewPart; + } } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index 85f5a18ad7..fce41016ed 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -864,7 +864,6 @@ private Dataset getDataFrameInParallel( variableNamesToExclude ); - // TODO: Useless because here is local for Dataset nativeQueryResult = tryNativeQuery( df, this.variableName, @@ -1220,6 +1219,7 @@ public static Dataset tryNativeQuery( return null; } System.out.println("native query returned " + nativeQuery.getResultingQuery()); + System.out.println("lateral view part is " + nativeQuery.getLateralViewPart()); String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); dataFrame.createOrReplaceTempView("input"); @@ -1228,15 +1228,31 @@ public static Dataset tryNativeQuery( if (allowingEmpty) { return null; } else { - return dataFrame.sparkSession() - .sql( - String.format( - "select %s explode(%s) as `%s` from input", - selectSQL, - nativeQuery.getResultingQuery(), - newVariableName - ) - ); + if(nativeQuery.getLateralViewPart().equals("")){ + // no array unboxing in the operation + return dataFrame.sparkSession() + .sql( + String.format( + "select %s %s as `%s` from input", + selectSQL, + nativeQuery.getResultingQuery(), + newVariableName + ) + ); + } else { + // we have at least an array unboxing operation + // col is the default name of explode + return dataFrame.sparkSession() + .sql( + String.format( + "select %s arr1.col%s as `%s` from input lateral view %s arr1", + selectSQL, + nativeQuery.getResultingQuery(), + newVariableName, + nativeQuery.getLateralViewPart() + ) + ); + } } } else { if (allowingEmpty) { diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java index 2a04287a77..7f36b855ff 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java @@ -33,9 +33,11 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.expressions.ExecutionMode; +import org.rumbledb.expressions.flowr.FLWOR_CLAUSES; import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; import sparksoniq.spark.SparkSessionManager; import java.util.Arrays; @@ -126,6 +128,26 @@ public boolean implementsDataFrames() { return true; } + @Override + public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { + if(nativeClauseContext.getClauseType() != FLWOR_CLAUSES.FOR){ + // unboxing only available for the FOR clause + return NativeClauseContext.NoNativeQuery; + } + NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); + if(newContext != NativeClauseContext.NoNativeQuery){ + DataType schema = newContext.getSchema(); + if (!(schema instanceof ArrayType)) { + // let control to UDF when what we are unboxing is not an array + return NativeClauseContext.NoNativeQuery; + } + newContext.setSchema(((ArrayType) schema).elementType()); + newContext.setLateralViewPart("explode(" + newContext.getResultingQuery() + ")"); + newContext.setResultingQuery(""); // dealt by for clause + } + return newContext; + } + public Dataset getDataFrame(DynamicContext context) { Dataset childDataFrame = this.children.get(0).getDataFrame(context); childDataFrame.createOrReplaceTempView("array"); From fe44d93552b076c857a552d7f2c18074cd674663 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 30 Dec 2020 13:52:56 +0100 Subject: [PATCH 119/206] added support for nested unboxing operations --- .../runtime/flwor/NativeClauseContext.java | 15 ++++++++------- .../flwor/clauses/ForClauseSparkIterator.java | 17 ++++++++++++++--- .../runtime/postfix/ArrayUnboxingIterator.java | 9 ++++++++- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java index 768719efc7..5afdb5dbba 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java +++ b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java @@ -5,6 +5,9 @@ import org.rumbledb.context.DynamicContext; import org.rumbledb.expressions.flowr.FLWOR_CLAUSES; +import java.util.ArrayList; +import java.util.List; + /** * This class describes the context of a native clause and is used when processing FLWOR expressions without UDF */ @@ -15,7 +18,7 @@ public class NativeClauseContext { private DataType schema; private DynamicContext context; private String resultingQuery; - private String lateralViewPart; // used in array unboxing to generate the correct lateral view + private List lateralViewPart; // used in array unboxing to generate the correct lateral view private NativeClauseContext() { } @@ -25,7 +28,7 @@ public NativeClauseContext(FLWOR_CLAUSES clauseType, StructType schema, DynamicC this.schema = schema; this.context = context; this.resultingQuery = ""; - this.lateralViewPart = ""; + this.lateralViewPart = new ArrayList<>(); } public NativeClauseContext(NativeClauseContext parent) { @@ -33,6 +36,7 @@ public NativeClauseContext(NativeClauseContext parent) { this.schema = parent.schema; this.context = parent.context; this.resultingQuery = parent.resultingQuery; + this.lateralViewPart = parent.lateralViewPart; } public NativeClauseContext(NativeClauseContext parent, String newSelectPart) { @@ -40,6 +44,7 @@ public NativeClauseContext(NativeClauseContext parent, String newSelectPart) { this.schema = parent.schema; this.context = parent.context; this.resultingQuery = newSelectPart; + this.lateralViewPart = parent.lateralViewPart; } public FLWOR_CLAUSES getClauseType() { @@ -66,11 +71,7 @@ public DynamicContext getContext() { return this.context; } - public String getLateralViewPart() { + public List getLateralViewPart() { return this.lateralViewPart; } - - public void setLateralViewPart(String lateralViewPart) { - this.lateralViewPart = lateralViewPart; - } } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index fce41016ed..0174bfcd5f 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -1228,7 +1228,8 @@ public static Dataset tryNativeQuery( if (allowingEmpty) { return null; } else { - if(nativeQuery.getLateralViewPart().equals("")){ + List lateralViewPart = nativeQuery.getLateralViewPart(); + if(lateralViewPart.size() == 0){ // no array unboxing in the operation return dataFrame.sparkSession() .sql( @@ -1242,14 +1243,24 @@ public static Dataset tryNativeQuery( } else { // we have at least an array unboxing operation // col is the default name of explode + StringBuilder lateralViewString = new StringBuilder(); + int arrIndex = 0; + for(String lateralView : lateralViewPart){ + ++arrIndex; + lateralViewString.append(" lateral view "); + lateralViewString.append(lateralView); + lateralViewString.append(" arr"); + lateralViewString.append(arrIndex); + } return dataFrame.sparkSession() .sql( String.format( - "select %s arr1.col%s as `%s` from input lateral view %s arr1", + "select %s arr%d.col%s as `%s` from input %s", selectSQL, + arrIndex, nativeQuery.getResultingQuery(), newVariableName, - nativeQuery.getLateralViewPart() + lateralViewString ) ); } diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java index 7f36b855ff..62d2a097f9 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java @@ -42,6 +42,7 @@ import java.util.Arrays; import java.util.LinkedList; +import java.util.List; import java.util.Queue; public class ArrayUnboxingIterator extends HybridRuntimeIterator { @@ -142,7 +143,13 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC return NativeClauseContext.NoNativeQuery; } newContext.setSchema(((ArrayType) schema).elementType()); - newContext.setLateralViewPart("explode(" + newContext.getResultingQuery() + ")"); + List lateralViewPart = newContext.getLateralViewPart(); + if(lateralViewPart.size() == 0){ + lateralViewPart.add("explode(" + newContext.getResultingQuery() + ")"); + } else { + // if we have multiple array unboxing we stack multiple lateral views and each one takes from the previous + lateralViewPart.add("explode( arr"+ lateralViewPart.size() + ".col" + newContext.getResultingQuery() + ")"); + } newContext.setResultingQuery(""); // dealt by for clause } return newContext; From 0bc4149e4bc0f1501b33ef67697ff7fe7e468073 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sat, 2 Jan 2021 12:57:12 +0100 Subject: [PATCH 120/206] added support for native allowing empty --- .../flwor/clauses/ForClauseSparkIterator.java | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index 0174bfcd5f..a98a8825a5 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -1226,7 +1226,57 @@ public static Dataset tryNativeQuery( // let's distinguish 4 cases if (positionalVariableName == null) { if (allowingEmpty) { - return null; + List lateralViewPart = nativeQuery.getLateralViewPart(); + if(lateralViewPart.size() == 0){ + // no array unboxing in the operation + // already covered in the generation and handled through UDF + // this branch should never happen in practice + return null; + } else { + // we have at least an array unboxing operation + // col is the default name of explode + + // to deal with allowing empty + // first we add an artificial unique id to the dataset and re-register the input table + String rowIdField = "idx-9384-3948-1272-4375"; + dataFrame = dataFrame.sparkSession().sql("select *, monotonically_increasing_id() as `" + rowIdField + "` from input"); + dataFrame.createOrReplaceTempView("input"); + + // then we create the virtual exploded table as before + // but this time we store it and also get the index field + StringBuilder lateralViewString = new StringBuilder(); + int arrIndex = 0; + for(String lateralView : lateralViewPart){ + ++arrIndex; + lateralViewString.append(" lateral view "); + lateralViewString.append(lateralView); + lateralViewString.append(" arr"); + lateralViewString.append(arrIndex); + } + Dataset lateralViewDf = dataFrame.sparkSession() + .sql( + String.format( + "select `%s`, arr%d.col%s as `%s` from input %s", + rowIdField, + arrIndex, + nativeQuery.getResultingQuery(), + newVariableName, + lateralViewString + ) + ); + lateralViewDf.createOrReplaceTempView("lateral"); + + // to return the correct number of empty results we perform a left join between input and lateral + return dataFrame.sparkSession().sql( + String.format( + "select %s lateral.`%s` from input left join lateral on input.`%s` = lateral.`%s`", + selectSQL, + newVariableName, + rowIdField, + rowIdField + ) + ); + } } else { List lateralViewPart = nativeQuery.getLateralViewPart(); if(lateralViewPart.size() == 0){ From 9f476c4d6d231179cd3979ed5eac800240eaece2 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sat, 2 Jan 2021 17:04:58 +0100 Subject: [PATCH 121/206] added support for positional variables in native clause both allowing or not allowing empty --- .../flwor/clauses/ForClauseSparkIterator.java | 99 ++++++++++++++++++- 1 file changed, 96 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index a98a8825a5..279398b3d0 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -1316,10 +1316,103 @@ public static Dataset tryNativeQuery( } } } else { - if (allowingEmpty) { - return null; + // common part for positional variable handling + List lateralViewPart = nativeQuery.getLateralViewPart(); + if(lateralViewPart.size() == 0){ + // if allowing empty we do not deal with this + if(allowingEmpty){ + return null; + } + // no array unboxing in the operation + // therefore position is for sure 1 + return dataFrame.sparkSession() + .sql( + String.format( + "select %s %s as `%s`, 1 as `%s` from input", + selectSQL, + nativeQuery.getResultingQuery(), + newVariableName, + positionalVariableName + ) + ); } else { - return null; + // we have at least an array unboxing operation + // pos, col are the default name of posexplode function + // to deal with positional variable + // we first add unique index to guarantee grouping correctly + String rowIdField = "idx-9384-3948-1272-4375"; + dataFrame = dataFrame.sparkSession().sql("select *, monotonically_increasing_id() as `" + rowIdField + "` from input"); + dataFrame.createOrReplaceTempView("input"); + + // then we collect all values from lateral view + // and group by original tuple + // this is basically equivalent to flattening the array, in case of multiple unboxing operation + StringBuilder lateralViewString = new StringBuilder(); + int arrIndex = 0; + for(String lateralView : lateralViewPart){ + ++arrIndex; + lateralViewString.append(" lateral view "); + lateralViewString.append(lateralView); + lateralViewString.append(" arr"); + lateralViewString.append(arrIndex); + } + dataFrame = dataFrame.sparkSession() + .sql( + String.format( + "select `%s`, %s collect_list(arr%d.col%s) as grouped from input %s group by %s `%s`", + rowIdField, + selectSQL, + arrIndex, + nativeQuery.getResultingQuery(), + lateralViewString, + selectSQL, + rowIdField + ) + ); + + + if (allowingEmpty) { + // register a support table to keep the empty values + dataFrame.sparkSession().sql("select `" + rowIdField + "` from input").createOrReplaceTempView("allrows"); + + // register previously created table + dataFrame.createOrReplaceTempView("input"); + + // insert null values + dataFrame = dataFrame.sparkSession().sql(String.format( + "select allrows.`%s`, %s grouped from allrows left join input on allrows.`%s` = input.`%s`", + rowIdField, + selectSQL, + rowIdField, + rowIdField + )); + dataFrame.createOrReplaceTempView("input"); + + // we use a lateral view to handle proper counting and NULL handling + return dataFrame.sparkSession() + .sql( + String.format( + "select %s IF(exploded.pos IS NULL, 0, exploded.pos + 1) as `%s`, exploded.col as `%s` from input lateral view outer posexplode(grouped) exploded", + selectSQL, + positionalVariableName, + newVariableName + ) + ); + } else { + // register previously created table + dataFrame.createOrReplaceTempView("input"); + + // finally we unwrap it with a single posexplode + return dataFrame.sparkSession() + .sql( + String.format( + "select %s (exploded.pos + 1) as `%s`, exploded.col as `%s` from input lateral view posexplode(grouped) exploded", + selectSQL, + positionalVariableName, + newVariableName + ) + ); + } } } } catch (Exception e) { From 1e5866b8a48c6c4dc7233e28efc40c5867464600 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 4 Jan 2021 07:07:25 +0100 Subject: [PATCH 122/206] spotless --- .../flwor/clauses/ForClauseSparkIterator.java | 189 +++++++++--------- .../postfix/ArrayUnboxingIterator.java | 13 +- 2 files changed, 107 insertions(+), 95 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index 279398b3d0..9c08f14bfc 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -1227,7 +1227,7 @@ public static Dataset tryNativeQuery( if (positionalVariableName == null) { if (allowingEmpty) { List lateralViewPart = nativeQuery.getLateralViewPart(); - if(lateralViewPart.size() == 0){ + if (lateralViewPart.size() == 0) { // no array unboxing in the operation // already covered in the generation and handled through UDF // this branch should never happen in practice @@ -1239,14 +1239,15 @@ public static Dataset tryNativeQuery( // to deal with allowing empty // first we add an artificial unique id to the dataset and re-register the input table String rowIdField = "idx-9384-3948-1272-4375"; - dataFrame = dataFrame.sparkSession().sql("select *, monotonically_increasing_id() as `" + rowIdField + "` from input"); + dataFrame = dataFrame.sparkSession() + .sql("select *, monotonically_increasing_id() as `" + rowIdField + "` from input"); dataFrame.createOrReplaceTempView("input"); // then we create the virtual exploded table as before // but this time we store it and also get the index field StringBuilder lateralViewString = new StringBuilder(); int arrIndex = 0; - for(String lateralView : lateralViewPart){ + for (String lateralView : lateralViewPart) { ++arrIndex; lateralViewString.append(" lateral view "); lateralViewString.append(lateralView); @@ -1254,48 +1255,50 @@ public static Dataset tryNativeQuery( lateralViewString.append(arrIndex); } Dataset lateralViewDf = dataFrame.sparkSession() - .sql( - String.format( - "select `%s`, arr%d.col%s as `%s` from input %s", - rowIdField, - arrIndex, - nativeQuery.getResultingQuery(), - newVariableName, - lateralViewString - ) - ); + .sql( + String.format( + "select `%s`, arr%d.col%s as `%s` from input %s", + rowIdField, + arrIndex, + nativeQuery.getResultingQuery(), + newVariableName, + lateralViewString + ) + ); lateralViewDf.createOrReplaceTempView("lateral"); - // to return the correct number of empty results we perform a left join between input and lateral - return dataFrame.sparkSession().sql( + // to return the correct number of empty results we perform a left join between input and + // lateral + return dataFrame.sparkSession() + .sql( String.format( - "select %s lateral.`%s` from input left join lateral on input.`%s` = lateral.`%s`", - selectSQL, - newVariableName, - rowIdField, - rowIdField + "select %s lateral.`%s` from input left join lateral on input.`%s` = lateral.`%s`", + selectSQL, + newVariableName, + rowIdField, + rowIdField ) - ); + ); } } else { List lateralViewPart = nativeQuery.getLateralViewPart(); - if(lateralViewPart.size() == 0){ + if (lateralViewPart.size() == 0) { // no array unboxing in the operation return dataFrame.sparkSession() - .sql( - String.format( - "select %s %s as `%s` from input", - selectSQL, - nativeQuery.getResultingQuery(), - newVariableName - ) - ); + .sql( + String.format( + "select %s %s as `%s` from input", + selectSQL, + nativeQuery.getResultingQuery(), + newVariableName + ) + ); } else { // we have at least an array unboxing operation // col is the default name of explode StringBuilder lateralViewString = new StringBuilder(); int arrIndex = 0; - for(String lateralView : lateralViewPart){ + for (String lateralView : lateralViewPart) { ++arrIndex; lateralViewString.append(" lateral view "); lateralViewString.append(lateralView); @@ -1303,45 +1306,46 @@ public static Dataset tryNativeQuery( lateralViewString.append(arrIndex); } return dataFrame.sparkSession() - .sql( - String.format( - "select %s arr%d.col%s as `%s` from input %s", - selectSQL, - arrIndex, - nativeQuery.getResultingQuery(), - newVariableName, - lateralViewString - ) - ); + .sql( + String.format( + "select %s arr%d.col%s as `%s` from input %s", + selectSQL, + arrIndex, + nativeQuery.getResultingQuery(), + newVariableName, + lateralViewString + ) + ); } } } else { // common part for positional variable handling List lateralViewPart = nativeQuery.getLateralViewPart(); - if(lateralViewPart.size() == 0){ + if (lateralViewPart.size() == 0) { // if allowing empty we do not deal with this - if(allowingEmpty){ + if (allowingEmpty) { return null; } // no array unboxing in the operation // therefore position is for sure 1 return dataFrame.sparkSession() - .sql( - String.format( - "select %s %s as `%s`, 1 as `%s` from input", - selectSQL, - nativeQuery.getResultingQuery(), - newVariableName, - positionalVariableName - ) - ); + .sql( + String.format( + "select %s %s as `%s`, 1 as `%s` from input", + selectSQL, + nativeQuery.getResultingQuery(), + newVariableName, + positionalVariableName + ) + ); } else { // we have at least an array unboxing operation // pos, col are the default name of posexplode function // to deal with positional variable // we first add unique index to guarantee grouping correctly String rowIdField = "idx-9384-3948-1272-4375"; - dataFrame = dataFrame.sparkSession().sql("select *, monotonically_increasing_id() as `" + rowIdField + "` from input"); + dataFrame = dataFrame.sparkSession() + .sql("select *, monotonically_increasing_id() as `" + rowIdField + "` from input"); dataFrame.createOrReplaceTempView("input"); // then we collect all values from lateral view @@ -1349,7 +1353,7 @@ public static Dataset tryNativeQuery( // this is basically equivalent to flattening the array, in case of multiple unboxing operation StringBuilder lateralViewString = new StringBuilder(); int arrIndex = 0; - for(String lateralView : lateralViewPart){ + for (String lateralView : lateralViewPart) { ++arrIndex; lateralViewString.append(" lateral view "); lateralViewString.append(lateralView); @@ -1357,61 +1361,66 @@ public static Dataset tryNativeQuery( lateralViewString.append(arrIndex); } dataFrame = dataFrame.sparkSession() - .sql( - String.format( - "select `%s`, %s collect_list(arr%d.col%s) as grouped from input %s group by %s `%s`", - rowIdField, - selectSQL, - arrIndex, - nativeQuery.getResultingQuery(), - lateralViewString, - selectSQL, - rowIdField - ) - ); + .sql( + String.format( + "select `%s`, %s collect_list(arr%d.col%s) as grouped from input %s group by %s `%s`", + rowIdField, + selectSQL, + arrIndex, + nativeQuery.getResultingQuery(), + lateralViewString, + selectSQL, + rowIdField + ) + ); if (allowingEmpty) { // register a support table to keep the empty values - dataFrame.sparkSession().sql("select `" + rowIdField + "` from input").createOrReplaceTempView("allrows"); + dataFrame.sparkSession() + .sql("select `" + rowIdField + "` from input") + .createOrReplaceTempView("allrows"); // register previously created table dataFrame.createOrReplaceTempView("input"); // insert null values - dataFrame = dataFrame.sparkSession().sql(String.format( - "select allrows.`%s`, %s grouped from allrows left join input on allrows.`%s` = input.`%s`", - rowIdField, - selectSQL, - rowIdField, - rowIdField - )); + dataFrame = dataFrame.sparkSession() + .sql( + String.format( + "select allrows.`%s`, %s grouped from allrows left join input on allrows.`%s` = input.`%s`", + rowIdField, + selectSQL, + rowIdField, + rowIdField + ) + ); dataFrame.createOrReplaceTempView("input"); // we use a lateral view to handle proper counting and NULL handling return dataFrame.sparkSession() - .sql( - String.format( - "select %s IF(exploded.pos IS NULL, 0, exploded.pos + 1) as `%s`, exploded.col as `%s` from input lateral view outer posexplode(grouped) exploded", - selectSQL, - positionalVariableName, - newVariableName - ) - ); + .sql( + String.format( + "select %s IF(exploded.pos IS NULL, 0, exploded.pos + 1) as `%s`, exploded.col as `%s` from input lateral view outer posexplode(grouped) exploded", + selectSQL, + positionalVariableName, + newVariableName + ) + ); } else { // register previously created table dataFrame.createOrReplaceTempView("input"); // finally we unwrap it with a single posexplode return dataFrame.sparkSession() - .sql( - String.format( - "select %s (exploded.pos + 1) as `%s`, exploded.col as `%s` from input lateral view posexplode(grouped) exploded", - selectSQL, - positionalVariableName, - newVariableName - ) - ); + .sql( + String.format( + "select %s (exploded.pos + 1) as `%s`, exploded.col as `%s` from input lateral view posexplode(grouped) exploded", + selectSQL, + positionalVariableName, + newVariableName + ) + ); } } } diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java index 62d2a097f9..13088c3f09 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java @@ -131,12 +131,12 @@ public boolean implementsDataFrames() { @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - if(nativeClauseContext.getClauseType() != FLWOR_CLAUSES.FOR){ + if (nativeClauseContext.getClauseType() != FLWOR_CLAUSES.FOR) { // unboxing only available for the FOR clause return NativeClauseContext.NoNativeQuery; } NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); - if(newContext != NativeClauseContext.NoNativeQuery){ + if (newContext != NativeClauseContext.NoNativeQuery) { DataType schema = newContext.getSchema(); if (!(schema instanceof ArrayType)) { // let control to UDF when what we are unboxing is not an array @@ -144,11 +144,14 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC } newContext.setSchema(((ArrayType) schema).elementType()); List lateralViewPart = newContext.getLateralViewPart(); - if(lateralViewPart.size() == 0){ + if (lateralViewPart.size() == 0) { lateralViewPart.add("explode(" + newContext.getResultingQuery() + ")"); } else { - // if we have multiple array unboxing we stack multiple lateral views and each one takes from the previous - lateralViewPart.add("explode( arr"+ lateralViewPart.size() + ".col" + newContext.getResultingQuery() + ")"); + // if we have multiple array unboxing we stack multiple lateral views and each one takes from the + // previous + lateralViewPart.add( + "explode( arr" + lateralViewPart.size() + ".col" + newContext.getResultingQuery() + ")" + ); } newContext.setResultingQuery(""); // dealt by for clause } From 9544e856f8ff82b1209cc9d9f1e91e7373112ca6 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 4 Jan 2021 07:38:56 +0100 Subject: [PATCH 123/206] removed try/catch for order by and where --- .../clauses/OrderByClauseSparkIterator.java | 58 +++++++++---------- .../clauses/WhereClauseSparkIterator.java | 30 ++++------ 2 files changed, 38 insertions(+), 50 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index f7f9f4c217..d44109af4f 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -522,39 +522,33 @@ public static Dataset tryNativeQuery( StructType inputSchema, DynamicContext context ) { - // the try catch block is required because of the query that are not supported by sparksql like using a field to - // decide which field to use (e.g. $i.($i.fieldToUse) ) - try { - NativeClauseContext orderContext = new NativeClauseContext(FLWOR_CLAUSES.ORDER_BY, inputSchema, context); - StringBuilder orderSql = new StringBuilder(); - String orderSeparator = ""; - NativeClauseContext nativeQuery; - for (OrderByClauseAnnotatedChildIterator orderIterator : expressionsWithIterator) { - nativeQuery = orderIterator.getIterator().generateNativeQuery(orderContext); - if (nativeQuery == NativeClauseContext.NoNativeQuery) { - return null; - } - orderSql.append(orderSeparator); - orderSeparator = ", "; - orderSql.append(nativeQuery.getResultingQuery()); - if (!orderIterator.isAscending()) { - orderSql.append(" desc"); - } + NativeClauseContext orderContext = new NativeClauseContext(FLWOR_CLAUSES.ORDER_BY, inputSchema, context); + StringBuilder orderSql = new StringBuilder(); + String orderSeparator = ""; + NativeClauseContext nativeQuery; + for (OrderByClauseAnnotatedChildIterator orderIterator : expressionsWithIterator) { + nativeQuery = orderIterator.getIterator().generateNativeQuery(orderContext); + if (nativeQuery == NativeClauseContext.NoNativeQuery) { + return null; + } + orderSql.append(orderSeparator); + orderSeparator = ", "; + orderSql.append(nativeQuery.getResultingQuery()); + if (!orderIterator.isAscending()) { + orderSql.append(" desc"); } - - System.out.println("native query returned: " + orderSql); - String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, false); - dataFrame.createOrReplaceTempView("input"); - return dataFrame.sparkSession() - .sql( - String.format( - "select %s from input order by %s", - selectSQL, - orderSql - ) - ); - } catch (Exception e) { - return null; } + + System.out.println("native query returned: " + orderSql); + String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, false); + dataFrame.createOrReplaceTempView("input"); + return dataFrame.sparkSession() + .sql( + String.format( + "select %s from input order by %s", + selectSQL, + orderSql + ) + ); } } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java index d72986f34d..0c6f5e12e7 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java @@ -305,25 +305,19 @@ public static Dataset tryNativeQuery( StructType inputSchema, DynamicContext context ) { - // the try catch block is required because of the query that are not supported by sparksql like using a field to - // decide which field to use (e.g. $i.($i.fieldToUse) ) - try { - NativeClauseContext letContext = new NativeClauseContext(FLWOR_CLAUSES.WHERE, inputSchema, context); - NativeClauseContext nativeQuery = iterator.generateNativeQuery(letContext); - if (nativeQuery == NativeClauseContext.NoNativeQuery) { - return null; - } - System.out.println("native query returned " + nativeQuery.getResultingQuery()); - dataFrame.createOrReplaceTempView("input"); - return dataFrame.sparkSession() - .sql( - String.format( - "select * from input where %s", - nativeQuery.getResultingQuery() - ) - ); - } catch (Exception e) { + NativeClauseContext letContext = new NativeClauseContext(FLWOR_CLAUSES.WHERE, inputSchema, context); + NativeClauseContext nativeQuery = iterator.generateNativeQuery(letContext); + if (nativeQuery == NativeClauseContext.NoNativeQuery) { return null; } + System.out.println("native query returned " + nativeQuery.getResultingQuery()); + dataFrame.createOrReplaceTempView("input"); + return dataFrame.sparkSession() + .sql( + String.format( + "select * from input where %s", + nativeQuery.getResultingQuery() + ) + ); } } From ab84e9856e24d643a8b334755169c7ea9da6f43a Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 4 Jan 2021 07:59:29 +0100 Subject: [PATCH 124/206] removed try/catch for native let, group and for --- .../flwor/clauses/ForClauseSparkIterator.java | 350 +++++++++--------- .../clauses/GroupByClauseSparkIterator.java | 106 +++--- .../flwor/clauses/LetClauseSparkIterator.java | 36 +- 3 files changed, 241 insertions(+), 251 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index 9c08f14bfc..b1c5558b3d 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -1210,147 +1210,89 @@ public static Dataset tryNativeQuery( StructType inputSchema, DynamicContext context ) { - // the try catch block is required because of the query that are not supported by sparksql like using a field to - // decide which field to use (e.g. $i.($i.fieldToUse) ) - try { - NativeClauseContext forContext = new NativeClauseContext(FLWOR_CLAUSES.FOR, inputSchema, context); - NativeClauseContext nativeQuery = iterator.generateNativeQuery(forContext); - if (nativeQuery == NativeClauseContext.NoNativeQuery) { - return null; - } - System.out.println("native query returned " + nativeQuery.getResultingQuery()); - System.out.println("lateral view part is " + nativeQuery.getLateralViewPart()); - String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); - dataFrame.createOrReplaceTempView("input"); - - // let's distinguish 4 cases - if (positionalVariableName == null) { - if (allowingEmpty) { - List lateralViewPart = nativeQuery.getLateralViewPart(); - if (lateralViewPart.size() == 0) { - // no array unboxing in the operation - // already covered in the generation and handled through UDF - // this branch should never happen in practice - return null; - } else { - // we have at least an array unboxing operation - // col is the default name of explode - - // to deal with allowing empty - // first we add an artificial unique id to the dataset and re-register the input table - String rowIdField = "idx-9384-3948-1272-4375"; - dataFrame = dataFrame.sparkSession() - .sql("select *, monotonically_increasing_id() as `" + rowIdField + "` from input"); - dataFrame.createOrReplaceTempView("input"); - - // then we create the virtual exploded table as before - // but this time we store it and also get the index field - StringBuilder lateralViewString = new StringBuilder(); - int arrIndex = 0; - for (String lateralView : lateralViewPart) { - ++arrIndex; - lateralViewString.append(" lateral view "); - lateralViewString.append(lateralView); - lateralViewString.append(" arr"); - lateralViewString.append(arrIndex); - } - Dataset lateralViewDf = dataFrame.sparkSession() - .sql( - String.format( - "select `%s`, arr%d.col%s as `%s` from input %s", - rowIdField, - arrIndex, - nativeQuery.getResultingQuery(), - newVariableName, - lateralViewString - ) - ); - lateralViewDf.createOrReplaceTempView("lateral"); - - // to return the correct number of empty results we perform a left join between input and - // lateral - return dataFrame.sparkSession() - .sql( - String.format( - "select %s lateral.`%s` from input left join lateral on input.`%s` = lateral.`%s`", - selectSQL, - newVariableName, - rowIdField, - rowIdField - ) - ); - } + NativeClauseContext forContext = new NativeClauseContext(FLWOR_CLAUSES.FOR, inputSchema, context); + NativeClauseContext nativeQuery = iterator.generateNativeQuery(forContext); + if (nativeQuery == NativeClauseContext.NoNativeQuery) { + return null; + } + System.out.println("native query returned " + nativeQuery.getResultingQuery()); + System.out.println("lateral view part is " + nativeQuery.getLateralViewPart()); + String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); + dataFrame.createOrReplaceTempView("input"); + + // let's distinguish 4 cases + if (positionalVariableName == null) { + if (allowingEmpty) { + List lateralViewPart = nativeQuery.getLateralViewPart(); + if (lateralViewPart.size() == 0) { + // no array unboxing in the operation + // already covered in the generation and handled through UDF + // this branch should never happen in practice + return null; } else { - List lateralViewPart = nativeQuery.getLateralViewPart(); - if (lateralViewPart.size() == 0) { - // no array unboxing in the operation - return dataFrame.sparkSession() - .sql( - String.format( - "select %s %s as `%s` from input", - selectSQL, - nativeQuery.getResultingQuery(), - newVariableName - ) - ); - } else { - // we have at least an array unboxing operation - // col is the default name of explode - StringBuilder lateralViewString = new StringBuilder(); - int arrIndex = 0; - for (String lateralView : lateralViewPart) { - ++arrIndex; - lateralViewString.append(" lateral view "); - lateralViewString.append(lateralView); - lateralViewString.append(" arr"); - lateralViewString.append(arrIndex); - } - return dataFrame.sparkSession() - .sql( - String.format( - "select %s arr%d.col%s as `%s` from input %s", - selectSQL, - arrIndex, - nativeQuery.getResultingQuery(), - newVariableName, - lateralViewString - ) - ); + // we have at least an array unboxing operation + // col is the default name of explode + + // to deal with allowing empty + // first we add an artificial unique id to the dataset and re-register the input table + String rowIdField = "idx-9384-3948-1272-4375"; + dataFrame = dataFrame.sparkSession() + .sql("select *, monotonically_increasing_id() as `" + rowIdField + "` from input"); + dataFrame.createOrReplaceTempView("input"); + + // then we create the virtual exploded table as before + // but this time we store it and also get the index field + StringBuilder lateralViewString = new StringBuilder(); + int arrIndex = 0; + for (String lateralView : lateralViewPart) { + ++arrIndex; + lateralViewString.append(" lateral view "); + lateralViewString.append(lateralView); + lateralViewString.append(" arr"); + lateralViewString.append(arrIndex); } + Dataset lateralViewDf = dataFrame.sparkSession() + .sql( + String.format( + "select `%s`, arr%d.col%s as `%s` from input %s", + rowIdField, + arrIndex, + nativeQuery.getResultingQuery(), + newVariableName, + lateralViewString + ) + ); + lateralViewDf.createOrReplaceTempView("lateral"); + + // to return the correct number of empty results we perform a left join between input and + // lateral + return dataFrame.sparkSession() + .sql( + String.format( + "select %s lateral.`%s` from input left join lateral on input.`%s` = lateral.`%s`", + selectSQL, + newVariableName, + rowIdField, + rowIdField + ) + ); } } else { - // common part for positional variable handling List lateralViewPart = nativeQuery.getLateralViewPart(); if (lateralViewPart.size() == 0) { - // if allowing empty we do not deal with this - if (allowingEmpty) { - return null; - } // no array unboxing in the operation - // therefore position is for sure 1 return dataFrame.sparkSession() .sql( String.format( - "select %s %s as `%s`, 1 as `%s` from input", + "select %s %s as `%s` from input", selectSQL, nativeQuery.getResultingQuery(), - newVariableName, - positionalVariableName + newVariableName ) ); } else { // we have at least an array unboxing operation - // pos, col are the default name of posexplode function - // to deal with positional variable - // we first add unique index to guarantee grouping correctly - String rowIdField = "idx-9384-3948-1272-4375"; - dataFrame = dataFrame.sparkSession() - .sql("select *, monotonically_increasing_id() as `" + rowIdField + "` from input"); - dataFrame.createOrReplaceTempView("input"); - - // then we collect all values from lateral view - // and group by original tuple - // this is basically equivalent to flattening the array, in case of multiple unboxing operation + // col is the default name of explode StringBuilder lateralViewString = new StringBuilder(); int arrIndex = 0; for (String lateralView : lateralViewPart) { @@ -1360,72 +1302,124 @@ public static Dataset tryNativeQuery( lateralViewString.append(" arr"); lateralViewString.append(arrIndex); } - dataFrame = dataFrame.sparkSession() + return dataFrame.sparkSession() .sql( String.format( - "select `%s`, %s collect_list(arr%d.col%s) as grouped from input %s group by %s `%s`", - rowIdField, + "select %s arr%d.col%s as `%s` from input %s", selectSQL, arrIndex, nativeQuery.getResultingQuery(), - lateralViewString, + newVariableName, + lateralViewString + ) + ); + } + } + } else { + // common part for positional variable handling + List lateralViewPart = nativeQuery.getLateralViewPart(); + if (lateralViewPart.size() == 0) { + // if allowing empty we do not deal with this + if (allowingEmpty) { + return null; + } + // no array unboxing in the operation + // therefore position is for sure 1 + return dataFrame.sparkSession() + .sql( + String.format( + "select %s %s as `%s`, 1 as `%s` from input", + selectSQL, + nativeQuery.getResultingQuery(), + newVariableName, + positionalVariableName + ) + ); + } else { + // we have at least an array unboxing operation + // pos, col are the default name of posexplode function + // to deal with positional variable + // we first add unique index to guarantee grouping correctly + String rowIdField = "idx-9384-3948-1272-4375"; + dataFrame = dataFrame.sparkSession() + .sql("select *, monotonically_increasing_id() as `" + rowIdField + "` from input"); + dataFrame.createOrReplaceTempView("input"); + + // then we collect all values from lateral view + // and group by original tuple + // this is basically equivalent to flattening the array, in case of multiple unboxing operation + StringBuilder lateralViewString = new StringBuilder(); + int arrIndex = 0; + for (String lateralView : lateralViewPart) { + ++arrIndex; + lateralViewString.append(" lateral view "); + lateralViewString.append(lateralView); + lateralViewString.append(" arr"); + lateralViewString.append(arrIndex); + } + dataFrame = dataFrame.sparkSession() + .sql( + String.format( + "select `%s`, %s collect_list(arr%d.col%s) as grouped from input %s group by %s `%s`", + rowIdField, + selectSQL, + arrIndex, + nativeQuery.getResultingQuery(), + lateralViewString, + selectSQL, + rowIdField + ) + ); + + + if (allowingEmpty) { + // register a support table to keep the empty values + dataFrame.sparkSession() + .sql("select `" + rowIdField + "` from input") + .createOrReplaceTempView("allrows"); + + // register previously created table + dataFrame.createOrReplaceTempView("input"); + + // insert null values + dataFrame = dataFrame.sparkSession() + .sql( + String.format( + "select allrows.`%s`, %s grouped from allrows left join input on allrows.`%s` = input.`%s`", + rowIdField, selectSQL, + rowIdField, rowIdField ) ); + dataFrame.createOrReplaceTempView("input"); + // we use a lateral view to handle proper counting and NULL handling + return dataFrame.sparkSession() + .sql( + String.format( + "select %s IF(exploded.pos IS NULL, 0, exploded.pos + 1) as `%s`, exploded.col as `%s` from input lateral view outer posexplode(grouped) exploded", + selectSQL, + positionalVariableName, + newVariableName + ) + ); + } else { + // register previously created table + dataFrame.createOrReplaceTempView("input"); - if (allowingEmpty) { - // register a support table to keep the empty values - dataFrame.sparkSession() - .sql("select `" + rowIdField + "` from input") - .createOrReplaceTempView("allrows"); - - // register previously created table - dataFrame.createOrReplaceTempView("input"); - - // insert null values - dataFrame = dataFrame.sparkSession() - .sql( - String.format( - "select allrows.`%s`, %s grouped from allrows left join input on allrows.`%s` = input.`%s`", - rowIdField, - selectSQL, - rowIdField, - rowIdField - ) - ); - dataFrame.createOrReplaceTempView("input"); - - // we use a lateral view to handle proper counting and NULL handling - return dataFrame.sparkSession() - .sql( - String.format( - "select %s IF(exploded.pos IS NULL, 0, exploded.pos + 1) as `%s`, exploded.col as `%s` from input lateral view outer posexplode(grouped) exploded", - selectSQL, - positionalVariableName, - newVariableName - ) - ); - } else { - // register previously created table - dataFrame.createOrReplaceTempView("input"); - - // finally we unwrap it with a single posexplode - return dataFrame.sparkSession() - .sql( - String.format( - "select %s (exploded.pos + 1) as `%s`, exploded.col as `%s` from input lateral view posexplode(grouped) exploded", - selectSQL, - positionalVariableName, - newVariableName - ) - ); - } + // finally we unwrap it with a single posexplode + return dataFrame.sparkSession() + .sql( + String.format( + "select %s (exploded.pos + 1) as `%s`, exploded.col as `%s` from input lateral view posexplode(grouped) exploded", + selectSQL, + positionalVariableName, + newVariableName + ) + ); } } - } catch (Exception e) { - return null; } } } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java index 86ac094518..7b24300d50 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java @@ -495,62 +495,64 @@ private Dataset tryNativeQuery( StructType inputSchema, DynamicContext context ) { - try { - StringBuilder groupByString = new StringBuilder(); - String sep = " "; - for (Name groupingVar : groupingVariables) { - StructField field = inputSchema.fields()[inputSchema.fieldIndex(groupingVar.toString())]; + StringBuilder groupByString = new StringBuilder(); + String sep = " "; + for (Name groupingVar : groupingVariables) { + StructField field = inputSchema.fields()[inputSchema.fieldIndex(groupingVar.toString())]; + if (field.dataType().equals(DataTypes.BinaryType)) { + // we got a non-native type for grouping, switch to udf version + return null; + } + + groupByString.append(sep); + sep = ", "; + groupByString.append(groupingVar.toString()); + } + StringBuilder selectString = new StringBuilder(); + sep = " "; + for (Map.Entry entry : dependencies.entrySet()) { + selectString.append(sep); + sep = ", "; + if (entry.getKey().toString().endsWith(".count")) { + // we are summing over a previous count + selectString.append("sum(`"); + selectString.append(entry.getKey().toString()); + selectString.append("`) as `"); + selectString.append(entry.getKey().toString()); + selectString.append("`"); + } else if (entry.getValue() == DynamicContext.VariableDependency.COUNT) { + // we need a count + selectString.append("count(`"); + selectString.append(entry.getKey().toString()); + selectString.append("`) as `"); + selectString.append(entry.getKey().toString()); + selectString.append(".count`"); + } else if (groupingVariables.contains(entry.getKey())) { + // we are considering one of the grouping variables + selectString.append(entry.getKey().toString()); + } else { + // we collect all the values, if it is a binary object we just switch over to udf + String columnName = entry.getKey().toString(); + StructField field = inputSchema.fields()[inputSchema.fieldIndex(columnName)]; if (field.dataType().equals(DataTypes.BinaryType)) { - // we got a non-native type for grouping, switch to udf version return null; } - - groupByString.append(sep); - sep = ", "; - groupByString.append(groupingVar.toString()); - } - StringBuilder selectString = new StringBuilder(); - sep = " "; - for (Map.Entry entry : dependencies.entrySet()) { - selectString.append(sep); - sep = ", "; - // TODO: what about precomputed count - if (entry.getValue() == DynamicContext.VariableDependency.COUNT) { - // we need a count - selectString.append("count(`"); - selectString.append(entry.getKey().toString()); - selectString.append("`) as `"); - selectString.append(entry.getKey().toString()); - selectString.append(".count`"); - } else if (groupingVariables.contains(entry.getKey())) { - // we are considering one of the grouping variables - selectString.append(entry.getKey().toString()); - } else { - // we collect all the values, if it is a binary object we just switch over to udf - String columnName = entry.getKey().toString(); - StructField field = inputSchema.fields()[inputSchema.fieldIndex(columnName)]; - if (field.dataType().equals(DataTypes.BinaryType)) { - return null; - } - selectString.append("collect_list(`"); - selectString.append(columnName); - selectString.append("`) as `"); - selectString.append(columnName); - selectString.append("`"); - } + selectString.append("collect_list(`"); + selectString.append(columnName); + selectString.append("`) as `"); + selectString.append(columnName); + selectString.append("`"); } - System.out.println("select part got returned: " + selectString); - System.out.println("groupby part got returned: " + groupByString); - return dataFrame.sparkSession() - .sql( - String.format( - "select %s from input group by %s", - selectString, - groupByString - ) - ); - } catch (Exception e) { - return null; } + System.out.println("select part got returned: " + selectString); + System.out.println("groupby part got returned: " + groupByString); + return dataFrame.sparkSession() + .sql( + String.format( + "select %s from input group by %s", + selectString, + groupByString + ) + ); } } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index 9eb364d6c9..1c1396c986 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -630,28 +630,22 @@ public static Dataset tryNativeQuery( StructType inputSchema, DynamicContext context ) { - // the try catch block is required because of the query that are not supported by sparksql like using a field to - // decide which field to use (e.g. $i.($i.fieldToUse) ) - try { - NativeClauseContext letContext = new NativeClauseContext(FLWOR_CLAUSES.LET, inputSchema, context); - NativeClauseContext nativeQuery = iterator.generateNativeQuery(letContext); - if (nativeQuery == NativeClauseContext.NoNativeQuery) { - return null; - } - System.out.println("native query returned " + nativeQuery.getResultingQuery()); - String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); - dataFrame.createOrReplaceTempView("input"); - return dataFrame.sparkSession() - .sql( - String.format( - "select %s (%s) as `%s` from input", - selectSQL, - nativeQuery.getResultingQuery(), - newVariableName - ) - ); - } catch (Exception e) { + NativeClauseContext letContext = new NativeClauseContext(FLWOR_CLAUSES.LET, inputSchema, context); + NativeClauseContext nativeQuery = iterator.generateNativeQuery(letContext); + if (nativeQuery == NativeClauseContext.NoNativeQuery) { return null; } + System.out.println("native query returned " + nativeQuery.getResultingQuery()); + String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); + dataFrame.createOrReplaceTempView("input"); + return dataFrame.sparkSession() + .sql( + String.format( + "select %s (%s) as `%s` from input", + selectSQL, + nativeQuery.getResultingQuery(), + newVariableName + ) + ); } } From cfedf0f265d31aa54f7deaee1983e466a657ddb1 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 5 Jan 2021 10:32:41 +0100 Subject: [PATCH 125/206] added sequence type to let spark iterator --- .../java/org/rumbledb/compiler/RuntimeIteratorVisitor.java | 1 + .../rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java b/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java index 3cd974f132..9b0e779cae 100644 --- a/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java +++ b/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java @@ -244,6 +244,7 @@ private RuntimeTupleIterator visitFlowrClause( return new LetClauseSparkIterator( previousIterator, letClause.getVariableName(), + letClause.getActualSequenceType(), assignmentIterator, letClause.getHighestExecutionMode(this.visitorConfig), clause.getMetadata() diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index 1c1396c986..0b49c54841 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -64,6 +64,7 @@ public class LetClauseSparkIterator extends RuntimeTupleIterator { private static final long serialVersionUID = 1L; private Name variableName; // for efficient use in local iteration + private SequenceType sequenceType; private RuntimeIterator assignmentIterator; private DynamicContext tupleContext; // re-use same DynamicContext object for efficiency private FlworTuple nextLocalTupleResult; @@ -71,12 +72,14 @@ public class LetClauseSparkIterator extends RuntimeTupleIterator { public LetClauseSparkIterator( RuntimeTupleIterator child, Name variableName, + SequenceType sequenceType, RuntimeIterator assignmentIterator, ExecutionMode executionMode, ExceptionMetadata iteratorMetadata ) { super(child, executionMode, iteratorMetadata); this.variableName = variableName; + this.sequenceType = sequenceType; this.assignmentIterator = assignmentIterator; } From 41653bf57a0717dc7efbe9f7815b1923cafa6536 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 5 Jan 2021 11:33:52 +0100 Subject: [PATCH 126/206] started new generic let udf --- .../flwor/udfs/GenericLetClauseUDF.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java diff --git a/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java b/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java new file mode 100644 index 0000000000..2068603b54 --- /dev/null +++ b/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java @@ -0,0 +1,48 @@ +package org.rumbledb.runtime.flwor.udfs; + +import org.apache.spark.sql.Row; +import org.apache.spark.sql.api.java.UDF1; +import org.apache.spark.sql.types.StructType; +import org.rumbledb.api.Item; +import org.rumbledb.context.DynamicContext; +import org.rumbledb.runtime.RuntimeIterator; + +import java.util.ArrayList; +import java.util.List; + +public class GenericLetClauseUDF implements UDF1 { + + private static final long serialVersionUID = 1L; + + private DataFrameContext dataFrameContext; + private RuntimeIterator expression; + private String classSimpleName; + + private List nextResult; + + public GenericLetClauseUDF( + RuntimeIterator expression, + DynamicContext context, + StructType schema, + List columnNames + ) { + this.dataFrameContext = new DataFrameContext(context, schema, columnNames); + this.expression = expression; + this.nextResult = new ArrayList<>(); + } + + @Override + public T call(Row row) { + this.dataFrameContext.setFromRow(row); + + this.expression.materialize(this.dataFrameContext.getContext(), this.nextResult); + + return toDFValue(classSimpleName); + } + + // TODO: check if there is a better/safer/faster way to do it + @SuppressWarnings("unchecked") + public T toDFValue(String classSimpleName){ + return (T) new Integer(4); + } +} From f77bf9a6ee90ab47c97a6166af57faaeb19b8bcc Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 5 Jan 2021 11:46:07 +0100 Subject: [PATCH 127/206] setup custom udf for string, integer, decimal and double --- .../flwor/clauses/ForClauseSparkIterator.java | 2 + .../clauses/GroupByClauseSparkIterator.java | 2 + .../flwor/clauses/LetClauseSparkIterator.java | 74 ++++++++++++++++--- 3 files changed, 68 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index b1c5558b3d..d47b89a825 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -556,6 +556,7 @@ public static Dataset joinInputTupleWithSequenceOnPredicate( expressionDF = LetClauseSparkIterator.bindLetVariableInDataFrame( expressionDF, Name.createVariableInNoNamespace(SparkSessionManager.expressionHashColumnName), + null, expressionSideEqualityCriterion, context, variablesInExpressionSideTuple, @@ -565,6 +566,7 @@ public static Dataset joinInputTupleWithSequenceOnPredicate( inputTuples = LetClauseSparkIterator.bindLetVariableInDataFrame( inputTuples, Name.createVariableInNoNamespace(SparkSessionManager.inputTupleHashColumnName), + null, inputTupleSideEqualityCriterion, context, variablesInInputTuple, diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java index 7b24300d50..4c6eb189d1 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/GroupByClauseSparkIterator.java @@ -274,12 +274,14 @@ public Dataset getDataFrame( columnNamesArray = inputSchema.fieldNames(); columnNames = Arrays.asList(columnNamesArray); + // TODO: consider add sequence type to group clause variable if (expression.getExpression() != null) { // if a variable is defined in-place with groupby, execute a let on the variable variableAccessNames.add(expression.getVariableName()); df = LetClauseSparkIterator.bindLetVariableInDataFrame( df, expression.getVariableName(), + null, expression.getExpression(), context, new ArrayList(this.child.getOutputTupleVariableNames()), diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index 0b49c54841..173f2afbff 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -35,21 +35,23 @@ import org.rumbledb.exceptions.UnsupportedFeatureException; import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.expressions.flowr.FLWOR_CLAUSES; +import org.rumbledb.items.AtomicItem; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.RuntimeTupleIterator; import org.rumbledb.runtime.flwor.FlworDataFrameUtils; import org.rumbledb.runtime.flwor.NativeClauseContext; -import org.rumbledb.runtime.flwor.udfs.GroupClauseSerializeAggregateResultsUDF; -import org.rumbledb.runtime.flwor.udfs.HashUDF; -import org.rumbledb.runtime.flwor.udfs.LetClauseUDF; +import org.rumbledb.runtime.flwor.udfs.*; import org.rumbledb.runtime.operational.ComparisonOperationIterator; import org.rumbledb.runtime.postfix.PredicateIterator; import org.rumbledb.runtime.primary.VariableReferenceIterator; +import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; import sparksoniq.jsoniq.tuple.FlworTuple; import sparksoniq.spark.SparkSessionManager; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -191,6 +193,7 @@ public Dataset getDataFrame( df = bindLetVariableInDataFrame( df, this.variableName, + this.sequenceType, this.assignmentIterator, context, (this.child == null) @@ -323,6 +326,7 @@ public Dataset getDataFrameAsJoin( expressionDF = LetClauseSparkIterator.bindLetVariableInDataFrame( expressionDF, Name.createVariableInNoNamespace(SparkSessionManager.expressionHashColumnName), + this.sequenceType, contextItemValueExpression, context, Collections.singletonList(Name.CONTEXT_ITEM), @@ -333,6 +337,7 @@ public Dataset getDataFrameAsJoin( inputDF = LetClauseSparkIterator.bindLetVariableInDataFrame( inputDF, Name.createVariableInNoNamespace(SparkSessionManager.inputTupleHashColumnName), + this.sequenceType, inputTupleValueExpression, context, (this.child == null) @@ -418,6 +423,7 @@ public Dataset getDataFrameAsJoin( inputDF = LetClauseSparkIterator.bindLetVariableInDataFrame( inputDF, this.variableName, + this.sequenceType, filteringPredicateIterator, context, new ArrayList(this.getOutputTupleVariableNames()), @@ -512,6 +518,7 @@ public Map getProjection( * * @param dataFrame the DataFrame to extend * @param newVariableName the name of the new column (variable) + * @param sequenceType the sequence type of the new bound item, not used in case of hash * @param newVariableExpression the expression to evaluate * @param context the context (in addition to each tuple) in which to evaluation the expression * @param variablesInInputTuple the name of the variables that can be found in the input tuple (as opposed to those @@ -523,6 +530,7 @@ public Map getProjection( public static Dataset bindLetVariableInDataFrame( Dataset dataFrame, Name newVariableName, + SequenceType sequenceType, RuntimeIterator newVariableExpression, DynamicContext context, List variablesInInputTuple, @@ -565,13 +573,7 @@ public static Dataset bindLetVariableInDataFrame( ); if (!hash) { - dataFrame.sparkSession() - .udf() - .register( - "letClauseUDF", - new LetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns), - DataTypes.BinaryType - ); + registerLetClauseUDF(dataFrame, newVariableExpression, context, inputSchema, UDFcolumns, sequenceType); } else { dataFrame.sparkSession() .udf() @@ -613,6 +615,58 @@ public static Dataset bindLetVariableInDataFrame( return dataFrame; } + private static void registerLetClauseUDF(Dataset dataFrame, RuntimeIterator newVariableExpression, DynamicContext context, StructType inputSchema, List UDFcolumns, SequenceType sequenceType) { + // for the moment we only consider natively types with single arity (what about optional) + if(sequenceType != null && !sequenceType.isEmptySequence() && sequenceType.getArity().equals(SequenceType.Arity.One)){ + ItemType itemType = sequenceType.getItemType(); + + if(itemType.equals(AtomicItemType.stringItem)){ + dataFrame.sparkSession().udf().register( + "letClauseUDF", + new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns), + DataTypes.StringType + ); + return; + } + + if(itemType.equals(AtomicItemType.integerItem)){ + dataFrame.sparkSession().udf().register( + "letClauseUDF", + new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns), + DataTypes.IntegerType + ); + return; + } + + if(itemType.equals(AtomicItemType.decimalItem)){ + dataFrame.sparkSession().udf().register( + "letClauseUDF", + new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns), + DataTypes.createDecimalType() + ); + return; + } + + if(itemType.equals(AtomicItemType.doubleItem)){ + dataFrame.sparkSession().udf().register( + "letClauseUDF", + new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns), + DataTypes.DoubleType + ); + return; + } + } + + // if it is not one of the allowed sequence type we just return the default udf + dataFrame.sparkSession() + .udf() + .register( + "letClauseUDF", + new LetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns), + DataTypes.BinaryType + ); + } + /** * Try to generate the native query for the let clause and run it, if successful return the resulting dataframe, * otherwise it returns null From 291e260b0cee643806e6af8675d1d38bbdcfb627 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 5 Jan 2021 12:11:01 +0100 Subject: [PATCH 128/206] completed first version of let UDF to native types --- .../flwor/clauses/LetClauseSparkIterator.java | 8 ++++---- .../flwor/udfs/GenericLetClauseUDF.java | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index 173f2afbff..dded1501a6 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -623,7 +623,7 @@ private static void registerLetClauseUDF(Dataset dataFrame, RuntimeIterator if(itemType.equals(AtomicItemType.stringItem)){ dataFrame.sparkSession().udf().register( "letClauseUDF", - new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns), + new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns, "String"), DataTypes.StringType ); return; @@ -632,7 +632,7 @@ private static void registerLetClauseUDF(Dataset dataFrame, RuntimeIterator if(itemType.equals(AtomicItemType.integerItem)){ dataFrame.sparkSession().udf().register( "letClauseUDF", - new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns), + new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns, "Integer"), DataTypes.IntegerType ); return; @@ -641,7 +641,7 @@ private static void registerLetClauseUDF(Dataset dataFrame, RuntimeIterator if(itemType.equals(AtomicItemType.decimalItem)){ dataFrame.sparkSession().udf().register( "letClauseUDF", - new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns), + new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns, "BigDecimal"), DataTypes.createDecimalType() ); return; @@ -650,7 +650,7 @@ private static void registerLetClauseUDF(Dataset dataFrame, RuntimeIterator if(itemType.equals(AtomicItemType.doubleItem)){ dataFrame.sparkSession().udf().register( "letClauseUDF", - new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns), + new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns, "Double"), DataTypes.DoubleType ); return; diff --git a/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java b/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java index 2068603b54..df977ff9da 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java +++ b/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java @@ -5,6 +5,7 @@ import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; +import org.rumbledb.exceptions.OurBadException; import org.rumbledb.runtime.RuntimeIterator; import java.util.ArrayList; @@ -24,11 +25,13 @@ public GenericLetClauseUDF( RuntimeIterator expression, DynamicContext context, StructType schema, - List columnNames + List columnNames, + String classSimpleName ) { this.dataFrameContext = new DataFrameContext(context, schema, columnNames); this.expression = expression; this.nextResult = new ArrayList<>(); + this.classSimpleName = classSimpleName; } @Override @@ -37,12 +40,20 @@ public T call(Row row) { this.expression.materialize(this.dataFrameContext.getContext(), this.nextResult); - return toDFValue(classSimpleName); + return toDFValue(); } // TODO: check if there is a better/safer/faster way to do it @SuppressWarnings("unchecked") - public T toDFValue(String classSimpleName){ - return (T) new Integer(4); + public T toDFValue(){ + // Arity and type check are done by the treat expression that is inserted in the let clause + // when using the 'as' syntax + switch (this.classSimpleName) { + case "String": return (T) this.nextResult.get(0).getStringValue(); + case "Integer": return (T) this.nextResult.get(0).getIntegerValue(); + case "BigDecimal": return (T) this.nextResult.get(0).getDecimalValue(); + case "Double": return (T) (Double) this.nextResult.get(0).getDoubleValue(); + default: throw new OurBadException("Unexpected type in Generic Let UDF"); + } } } From e1a6d137db48bafac8dd7c586e76ca456a167f41 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 11 Jan 2021 14:54:04 +0100 Subject: [PATCH 129/206] fixed special case for integer ordering with native --- .../flwor/clauses/OrderByClauseSparkIterator.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index d44109af4f..851191f206 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -533,7 +533,16 @@ public static Dataset tryNativeQuery( } orderSql.append(orderSeparator); orderSeparator = ", "; - orderSql.append(nativeQuery.getResultingQuery()); + // special check to avoid ordering by an integer constant in an ordering clause + // because of meaning mismatch between sparksql (where it is supposed to order by the i-th col) + // and jsoniq (order by a costant, so no actual ordering is performed) + if(nativeQuery.getResultingQuery().matches("\\s*-?\\s*\\d+\\s*")){ + orderSql.append('"'); + orderSql.append(nativeQuery.getResultingQuery()); + orderSql.append('"'); + } else { + orderSql.append(nativeQuery.getResultingQuery()); + } if (!orderIterator.isAscending()) { orderSql.append(" desc"); } From 98aa1b0410a2c3700dd1a31442fff9961c47b213 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 11 Jan 2021 14:54:34 +0100 Subject: [PATCH 130/206] spotless --- .../flwor/clauses/LetClauseSparkIterator.java | 80 ++++++++++++++----- .../clauses/OrderByClauseSparkIterator.java | 2 +- .../flwor/udfs/GenericLetClauseUDF.java | 17 ++-- 3 files changed, 73 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index dded1501a6..7db92050cf 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -35,7 +35,6 @@ import org.rumbledb.exceptions.UnsupportedFeatureException; import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.expressions.flowr.FLWOR_CLAUSES; -import org.rumbledb.items.AtomicItem; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.RuntimeTupleIterator; import org.rumbledb.runtime.flwor.FlworDataFrameUtils; @@ -615,44 +614,87 @@ public static Dataset bindLetVariableInDataFrame( return dataFrame; } - private static void registerLetClauseUDF(Dataset dataFrame, RuntimeIterator newVariableExpression, DynamicContext context, StructType inputSchema, List UDFcolumns, SequenceType sequenceType) { + private static void registerLetClauseUDF( + Dataset dataFrame, + RuntimeIterator newVariableExpression, + DynamicContext context, + StructType inputSchema, + List UDFcolumns, + SequenceType sequenceType + ) { // for the moment we only consider natively types with single arity (what about optional) - if(sequenceType != null && !sequenceType.isEmptySequence() && sequenceType.getArity().equals(SequenceType.Arity.One)){ + if ( + sequenceType != null + && !sequenceType.isEmptySequence() + && sequenceType.getArity().equals(SequenceType.Arity.One) + ) { ItemType itemType = sequenceType.getItemType(); - if(itemType.equals(AtomicItemType.stringItem)){ - dataFrame.sparkSession().udf().register( + if (itemType.equals(AtomicItemType.stringItem)) { + dataFrame.sparkSession() + .udf() + .register( "letClauseUDF", - new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns, "String"), + new GenericLetClauseUDF( + newVariableExpression, + context, + inputSchema, + UDFcolumns, + "String" + ), DataTypes.StringType - ); + ); return; } - if(itemType.equals(AtomicItemType.integerItem)){ - dataFrame.sparkSession().udf().register( + if (itemType.equals(AtomicItemType.integerItem)) { + dataFrame.sparkSession() + .udf() + .register( "letClauseUDF", - new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns, "Integer"), + new GenericLetClauseUDF( + newVariableExpression, + context, + inputSchema, + UDFcolumns, + "Integer" + ), DataTypes.IntegerType - ); + ); return; } - if(itemType.equals(AtomicItemType.decimalItem)){ - dataFrame.sparkSession().udf().register( + if (itemType.equals(AtomicItemType.decimalItem)) { + dataFrame.sparkSession() + .udf() + .register( "letClauseUDF", - new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns, "BigDecimal"), + new GenericLetClauseUDF( + newVariableExpression, + context, + inputSchema, + UDFcolumns, + "BigDecimal" + ), DataTypes.createDecimalType() - ); + ); return; } - if(itemType.equals(AtomicItemType.doubleItem)){ - dataFrame.sparkSession().udf().register( + if (itemType.equals(AtomicItemType.doubleItem)) { + dataFrame.sparkSession() + .udf() + .register( "letClauseUDF", - new GenericLetClauseUDF(newVariableExpression, context, inputSchema, UDFcolumns, "Double"), + new GenericLetClauseUDF( + newVariableExpression, + context, + inputSchema, + UDFcolumns, + "Double" + ), DataTypes.DoubleType - ); + ); return; } } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index 851191f206..3981faa425 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -536,7 +536,7 @@ public static Dataset tryNativeQuery( // special check to avoid ordering by an integer constant in an ordering clause // because of meaning mismatch between sparksql (where it is supposed to order by the i-th col) // and jsoniq (order by a costant, so no actual ordering is performed) - if(nativeQuery.getResultingQuery().matches("\\s*-?\\s*\\d+\\s*")){ + if (nativeQuery.getResultingQuery().matches("\\s*-?\\s*\\d+\\s*")) { orderSql.append('"'); orderSql.append(nativeQuery.getResultingQuery()); orderSql.append('"'); diff --git a/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java b/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java index df977ff9da..1c461ee0c1 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java +++ b/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java @@ -45,15 +45,20 @@ public T call(Row row) { // TODO: check if there is a better/safer/faster way to do it @SuppressWarnings("unchecked") - public T toDFValue(){ + public T toDFValue() { // Arity and type check are done by the treat expression that is inserted in the let clause // when using the 'as' syntax switch (this.classSimpleName) { - case "String": return (T) this.nextResult.get(0).getStringValue(); - case "Integer": return (T) this.nextResult.get(0).getIntegerValue(); - case "BigDecimal": return (T) this.nextResult.get(0).getDecimalValue(); - case "Double": return (T) (Double) this.nextResult.get(0).getDoubleValue(); - default: throw new OurBadException("Unexpected type in Generic Let UDF"); + case "String": + return (T) this.nextResult.get(0).getStringValue(); + case "Integer": + return (T) this.nextResult.get(0).getIntegerValue(); + case "BigDecimal": + return (T) this.nextResult.get(0).getDecimalValue(); + case "Double": + return (T) (Double) this.nextResult.get(0).getDoubleValue(); + default: + throw new OurBadException("Unexpected type in Generic Let UDF"); } } } From 82c225c91c9c49b8225d0f295a0d1cae80cca16a Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 11 Jan 2021 17:45:20 +0100 Subject: [PATCH 131/206] fixed biginteger to int conversion issue on generic let udf --- .../org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java b/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java index 1c461ee0c1..196318d4fa 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java +++ b/src/main/java/org/rumbledb/runtime/flwor/udfs/GenericLetClauseUDF.java @@ -52,7 +52,8 @@ public T toDFValue() { case "String": return (T) this.nextResult.get(0).getStringValue(); case "Integer": - return (T) this.nextResult.get(0).getIntegerValue(); + // TODO: watch out for big integers + return (T) (Integer) this.nextResult.get(0).getIntegerValue().intValue(); case "BigDecimal": return (T) this.nextResult.get(0).getDecimalValue(); case "Double": From 9597026584cfee4dfc3961848cc08b688ae8d13e Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 13 Jan 2021 09:46:13 +0100 Subject: [PATCH 132/206] setup new test for native flwor optimization --- src/test/java/iq/NativeFLWORRuntimeTests.java | 66 +++++++++++++++++++ src/test/resources/queries/denormalized2.json | 28 ++++++++ .../runtime-native-flwor/let/let1.jq | 4 ++ 3 files changed, 98 insertions(+) create mode 100644 src/test/java/iq/NativeFLWORRuntimeTests.java create mode 100644 src/test/resources/queries/denormalized2.json create mode 100644 src/test/resources/test_files/runtime-native-flwor/let/let1.jq diff --git a/src/test/java/iq/NativeFLWORRuntimeTests.java b/src/test/java/iq/NativeFLWORRuntimeTests.java new file mode 100644 index 0000000000..eeacbb8259 --- /dev/null +++ b/src/test/java/iq/NativeFLWORRuntimeTests.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Authors: Stefan Irimescu, Can Berker Cikis + * + */ + +package iq; + +import org.junit.Assert; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.rumbledb.api.SequenceOfItems; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +@RunWith(Parameterized.class) +public class NativeFLWORRuntimeTests extends RuntimeTests { + + public static final File nativeFlworRuntimeTestsDirectory = new File( + System.getProperty("user.dir") + + + "/src/test/resources/test_files/runtime-native-flwor" + ); + + public NativeFLWORRuntimeTests(File testFile) { + super(testFile); + } + + @Parameterized.Parameters(name = "{index}:{0}") + public static Collection testFiles() { + List result = new ArrayList<>(); + _testFiles.clear(); + readFileList(nativeFlworRuntimeTestsDirectory); + _testFiles.forEach(file -> result.add(new Object[] { file })); + return result; + } + + @Override + protected void checkExpectedOutput( + String expectedOutput, + SequenceOfItems sequence + ) { + String actualOutput = runIterators(sequence); + Assert.assertTrue( + "Expected output: " + expectedOutput + " Actual result: " + actualOutput, + expectedOutput.equals(actualOutput) + ); + } +} diff --git a/src/test/resources/queries/denormalized2.json b/src/test/resources/queries/denormalized2.json new file mode 100644 index 0000000000..aa910c09a2 --- /dev/null +++ b/src/test/resources/queries/denormalized2.json @@ -0,0 +1,28 @@ +{ "foo" : [ { "bar" : [ { "foobar" : 1 } , { "foobar" : 1 } ], "foobar" : 2 }, { "bar" : [ { "foobar" : 3 } , { "foobar" : 3 } ], "foobar" : 4 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 5 } , { "foobar" : 5 } ], "foobar" : 6 } ] } +{ "foo" : [ ] } +{ "foo" : [ { "bar" : [ { "foobar" : 7 } , { "foobar" : 7 } ], "foobar" : 8 }, { "bar" : [ { "foobar" : 9 } , { "foobar" : 9 } ], "foobar" : 10 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 1 } , { "foobar" : 1 } ], "foobar" : 2 }, { "bar" : [ { "foobar" : 3 } , { "foobar" : 3 } ], "foobar" : 4 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 5 } , { "foobar" : 5 } ], "foobar" : 6 } ] } +{ "foo" : [ ] } +{ "foo" : [ { "bar" : [ { "foobar" : 7 } , { "foobar" : 7 } ], "foobar" : 8 }, { "bar" : [ { "foobar" : 9 } , { "foobar" : 9 } ], "foobar" : 10 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 1 } , { "foobar" : 1 } ], "foobar" : 2 }, { "bar" : [ { "foobar" : 3 } , { "foobar" : 3 } ], "foobar" : 4 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 5 } , { "foobar" : 5 } ], "foobar" : 6 } ] } +{ "foo" : [ ] } +{ "foo" : [ { "bar" : [ { "foobar" : 7 } , { "foobar" : 7 } ], "foobar" : 8 }, { "bar" : [ { "foobar" : 9 } , { "foobar" : 9 } ], "foobar" : 10 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 1 } , { "foobar" : 1 } ], "foobar" : 2 }, { "bar" : [ { "foobar" : 3 } , { "foobar" : 3 } ], "foobar" : 4 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 5 } , { "foobar" : 5 } ], "foobar" : 6 } ] } +{ "foo" : [ ] } +{ "foo" : [ { "bar" : [ { "foobar" : 7 } , { "foobar" : 7 } ], "foobar" : 8 }, { "bar" : [ { "foobar" : 9 } , { "foobar" : 9 } ], "foobar" : 10 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 1 } , { "foobar" : 1 } ], "foobar" : 2 }, { "bar" : [ { "foobar" : 3 } , { "foobar" : 3 } ], "foobar" : 4 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 5 } , { "foobar" : 5 } ], "foobar" : 6 } ] } +{ "foo" : [ ] } +{ "foo" : [ { "bar" : [ { "foobar" : 7 } , { "foobar" : 7 } ], "foobar" : 8 }, { "bar" : [ { "foobar" : 9 } , { "foobar" : 9 } ], "foobar" : 10 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 1 } , { "foobar" : 1 } ], "foobar" : 2 }, { "bar" : [ { "foobar" : 3 } , { "foobar" : 3 } ], "foobar" : 4 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 5 } , { "foobar" : 5 } ], "foobar" : 6 } ] } +{ "foo" : [ ] } +{ "foo" : [ { "bar" : [ { "foobar" : 7 } , { "foobar" : 7 } ], "foobar" : 8 }, { "bar" : [ { "foobar" : 9 } , { "foobar" : 9 } ], "foobar" : 10 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 1 } , { "foobar" : 1 } ], "foobar" : 2 }, { "bar" : [ { "foobar" : 3 } , { "foobar" : 3 } ], "foobar" : 4 } ] } +{ "foo" : [ { "bar" : [ { "foobar" : 5 } , { "foobar" : 5 } ], "foobar" : 6 } ] } +{ "foo" : [ ] } +{ "foo" : [ { "bar" : [ { "foobar" : 7 } , { "foobar" : 7 } ], "foobar" : 8 }, { "bar" : [ { "foobar" : 9 } , { "foobar" : 9 } ], "foobar" : 10 } ] } diff --git a/src/test/resources/test_files/runtime-native-flwor/let/let1.jq b/src/test/resources/test_files/runtime-native-flwor/let/let1.jq new file mode 100644 index 0000000000..60302f3eed --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/let/let1.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="(Latvian, Russian, Czech, Greek, Serbian)" :) +for $i in structured-json-file("../../../queries/conf-ex.json") +let $g := $i.guess +return $g \ No newline at end of file From b64ac0e642f01ba2a175fb81d09dcf5b07c83e4c Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 13 Jan 2021 11:14:24 +0100 Subject: [PATCH 133/206] arrayunboxing tests --- .../test_files/runtime-native-flwor/array-unboxing/au1.jq | 4 ++++ .../test_files/runtime-native-flwor/array-unboxing/au10.jq | 5 +++++ .../test_files/runtime-native-flwor/array-unboxing/au11.jq | 5 +++++ .../test_files/runtime-native-flwor/array-unboxing/au12.jq | 6 ++++++ .../test_files/runtime-native-flwor/array-unboxing/au2.jq | 4 ++++ .../test_files/runtime-native-flwor/array-unboxing/au3.jq | 4 ++++ .../test_files/runtime-native-flwor/array-unboxing/au4.jq | 4 ++++ .../test_files/runtime-native-flwor/array-unboxing/au5.jq | 4 ++++ .../test_files/runtime-native-flwor/array-unboxing/au6.jq | 4 ++++ .../test_files/runtime-native-flwor/array-unboxing/au7.jq | 4 ++++ .../test_files/runtime-native-flwor/array-unboxing/au8.jq | 4 ++++ .../test_files/runtime-native-flwor/array-unboxing/au9.jq | 4 ++++ 12 files changed, 52 insertions(+) create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-unboxing/au1.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-unboxing/au10.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-unboxing/au11.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-unboxing/au12.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-unboxing/au2.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-unboxing/au3.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-unboxing/au4.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-unboxing/au5.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-unboxing/au6.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-unboxing/au7.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-unboxing/au8.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-unboxing/au9.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au1.jq b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au1.jq new file mode 100644 index 0000000000..495598a6c5 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au1.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="(Latvian, Nepali, Czech, Greek, Serbian)" :) +for $i in structured-json-file("../../../queries/conf-ex.json") +let $c := $i.choices[[2]] +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au10.jq b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au10.jq new file mode 100644 index 0000000000..2e3703aef4 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au10.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldRun; Output="(Russian, Russian, Korean, Kannada, Sinhalese)" :) +declare variable $idx := 3; +for $i in structured-json-file("../../../queries/conf-ex.json") +let $c := $i.choices[[$idx]] +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au11.jq b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au11.jq new file mode 100644 index 0000000000..1141515b3a --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au11.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldRun; Output="(Latvian, Nepali, Czech, Greek, Serbian)" :) +declare variable $idx := 3; +for $i in structured-json-file("../../../queries/conf-ex.json") +let $c := $i.choices[[$idx - 1]] +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au12.jq b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au12.jq new file mode 100644 index 0000000000..54954274e9 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au12.jq @@ -0,0 +1,6 @@ +(:JIQS: ShouldRun; Output="(Lao, Croatian, Maori, German, Dari, Russian, Russian, Korean, Kannada, Sinhalese)" :) +for $idx in (1,3,5) +return +for $i in structured-json-file("../../../queries/conf-ex.json") +let $c := $i.choices[[$idx]] +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au2.jq b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au2.jq new file mode 100644 index 0000000000..ca93070de2 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au2.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="" :) +for $i in structured-json-file("../../../queries/conf-ex.json") +let $c := $i.choices[[20]] +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au3.jq b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au3.jq new file mode 100644 index 0000000000..0664eaa38b --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au3.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="({ "bar" : 3, "foobar" : 4 }, { "bar" : 9, "foobar" : 10 }, { "bar" : 3, "foobar" : 4 }, { "bar" : 9, "foobar" : 10 }, { "bar" : 3, "foobar" : 4 }, { "bar" : 9, "foobar" : 10 }, { "bar" : 3, "foobar" : 4 }, { "bar" : 9, "foobar" : 10 }, { "bar" : 3, "foobar" : 4 }, { "bar" : 9, "foobar" : 10 }, { "bar" : 3, "foobar" : 4 }, { "bar" : 9, "foobar" : 10 }, { "bar" : 3, "foobar" : 4 }, { "bar" : 9, "foobar" : 10 })" :) +for $i in structured-json-file("../../../queries/denormalized.json") +let $c := $i.foo[[2]] +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au4.jq b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au4.jq new file mode 100644 index 0000000000..a6f620937d --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au4.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="(3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9)" :) +for $i in structured-json-file("../../../queries/denormalized.json") +let $c := $i.foo[[2]].bar +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au5.jq b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au5.jq new file mode 100644 index 0000000000..0dfb44efc7 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au5.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="({ "foobar" : 3 }, { "foobar" : 9 }, { "foobar" : 3 }, { "foobar" : 9 }, { "foobar" : 3 }, { "foobar" : 9 }, { "foobar" : 3 }, { "foobar" : 9 }, { "foobar" : 3 }, { "foobar" : 9 }, { "foobar" : 3 }, { "foobar" : 9 }, { "foobar" : 3 }, { "foobar" : 9 })" :) +for $i in structured-json-file("../../../queries/denormalized2.json") +let $c := $i.foo[[2]].bar[[1]] +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au6.jq b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au6.jq new file mode 100644 index 0000000000..0a60684bc6 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au6.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="" :) +for $i in structured-json-file("../../../queries/denormalized2.json") +let $c := $i.foo[[2]].bar[[20]] +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au7.jq b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au7.jq new file mode 100644 index 0000000000..f1745ed9d6 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au7.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="" :) +for $i in structured-json-file("../../../queries/denormalized2.json") +let $c := $i.foo[[20]].bar[[1]] +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au8.jq b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au8.jq new file mode 100644 index 0000000000..a06c65c572 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au8.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="(3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9)" :) +for $i in structured-json-file("../../../queries/denormalized2.json") +let $c := $i.foo[[2]].bar[[1]].foobar +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au9.jq b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au9.jq new file mode 100644 index 0000000000..031bd04963 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au9.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="(Russian, Russian, Korean, Kannada, Sinhalese)" :) +for $i in structured-json-file("../../../queries/conf-ex.json") +let $c := $i.choices[[2 * 2 - 1]] +return $c \ No newline at end of file From d36a738ef3c6dbdf66383c0a9128145757a24a0d Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 13 Jan 2021 15:39:09 +0100 Subject: [PATCH 134/206] actually it was array lookups --- .../{array-unboxing/au1.jq => array-lookup/al1.jq} | 0 .../{array-unboxing/au10.jq => array-lookup/al10.jq} | 0 .../{array-unboxing/au11.jq => array-lookup/al11.jq} | 0 .../{array-unboxing/au12.jq => array-lookup/al12.jq} | 0 .../{array-unboxing/au2.jq => array-lookup/al2.jq} | 0 .../{array-unboxing/au3.jq => array-lookup/al3.jq} | 0 .../{array-unboxing/au4.jq => array-lookup/al4.jq} | 0 .../{array-unboxing/au5.jq => array-lookup/al5.jq} | 0 .../{array-unboxing/au6.jq => array-lookup/al6.jq} | 0 .../{array-unboxing/au7.jq => array-lookup/al7.jq} | 0 .../{array-unboxing/au8.jq => array-lookup/al8.jq} | 0 .../{array-unboxing/au9.jq => array-lookup/al9.jq} | 0 12 files changed, 0 insertions(+), 0 deletions(-) rename src/test/resources/test_files/runtime-native-flwor/{array-unboxing/au1.jq => array-lookup/al1.jq} (100%) rename src/test/resources/test_files/runtime-native-flwor/{array-unboxing/au10.jq => array-lookup/al10.jq} (100%) rename src/test/resources/test_files/runtime-native-flwor/{array-unboxing/au11.jq => array-lookup/al11.jq} (100%) rename src/test/resources/test_files/runtime-native-flwor/{array-unboxing/au12.jq => array-lookup/al12.jq} (100%) rename src/test/resources/test_files/runtime-native-flwor/{array-unboxing/au2.jq => array-lookup/al2.jq} (100%) rename src/test/resources/test_files/runtime-native-flwor/{array-unboxing/au3.jq => array-lookup/al3.jq} (100%) rename src/test/resources/test_files/runtime-native-flwor/{array-unboxing/au4.jq => array-lookup/al4.jq} (100%) rename src/test/resources/test_files/runtime-native-flwor/{array-unboxing/au5.jq => array-lookup/al5.jq} (100%) rename src/test/resources/test_files/runtime-native-flwor/{array-unboxing/au6.jq => array-lookup/al6.jq} (100%) rename src/test/resources/test_files/runtime-native-flwor/{array-unboxing/au7.jq => array-lookup/al7.jq} (100%) rename src/test/resources/test_files/runtime-native-flwor/{array-unboxing/au8.jq => array-lookup/al8.jq} (100%) rename src/test/resources/test_files/runtime-native-flwor/{array-unboxing/au9.jq => array-lookup/al9.jq} (100%) diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au1.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al1.jq similarity index 100% rename from src/test/resources/test_files/runtime-native-flwor/array-unboxing/au1.jq rename to src/test/resources/test_files/runtime-native-flwor/array-lookup/al1.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au10.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al10.jq similarity index 100% rename from src/test/resources/test_files/runtime-native-flwor/array-unboxing/au10.jq rename to src/test/resources/test_files/runtime-native-flwor/array-lookup/al10.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au11.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al11.jq similarity index 100% rename from src/test/resources/test_files/runtime-native-flwor/array-unboxing/au11.jq rename to src/test/resources/test_files/runtime-native-flwor/array-lookup/al11.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au12.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al12.jq similarity index 100% rename from src/test/resources/test_files/runtime-native-flwor/array-unboxing/au12.jq rename to src/test/resources/test_files/runtime-native-flwor/array-lookup/al12.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au2.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al2.jq similarity index 100% rename from src/test/resources/test_files/runtime-native-flwor/array-unboxing/au2.jq rename to src/test/resources/test_files/runtime-native-flwor/array-lookup/al2.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au3.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al3.jq similarity index 100% rename from src/test/resources/test_files/runtime-native-flwor/array-unboxing/au3.jq rename to src/test/resources/test_files/runtime-native-flwor/array-lookup/al3.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au4.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al4.jq similarity index 100% rename from src/test/resources/test_files/runtime-native-flwor/array-unboxing/au4.jq rename to src/test/resources/test_files/runtime-native-flwor/array-lookup/al4.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au5.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al5.jq similarity index 100% rename from src/test/resources/test_files/runtime-native-flwor/array-unboxing/au5.jq rename to src/test/resources/test_files/runtime-native-flwor/array-lookup/al5.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au6.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al6.jq similarity index 100% rename from src/test/resources/test_files/runtime-native-flwor/array-unboxing/au6.jq rename to src/test/resources/test_files/runtime-native-flwor/array-lookup/al6.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au7.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al7.jq similarity index 100% rename from src/test/resources/test_files/runtime-native-flwor/array-unboxing/au7.jq rename to src/test/resources/test_files/runtime-native-flwor/array-lookup/al7.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au8.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al8.jq similarity index 100% rename from src/test/resources/test_files/runtime-native-flwor/array-unboxing/au8.jq rename to src/test/resources/test_files/runtime-native-flwor/array-lookup/al8.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-unboxing/au9.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al9.jq similarity index 100% rename from src/test/resources/test_files/runtime-native-flwor/array-unboxing/au9.jq rename to src/test/resources/test_files/runtime-native-flwor/array-lookup/al9.jq From 876dcb341ca0783adb3c00623665be0a80add452 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 13 Jan 2021 16:37:17 +0100 Subject: [PATCH 135/206] added object-lookup tests --- src/test/resources/queries/difficult-names.json | 2 ++ .../test_files/runtime-native-flwor/object-lookup/ol1.jq | 4 ++++ .../test_files/runtime-native-flwor/object-lookup/ol10.jq | 5 +++++ .../test_files/runtime-native-flwor/object-lookup/ol11.jq | 5 +++++ .../test_files/runtime-native-flwor/object-lookup/ol12.jq | 6 ++++++ .../test_files/runtime-native-flwor/object-lookup/ol13.jq | 5 +++++ .../test_files/runtime-native-flwor/object-lookup/ol2.jq | 4 ++++ .../test_files/runtime-native-flwor/object-lookup/ol3.jq | 4 ++++ .../test_files/runtime-native-flwor/object-lookup/ol4.jq | 4 ++++ .../test_files/runtime-native-flwor/object-lookup/ol5.jq | 4 ++++ .../test_files/runtime-native-flwor/object-lookup/ol6.jq | 4 ++++ .../test_files/runtime-native-flwor/object-lookup/ol7.jq | 4 ++++ .../test_files/runtime-native-flwor/object-lookup/ol8.jq | 4 ++++ .../test_files/runtime-native-flwor/object-lookup/ol9.jq | 4 ++++ 14 files changed, 59 insertions(+) create mode 100644 src/test/resources/queries/difficult-names.json create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol1.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol10.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol11.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol12.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol13.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol2.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol3.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol4.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol5.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol6.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol7.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol8.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol9.jq diff --git a/src/test/resources/queries/difficult-names.json b/src/test/resources/queries/difficult-names.json new file mode 100644 index 0000000000..ef2905ee83 --- /dev/null +++ b/src/test/resources/queries/difficult-names.json @@ -0,0 +1,2 @@ +{"1": "one", "include spaces": "impressive", "quotes\"": "very tricky", "keyToUse" : "1"} +{"1": "two", "include spaces": "amazing", "quotes\"": "unexpected", "keyToUse" : "include spaces"} \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol1.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol1.jq new file mode 100644 index 0000000000..b203110f0b --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol1.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="(Russian, Russian, Czech, Serbian, Serbian)" :) +for $i in structured-json-file("../../../queries/conf-ex.json") +let $c := $i.target +return $c diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol10.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol10.jq new file mode 100644 index 0000000000..4de8a809ff --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol10.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldRun; Output="(Russian, Russian, Czech, Serbian, Serbian)" :) +declare variable $k := "target"; +for $i in structured-json-file("../../../queries/conf-ex.json") +let $c := $i.$k +return $c diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol11.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol11.jq new file mode 100644 index 0000000000..a81215947b --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol11.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldRun; Output="(Russian, Russian, Czech, Serbian, Serbian)" :) +declare variable $k := "target"; +for $i in structured-json-file("../../../queries/conf-ex.json") +let $c := $i.($k) +return $c diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol12.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol12.jq new file mode 100644 index 0000000000..ca028cf8e9 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol12.jq @@ -0,0 +1,6 @@ +(:JIQS: ShouldRun; Output="(Latvian, Russian, Czech, Greek, Serbian, Russian, Russian, Czech, Serbian, Serbian)" :) +for $k in ("guess", "target", "missing") +return +for $i in structured-json-file("../../../queries/conf-ex.json") +let $c := $i.$k +return $c diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol13.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol13.jq new file mode 100644 index 0000000000..9232a784b2 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol13.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldRun; Output="(one, amazing)" :) +for $i in structured-json-file("../../../queries/difficult-names.json") +let $k := $i.keyToUse +let $c := $i.$k +return $c diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol2.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol2.jq new file mode 100644 index 0000000000..35c29a455a --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol2.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="([ "Lao", "Latvian", "Russian", "Swahili" ], [ "Croatian", "Nepali", "Russian", "Slovenian" ], [ "Maori", "Czech", "Korean", "Turkish" ], [ "German", "Greek", "Kannada", "Serbian" ], [ "Dari", "Serbian", "Sinhalese", "Vietnamese" ])" :) +for $i in structured-json-file("../../../queries/conf-ex.json") +let $c := $i.choices +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol3.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol3.jq new file mode 100644 index 0000000000..27b62d69d2 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol3.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="" :) +for $i in structured-json-file("../../../queries/denormalized.json") +let $c := $i.foo[[200]].bar +return $c diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol4.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol4.jq new file mode 100644 index 0000000000..69d78c93fe --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol4.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="" :) +for $i in structured-json-file("../../../queries/denormalized.json") +let $c := $i.wrongkey +return $c diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol5.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol5.jq new file mode 100644 index 0000000000..1723a8f2fd --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol5.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="([ { "bar" : 1, "foobar" : 2 }, { "bar" : 3, "foobar" : 4 } ], [ { "bar" : 5, "foobar" : 6 } ], [ ], [ { "bar" : 7, "foobar" : 8 }, { "bar" : 9, "foobar" : 10 } ], [ { "bar" : 1, "foobar" : 2 }, { "bar" : 3, "foobar" : 4 } ], [ { "bar" : 5, "foobar" : 6 } ], [ ], [ { "bar" : 7, "foobar" : 8 }, { "bar" : 9, "foobar" : 10 } ], [ { "bar" : 1, "foobar" : 2 }, { "bar" : 3, "foobar" : 4 } ], [ { "bar" : 5, "foobar" : 6 } ], [ ], [ { "bar" : 7, "foobar" : 8 }, { "bar" : 9, "foobar" : 10 } ], [ { "bar" : 1, "foobar" : 2 }, { "bar" : 3, "foobar" : 4 } ], [ { "bar" : 5, "foobar" : 6 } ], [ ], [ { "bar" : 7, "foobar" : 8 }, { "bar" : 9, "foobar" : 10 } ], [ { "bar" : 1, "foobar" : 2 }, { "bar" : 3, "foobar" : 4 } ], [ { "bar" : 5, "foobar" : 6 } ], [ ], [ { "bar" : 7, "foobar" : 8 }, { "bar" : 9, "foobar" : 10 } ], [ { "bar" : 1, "foobar" : 2 }, { "bar" : 3, "foobar" : 4 } ], [ { "bar" : 5, "foobar" : 6 } ], [ ], [ { "bar" : 7, "foobar" : 8 }, { "bar" : 9, "foobar" : 10 } ], [ { "bar" : 1, "foobar" : 2 }, { "bar" : 3, "foobar" : 4 } ], [ { "bar" : 5, "foobar" : 6 } ], [ ], [ { "bar" : 7, "foobar" : 8 }, { "bar" : 9, "foobar" : 10 } ])" :) +for $i in structured-json-file("../../../queries/denormalized.json") +let $c := $i.("fo" || "o") +return $c diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol6.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol6.jq new file mode 100644 index 0000000000..32720ecfb5 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol6.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="(impressive, amazing)" :) +for $i in structured-json-file("../../../queries/difficult-names.json") +let $c := $i."include spaces" +return $c diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol7.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol7.jq new file mode 100644 index 0000000000..99ab6462fc --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol7.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="(very tricky, unexpected)" :) +for $i in structured-json-file("../../../queries/difficult-names.json") +let $c := $i."quotes\"" +return $c diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol8.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol8.jq new file mode 100644 index 0000000000..b8a898b371 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol8.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="(one, two)" :) +for $i in structured-json-file("../../../queries/difficult-names.json") +let $c := $i."1" +return $c diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol9.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol9.jq new file mode 100644 index 0000000000..77db028e65 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol9.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="(one, two)" :) +for $i in structured-json-file("../../../queries/difficult-names.json") +let $c := $i.(1) +return $c From 630fd699f92c88b24930e81a352fabc39b35b5fa Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 13 Jan 2021 17:16:28 +0100 Subject: [PATCH 136/206] fix on escaping native object lookup, added backtick test --- .../org/rumbledb/runtime/postfix/ObjectLookupIterator.java | 2 +- src/test/resources/queries/backtick.json | 2 ++ .../test_files/runtime-native-flwor/object-lookup/ol14.jq | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/queries/backtick.json create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol14.jq diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index 2a1529cc63..685360a24b 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -229,7 +229,7 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC } StructType structSchema = (StructType) schema; if (Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(key))) { - newContext.setResultingQuery(newContext.getResultingQuery() + "." + key); + newContext.setResultingQuery(newContext.getResultingQuery() + ".`" + key + "`"); StructField field = structSchema.fields()[structSchema.fieldIndex(key)]; newContext.setSchema(field.dataType()); } else { diff --git a/src/test/resources/queries/backtick.json b/src/test/resources/queries/backtick.json new file mode 100644 index 0000000000..873e5f8938 --- /dev/null +++ b/src/test/resources/queries/backtick.json @@ -0,0 +1,2 @@ +{"backtick`" : "oh cmon"} +{"backtick`" : "why?"} \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol14.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol14.jq new file mode 100644 index 0000000000..3d8d53358c --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol14.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldRun; Output="(oh cmon, why)" :) +for $i in structured-json-file("../../../queries/backtick.json") +let $c := $i."backtick`" +return $c From bbc11305b064daada719300f69cc27400befbadb Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 13 Jan 2021 19:35:48 +0100 Subject: [PATCH 137/206] fixed dynamic variable reference in lokups --- .../runtime/postfix/ArrayLookupIterator.java | 14 +++++++------- .../runtime/postfix/ObjectLookupIterator.java | 14 +++++++------- src/test/resources/queries/difficult-names.json | 4 ++-- .../runtime-native-flwor/array-lookup/al13.jq | 5 +++++ 4 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-lookup/al13.jq diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java index 8952fd1eed..1d42084793 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java @@ -30,12 +30,7 @@ import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; -import org.rumbledb.exceptions.ExceptionMetadata; -import org.rumbledb.exceptions.InvalidSelectorException; -import org.rumbledb.exceptions.IteratorFlowException; -import org.rumbledb.exceptions.MoreThanOneItemException; -import org.rumbledb.exceptions.NoItemException; -import org.rumbledb.exceptions.UnexpectedTypeException; +import org.rumbledb.exceptions.*; import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; @@ -165,7 +160,12 @@ public boolean implementsDataFrames() { public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); if (newContext != NativeClauseContext.NoNativeQuery) { - initLookupPosition(newContext.getContext()); + try { + initLookupPosition(newContext.getContext()); + } catch (RumbleException e){ + return NativeClauseContext.NoNativeQuery; + } + DataType schema = newContext.getSchema(); if (!(schema instanceof ArrayType)) { return NativeClauseContext.NoNativeQuery; diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index 685360a24b..fd223a7cbe 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -30,12 +30,7 @@ import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; import org.rumbledb.context.Name; -import org.rumbledb.exceptions.ExceptionMetadata; -import org.rumbledb.exceptions.InvalidSelectorException; -import org.rumbledb.exceptions.IteratorFlowException; -import org.rumbledb.exceptions.MoreThanOneItemException; -import org.rumbledb.exceptions.NoItemException; -import org.rumbledb.exceptions.UnexpectedTypeException; +import org.rumbledb.exceptions.*; import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.HybridRuntimeIterator; @@ -221,7 +216,12 @@ public boolean implementsDataFrames() { public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); if (newContext != NativeClauseContext.NoNativeQuery) { - initLookupKey(newContext.getContext()); + try { + initLookupKey(newContext.getContext()); + } catch (RumbleException e){ + return NativeClauseContext.NoNativeQuery; + } + String key = this.lookupKey.getStringValue(); DataType schema = newContext.getSchema(); if (!(schema instanceof StructType)) { diff --git a/src/test/resources/queries/difficult-names.json b/src/test/resources/queries/difficult-names.json index ef2905ee83..4d6c261736 100644 --- a/src/test/resources/queries/difficult-names.json +++ b/src/test/resources/queries/difficult-names.json @@ -1,2 +1,2 @@ -{"1": "one", "include spaces": "impressive", "quotes\"": "very tricky", "keyToUse" : "1"} -{"1": "two", "include spaces": "amazing", "quotes\"": "unexpected", "keyToUse" : "include spaces"} \ No newline at end of file +{"1": "one", "include spaces": "impressive", "quotes\"": "very tricky", "keyToUse" : "1", "indexToUse" : 1, "a": [10,20] } +{"1": "two", "include spaces": "amazing", "quotes\"": "unexpected", "keyToUse" : "include spaces", "indexToUse" : 2, "a": [10,20] } \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/array-lookup/al13.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al13.jq new file mode 100644 index 0000000000..06e8d6b630 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al13.jq @@ -0,0 +1,5 @@ +(:JIQS: ShouldRun; Output="(10, 20)" :) +for $i in structured-json-file("../../../queries/difficult-names.json") +let $k := $i.indexToUse +let $c := $i.a[[$k]] +return $c \ No newline at end of file From f97056e01b34723a3a014c9664a732146437362e Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 13 Jan 2021 22:36:57 +0100 Subject: [PATCH 138/206] fixed case of variable redeclaration checking on flwor clause schema --- .../runtime/postfix/ArrayLookupIterator.java | 21 +++++++++++++----- .../runtime/postfix/ObjectLookupIterator.java | 22 ++++++++++++++----- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java index 1d42084793..88ccce258a 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java @@ -30,6 +30,7 @@ import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; import org.rumbledb.context.DynamicContext; +import org.rumbledb.context.Name; import org.rumbledb.exceptions.*; import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.runtime.HybridRuntimeIterator; @@ -39,6 +40,7 @@ import sparksoniq.spark.SparkSessionManager; import java.util.Arrays; +import java.util.Map; public class ArrayLookupIterator extends HybridRuntimeIterator { @@ -160,13 +162,22 @@ public boolean implementsDataFrames() { public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); if (newContext != NativeClauseContext.NoNativeQuery) { - try { - initLookupPosition(newContext.getContext()); - } catch (RumbleException e){ - return NativeClauseContext.NoNativeQuery; + // check if the key has variable dependencies inside the FLWOR expression + // in that case we switch over to UDF + Map keyDependencies = this.children.get(1).getVariableDependencies(); + // we use nativeClauseContext that contains the top level schema + DataType schema = nativeClauseContext.getSchema(); + StructType structSchema; + if (schema instanceof StructType) { + structSchema = (StructType) schema; + if(Arrays.stream(structSchema.fieldNames()).anyMatch(field -> keyDependencies.containsKey(Name.createVariableInNoNamespace(field)))){ + return NativeClauseContext.NoNativeQuery; + } } - DataType schema = newContext.getSchema(); + initLookupPosition(newContext.getContext()); + + schema = newContext.getSchema(); if (!(schema instanceof ArrayType)) { return NativeClauseContext.NoNativeQuery; } diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index fd223a7cbe..d8b8e6e725 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -43,6 +43,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.Arrays; +import java.util.Map; public class ObjectLookupIterator extends HybridRuntimeIterator { @@ -216,18 +217,27 @@ public boolean implementsDataFrames() { public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { NativeClauseContext newContext = this.iterator.generateNativeQuery(nativeClauseContext); if (newContext != NativeClauseContext.NoNativeQuery) { - try { - initLookupKey(newContext.getContext()); - } catch (RumbleException e){ - return NativeClauseContext.NoNativeQuery; + // check if the key has variable dependencies inside the FLWOR expression + // in that case we switch over to UDF + Map keyDependencies = this.children.get(1).getVariableDependencies(); + // we use nativeClauseContext that contains the top level schema + DataType schema = nativeClauseContext.getSchema(); + StructType structSchema; + if (schema instanceof StructType) { + structSchema = (StructType) schema; + if(Arrays.stream(structSchema.fieldNames()).anyMatch(field -> keyDependencies.containsKey(Name.createVariableInNoNamespace(field)))){ + return NativeClauseContext.NoNativeQuery; + } } + initLookupKey(newContext.getContext()); + String key = this.lookupKey.getStringValue(); - DataType schema = newContext.getSchema(); + schema = newContext.getSchema(); if (!(schema instanceof StructType)) { return NativeClauseContext.NoNativeQuery; } - StructType structSchema = (StructType) schema; + structSchema = (StructType) schema; if (Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(key))) { newContext.setResultingQuery(newContext.getResultingQuery() + ".`" + key + "`"); StructField field = structSchema.fields()[structSchema.fieldIndex(key)]; From dbd88d2c362891a2c269b11c2339f6fd1a383478 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 13 Jan 2021 22:46:47 +0100 Subject: [PATCH 139/206] added test for redeclaration --- .../test_files/runtime-native-flwor/array-lookup/al14.jq | 6 ++++++ .../test_files/runtime-native-flwor/object-lookup/ol15.jq | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 src/test/resources/test_files/runtime-native-flwor/array-lookup/al14.jq create mode 100644 src/test/resources/test_files/runtime-native-flwor/object-lookup/ol15.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/array-lookup/al14.jq b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al14.jq new file mode 100644 index 0000000000..f4c03328b1 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/array-lookup/al14.jq @@ -0,0 +1,6 @@ +(:JIQS: ShouldRun; Output="(10, 20)" :) +declare variable $k := 1; +for $i in structured-json-file("../../../queries/difficult-names.json") +let $k := $i.indexToUse +let $c := $i.a[[$k]] +return $c \ No newline at end of file diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol15.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol15.jq new file mode 100644 index 0000000000..d241233865 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol15.jq @@ -0,0 +1,6 @@ +(:JIQS: ShouldRun; Output="(one, amazing)" :) +declare variable $k := "1"; +for $i in structured-json-file("../../../queries/difficult-names.json") +let $k := $i.keyToUse +let $c := $i.$k +return $c From 5eb350a969bc080bdd7b5d240be2e8dae9deb140 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 3 Feb 2021 18:49:52 +0100 Subject: [PATCH 140/206] added support for backtick in keys through escaping with uuid --- .../runtime/flwor/FlworDataFrameUtils.java | 40 ++++++++++++++++++- .../flwor/clauses/ForClauseSparkIterator.java | 9 ++++- .../clauses/ReturnClauseSparkIterator.java | 4 ++ .../runtime/postfix/ObjectLookupIterator.java | 4 +- .../primary/VariableReferenceIterator.java | 9 +++-- 5 files changed, 60 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java index b6dd0ea624..51b4d2a626 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java +++ b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java @@ -28,7 +28,9 @@ import org.apache.spark.sql.RowFactory; import org.apache.spark.sql.expressions.UserDefinedFunction; import org.apache.spark.sql.expressions.Window; +import org.apache.spark.sql.types.ArrayType; import org.apache.spark.sql.types.DataTypes; +import org.apache.spark.sql.types.StructField; import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; import org.rumbledb.config.RumbleRuntimeConfiguration; @@ -67,6 +69,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collector; import static org.apache.spark.sql.functions.col; import static org.apache.spark.sql.functions.count; @@ -79,6 +82,9 @@ public class FlworDataFrameUtils { + // we use UUID to escape backtick within DataFrame columns + public static String backtickEscape = "d32a3242-b15d-46b8-b689-d2288f7f492f"; + private static ThreadLocal lastBytesCache = ThreadLocal.withInitial(() -> null); private static ThreadLocal> lastObjectItemCache = ThreadLocal.withInitial(() -> null); @@ -329,7 +335,8 @@ public static String getSQLProjection( queryColumnString.append(comma); comma = ","; queryColumnString.append("`"); - queryColumnString.append(var); + // replace any backtick (`) with uuid + queryColumnString.append(var.replace("`", backtickEscape)); queryColumnString.append("`"); } if (trailingComma) { @@ -338,6 +345,37 @@ public static String getSQLProjection( return queryColumnString.toString(); } + public static StructField[] recursiveRename(StructType schema, boolean inverse){ + return Arrays.stream(schema.fields()).map(field -> { + String newName = inverse ? field.name().replace(FlworDataFrameUtils.backtickEscape, "`") : field.name().replace("`", FlworDataFrameUtils.backtickEscape); + if(field.dataType() instanceof StructType){ + StructType castedField = (StructType) field.dataType(); + return new StructField(newName, new StructType(recursiveRename(castedField, inverse)), field.nullable(), field.metadata()); + } else if(field.dataType() instanceof ArrayType){ + ArrayType castedField = (ArrayType) field.dataType(); + if(castedField.elementType() instanceof StructType){ + StructType castedElementType = (StructType) castedField.elementType(); + return new StructField(newName, new ArrayType(new StructType(recursiveRename(castedElementType, inverse)), castedField.containsNull()), field.nullable(), field.metadata()); + } else { + return new StructField(newName, field.dataType(), field.nullable(), field.metadata()); + } + } else { + return new StructField(newName, field.dataType(), field.nullable(), field.metadata()); + } + }).toArray(StructField[]::new); + } + + /** + * recursevely escape/de-escape backticks from all fields in a sparkSql schema + * + * @param schema schema to escape + * @param inverse if true, perform de-escaping, otherwise escape + * @return the new schema appropriately escaped/de-escaped + */ + public static StructType escapeSchema(StructType schema, boolean inverse){ + return new StructType(recursiveRename(schema, inverse)); + } + /** * Prepares a SQL projection for use in a GROUP BY query. * diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index d47b89a825..9073dcaf63 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -22,6 +22,7 @@ import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; +import org.apache.spark.sql.Column; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; import org.apache.spark.sql.RowFactory; @@ -69,6 +70,8 @@ import java.util.Stack; import java.util.TreeMap; +import static org.apache.spark.sql.functions.struct; + public class ForClauseSparkIterator extends RuntimeTupleIterator { @@ -1029,8 +1032,12 @@ public static Dataset getDataFrameStartingClause( Dataset df = null;; if (iterator.isDataFrame()) { Dataset rows = iterator.getDataFrame(context); - rows.createOrReplaceTempView("assignment"); String[] fields = rows.schema().fieldNames(); + + // escape backticks (`) + rows = rows.sparkSession().createDataFrame(rows.rdd(), FlworDataFrameUtils.escapeSchema(rows.schema(), false)); + + rows.createOrReplaceTempView("assignment"); String columnNames = FlworDataFrameUtils.getSQLProjection(Arrays.asList(fields), false); df = rows.sparkSession() .sql( diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ReturnClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ReturnClauseSparkIterator.java index aa6dc40378..1847dde06e 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ReturnClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ReturnClauseSparkIterator.java @@ -109,6 +109,10 @@ public JavaRDD getRDDAux(DynamicContext context) { } } Dataset df = this.child.getDataFrame(context, projection); + + // unescape backticks (`) + df = df.sparkSession().createDataFrame(df.rdd(), FlworDataFrameUtils.escapeSchema(df.schema(), true)); + StructType oldSchema = df.schema(); List UDFcolumns = FlworDataFrameUtils.getColumnNames( oldSchema, diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index d8b8e6e725..ce3b504c7b 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -35,6 +35,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.FlworDataFrameUtils; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.runtime.primary.ContextExpressionIterator; @@ -232,7 +233,8 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC initLookupKey(newContext.getContext()); - String key = this.lookupKey.getStringValue(); + // get key (escape backtick) + String key = this.lookupKey.getStringValue().replace("`", FlworDataFrameUtils.backtickEscape); schema = newContext.getSchema(); if (!(schema instanceof StructType)) { return NativeClauseContext.NoNativeQuery; diff --git a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java index 27e1868904..3df758ac4e 100644 --- a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java @@ -34,6 +34,7 @@ import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.FlworDataFrameUtils; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.SequenceType; @@ -91,9 +92,11 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC } // check if name is in the schema StructType structSchema = (StructType) schema; - if (Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(name))) { - NativeClauseContext newContext = new NativeClauseContext(nativeClauseContext, name); - StructField field = structSchema.fields()[structSchema.fieldIndex(name)]; + // we need to escape the backtick + String escapedName = name.replace("`", FlworDataFrameUtils.backtickEscape); + if (Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(escapedName))) { + NativeClauseContext newContext = new NativeClauseContext(nativeClauseContext, escapedName); + StructField field = structSchema.fields()[structSchema.fieldIndex(escapedName)]; DataType fieldType = field.dataType(); if (fieldType.typeName().equals("binary")) { return NativeClauseContext.NoNativeQuery; From e0be6e63601c094ae0c8c681ddcf90d9df7f17aa Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 4 Feb 2021 13:07:22 +0100 Subject: [PATCH 141/206] added return type to native clause context, fixed error in backtick escaping --- src/main/java/org/rumbledb/api/Item.java | 4 ++- .../java/org/rumbledb/items/AnyURIItem.java | 5 ++-- .../java/org/rumbledb/items/ArrayItem.java | 5 ++-- .../org/rumbledb/items/Base64BinaryItem.java | 5 ++-- .../java/org/rumbledb/items/BooleanItem.java | 5 ++-- .../java/org/rumbledb/items/DateItem.java | 5 ++-- .../java/org/rumbledb/items/DateTimeItem.java | 5 ++-- .../rumbledb/items/DayTimeDurationItem.java | 5 ++-- .../java/org/rumbledb/items/DecimalItem.java | 5 ++-- .../java/org/rumbledb/items/DoubleItem.java | 5 ++-- .../java/org/rumbledb/items/DurationItem.java | 5 ++-- .../java/org/rumbledb/items/FunctionItem.java | 5 ++-- .../org/rumbledb/items/HexBinaryItem.java | 5 ++-- src/main/java/org/rumbledb/items/IntItem.java | 5 ++-- .../java/org/rumbledb/items/IntegerItem.java | 5 ++-- .../java/org/rumbledb/items/NullItem.java | 5 ++-- .../java/org/rumbledb/items/ObjectItem.java | 5 ++-- .../java/org/rumbledb/items/StringItem.java | 5 ++-- .../java/org/rumbledb/items/TimeItem.java | 5 ++-- .../runtime/flwor/FlworDataFrameUtils.java | 25 ++++++++++++++----- .../runtime/flwor/NativeClauseContext.java | 17 +++++++++++-- .../flwor/clauses/ForClauseSparkIterator.java | 2 +- .../clauses/OrderByClauseSparkIterator.java | 2 +- .../operational/AndOperationIterator.java | 3 ++- .../ComparisonOperationIterator.java | 8 +++++- .../operational/NotOperationIterator.java | 3 ++- .../operational/OrOperationIterator.java | 3 ++- .../runtime/postfix/ArrayLookupIterator.java | 2 ++ .../postfix/ArrayUnboxingIterator.java | 5 +++- .../runtime/postfix/ObjectLookupIterator.java | 1 + .../primary/DecimalRuntimeIterator.java | 3 ++- .../primary/DoubleRuntimeIterator.java | 3 ++- .../primary/IntegerRuntimeIterator.java | 3 ++- .../primary/StringRuntimeIterator.java | 3 ++- .../primary/VariableReferenceIterator.java | 13 +++++----- .../object-lookup/ol14.jq | 2 +- 36 files changed, 128 insertions(+), 64 deletions(-) diff --git a/src/main/java/org/rumbledb/api/Item.java b/src/main/java/org/rumbledb/api/Item.java index 7c033e79df..cababd80b3 100644 --- a/src/main/java/org/rumbledb/api/Item.java +++ b/src/main/java/org/rumbledb/api/Item.java @@ -17,6 +17,7 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.expressions.comparison.ComparisonExpression; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.ItemType; @@ -519,6 +520,7 @@ Item compareItem( * Get sparkSql string for the item * * @return String representing the item in a sparksql query or null if it is not supported for the item + * @param context */ - String getSparkSqlQuery(); + NativeClauseContext generateNativeQuery(NativeClauseContext context); } diff --git a/src/main/java/org/rumbledb/items/AnyURIItem.java b/src/main/java/org/rumbledb/items/AnyURIItem.java index e3b546f1d8..6332cc9104 100644 --- a/src/main/java/org/rumbledb/items/AnyURIItem.java +++ b/src/main/java/org/rumbledb/items/AnyURIItem.java @@ -24,6 +24,7 @@ import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; import org.rumbledb.api.Item; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; @@ -143,7 +144,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/items/ArrayItem.java b/src/main/java/org/rumbledb/items/ArrayItem.java index 0c2f6fdbe4..aee44a2c31 100644 --- a/src/main/java/org/rumbledb/items/ArrayItem.java +++ b/src/main/java/org/rumbledb/items/ArrayItem.java @@ -25,6 +25,7 @@ import com.esotericsoftware.kryo.io.Output; import org.apache.commons.text.StringEscapeUtils; import org.rumbledb.api.Item; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.exceptions.OurBadException; import org.rumbledb.types.ItemType; @@ -159,7 +160,7 @@ public boolean isCastableAs(ItemType itemType) { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/items/Base64BinaryItem.java b/src/main/java/org/rumbledb/items/Base64BinaryItem.java index 10be736ffe..b855723dcc 100644 --- a/src/main/java/org/rumbledb/items/Base64BinaryItem.java +++ b/src/main/java/org/rumbledb/items/Base64BinaryItem.java @@ -11,6 +11,7 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import javax.xml.bind.DatatypeConverter; @@ -208,7 +209,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/items/BooleanItem.java b/src/main/java/org/rumbledb/items/BooleanItem.java index 69bd84f7d3..1c3b8ba5f5 100644 --- a/src/main/java/org/rumbledb/items/BooleanItem.java +++ b/src/main/java/org/rumbledb/items/BooleanItem.java @@ -27,6 +27,7 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.math.BigDecimal; @@ -157,7 +158,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/items/DateItem.java b/src/main/java/org/rumbledb/items/DateItem.java index 259a80b687..65a9629266 100644 --- a/src/main/java/org/rumbledb/items/DateItem.java +++ b/src/main/java/org/rumbledb/items/DateItem.java @@ -12,6 +12,7 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; @@ -200,7 +201,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/items/DateTimeItem.java b/src/main/java/org/rumbledb/items/DateTimeItem.java index 95f4113d3e..75d8072720 100644 --- a/src/main/java/org/rumbledb/items/DateTimeItem.java +++ b/src/main/java/org/rumbledb/items/DateTimeItem.java @@ -16,6 +16,7 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; @@ -322,7 +323,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/items/DayTimeDurationItem.java b/src/main/java/org/rumbledb/items/DayTimeDurationItem.java index 9220a7749d..8a00dd00e3 100644 --- a/src/main/java/org/rumbledb/items/DayTimeDurationItem.java +++ b/src/main/java/org/rumbledb/items/DayTimeDurationItem.java @@ -8,6 +8,7 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; @@ -135,7 +136,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/items/DecimalItem.java b/src/main/java/org/rumbledb/items/DecimalItem.java index ddbd3bafb1..79119cc71d 100644 --- a/src/main/java/org/rumbledb/items/DecimalItem.java +++ b/src/main/java/org/rumbledb/items/DecimalItem.java @@ -29,6 +29,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.math.BigDecimal; @@ -210,8 +211,8 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return this.value.toString(); + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return new NativeClauseContext(context, this.value.toString(), AtomicItemType.stringItem); } @Override diff --git a/src/main/java/org/rumbledb/items/DoubleItem.java b/src/main/java/org/rumbledb/items/DoubleItem.java index 2997091a1d..d272ec2ebd 100644 --- a/src/main/java/org/rumbledb/items/DoubleItem.java +++ b/src/main/java/org/rumbledb/items/DoubleItem.java @@ -38,6 +38,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.typing.InstanceOfIterator; @@ -220,8 +221,8 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return "" + this.value; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return new NativeClauseContext(context, "" + this.value, AtomicItemType.doubleItem); } @Override diff --git a/src/main/java/org/rumbledb/items/DurationItem.java b/src/main/java/org/rumbledb/items/DurationItem.java index fe7afe0771..7ab269802f 100644 --- a/src/main/java/org/rumbledb/items/DurationItem.java +++ b/src/main/java/org/rumbledb/items/DurationItem.java @@ -15,6 +15,7 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; @@ -309,7 +310,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/items/FunctionItem.java b/src/main/java/org/rumbledb/items/FunctionItem.java index c9a5f423c2..b86994a680 100644 --- a/src/main/java/org/rumbledb/items/FunctionItem.java +++ b/src/main/java/org/rumbledb/items/FunctionItem.java @@ -35,6 +35,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.RumbleException; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.*; import java.io.ByteArrayInputStream; @@ -341,7 +342,7 @@ public boolean isCastableAs(ItemType itemType) { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/items/HexBinaryItem.java b/src/main/java/org/rumbledb/items/HexBinaryItem.java index 35203b3a22..fc3d5b7f4d 100644 --- a/src/main/java/org/rumbledb/items/HexBinaryItem.java +++ b/src/main/java/org/rumbledb/items/HexBinaryItem.java @@ -11,6 +11,7 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.util.Arrays; @@ -202,7 +203,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/items/IntItem.java b/src/main/java/org/rumbledb/items/IntItem.java index 25de55705b..8d94085505 100644 --- a/src/main/java/org/rumbledb/items/IntItem.java +++ b/src/main/java/org/rumbledb/items/IntItem.java @@ -29,6 +29,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.math.BigDecimal; @@ -261,8 +262,8 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return "" + this.value; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return new NativeClauseContext(context, "" + this.value, AtomicItemType.integerItem); } @Override diff --git a/src/main/java/org/rumbledb/items/IntegerItem.java b/src/main/java/org/rumbledb/items/IntegerItem.java index d0d65440fd..1160e03649 100644 --- a/src/main/java/org/rumbledb/items/IntegerItem.java +++ b/src/main/java/org/rumbledb/items/IntegerItem.java @@ -29,6 +29,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import java.math.BigDecimal; @@ -228,8 +229,8 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return this.value.toString(); + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return new NativeClauseContext(context, this.value.toString(), AtomicItemType.integerItem); } @Override diff --git a/src/main/java/org/rumbledb/items/NullItem.java b/src/main/java/org/rumbledb/items/NullItem.java index 2dffa21700..094bb866ca 100644 --- a/src/main/java/org/rumbledb/items/NullItem.java +++ b/src/main/java/org/rumbledb/items/NullItem.java @@ -26,6 +26,7 @@ import org.rumbledb.api.Item; import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; @@ -122,7 +123,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/items/ObjectItem.java b/src/main/java/org/rumbledb/items/ObjectItem.java index d4cc13dcab..482d841b6e 100644 --- a/src/main/java/org/rumbledb/items/ObjectItem.java +++ b/src/main/java/org/rumbledb/items/ObjectItem.java @@ -27,6 +27,7 @@ import org.rumbledb.api.Item; import org.rumbledb.exceptions.DuplicateObjectKeyException; import org.rumbledb.exceptions.ExceptionMetadata; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.exceptions.OurBadException; import org.rumbledb.types.ItemType; @@ -229,8 +230,8 @@ public boolean isCastableAs(ItemType itemType) { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/items/StringItem.java b/src/main/java/org/rumbledb/items/StringItem.java index 4db59cddf1..012b1ba5f7 100644 --- a/src/main/java/org/rumbledb/items/StringItem.java +++ b/src/main/java/org/rumbledb/items/StringItem.java @@ -37,6 +37,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.typing.InstanceOfIterator; @@ -285,8 +286,8 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return '"' + this.value + '"'; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return new NativeClauseContext(context, '"' + this.value + '"', AtomicItemType.stringItem); } @Override diff --git a/src/main/java/org/rumbledb/items/TimeItem.java b/src/main/java/org/rumbledb/items/TimeItem.java index ed32c8bcd9..ea5ec4185a 100644 --- a/src/main/java/org/rumbledb/items/TimeItem.java +++ b/src/main/java/org/rumbledb/items/TimeItem.java @@ -12,6 +12,7 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.exceptions.UnexpectedTypeException; import org.rumbledb.expressions.comparison.ComparisonExpression; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; @@ -198,7 +199,7 @@ public ItemType getDynamicType() { } @Override - public String getSparkSqlQuery() { - return null; + public NativeClauseContext generateNativeQuery(NativeClauseContext context) { + return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java index 51b4d2a626..1c853ce8c5 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java +++ b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java @@ -28,10 +28,7 @@ import org.apache.spark.sql.RowFactory; import org.apache.spark.sql.expressions.UserDefinedFunction; import org.apache.spark.sql.expressions.Window; -import org.apache.spark.sql.types.ArrayType; -import org.apache.spark.sql.types.DataTypes; -import org.apache.spark.sql.types.StructField; -import org.apache.spark.sql.types.StructType; +import org.apache.spark.sql.types.*; import org.rumbledb.api.Item; import org.rumbledb.config.RumbleRuntimeConfiguration; import org.rumbledb.context.DynamicContext; @@ -56,6 +53,7 @@ import org.rumbledb.items.StringItem; import org.rumbledb.items.TimeItem; import org.rumbledb.items.YearMonthDurationItem; +import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -335,8 +333,7 @@ public static String getSQLProjection( queryColumnString.append(comma); comma = ","; queryColumnString.append("`"); - // replace any backtick (`) with uuid - queryColumnString.append(var.replace("`", backtickEscape)); + queryColumnString.append(var); queryColumnString.append("`"); } if (trailingComma) { @@ -376,6 +373,22 @@ public static StructType escapeSchema(StructType schema, boolean inverse){ return new StructType(recursiveRename(schema, inverse)); } + public static ItemType mapToJsoniqType(DataType type){ + // TODO: once type mapping is defined add string field to determine and document properly + if(type == DataTypes.StringType) { + return AtomicItemType.stringItem; + } else if(type == DataTypes.IntegerType) { + return AtomicItemType.integerItem; + } else if(type.equals(DataTypes.createDecimalType())) { + // TODO: test correct working + return AtomicItemType.integerItem; + } else if(type == DataTypes.DoubleType) { + return AtomicItemType.doubleItem; + } else { + return null; + } + } + /** * Prepares a SQL projection for use in a GROUP BY query. * diff --git a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java index 5afdb5dbba..58e1eae2b3 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java +++ b/src/main/java/org/rumbledb/runtime/flwor/NativeClauseContext.java @@ -4,6 +4,7 @@ import org.apache.spark.sql.types.StructType; import org.rumbledb.context.DynamicContext; import org.rumbledb.expressions.flowr.FLWOR_CLAUSES; +import org.rumbledb.types.ItemType; import java.util.ArrayList; import java.util.List; @@ -19,6 +20,7 @@ public class NativeClauseContext { private DynamicContext context; private String resultingQuery; private List lateralViewPart; // used in array unboxing to generate the correct lateral view + private ItemType resultingType; private NativeClauseContext() { } @@ -29,6 +31,7 @@ public NativeClauseContext(FLWOR_CLAUSES clauseType, StructType schema, DynamicC this.context = context; this.resultingQuery = ""; this.lateralViewPart = new ArrayList<>(); + this.resultingType = null; } public NativeClauseContext(NativeClauseContext parent) { @@ -37,14 +40,16 @@ public NativeClauseContext(NativeClauseContext parent) { this.context = parent.context; this.resultingQuery = parent.resultingQuery; this.lateralViewPart = parent.lateralViewPart; + this.resultingType = parent.resultingType; } - public NativeClauseContext(NativeClauseContext parent, String newSelectPart) { + public NativeClauseContext(NativeClauseContext parent, String newResultingQuery, ItemType resultingType) { this.clauseType = parent.clauseType; this.schema = parent.schema; this.context = parent.context; - this.resultingQuery = newSelectPart; + this.resultingQuery = newResultingQuery; this.lateralViewPart = parent.lateralViewPart; + this.resultingType = resultingType; } public FLWOR_CLAUSES getClauseType() { @@ -74,4 +79,12 @@ public DynamicContext getContext() { public List getLateralViewPart() { return this.lateralViewPart; } + + public ItemType getResultingType() { + return this.resultingType; + } + + public void setResultingType(ItemType resultingType) { + this.resultingType = resultingType; + } } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index 9073dcaf63..f5ab3d8ce8 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -1032,11 +1032,11 @@ public static Dataset getDataFrameStartingClause( Dataset df = null;; if (iterator.isDataFrame()) { Dataset rows = iterator.getDataFrame(context); - String[] fields = rows.schema().fieldNames(); // escape backticks (`) rows = rows.sparkSession().createDataFrame(rows.rdd(), FlworDataFrameUtils.escapeSchema(rows.schema(), false)); + String[] fields = rows.schema().fieldNames(); rows.createOrReplaceTempView("assignment"); String columnNames = FlworDataFrameUtils.getSQLProjection(Arrays.asList(fields), false); df = rows.sparkSession() diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index 3981faa425..843282a188 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -536,7 +536,7 @@ public static Dataset tryNativeQuery( // special check to avoid ordering by an integer constant in an ordering clause // because of meaning mismatch between sparksql (where it is supposed to order by the i-th col) // and jsoniq (order by a costant, so no actual ordering is performed) - if (nativeQuery.getResultingQuery().matches("\\s*-?\\s*\\d+\\s*")) { + if (nativeQuery.getResultingType() == AtomicItemType.integerItem) { orderSql.append('"'); orderSql.append(nativeQuery.getResultingQuery()); orderSql.append('"'); diff --git a/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java index 1c323fcd10..ed60f71326 100644 --- a/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java @@ -30,6 +30,7 @@ import org.rumbledb.runtime.LocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; +import org.rumbledb.types.AtomicItemType; public class AndOperationIterator extends LocalRuntimeIterator { @@ -88,6 +89,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC + " AND " + rightResult.getResultingQuery() + " )"; - return new NativeClauseContext(nativeClauseContext, resultingQuery); + return new NativeClauseContext(nativeClauseContext, resultingQuery, AtomicItemType.booleanItem); } } diff --git a/src/main/java/org/rumbledb/runtime/operational/ComparisonOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/ComparisonOperationIterator.java index b4f22947cb..fd9a81c32c 100644 --- a/src/main/java/org/rumbledb/runtime/operational/ComparisonOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/ComparisonOperationIterator.java @@ -32,6 +32,7 @@ import org.rumbledb.runtime.LocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; +import org.rumbledb.types.AtomicItemType; import java.util.ArrayList; import java.util.Arrays; @@ -195,6 +196,11 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC return NativeClauseContext.NoNativeQuery; } + // TODO: once done type system do proper comparison + if(!(leftResult.getResultingType().isNumeric() && rightResult.getResultingType().isNumeric() || leftResult.getResultingType() == rightResult.getResultingType())){ + return NativeClauseContext.NoNativeQuery; + } + String operator = " = "; switch (this.comparisonOperator.name()) { case "eq": @@ -217,7 +223,7 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC break; } String query = "( " + leftResult.getResultingQuery() + operator + rightResult.getResultingQuery() + " )"; - return new NativeClauseContext(nativeClauseContext, query); + return new NativeClauseContext(nativeClauseContext, query, AtomicItemType.booleanItem); } else { return NativeClauseContext.NoNativeQuery; } diff --git a/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java index 9f196c9060..3b0407ab50 100644 --- a/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java @@ -29,6 +29,7 @@ import org.rumbledb.runtime.LocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; +import org.rumbledb.types.AtomicItemType; public class NotOperationIterator extends LocalRuntimeIterator { @@ -61,6 +62,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC } String resultingQuery = "( NOT " + childResult.getResultingQuery() + " )"; - return new NativeClauseContext(nativeClauseContext, resultingQuery); + return new NativeClauseContext(nativeClauseContext, resultingQuery, AtomicItemType.booleanItem); } } diff --git a/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java index 6a87d8aa15..9de4b2b457 100644 --- a/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java @@ -29,6 +29,7 @@ import org.rumbledb.runtime.LocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; +import org.rumbledb.types.AtomicItemType; public class OrOperationIterator extends LocalRuntimeIterator { @@ -71,6 +72,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC } String resultingQuery = "( " + leftResult.getResultingQuery() + " OR " + rightResult.getResultingQuery() + " )"; - return new NativeClauseContext(nativeClauseContext, resultingQuery); + return new NativeClauseContext(nativeClauseContext, resultingQuery, AtomicItemType.booleanItem); } } diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java index 88ccce258a..66dd46b0fc 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java @@ -36,6 +36,7 @@ import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.FlworDataFrameUtils; import org.rumbledb.runtime.flwor.NativeClauseContext; import sparksoniq.spark.SparkSessionManager; @@ -183,6 +184,7 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC } ArrayType arraySchema = (ArrayType) schema; newContext.setSchema(arraySchema.elementType()); + newContext.setResultingType(FlworDataFrameUtils.mapToJsoniqType(arraySchema.elementType())); newContext.setResultingQuery(newContext.getResultingQuery() + "[" + (this.lookup - 1) + "]"); } return newContext; diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java index 13088c3f09..4855c9c806 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayUnboxingIterator.java @@ -37,6 +37,7 @@ import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; +import org.rumbledb.runtime.flwor.FlworDataFrameUtils; import org.rumbledb.runtime.flwor.NativeClauseContext; import sparksoniq.spark.SparkSessionManager; @@ -142,7 +143,9 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC // let control to UDF when what we are unboxing is not an array return NativeClauseContext.NoNativeQuery; } - newContext.setSchema(((ArrayType) schema).elementType()); + ArrayType arraySchema = (ArrayType) schema; + newContext.setSchema(arraySchema.elementType()); + newContext.setResultingType(FlworDataFrameUtils.mapToJsoniqType(arraySchema.elementType())); List lateralViewPart = newContext.getLateralViewPart(); if (lateralViewPart.size() == 0) { lateralViewPart.add("explode(" + newContext.getResultingQuery() + ")"); diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index ce3b504c7b..37f4750fb8 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -244,6 +244,7 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC newContext.setResultingQuery(newContext.getResultingQuery() + ".`" + key + "`"); StructField field = structSchema.fields()[structSchema.fieldIndex(key)]; newContext.setSchema(field.dataType()); + newContext.setResultingType(FlworDataFrameUtils.mapToJsoniqType(field.dataType())); } else { return NativeClauseContext.NoNativeQuery; } diff --git a/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java index dc988bf6d0..89acbed7e0 100644 --- a/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java @@ -30,6 +30,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; +import org.rumbledb.types.AtomicItemType; import java.math.BigDecimal; @@ -62,6 +63,6 @@ public Item materializeExactlyOneItem(DynamicContext context) throws NoItemExcep @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - return new NativeClauseContext(nativeClauseContext, "" + this.item.getDecimalValue()); + return new NativeClauseContext(nativeClauseContext, "" + this.item.getDecimalValue(), AtomicItemType.decimalItem); } } diff --git a/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java index 96dff652c6..caec302903 100644 --- a/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java @@ -30,6 +30,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; +import org.rumbledb.types.AtomicItemType; public class DoubleRuntimeIterator extends AtomicRuntimeIterator { @@ -60,6 +61,6 @@ public Item materializeExactlyOneItem(DynamicContext context) throws NoItemExcep @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - return new NativeClauseContext(nativeClauseContext, "" + this.item.getDoubleValue()); + return new NativeClauseContext(nativeClauseContext, "" + this.item.getDoubleValue(), AtomicItemType.doubleItem); } } diff --git a/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java index 43d65fbb87..259aea5a17 100644 --- a/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java @@ -30,6 +30,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; +import org.rumbledb.types.AtomicItemType; public class IntegerRuntimeIterator extends AtomicRuntimeIterator { @@ -62,6 +63,6 @@ public Item materializeExactlyOneItem(DynamicContext context) throws NoItemExcep @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - return new NativeClauseContext(nativeClauseContext, "" + this.item.getIntValue()); + return new NativeClauseContext(nativeClauseContext, "" + this.item.getIntValue(), AtomicItemType.integerItem); } } diff --git a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java index 959acea780..db7b76e363 100644 --- a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java @@ -31,6 +31,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; +import org.rumbledb.types.AtomicItemType; public class StringRuntimeIterator extends AtomicRuntimeIterator { @@ -59,6 +60,6 @@ public Item materializeExactlyOneItem(DynamicContext context) throws NoItemExcep @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - return new NativeClauseContext(nativeClauseContext, '"' + this.item.getStringValue() + '"'); + return new NativeClauseContext(nativeClauseContext, '"' + this.item.getStringValue() + '"', AtomicItemType.stringItem); } } diff --git a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java index 3df758ac4e..4a367d783a 100644 --- a/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/VariableReferenceIterator.java @@ -24,6 +24,7 @@ import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; import org.apache.spark.sql.types.DataType; +import org.apache.spark.sql.types.DataTypes; import org.apache.spark.sql.types.StructField; import org.apache.spark.sql.types.StructType; import org.rumbledb.api.Item; @@ -36,6 +37,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.FlworDataFrameUtils; import org.rumbledb.runtime.flwor.NativeClauseContext; +import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; import java.util.Arrays; @@ -95,12 +97,13 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC // we need to escape the backtick String escapedName = name.replace("`", FlworDataFrameUtils.backtickEscape); if (Arrays.stream(structSchema.fieldNames()).anyMatch(field -> field.equals(escapedName))) { - NativeClauseContext newContext = new NativeClauseContext(nativeClauseContext, escapedName); StructField field = structSchema.fields()[structSchema.fieldIndex(escapedName)]; DataType fieldType = field.dataType(); - if (fieldType.typeName().equals("binary")) { + if (fieldType == DataTypes.BinaryType) { return NativeClauseContext.NoNativeQuery; } + ItemType variableType = FlworDataFrameUtils.mapToJsoniqType(fieldType); + NativeClauseContext newContext = new NativeClauseContext(nativeClauseContext, escapedName, variableType); newContext.setSchema(fieldType); return newContext; } else { @@ -111,11 +114,7 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC // only possible to turn into native, sequence of length 1 return NativeClauseContext.NoNativeQuery; } - String itemQuery = items.get(0).getSparkSqlQuery(); - if (itemQuery == null) { - return NativeClauseContext.NoNativeQuery; - } - return new NativeClauseContext(nativeClauseContext, itemQuery); + return items.get(0).generateNativeQuery(nativeClauseContext); } } diff --git a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol14.jq b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol14.jq index 3d8d53358c..02f82aa9b5 100644 --- a/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol14.jq +++ b/src/test/resources/test_files/runtime-native-flwor/object-lookup/ol14.jq @@ -1,4 +1,4 @@ -(:JIQS: ShouldRun; Output="(oh cmon, why)" :) +(:JIQS: ShouldRun; Output="(oh cmon, why?)" :) for $i in structured-json-file("../../../queries/backtick.json") let $c := $i."backtick`" return $c From 2ae6e6e06c8cfcbd3ce18c434f1eca40bd0e0898 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 4 Feb 2021 17:11:25 +0100 Subject: [PATCH 142/206] fixed grammar to include is statically --- .../rumbledb/compiler/TranslationVisitor.java | 5 +- src/main/java/org/rumbledb/parser/Jsoniq.g4 | 10 +- .../java/org/rumbledb/parser/Jsoniq.tokens | 54 +- .../rumbledb/parser/JsoniqBaseVisitor.java | 7 + .../java/org/rumbledb/parser/JsoniqLexer.java | 619 +++--- .../org/rumbledb/parser/JsoniqLexer.tokens | 54 +- .../org/rumbledb/parser/JsoniqParser.java | 1912 +++++++++-------- .../org/rumbledb/parser/JsoniqVisitor.java | 6 + 8 files changed, 1390 insertions(+), 1277 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 688042d4ac..3e9b40d0b8 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -99,10 +99,7 @@ import org.rumbledb.expressions.primary.ObjectConstructorExpression; import org.rumbledb.expressions.primary.StringLiteralExpression; import org.rumbledb.expressions.primary.VariableReferenceExpression; -import org.rumbledb.expressions.typing.CastExpression; -import org.rumbledb.expressions.typing.CastableExpression; -import org.rumbledb.expressions.typing.InstanceOfExpression; -import org.rumbledb.expressions.typing.TreatExpression; +import org.rumbledb.expressions.typing.*; import org.rumbledb.parser.JsoniqParser; import org.rumbledb.parser.JsoniqParser.DefaultCollationDeclContext; import org.rumbledb.parser.JsoniqParser.EmptyOrderDeclContext; diff --git a/src/main/java/org/rumbledb/parser/Jsoniq.g4 b/src/main/java/org/rumbledb/parser/Jsoniq.g4 index e94b24b4a8..93ac90ff79 100644 --- a/src/main/java/org/rumbledb/parser/Jsoniq.g4 +++ b/src/main/java/org/rumbledb/parser/Jsoniq.g4 @@ -153,7 +153,9 @@ additiveExpr : main_expr=multiplicativeExpr ( op+=('+' | '-') rhs+=mu multiplicativeExpr : main_expr=instanceOfExpr ( op+=('*' | 'div' | 'idiv' | 'mod') rhs+=instanceOfExpr )*; -instanceOfExpr : main_expr=treatExpr ( Kinstance Kof seq=sequenceType)?; +instanceOfExpr : main_expr=isStaticallyExpr ( Kinstance Kof seq=sequenceType)?; + +isStaticallyExpr : main_expr=treatExpr ( Kis Kstatically seq=sequenceType)?; treatExpr : main_expr=castableExpr ( Ktreat Kas seq=sequenceType )?; @@ -246,6 +248,8 @@ keyWords : Kjsoniq | Kelse | Kgreatest | Kinstance + | Kstatically + | Kis | Kleast | Knot | NullLiteral @@ -358,6 +362,10 @@ Kinstance : 'instance' ; Kof : 'of' ; +Kstatically : 'statically' ; + +Kis : 'is' ; + Ktreat : 'treat'; Kcast : 'cast'; diff --git a/src/main/java/org/rumbledb/parser/Jsoniq.tokens b/src/main/java/org/rumbledb/parser/Jsoniq.tokens index 8759bd69b3..610f232f17 100644 --- a/src/main/java/org/rumbledb/parser/Jsoniq.tokens +++ b/src/main/java/org/rumbledb/parser/Jsoniq.tokens @@ -93,24 +93,26 @@ Knot=92 Kto=93 Kinstance=94 Kof=95 -Ktreat=96 -Kcast=97 -Kcastable=98 -Kversion=99 -Kjsoniq=100 -STRING=101 -ArgumentPlaceholder=102 -NullLiteral=103 -Literal=104 -NumericLiteral=105 -BooleanLiteral=106 -IntegerLiteral=107 -DecimalLiteral=108 -DoubleLiteral=109 -WS=110 -NCName=111 -XQComment=112 -ContentChar=113 +Kstatically=96 +Kis=97 +Ktreat=98 +Kcast=99 +Kcastable=100 +Kversion=101 +Kjsoniq=102 +STRING=103 +ArgumentPlaceholder=104 +NullLiteral=105 +Literal=106 +NumericLiteral=107 +BooleanLiteral=108 +IntegerLiteral=109 +DecimalLiteral=110 +DoubleLiteral=111 +WS=112 +NCName=113 +XQComment=114 +ContentChar=115 ';'=1 'module'=2 'namespace'=3 @@ -206,10 +208,12 @@ ContentChar=113 'to'=93 'instance'=94 'of'=95 -'treat'=96 -'cast'=97 -'castable'=98 -'version'=99 -'jsoniq'=100 -'?'=102 -'null'=103 +'statically'=96 +'is'=97 +'treat'=98 +'cast'=99 +'castable'=100 +'version'=101 +'jsoniq'=102 +'?'=104 +'null'=105 diff --git a/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java b/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java index 6ee5ec3b36..05ba57584b 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java +++ b/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java @@ -371,6 +371,13 @@ public class JsoniqBaseVisitor extends AbstractParseTreeVisitor implements * {@link #visitChildren} on {@code ctx}.

*/ @Override public T visitInstanceOfExpr(JsoniqParser.InstanceOfExprContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIsStaticallyExpr(JsoniqParser.IsStaticallyExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * diff --git a/src/main/java/org/rumbledb/parser/JsoniqLexer.java b/src/main/java/org/rumbledb/parser/JsoniqLexer.java index 80dbeeda51..187647e3c9 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqLexer.java +++ b/src/main/java/org/rumbledb/parser/JsoniqLexer.java @@ -35,10 +35,10 @@ public class JsoniqLexer extends Lexer { Kdescending=75, Ksome=76, Kevery=77, Ksatisfies=78, Kcollation=79, Kgreatest=80, Kleast=81, Kswitch=82, Kcase=83, Ktry=84, Kcatch=85, Kdefault=86, Kthen=87, Kelse=88, Ktypeswitch=89, Kor=90, Kand=91, Knot=92, Kto=93, Kinstance=94, - Kof=95, Ktreat=96, Kcast=97, Kcastable=98, Kversion=99, Kjsoniq=100, STRING=101, - ArgumentPlaceholder=102, NullLiteral=103, Literal=104, NumericLiteral=105, - BooleanLiteral=106, IntegerLiteral=107, DecimalLiteral=108, DoubleLiteral=109, - WS=110, NCName=111, XQComment=112, ContentChar=113; + Kof=95, Kstatically=96, Kis=97, Ktreat=98, Kcast=99, Kcastable=100, Kversion=101, + Kjsoniq=102, STRING=103, ArgumentPlaceholder=104, NullLiteral=105, Literal=106, + NumericLiteral=107, BooleanLiteral=108, IntegerLiteral=109, DecimalLiteral=110, + DoubleLiteral=111, WS=112, NCName=113, XQComment=114, ContentChar=115; public static String[] channelNames = { "DEFAULT_TOKEN_CHANNEL", "HIDDEN" }; @@ -60,9 +60,9 @@ public class JsoniqLexer extends Lexer { "Kascending", "Kdescending", "Ksome", "Kevery", "Ksatisfies", "Kcollation", "Kgreatest", "Kleast", "Kswitch", "Kcase", "Ktry", "Kcatch", "Kdefault", "Kthen", "Kelse", "Ktypeswitch", "Kor", "Kand", "Knot", "Kto", "Kinstance", - "Kof", "Ktreat", "Kcast", "Kcastable", "Kversion", "Kjsoniq", "STRING", - "ESC", "UNICODE", "HEX", "ArgumentPlaceholder", "NullLiteral", "Literal", - "NumericLiteral", "BooleanLiteral", "IntegerLiteral", "DecimalLiteral", + "Kof", "Kstatically", "Kis", "Ktreat", "Kcast", "Kcastable", "Kversion", + "Kjsoniq", "STRING", "ESC", "UNICODE", "HEX", "ArgumentPlaceholder", "NullLiteral", + "Literal", "NumericLiteral", "BooleanLiteral", "IntegerLiteral", "DecimalLiteral", "DoubleLiteral", "Digits", "WS", "NCName", "NameStartChar", "NameChar", "XQComment", "ContentChar" }; @@ -81,8 +81,8 @@ public class JsoniqLexer extends Lexer { "'ascending'", "'descending'", "'some'", "'every'", "'satisfies'", "'collation'", "'greatest'", "'least'", "'switch'", "'case'", "'try'", "'catch'", "'default'", "'then'", "'else'", "'typeswitch'", "'or'", "'and'", "'not'", "'to'", - "'instance'", "'of'", "'treat'", "'cast'", "'castable'", "'version'", - "'jsoniq'", null, "'?'", "'null'" + "'instance'", "'of'", "'statically'", "'is'", "'treat'", "'cast'", "'castable'", + "'version'", "'jsoniq'", null, "'?'", "'null'" }; private static final String[] _SYMBOLIC_NAMES = { null, null, null, null, null, null, null, null, null, null, null, null, @@ -94,10 +94,11 @@ public class JsoniqLexer extends Lexer { "Kas", "Kat", "Kallowing", "Kempty", "Kcount", "Kstable", "Kascending", "Kdescending", "Ksome", "Kevery", "Ksatisfies", "Kcollation", "Kgreatest", "Kleast", "Kswitch", "Kcase", "Ktry", "Kcatch", "Kdefault", "Kthen", "Kelse", - "Ktypeswitch", "Kor", "Kand", "Knot", "Kto", "Kinstance", "Kof", "Ktreat", - "Kcast", "Kcastable", "Kversion", "Kjsoniq", "STRING", "ArgumentPlaceholder", - "NullLiteral", "Literal", "NumericLiteral", "BooleanLiteral", "IntegerLiteral", - "DecimalLiteral", "DoubleLiteral", "WS", "NCName", "XQComment", "ContentChar" + "Ktypeswitch", "Kor", "Kand", "Knot", "Kto", "Kinstance", "Kof", "Kstatically", + "Kis", "Ktreat", "Kcast", "Kcastable", "Kversion", "Kjsoniq", "STRING", + "ArgumentPlaceholder", "NullLiteral", "Literal", "NumericLiteral", "BooleanLiteral", + "IntegerLiteral", "DecimalLiteral", "DoubleLiteral", "WS", "NCName", "XQComment", + "ContentChar" }; public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); @@ -157,7 +158,7 @@ public JsoniqLexer(CharStream input) { public ATN getATN() { return _ATN; } public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2s\u03a9\b\1\4\2\t"+ + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2u\u03bb\b\1\4\2\t"+ "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ @@ -170,69 +171,70 @@ public JsoniqLexer(CharStream input) { "\4U\tU\4V\tV\4W\tW\4X\tX\4Y\tY\4Z\tZ\4[\t[\4\\\t\\\4]\t]\4^\t^\4_\t_\4"+ "`\t`\4a\ta\4b\tb\4c\tc\4d\td\4e\te\4f\tf\4g\tg\4h\th\4i\ti\4j\tj\4k\t"+ "k\4l\tl\4m\tm\4n\tn\4o\to\4p\tp\4q\tq\4r\tr\4s\ts\4t\tt\4u\tu\4v\tv\4"+ - "w\tw\4x\tx\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4"+ - "\3\4\3\4\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3"+ - "\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t"+ - "\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3"+ - "\n\3\n\3\n\3\n\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3"+ - "\f\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r"+ - "\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3"+ - "\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3"+ - "\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22\3\22\3"+ - "\22\3\22\3\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3"+ - "\23\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\24\3\25\3\25\3\25\3\25\3"+ - "\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3"+ - "\26\3\26\3\26\3\26\3\26\3\26\3\26\3\27\3\27\3\30\3\30\3\30\3\30\3\30\3"+ - "\30\3\30\3\30\3\30\3\31\3\31\3\31\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3"+ - "\32\3\32\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\35\3"+ - "\35\3\36\3\36\3\37\3\37\3 \3 \3!\3!\3\"\3\"\3#\3#\3#\3$\3$\3$\3%\3%\3"+ - "%\3&\3&\3&\3\'\3\'\3\'\3(\3(\3(\3)\3)\3)\3*\3*\3+\3+\3+\3,\3,\3-\3-\3"+ - "-\3.\3.\3.\3/\3/\3\60\3\60\3\61\3\61\3\61\3\61\3\62\3\62\3\62\3\62\3\62"+ - "\3\63\3\63\3\63\3\63\3\64\3\64\3\65\3\65\3\66\3\66\3\67\3\67\38\38\38"+ - "\39\39\3:\3:\3:\3;\3;\3;\3<\3<\3<\3<\3=\3=\3=\3=\3>\3>\3>\3>\3>\3>\3?"+ - "\3?\3?\3?\3?\3?\3@\3@\3@\3A\3A\3A\3A\3A\3A\3B\3B\3B\3B\3B\3B\3B\3C\3C"+ - "\3C\3D\3D\3D\3E\3E\3E\3F\3F\3F\3G\3G\3G\3G\3G\3G\3G\3G\3G\3H\3H\3H\3H"+ - "\3H\3H\3I\3I\3I\3I\3I\3I\3J\3J\3J\3J\3J\3J\3J\3K\3K\3K\3K\3K\3K\3K\3K"+ - "\3K\3K\3L\3L\3L\3L\3L\3L\3L\3L\3L\3L\3L\3M\3M\3M\3M\3M\3N\3N\3N\3N\3N"+ - "\3N\3O\3O\3O\3O\3O\3O\3O\3O\3O\3O\3P\3P\3P\3P\3P\3P\3P\3P\3P\3P\3Q\3Q"+ - "\3Q\3Q\3Q\3Q\3Q\3Q\3Q\3R\3R\3R\3R\3R\3R\3S\3S\3S\3S\3S\3S\3S\3T\3T\3T"+ - "\3T\3T\3U\3U\3U\3U\3V\3V\3V\3V\3V\3V\3W\3W\3W\3W\3W\3W\3W\3W\3X\3X\3X"+ - "\3X\3X\3Y\3Y\3Y\3Y\3Y\3Z\3Z\3Z\3Z\3Z\3Z\3Z\3Z\3Z\3Z\3Z\3[\3[\3[\3\\\3"+ - "\\\3\\\3\\\3]\3]\3]\3]\3^\3^\3^\3_\3_\3_\3_\3_\3_\3_\3_\3_\3`\3`\3`\3"+ - "a\3a\3a\3a\3a\3a\3b\3b\3b\3b\3b\3c\3c\3c\3c\3c\3c\3c\3c\3c\3d\3d\3d\3"+ - "d\3d\3d\3d\3d\3e\3e\3e\3e\3e\3e\3e\3f\3f\3f\7f\u032a\nf\ff\16f\u032d\13"+ - "f\3f\3f\3g\3g\3g\5g\u0334\ng\3h\3h\3h\3h\3h\3h\3i\3i\3j\3j\3k\3k\3k\3"+ - "k\3k\3l\3l\5l\u0347\nl\3m\3m\3m\5m\u034c\nm\3n\3n\3n\3n\3n\3n\3n\3n\3"+ - "n\5n\u0357\nn\3o\3o\3p\3p\3p\3p\3p\7p\u0360\np\fp\16p\u0363\13p\5p\u0365"+ - "\np\3q\3q\3q\3q\3q\7q\u036c\nq\fq\16q\u036f\13q\5q\u0371\nq\5q\u0373\n"+ - "q\3q\3q\5q\u0377\nq\3q\3q\3r\6r\u037c\nr\rr\16r\u037d\3s\3s\3s\3s\3t\3"+ - "t\7t\u0386\nt\ft\16t\u0389\13t\3u\5u\u038c\nu\3v\3v\5v\u0390\nv\3w\3w"+ - "\3w\3w\3w\3w\3w\3w\7w\u039a\nw\fw\16w\u039d\13w\3w\6w\u03a0\nw\rw\16w"+ - "\u03a1\3w\3w\3w\3w\3x\3x\2\2y\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13"+ - "\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61"+ - "\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61"+ - "a\62c\63e\64g\65i\66k\67m8o9q:s;u{?}@\177A\u0081B\u0083C\u0085D\u0087"+ - "E\u0089F\u008bG\u008dH\u008fI\u0091J\u0093K\u0095L\u0097M\u0099N\u009b"+ - "O\u009dP\u009fQ\u00a1R\u00a3S\u00a5T\u00a7U\u00a9V\u00abW\u00adX\u00af"+ - "Y\u00b1Z\u00b3[\u00b5\\\u00b7]\u00b9^\u00bb_\u00bd`\u00bfa\u00c1b\u00c3"+ - "c\u00c5d\u00c7e\u00c9f\u00cbg\u00cd\2\u00cf\2\u00d1\2\u00d3h\u00d5i\u00d7"+ - "j\u00d9k\u00dbl\u00ddm\u00dfn\u00e1o\u00e3\2\u00e5p\u00e7q\u00e9\2\u00eb"+ - "\2\u00edr\u00efs\3\2\17\4\2$$^^\n\2$$\61\61^^ddhhppttvv\5\2\62;CHch\3"+ - "\2\62;\4\2GGgg\4\2--//\5\2\13\f\17\17\"\"\20\2C\\aac|\u00c2\u00d8\u00da"+ - "\u00f8\u00fa\u0301\u0372\u037f\u0381\u2001\u200e\u200f\u2072\u2191\u2c02"+ - "\u2ff1\u3003\ud801\uf902\ufdd1\ufdf2\uffff\7\2//\62;\u00b9\u00b9\u0302"+ - "\u0371\u2041\u2042\3\2<<\3\2++\4\2**<<\7\2$$()>>}}\177\177\2\u03b7\2\3"+ - "\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2"+ - "\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31"+ - "\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2"+ - "\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2"+ - "\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2"+ - "\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2"+ - "I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U\3"+ - "\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\2a\3\2\2"+ - "\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2m\3\2\2\2\2"+ - "o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3\2\2\2\2{\3"+ - "\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2\2\2\2\u0085"+ + "w\tw\4x\tx\4y\ty\4z\tz\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\4\3\4\3\4"+ + "\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3"+ + "\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\t"+ + "\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3"+ + "\n\3\n\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3"+ + "\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r"+ + "\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16"+ + "\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17"+ + "\3\17\3\20\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\22"+ + "\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\3\23"+ + "\3\23\3\23\3\23\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\24\3\25\3\25"+ + "\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25"+ + "\3\25\3\25\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\27\3\27\3\30\3\30\3\30"+ + "\3\30\3\30\3\30\3\30\3\30\3\30\3\31\3\31\3\31\3\32\3\32\3\32\3\32\3\32"+ + "\3\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\34"+ + "\3\34\3\35\3\35\3\36\3\36\3\37\3\37\3 \3 \3!\3!\3\"\3\"\3#\3#\3#\3$\3"+ + "$\3$\3%\3%\3%\3&\3&\3&\3\'\3\'\3\'\3(\3(\3(\3)\3)\3)\3*\3*\3+\3+\3+\3"+ + ",\3,\3-\3-\3-\3.\3.\3.\3/\3/\3\60\3\60\3\61\3\61\3\61\3\61\3\62\3\62\3"+ + "\62\3\62\3\62\3\63\3\63\3\63\3\63\3\64\3\64\3\65\3\65\3\66\3\66\3\67\3"+ + "\67\38\38\38\39\39\3:\3:\3:\3;\3;\3;\3<\3<\3<\3<\3=\3=\3=\3=\3>\3>\3>"+ + "\3>\3>\3>\3?\3?\3?\3?\3?\3?\3@\3@\3@\3A\3A\3A\3A\3A\3A\3B\3B\3B\3B\3B"+ + "\3B\3B\3C\3C\3C\3D\3D\3D\3E\3E\3E\3F\3F\3F\3G\3G\3G\3G\3G\3G\3G\3G\3G"+ + "\3H\3H\3H\3H\3H\3H\3I\3I\3I\3I\3I\3I\3J\3J\3J\3J\3J\3J\3J\3K\3K\3K\3K"+ + "\3K\3K\3K\3K\3K\3K\3L\3L\3L\3L\3L\3L\3L\3L\3L\3L\3L\3M\3M\3M\3M\3M\3N"+ + "\3N\3N\3N\3N\3N\3O\3O\3O\3O\3O\3O\3O\3O\3O\3O\3P\3P\3P\3P\3P\3P\3P\3P"+ + "\3P\3P\3Q\3Q\3Q\3Q\3Q\3Q\3Q\3Q\3Q\3R\3R\3R\3R\3R\3R\3S\3S\3S\3S\3S\3S"+ + "\3S\3T\3T\3T\3T\3T\3U\3U\3U\3U\3V\3V\3V\3V\3V\3V\3W\3W\3W\3W\3W\3W\3W"+ + "\3W\3X\3X\3X\3X\3X\3Y\3Y\3Y\3Y\3Y\3Z\3Z\3Z\3Z\3Z\3Z\3Z\3Z\3Z\3Z\3Z\3["+ + "\3[\3[\3\\\3\\\3\\\3\\\3]\3]\3]\3]\3^\3^\3^\3_\3_\3_\3_\3_\3_\3_\3_\3"+ + "_\3`\3`\3`\3a\3a\3a\3a\3a\3a\3a\3a\3a\3a\3a\3b\3b\3b\3c\3c\3c\3c\3c\3"+ + "c\3d\3d\3d\3d\3d\3e\3e\3e\3e\3e\3e\3e\3e\3e\3f\3f\3f\3f\3f\3f\3f\3f\3"+ + "g\3g\3g\3g\3g\3g\3g\3h\3h\3h\7h\u033c\nh\fh\16h\u033f\13h\3h\3h\3i\3i"+ + "\3i\5i\u0346\ni\3j\3j\3j\3j\3j\3j\3k\3k\3l\3l\3m\3m\3m\3m\3m\3n\3n\5n"+ + "\u0359\nn\3o\3o\3o\5o\u035e\no\3p\3p\3p\3p\3p\3p\3p\3p\3p\5p\u0369\np"+ + "\3q\3q\3r\3r\3r\3r\3r\7r\u0372\nr\fr\16r\u0375\13r\5r\u0377\nr\3s\3s\3"+ + "s\3s\3s\7s\u037e\ns\fs\16s\u0381\13s\5s\u0383\ns\5s\u0385\ns\3s\3s\5s"+ + "\u0389\ns\3s\3s\3t\6t\u038e\nt\rt\16t\u038f\3u\3u\3u\3u\3v\3v\7v\u0398"+ + "\nv\fv\16v\u039b\13v\3w\5w\u039e\nw\3x\3x\5x\u03a2\nx\3y\3y\3y\3y\3y\3"+ + "y\3y\3y\7y\u03ac\ny\fy\16y\u03af\13y\3y\6y\u03b2\ny\ry\16y\u03b3\3y\3"+ + "y\3y\3y\3z\3z\2\2{\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r"+ + "\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33"+ + "\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63"+ + "e\64g\65i\66k\67m8o9q:s;u{?}@\177A\u0081B\u0083C\u0085D\u0087E\u0089"+ + "F\u008bG\u008dH\u008fI\u0091J\u0093K\u0095L\u0097M\u0099N\u009bO\u009d"+ + "P\u009fQ\u00a1R\u00a3S\u00a5T\u00a7U\u00a9V\u00abW\u00adX\u00afY\u00b1"+ + "Z\u00b3[\u00b5\\\u00b7]\u00b9^\u00bb_\u00bd`\u00bfa\u00c1b\u00c3c\u00c5"+ + "d\u00c7e\u00c9f\u00cbg\u00cdh\u00cfi\u00d1\2\u00d3\2\u00d5\2\u00d7j\u00d9"+ + "k\u00dbl\u00ddm\u00dfn\u00e1o\u00e3p\u00e5q\u00e7\2\u00e9r\u00ebs\u00ed"+ + "\2\u00ef\2\u00f1t\u00f3u\3\2\17\4\2$$^^\n\2$$\61\61^^ddhhppttvv\5\2\62"+ + ";CHch\3\2\62;\4\2GGgg\4\2--//\5\2\13\f\17\17\"\"\20\2C\\aac|\u00c2\u00d8"+ + "\u00da\u00f8\u00fa\u0301\u0372\u037f\u0381\u2001\u200e\u200f\u2072\u2191"+ + "\u2c02\u2ff1\u3003\ud801\uf902\ufdd1\ufdf2\uffff\7\2//\62;\u00b9\u00b9"+ + "\u0302\u0371\u2041\u2042\3\2<<\3\2++\4\2**<<\7\2$$()>>}}\177\177\2\u03c9"+ + "\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2"+ + "\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2"+ + "\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2"+ + "\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2"+ + "\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3"+ + "\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2"+ + "\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2"+ + "U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\2a\3"+ + "\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2m\3\2\2"+ + "\2\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3\2\2\2\2"+ + "{\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2\2\2\2\u0085"+ "\3\2\2\2\2\u0087\3\2\2\2\2\u0089\3\2\2\2\2\u008b\3\2\2\2\2\u008d\3\2\2"+ "\2\2\u008f\3\2\2\2\2\u0091\3\2\2\2\2\u0093\3\2\2\2\2\u0095\3\2\2\2\2\u0097"+ "\3\2\2\2\2\u0099\3\2\2\2\2\u009b\3\2\2\2\2\u009d\3\2\2\2\2\u009f\3\2\2"+ @@ -240,235 +242,240 @@ public JsoniqLexer(CharStream input) { "\3\2\2\2\2\u00ab\3\2\2\2\2\u00ad\3\2\2\2\2\u00af\3\2\2\2\2\u00b1\3\2\2"+ "\2\2\u00b3\3\2\2\2\2\u00b5\3\2\2\2\2\u00b7\3\2\2\2\2\u00b9\3\2\2\2\2\u00bb"+ "\3\2\2\2\2\u00bd\3\2\2\2\2\u00bf\3\2\2\2\2\u00c1\3\2\2\2\2\u00c3\3\2\2"+ - "\2\2\u00c5\3\2\2\2\2\u00c7\3\2\2\2\2\u00c9\3\2\2\2\2\u00cb\3\2\2\2\2\u00d3"+ - "\3\2\2\2\2\u00d5\3\2\2\2\2\u00d7\3\2\2\2\2\u00d9\3\2\2\2\2\u00db\3\2\2"+ - "\2\2\u00dd\3\2\2\2\2\u00df\3\2\2\2\2\u00e1\3\2\2\2\2\u00e5\3\2\2\2\2\u00e7"+ - "\3\2\2\2\2\u00ed\3\2\2\2\2\u00ef\3\2\2\2\3\u00f1\3\2\2\2\5\u00f3\3\2\2"+ - "\2\7\u00fa\3\2\2\2\t\u0104\3\2\2\2\13\u0106\3\2\2\2\r\u010e\3\2\2\2\17"+ - "\u0117\3\2\2\2\21\u011f\3\2\2\2\23\u0129\3\2\2\2\25\u0138\3\2\2\2\27\u013a"+ - "\3\2\2\2\31\u014c\3\2\2\2\33\u015f\3\2\2\2\35\u0168\3\2\2\2\37\u0173\3"+ - "\2\2\2!\u0177\3\2\2\2#\u017f\3\2\2\2%\u0189\3\2\2\2\'\u0194\3\2\2\2)\u019a"+ - "\3\2\2\2+\u01ac\3\2\2\2-\u01b3\3\2\2\2/\u01b5\3\2\2\2\61\u01be\3\2\2\2"+ - "\63\u01c1\3\2\2\2\65\u01ca\3\2\2\2\67\u01d3\3\2\2\29\u01d5\3\2\2\2;\u01d7"+ - "\3\2\2\2=\u01d9\3\2\2\2?\u01db\3\2\2\2A\u01dd\3\2\2\2C\u01df\3\2\2\2E"+ - "\u01e1\3\2\2\2G\u01e4\3\2\2\2I\u01e7\3\2\2\2K\u01ea\3\2\2\2M\u01ed\3\2"+ - "\2\2O\u01f0\3\2\2\2Q\u01f3\3\2\2\2S\u01f6\3\2\2\2U\u01f8\3\2\2\2W\u01fb"+ - "\3\2\2\2Y\u01fd\3\2\2\2[\u0200\3\2\2\2]\u0203\3\2\2\2_\u0205\3\2\2\2a"+ - "\u0207\3\2\2\2c\u020b\3\2\2\2e\u0210\3\2\2\2g\u0214\3\2\2\2i\u0216\3\2"+ - "\2\2k\u0218\3\2\2\2m\u021a\3\2\2\2o\u021c\3\2\2\2q\u021f\3\2\2\2s\u0221"+ - "\3\2\2\2u\u0224\3\2\2\2w\u0227\3\2\2\2y\u022b\3\2\2\2{\u022f\3\2\2\2}"+ - "\u0235\3\2\2\2\177\u023b\3\2\2\2\u0081\u023e\3\2\2\2\u0083\u0244\3\2\2"+ - "\2\u0085\u024b\3\2\2\2\u0087\u024e\3\2\2\2\u0089\u0251\3\2\2\2\u008b\u0254"+ - "\3\2\2\2\u008d\u0257\3\2\2\2\u008f\u0260\3\2\2\2\u0091\u0266\3\2\2\2\u0093"+ - "\u026c\3\2\2\2\u0095\u0273\3\2\2\2\u0097\u027d\3\2\2\2\u0099\u0288\3\2"+ - "\2\2\u009b\u028d\3\2\2\2\u009d\u0293\3\2\2\2\u009f\u029d\3\2\2\2\u00a1"+ - "\u02a7\3\2\2\2\u00a3\u02b0\3\2\2\2\u00a5\u02b6\3\2\2\2\u00a7\u02bd\3\2"+ - "\2\2\u00a9\u02c2\3\2\2\2\u00ab\u02c6\3\2\2\2\u00ad\u02cc\3\2\2\2\u00af"+ - "\u02d4\3\2\2\2\u00b1\u02d9\3\2\2\2\u00b3\u02de\3\2\2\2\u00b5\u02e9\3\2"+ - "\2\2\u00b7\u02ec\3\2\2\2\u00b9\u02f0\3\2\2\2\u00bb\u02f4\3\2\2\2\u00bd"+ - "\u02f7\3\2\2\2\u00bf\u0300\3\2\2\2\u00c1\u0303\3\2\2\2\u00c3\u0309\3\2"+ - "\2\2\u00c5\u030e\3\2\2\2\u00c7\u0317\3\2\2\2\u00c9\u031f\3\2\2\2\u00cb"+ - "\u0326\3\2\2\2\u00cd\u0330\3\2\2\2\u00cf\u0335\3\2\2\2\u00d1\u033b\3\2"+ - "\2\2\u00d3\u033d\3\2\2\2\u00d5\u033f\3\2\2\2\u00d7\u0346\3\2\2\2\u00d9"+ - "\u034b\3\2\2\2\u00db\u0356\3\2\2\2\u00dd\u0358\3\2\2\2\u00df\u0364\3\2"+ - "\2\2\u00e1\u0372\3\2\2\2\u00e3\u037b\3\2\2\2\u00e5\u037f\3\2\2\2\u00e7"+ - "\u0383\3\2\2\2\u00e9\u038b\3\2\2\2\u00eb\u038f\3\2\2\2\u00ed\u0391\3\2"+ - "\2\2\u00ef\u03a7\3\2\2\2\u00f1\u00f2\7=\2\2\u00f2\4\3\2\2\2\u00f3\u00f4"+ - "\7o\2\2\u00f4\u00f5\7q\2\2\u00f5\u00f6\7f\2\2\u00f6\u00f7\7w\2\2\u00f7"+ - "\u00f8\7n\2\2\u00f8\u00f9\7g\2\2\u00f9\6\3\2\2\2\u00fa\u00fb\7p\2\2\u00fb"+ - "\u00fc\7c\2\2\u00fc\u00fd\7o\2\2\u00fd\u00fe\7g\2\2\u00fe\u00ff\7u\2\2"+ - "\u00ff\u0100\7r\2\2\u0100\u0101\7c\2\2\u0101\u0102\7e\2\2\u0102\u0103"+ - "\7g\2\2\u0103\b\3\2\2\2\u0104\u0105\7?\2\2\u0105\n\3\2\2\2\u0106\u0107"+ - "\7f\2\2\u0107\u0108\7g\2\2\u0108\u0109\7e\2\2\u0109\u010a\7n\2\2\u010a"+ - "\u010b\7c\2\2\u010b\u010c\7t\2\2\u010c\u010d\7g\2\2\u010d\f\3\2\2\2\u010e"+ - "\u010f\7q\2\2\u010f\u0110\7t\2\2\u0110\u0111\7f\2\2\u0111\u0112\7g\2\2"+ - "\u0112\u0113\7t\2\2\u0113\u0114\7k\2\2\u0114\u0115\7p\2\2\u0115\u0116"+ - "\7i\2\2\u0116\16\3\2\2\2\u0117\u0118\7q\2\2\u0118\u0119\7t\2\2\u0119\u011a"+ - "\7f\2\2\u011a\u011b\7g\2\2\u011b\u011c\7t\2\2\u011c\u011d\7g\2\2\u011d"+ - "\u011e\7f\2\2\u011e\20\3\2\2\2\u011f\u0120\7w\2\2\u0120\u0121\7p\2\2\u0121"+ - "\u0122\7q\2\2\u0122\u0123\7t\2\2\u0123\u0124\7f\2\2\u0124\u0125\7g\2\2"+ - "\u0125\u0126\7t\2\2\u0126\u0127\7g\2\2\u0127\u0128\7f\2\2\u0128\22\3\2"+ - "\2\2\u0129\u012a\7f\2\2\u012a\u012b\7g\2\2\u012b\u012c\7e\2\2\u012c\u012d"+ - "\7k\2\2\u012d\u012e\7o\2\2\u012e\u012f\7c\2\2\u012f\u0130\7n\2\2\u0130"+ - "\u0131\7/\2\2\u0131\u0132\7h\2\2\u0132\u0133\7q\2\2\u0133\u0134\7t\2\2"+ - "\u0134\u0135\7o\2\2\u0135\u0136\7c\2\2\u0136\u0137\7v\2\2\u0137\24\3\2"+ - "\2\2\u0138\u0139\7<\2\2\u0139\26\3\2\2\2\u013a\u013b\7f\2\2\u013b\u013c"+ - "\7g\2\2\u013c\u013d\7e\2\2\u013d\u013e\7k\2\2\u013e\u013f\7o\2\2\u013f"+ - "\u0140\7c\2\2\u0140\u0141\7n\2\2\u0141\u0142\7/\2\2\u0142\u0143\7u\2\2"+ - "\u0143\u0144\7g\2\2\u0144\u0145\7r\2\2\u0145\u0146\7c\2\2\u0146\u0147"+ - "\7t\2\2\u0147\u0148\7c\2\2\u0148\u0149\7v\2\2\u0149\u014a\7q\2\2\u014a"+ - "\u014b\7t\2\2\u014b\30\3\2\2\2\u014c\u014d\7i\2\2\u014d\u014e\7t\2\2\u014e"+ - "\u014f\7q\2\2\u014f\u0150\7w\2\2\u0150\u0151\7r\2\2\u0151\u0152\7k\2\2"+ - "\u0152\u0153\7p\2\2\u0153\u0154\7i\2\2\u0154\u0155\7/\2\2\u0155\u0156"+ - "\7u\2\2\u0156\u0157\7g\2\2\u0157\u0158\7r\2\2\u0158\u0159\7c\2\2\u0159"+ - "\u015a\7t\2\2\u015a\u015b\7c\2\2\u015b\u015c\7v\2\2\u015c\u015d\7q\2\2"+ - "\u015d\u015e\7t\2\2\u015e\32\3\2\2\2\u015f\u0160\7k\2\2\u0160\u0161\7"+ - "p\2\2\u0161\u0162\7h\2\2\u0162\u0163\7k\2\2\u0163\u0164\7p\2\2\u0164\u0165"+ - "\7k\2\2\u0165\u0166\7v\2\2\u0166\u0167\7{\2\2\u0167\34\3\2\2\2\u0168\u0169"+ - "\7o\2\2\u0169\u016a\7k\2\2\u016a\u016b\7p\2\2\u016b\u016c\7w\2\2\u016c"+ - "\u016d\7u\2\2\u016d\u016e\7/\2\2\u016e\u016f\7u\2\2\u016f\u0170\7k\2\2"+ - "\u0170\u0171\7i\2\2\u0171\u0172\7p\2\2\u0172\36\3\2\2\2\u0173\u0174\7"+ - "P\2\2\u0174\u0175\7c\2\2\u0175\u0176\7P\2\2\u0176 \3\2\2\2\u0177\u0178"+ - "\7r\2\2\u0178\u0179\7g\2\2\u0179\u017a\7t\2\2\u017a\u017b\7e\2\2\u017b"+ - "\u017c\7g\2\2\u017c\u017d\7p\2\2\u017d\u017e\7v\2\2\u017e\"\3\2\2\2\u017f"+ - "\u0180\7r\2\2\u0180\u0181\7g\2\2\u0181\u0182\7t\2\2\u0182\u0183\7/\2\2"+ - "\u0183\u0184\7o\2\2\u0184\u0185\7k\2\2\u0185\u0186\7n\2\2\u0186\u0187"+ - "\7n\2\2\u0187\u0188\7g\2\2\u0188$\3\2\2\2\u0189\u018a\7|\2\2\u018a\u018b"+ - "\7g\2\2\u018b\u018c\7t\2\2\u018c\u018d\7q\2\2\u018d\u018e\7/\2\2\u018e"+ - "\u018f\7f\2\2\u018f\u0190\7k\2\2\u0190\u0191\7i\2\2\u0191\u0192\7k\2\2"+ - "\u0192\u0193\7v\2\2\u0193&\3\2\2\2\u0194\u0195\7f\2\2\u0195\u0196\7k\2"+ - "\2\u0196\u0197\7i\2\2\u0197\u0198\7k\2\2\u0198\u0199\7v\2\2\u0199(\3\2"+ - "\2\2\u019a\u019b\7r\2\2\u019b\u019c\7c\2\2\u019c\u019d\7v\2\2\u019d\u019e"+ - "\7v\2\2\u019e\u019f\7g\2\2\u019f\u01a0\7t\2\2\u01a0\u01a1\7p\2\2\u01a1"+ - "\u01a2\7/\2\2\u01a2\u01a3\7u\2\2\u01a3\u01a4\7g\2\2\u01a4\u01a5\7r\2\2"+ - "\u01a5\u01a6\7c\2\2\u01a6\u01a7\7t\2\2\u01a7\u01a8\7c\2\2\u01a8\u01a9"+ - "\7v\2\2\u01a9\u01aa\7q\2\2\u01aa\u01ab\7t\2\2\u01ab*\3\2\2\2\u01ac\u01ad"+ - "\7k\2\2\u01ad\u01ae\7o\2\2\u01ae\u01af\7r\2\2\u01af\u01b0\7q\2\2\u01b0"+ - "\u01b1\7t\2\2\u01b1\u01b2\7v\2\2\u01b2,\3\2\2\2\u01b3\u01b4\7.\2\2\u01b4"+ - ".\3\2\2\2\u01b5\u01b6\7x\2\2\u01b6\u01b7\7c\2\2\u01b7\u01b8\7t\2\2\u01b8"+ - "\u01b9\7k\2\2\u01b9\u01ba\7c\2\2\u01ba\u01bb\7d\2\2\u01bb\u01bc\7n\2\2"+ - "\u01bc\u01bd\7g\2\2\u01bd\60\3\2\2\2\u01be\u01bf\7<\2\2\u01bf\u01c0\7"+ - "?\2\2\u01c0\62\3\2\2\2\u01c1\u01c2\7g\2\2\u01c2\u01c3\7z\2\2\u01c3\u01c4"+ - "\7v\2\2\u01c4\u01c5\7g\2\2\u01c5\u01c6\7t\2\2\u01c6\u01c7\7p\2\2\u01c7"+ - "\u01c8\7c\2\2\u01c8\u01c9\7n\2\2\u01c9\64\3\2\2\2\u01ca\u01cb\7h\2\2\u01cb"+ - "\u01cc\7w\2\2\u01cc\u01cd\7p\2\2\u01cd\u01ce\7e\2\2\u01ce\u01cf\7v\2\2"+ - "\u01cf\u01d0\7k\2\2\u01d0\u01d1\7q\2\2\u01d1\u01d2\7p\2\2\u01d2\66\3\2"+ - "\2\2\u01d3\u01d4\7*\2\2\u01d48\3\2\2\2\u01d5\u01d6\7+\2\2\u01d6:\3\2\2"+ - "\2\u01d7\u01d8\7}\2\2\u01d8<\3\2\2\2\u01d9\u01da\7\177\2\2\u01da>\3\2"+ - "\2\2\u01db\u01dc\7&\2\2\u01dc@\3\2\2\2\u01dd\u01de\7~\2\2\u01deB\3\2\2"+ - "\2\u01df\u01e0\7,\2\2\u01e0D\3\2\2\2\u01e1\u01e2\7g\2\2\u01e2\u01e3\7"+ - "s\2\2\u01e3F\3\2\2\2\u01e4\u01e5\7p\2\2\u01e5\u01e6\7g\2\2\u01e6H\3\2"+ - "\2\2\u01e7\u01e8\7n\2\2\u01e8\u01e9\7v\2\2\u01e9J\3\2\2\2\u01ea\u01eb"+ - "\7n\2\2\u01eb\u01ec\7g\2\2\u01ecL\3\2\2\2\u01ed\u01ee\7i\2\2\u01ee\u01ef"+ - "\7v\2\2\u01efN\3\2\2\2\u01f0\u01f1\7i\2\2\u01f1\u01f2\7g\2\2\u01f2P\3"+ - "\2\2\2\u01f3\u01f4\7#\2\2\u01f4\u01f5\7?\2\2\u01f5R\3\2\2\2\u01f6\u01f7"+ - "\7>\2\2\u01f7T\3\2\2\2\u01f8\u01f9\7>\2\2\u01f9\u01fa\7?\2\2\u01faV\3"+ - "\2\2\2\u01fb\u01fc\7@\2\2\u01fcX\3\2\2\2\u01fd\u01fe\7@\2\2\u01fe\u01ff"+ - "\7?\2\2\u01ffZ\3\2\2\2\u0200\u0201\7~\2\2\u0201\u0202\7~\2\2\u0202\\\3"+ - "\2\2\2\u0203\u0204\7-\2\2\u0204^\3\2\2\2\u0205\u0206\7/\2\2\u0206`\3\2"+ - "\2\2\u0207\u0208\7f\2\2\u0208\u0209\7k\2\2\u0209\u020a\7x\2\2\u020ab\3"+ - "\2\2\2\u020b\u020c\7k\2\2\u020c\u020d\7f\2\2\u020d\u020e\7k\2\2\u020e"+ - "\u020f\7x\2\2\u020fd\3\2\2\2\u0210\u0211\7o\2\2\u0211\u0212\7q\2\2\u0212"+ - "\u0213\7f\2\2\u0213f\3\2\2\2\u0214\u0215\7#\2\2\u0215h\3\2\2\2\u0216\u0217"+ - "\7]\2\2\u0217j\3\2\2\2\u0218\u0219\7_\2\2\u0219l\3\2\2\2\u021a\u021b\7"+ - "\60\2\2\u021bn\3\2\2\2\u021c\u021d\7&\2\2\u021d\u021e\7&\2\2\u021ep\3"+ - "\2\2\2\u021f\u0220\7%\2\2\u0220r\3\2\2\2\u0221\u0222\7}\2\2\u0222\u0223"+ - "\7~\2\2\u0223t\3\2\2\2\u0224\u0225\7~\2\2\u0225\u0226\7\177\2\2\u0226"+ - "v\3\2\2\2\u0227\u0228\7h\2\2\u0228\u0229\7q\2\2\u0229\u022a\7t\2\2\u022a"+ - "x\3\2\2\2\u022b\u022c\7n\2\2\u022c\u022d\7g\2\2\u022d\u022e\7v\2\2\u022e"+ - "z\3\2\2\2\u022f\u0230\7y\2\2\u0230\u0231\7j\2\2\u0231\u0232\7g\2\2\u0232"+ - "\u0233\7t\2\2\u0233\u0234\7g\2\2\u0234|\3\2\2\2\u0235\u0236\7i\2\2\u0236"+ - "\u0237\7t\2\2\u0237\u0238\7q\2\2\u0238\u0239\7w\2\2\u0239\u023a\7r\2\2"+ - "\u023a~\3\2\2\2\u023b\u023c\7d\2\2\u023c\u023d\7{\2\2\u023d\u0080\3\2"+ - "\2\2\u023e\u023f\7q\2\2\u023f\u0240\7t\2\2\u0240\u0241\7f\2\2\u0241\u0242"+ - "\7g\2\2\u0242\u0243\7t\2\2\u0243\u0082\3\2\2\2\u0244\u0245\7t\2\2\u0245"+ - "\u0246\7g\2\2\u0246\u0247\7v\2\2\u0247\u0248\7w\2\2\u0248\u0249\7t\2\2"+ - "\u0249\u024a\7p\2\2\u024a\u0084\3\2\2\2\u024b\u024c\7k\2\2\u024c\u024d"+ - "\7h\2\2\u024d\u0086\3\2\2\2\u024e\u024f\7k\2\2\u024f\u0250\7p\2\2\u0250"+ - "\u0088\3\2\2\2\u0251\u0252\7c\2\2\u0252\u0253\7u\2\2\u0253\u008a\3\2\2"+ - "\2\u0254\u0255\7c\2\2\u0255\u0256\7v\2\2\u0256\u008c\3\2\2\2\u0257\u0258"+ - "\7c\2\2\u0258\u0259\7n\2\2\u0259\u025a\7n\2\2\u025a\u025b\7q\2\2\u025b"+ - "\u025c\7y\2\2\u025c\u025d\7k\2\2\u025d\u025e\7p\2\2\u025e\u025f\7i\2\2"+ - "\u025f\u008e\3\2\2\2\u0260\u0261\7g\2\2\u0261\u0262\7o\2\2\u0262\u0263"+ - "\7r\2\2\u0263\u0264\7v\2\2\u0264\u0265\7{\2\2\u0265\u0090\3\2\2\2\u0266"+ - "\u0267\7e\2\2\u0267\u0268\7q\2\2\u0268\u0269\7w\2\2\u0269\u026a\7p\2\2"+ - "\u026a\u026b\7v\2\2\u026b\u0092\3\2\2\2\u026c\u026d\7u\2\2\u026d\u026e"+ - "\7v\2\2\u026e\u026f\7c\2\2\u026f\u0270\7d\2\2\u0270\u0271\7n\2\2\u0271"+ - "\u0272\7g\2\2\u0272\u0094\3\2\2\2\u0273\u0274\7c\2\2\u0274\u0275\7u\2"+ - "\2\u0275\u0276\7e\2\2\u0276\u0277\7g\2\2\u0277\u0278\7p\2\2\u0278\u0279"+ - "\7f\2\2\u0279\u027a\7k\2\2\u027a\u027b\7p\2\2\u027b\u027c\7i\2\2\u027c"+ - "\u0096\3\2\2\2\u027d\u027e\7f\2\2\u027e\u027f\7g\2\2\u027f\u0280\7u\2"+ - "\2\u0280\u0281\7e\2\2\u0281\u0282\7g\2\2\u0282\u0283\7p\2\2\u0283\u0284"+ - "\7f\2\2\u0284\u0285\7k\2\2\u0285\u0286\7p\2\2\u0286\u0287\7i\2\2\u0287"+ - "\u0098\3\2\2\2\u0288\u0289\7u\2\2\u0289\u028a\7q\2\2\u028a\u028b\7o\2"+ - "\2\u028b\u028c\7g\2\2\u028c\u009a\3\2\2\2\u028d\u028e\7g\2\2\u028e\u028f"+ - "\7x\2\2\u028f\u0290\7g\2\2\u0290\u0291\7t\2\2\u0291\u0292\7{\2\2\u0292"+ - "\u009c\3\2\2\2\u0293\u0294\7u\2\2\u0294\u0295\7c\2\2\u0295\u0296\7v\2"+ - "\2\u0296\u0297\7k\2\2\u0297\u0298\7u\2\2\u0298\u0299\7h\2\2\u0299\u029a"+ - "\7k\2\2\u029a\u029b\7g\2\2\u029b\u029c\7u\2\2\u029c\u009e\3\2\2\2\u029d"+ - "\u029e\7e\2\2\u029e\u029f\7q\2\2\u029f\u02a0\7n\2\2\u02a0\u02a1\7n\2\2"+ - "\u02a1\u02a2\7c\2\2\u02a2\u02a3\7v\2\2\u02a3\u02a4\7k\2\2\u02a4\u02a5"+ - "\7q\2\2\u02a5\u02a6\7p\2\2\u02a6\u00a0\3\2\2\2\u02a7\u02a8\7i\2\2\u02a8"+ - "\u02a9\7t\2\2\u02a9\u02aa\7g\2\2\u02aa\u02ab\7c\2\2\u02ab\u02ac\7v\2\2"+ - "\u02ac\u02ad\7g\2\2\u02ad\u02ae\7u\2\2\u02ae\u02af\7v\2\2\u02af\u00a2"+ - "\3\2\2\2\u02b0\u02b1\7n\2\2\u02b1\u02b2\7g\2\2\u02b2\u02b3\7c\2\2\u02b3"+ - "\u02b4\7u\2\2\u02b4\u02b5\7v\2\2\u02b5\u00a4\3\2\2\2\u02b6\u02b7\7u\2"+ - "\2\u02b7\u02b8\7y\2\2\u02b8\u02b9\7k\2\2\u02b9\u02ba\7v\2\2\u02ba\u02bb"+ - "\7e\2\2\u02bb\u02bc\7j\2\2\u02bc\u00a6\3\2\2\2\u02bd\u02be\7e\2\2\u02be"+ - "\u02bf\7c\2\2\u02bf\u02c0\7u\2\2\u02c0\u02c1\7g\2\2\u02c1\u00a8\3\2\2"+ - "\2\u02c2\u02c3\7v\2\2\u02c3\u02c4\7t\2\2\u02c4\u02c5\7{\2\2\u02c5\u00aa"+ - "\3\2\2\2\u02c6\u02c7\7e\2\2\u02c7\u02c8\7c\2\2\u02c8\u02c9\7v\2\2\u02c9"+ - "\u02ca\7e\2\2\u02ca\u02cb\7j\2\2\u02cb\u00ac\3\2\2\2\u02cc\u02cd\7f\2"+ - "\2\u02cd\u02ce\7g\2\2\u02ce\u02cf\7h\2\2\u02cf\u02d0\7c\2\2\u02d0\u02d1"+ - "\7w\2\2\u02d1\u02d2\7n\2\2\u02d2\u02d3\7v\2\2\u02d3\u00ae\3\2\2\2\u02d4"+ - "\u02d5\7v\2\2\u02d5\u02d6\7j\2\2\u02d6\u02d7\7g\2\2\u02d7\u02d8\7p\2\2"+ - "\u02d8\u00b0\3\2\2\2\u02d9\u02da\7g\2\2\u02da\u02db\7n\2\2\u02db\u02dc"+ - "\7u\2\2\u02dc\u02dd\7g\2\2\u02dd\u00b2\3\2\2\2\u02de\u02df\7v\2\2\u02df"+ - "\u02e0\7{\2\2\u02e0\u02e1\7r\2\2\u02e1\u02e2\7g\2\2\u02e2\u02e3\7u\2\2"+ - "\u02e3\u02e4\7y\2\2\u02e4\u02e5\7k\2\2\u02e5\u02e6\7v\2\2\u02e6\u02e7"+ - "\7e\2\2\u02e7\u02e8\7j\2\2\u02e8\u00b4\3\2\2\2\u02e9\u02ea\7q\2\2\u02ea"+ - "\u02eb\7t\2\2\u02eb\u00b6\3\2\2\2\u02ec\u02ed\7c\2\2\u02ed\u02ee\7p\2"+ - "\2\u02ee\u02ef\7f\2\2\u02ef\u00b8\3\2\2\2\u02f0\u02f1\7p\2\2\u02f1\u02f2"+ - "\7q\2\2\u02f2\u02f3\7v\2\2\u02f3\u00ba\3\2\2\2\u02f4\u02f5\7v\2\2\u02f5"+ - "\u02f6\7q\2\2\u02f6\u00bc\3\2\2\2\u02f7\u02f8\7k\2\2\u02f8\u02f9\7p\2"+ - "\2\u02f9\u02fa\7u\2\2\u02fa\u02fb\7v\2\2\u02fb\u02fc\7c\2\2\u02fc\u02fd"+ - "\7p\2\2\u02fd\u02fe\7e\2\2\u02fe\u02ff\7g\2\2\u02ff\u00be\3\2\2\2\u0300"+ - "\u0301\7q\2\2\u0301\u0302\7h\2\2\u0302\u00c0\3\2\2\2\u0303\u0304\7v\2"+ - "\2\u0304\u0305\7t\2\2\u0305\u0306\7g\2\2\u0306\u0307\7c\2\2\u0307\u0308"+ - "\7v\2\2\u0308\u00c2\3\2\2\2\u0309\u030a\7e\2\2\u030a\u030b\7c\2\2\u030b"+ - "\u030c\7u\2\2\u030c\u030d\7v\2\2\u030d\u00c4\3\2\2\2\u030e\u030f\7e\2"+ - "\2\u030f\u0310\7c\2\2\u0310\u0311\7u\2\2\u0311\u0312\7v\2\2\u0312\u0313"+ - "\7c\2\2\u0313\u0314\7d\2\2\u0314\u0315\7n\2\2\u0315\u0316\7g\2\2\u0316"+ - "\u00c6\3\2\2\2\u0317\u0318\7x\2\2\u0318\u0319\7g\2\2\u0319\u031a\7t\2"+ - "\2\u031a\u031b\7u\2\2\u031b\u031c\7k\2\2\u031c\u031d\7q\2\2\u031d\u031e"+ - "\7p\2\2\u031e\u00c8\3\2\2\2\u031f\u0320\7l\2\2\u0320\u0321\7u\2\2\u0321"+ - "\u0322\7q\2\2\u0322\u0323\7p\2\2\u0323\u0324\7k\2\2\u0324\u0325\7s\2\2"+ - "\u0325\u00ca\3\2\2\2\u0326\u032b\7$\2\2\u0327\u032a\5\u00cdg\2\u0328\u032a"+ - "\n\2\2\2\u0329\u0327\3\2\2\2\u0329\u0328\3\2\2\2\u032a\u032d\3\2\2\2\u032b"+ - "\u0329\3\2\2\2\u032b\u032c\3\2\2\2\u032c\u032e\3\2\2\2\u032d\u032b\3\2"+ - "\2\2\u032e\u032f\7$\2\2\u032f\u00cc\3\2\2\2\u0330\u0333\7^\2\2\u0331\u0334"+ - "\t\3\2\2\u0332\u0334\5\u00cfh\2\u0333\u0331\3\2\2\2\u0333\u0332\3\2\2"+ - "\2\u0334\u00ce\3\2\2\2\u0335\u0336\7w\2\2\u0336\u0337\5\u00d1i\2\u0337"+ - "\u0338\5\u00d1i\2\u0338\u0339\5\u00d1i\2\u0339\u033a\5\u00d1i\2\u033a"+ - "\u00d0\3\2\2\2\u033b\u033c\t\4\2\2\u033c\u00d2\3\2\2\2\u033d\u033e\7A"+ - "\2\2\u033e\u00d4\3\2\2\2\u033f\u0340\7p\2\2\u0340\u0341\7w\2\2\u0341\u0342"+ - "\7n\2\2\u0342\u0343\7n\2\2\u0343\u00d6\3\2\2\2\u0344\u0347\5\u00d9m\2"+ - "\u0345\u0347\5\u00dbn\2\u0346\u0344\3\2\2\2\u0346\u0345\3\2\2\2\u0347"+ - "\u00d8\3\2\2\2\u0348\u034c\5\u00ddo\2\u0349\u034c\5\u00dfp\2\u034a\u034c"+ - "\5\u00e1q\2\u034b\u0348\3\2\2\2\u034b\u0349\3\2\2\2\u034b\u034a\3\2\2"+ - "\2\u034c\u00da\3\2\2\2\u034d\u034e\7v\2\2\u034e\u034f\7t\2\2\u034f\u0350"+ - "\7w\2\2\u0350\u0357\7g\2\2\u0351\u0352\7h\2\2\u0352\u0353\7c\2\2\u0353"+ - "\u0354\7n\2\2\u0354\u0355\7u\2\2\u0355\u0357\7g\2\2\u0356\u034d\3\2\2"+ - "\2\u0356\u0351\3\2\2\2\u0357\u00dc\3\2\2\2\u0358\u0359\5\u00e3r\2\u0359"+ - "\u00de\3\2\2\2\u035a\u035b\7\60\2\2\u035b\u0365\5\u00e3r\2\u035c\u035d"+ - "\5\u00e3r\2\u035d\u0361\7\60\2\2\u035e\u0360\t\5\2\2\u035f\u035e\3\2\2"+ - "\2\u0360\u0363\3\2\2\2\u0361\u035f\3\2\2\2\u0361\u0362\3\2\2\2\u0362\u0365"+ - "\3\2\2\2\u0363\u0361\3\2\2\2\u0364\u035a\3\2\2\2\u0364\u035c\3\2\2\2\u0365"+ - "\u00e0\3\2\2\2\u0366\u0367\7\60\2\2\u0367\u0373\5\u00e3r\2\u0368\u0370"+ - "\5\u00e3r\2\u0369\u036d\7\60\2\2\u036a\u036c\t\5\2\2\u036b\u036a\3\2\2"+ - "\2\u036c\u036f\3\2\2\2\u036d\u036b\3\2\2\2\u036d\u036e\3\2\2\2\u036e\u0371"+ - "\3\2\2\2\u036f\u036d\3\2\2\2\u0370\u0369\3\2\2\2\u0370\u0371\3\2\2\2\u0371"+ - "\u0373\3\2\2\2\u0372\u0366\3\2\2\2\u0372\u0368\3\2\2\2\u0373\u0374\3\2"+ - "\2\2\u0374\u0376\t\6\2\2\u0375\u0377\t\7\2\2\u0376\u0375\3\2\2\2\u0376"+ - "\u0377\3\2\2\2\u0377\u0378\3\2\2\2\u0378\u0379\5\u00e3r\2\u0379\u00e2"+ - "\3\2\2\2\u037a\u037c\t\5\2\2\u037b\u037a\3\2\2\2\u037c\u037d\3\2\2\2\u037d"+ - "\u037b\3\2\2\2\u037d\u037e\3\2\2\2\u037e\u00e4\3\2\2\2\u037f\u0380\t\b"+ - "\2\2\u0380\u0381\3\2\2\2\u0381\u0382\bs\2\2\u0382\u00e6\3\2\2\2\u0383"+ - "\u0387\5\u00e9u\2\u0384\u0386\5\u00ebv\2\u0385\u0384\3\2\2\2\u0386\u0389"+ - "\3\2\2\2\u0387\u0385\3\2\2\2\u0387\u0388\3\2\2\2\u0388\u00e8\3\2\2\2\u0389"+ - "\u0387\3\2\2\2\u038a\u038c\t\t\2\2\u038b\u038a\3\2\2\2\u038c\u00ea\3\2"+ - "\2\2\u038d\u0390\5\u00e9u\2\u038e\u0390\t\n\2\2\u038f\u038d\3\2\2\2\u038f"+ - "\u038e\3\2\2\2\u0390\u00ec\3\2\2\2\u0391\u0392\7*\2\2\u0392\u039b\7<\2"+ - "\2\u0393\u039a\5\u00edw\2\u0394\u0395\7*\2\2\u0395\u039a\n\13\2\2\u0396"+ - "\u0397\7<\2\2\u0397\u039a\n\f\2\2\u0398\u039a\n\r\2\2\u0399\u0393\3\2"+ - "\2\2\u0399\u0394\3\2\2\2\u0399\u0396\3\2\2\2\u0399\u0398\3\2\2\2\u039a"+ - "\u039d\3\2\2\2\u039b\u0399\3\2\2\2\u039b\u039c\3\2\2\2\u039c\u039f\3\2"+ - "\2\2\u039d\u039b\3\2\2\2\u039e\u03a0\7<\2\2\u039f\u039e\3\2\2\2\u03a0"+ - "\u03a1\3\2\2\2\u03a1\u039f\3\2\2\2\u03a1\u03a2\3\2\2\2\u03a2\u03a3\3\2"+ - "\2\2\u03a3\u03a4\7+\2\2\u03a4\u03a5\3\2\2\2\u03a5\u03a6\bw\2\2\u03a6\u00ee"+ - "\3\2\2\2\u03a7\u03a8\n\16\2\2\u03a8\u00f0\3\2\2\2\26\2\u0329\u032b\u0333"+ - "\u0346\u034b\u0356\u0361\u0364\u036d\u0370\u0372\u0376\u037d\u0387\u038b"+ - "\u038f\u0399\u039b\u03a1\3\2\3\2"; + "\2\2\u00c5\3\2\2\2\2\u00c7\3\2\2\2\2\u00c9\3\2\2\2\2\u00cb\3\2\2\2\2\u00cd"+ + "\3\2\2\2\2\u00cf\3\2\2\2\2\u00d7\3\2\2\2\2\u00d9\3\2\2\2\2\u00db\3\2\2"+ + "\2\2\u00dd\3\2\2\2\2\u00df\3\2\2\2\2\u00e1\3\2\2\2\2\u00e3\3\2\2\2\2\u00e5"+ + "\3\2\2\2\2\u00e9\3\2\2\2\2\u00eb\3\2\2\2\2\u00f1\3\2\2\2\2\u00f3\3\2\2"+ + "\2\3\u00f5\3\2\2\2\5\u00f7\3\2\2\2\7\u00fe\3\2\2\2\t\u0108\3\2\2\2\13"+ + "\u010a\3\2\2\2\r\u0112\3\2\2\2\17\u011b\3\2\2\2\21\u0123\3\2\2\2\23\u012d"+ + "\3\2\2\2\25\u013c\3\2\2\2\27\u013e\3\2\2\2\31\u0150\3\2\2\2\33\u0163\3"+ + "\2\2\2\35\u016c\3\2\2\2\37\u0177\3\2\2\2!\u017b\3\2\2\2#\u0183\3\2\2\2"+ + "%\u018d\3\2\2\2\'\u0198\3\2\2\2)\u019e\3\2\2\2+\u01b0\3\2\2\2-\u01b7\3"+ + "\2\2\2/\u01b9\3\2\2\2\61\u01c2\3\2\2\2\63\u01c5\3\2\2\2\65\u01ce\3\2\2"+ + "\2\67\u01d7\3\2\2\29\u01d9\3\2\2\2;\u01db\3\2\2\2=\u01dd\3\2\2\2?\u01df"+ + "\3\2\2\2A\u01e1\3\2\2\2C\u01e3\3\2\2\2E\u01e5\3\2\2\2G\u01e8\3\2\2\2I"+ + "\u01eb\3\2\2\2K\u01ee\3\2\2\2M\u01f1\3\2\2\2O\u01f4\3\2\2\2Q\u01f7\3\2"+ + "\2\2S\u01fa\3\2\2\2U\u01fc\3\2\2\2W\u01ff\3\2\2\2Y\u0201\3\2\2\2[\u0204"+ + "\3\2\2\2]\u0207\3\2\2\2_\u0209\3\2\2\2a\u020b\3\2\2\2c\u020f\3\2\2\2e"+ + "\u0214\3\2\2\2g\u0218\3\2\2\2i\u021a\3\2\2\2k\u021c\3\2\2\2m\u021e\3\2"+ + "\2\2o\u0220\3\2\2\2q\u0223\3\2\2\2s\u0225\3\2\2\2u\u0228\3\2\2\2w\u022b"+ + "\3\2\2\2y\u022f\3\2\2\2{\u0233\3\2\2\2}\u0239\3\2\2\2\177\u023f\3\2\2"+ + "\2\u0081\u0242\3\2\2\2\u0083\u0248\3\2\2\2\u0085\u024f\3\2\2\2\u0087\u0252"+ + "\3\2\2\2\u0089\u0255\3\2\2\2\u008b\u0258\3\2\2\2\u008d\u025b\3\2\2\2\u008f"+ + "\u0264\3\2\2\2\u0091\u026a\3\2\2\2\u0093\u0270\3\2\2\2\u0095\u0277\3\2"+ + "\2\2\u0097\u0281\3\2\2\2\u0099\u028c\3\2\2\2\u009b\u0291\3\2\2\2\u009d"+ + "\u0297\3\2\2\2\u009f\u02a1\3\2\2\2\u00a1\u02ab\3\2\2\2\u00a3\u02b4\3\2"+ + "\2\2\u00a5\u02ba\3\2\2\2\u00a7\u02c1\3\2\2\2\u00a9\u02c6\3\2\2\2\u00ab"+ + "\u02ca\3\2\2\2\u00ad\u02d0\3\2\2\2\u00af\u02d8\3\2\2\2\u00b1\u02dd\3\2"+ + "\2\2\u00b3\u02e2\3\2\2\2\u00b5\u02ed\3\2\2\2\u00b7\u02f0\3\2\2\2\u00b9"+ + "\u02f4\3\2\2\2\u00bb\u02f8\3\2\2\2\u00bd\u02fb\3\2\2\2\u00bf\u0304\3\2"+ + "\2\2\u00c1\u0307\3\2\2\2\u00c3\u0312\3\2\2\2\u00c5\u0315\3\2\2\2\u00c7"+ + "\u031b\3\2\2\2\u00c9\u0320\3\2\2\2\u00cb\u0329\3\2\2\2\u00cd\u0331\3\2"+ + "\2\2\u00cf\u0338\3\2\2\2\u00d1\u0342\3\2\2\2\u00d3\u0347\3\2\2\2\u00d5"+ + "\u034d\3\2\2\2\u00d7\u034f\3\2\2\2\u00d9\u0351\3\2\2\2\u00db\u0358\3\2"+ + "\2\2\u00dd\u035d\3\2\2\2\u00df\u0368\3\2\2\2\u00e1\u036a\3\2\2\2\u00e3"+ + "\u0376\3\2\2\2\u00e5\u0384\3\2\2\2\u00e7\u038d\3\2\2\2\u00e9\u0391\3\2"+ + "\2\2\u00eb\u0395\3\2\2\2\u00ed\u039d\3\2\2\2\u00ef\u03a1\3\2\2\2\u00f1"+ + "\u03a3\3\2\2\2\u00f3\u03b9\3\2\2\2\u00f5\u00f6\7=\2\2\u00f6\4\3\2\2\2"+ + "\u00f7\u00f8\7o\2\2\u00f8\u00f9\7q\2\2\u00f9\u00fa\7f\2\2\u00fa\u00fb"+ + "\7w\2\2\u00fb\u00fc\7n\2\2\u00fc\u00fd\7g\2\2\u00fd\6\3\2\2\2\u00fe\u00ff"+ + "\7p\2\2\u00ff\u0100\7c\2\2\u0100\u0101\7o\2\2\u0101\u0102\7g\2\2\u0102"+ + "\u0103\7u\2\2\u0103\u0104\7r\2\2\u0104\u0105\7c\2\2\u0105\u0106\7e\2\2"+ + "\u0106\u0107\7g\2\2\u0107\b\3\2\2\2\u0108\u0109\7?\2\2\u0109\n\3\2\2\2"+ + "\u010a\u010b\7f\2\2\u010b\u010c\7g\2\2\u010c\u010d\7e\2\2\u010d\u010e"+ + "\7n\2\2\u010e\u010f\7c\2\2\u010f\u0110\7t\2\2\u0110\u0111\7g\2\2\u0111"+ + "\f\3\2\2\2\u0112\u0113\7q\2\2\u0113\u0114\7t\2\2\u0114\u0115\7f\2\2\u0115"+ + "\u0116\7g\2\2\u0116\u0117\7t\2\2\u0117\u0118\7k\2\2\u0118\u0119\7p\2\2"+ + "\u0119\u011a\7i\2\2\u011a\16\3\2\2\2\u011b\u011c\7q\2\2\u011c\u011d\7"+ + "t\2\2\u011d\u011e\7f\2\2\u011e\u011f\7g\2\2\u011f\u0120\7t\2\2\u0120\u0121"+ + "\7g\2\2\u0121\u0122\7f\2\2\u0122\20\3\2\2\2\u0123\u0124\7w\2\2\u0124\u0125"+ + "\7p\2\2\u0125\u0126\7q\2\2\u0126\u0127\7t\2\2\u0127\u0128\7f\2\2\u0128"+ + "\u0129\7g\2\2\u0129\u012a\7t\2\2\u012a\u012b\7g\2\2\u012b\u012c\7f\2\2"+ + "\u012c\22\3\2\2\2\u012d\u012e\7f\2\2\u012e\u012f\7g\2\2\u012f\u0130\7"+ + "e\2\2\u0130\u0131\7k\2\2\u0131\u0132\7o\2\2\u0132\u0133\7c\2\2\u0133\u0134"+ + "\7n\2\2\u0134\u0135\7/\2\2\u0135\u0136\7h\2\2\u0136\u0137\7q\2\2\u0137"+ + "\u0138\7t\2\2\u0138\u0139\7o\2\2\u0139\u013a\7c\2\2\u013a\u013b\7v\2\2"+ + "\u013b\24\3\2\2\2\u013c\u013d\7<\2\2\u013d\26\3\2\2\2\u013e\u013f\7f\2"+ + "\2\u013f\u0140\7g\2\2\u0140\u0141\7e\2\2\u0141\u0142\7k\2\2\u0142\u0143"+ + "\7o\2\2\u0143\u0144\7c\2\2\u0144\u0145\7n\2\2\u0145\u0146\7/\2\2\u0146"+ + "\u0147\7u\2\2\u0147\u0148\7g\2\2\u0148\u0149\7r\2\2\u0149\u014a\7c\2\2"+ + "\u014a\u014b\7t\2\2\u014b\u014c\7c\2\2\u014c\u014d\7v\2\2\u014d\u014e"+ + "\7q\2\2\u014e\u014f\7t\2\2\u014f\30\3\2\2\2\u0150\u0151\7i\2\2\u0151\u0152"+ + "\7t\2\2\u0152\u0153\7q\2\2\u0153\u0154\7w\2\2\u0154\u0155\7r\2\2\u0155"+ + "\u0156\7k\2\2\u0156\u0157\7p\2\2\u0157\u0158\7i\2\2\u0158\u0159\7/\2\2"+ + "\u0159\u015a\7u\2\2\u015a\u015b\7g\2\2\u015b\u015c\7r\2\2\u015c\u015d"+ + "\7c\2\2\u015d\u015e\7t\2\2\u015e\u015f\7c\2\2\u015f\u0160\7v\2\2\u0160"+ + "\u0161\7q\2\2\u0161\u0162\7t\2\2\u0162\32\3\2\2\2\u0163\u0164\7k\2\2\u0164"+ + "\u0165\7p\2\2\u0165\u0166\7h\2\2\u0166\u0167\7k\2\2\u0167\u0168\7p\2\2"+ + "\u0168\u0169\7k\2\2\u0169\u016a\7v\2\2\u016a\u016b\7{\2\2\u016b\34\3\2"+ + "\2\2\u016c\u016d\7o\2\2\u016d\u016e\7k\2\2\u016e\u016f\7p\2\2\u016f\u0170"+ + "\7w\2\2\u0170\u0171\7u\2\2\u0171\u0172\7/\2\2\u0172\u0173\7u\2\2\u0173"+ + "\u0174\7k\2\2\u0174\u0175\7i\2\2\u0175\u0176\7p\2\2\u0176\36\3\2\2\2\u0177"+ + "\u0178\7P\2\2\u0178\u0179\7c\2\2\u0179\u017a\7P\2\2\u017a \3\2\2\2\u017b"+ + "\u017c\7r\2\2\u017c\u017d\7g\2\2\u017d\u017e\7t\2\2\u017e\u017f\7e\2\2"+ + "\u017f\u0180\7g\2\2\u0180\u0181\7p\2\2\u0181\u0182\7v\2\2\u0182\"\3\2"+ + "\2\2\u0183\u0184\7r\2\2\u0184\u0185\7g\2\2\u0185\u0186\7t\2\2\u0186\u0187"+ + "\7/\2\2\u0187\u0188\7o\2\2\u0188\u0189\7k\2\2\u0189\u018a\7n\2\2\u018a"+ + "\u018b\7n\2\2\u018b\u018c\7g\2\2\u018c$\3\2\2\2\u018d\u018e\7|\2\2\u018e"+ + "\u018f\7g\2\2\u018f\u0190\7t\2\2\u0190\u0191\7q\2\2\u0191\u0192\7/\2\2"+ + "\u0192\u0193\7f\2\2\u0193\u0194\7k\2\2\u0194\u0195\7i\2\2\u0195\u0196"+ + "\7k\2\2\u0196\u0197\7v\2\2\u0197&\3\2\2\2\u0198\u0199\7f\2\2\u0199\u019a"+ + "\7k\2\2\u019a\u019b\7i\2\2\u019b\u019c\7k\2\2\u019c\u019d\7v\2\2\u019d"+ + "(\3\2\2\2\u019e\u019f\7r\2\2\u019f\u01a0\7c\2\2\u01a0\u01a1\7v\2\2\u01a1"+ + "\u01a2\7v\2\2\u01a2\u01a3\7g\2\2\u01a3\u01a4\7t\2\2\u01a4\u01a5\7p\2\2"+ + "\u01a5\u01a6\7/\2\2\u01a6\u01a7\7u\2\2\u01a7\u01a8\7g\2\2\u01a8\u01a9"+ + "\7r\2\2\u01a9\u01aa\7c\2\2\u01aa\u01ab\7t\2\2\u01ab\u01ac\7c\2\2\u01ac"+ + "\u01ad\7v\2\2\u01ad\u01ae\7q\2\2\u01ae\u01af\7t\2\2\u01af*\3\2\2\2\u01b0"+ + "\u01b1\7k\2\2\u01b1\u01b2\7o\2\2\u01b2\u01b3\7r\2\2\u01b3\u01b4\7q\2\2"+ + "\u01b4\u01b5\7t\2\2\u01b5\u01b6\7v\2\2\u01b6,\3\2\2\2\u01b7\u01b8\7.\2"+ + "\2\u01b8.\3\2\2\2\u01b9\u01ba\7x\2\2\u01ba\u01bb\7c\2\2\u01bb\u01bc\7"+ + "t\2\2\u01bc\u01bd\7k\2\2\u01bd\u01be\7c\2\2\u01be\u01bf\7d\2\2\u01bf\u01c0"+ + "\7n\2\2\u01c0\u01c1\7g\2\2\u01c1\60\3\2\2\2\u01c2\u01c3\7<\2\2\u01c3\u01c4"+ + "\7?\2\2\u01c4\62\3\2\2\2\u01c5\u01c6\7g\2\2\u01c6\u01c7\7z\2\2\u01c7\u01c8"+ + "\7v\2\2\u01c8\u01c9\7g\2\2\u01c9\u01ca\7t\2\2\u01ca\u01cb\7p\2\2\u01cb"+ + "\u01cc\7c\2\2\u01cc\u01cd\7n\2\2\u01cd\64\3\2\2\2\u01ce\u01cf\7h\2\2\u01cf"+ + "\u01d0\7w\2\2\u01d0\u01d1\7p\2\2\u01d1\u01d2\7e\2\2\u01d2\u01d3\7v\2\2"+ + "\u01d3\u01d4\7k\2\2\u01d4\u01d5\7q\2\2\u01d5\u01d6\7p\2\2\u01d6\66\3\2"+ + "\2\2\u01d7\u01d8\7*\2\2\u01d88\3\2\2\2\u01d9\u01da\7+\2\2\u01da:\3\2\2"+ + "\2\u01db\u01dc\7}\2\2\u01dc<\3\2\2\2\u01dd\u01de\7\177\2\2\u01de>\3\2"+ + "\2\2\u01df\u01e0\7&\2\2\u01e0@\3\2\2\2\u01e1\u01e2\7~\2\2\u01e2B\3\2\2"+ + "\2\u01e3\u01e4\7,\2\2\u01e4D\3\2\2\2\u01e5\u01e6\7g\2\2\u01e6\u01e7\7"+ + "s\2\2\u01e7F\3\2\2\2\u01e8\u01e9\7p\2\2\u01e9\u01ea\7g\2\2\u01eaH\3\2"+ + "\2\2\u01eb\u01ec\7n\2\2\u01ec\u01ed\7v\2\2\u01edJ\3\2\2\2\u01ee\u01ef"+ + "\7n\2\2\u01ef\u01f0\7g\2\2\u01f0L\3\2\2\2\u01f1\u01f2\7i\2\2\u01f2\u01f3"+ + "\7v\2\2\u01f3N\3\2\2\2\u01f4\u01f5\7i\2\2\u01f5\u01f6\7g\2\2\u01f6P\3"+ + "\2\2\2\u01f7\u01f8\7#\2\2\u01f8\u01f9\7?\2\2\u01f9R\3\2\2\2\u01fa\u01fb"+ + "\7>\2\2\u01fbT\3\2\2\2\u01fc\u01fd\7>\2\2\u01fd\u01fe\7?\2\2\u01feV\3"+ + "\2\2\2\u01ff\u0200\7@\2\2\u0200X\3\2\2\2\u0201\u0202\7@\2\2\u0202\u0203"+ + "\7?\2\2\u0203Z\3\2\2\2\u0204\u0205\7~\2\2\u0205\u0206\7~\2\2\u0206\\\3"+ + "\2\2\2\u0207\u0208\7-\2\2\u0208^\3\2\2\2\u0209\u020a\7/\2\2\u020a`\3\2"+ + "\2\2\u020b\u020c\7f\2\2\u020c\u020d\7k\2\2\u020d\u020e\7x\2\2\u020eb\3"+ + "\2\2\2\u020f\u0210\7k\2\2\u0210\u0211\7f\2\2\u0211\u0212\7k\2\2\u0212"+ + "\u0213\7x\2\2\u0213d\3\2\2\2\u0214\u0215\7o\2\2\u0215\u0216\7q\2\2\u0216"+ + "\u0217\7f\2\2\u0217f\3\2\2\2\u0218\u0219\7#\2\2\u0219h\3\2\2\2\u021a\u021b"+ + "\7]\2\2\u021bj\3\2\2\2\u021c\u021d\7_\2\2\u021dl\3\2\2\2\u021e\u021f\7"+ + "\60\2\2\u021fn\3\2\2\2\u0220\u0221\7&\2\2\u0221\u0222\7&\2\2\u0222p\3"+ + "\2\2\2\u0223\u0224\7%\2\2\u0224r\3\2\2\2\u0225\u0226\7}\2\2\u0226\u0227"+ + "\7~\2\2\u0227t\3\2\2\2\u0228\u0229\7~\2\2\u0229\u022a\7\177\2\2\u022a"+ + "v\3\2\2\2\u022b\u022c\7h\2\2\u022c\u022d\7q\2\2\u022d\u022e\7t\2\2\u022e"+ + "x\3\2\2\2\u022f\u0230\7n\2\2\u0230\u0231\7g\2\2\u0231\u0232\7v\2\2\u0232"+ + "z\3\2\2\2\u0233\u0234\7y\2\2\u0234\u0235\7j\2\2\u0235\u0236\7g\2\2\u0236"+ + "\u0237\7t\2\2\u0237\u0238\7g\2\2\u0238|\3\2\2\2\u0239\u023a\7i\2\2\u023a"+ + "\u023b\7t\2\2\u023b\u023c\7q\2\2\u023c\u023d\7w\2\2\u023d\u023e\7r\2\2"+ + "\u023e~\3\2\2\2\u023f\u0240\7d\2\2\u0240\u0241\7{\2\2\u0241\u0080\3\2"+ + "\2\2\u0242\u0243\7q\2\2\u0243\u0244\7t\2\2\u0244\u0245\7f\2\2\u0245\u0246"+ + "\7g\2\2\u0246\u0247\7t\2\2\u0247\u0082\3\2\2\2\u0248\u0249\7t\2\2\u0249"+ + "\u024a\7g\2\2\u024a\u024b\7v\2\2\u024b\u024c\7w\2\2\u024c\u024d\7t\2\2"+ + "\u024d\u024e\7p\2\2\u024e\u0084\3\2\2\2\u024f\u0250\7k\2\2\u0250\u0251"+ + "\7h\2\2\u0251\u0086\3\2\2\2\u0252\u0253\7k\2\2\u0253\u0254\7p\2\2\u0254"+ + "\u0088\3\2\2\2\u0255\u0256\7c\2\2\u0256\u0257\7u\2\2\u0257\u008a\3\2\2"+ + "\2\u0258\u0259\7c\2\2\u0259\u025a\7v\2\2\u025a\u008c\3\2\2\2\u025b\u025c"+ + "\7c\2\2\u025c\u025d\7n\2\2\u025d\u025e\7n\2\2\u025e\u025f\7q\2\2\u025f"+ + "\u0260\7y\2\2\u0260\u0261\7k\2\2\u0261\u0262\7p\2\2\u0262\u0263\7i\2\2"+ + "\u0263\u008e\3\2\2\2\u0264\u0265\7g\2\2\u0265\u0266\7o\2\2\u0266\u0267"+ + "\7r\2\2\u0267\u0268\7v\2\2\u0268\u0269\7{\2\2\u0269\u0090\3\2\2\2\u026a"+ + "\u026b\7e\2\2\u026b\u026c\7q\2\2\u026c\u026d\7w\2\2\u026d\u026e\7p\2\2"+ + "\u026e\u026f\7v\2\2\u026f\u0092\3\2\2\2\u0270\u0271\7u\2\2\u0271\u0272"+ + "\7v\2\2\u0272\u0273\7c\2\2\u0273\u0274\7d\2\2\u0274\u0275\7n\2\2\u0275"+ + "\u0276\7g\2\2\u0276\u0094\3\2\2\2\u0277\u0278\7c\2\2\u0278\u0279\7u\2"+ + "\2\u0279\u027a\7e\2\2\u027a\u027b\7g\2\2\u027b\u027c\7p\2\2\u027c\u027d"+ + "\7f\2\2\u027d\u027e\7k\2\2\u027e\u027f\7p\2\2\u027f\u0280\7i\2\2\u0280"+ + "\u0096\3\2\2\2\u0281\u0282\7f\2\2\u0282\u0283\7g\2\2\u0283\u0284\7u\2"+ + "\2\u0284\u0285\7e\2\2\u0285\u0286\7g\2\2\u0286\u0287\7p\2\2\u0287\u0288"+ + "\7f\2\2\u0288\u0289\7k\2\2\u0289\u028a\7p\2\2\u028a\u028b\7i\2\2\u028b"+ + "\u0098\3\2\2\2\u028c\u028d\7u\2\2\u028d\u028e\7q\2\2\u028e\u028f\7o\2"+ + "\2\u028f\u0290\7g\2\2\u0290\u009a\3\2\2\2\u0291\u0292\7g\2\2\u0292\u0293"+ + "\7x\2\2\u0293\u0294\7g\2\2\u0294\u0295\7t\2\2\u0295\u0296\7{\2\2\u0296"+ + "\u009c\3\2\2\2\u0297\u0298\7u\2\2\u0298\u0299\7c\2\2\u0299\u029a\7v\2"+ + "\2\u029a\u029b\7k\2\2\u029b\u029c\7u\2\2\u029c\u029d\7h\2\2\u029d\u029e"+ + "\7k\2\2\u029e\u029f\7g\2\2\u029f\u02a0\7u\2\2\u02a0\u009e\3\2\2\2\u02a1"+ + "\u02a2\7e\2\2\u02a2\u02a3\7q\2\2\u02a3\u02a4\7n\2\2\u02a4\u02a5\7n\2\2"+ + "\u02a5\u02a6\7c\2\2\u02a6\u02a7\7v\2\2\u02a7\u02a8\7k\2\2\u02a8\u02a9"+ + "\7q\2\2\u02a9\u02aa\7p\2\2\u02aa\u00a0\3\2\2\2\u02ab\u02ac\7i\2\2\u02ac"+ + "\u02ad\7t\2\2\u02ad\u02ae\7g\2\2\u02ae\u02af\7c\2\2\u02af\u02b0\7v\2\2"+ + "\u02b0\u02b1\7g\2\2\u02b1\u02b2\7u\2\2\u02b2\u02b3\7v\2\2\u02b3\u00a2"+ + "\3\2\2\2\u02b4\u02b5\7n\2\2\u02b5\u02b6\7g\2\2\u02b6\u02b7\7c\2\2\u02b7"+ + "\u02b8\7u\2\2\u02b8\u02b9\7v\2\2\u02b9\u00a4\3\2\2\2\u02ba\u02bb\7u\2"+ + "\2\u02bb\u02bc\7y\2\2\u02bc\u02bd\7k\2\2\u02bd\u02be\7v\2\2\u02be\u02bf"+ + "\7e\2\2\u02bf\u02c0\7j\2\2\u02c0\u00a6\3\2\2\2\u02c1\u02c2\7e\2\2\u02c2"+ + "\u02c3\7c\2\2\u02c3\u02c4\7u\2\2\u02c4\u02c5\7g\2\2\u02c5\u00a8\3\2\2"+ + "\2\u02c6\u02c7\7v\2\2\u02c7\u02c8\7t\2\2\u02c8\u02c9\7{\2\2\u02c9\u00aa"+ + "\3\2\2\2\u02ca\u02cb\7e\2\2\u02cb\u02cc\7c\2\2\u02cc\u02cd\7v\2\2\u02cd"+ + "\u02ce\7e\2\2\u02ce\u02cf\7j\2\2\u02cf\u00ac\3\2\2\2\u02d0\u02d1\7f\2"+ + "\2\u02d1\u02d2\7g\2\2\u02d2\u02d3\7h\2\2\u02d3\u02d4\7c\2\2\u02d4\u02d5"+ + "\7w\2\2\u02d5\u02d6\7n\2\2\u02d6\u02d7\7v\2\2\u02d7\u00ae\3\2\2\2\u02d8"+ + "\u02d9\7v\2\2\u02d9\u02da\7j\2\2\u02da\u02db\7g\2\2\u02db\u02dc\7p\2\2"+ + "\u02dc\u00b0\3\2\2\2\u02dd\u02de\7g\2\2\u02de\u02df\7n\2\2\u02df\u02e0"+ + "\7u\2\2\u02e0\u02e1\7g\2\2\u02e1\u00b2\3\2\2\2\u02e2\u02e3\7v\2\2\u02e3"+ + "\u02e4\7{\2\2\u02e4\u02e5\7r\2\2\u02e5\u02e6\7g\2\2\u02e6\u02e7\7u\2\2"+ + "\u02e7\u02e8\7y\2\2\u02e8\u02e9\7k\2\2\u02e9\u02ea\7v\2\2\u02ea\u02eb"+ + "\7e\2\2\u02eb\u02ec\7j\2\2\u02ec\u00b4\3\2\2\2\u02ed\u02ee\7q\2\2\u02ee"+ + "\u02ef\7t\2\2\u02ef\u00b6\3\2\2\2\u02f0\u02f1\7c\2\2\u02f1\u02f2\7p\2"+ + "\2\u02f2\u02f3\7f\2\2\u02f3\u00b8\3\2\2\2\u02f4\u02f5\7p\2\2\u02f5\u02f6"+ + "\7q\2\2\u02f6\u02f7\7v\2\2\u02f7\u00ba\3\2\2\2\u02f8\u02f9\7v\2\2\u02f9"+ + "\u02fa\7q\2\2\u02fa\u00bc\3\2\2\2\u02fb\u02fc\7k\2\2\u02fc\u02fd\7p\2"+ + "\2\u02fd\u02fe\7u\2\2\u02fe\u02ff\7v\2\2\u02ff\u0300\7c\2\2\u0300\u0301"+ + "\7p\2\2\u0301\u0302\7e\2\2\u0302\u0303\7g\2\2\u0303\u00be\3\2\2\2\u0304"+ + "\u0305\7q\2\2\u0305\u0306\7h\2\2\u0306\u00c0\3\2\2\2\u0307\u0308\7u\2"+ + "\2\u0308\u0309\7v\2\2\u0309\u030a\7c\2\2\u030a\u030b\7v\2\2\u030b\u030c"+ + "\7k\2\2\u030c\u030d\7e\2\2\u030d\u030e\7c\2\2\u030e\u030f\7n\2\2\u030f"+ + "\u0310\7n\2\2\u0310\u0311\7{\2\2\u0311\u00c2\3\2\2\2\u0312\u0313\7k\2"+ + "\2\u0313\u0314\7u\2\2\u0314\u00c4\3\2\2\2\u0315\u0316\7v\2\2\u0316\u0317"+ + "\7t\2\2\u0317\u0318\7g\2\2\u0318\u0319\7c\2\2\u0319\u031a\7v\2\2\u031a"+ + "\u00c6\3\2\2\2\u031b\u031c\7e\2\2\u031c\u031d\7c\2\2\u031d\u031e\7u\2"+ + "\2\u031e\u031f\7v\2\2\u031f\u00c8\3\2\2\2\u0320\u0321\7e\2\2\u0321\u0322"+ + "\7c\2\2\u0322\u0323\7u\2\2\u0323\u0324\7v\2\2\u0324\u0325\7c\2\2\u0325"+ + "\u0326\7d\2\2\u0326\u0327\7n\2\2\u0327\u0328\7g\2\2\u0328\u00ca\3\2\2"+ + "\2\u0329\u032a\7x\2\2\u032a\u032b\7g\2\2\u032b\u032c\7t\2\2\u032c\u032d"+ + "\7u\2\2\u032d\u032e\7k\2\2\u032e\u032f\7q\2\2\u032f\u0330\7p\2\2\u0330"+ + "\u00cc\3\2\2\2\u0331\u0332\7l\2\2\u0332\u0333\7u\2\2\u0333\u0334\7q\2"+ + "\2\u0334\u0335\7p\2\2\u0335\u0336\7k\2\2\u0336\u0337\7s\2\2\u0337\u00ce"+ + "\3\2\2\2\u0338\u033d\7$\2\2\u0339\u033c\5\u00d1i\2\u033a\u033c\n\2\2\2"+ + "\u033b\u0339\3\2\2\2\u033b\u033a\3\2\2\2\u033c\u033f\3\2\2\2\u033d\u033b"+ + "\3\2\2\2\u033d\u033e\3\2\2\2\u033e\u0340\3\2\2\2\u033f\u033d\3\2\2\2\u0340"+ + "\u0341\7$\2\2\u0341\u00d0\3\2\2\2\u0342\u0345\7^\2\2\u0343\u0346\t\3\2"+ + "\2\u0344\u0346\5\u00d3j\2\u0345\u0343\3\2\2\2\u0345\u0344\3\2\2\2\u0346"+ + "\u00d2\3\2\2\2\u0347\u0348\7w\2\2\u0348\u0349\5\u00d5k\2\u0349\u034a\5"+ + "\u00d5k\2\u034a\u034b\5\u00d5k\2\u034b\u034c\5\u00d5k\2\u034c\u00d4\3"+ + "\2\2\2\u034d\u034e\t\4\2\2\u034e\u00d6\3\2\2\2\u034f\u0350\7A\2\2\u0350"+ + "\u00d8\3\2\2\2\u0351\u0352\7p\2\2\u0352\u0353\7w\2\2\u0353\u0354\7n\2"+ + "\2\u0354\u0355\7n\2\2\u0355\u00da\3\2\2\2\u0356\u0359\5\u00ddo\2\u0357"+ + "\u0359\5\u00dfp\2\u0358\u0356\3\2\2\2\u0358\u0357\3\2\2\2\u0359\u00dc"+ + "\3\2\2\2\u035a\u035e\5\u00e1q\2\u035b\u035e\5\u00e3r\2\u035c\u035e\5\u00e5"+ + "s\2\u035d\u035a\3\2\2\2\u035d\u035b\3\2\2\2\u035d\u035c\3\2\2\2\u035e"+ + "\u00de\3\2\2\2\u035f\u0360\7v\2\2\u0360\u0361\7t\2\2\u0361\u0362\7w\2"+ + "\2\u0362\u0369\7g\2\2\u0363\u0364\7h\2\2\u0364\u0365\7c\2\2\u0365\u0366"+ + "\7n\2\2\u0366\u0367\7u\2\2\u0367\u0369\7g\2\2\u0368\u035f\3\2\2\2\u0368"+ + "\u0363\3\2\2\2\u0369\u00e0\3\2\2\2\u036a\u036b\5\u00e7t\2\u036b\u00e2"+ + "\3\2\2\2\u036c\u036d\7\60\2\2\u036d\u0377\5\u00e7t\2\u036e\u036f\5\u00e7"+ + "t\2\u036f\u0373\7\60\2\2\u0370\u0372\t\5\2\2\u0371\u0370\3\2\2\2\u0372"+ + "\u0375\3\2\2\2\u0373\u0371\3\2\2\2\u0373\u0374\3\2\2\2\u0374\u0377\3\2"+ + "\2\2\u0375\u0373\3\2\2\2\u0376\u036c\3\2\2\2\u0376\u036e\3\2\2\2\u0377"+ + "\u00e4\3\2\2\2\u0378\u0379\7\60\2\2\u0379\u0385\5\u00e7t\2\u037a\u0382"+ + "\5\u00e7t\2\u037b\u037f\7\60\2\2\u037c\u037e\t\5\2\2\u037d\u037c\3\2\2"+ + "\2\u037e\u0381\3\2\2\2\u037f\u037d\3\2\2\2\u037f\u0380\3\2\2\2\u0380\u0383"+ + "\3\2\2\2\u0381\u037f\3\2\2\2\u0382\u037b\3\2\2\2\u0382\u0383\3\2\2\2\u0383"+ + "\u0385\3\2\2\2\u0384\u0378\3\2\2\2\u0384\u037a\3\2\2\2\u0385\u0386\3\2"+ + "\2\2\u0386\u0388\t\6\2\2\u0387\u0389\t\7\2\2\u0388\u0387\3\2\2\2\u0388"+ + "\u0389\3\2\2\2\u0389\u038a\3\2\2\2\u038a\u038b\5\u00e7t\2\u038b\u00e6"+ + "\3\2\2\2\u038c\u038e\t\5\2\2\u038d\u038c\3\2\2\2\u038e\u038f\3\2\2\2\u038f"+ + "\u038d\3\2\2\2\u038f\u0390\3\2\2\2\u0390\u00e8\3\2\2\2\u0391\u0392\t\b"+ + "\2\2\u0392\u0393\3\2\2\2\u0393\u0394\bu\2\2\u0394\u00ea\3\2\2\2\u0395"+ + "\u0399\5\u00edw\2\u0396\u0398\5\u00efx\2\u0397\u0396\3\2\2\2\u0398\u039b"+ + "\3\2\2\2\u0399\u0397\3\2\2\2\u0399\u039a\3\2\2\2\u039a\u00ec\3\2\2\2\u039b"+ + "\u0399\3\2\2\2\u039c\u039e\t\t\2\2\u039d\u039c\3\2\2\2\u039e\u00ee\3\2"+ + "\2\2\u039f\u03a2\5\u00edw\2\u03a0\u03a2\t\n\2\2\u03a1\u039f\3\2\2\2\u03a1"+ + "\u03a0\3\2\2\2\u03a2\u00f0\3\2\2\2\u03a3\u03a4\7*\2\2\u03a4\u03ad\7<\2"+ + "\2\u03a5\u03ac\5\u00f1y\2\u03a6\u03a7\7*\2\2\u03a7\u03ac\n\13\2\2\u03a8"+ + "\u03a9\7<\2\2\u03a9\u03ac\n\f\2\2\u03aa\u03ac\n\r\2\2\u03ab\u03a5\3\2"+ + "\2\2\u03ab\u03a6\3\2\2\2\u03ab\u03a8\3\2\2\2\u03ab\u03aa\3\2\2\2\u03ac"+ + "\u03af\3\2\2\2\u03ad\u03ab\3\2\2\2\u03ad\u03ae\3\2\2\2\u03ae\u03b1\3\2"+ + "\2\2\u03af\u03ad\3\2\2\2\u03b0\u03b2\7<\2\2\u03b1\u03b0\3\2\2\2\u03b2"+ + "\u03b3\3\2\2\2\u03b3\u03b1\3\2\2\2\u03b3\u03b4\3\2\2\2\u03b4\u03b5\3\2"+ + "\2\2\u03b5\u03b6\7+\2\2\u03b6\u03b7\3\2\2\2\u03b7\u03b8\by\2\2\u03b8\u00f2"+ + "\3\2\2\2\u03b9\u03ba\n\16\2\2\u03ba\u00f4\3\2\2\2\26\2\u033b\u033d\u0345"+ + "\u0358\u035d\u0368\u0373\u0376\u037f\u0382\u0384\u0388\u038f\u0399\u039d"+ + "\u03a1\u03ab\u03ad\u03b3\3\2\3\2"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/src/main/java/org/rumbledb/parser/JsoniqLexer.tokens b/src/main/java/org/rumbledb/parser/JsoniqLexer.tokens index 8759bd69b3..610f232f17 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqLexer.tokens +++ b/src/main/java/org/rumbledb/parser/JsoniqLexer.tokens @@ -93,24 +93,26 @@ Knot=92 Kto=93 Kinstance=94 Kof=95 -Ktreat=96 -Kcast=97 -Kcastable=98 -Kversion=99 -Kjsoniq=100 -STRING=101 -ArgumentPlaceholder=102 -NullLiteral=103 -Literal=104 -NumericLiteral=105 -BooleanLiteral=106 -IntegerLiteral=107 -DecimalLiteral=108 -DoubleLiteral=109 -WS=110 -NCName=111 -XQComment=112 -ContentChar=113 +Kstatically=96 +Kis=97 +Ktreat=98 +Kcast=99 +Kcastable=100 +Kversion=101 +Kjsoniq=102 +STRING=103 +ArgumentPlaceholder=104 +NullLiteral=105 +Literal=106 +NumericLiteral=107 +BooleanLiteral=108 +IntegerLiteral=109 +DecimalLiteral=110 +DoubleLiteral=111 +WS=112 +NCName=113 +XQComment=114 +ContentChar=115 ';'=1 'module'=2 'namespace'=3 @@ -206,10 +208,12 @@ ContentChar=113 'to'=93 'instance'=94 'of'=95 -'treat'=96 -'cast'=97 -'castable'=98 -'version'=99 -'jsoniq'=100 -'?'=102 -'null'=103 +'statically'=96 +'is'=97 +'treat'=98 +'cast'=99 +'castable'=100 +'version'=101 +'jsoniq'=102 +'?'=104 +'null'=105 diff --git a/src/main/java/org/rumbledb/parser/JsoniqParser.java b/src/main/java/org/rumbledb/parser/JsoniqParser.java index 1b60805010..3d29217c58 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqParser.java +++ b/src/main/java/org/rumbledb/parser/JsoniqParser.java @@ -44,10 +44,10 @@ public class JsoniqParser extends Parser { Kdescending=75, Ksome=76, Kevery=77, Ksatisfies=78, Kcollation=79, Kgreatest=80, Kleast=81, Kswitch=82, Kcase=83, Ktry=84, Kcatch=85, Kdefault=86, Kthen=87, Kelse=88, Ktypeswitch=89, Kor=90, Kand=91, Knot=92, Kto=93, Kinstance=94, - Kof=95, Ktreat=96, Kcast=97, Kcastable=98, Kversion=99, Kjsoniq=100, STRING=101, - ArgumentPlaceholder=102, NullLiteral=103, Literal=104, NumericLiteral=105, - BooleanLiteral=106, IntegerLiteral=107, DecimalLiteral=108, DoubleLiteral=109, - WS=110, NCName=111, XQComment=112, ContentChar=113; + Kof=95, Kstatically=96, Kis=97, Ktreat=98, Kcast=99, Kcastable=100, Kversion=101, + Kjsoniq=102, STRING=103, ArgumentPlaceholder=104, NullLiteral=105, Literal=106, + NumericLiteral=107, BooleanLiteral=108, IntegerLiteral=109, DecimalLiteral=110, + DoubleLiteral=111, WS=112, NCName=113, XQComment=114, ContentChar=115; public static final int RULE_moduleAndThisIsIt = 0, RULE_module = 1, RULE_mainModule = 2, RULE_libraryModule = 3, RULE_prolog = 4, RULE_setter = 5, RULE_namespaceDecl = 6, RULE_annotatedDecl = 7, @@ -63,16 +63,17 @@ public class JsoniqParser extends Parser { RULE_ifExpr = 39, RULE_tryCatchExpr = 40, RULE_catchClause = 41, RULE_orExpr = 42, RULE_andExpr = 43, RULE_notExpr = 44, RULE_comparisonExpr = 45, RULE_stringConcatExpr = 46, RULE_rangeExpr = 47, RULE_additiveExpr = 48, RULE_multiplicativeExpr = 49, - RULE_instanceOfExpr = 50, RULE_treatExpr = 51, RULE_castableExpr = 52, - RULE_castExpr = 53, RULE_arrowExpr = 54, RULE_unaryExpr = 55, RULE_simpleMapExpr = 56, - RULE_postFixExpr = 57, RULE_arrayLookup = 58, RULE_arrayUnboxing = 59, - RULE_predicate = 60, RULE_objectLookup = 61, RULE_primaryExpr = 62, RULE_varRef = 63, - RULE_parenthesizedExpr = 64, RULE_contextItemExpr = 65, RULE_orderedExpr = 66, - RULE_unorderedExpr = 67, RULE_functionCall = 68, RULE_argumentList = 69, - RULE_argument = 70, RULE_functionItemExpr = 71, RULE_namedFunctionRef = 72, - RULE_inlineFunctionExpr = 73, RULE_sequenceType = 74, RULE_objectConstructor = 75, - RULE_itemType = 76, RULE_singleType = 77, RULE_pairConstructor = 78, RULE_arrayConstructor = 79, - RULE_uriLiteral = 80, RULE_stringLiteral = 81, RULE_keyWords = 82; + RULE_instanceOfExpr = 50, RULE_isStaticallyExpr = 51, RULE_treatExpr = 52, + RULE_castableExpr = 53, RULE_castExpr = 54, RULE_arrowExpr = 55, RULE_unaryExpr = 56, + RULE_simpleMapExpr = 57, RULE_postFixExpr = 58, RULE_arrayLookup = 59, + RULE_arrayUnboxing = 60, RULE_predicate = 61, RULE_objectLookup = 62, + RULE_primaryExpr = 63, RULE_varRef = 64, RULE_parenthesizedExpr = 65, + RULE_contextItemExpr = 66, RULE_orderedExpr = 67, RULE_unorderedExpr = 68, + RULE_functionCall = 69, RULE_argumentList = 70, RULE_argument = 71, RULE_functionItemExpr = 72, + RULE_namedFunctionRef = 73, RULE_inlineFunctionExpr = 74, RULE_sequenceType = 75, + RULE_objectConstructor = 76, RULE_itemType = 77, RULE_singleType = 78, + RULE_pairConstructor = 79, RULE_arrayConstructor = 80, RULE_uriLiteral = 81, + RULE_stringLiteral = 82, RULE_keyWords = 83; public static final String[] ruleNames = { "moduleAndThisIsIt", "module", "mainModule", "libraryModule", "prolog", "setter", "namespaceDecl", "annotatedDecl", "defaultCollationDecl", "orderingModeDecl", @@ -83,8 +84,8 @@ public class JsoniqParser extends Parser { "countClause", "quantifiedExpr", "quantifiedExprVar", "switchExpr", "switchCaseClause", "typeSwitchExpr", "caseClause", "ifExpr", "tryCatchExpr", "catchClause", "orExpr", "andExpr", "notExpr", "comparisonExpr", "stringConcatExpr", - "rangeExpr", "additiveExpr", "multiplicativeExpr", "instanceOfExpr", "treatExpr", - "castableExpr", "castExpr", "arrowExpr", "unaryExpr", "simpleMapExpr", + "rangeExpr", "additiveExpr", "multiplicativeExpr", "instanceOfExpr", "isStaticallyExpr", + "treatExpr", "castableExpr", "castExpr", "arrowExpr", "unaryExpr", "simpleMapExpr", "postFixExpr", "arrayLookup", "arrayUnboxing", "predicate", "objectLookup", "primaryExpr", "varRef", "parenthesizedExpr", "contextItemExpr", "orderedExpr", "unorderedExpr", "functionCall", "argumentList", "argument", "functionItemExpr", @@ -107,8 +108,8 @@ public class JsoniqParser extends Parser { "'ascending'", "'descending'", "'some'", "'every'", "'satisfies'", "'collation'", "'greatest'", "'least'", "'switch'", "'case'", "'try'", "'catch'", "'default'", "'then'", "'else'", "'typeswitch'", "'or'", "'and'", "'not'", "'to'", - "'instance'", "'of'", "'treat'", "'cast'", "'castable'", "'version'", - "'jsoniq'", null, "'?'", "'null'" + "'instance'", "'of'", "'statically'", "'is'", "'treat'", "'cast'", "'castable'", + "'version'", "'jsoniq'", null, "'?'", "'null'" }; private static final String[] _SYMBOLIC_NAMES = { null, null, null, null, null, null, null, null, null, null, null, null, @@ -120,10 +121,11 @@ public class JsoniqParser extends Parser { "Kas", "Kat", "Kallowing", "Kempty", "Kcount", "Kstable", "Kascending", "Kdescending", "Ksome", "Kevery", "Ksatisfies", "Kcollation", "Kgreatest", "Kleast", "Kswitch", "Kcase", "Ktry", "Kcatch", "Kdefault", "Kthen", "Kelse", - "Ktypeswitch", "Kor", "Kand", "Knot", "Kto", "Kinstance", "Kof", "Ktreat", - "Kcast", "Kcastable", "Kversion", "Kjsoniq", "STRING", "ArgumentPlaceholder", - "NullLiteral", "Literal", "NumericLiteral", "BooleanLiteral", "IntegerLiteral", - "DecimalLiteral", "DoubleLiteral", "WS", "NCName", "XQComment", "ContentChar" + "Ktypeswitch", "Kor", "Kand", "Knot", "Kto", "Kinstance", "Kof", "Kstatically", + "Kis", "Ktreat", "Kcast", "Kcastable", "Kversion", "Kjsoniq", "STRING", + "ArgumentPlaceholder", "NullLiteral", "Literal", "NumericLiteral", "BooleanLiteral", + "IntegerLiteral", "DecimalLiteral", "DoubleLiteral", "WS", "NCName", "XQComment", + "ContentChar" }; public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); @@ -196,9 +198,9 @@ public final ModuleAndThisIsItContext moduleAndThisIsIt() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(166); + setState(168); module(); - setState(167); + setState(169); match(EOF); } } @@ -244,28 +246,28 @@ public final ModuleContext module() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(174); + setState(176); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,0,_ctx) ) { case 1: { - setState(169); + setState(171); match(Kjsoniq); - setState(170); + setState(172); match(Kversion); - setState(171); + setState(173); ((ModuleContext)_localctx).vers = stringLiteral(); - setState(172); + setState(174); match(T__0); } break; } - setState(178); + setState(180); _errHandler.sync(this); switch (_input.LA(1)) { case T__1: { - setState(176); + setState(178); libraryModule(); } break; @@ -319,6 +321,8 @@ public final ModuleContext module() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -329,7 +333,7 @@ public final ModuleContext module() throws RecognitionException { case Literal: case NCName: { - setState(177); + setState(179); ((ModuleContext)_localctx).main = mainModule(); } break; @@ -373,9 +377,9 @@ public final MainModuleContext mainModule() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(180); + setState(182); prolog(); - setState(181); + setState(183); expr(); } } @@ -415,19 +419,19 @@ public final LibraryModuleContext libraryModule() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(183); + setState(185); match(T__1); - setState(184); + setState(186); match(T__2); - setState(185); + setState(187); match(NCName); - setState(186); + setState(188); match(T__3); - setState(187); + setState(189); uriLiteral(); - setState(188); + setState(190); match(T__0); - setState(189); + setState(191); prolog(); } } @@ -486,57 +490,57 @@ public final PrologContext prolog() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(200); + setState(202); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,3,_ctx); - while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(194); + setState(196); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) { case 1: { - setState(191); + setState(193); setter(); } break; case 2: { - setState(192); + setState(194); namespaceDecl(); } break; case 3: { - setState(193); + setState(195); moduleImport(); } break; } - setState(196); + setState(198); match(T__0); } } } - setState(202); + setState(204); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,3,_ctx); } - setState(208); + setState(210); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__4) { { { - setState(203); + setState(205); annotatedDecl(); - setState(204); + setState(206); match(T__0); } } - setState(210); + setState(212); _errHandler.sync(this); _la = _input.LA(1); } @@ -581,34 +585,34 @@ public final SetterContext setter() throws RecognitionException { SetterContext _localctx = new SetterContext(_ctx, getState()); enterRule(_localctx, 10, RULE_setter); try { - setState(215); + setState(217); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,5,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(211); + setState(213); defaultCollationDecl(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(212); + setState(214); orderingModeDecl(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(213); + setState(215); emptyOrderDecl(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(214); + setState(216); decimalFormatDecl(); } break; @@ -647,15 +651,15 @@ public final NamespaceDeclContext namespaceDecl() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(217); + setState(219); match(T__4); - setState(218); + setState(220); match(T__2); - setState(219); + setState(221); match(NCName); - setState(220); + setState(222); match(T__3); - setState(221); + setState(223); uriLiteral(); } } @@ -692,20 +696,20 @@ public final AnnotatedDeclContext annotatedDecl() throws RecognitionException { AnnotatedDeclContext _localctx = new AnnotatedDeclContext(_ctx, getState()); enterRule(_localctx, 14, RULE_annotatedDecl); try { - setState(225); + setState(227); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(223); + setState(225); functionDecl(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(224); + setState(226); varDecl(); } break; @@ -745,13 +749,13 @@ public final DefaultCollationDeclContext defaultCollationDecl() throws Recogniti try { enterOuterAlt(_localctx, 1); { - setState(227); + setState(229); match(T__4); - setState(228); + setState(230); match(Kdefault); - setState(229); + setState(231); match(Kcollation); - setState(230); + setState(232); uriLiteral(); } } @@ -785,11 +789,11 @@ public final OrderingModeDeclContext orderingModeDecl() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(232); + setState(234); match(T__4); - setState(233); + setState(235); match(T__5); - setState(234); + setState(236); _la = _input.LA(1); if ( !(_la==T__6 || _la==T__7) ) { _errHandler.recoverInline(this); @@ -836,16 +840,16 @@ public final EmptyOrderDeclContext emptyOrderDecl() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(236); + setState(238); match(T__4); - setState(237); + setState(239); match(Kdefault); - setState(238); + setState(240); match(Korder); - setState(239); + setState(241); match(Kempty); { - setState(240); + setState(242); ((EmptyOrderDeclContext)_localctx).emptySequenceOrder = _input.LT(1); _la = _input.LA(1); if ( !(_la==Kgreatest || _la==Kleast) ) { @@ -905,17 +909,17 @@ public final DecimalFormatDeclContext decimalFormatDecl() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(242); + setState(244); match(T__4); - setState(247); + setState(249); _errHandler.sync(this); switch (_input.LA(1)) { case T__8: { { - setState(243); + setState(245); match(T__8); - setState(244); + setState(246); qname(); } } @@ -923,9 +927,9 @@ public final DecimalFormatDeclContext decimalFormatDecl() throws RecognitionExce case Kdefault: { { - setState(245); + setState(247); match(Kdefault); - setState(246); + setState(248); match(T__8); } } @@ -933,21 +937,21 @@ public final DecimalFormatDeclContext decimalFormatDecl() throws RecognitionExce default: throw new NoViableAltException(this); } - setState(255); + setState(257); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__14) | (1L << T__15) | (1L << T__16) | (1L << T__17) | (1L << T__18) | (1L << T__19))) != 0)) { { { - setState(249); + setState(251); dfPropertyName(); - setState(250); + setState(252); match(T__3); - setState(251); + setState(253); stringLiteral(); } } - setState(257); + setState(259); _errHandler.sync(this); _la = _input.LA(1); } @@ -996,17 +1000,17 @@ public final QnameContext qname() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(263); + setState(265); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,10,_ctx) ) { case 1: { - setState(260); + setState(262); _errHandler.sync(this); switch (_input.LA(1)) { case NCName: { - setState(258); + setState(260); ((QnameContext)_localctx).ns = match(NCName); } break; @@ -1047,6 +1051,8 @@ public final QnameContext qname() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -1054,30 +1060,30 @@ public final QnameContext qname() throws RecognitionException { case Kjsoniq: case NullLiteral: { - setState(259); + setState(261); ((QnameContext)_localctx).nskw = keyWords(); } break; default: throw new NoViableAltException(this); } - setState(262); + setState(264); match(T__9); } break; } - setState(267); + setState(269); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,11,_ctx) ) { case 1: { - setState(265); + setState(267); ((QnameContext)_localctx).local_name = nCNameOrKeyWord(); } break; case 2: { - setState(266); + setState(268); ((QnameContext)_localctx).local_namekw = keyWords(); } break; @@ -1116,7 +1122,7 @@ public final NCNameOrKeyWordContext nCNameOrKeyWord() throws RecognitionExceptio try { enterOuterAlt(_localctx, 1); { - setState(269); + setState(271); _la = _input.LA(1); if ( !(_la==NullLiteral || _la==NCName) ) { _errHandler.recoverInline(this); @@ -1158,7 +1164,7 @@ public final DfPropertyNameContext dfPropertyName() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(271); + setState(273); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__14) | (1L << T__15) | (1L << T__16) | (1L << T__17) | (1L << T__18) | (1L << T__19))) != 0)) ) { _errHandler.recoverInline(this); @@ -1210,48 +1216,48 @@ public final ModuleImportContext moduleImport() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(273); + setState(275); match(T__20); - setState(274); + setState(276); match(T__1); - setState(278); + setState(280); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__2) { { - setState(275); + setState(277); match(T__2); - setState(276); + setState(278); ((ModuleImportContext)_localctx).prefix = match(NCName); - setState(277); + setState(279); match(T__3); } } - setState(280); + setState(282); ((ModuleImportContext)_localctx).targetNamespace = uriLiteral(); - setState(290); + setState(292); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kat) { { - setState(281); + setState(283); match(Kat); - setState(282); + setState(284); uriLiteral(); - setState(287); + setState(289); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(283); + setState(285); match(T__21); - setState(284); + setState(286); uriLiteral(); } } - setState(289); + setState(291); _errHandler.sync(this); _la = _input.LA(1); } @@ -1301,33 +1307,33 @@ public final VarDeclContext varDecl() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(292); + setState(294); match(T__4); - setState(293); + setState(295); match(T__22); - setState(294); + setState(296); varRef(); - setState(297); + setState(299); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(295); + setState(297); match(Kas); - setState(296); + setState(298); sequenceType(); } } - setState(306); + setState(308); _errHandler.sync(this); switch (_input.LA(1)) { case T__23: { { - setState(299); + setState(301); match(T__23); - setState(300); + setState(302); exprSingle(); } } @@ -1335,16 +1341,16 @@ public final VarDeclContext varDecl() throws RecognitionException { case T__24: { { - setState(301); + setState(303); ((VarDeclContext)_localctx).external = match(T__24); - setState(304); + setState(306); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__23) { { - setState(302); + setState(304); match(T__23); - setState(303); + setState(305); exprSingle(); } } @@ -1403,62 +1409,62 @@ public final FunctionDeclContext functionDecl() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(308); + setState(310); match(T__4); - setState(309); + setState(311); match(T__25); - setState(310); + setState(312); ((FunctionDeclContext)_localctx).fn_name = qname(); - setState(311); - match(T__26); setState(313); + match(T__26); + setState(315); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(312); + setState(314); paramList(); } } - setState(315); + setState(317); match(T__27); - setState(318); + setState(320); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(316); + setState(318); match(Kas); - setState(317); + setState(319); ((FunctionDeclContext)_localctx).return_type = sequenceType(); } } - setState(326); + setState(328); _errHandler.sync(this); switch (_input.LA(1)) { case T__28: { - setState(320); - match(T__28); setState(322); + match(T__28); + setState(324); _errHandler.sync(this); _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { { - setState(321); + setState(323); ((FunctionDeclContext)_localctx).fn_body = expr(); } } - setState(324); + setState(326); match(T__29); } break; case T__24: { - setState(325); + setState(327); match(T__24); } break; @@ -1503,21 +1509,21 @@ public final ParamListContext paramList() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(328); + setState(330); param(); - setState(333); + setState(335); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(329); + setState(331); match(T__21); - setState(330); + setState(332); param(); } } - setState(335); + setState(337); _errHandler.sync(this); _la = _input.LA(1); } @@ -1560,18 +1566,18 @@ public final ParamContext param() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(336); + setState(338); match(T__30); - setState(337); + setState(339); qname(); - setState(340); + setState(342); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(338); + setState(340); match(Kas); - setState(339); + setState(341); sequenceType(); } } @@ -1614,21 +1620,21 @@ public final ExprContext expr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(342); + setState(344); exprSingle(); - setState(347); + setState(349); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(343); + setState(345); match(T__21); - setState(344); + setState(346); exprSingle(); } } - setState(349); + setState(351); _errHandler.sync(this); _la = _input.LA(1); } @@ -1682,55 +1688,55 @@ public final ExprSingleContext exprSingle() throws RecognitionException { ExprSingleContext _localctx = new ExprSingleContext(_ctx, getState()); enterRule(_localctx, 42, RULE_exprSingle); try { - setState(357); + setState(359); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,25,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(350); + setState(352); flowrExpr(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(351); + setState(353); quantifiedExpr(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(352); + setState(354); switchExpr(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(353); + setState(355); typeSwitchExpr(); } break; case 5: enterOuterAlt(_localctx, 5); { - setState(354); + setState(356); ifExpr(); } break; case 6: enterOuterAlt(_localctx, 6); { - setState(355); + setState(357); tryCatchExpr(); } break; case 7: enterOuterAlt(_localctx, 7); { - setState(356); + setState(358); orExpr(); } break; @@ -1809,66 +1815,66 @@ public final FlowrExprContext flowrExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(361); + setState(363); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: { - setState(359); + setState(361); ((FlowrExprContext)_localctx).start_for = forClause(); } break; case Klet: { - setState(360); + setState(362); ((FlowrExprContext)_localctx).start_let = letClause(); } break; default: throw new NoViableAltException(this); } - setState(371); + setState(373); _errHandler.sync(this); _la = _input.LA(1); while (((((_la - 59)) & ~0x3f) == 0 && ((1L << (_la - 59)) & ((1L << (Kfor - 59)) | (1L << (Klet - 59)) | (1L << (Kwhere - 59)) | (1L << (Kgroup - 59)) | (1L << (Korder - 59)) | (1L << (Kcount - 59)) | (1L << (Kstable - 59)))) != 0)) { { - setState(369); + setState(371); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: { - setState(363); + setState(365); forClause(); } break; case Kwhere: { - setState(364); + setState(366); whereClause(); } break; case Klet: { - setState(365); + setState(367); letClause(); } break; case Kgroup: { - setState(366); + setState(368); groupByClause(); } break; case Korder: case Kstable: { - setState(367); + setState(369); orderByClause(); } break; case Kcount: { - setState(368); + setState(370); countClause(); } break; @@ -1876,13 +1882,13 @@ public final FlowrExprContext flowrExpr() throws RecognitionException { throw new NoViableAltException(this); } } - setState(373); + setState(375); _errHandler.sync(this); _la = _input.LA(1); } - setState(374); + setState(376); match(Kreturn); - setState(375); + setState(377); ((FlowrExprContext)_localctx).return_expr = exprSingle(); } } @@ -1925,25 +1931,25 @@ public final ForClauseContext forClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(377); + setState(379); match(Kfor); - setState(378); + setState(380); ((ForClauseContext)_localctx).forVar = forVar(); ((ForClauseContext)_localctx).vars.add(((ForClauseContext)_localctx).forVar); - setState(383); + setState(385); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(379); + setState(381); match(T__21); - setState(380); + setState(382); ((ForClauseContext)_localctx).forVar = forVar(); ((ForClauseContext)_localctx).vars.add(((ForClauseContext)_localctx).forVar); } } - setState(385); + setState(387); _errHandler.sync(this); _la = _input.LA(1); } @@ -2001,47 +2007,47 @@ public final ForVarContext forVar() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(386); + setState(388); ((ForVarContext)_localctx).var_ref = varRef(); - setState(389); + setState(391); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(387); + setState(389); match(Kas); - setState(388); + setState(390); ((ForVarContext)_localctx).seq = sequenceType(); } } - setState(393); + setState(395); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kallowing) { { - setState(391); + setState(393); ((ForVarContext)_localctx).flag = match(Kallowing); - setState(392); + setState(394); match(Kempty); } } - setState(397); + setState(399); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kat) { { - setState(395); + setState(397); match(Kat); - setState(396); + setState(398); ((ForVarContext)_localctx).at = varRef(); } } - setState(399); + setState(401); match(Kin); - setState(400); + setState(402); ((ForVarContext)_localctx).ex = exprSingle(); } } @@ -2084,25 +2090,25 @@ public final LetClauseContext letClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(402); + setState(404); match(Klet); - setState(403); + setState(405); ((LetClauseContext)_localctx).letVar = letVar(); ((LetClauseContext)_localctx).vars.add(((LetClauseContext)_localctx).letVar); - setState(408); + setState(410); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(404); + setState(406); match(T__21); - setState(405); + setState(407); ((LetClauseContext)_localctx).letVar = letVar(); ((LetClauseContext)_localctx).vars.add(((LetClauseContext)_localctx).letVar); } } - setState(410); + setState(412); _errHandler.sync(this); _la = _input.LA(1); } @@ -2151,23 +2157,23 @@ public final LetVarContext letVar() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(411); + setState(413); ((LetVarContext)_localctx).var_ref = varRef(); - setState(414); + setState(416); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(412); + setState(414); match(Kas); - setState(413); + setState(415); ((LetVarContext)_localctx).seq = sequenceType(); } } - setState(416); + setState(418); match(T__23); - setState(417); + setState(419); ((LetVarContext)_localctx).ex = exprSingle(); } } @@ -2204,9 +2210,9 @@ public final WhereClauseContext whereClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(419); + setState(421); match(Kwhere); - setState(420); + setState(422); exprSingle(); } } @@ -2250,27 +2256,27 @@ public final GroupByClauseContext groupByClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(422); + setState(424); match(Kgroup); - setState(423); + setState(425); match(Kby); - setState(424); + setState(426); ((GroupByClauseContext)_localctx).groupByVar = groupByVar(); ((GroupByClauseContext)_localctx).vars.add(((GroupByClauseContext)_localctx).groupByVar); - setState(429); + setState(431); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(425); + setState(427); match(T__21); - setState(426); + setState(428); ((GroupByClauseContext)_localctx).groupByVar = groupByVar(); ((GroupByClauseContext)_localctx).vars.add(((GroupByClauseContext)_localctx).groupByVar); } } - setState(431); + setState(433); _errHandler.sync(this); _la = _input.LA(1); } @@ -2325,40 +2331,40 @@ public final GroupByVarContext groupByVar() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(432); + setState(434); ((GroupByVarContext)_localctx).var_ref = varRef(); - setState(439); + setState(441); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__23 || _la==Kas) { { - setState(435); + setState(437); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(433); + setState(435); match(Kas); - setState(434); + setState(436); ((GroupByVarContext)_localctx).seq = sequenceType(); } } - setState(437); + setState(439); ((GroupByVarContext)_localctx).decl = match(T__23); - setState(438); + setState(440); ((GroupByVarContext)_localctx).ex = exprSingle(); } } - setState(443); + setState(445); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kcollation) { { - setState(441); + setState(443); match(Kcollation); - setState(442); + setState(444); ((GroupByVarContext)_localctx).uri = uriLiteral(); } } @@ -2405,15 +2411,15 @@ public final OrderByClauseContext orderByClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(450); + setState(452); _errHandler.sync(this); switch (_input.LA(1)) { case Korder: { { - setState(445); + setState(447); match(Korder); - setState(446); + setState(448); match(Kby); } } @@ -2421,11 +2427,11 @@ public final OrderByClauseContext orderByClause() throws RecognitionException { case Kstable: { { - setState(447); + setState(449); ((OrderByClauseContext)_localctx).stb = match(Kstable); - setState(448); + setState(450); match(Korder); - setState(449); + setState(451); match(Kby); } } @@ -2433,21 +2439,21 @@ public final OrderByClauseContext orderByClause() throws RecognitionException { default: throw new NoViableAltException(this); } - setState(452); + setState(454); orderByExpr(); - setState(457); + setState(459); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(453); + setState(455); match(T__21); - setState(454); + setState(456); orderByExpr(); } } - setState(459); + setState(461); _errHandler.sync(this); _la = _input.LA(1); } @@ -2500,20 +2506,20 @@ public final OrderByExprContext orderByExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(460); + setState(462); ((OrderByExprContext)_localctx).ex = exprSingle(); - setState(463); + setState(465); _errHandler.sync(this); switch (_input.LA(1)) { case Kascending: { - setState(461); + setState(463); match(Kascending); } break; case Kdescending: { - setState(462); + setState(464); ((OrderByExprContext)_localctx).desc = match(Kdescending); } break; @@ -2532,25 +2538,25 @@ public final OrderByExprContext orderByExpr() throws RecognitionException { default: break; } - setState(470); + setState(472); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kempty) { { - setState(465); + setState(467); match(Kempty); - setState(468); + setState(470); _errHandler.sync(this); switch (_input.LA(1)) { case Kgreatest: { - setState(466); + setState(468); ((OrderByExprContext)_localctx).gr = match(Kgreatest); } break; case Kleast: { - setState(467); + setState(469); ((OrderByExprContext)_localctx).ls = match(Kleast); } break; @@ -2560,14 +2566,14 @@ public final OrderByExprContext orderByExpr() throws RecognitionException { } } - setState(474); + setState(476); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kcollation) { { - setState(472); + setState(474); match(Kcollation); - setState(473); + setState(475); ((OrderByExprContext)_localctx).uril = uriLiteral(); } } @@ -2607,9 +2613,9 @@ public final CountClauseContext countClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(476); + setState(478); match(Kcount); - setState(477); + setState(479); varRef(); } } @@ -2659,47 +2665,47 @@ public final QuantifiedExprContext quantifiedExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(481); + setState(483); _errHandler.sync(this); switch (_input.LA(1)) { case Ksome: { - setState(479); + setState(481); ((QuantifiedExprContext)_localctx).so = match(Ksome); } break; case Kevery: { - setState(480); + setState(482); ((QuantifiedExprContext)_localctx).ev = match(Kevery); } break; default: throw new NoViableAltException(this); } - setState(483); + setState(485); ((QuantifiedExprContext)_localctx).quantifiedExprVar = quantifiedExprVar(); ((QuantifiedExprContext)_localctx).vars.add(((QuantifiedExprContext)_localctx).quantifiedExprVar); - setState(488); + setState(490); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(484); + setState(486); match(T__21); - setState(485); + setState(487); ((QuantifiedExprContext)_localctx).quantifiedExprVar = quantifiedExprVar(); ((QuantifiedExprContext)_localctx).vars.add(((QuantifiedExprContext)_localctx).quantifiedExprVar); } } - setState(490); + setState(492); _errHandler.sync(this); _la = _input.LA(1); } - setState(491); + setState(493); match(Ksatisfies); - setState(492); + setState(494); exprSingle(); } } @@ -2744,23 +2750,23 @@ public final QuantifiedExprVarContext quantifiedExprVar() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(494); + setState(496); varRef(); - setState(497); + setState(499); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(495); + setState(497); match(Kas); - setState(496); + setState(498); sequenceType(); } } - setState(499); + setState(501); match(Kin); - setState(500); + setState(502); exprSingle(); } } @@ -2813,34 +2819,34 @@ public final SwitchExprContext switchExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(502); + setState(504); match(Kswitch); - setState(503); + setState(505); match(T__26); - setState(504); + setState(506); ((SwitchExprContext)_localctx).cond = expr(); - setState(505); + setState(507); match(T__27); - setState(507); + setState(509); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(506); + setState(508); ((SwitchExprContext)_localctx).switchCaseClause = switchCaseClause(); ((SwitchExprContext)_localctx).cases.add(((SwitchExprContext)_localctx).switchCaseClause); } } - setState(509); + setState(511); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Kcase ); - setState(511); + setState(513); match(Kdefault); - setState(512); + setState(514); match(Kreturn); - setState(513); + setState(515); ((SwitchExprContext)_localctx).def = exprSingle(); } } @@ -2888,26 +2894,26 @@ public final SwitchCaseClauseContext switchCaseClause() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(517); + setState(519); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(515); + setState(517); match(Kcase); - setState(516); + setState(518); ((SwitchCaseClauseContext)_localctx).exprSingle = exprSingle(); ((SwitchCaseClauseContext)_localctx).cond.add(((SwitchCaseClauseContext)_localctx).exprSingle); } } - setState(519); + setState(521); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Kcase ); - setState(521); + setState(523); match(Kreturn); - setState(522); + setState(524); ((SwitchCaseClauseContext)_localctx).ret = exprSingle(); } } @@ -2964,44 +2970,44 @@ public final TypeSwitchExprContext typeSwitchExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(524); + setState(526); match(Ktypeswitch); - setState(525); + setState(527); match(T__26); - setState(526); + setState(528); ((TypeSwitchExprContext)_localctx).cond = expr(); - setState(527); + setState(529); match(T__27); - setState(529); + setState(531); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(528); + setState(530); ((TypeSwitchExprContext)_localctx).caseClause = caseClause(); ((TypeSwitchExprContext)_localctx).cses.add(((TypeSwitchExprContext)_localctx).caseClause); } } - setState(531); + setState(533); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Kcase ); - setState(533); - match(Kdefault); setState(535); + match(Kdefault); + setState(537); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(534); + setState(536); ((TypeSwitchExprContext)_localctx).var_ref = varRef(); } } - setState(537); + setState(539); match(Kreturn); - setState(538); + setState(540); ((TypeSwitchExprContext)_localctx).def = exprSingle(); } } @@ -3054,43 +3060,43 @@ public final CaseClauseContext caseClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(540); + setState(542); match(Kcase); - setState(544); + setState(546); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(541); + setState(543); ((CaseClauseContext)_localctx).var_ref = varRef(); - setState(542); + setState(544); match(Kas); } } - setState(546); + setState(548); ((CaseClauseContext)_localctx).sequenceType = sequenceType(); ((CaseClauseContext)_localctx).union.add(((CaseClauseContext)_localctx).sequenceType); - setState(551); + setState(553); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__31) { { { - setState(547); + setState(549); match(T__31); - setState(548); + setState(550); ((CaseClauseContext)_localctx).sequenceType = sequenceType(); ((CaseClauseContext)_localctx).union.add(((CaseClauseContext)_localctx).sequenceType); } } - setState(553); + setState(555); _errHandler.sync(this); _la = _input.LA(1); } - setState(554); + setState(556); match(Kreturn); - setState(555); + setState(557); ((CaseClauseContext)_localctx).ret = exprSingle(); } } @@ -3138,21 +3144,21 @@ public final IfExprContext ifExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(557); + setState(559); match(Kif); - setState(558); + setState(560); match(T__26); - setState(559); + setState(561); ((IfExprContext)_localctx).test_condition = expr(); - setState(560); + setState(562); match(T__27); - setState(561); + setState(563); match(Kthen); - setState(562); + setState(564); ((IfExprContext)_localctx).branch = exprSingle(); - setState(563); + setState(565); match(Kelse); - setState(564); + setState(566); ((IfExprContext)_localctx).else_branch = exprSingle(); } } @@ -3199,15 +3205,15 @@ public final TryCatchExprContext tryCatchExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(566); + setState(568); match(Ktry); - setState(567); + setState(569); match(T__28); - setState(568); + setState(570); ((TryCatchExprContext)_localctx).try_expression = expr(); - setState(569); + setState(571); match(T__29); - setState(571); + setState(573); _errHandler.sync(this); _alt = 1; do { @@ -3215,7 +3221,7 @@ public final TryCatchExprContext tryCatchExpr() throws RecognitionException { case 1: { { - setState(570); + setState(572); ((TryCatchExprContext)_localctx).catchClause = catchClause(); ((TryCatchExprContext)_localctx).catches.add(((TryCatchExprContext)_localctx).catchClause); } @@ -3224,10 +3230,10 @@ public final TryCatchExprContext tryCatchExpr() throws RecognitionException { default: throw new NoViableAltException(this); } - setState(573); + setState(575); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,54,_ctx); - } while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ); + } while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); } } catch (RecognitionException re) { @@ -3275,14 +3281,14 @@ public final CatchClauseContext catchClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(575); + setState(577); match(Kcatch); - setState(578); + setState(580); _errHandler.sync(this); switch (_input.LA(1)) { case T__32: { - setState(576); + setState(578); ((CatchClauseContext)_localctx).s33 = match(T__32); ((CatchClauseContext)_localctx).jokers.add(((CatchClauseContext)_localctx).s33); } @@ -3324,6 +3330,8 @@ public final CatchClauseContext catchClause() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -3332,7 +3340,7 @@ public final CatchClauseContext catchClause() throws RecognitionException { case NullLiteral: case NCName: { - setState(577); + setState(579); ((CatchClauseContext)_localctx).qname = qname(); ((CatchClauseContext)_localctx).errors.add(((CatchClauseContext)_localctx).qname); } @@ -3340,20 +3348,20 @@ public final CatchClauseContext catchClause() throws RecognitionException { default: throw new NoViableAltException(this); } - setState(587); + setState(589); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__31) { { { - setState(580); + setState(582); match(T__31); - setState(583); + setState(585); _errHandler.sync(this); switch (_input.LA(1)) { case T__32: { - setState(581); + setState(583); ((CatchClauseContext)_localctx).s33 = match(T__32); ((CatchClauseContext)_localctx).jokers.add(((CatchClauseContext)_localctx).s33); } @@ -3395,6 +3403,8 @@ public final CatchClauseContext catchClause() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -3403,7 +3413,7 @@ public final CatchClauseContext catchClause() throws RecognitionException { case NullLiteral: case NCName: { - setState(582); + setState(584); ((CatchClauseContext)_localctx).qname = qname(); ((CatchClauseContext)_localctx).errors.add(((CatchClauseContext)_localctx).qname); } @@ -3413,15 +3423,15 @@ public final CatchClauseContext catchClause() throws RecognitionException { } } } - setState(589); + setState(591); _errHandler.sync(this); _la = _input.LA(1); } - setState(590); + setState(592); match(T__28); - setState(591); + setState(593); ((CatchClauseContext)_localctx).catch_expression = expr(); - setState(592); + setState(594); match(T__29); } } @@ -3468,24 +3478,24 @@ public final OrExprContext orExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(594); + setState(596); ((OrExprContext)_localctx).main_expr = andExpr(); - setState(599); + setState(601); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,58,_ctx); - while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(595); + setState(597); match(Kor); - setState(596); + setState(598); ((OrExprContext)_localctx).andExpr = andExpr(); ((OrExprContext)_localctx).rhs.add(((OrExprContext)_localctx).andExpr); } } } - setState(601); + setState(603); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,58,_ctx); } @@ -3534,24 +3544,24 @@ public final AndExprContext andExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(602); + setState(604); ((AndExprContext)_localctx).main_expr = notExpr(); - setState(607); + setState(609); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,59,_ctx); - while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(603); + setState(605); match(Kand); - setState(604); + setState(606); ((AndExprContext)_localctx).notExpr = notExpr(); ((AndExprContext)_localctx).rhs.add(((AndExprContext)_localctx).notExpr); } } } - setState(609); + setState(611); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,59,_ctx); } @@ -3593,18 +3603,18 @@ public final NotExprContext notExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(611); + setState(613); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,60,_ctx) ) { case 1: { - setState(610); + setState(612); ((NotExprContext)_localctx).Knot = match(Knot); ((NotExprContext)_localctx).op.add(((NotExprContext)_localctx).Knot); } break; } - setState(613); + setState(615); ((NotExprContext)_localctx).main_expr = comparisonExpr(); } } @@ -3661,14 +3671,14 @@ public final ComparisonExprContext comparisonExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(615); + setState(617); ((ComparisonExprContext)_localctx).main_expr = stringConcatExpr(); - setState(618); + setState(620); _errHandler.sync(this); _la = _input.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40) | (1L << T__41) | (1L << T__42) | (1L << T__43))) != 0)) { { - setState(616); + setState(618); ((ComparisonExprContext)_localctx)._tset1171 = _input.LT(1); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40) | (1L << T__41) | (1L << T__42) | (1L << T__43))) != 0)) ) { @@ -3680,7 +3690,7 @@ public final ComparisonExprContext comparisonExpr() throws RecognitionException consume(); } ((ComparisonExprContext)_localctx).op.add(((ComparisonExprContext)_localctx)._tset1171); - setState(617); + setState(619); ((ComparisonExprContext)_localctx).stringConcatExpr = stringConcatExpr(); ((ComparisonExprContext)_localctx).rhs.add(((ComparisonExprContext)_localctx).stringConcatExpr); } @@ -3727,22 +3737,22 @@ public final StringConcatExprContext stringConcatExpr() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(620); + setState(622); ((StringConcatExprContext)_localctx).main_expr = rangeExpr(); - setState(625); + setState(627); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__44) { { { - setState(621); + setState(623); match(T__44); - setState(622); + setState(624); ((StringConcatExprContext)_localctx).rangeExpr = rangeExpr(); ((StringConcatExprContext)_localctx).rhs.add(((StringConcatExprContext)_localctx).rangeExpr); } } - setState(627); + setState(629); _errHandler.sync(this); _la = _input.LA(1); } @@ -3787,16 +3797,16 @@ public final RangeExprContext rangeExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(628); + setState(630); ((RangeExprContext)_localctx).main_expr = additiveExpr(); - setState(631); + setState(633); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,63,_ctx) ) { case 1: { - setState(629); + setState(631); match(Kto); - setState(630); + setState(632); ((RangeExprContext)_localctx).additiveExpr = additiveExpr(); ((RangeExprContext)_localctx).rhs.add(((RangeExprContext)_localctx).additiveExpr); } @@ -3848,16 +3858,16 @@ public final AdditiveExprContext additiveExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(633); + setState(635); ((AdditiveExprContext)_localctx).main_expr = multiplicativeExpr(); - setState(638); + setState(640); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,64,_ctx); - while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(634); + setState(636); ((AdditiveExprContext)_localctx)._tset1280 = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__45 || _la==T__46) ) { @@ -3869,13 +3879,13 @@ public final AdditiveExprContext additiveExpr() throws RecognitionException { consume(); } ((AdditiveExprContext)_localctx).op.add(((AdditiveExprContext)_localctx)._tset1280); - setState(635); + setState(637); ((AdditiveExprContext)_localctx).multiplicativeExpr = multiplicativeExpr(); ((AdditiveExprContext)_localctx).rhs.add(((AdditiveExprContext)_localctx).multiplicativeExpr); } } } - setState(640); + setState(642); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,64,_ctx); } @@ -3926,15 +3936,15 @@ public final MultiplicativeExprContext multiplicativeExpr() throws RecognitionEx try { enterOuterAlt(_localctx, 1); { - setState(641); + setState(643); ((MultiplicativeExprContext)_localctx).main_expr = instanceOfExpr(); - setState(646); + setState(648); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__32) | (1L << T__47) | (1L << T__48) | (1L << T__49))) != 0)) { { { - setState(642); + setState(644); ((MultiplicativeExprContext)_localctx)._tset1308 = _input.LT(1); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__32) | (1L << T__47) | (1L << T__48) | (1L << T__49))) != 0)) ) { @@ -3946,12 +3956,12 @@ public final MultiplicativeExprContext multiplicativeExpr() throws RecognitionEx consume(); } ((MultiplicativeExprContext)_localctx).op.add(((MultiplicativeExprContext)_localctx)._tset1308); - setState(643); + setState(645); ((MultiplicativeExprContext)_localctx).instanceOfExpr = instanceOfExpr(); ((MultiplicativeExprContext)_localctx).rhs.add(((MultiplicativeExprContext)_localctx).instanceOfExpr); } } - setState(648); + setState(650); _errHandler.sync(this); _la = _input.LA(1); } @@ -3969,10 +3979,10 @@ public final MultiplicativeExprContext multiplicativeExpr() throws RecognitionEx } public static class InstanceOfExprContext extends ParserRuleContext { - public TreatExprContext main_expr; + public IsStaticallyExprContext main_expr; public SequenceTypeContext seq; - public TreatExprContext treatExpr() { - return getRuleContext(TreatExprContext.class,0); + public IsStaticallyExprContext isStaticallyExpr() { + return getRuleContext(IsStaticallyExprContext.class,0); } public TerminalNode Kinstance() { return getToken(JsoniqParser.Kinstance, 0); } public TerminalNode Kof() { return getToken(JsoniqParser.Kof, 0); } @@ -3996,18 +4006,18 @@ public final InstanceOfExprContext instanceOfExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(649); - ((InstanceOfExprContext)_localctx).main_expr = treatExpr(); - setState(653); + setState(651); + ((InstanceOfExprContext)_localctx).main_expr = isStaticallyExpr(); + setState(655); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,66,_ctx) ) { case 1: { - setState(650); + setState(652); match(Kinstance); - setState(651); + setState(653); match(Kof); - setState(652); + setState(654); ((InstanceOfExprContext)_localctx).seq = sequenceType(); } break; @@ -4025,6 +4035,63 @@ public final InstanceOfExprContext instanceOfExpr() throws RecognitionException return _localctx; } + public static class IsStaticallyExprContext extends ParserRuleContext { + public TreatExprContext main_expr; + public SequenceTypeContext seq; + public TreatExprContext treatExpr() { + return getRuleContext(TreatExprContext.class,0); + } + public TerminalNode Kis() { return getToken(JsoniqParser.Kis, 0); } + public TerminalNode Kstatically() { return getToken(JsoniqParser.Kstatically, 0); } + public SequenceTypeContext sequenceType() { + return getRuleContext(SequenceTypeContext.class,0); + } + public IsStaticallyExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_isStaticallyExpr; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor)visitor).visitIsStaticallyExpr(this); + else return visitor.visitChildren(this); + } + } + + public final IsStaticallyExprContext isStaticallyExpr() throws RecognitionException { + IsStaticallyExprContext _localctx = new IsStaticallyExprContext(_ctx, getState()); + enterRule(_localctx, 102, RULE_isStaticallyExpr); + try { + enterOuterAlt(_localctx, 1); + { + setState(657); + ((IsStaticallyExprContext)_localctx).main_expr = treatExpr(); + setState(661); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,67,_ctx) ) { + case 1: + { + setState(658); + match(Kis); + setState(659); + match(Kstatically); + setState(660); + ((IsStaticallyExprContext)_localctx).seq = sequenceType(); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + public static class TreatExprContext extends ParserRuleContext { public CastableExprContext main_expr; public SequenceTypeContext seq; @@ -4049,22 +4116,22 @@ public T accept(ParseTreeVisitor visitor) { public final TreatExprContext treatExpr() throws RecognitionException { TreatExprContext _localctx = new TreatExprContext(_ctx, getState()); - enterRule(_localctx, 102, RULE_treatExpr); + enterRule(_localctx, 104, RULE_treatExpr); try { enterOuterAlt(_localctx, 1); { - setState(655); + setState(663); ((TreatExprContext)_localctx).main_expr = castableExpr(); - setState(659); + setState(667); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,67,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,68,_ctx) ) { case 1: { - setState(656); + setState(664); match(Ktreat); - setState(657); + setState(665); match(Kas); - setState(658); + setState(666); ((TreatExprContext)_localctx).seq = sequenceType(); } break; @@ -4106,22 +4173,22 @@ public T accept(ParseTreeVisitor visitor) { public final CastableExprContext castableExpr() throws RecognitionException { CastableExprContext _localctx = new CastableExprContext(_ctx, getState()); - enterRule(_localctx, 104, RULE_castableExpr); + enterRule(_localctx, 106, RULE_castableExpr); try { enterOuterAlt(_localctx, 1); { - setState(661); + setState(669); ((CastableExprContext)_localctx).main_expr = castExpr(); - setState(665); + setState(673); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,68,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,69,_ctx) ) { case 1: { - setState(662); + setState(670); match(Kcastable); - setState(663); + setState(671); match(Kas); - setState(664); + setState(672); ((CastableExprContext)_localctx).single = singleType(); } break; @@ -4163,22 +4230,22 @@ public T accept(ParseTreeVisitor visitor) { public final CastExprContext castExpr() throws RecognitionException { CastExprContext _localctx = new CastExprContext(_ctx, getState()); - enterRule(_localctx, 106, RULE_castExpr); + enterRule(_localctx, 108, RULE_castExpr); try { enterOuterAlt(_localctx, 1); { - setState(667); + setState(675); ((CastExprContext)_localctx).main_expr = arrowExpr(); - setState(671); + setState(679); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,69,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,70,_ctx) ) { case 1: { - setState(668); + setState(676); match(Kcast); - setState(669); + setState(677); match(Kas); - setState(670); + setState(678); ((CastExprContext)_localctx).single = singleType(); } break; @@ -4222,35 +4289,35 @@ public T accept(ParseTreeVisitor visitor) { public final ArrowExprContext arrowExpr() throws RecognitionException { ArrowExprContext _localctx = new ArrowExprContext(_ctx, getState()); - enterRule(_localctx, 108, RULE_arrowExpr); + enterRule(_localctx, 110, RULE_arrowExpr); try { int _alt; enterOuterAlt(_localctx, 1); { - setState(673); + setState(681); ((ArrowExprContext)_localctx).main_expr = unaryExpr(); - setState(680); + setState(688); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,70,_ctx); - while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { + _alt = getInterpreter().adaptivePredict(_input,71,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { { - setState(674); + setState(682); match(T__3); - setState(675); + setState(683); match(T__42); } - setState(677); + setState(685); ((ArrowExprContext)_localctx).functionCall = functionCall(); ((ArrowExprContext)_localctx).function_call_expr.add(((ArrowExprContext)_localctx).functionCall); } } } - setState(682); + setState(690); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,70,_ctx); + _alt = getInterpreter().adaptivePredict(_input,71,_ctx); } } } @@ -4269,7 +4336,7 @@ public static class UnaryExprContext extends ParserRuleContext { public Token s47; public List op = new ArrayList(); public Token s46; - public Token _tset1447; + public Token _tset1468; public SimpleMapExprContext main_expr; public SimpleMapExprContext simpleMapExpr() { return getRuleContext(SimpleMapExprContext.class,0); @@ -4287,36 +4354,36 @@ public T accept(ParseTreeVisitor visitor) { public final UnaryExprContext unaryExpr() throws RecognitionException { UnaryExprContext _localctx = new UnaryExprContext(_ctx, getState()); - enterRule(_localctx, 110, RULE_unaryExpr); + enterRule(_localctx, 112, RULE_unaryExpr); int _la; try { enterOuterAlt(_localctx, 1); { - setState(686); + setState(694); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__45 || _la==T__46) { { { - setState(683); - ((UnaryExprContext)_localctx)._tset1447 = _input.LT(1); + setState(691); + ((UnaryExprContext)_localctx)._tset1468 = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__45 || _la==T__46) ) { - ((UnaryExprContext)_localctx)._tset1447 = (Token)_errHandler.recoverInline(this); + ((UnaryExprContext)_localctx)._tset1468 = (Token)_errHandler.recoverInline(this); } else { if ( _input.LA(1)==Token.EOF ) matchedEOF = true; _errHandler.reportMatch(this); consume(); } - ((UnaryExprContext)_localctx).op.add(((UnaryExprContext)_localctx)._tset1447); + ((UnaryExprContext)_localctx).op.add(((UnaryExprContext)_localctx)._tset1468); } } - setState(688); + setState(696); _errHandler.sync(this); _la = _input.LA(1); } - setState(689); + setState(697); ((UnaryExprContext)_localctx).main_expr = simpleMapExpr(); } } @@ -4354,27 +4421,27 @@ public T accept(ParseTreeVisitor visitor) { public final SimpleMapExprContext simpleMapExpr() throws RecognitionException { SimpleMapExprContext _localctx = new SimpleMapExprContext(_ctx, getState()); - enterRule(_localctx, 112, RULE_simpleMapExpr); + enterRule(_localctx, 114, RULE_simpleMapExpr); int _la; try { enterOuterAlt(_localctx, 1); { - setState(691); + setState(699); ((SimpleMapExprContext)_localctx).main_expr = postFixExpr(); - setState(696); + setState(704); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__50) { { { - setState(692); + setState(700); match(T__50); - setState(693); + setState(701); ((SimpleMapExprContext)_localctx).postFixExpr = postFixExpr(); ((SimpleMapExprContext)_localctx).map_expr.add(((SimpleMapExprContext)_localctx).postFixExpr); } } - setState(698); + setState(706); _errHandler.sync(this); _la = _input.LA(1); } @@ -4439,58 +4506,58 @@ public T accept(ParseTreeVisitor visitor) { public final PostFixExprContext postFixExpr() throws RecognitionException { PostFixExprContext _localctx = new PostFixExprContext(_ctx, getState()); - enterRule(_localctx, 114, RULE_postFixExpr); + enterRule(_localctx, 116, RULE_postFixExpr); try { int _alt; enterOuterAlt(_localctx, 1); { - setState(699); - ((PostFixExprContext)_localctx).main_expr = primaryExpr(); setState(707); + ((PostFixExprContext)_localctx).main_expr = primaryExpr(); + setState(715); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,74,_ctx); - while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { + _alt = getInterpreter().adaptivePredict(_input,75,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { - setState(705); + setState(713); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,73,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,74,_ctx) ) { case 1: { - setState(700); + setState(708); arrayLookup(); } break; case 2: { - setState(701); + setState(709); predicate(); } break; case 3: { - setState(702); + setState(710); objectLookup(); } break; case 4: { - setState(703); + setState(711); arrayUnboxing(); } break; case 5: { - setState(704); + setState(712); argumentList(); } break; } } } - setState(709); + setState(717); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,74,_ctx); + _alt = getInterpreter().adaptivePredict(_input,75,_ctx); } } } @@ -4522,19 +4589,19 @@ public T accept(ParseTreeVisitor visitor) { public final ArrayLookupContext arrayLookup() throws RecognitionException { ArrayLookupContext _localctx = new ArrayLookupContext(_ctx, getState()); - enterRule(_localctx, 116, RULE_arrayLookup); + enterRule(_localctx, 118, RULE_arrayLookup); try { enterOuterAlt(_localctx, 1); { - setState(710); + setState(718); match(T__51); - setState(711); + setState(719); match(T__51); - setState(712); + setState(720); expr(); - setState(713); + setState(721); match(T__52); - setState(714); + setState(722); match(T__52); } } @@ -4563,13 +4630,13 @@ public T accept(ParseTreeVisitor visitor) { public final ArrayUnboxingContext arrayUnboxing() throws RecognitionException { ArrayUnboxingContext _localctx = new ArrayUnboxingContext(_ctx, getState()); - enterRule(_localctx, 118, RULE_arrayUnboxing); + enterRule(_localctx, 120, RULE_arrayUnboxing); try { enterOuterAlt(_localctx, 1); { - setState(716); + setState(724); match(T__51); - setState(717); + setState(725); match(T__52); } } @@ -4601,15 +4668,15 @@ public T accept(ParseTreeVisitor visitor) { public final PredicateContext predicate() throws RecognitionException { PredicateContext _localctx = new PredicateContext(_ctx, getState()); - enterRule(_localctx, 120, RULE_predicate); + enterRule(_localctx, 122, RULE_predicate); try { enterOuterAlt(_localctx, 1); { - setState(719); + setState(727); match(T__51); - setState(720); + setState(728); expr(); - setState(721); + setState(729); match(T__52); } } @@ -4660,13 +4727,13 @@ public T accept(ParseTreeVisitor visitor) { public final ObjectLookupContext objectLookup() throws RecognitionException { ObjectLookupContext _localctx = new ObjectLookupContext(_ctx, getState()); - enterRule(_localctx, 122, RULE_objectLookup); + enterRule(_localctx, 124, RULE_objectLookup); try { enterOuterAlt(_localctx, 1); { - setState(723); + setState(731); match(T__53); - setState(730); + setState(738); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: @@ -4706,6 +4773,8 @@ public final ObjectLookupContext objectLookup() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -4713,37 +4782,37 @@ public final ObjectLookupContext objectLookup() throws RecognitionException { case Kjsoniq: case NullLiteral: { - setState(724); + setState(732); ((ObjectLookupContext)_localctx).kw = keyWords(); } break; case STRING: { - setState(725); + setState(733); ((ObjectLookupContext)_localctx).lt = stringLiteral(); } break; case NCName: { - setState(726); + setState(734); ((ObjectLookupContext)_localctx).nc = match(NCName); } break; case T__26: { - setState(727); + setState(735); ((ObjectLookupContext)_localctx).pe = parenthesizedExpr(); } break; case T__30: { - setState(728); + setState(736); ((ObjectLookupContext)_localctx).vr = varRef(); } break; case T__54: { - setState(729); + setState(737); ((ObjectLookupContext)_localctx).ci = contextItemExpr(); } break; @@ -4809,92 +4878,92 @@ public T accept(ParseTreeVisitor visitor) { public final PrimaryExprContext primaryExpr() throws RecognitionException { PrimaryExprContext _localctx = new PrimaryExprContext(_ctx, getState()); - enterRule(_localctx, 124, RULE_primaryExpr); + enterRule(_localctx, 126, RULE_primaryExpr); try { - setState(744); + setState(752); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,76,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,77,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(732); + setState(740); match(NullLiteral); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(733); + setState(741); match(Literal); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(734); + setState(742); stringLiteral(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(735); + setState(743); varRef(); } break; case 5: enterOuterAlt(_localctx, 5); { - setState(736); + setState(744); parenthesizedExpr(); } break; case 6: enterOuterAlt(_localctx, 6); { - setState(737); + setState(745); contextItemExpr(); } break; case 7: enterOuterAlt(_localctx, 7); { - setState(738); + setState(746); objectConstructor(); } break; case 8: enterOuterAlt(_localctx, 8); { - setState(739); + setState(747); functionCall(); } break; case 9: enterOuterAlt(_localctx, 9); { - setState(740); + setState(748); orderedExpr(); } break; case 10: enterOuterAlt(_localctx, 10); { - setState(741); + setState(749); unorderedExpr(); } break; case 11: enterOuterAlt(_localctx, 11); { - setState(742); + setState(750); arrayConstructor(); } break; case 12: enterOuterAlt(_localctx, 12); { - setState(743); + setState(751); functionItemExpr(); } break; @@ -4929,13 +4998,13 @@ public T accept(ParseTreeVisitor visitor) { public final VarRefContext varRef() throws RecognitionException { VarRefContext _localctx = new VarRefContext(_ctx, getState()); - enterRule(_localctx, 126, RULE_varRef); + enterRule(_localctx, 128, RULE_varRef); try { enterOuterAlt(_localctx, 1); { - setState(746); + setState(754); match(T__30); - setState(747); + setState(755); ((VarRefContext)_localctx).var_name = qname(); } } @@ -4967,24 +5036,24 @@ public T accept(ParseTreeVisitor visitor) { public final ParenthesizedExprContext parenthesizedExpr() throws RecognitionException { ParenthesizedExprContext _localctx = new ParenthesizedExprContext(_ctx, getState()); - enterRule(_localctx, 128, RULE_parenthesizedExpr); + enterRule(_localctx, 130, RULE_parenthesizedExpr); int _la; try { enterOuterAlt(_localctx, 1); { - setState(749); + setState(757); match(T__26); - setState(751); + setState(759); _errHandler.sync(this); _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { { - setState(750); + setState(758); expr(); } } - setState(753); + setState(761); match(T__27); } } @@ -5013,11 +5082,11 @@ public T accept(ParseTreeVisitor visitor) { public final ContextItemExprContext contextItemExpr() throws RecognitionException { ContextItemExprContext _localctx = new ContextItemExprContext(_ctx, getState()); - enterRule(_localctx, 130, RULE_contextItemExpr); + enterRule(_localctx, 132, RULE_contextItemExpr); try { enterOuterAlt(_localctx, 1); { - setState(755); + setState(763); match(T__54); } } @@ -5049,17 +5118,17 @@ public T accept(ParseTreeVisitor visitor) { public final OrderedExprContext orderedExpr() throws RecognitionException { OrderedExprContext _localctx = new OrderedExprContext(_ctx, getState()); - enterRule(_localctx, 132, RULE_orderedExpr); + enterRule(_localctx, 134, RULE_orderedExpr); try { enterOuterAlt(_localctx, 1); { - setState(757); + setState(765); match(T__6); - setState(758); + setState(766); match(T__28); - setState(759); + setState(767); expr(); - setState(760); + setState(768); match(T__29); } } @@ -5091,17 +5160,17 @@ public T accept(ParseTreeVisitor visitor) { public final UnorderedExprContext unorderedExpr() throws RecognitionException { UnorderedExprContext _localctx = new UnorderedExprContext(_ctx, getState()); - enterRule(_localctx, 134, RULE_unorderedExpr); + enterRule(_localctx, 136, RULE_unorderedExpr); try { enterOuterAlt(_localctx, 1); { - setState(762); + setState(770); match(T__7); - setState(763); + setState(771); match(T__28); - setState(764); + setState(772); expr(); - setState(765); + setState(773); match(T__29); } } @@ -5137,13 +5206,13 @@ public T accept(ParseTreeVisitor visitor) { public final FunctionCallContext functionCall() throws RecognitionException { FunctionCallContext _localctx = new FunctionCallContext(_ctx, getState()); - enterRule(_localctx, 136, RULE_functionCall); + enterRule(_localctx, 138, RULE_functionCall); try { enterOuterAlt(_localctx, 1); { - setState(767); + setState(775); ((FunctionCallContext)_localctx).fn_name = qname(); - setState(768); + setState(776); argumentList(); } } @@ -5180,39 +5249,39 @@ public T accept(ParseTreeVisitor visitor) { public final ArgumentListContext argumentList() throws RecognitionException { ArgumentListContext _localctx = new ArgumentListContext(_ctx, getState()); - enterRule(_localctx, 138, RULE_argumentList); + enterRule(_localctx, 140, RULE_argumentList); int _la; try { enterOuterAlt(_localctx, 1); { - setState(770); + setState(778); match(T__26); - setState(777); + setState(785); _errHandler.sync(this); _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (ArgumentPlaceholder - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (ArgumentPlaceholder - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { { { - setState(771); + setState(779); ((ArgumentListContext)_localctx).argument = argument(); ((ArgumentListContext)_localctx).args.add(((ArgumentListContext)_localctx).argument); - setState(773); + setState(781); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__21) { { - setState(772); + setState(780); match(T__21); } } } } - setState(779); + setState(787); _errHandler.sync(this); _la = _input.LA(1); } - setState(780); + setState(788); match(T__27); } } @@ -5245,9 +5314,9 @@ public T accept(ParseTreeVisitor visitor) { public final ArgumentContext argument() throws RecognitionException { ArgumentContext _localctx = new ArgumentContext(_ctx, getState()); - enterRule(_localctx, 140, RULE_argument); + enterRule(_localctx, 142, RULE_argument); try { - setState(784); + setState(792); _errHandler.sync(this); switch (_input.LA(1)) { case T__6: @@ -5298,6 +5367,8 @@ public final ArgumentContext argument() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -5309,14 +5380,14 @@ public final ArgumentContext argument() throws RecognitionException { case NCName: enterOuterAlt(_localctx, 1); { - setState(782); + setState(790); exprSingle(); } break; case ArgumentPlaceholder: enterOuterAlt(_localctx, 2); { - setState(783); + setState(791); match(ArgumentPlaceholder); } break; @@ -5355,9 +5426,9 @@ public T accept(ParseTreeVisitor visitor) { public final FunctionItemExprContext functionItemExpr() throws RecognitionException { FunctionItemExprContext _localctx = new FunctionItemExprContext(_ctx, getState()); - enterRule(_localctx, 142, RULE_functionItemExpr); + enterRule(_localctx, 144, RULE_functionItemExpr); try { - setState(788); + setState(796); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: @@ -5397,6 +5468,8 @@ public final FunctionItemExprContext functionItemExpr() throws RecognitionExcept case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -5406,14 +5479,14 @@ public final FunctionItemExprContext functionItemExpr() throws RecognitionExcept case NCName: enterOuterAlt(_localctx, 1); { - setState(786); + setState(794); namedFunctionRef(); } break; case T__25: enterOuterAlt(_localctx, 2); { - setState(787); + setState(795); inlineFunctionExpr(); } break; @@ -5452,15 +5525,15 @@ public T accept(ParseTreeVisitor visitor) { public final NamedFunctionRefContext namedFunctionRef() throws RecognitionException { NamedFunctionRefContext _localctx = new NamedFunctionRefContext(_ctx, getState()); - enterRule(_localctx, 144, RULE_namedFunctionRef); + enterRule(_localctx, 146, RULE_namedFunctionRef); try { enterOuterAlt(_localctx, 1); { - setState(790); + setState(798); ((NamedFunctionRefContext)_localctx).fn_name = qname(); - setState(791); + setState(799); match(T__55); - setState(792); + setState(800); ((NamedFunctionRefContext)_localctx).arity = match(Literal); } } @@ -5501,53 +5574,53 @@ public T accept(ParseTreeVisitor visitor) { public final InlineFunctionExprContext inlineFunctionExpr() throws RecognitionException { InlineFunctionExprContext _localctx = new InlineFunctionExprContext(_ctx, getState()); - enterRule(_localctx, 146, RULE_inlineFunctionExpr); + enterRule(_localctx, 148, RULE_inlineFunctionExpr); int _la; try { enterOuterAlt(_localctx, 1); { - setState(794); + setState(802); match(T__25); - setState(795); + setState(803); match(T__26); - setState(797); + setState(805); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(796); + setState(804); paramList(); } } - setState(799); + setState(807); match(T__27); - setState(802); + setState(810); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(800); + setState(808); match(Kas); - setState(801); + setState(809); ((InlineFunctionExprContext)_localctx).return_type = sequenceType(); } } { - setState(804); + setState(812); match(T__28); - setState(806); + setState(814); _errHandler.sync(this); _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { { - setState(805); + setState(813); ((InlineFunctionExprContext)_localctx).fn_body = expr(); } } - setState(808); + setState(816); match(T__29); } } @@ -5565,7 +5638,7 @@ public final InlineFunctionExprContext inlineFunctionExpr() throws RecognitionEx public static class SequenceTypeContext extends ParserRuleContext { public ItemTypeContext item; - public Token s102; + public Token s104; public List question = new ArrayList(); public Token s33; public List star = new ArrayList(); @@ -5587,17 +5660,17 @@ public T accept(ParseTreeVisitor visitor) { public final SequenceTypeContext sequenceType() throws RecognitionException { SequenceTypeContext _localctx = new SequenceTypeContext(_ctx, getState()); - enterRule(_localctx, 148, RULE_sequenceType); + enterRule(_localctx, 150, RULE_sequenceType); try { - setState(818); + setState(826); _errHandler.sync(this); switch (_input.LA(1)) { case T__26: enterOuterAlt(_localctx, 1); { - setState(810); + setState(818); match(T__26); - setState(811); + setState(819); match(T__27); } break; @@ -5638,6 +5711,8 @@ public final SequenceTypeContext sequenceType() throws RecognitionException { case Kto: case Kinstance: case Kof: + case Kstatically: + case Kis: case Ktreat: case Kcast: case Kcastable: @@ -5647,28 +5722,28 @@ public final SequenceTypeContext sequenceType() throws RecognitionException { case NCName: enterOuterAlt(_localctx, 2); { - setState(812); + setState(820); ((SequenceTypeContext)_localctx).item = itemType(); - setState(816); + setState(824); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,85,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,86,_ctx) ) { case 1: { - setState(813); - ((SequenceTypeContext)_localctx).s102 = match(ArgumentPlaceholder); - ((SequenceTypeContext)_localctx).question.add(((SequenceTypeContext)_localctx).s102); + setState(821); + ((SequenceTypeContext)_localctx).s104 = match(ArgumentPlaceholder); + ((SequenceTypeContext)_localctx).question.add(((SequenceTypeContext)_localctx).s104); } break; case 2: { - setState(814); + setState(822); ((SequenceTypeContext)_localctx).s33 = match(T__32); ((SequenceTypeContext)_localctx).star.add(((SequenceTypeContext)_localctx).s33); } break; case 3: { - setState(815); + setState(823); ((SequenceTypeContext)_localctx).s46 = match(T__45); ((SequenceTypeContext)_localctx).plus.add(((SequenceTypeContext)_localctx).s46); } @@ -5716,56 +5791,56 @@ public T accept(ParseTreeVisitor visitor) { public final ObjectConstructorContext objectConstructor() throws RecognitionException { ObjectConstructorContext _localctx = new ObjectConstructorContext(_ctx, getState()); - enterRule(_localctx, 150, RULE_objectConstructor); + enterRule(_localctx, 152, RULE_objectConstructor); int _la; try { - setState(836); + setState(844); _errHandler.sync(this); switch (_input.LA(1)) { case T__28: enterOuterAlt(_localctx, 1); { - setState(820); + setState(828); match(T__28); - setState(829); + setState(837); _errHandler.sync(this); _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { { - setState(821); + setState(829); pairConstructor(); - setState(826); + setState(834); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(822); + setState(830); match(T__21); - setState(823); + setState(831); pairConstructor(); } } - setState(828); + setState(836); _errHandler.sync(this); _la = _input.LA(1); } } } - setState(831); + setState(839); match(T__29); } break; case T__56: enterOuterAlt(_localctx, 2); { - setState(832); + setState(840); ((ObjectConstructorContext)_localctx).s57 = match(T__56); ((ObjectConstructorContext)_localctx).merge_operator.add(((ObjectConstructorContext)_localctx).s57); - setState(833); + setState(841); expr(); - setState(834); + setState(842); match(T__57); } break; @@ -5802,22 +5877,22 @@ public T accept(ParseTreeVisitor visitor) { public final ItemTypeContext itemType() throws RecognitionException { ItemTypeContext _localctx = new ItemTypeContext(_ctx, getState()); - enterRule(_localctx, 152, RULE_itemType); + enterRule(_localctx, 154, RULE_itemType); try { - setState(840); + setState(848); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,90,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,91,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(838); + setState(846); qname(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(839); + setState(847); match(NullLiteral); } break; @@ -5836,7 +5911,7 @@ public final ItemTypeContext itemType() throws RecognitionException { public static class SingleTypeContext extends ParserRuleContext { public ItemTypeContext item; - public Token s102; + public Token s104; public List question = new ArrayList(); public ItemTypeContext itemType() { return getRuleContext(ItemTypeContext.class,0); @@ -5854,20 +5929,20 @@ public T accept(ParseTreeVisitor visitor) { public final SingleTypeContext singleType() throws RecognitionException { SingleTypeContext _localctx = new SingleTypeContext(_ctx, getState()); - enterRule(_localctx, 154, RULE_singleType); + enterRule(_localctx, 156, RULE_singleType); try { enterOuterAlt(_localctx, 1); { - setState(842); + setState(850); ((SingleTypeContext)_localctx).item = itemType(); - setState(844); + setState(852); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,91,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,92,_ctx) ) { case 1: { - setState(843); - ((SingleTypeContext)_localctx).s102 = match(ArgumentPlaceholder); - ((SingleTypeContext)_localctx).question.add(((SingleTypeContext)_localctx).s102); + setState(851); + ((SingleTypeContext)_localctx).s104 = match(ArgumentPlaceholder); + ((SingleTypeContext)_localctx).question.add(((SingleTypeContext)_localctx).s104); } break; } @@ -5908,28 +5983,28 @@ public T accept(ParseTreeVisitor visitor) { public final PairConstructorContext pairConstructor() throws RecognitionException { PairConstructorContext _localctx = new PairConstructorContext(_ctx, getState()); - enterRule(_localctx, 156, RULE_pairConstructor); + enterRule(_localctx, 158, RULE_pairConstructor); int _la; try { enterOuterAlt(_localctx, 1); { - setState(848); + setState(856); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,92,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,93,_ctx) ) { case 1: { - setState(846); + setState(854); ((PairConstructorContext)_localctx).lhs = exprSingle(); } break; case 2: { - setState(847); + setState(855); ((PairConstructorContext)_localctx).name = match(NCName); } break; } - setState(850); + setState(858); _la = _input.LA(1); if ( !(_la==T__9 || _la==ArgumentPlaceholder) ) { _errHandler.recoverInline(this); @@ -5939,7 +6014,7 @@ public final PairConstructorContext pairConstructor() throws RecognitionExceptio _errHandler.reportMatch(this); consume(); } - setState(851); + setState(859); ((PairConstructorContext)_localctx).rhs = exprSingle(); } } @@ -5971,24 +6046,24 @@ public T accept(ParseTreeVisitor visitor) { public final ArrayConstructorContext arrayConstructor() throws RecognitionException { ArrayConstructorContext _localctx = new ArrayConstructorContext(_ctx, getState()); - enterRule(_localctx, 158, RULE_arrayConstructor); + enterRule(_localctx, 160, RULE_arrayConstructor); int _la; try { enterOuterAlt(_localctx, 1); { - setState(853); + setState(861); match(T__51); - setState(855); + setState(863); _errHandler.sync(this); _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { { - setState(854); + setState(862); expr(); } } - setState(857); + setState(865); match(T__52); } } @@ -6020,11 +6095,11 @@ public T accept(ParseTreeVisitor visitor) { public final UriLiteralContext uriLiteral() throws RecognitionException { UriLiteralContext _localctx = new UriLiteralContext(_ctx, getState()); - enterRule(_localctx, 160, RULE_uriLiteral); + enterRule(_localctx, 162, RULE_uriLiteral); try { enterOuterAlt(_localctx, 1); { - setState(859); + setState(867); stringLiteral(); } } @@ -6054,11 +6129,11 @@ public T accept(ParseTreeVisitor visitor) { public final StringLiteralContext stringLiteral() throws RecognitionException { StringLiteralContext _localctx = new StringLiteralContext(_ctx, getState()); - enterRule(_localctx, 162, RULE_stringLiteral); + enterRule(_localctx, 164, RULE_stringLiteral); try { enterOuterAlt(_localctx, 1); { - setState(861); + setState(869); match(STRING); } } @@ -6083,6 +6158,8 @@ public static class KeyWordsContext extends ParserRuleContext { public TerminalNode Kelse() { return getToken(JsoniqParser.Kelse, 0); } public TerminalNode Kgreatest() { return getToken(JsoniqParser.Kgreatest, 0); } public TerminalNode Kinstance() { return getToken(JsoniqParser.Kinstance, 0); } + public TerminalNode Kstatically() { return getToken(JsoniqParser.Kstatically, 0); } + public TerminalNode Kis() { return getToken(JsoniqParser.Kis, 0); } public TerminalNode Kleast() { return getToken(JsoniqParser.Kleast, 0); } public TerminalNode Knot() { return getToken(JsoniqParser.Knot, 0); } public TerminalNode NullLiteral() { return getToken(JsoniqParser.NullLiteral, 0); } @@ -6130,14 +6207,14 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordsContext keyWords() throws RecognitionException { KeyWordsContext _localctx = new KeyWordsContext(_ctx, getState()); - enterRule(_localctx, 164, RULE_keyWords); + enterRule(_localctx, 166, RULE_keyWords); int _la; try { enterOuterAlt(_localctx, 1); { - setState(863); + setState(871); _la = _input.LA(1); - if ( !(((((_la - 59)) & ~0x3f) == 0 && ((1L << (_la - 59)) & ((1L << (Kfor - 59)) | (1L << (Klet - 59)) | (1L << (Kwhere - 59)) | (1L << (Kgroup - 59)) | (1L << (Kby - 59)) | (1L << (Korder - 59)) | (1L << (Kreturn - 59)) | (1L << (Kif - 59)) | (1L << (Kin - 59)) | (1L << (Kas - 59)) | (1L << (Kat - 59)) | (1L << (Kallowing - 59)) | (1L << (Kempty - 59)) | (1L << (Kcount - 59)) | (1L << (Kstable - 59)) | (1L << (Kascending - 59)) | (1L << (Kdescending - 59)) | (1L << (Ksome - 59)) | (1L << (Kevery - 59)) | (1L << (Ksatisfies - 59)) | (1L << (Kcollation - 59)) | (1L << (Kgreatest - 59)) | (1L << (Kleast - 59)) | (1L << (Kswitch - 59)) | (1L << (Kcase - 59)) | (1L << (Ktry - 59)) | (1L << (Kcatch - 59)) | (1L << (Kdefault - 59)) | (1L << (Kthen - 59)) | (1L << (Kelse - 59)) | (1L << (Ktypeswitch - 59)) | (1L << (Kor - 59)) | (1L << (Kand - 59)) | (1L << (Knot - 59)) | (1L << (Kto - 59)) | (1L << (Kinstance - 59)) | (1L << (Kof - 59)) | (1L << (Ktreat - 59)) | (1L << (Kcast - 59)) | (1L << (Kcastable - 59)) | (1L << (Kversion - 59)) | (1L << (Kjsoniq - 59)) | (1L << (NullLiteral - 59)))) != 0)) ) { + if ( !(((((_la - 59)) & ~0x3f) == 0 && ((1L << (_la - 59)) & ((1L << (Kfor - 59)) | (1L << (Klet - 59)) | (1L << (Kwhere - 59)) | (1L << (Kgroup - 59)) | (1L << (Kby - 59)) | (1L << (Korder - 59)) | (1L << (Kreturn - 59)) | (1L << (Kif - 59)) | (1L << (Kin - 59)) | (1L << (Kas - 59)) | (1L << (Kat - 59)) | (1L << (Kallowing - 59)) | (1L << (Kempty - 59)) | (1L << (Kcount - 59)) | (1L << (Kstable - 59)) | (1L << (Kascending - 59)) | (1L << (Kdescending - 59)) | (1L << (Ksome - 59)) | (1L << (Kevery - 59)) | (1L << (Ksatisfies - 59)) | (1L << (Kcollation - 59)) | (1L << (Kgreatest - 59)) | (1L << (Kleast - 59)) | (1L << (Kswitch - 59)) | (1L << (Kcase - 59)) | (1L << (Ktry - 59)) | (1L << (Kcatch - 59)) | (1L << (Kdefault - 59)) | (1L << (Kthen - 59)) | (1L << (Kelse - 59)) | (1L << (Ktypeswitch - 59)) | (1L << (Kor - 59)) | (1L << (Kand - 59)) | (1L << (Knot - 59)) | (1L << (Kto - 59)) | (1L << (Kinstance - 59)) | (1L << (Kof - 59)) | (1L << (Kstatically - 59)) | (1L << (Kis - 59)) | (1L << (Ktreat - 59)) | (1L << (Kcast - 59)) | (1L << (Kcastable - 59)) | (1L << (Kversion - 59)) | (1L << (Kjsoniq - 59)) | (1L << (NullLiteral - 59)))) != 0)) ) { _errHandler.recoverInline(this); } else { @@ -6159,7 +6236,7 @@ public final KeyWordsContext keyWords() throws RecognitionException { } public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3s\u0364\4\2\t\2\4"+ + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3u\u036c\4\2\t\2\4"+ "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ @@ -6169,319 +6246,322 @@ public final KeyWordsContext keyWords() throws RecognitionException { "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+ "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I"+ "\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT"+ - "\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\5\3\u00b1\n\3\3\3\3\3\5\3\u00b5\n\3\3"+ - "\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\5\6\u00c5\n\6\3"+ - "\6\3\6\7\6\u00c9\n\6\f\6\16\6\u00cc\13\6\3\6\3\6\3\6\7\6\u00d1\n\6\f\6"+ - "\16\6\u00d4\13\6\3\7\3\7\3\7\3\7\5\7\u00da\n\7\3\b\3\b\3\b\3\b\3\b\3\b"+ - "\3\t\3\t\5\t\u00e4\n\t\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\f\3\f"+ - "\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\5\r\u00fa\n\r\3\r\3\r\3\r\3\r\7\r"+ - "\u0100\n\r\f\r\16\r\u0103\13\r\3\16\3\16\5\16\u0107\n\16\3\16\5\16\u010a"+ - "\n\16\3\16\3\16\5\16\u010e\n\16\3\17\3\17\3\20\3\20\3\21\3\21\3\21\3\21"+ - "\3\21\5\21\u0119\n\21\3\21\3\21\3\21\3\21\3\21\7\21\u0120\n\21\f\21\16"+ - "\21\u0123\13\21\5\21\u0125\n\21\3\22\3\22\3\22\3\22\3\22\5\22\u012c\n"+ - "\22\3\22\3\22\3\22\3\22\3\22\5\22\u0133\n\22\5\22\u0135\n\22\3\23\3\23"+ - "\3\23\3\23\3\23\5\23\u013c\n\23\3\23\3\23\3\23\5\23\u0141\n\23\3\23\3"+ - "\23\5\23\u0145\n\23\3\23\3\23\5\23\u0149\n\23\3\24\3\24\3\24\7\24\u014e"+ - "\n\24\f\24\16\24\u0151\13\24\3\25\3\25\3\25\3\25\5\25\u0157\n\25\3\26"+ - "\3\26\3\26\7\26\u015c\n\26\f\26\16\26\u015f\13\26\3\27\3\27\3\27\3\27"+ - "\3\27\3\27\3\27\5\27\u0168\n\27\3\30\3\30\5\30\u016c\n\30\3\30\3\30\3"+ - "\30\3\30\3\30\3\30\7\30\u0174\n\30\f\30\16\30\u0177\13\30\3\30\3\30\3"+ - "\30\3\31\3\31\3\31\3\31\7\31\u0180\n\31\f\31\16\31\u0183\13\31\3\32\3"+ - "\32\3\32\5\32\u0188\n\32\3\32\3\32\5\32\u018c\n\32\3\32\3\32\5\32\u0190"+ - "\n\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\7\33\u0199\n\33\f\33\16\33\u019c"+ - "\13\33\3\34\3\34\3\34\5\34\u01a1\n\34\3\34\3\34\3\34\3\35\3\35\3\35\3"+ - "\36\3\36\3\36\3\36\3\36\7\36\u01ae\n\36\f\36\16\36\u01b1\13\36\3\37\3"+ - "\37\3\37\5\37\u01b6\n\37\3\37\3\37\5\37\u01ba\n\37\3\37\3\37\5\37\u01be"+ - "\n\37\3 \3 \3 \3 \3 \5 \u01c5\n \3 \3 \3 \7 \u01ca\n \f \16 \u01cd\13"+ - " \3!\3!\3!\5!\u01d2\n!\3!\3!\3!\5!\u01d7\n!\5!\u01d9\n!\3!\3!\5!\u01dd"+ - "\n!\3\"\3\"\3\"\3#\3#\5#\u01e4\n#\3#\3#\3#\7#\u01e9\n#\f#\16#\u01ec\13"+ - "#\3#\3#\3#\3$\3$\3$\5$\u01f4\n$\3$\3$\3$\3%\3%\3%\3%\3%\6%\u01fe\n%\r"+ - "%\16%\u01ff\3%\3%\3%\3%\3&\3&\6&\u0208\n&\r&\16&\u0209\3&\3&\3&\3\'\3"+ - "\'\3\'\3\'\3\'\6\'\u0214\n\'\r\'\16\'\u0215\3\'\3\'\5\'\u021a\n\'\3\'"+ - "\3\'\3\'\3(\3(\3(\3(\5(\u0223\n(\3(\3(\3(\7(\u0228\n(\f(\16(\u022b\13"+ - "(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3)\3)\3)\3*\3*\3*\3*\3*\6*\u023e\n*\r*\16"+ - "*\u023f\3+\3+\3+\5+\u0245\n+\3+\3+\3+\5+\u024a\n+\7+\u024c\n+\f+\16+\u024f"+ - "\13+\3+\3+\3+\3+\3,\3,\3,\7,\u0258\n,\f,\16,\u025b\13,\3-\3-\3-\7-\u0260"+ - "\n-\f-\16-\u0263\13-\3.\5.\u0266\n.\3.\3.\3/\3/\3/\5/\u026d\n/\3\60\3"+ - "\60\3\60\7\60\u0272\n\60\f\60\16\60\u0275\13\60\3\61\3\61\3\61\5\61\u027a"+ - "\n\61\3\62\3\62\3\62\7\62\u027f\n\62\f\62\16\62\u0282\13\62\3\63\3\63"+ - "\3\63\7\63\u0287\n\63\f\63\16\63\u028a\13\63\3\64\3\64\3\64\3\64\5\64"+ - "\u0290\n\64\3\65\3\65\3\65\3\65\5\65\u0296\n\65\3\66\3\66\3\66\3\66\5"+ - "\66\u029c\n\66\3\67\3\67\3\67\3\67\5\67\u02a2\n\67\38\38\38\38\38\78\u02a9"+ - "\n8\f8\168\u02ac\138\39\79\u02af\n9\f9\169\u02b2\139\39\39\3:\3:\3:\7"+ - ":\u02b9\n:\f:\16:\u02bc\13:\3;\3;\3;\3;\3;\3;\7;\u02c4\n;\f;\16;\u02c7"+ - "\13;\3<\3<\3<\3<\3<\3<\3=\3=\3=\3>\3>\3>\3>\3?\3?\3?\3?\3?\3?\3?\5?\u02dd"+ - "\n?\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\5@\u02eb\n@\3A\3A\3A\3B\3B\5B"+ - "\u02f2\nB\3B\3B\3C\3C\3D\3D\3D\3D\3D\3E\3E\3E\3E\3E\3F\3F\3F\3G\3G\3G"+ - "\5G\u0308\nG\7G\u030a\nG\fG\16G\u030d\13G\3G\3G\3H\3H\5H\u0313\nH\3I\3"+ - "I\5I\u0317\nI\3J\3J\3J\3J\3K\3K\3K\5K\u0320\nK\3K\3K\3K\5K\u0325\nK\3"+ - "K\3K\5K\u0329\nK\3K\3K\3L\3L\3L\3L\3L\3L\5L\u0333\nL\5L\u0335\nL\3M\3"+ - "M\3M\3M\7M\u033b\nM\fM\16M\u033e\13M\5M\u0340\nM\3M\3M\3M\3M\3M\5M\u0347"+ - "\nM\3N\3N\5N\u034b\nN\3O\3O\5O\u034f\nO\3P\3P\5P\u0353\nP\3P\3P\3P\3Q"+ - "\3Q\5Q\u035a\nQ\3Q\3Q\3R\3R\3S\3S\3T\3T\3T\2\2U\2\4\6\b\n\f\16\20\22\24"+ - "\26\30\32\34\36 \"$&(*,.\60\62\64\668:<>@BDFHJLNPRTVXZ\\^`bdfhjlnprtv"+ - "xz|~\u0080\u0082\u0084\u0086\u0088\u008a\u008c\u008e\u0090\u0092\u0094"+ - "\u0096\u0098\u009a\u009c\u009e\u00a0\u00a2\u00a4\u00a6\2\13\3\2\t\n\3"+ - "\2RS\4\2iiqq\3\2\r\26\4\2\6\6$.\3\2\60\61\4\2##\62\64\4\2\f\fhh\4\2=f"+ - "ii\2\u038e\2\u00a8\3\2\2\2\4\u00b0\3\2\2\2\6\u00b6\3\2\2\2\b\u00b9\3\2"+ - "\2\2\n\u00ca\3\2\2\2\f\u00d9\3\2\2\2\16\u00db\3\2\2\2\20\u00e3\3\2\2\2"+ - "\22\u00e5\3\2\2\2\24\u00ea\3\2\2\2\26\u00ee\3\2\2\2\30\u00f4\3\2\2\2\32"+ - "\u0109\3\2\2\2\34\u010f\3\2\2\2\36\u0111\3\2\2\2 \u0113\3\2\2\2\"\u0126"+ - "\3\2\2\2$\u0136\3\2\2\2&\u014a\3\2\2\2(\u0152\3\2\2\2*\u0158\3\2\2\2,"+ - "\u0167\3\2\2\2.\u016b\3\2\2\2\60\u017b\3\2\2\2\62\u0184\3\2\2\2\64\u0194"+ - "\3\2\2\2\66\u019d\3\2\2\28\u01a5\3\2\2\2:\u01a8\3\2\2\2<\u01b2\3\2\2\2"+ - ">\u01c4\3\2\2\2@\u01ce\3\2\2\2B\u01de\3\2\2\2D\u01e3\3\2\2\2F\u01f0\3"+ - "\2\2\2H\u01f8\3\2\2\2J\u0207\3\2\2\2L\u020e\3\2\2\2N\u021e\3\2\2\2P\u022f"+ - "\3\2\2\2R\u0238\3\2\2\2T\u0241\3\2\2\2V\u0254\3\2\2\2X\u025c\3\2\2\2Z"+ - "\u0265\3\2\2\2\\\u0269\3\2\2\2^\u026e\3\2\2\2`\u0276\3\2\2\2b\u027b\3"+ - "\2\2\2d\u0283\3\2\2\2f\u028b\3\2\2\2h\u0291\3\2\2\2j\u0297\3\2\2\2l\u029d"+ - "\3\2\2\2n\u02a3\3\2\2\2p\u02b0\3\2\2\2r\u02b5\3\2\2\2t\u02bd\3\2\2\2v"+ - "\u02c8\3\2\2\2x\u02ce\3\2\2\2z\u02d1\3\2\2\2|\u02d5\3\2\2\2~\u02ea\3\2"+ - "\2\2\u0080\u02ec\3\2\2\2\u0082\u02ef\3\2\2\2\u0084\u02f5\3\2\2\2\u0086"+ - "\u02f7\3\2\2\2\u0088\u02fc\3\2\2\2\u008a\u0301\3\2\2\2\u008c\u0304\3\2"+ - "\2\2\u008e\u0312\3\2\2\2\u0090\u0316\3\2\2\2\u0092\u0318\3\2\2\2\u0094"+ - "\u031c\3\2\2\2\u0096\u0334\3\2\2\2\u0098\u0346\3\2\2\2\u009a\u034a\3\2"+ - "\2\2\u009c\u034c\3\2\2\2\u009e\u0352\3\2\2\2\u00a0\u0357\3\2\2\2\u00a2"+ - "\u035d\3\2\2\2\u00a4\u035f\3\2\2\2\u00a6\u0361\3\2\2\2\u00a8\u00a9\5\4"+ - "\3\2\u00a9\u00aa\7\2\2\3\u00aa\3\3\2\2\2\u00ab\u00ac\7f\2\2\u00ac\u00ad"+ - "\7e\2\2\u00ad\u00ae\5\u00a4S\2\u00ae\u00af\7\3\2\2\u00af\u00b1\3\2\2\2"+ - "\u00b0\u00ab\3\2\2\2\u00b0\u00b1\3\2\2\2\u00b1\u00b4\3\2\2\2\u00b2\u00b5"+ - "\5\b\5\2\u00b3\u00b5\5\6\4\2\u00b4\u00b2\3\2\2\2\u00b4\u00b3\3\2\2\2\u00b5"+ - "\5\3\2\2\2\u00b6\u00b7\5\n\6\2\u00b7\u00b8\5*\26\2\u00b8\7\3\2\2\2\u00b9"+ - "\u00ba\7\4\2\2\u00ba\u00bb\7\5\2\2\u00bb\u00bc\7q\2\2\u00bc\u00bd\7\6"+ - "\2\2\u00bd\u00be\5\u00a2R\2\u00be\u00bf\7\3\2\2\u00bf\u00c0\5\n\6\2\u00c0"+ - "\t\3\2\2\2\u00c1\u00c5\5\f\7\2\u00c2\u00c5\5\16\b\2\u00c3\u00c5\5 \21"+ - "\2\u00c4\u00c1\3\2\2\2\u00c4\u00c2\3\2\2\2\u00c4\u00c3\3\2\2\2\u00c5\u00c6"+ - "\3\2\2\2\u00c6\u00c7\7\3\2\2\u00c7\u00c9\3\2\2\2\u00c8\u00c4\3\2\2\2\u00c9"+ - "\u00cc\3\2\2\2\u00ca\u00c8\3\2\2\2\u00ca\u00cb\3\2\2\2\u00cb\u00d2\3\2"+ - "\2\2\u00cc\u00ca\3\2\2\2\u00cd\u00ce\5\20\t\2\u00ce\u00cf\7\3\2\2\u00cf"+ - "\u00d1\3\2\2\2\u00d0\u00cd\3\2\2\2\u00d1\u00d4\3\2\2\2\u00d2\u00d0\3\2"+ - "\2\2\u00d2\u00d3\3\2\2\2\u00d3\13\3\2\2\2\u00d4\u00d2\3\2\2\2\u00d5\u00da"+ - "\5\22\n\2\u00d6\u00da\5\24\13\2\u00d7\u00da\5\26\f\2\u00d8\u00da\5\30"+ - "\r\2\u00d9\u00d5\3\2\2\2\u00d9\u00d6\3\2\2\2\u00d9\u00d7\3\2\2\2\u00d9"+ - "\u00d8\3\2\2\2\u00da\r\3\2\2\2\u00db\u00dc\7\7\2\2\u00dc\u00dd\7\5\2\2"+ - "\u00dd\u00de\7q\2\2\u00de\u00df\7\6\2\2\u00df\u00e0\5\u00a2R\2\u00e0\17"+ - "\3\2\2\2\u00e1\u00e4\5$\23\2\u00e2\u00e4\5\"\22\2\u00e3\u00e1\3\2\2\2"+ - "\u00e3\u00e2\3\2\2\2\u00e4\21\3\2\2\2\u00e5\u00e6\7\7\2\2\u00e6\u00e7"+ - "\7X\2\2\u00e7\u00e8\7Q\2\2\u00e8\u00e9\5\u00a2R\2\u00e9\23\3\2\2\2\u00ea"+ - "\u00eb\7\7\2\2\u00eb\u00ec\7\b\2\2\u00ec\u00ed\t\2\2\2\u00ed\25\3\2\2"+ - "\2\u00ee\u00ef\7\7\2\2\u00ef\u00f0\7X\2\2\u00f0\u00f1\7B\2\2\u00f1\u00f2"+ - "\7I\2\2\u00f2\u00f3\t\3\2\2\u00f3\27\3\2\2\2\u00f4\u00f9\7\7\2\2\u00f5"+ - "\u00f6\7\13\2\2\u00f6\u00fa\5\32\16\2\u00f7\u00f8\7X\2\2\u00f8\u00fa\7"+ - "\13\2\2\u00f9\u00f5\3\2\2\2\u00f9\u00f7\3\2\2\2\u00fa\u0101\3\2\2\2\u00fb"+ - "\u00fc\5\36\20\2\u00fc\u00fd\7\6\2\2\u00fd\u00fe\5\u00a4S\2\u00fe\u0100"+ - "\3\2\2\2\u00ff\u00fb\3\2\2\2\u0100\u0103\3\2\2\2\u0101\u00ff\3\2\2\2\u0101"+ - "\u0102\3\2\2\2\u0102\31\3\2\2\2\u0103\u0101\3\2\2\2\u0104\u0107\7q\2\2"+ - "\u0105\u0107\5\u00a6T\2\u0106\u0104\3\2\2\2\u0106\u0105\3\2\2\2\u0107"+ - "\u0108\3\2\2\2\u0108\u010a\7\f\2\2\u0109\u0106\3\2\2\2\u0109\u010a\3\2"+ - "\2\2\u010a\u010d\3\2\2\2\u010b\u010e\5\34\17\2\u010c\u010e\5\u00a6T\2"+ - "\u010d\u010b\3\2\2\2\u010d\u010c\3\2\2\2\u010e\33\3\2\2\2\u010f\u0110"+ - "\t\4\2\2\u0110\35\3\2\2\2\u0111\u0112\t\5\2\2\u0112\37\3\2\2\2\u0113\u0114"+ - "\7\27\2\2\u0114\u0118\7\4\2\2\u0115\u0116\7\5\2\2\u0116\u0117\7q\2\2\u0117"+ - "\u0119\7\6\2\2\u0118\u0115\3\2\2\2\u0118\u0119\3\2\2\2\u0119\u011a\3\2"+ - "\2\2\u011a\u0124\5\u00a2R\2\u011b\u011c\7G\2\2\u011c\u0121\5\u00a2R\2"+ - "\u011d\u011e\7\30\2\2\u011e\u0120\5\u00a2R\2\u011f\u011d\3\2\2\2\u0120"+ - "\u0123\3\2\2\2\u0121\u011f\3\2\2\2\u0121\u0122\3\2\2\2\u0122\u0125\3\2"+ - "\2\2\u0123\u0121\3\2\2\2\u0124\u011b\3\2\2\2\u0124\u0125\3\2\2\2\u0125"+ - "!\3\2\2\2\u0126\u0127\7\7\2\2\u0127\u0128\7\31\2\2\u0128\u012b\5\u0080"+ - "A\2\u0129\u012a\7F\2\2\u012a\u012c\5\u0096L\2\u012b\u0129\3\2\2\2\u012b"+ - "\u012c\3\2\2\2\u012c\u0134\3\2\2\2\u012d\u012e\7\32\2\2\u012e\u0135\5"+ - ",\27\2\u012f\u0132\7\33\2\2\u0130\u0131\7\32\2\2\u0131\u0133\5,\27\2\u0132"+ - "\u0130\3\2\2\2\u0132\u0133\3\2\2\2\u0133\u0135\3\2\2\2\u0134\u012d\3\2"+ - "\2\2\u0134\u012f\3\2\2\2\u0135#\3\2\2\2\u0136\u0137\7\7\2\2\u0137\u0138"+ - "\7\34\2\2\u0138\u0139\5\32\16\2\u0139\u013b\7\35\2\2\u013a\u013c\5&\24"+ - "\2\u013b\u013a\3\2\2\2\u013b\u013c\3\2\2\2\u013c\u013d\3\2\2\2\u013d\u0140"+ - "\7\36\2\2\u013e\u013f\7F\2\2\u013f\u0141\5\u0096L\2\u0140\u013e\3\2\2"+ - "\2\u0140\u0141\3\2\2\2\u0141\u0148\3\2\2\2\u0142\u0144\7\37\2\2\u0143"+ - "\u0145\5*\26\2\u0144\u0143\3\2\2\2\u0144\u0145\3\2\2\2\u0145\u0146\3\2"+ - "\2\2\u0146\u0149\7 \2\2\u0147\u0149\7\33\2\2\u0148\u0142\3\2\2\2\u0148"+ - "\u0147\3\2\2\2\u0149%\3\2\2\2\u014a\u014f\5(\25\2\u014b\u014c\7\30\2\2"+ - "\u014c\u014e\5(\25\2\u014d\u014b\3\2\2\2\u014e\u0151\3\2\2\2\u014f\u014d"+ - "\3\2\2\2\u014f\u0150\3\2\2\2\u0150\'\3\2\2\2\u0151\u014f\3\2\2\2\u0152"+ - "\u0153\7!\2\2\u0153\u0156\5\32\16\2\u0154\u0155\7F\2\2\u0155\u0157\5\u0096"+ - "L\2\u0156\u0154\3\2\2\2\u0156\u0157\3\2\2\2\u0157)\3\2\2\2\u0158\u015d"+ - "\5,\27\2\u0159\u015a\7\30\2\2\u015a\u015c\5,\27\2\u015b\u0159\3\2\2\2"+ - "\u015c\u015f\3\2\2\2\u015d\u015b\3\2\2\2\u015d\u015e\3\2\2\2\u015e+\3"+ - "\2\2\2\u015f\u015d\3\2\2\2\u0160\u0168\5.\30\2\u0161\u0168\5D#\2\u0162"+ - "\u0168\5H%\2\u0163\u0168\5L\'\2\u0164\u0168\5P)\2\u0165\u0168\5R*\2\u0166"+ - "\u0168\5V,\2\u0167\u0160\3\2\2\2\u0167\u0161\3\2\2\2\u0167\u0162\3\2\2"+ - "\2\u0167\u0163\3\2\2\2\u0167\u0164\3\2\2\2\u0167\u0165\3\2\2\2\u0167\u0166"+ - "\3\2\2\2\u0168-\3\2\2\2\u0169\u016c\5\60\31\2\u016a\u016c\5\64\33\2\u016b"+ - "\u0169\3\2\2\2\u016b\u016a\3\2\2\2\u016c\u0175\3\2\2\2\u016d\u0174\5\60"+ - "\31\2\u016e\u0174\58\35\2\u016f\u0174\5\64\33\2\u0170\u0174\5:\36\2\u0171"+ - "\u0174\5> \2\u0172\u0174\5B\"\2\u0173\u016d\3\2\2\2\u0173\u016e\3\2\2"+ - "\2\u0173\u016f\3\2\2\2\u0173\u0170\3\2\2\2\u0173\u0171\3\2\2\2\u0173\u0172"+ - "\3\2\2\2\u0174\u0177\3\2\2\2\u0175\u0173\3\2\2\2\u0175\u0176\3\2\2\2\u0176"+ - "\u0178\3\2\2\2\u0177\u0175\3\2\2\2\u0178\u0179\7C\2\2\u0179\u017a\5,\27"+ - "\2\u017a/\3\2\2\2\u017b\u017c\7=\2\2\u017c\u0181\5\62\32\2\u017d\u017e"+ - "\7\30\2\2\u017e\u0180\5\62\32\2\u017f\u017d\3\2\2\2\u0180\u0183\3\2\2"+ - "\2\u0181\u017f\3\2\2\2\u0181\u0182\3\2\2\2\u0182\61\3\2\2\2\u0183\u0181"+ - "\3\2\2\2\u0184\u0187\5\u0080A\2\u0185\u0186\7F\2\2\u0186\u0188\5\u0096"+ - "L\2\u0187\u0185\3\2\2\2\u0187\u0188\3\2\2\2\u0188\u018b\3\2\2\2\u0189"+ - "\u018a\7H\2\2\u018a\u018c\7I\2\2\u018b\u0189\3\2\2\2\u018b\u018c\3\2\2"+ - "\2\u018c\u018f\3\2\2\2\u018d\u018e\7G\2\2\u018e\u0190\5\u0080A\2\u018f"+ - "\u018d\3\2\2\2\u018f\u0190\3\2\2\2\u0190\u0191\3\2\2\2\u0191\u0192\7E"+ - "\2\2\u0192\u0193\5,\27\2\u0193\63\3\2\2\2\u0194\u0195\7>\2\2\u0195\u019a"+ - "\5\66\34\2\u0196\u0197\7\30\2\2\u0197\u0199\5\66\34\2\u0198\u0196\3\2"+ - "\2\2\u0199\u019c\3\2\2\2\u019a\u0198\3\2\2\2\u019a\u019b\3\2\2\2\u019b"+ - "\65\3\2\2\2\u019c\u019a\3\2\2\2\u019d\u01a0\5\u0080A\2\u019e\u019f\7F"+ - "\2\2\u019f\u01a1\5\u0096L\2\u01a0\u019e\3\2\2\2\u01a0\u01a1\3\2\2\2\u01a1"+ - "\u01a2\3\2\2\2\u01a2\u01a3\7\32\2\2\u01a3\u01a4\5,\27\2\u01a4\67\3\2\2"+ - "\2\u01a5\u01a6\7?\2\2\u01a6\u01a7\5,\27\2\u01a79\3\2\2\2\u01a8\u01a9\7"+ - "@\2\2\u01a9\u01aa\7A\2\2\u01aa\u01af\5<\37\2\u01ab\u01ac\7\30\2\2\u01ac"+ - "\u01ae\5<\37\2\u01ad\u01ab\3\2\2\2\u01ae\u01b1\3\2\2\2\u01af\u01ad\3\2"+ - "\2\2\u01af\u01b0\3\2\2\2\u01b0;\3\2\2\2\u01b1\u01af\3\2\2\2\u01b2\u01b9"+ - "\5\u0080A\2\u01b3\u01b4\7F\2\2\u01b4\u01b6\5\u0096L\2\u01b5\u01b3\3\2"+ - "\2\2\u01b5\u01b6\3\2\2\2\u01b6\u01b7\3\2\2\2\u01b7\u01b8\7\32\2\2\u01b8"+ - "\u01ba\5,\27\2\u01b9\u01b5\3\2\2\2\u01b9\u01ba\3\2\2\2\u01ba\u01bd\3\2"+ - "\2\2\u01bb\u01bc\7Q\2\2\u01bc\u01be\5\u00a2R\2\u01bd\u01bb\3\2\2\2\u01bd"+ - "\u01be\3\2\2\2\u01be=\3\2\2\2\u01bf\u01c0\7B\2\2\u01c0\u01c5\7A\2\2\u01c1"+ - "\u01c2\7K\2\2\u01c2\u01c3\7B\2\2\u01c3\u01c5\7A\2\2\u01c4\u01bf\3\2\2"+ - "\2\u01c4\u01c1\3\2\2\2\u01c5\u01c6\3\2\2\2\u01c6\u01cb\5@!\2\u01c7\u01c8"+ - "\7\30\2\2\u01c8\u01ca\5@!\2\u01c9\u01c7\3\2\2\2\u01ca\u01cd\3\2\2\2\u01cb"+ - "\u01c9\3\2\2\2\u01cb\u01cc\3\2\2\2\u01cc?\3\2\2\2\u01cd\u01cb\3\2\2\2"+ - "\u01ce\u01d1\5,\27\2\u01cf\u01d2\7L\2\2\u01d0\u01d2\7M\2\2\u01d1\u01cf"+ - "\3\2\2\2\u01d1\u01d0\3\2\2\2\u01d1\u01d2\3\2\2\2\u01d2\u01d8\3\2\2\2\u01d3"+ - "\u01d6\7I\2\2\u01d4\u01d7\7R\2\2\u01d5\u01d7\7S\2\2\u01d6\u01d4\3\2\2"+ - "\2\u01d6\u01d5\3\2\2\2\u01d7\u01d9\3\2\2\2\u01d8\u01d3\3\2\2\2\u01d8\u01d9"+ - "\3\2\2\2\u01d9\u01dc\3\2\2\2\u01da\u01db\7Q\2\2\u01db\u01dd\5\u00a2R\2"+ - "\u01dc\u01da\3\2\2\2\u01dc\u01dd\3\2\2\2\u01ddA\3\2\2\2\u01de\u01df\7"+ - "J\2\2\u01df\u01e0\5\u0080A\2\u01e0C\3\2\2\2\u01e1\u01e4\7N\2\2\u01e2\u01e4"+ - "\7O\2\2\u01e3\u01e1\3\2\2\2\u01e3\u01e2\3\2\2\2\u01e4\u01e5\3\2\2\2\u01e5"+ - "\u01ea\5F$\2\u01e6\u01e7\7\30\2\2\u01e7\u01e9\5F$\2\u01e8\u01e6\3\2\2"+ - "\2\u01e9\u01ec\3\2\2\2\u01ea\u01e8\3\2\2\2\u01ea\u01eb\3\2\2\2\u01eb\u01ed"+ - "\3\2\2\2\u01ec\u01ea\3\2\2\2\u01ed\u01ee\7P\2\2\u01ee\u01ef\5,\27\2\u01ef"+ - "E\3\2\2\2\u01f0\u01f3\5\u0080A\2\u01f1\u01f2\7F\2\2\u01f2\u01f4\5\u0096"+ - "L\2\u01f3\u01f1\3\2\2\2\u01f3\u01f4\3\2\2\2\u01f4\u01f5\3\2\2\2\u01f5"+ - "\u01f6\7E\2\2\u01f6\u01f7\5,\27\2\u01f7G\3\2\2\2\u01f8\u01f9\7T\2\2\u01f9"+ - "\u01fa\7\35\2\2\u01fa\u01fb\5*\26\2\u01fb\u01fd\7\36\2\2\u01fc\u01fe\5"+ - "J&\2\u01fd\u01fc\3\2\2\2\u01fe\u01ff\3\2\2\2\u01ff\u01fd\3\2\2\2\u01ff"+ - "\u0200\3\2\2\2\u0200\u0201\3\2\2\2\u0201\u0202\7X\2\2\u0202\u0203\7C\2"+ - "\2\u0203\u0204\5,\27\2\u0204I\3\2\2\2\u0205\u0206\7U\2\2\u0206\u0208\5"+ - ",\27\2\u0207\u0205\3\2\2\2\u0208\u0209\3\2\2\2\u0209\u0207\3\2\2\2\u0209"+ - "\u020a\3\2\2\2\u020a\u020b\3\2\2\2\u020b\u020c\7C\2\2\u020c\u020d\5,\27"+ - "\2\u020dK\3\2\2\2\u020e\u020f\7[\2\2\u020f\u0210\7\35\2\2\u0210\u0211"+ - "\5*\26\2\u0211\u0213\7\36\2\2\u0212\u0214\5N(\2\u0213\u0212\3\2\2\2\u0214"+ - "\u0215\3\2\2\2\u0215\u0213\3\2\2\2\u0215\u0216\3\2\2\2\u0216\u0217\3\2"+ - "\2\2\u0217\u0219\7X\2\2\u0218\u021a\5\u0080A\2\u0219\u0218\3\2\2\2\u0219"+ - "\u021a\3\2\2\2\u021a\u021b\3\2\2\2\u021b\u021c\7C\2\2\u021c\u021d\5,\27"+ - "\2\u021dM\3\2\2\2\u021e\u0222\7U\2\2\u021f\u0220\5\u0080A\2\u0220\u0221"+ - "\7F\2\2\u0221\u0223\3\2\2\2\u0222\u021f\3\2\2\2\u0222\u0223\3\2\2\2\u0223"+ - "\u0224\3\2\2\2\u0224\u0229\5\u0096L\2\u0225\u0226\7\"\2\2\u0226\u0228"+ - "\5\u0096L\2\u0227\u0225\3\2\2\2\u0228\u022b\3\2\2\2\u0229\u0227\3\2\2"+ - "\2\u0229\u022a\3\2\2\2\u022a\u022c\3\2\2\2\u022b\u0229\3\2\2\2\u022c\u022d"+ - "\7C\2\2\u022d\u022e\5,\27\2\u022eO\3\2\2\2\u022f\u0230\7D\2\2\u0230\u0231"+ - "\7\35\2\2\u0231\u0232\5*\26\2\u0232\u0233\7\36\2\2\u0233\u0234\7Y\2\2"+ - "\u0234\u0235\5,\27\2\u0235\u0236\7Z\2\2\u0236\u0237\5,\27\2\u0237Q\3\2"+ - "\2\2\u0238\u0239\7V\2\2\u0239\u023a\7\37\2\2\u023a\u023b\5*\26\2\u023b"+ - "\u023d\7 \2\2\u023c\u023e\5T+\2\u023d\u023c\3\2\2\2\u023e\u023f\3\2\2"+ - "\2\u023f\u023d\3\2\2\2\u023f\u0240\3\2\2\2\u0240S\3\2\2\2\u0241\u0244"+ - "\7W\2\2\u0242\u0245\7#\2\2\u0243\u0245\5\32\16\2\u0244\u0242\3\2\2\2\u0244"+ - "\u0243\3\2\2\2\u0245\u024d\3\2\2\2\u0246\u0249\7\"\2\2\u0247\u024a\7#"+ - "\2\2\u0248\u024a\5\32\16\2\u0249\u0247\3\2\2\2\u0249\u0248\3\2\2\2\u024a"+ - "\u024c\3\2\2\2\u024b\u0246\3\2\2\2\u024c\u024f\3\2\2\2\u024d\u024b\3\2"+ - "\2\2\u024d\u024e\3\2\2\2\u024e\u0250\3\2\2\2\u024f\u024d\3\2\2\2\u0250"+ - "\u0251\7\37\2\2\u0251\u0252\5*\26\2\u0252\u0253\7 \2\2\u0253U\3\2\2\2"+ - "\u0254\u0259\5X-\2\u0255\u0256\7\\\2\2\u0256\u0258\5X-\2\u0257\u0255\3"+ - "\2\2\2\u0258\u025b\3\2\2\2\u0259\u0257\3\2\2\2\u0259\u025a\3\2\2\2\u025a"+ - "W\3\2\2\2\u025b\u0259\3\2\2\2\u025c\u0261\5Z.\2\u025d\u025e\7]\2\2\u025e"+ - "\u0260\5Z.\2\u025f\u025d\3\2\2\2\u0260\u0263\3\2\2\2\u0261\u025f\3\2\2"+ - "\2\u0261\u0262\3\2\2\2\u0262Y\3\2\2\2\u0263\u0261\3\2\2\2\u0264\u0266"+ - "\7^\2\2\u0265\u0264\3\2\2\2\u0265\u0266\3\2\2\2\u0266\u0267\3\2\2\2\u0267"+ - "\u0268\5\\/\2\u0268[\3\2\2\2\u0269\u026c\5^\60\2\u026a\u026b\t\6\2\2\u026b"+ - "\u026d\5^\60\2\u026c\u026a\3\2\2\2\u026c\u026d\3\2\2\2\u026d]\3\2\2\2"+ - "\u026e\u0273\5`\61\2\u026f\u0270\7/\2\2\u0270\u0272\5`\61\2\u0271\u026f"+ - "\3\2\2\2\u0272\u0275\3\2\2\2\u0273\u0271\3\2\2\2\u0273\u0274\3\2\2\2\u0274"+ - "_\3\2\2\2\u0275\u0273\3\2\2\2\u0276\u0279\5b\62\2\u0277\u0278\7_\2\2\u0278"+ - "\u027a\5b\62\2\u0279\u0277\3\2\2\2\u0279\u027a\3\2\2\2\u027aa\3\2\2\2"+ - "\u027b\u0280\5d\63\2\u027c\u027d\t\7\2\2\u027d\u027f\5d\63\2\u027e\u027c"+ - "\3\2\2\2\u027f\u0282\3\2\2\2\u0280\u027e\3\2\2\2\u0280\u0281\3\2\2\2\u0281"+ - "c\3\2\2\2\u0282\u0280\3\2\2\2\u0283\u0288\5f\64\2\u0284\u0285\t\b\2\2"+ - "\u0285\u0287\5f\64\2\u0286\u0284\3\2\2\2\u0287\u028a\3\2\2\2\u0288\u0286"+ - "\3\2\2\2\u0288\u0289\3\2\2\2\u0289e\3\2\2\2\u028a\u0288\3\2\2\2\u028b"+ - "\u028f\5h\65\2\u028c\u028d\7`\2\2\u028d\u028e\7a\2\2\u028e\u0290\5\u0096"+ - "L\2\u028f\u028c\3\2\2\2\u028f\u0290\3\2\2\2\u0290g\3\2\2\2\u0291\u0295"+ - "\5j\66\2\u0292\u0293\7b\2\2\u0293\u0294\7F\2\2\u0294\u0296\5\u0096L\2"+ - "\u0295\u0292\3\2\2\2\u0295\u0296\3\2\2\2\u0296i\3\2\2\2\u0297\u029b\5"+ - "l\67\2\u0298\u0299\7d\2\2\u0299\u029a\7F\2\2\u029a\u029c\5\u009cO\2\u029b"+ - "\u0298\3\2\2\2\u029b\u029c\3\2\2\2\u029ck\3\2\2\2\u029d\u02a1\5n8\2\u029e"+ - "\u029f\7c\2\2\u029f\u02a0\7F\2\2\u02a0\u02a2\5\u009cO\2\u02a1\u029e\3"+ - "\2\2\2\u02a1\u02a2\3\2\2\2\u02a2m\3\2\2\2\u02a3\u02aa\5p9\2\u02a4\u02a5"+ - "\7\6\2\2\u02a5\u02a6\7-\2\2\u02a6\u02a7\3\2\2\2\u02a7\u02a9\5\u008aF\2"+ - "\u02a8\u02a4\3\2\2\2\u02a9\u02ac\3\2\2\2\u02aa\u02a8\3\2\2\2\u02aa\u02ab"+ - "\3\2\2\2\u02abo\3\2\2\2\u02ac\u02aa\3\2\2\2\u02ad\u02af\t\7\2\2\u02ae"+ - "\u02ad\3\2\2\2\u02af\u02b2\3\2\2\2\u02b0\u02ae\3\2\2\2\u02b0\u02b1\3\2"+ - "\2\2\u02b1\u02b3\3\2\2\2\u02b2\u02b0\3\2\2\2\u02b3\u02b4\5r:\2\u02b4q"+ - "\3\2\2\2\u02b5\u02ba\5t;\2\u02b6\u02b7\7\65\2\2\u02b7\u02b9\5t;\2\u02b8"+ - "\u02b6\3\2\2\2\u02b9\u02bc\3\2\2\2\u02ba\u02b8\3\2\2\2\u02ba\u02bb\3\2"+ - "\2\2\u02bbs\3\2\2\2\u02bc\u02ba\3\2\2\2\u02bd\u02c5\5~@\2\u02be\u02c4"+ - "\5v<\2\u02bf\u02c4\5z>\2\u02c0\u02c4\5|?\2\u02c1\u02c4\5x=\2\u02c2\u02c4"+ - "\5\u008cG\2\u02c3\u02be\3\2\2\2\u02c3\u02bf\3\2\2\2\u02c3\u02c0\3\2\2"+ - "\2\u02c3\u02c1\3\2\2\2\u02c3\u02c2\3\2\2\2\u02c4\u02c7\3\2\2\2\u02c5\u02c3"+ - "\3\2\2\2\u02c5\u02c6\3\2\2\2\u02c6u\3\2\2\2\u02c7\u02c5\3\2\2\2\u02c8"+ - "\u02c9\7\66\2\2\u02c9\u02ca\7\66\2\2\u02ca\u02cb\5*\26\2\u02cb\u02cc\7"+ - "\67\2\2\u02cc\u02cd\7\67\2\2\u02cdw\3\2\2\2\u02ce\u02cf\7\66\2\2\u02cf"+ - "\u02d0\7\67\2\2\u02d0y\3\2\2\2\u02d1\u02d2\7\66\2\2\u02d2\u02d3\5*\26"+ - "\2\u02d3\u02d4\7\67\2\2\u02d4{\3\2\2\2\u02d5\u02dc\78\2\2\u02d6\u02dd"+ - "\5\u00a6T\2\u02d7\u02dd\5\u00a4S\2\u02d8\u02dd\7q\2\2\u02d9\u02dd\5\u0082"+ - "B\2\u02da\u02dd\5\u0080A\2\u02db\u02dd\5\u0084C\2\u02dc\u02d6\3\2\2\2"+ - "\u02dc\u02d7\3\2\2\2\u02dc\u02d8\3\2\2\2\u02dc\u02d9\3\2\2\2\u02dc\u02da"+ - "\3\2\2\2\u02dc\u02db\3\2\2\2\u02dd}\3\2\2\2\u02de\u02eb\7i\2\2\u02df\u02eb"+ - "\7j\2\2\u02e0\u02eb\5\u00a4S\2\u02e1\u02eb\5\u0080A\2\u02e2\u02eb\5\u0082"+ - "B\2\u02e3\u02eb\5\u0084C\2\u02e4\u02eb\5\u0098M\2\u02e5\u02eb\5\u008a"+ - "F\2\u02e6\u02eb\5\u0086D\2\u02e7\u02eb\5\u0088E\2\u02e8\u02eb\5\u00a0"+ - "Q\2\u02e9\u02eb\5\u0090I\2\u02ea\u02de\3\2\2\2\u02ea\u02df\3\2\2\2\u02ea"+ - "\u02e0\3\2\2\2\u02ea\u02e1\3\2\2\2\u02ea\u02e2\3\2\2\2\u02ea\u02e3\3\2"+ - "\2\2\u02ea\u02e4\3\2\2\2\u02ea\u02e5\3\2\2\2\u02ea\u02e6\3\2\2\2\u02ea"+ - "\u02e7\3\2\2\2\u02ea\u02e8\3\2\2\2\u02ea\u02e9\3\2\2\2\u02eb\177\3\2\2"+ - "\2\u02ec\u02ed\7!\2\2\u02ed\u02ee\5\32\16\2\u02ee\u0081\3\2\2\2\u02ef"+ - "\u02f1\7\35\2\2\u02f0\u02f2\5*\26\2\u02f1\u02f0\3\2\2\2\u02f1\u02f2\3"+ - "\2\2\2\u02f2\u02f3\3\2\2\2\u02f3\u02f4\7\36\2\2\u02f4\u0083\3\2\2\2\u02f5"+ - "\u02f6\79\2\2\u02f6\u0085\3\2\2\2\u02f7\u02f8\7\t\2\2\u02f8\u02f9\7\37"+ - "\2\2\u02f9\u02fa\5*\26\2\u02fa\u02fb\7 \2\2\u02fb\u0087\3\2\2\2\u02fc"+ - "\u02fd\7\n\2\2\u02fd\u02fe\7\37\2\2\u02fe\u02ff\5*\26\2\u02ff\u0300\7"+ - " \2\2\u0300\u0089\3\2\2\2\u0301\u0302\5\32\16\2\u0302\u0303\5\u008cG\2"+ - "\u0303\u008b\3\2\2\2\u0304\u030b\7\35\2\2\u0305\u0307\5\u008eH\2\u0306"+ - "\u0308\7\30\2\2\u0307\u0306\3\2\2\2\u0307\u0308\3\2\2\2\u0308\u030a\3"+ - "\2\2\2\u0309\u0305\3\2\2\2\u030a\u030d\3\2\2\2\u030b\u0309\3\2\2\2\u030b"+ - "\u030c\3\2\2\2\u030c\u030e\3\2\2\2\u030d\u030b\3\2\2\2\u030e\u030f\7\36"+ - "\2\2\u030f\u008d\3\2\2\2\u0310\u0313\5,\27\2\u0311\u0313\7h\2\2\u0312"+ - "\u0310\3\2\2\2\u0312\u0311\3\2\2\2\u0313\u008f\3\2\2\2\u0314\u0317\5\u0092"+ - "J\2\u0315\u0317\5\u0094K\2\u0316\u0314\3\2\2\2\u0316\u0315\3\2\2\2\u0317"+ - "\u0091\3\2\2\2\u0318\u0319\5\32\16\2\u0319\u031a\7:\2\2\u031a\u031b\7"+ - "j\2\2\u031b\u0093\3\2\2\2\u031c\u031d\7\34\2\2\u031d\u031f\7\35\2\2\u031e"+ - "\u0320\5&\24\2\u031f\u031e\3\2\2\2\u031f\u0320\3\2\2\2\u0320\u0321\3\2"+ - "\2\2\u0321\u0324\7\36\2\2\u0322\u0323\7F\2\2\u0323\u0325\5\u0096L\2\u0324"+ - "\u0322\3\2\2\2\u0324\u0325\3\2\2\2\u0325\u0326\3\2\2\2\u0326\u0328\7\37"+ - "\2\2\u0327\u0329\5*\26\2\u0328\u0327\3\2\2\2\u0328\u0329\3\2\2\2\u0329"+ - "\u032a\3\2\2\2\u032a\u032b\7 \2\2\u032b\u0095\3\2\2\2\u032c\u032d\7\35"+ - "\2\2\u032d\u0335\7\36\2\2\u032e\u0332\5\u009aN\2\u032f\u0333\7h\2\2\u0330"+ - "\u0333\7#\2\2\u0331\u0333\7\60\2\2\u0332\u032f\3\2\2\2\u0332\u0330\3\2"+ - "\2\2\u0332\u0331\3\2\2\2\u0332\u0333\3\2\2\2\u0333\u0335\3\2\2\2\u0334"+ - "\u032c\3\2\2\2\u0334\u032e\3\2\2\2\u0335\u0097\3\2\2\2\u0336\u033f\7\37"+ - "\2\2\u0337\u033c\5\u009eP\2\u0338\u0339\7\30\2\2\u0339\u033b\5\u009eP"+ - "\2\u033a\u0338\3\2\2\2\u033b\u033e\3\2\2\2\u033c\u033a\3\2\2\2\u033c\u033d"+ - "\3\2\2\2\u033d\u0340\3\2\2\2\u033e\u033c\3\2\2\2\u033f\u0337\3\2\2\2\u033f"+ - "\u0340\3\2\2\2\u0340\u0341\3\2\2\2\u0341\u0347\7 \2\2\u0342\u0343\7;\2"+ - "\2\u0343\u0344\5*\26\2\u0344\u0345\7<\2\2\u0345\u0347\3\2\2\2\u0346\u0336"+ - "\3\2\2\2\u0346\u0342\3\2\2\2\u0347\u0099\3\2\2\2\u0348\u034b\5\32\16\2"+ - "\u0349\u034b\7i\2\2\u034a\u0348\3\2\2\2\u034a\u0349\3\2\2\2\u034b\u009b"+ - "\3\2\2\2\u034c\u034e\5\u009aN\2\u034d\u034f\7h\2\2\u034e\u034d\3\2\2\2"+ - "\u034e\u034f\3\2\2\2\u034f\u009d\3\2\2\2\u0350\u0353\5,\27\2\u0351\u0353"+ - "\7q\2\2\u0352\u0350\3\2\2\2\u0352\u0351\3\2\2\2\u0353\u0354\3\2\2\2\u0354"+ - "\u0355\t\t\2\2\u0355\u0356\5,\27\2\u0356\u009f\3\2\2\2\u0357\u0359\7\66"+ - "\2\2\u0358\u035a\5*\26\2\u0359\u0358\3\2\2\2\u0359\u035a\3\2\2\2\u035a"+ - "\u035b\3\2\2\2\u035b\u035c\7\67\2\2\u035c\u00a1\3\2\2\2\u035d\u035e\5"+ - "\u00a4S\2\u035e\u00a3\3\2\2\2\u035f\u0360\7g\2\2\u0360\u00a5\3\2\2\2\u0361"+ - "\u0362\t\n\2\2\u0362\u00a7\3\2\2\2`\u00b0\u00b4\u00c4\u00ca\u00d2\u00d9"+ - "\u00e3\u00f9\u0101\u0106\u0109\u010d\u0118\u0121\u0124\u012b\u0132\u0134"+ - "\u013b\u0140\u0144\u0148\u014f\u0156\u015d\u0167\u016b\u0173\u0175\u0181"+ - "\u0187\u018b\u018f\u019a\u01a0\u01af\u01b5\u01b9\u01bd\u01c4\u01cb\u01d1"+ - "\u01d6\u01d8\u01dc\u01e3\u01ea\u01f3\u01ff\u0209\u0215\u0219\u0222\u0229"+ - "\u023f\u0244\u0249\u024d\u0259\u0261\u0265\u026c\u0273\u0279\u0280\u0288"+ - "\u028f\u0295\u029b\u02a1\u02aa\u02b0\u02ba\u02c3\u02c5\u02dc\u02ea\u02f1"+ - "\u0307\u030b\u0312\u0316\u031f\u0324\u0328\u0332\u0334\u033c\u033f\u0346"+ - "\u034a\u034e\u0352\u0359"; + "\4U\tU\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\5\3\u00b3\n\3\3\3\3\3\5\3\u00b7"+ + "\n\3\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\5\6\u00c7"+ + "\n\6\3\6\3\6\7\6\u00cb\n\6\f\6\16\6\u00ce\13\6\3\6\3\6\3\6\7\6\u00d3\n"+ + "\6\f\6\16\6\u00d6\13\6\3\7\3\7\3\7\3\7\5\7\u00dc\n\7\3\b\3\b\3\b\3\b\3"+ + "\b\3\b\3\t\3\t\5\t\u00e6\n\t\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3"+ + "\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\5\r\u00fc\n\r\3\r\3\r\3\r\3"+ + "\r\7\r\u0102\n\r\f\r\16\r\u0105\13\r\3\16\3\16\5\16\u0109\n\16\3\16\5"+ + "\16\u010c\n\16\3\16\3\16\5\16\u0110\n\16\3\17\3\17\3\20\3\20\3\21\3\21"+ + "\3\21\3\21\3\21\5\21\u011b\n\21\3\21\3\21\3\21\3\21\3\21\7\21\u0122\n"+ + "\21\f\21\16\21\u0125\13\21\5\21\u0127\n\21\3\22\3\22\3\22\3\22\3\22\5"+ + "\22\u012e\n\22\3\22\3\22\3\22\3\22\3\22\5\22\u0135\n\22\5\22\u0137\n\22"+ + "\3\23\3\23\3\23\3\23\3\23\5\23\u013e\n\23\3\23\3\23\3\23\5\23\u0143\n"+ + "\23\3\23\3\23\5\23\u0147\n\23\3\23\3\23\5\23\u014b\n\23\3\24\3\24\3\24"+ + "\7\24\u0150\n\24\f\24\16\24\u0153\13\24\3\25\3\25\3\25\3\25\5\25\u0159"+ + "\n\25\3\26\3\26\3\26\7\26\u015e\n\26\f\26\16\26\u0161\13\26\3\27\3\27"+ + "\3\27\3\27\3\27\3\27\3\27\5\27\u016a\n\27\3\30\3\30\5\30\u016e\n\30\3"+ + "\30\3\30\3\30\3\30\3\30\3\30\7\30\u0176\n\30\f\30\16\30\u0179\13\30\3"+ + "\30\3\30\3\30\3\31\3\31\3\31\3\31\7\31\u0182\n\31\f\31\16\31\u0185\13"+ + "\31\3\32\3\32\3\32\5\32\u018a\n\32\3\32\3\32\5\32\u018e\n\32\3\32\3\32"+ + "\5\32\u0192\n\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\7\33\u019b\n\33\f"+ + "\33\16\33\u019e\13\33\3\34\3\34\3\34\5\34\u01a3\n\34\3\34\3\34\3\34\3"+ + "\35\3\35\3\35\3\36\3\36\3\36\3\36\3\36\7\36\u01b0\n\36\f\36\16\36\u01b3"+ + "\13\36\3\37\3\37\3\37\5\37\u01b8\n\37\3\37\3\37\5\37\u01bc\n\37\3\37\3"+ + "\37\5\37\u01c0\n\37\3 \3 \3 \3 \3 \5 \u01c7\n \3 \3 \3 \7 \u01cc\n \f"+ + " \16 \u01cf\13 \3!\3!\3!\5!\u01d4\n!\3!\3!\3!\5!\u01d9\n!\5!\u01db\n!"+ + "\3!\3!\5!\u01df\n!\3\"\3\"\3\"\3#\3#\5#\u01e6\n#\3#\3#\3#\7#\u01eb\n#"+ + "\f#\16#\u01ee\13#\3#\3#\3#\3$\3$\3$\5$\u01f6\n$\3$\3$\3$\3%\3%\3%\3%\3"+ + "%\6%\u0200\n%\r%\16%\u0201\3%\3%\3%\3%\3&\3&\6&\u020a\n&\r&\16&\u020b"+ + "\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\6\'\u0216\n\'\r\'\16\'\u0217\3\'\3\'\5\'"+ + "\u021c\n\'\3\'\3\'\3\'\3(\3(\3(\3(\5(\u0225\n(\3(\3(\3(\7(\u022a\n(\f"+ + "(\16(\u022d\13(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3)\3)\3)\3*\3*\3*\3*\3*\6*"+ + "\u0240\n*\r*\16*\u0241\3+\3+\3+\5+\u0247\n+\3+\3+\3+\5+\u024c\n+\7+\u024e"+ + "\n+\f+\16+\u0251\13+\3+\3+\3+\3+\3,\3,\3,\7,\u025a\n,\f,\16,\u025d\13"+ + ",\3-\3-\3-\7-\u0262\n-\f-\16-\u0265\13-\3.\5.\u0268\n.\3.\3.\3/\3/\3/"+ + "\5/\u026f\n/\3\60\3\60\3\60\7\60\u0274\n\60\f\60\16\60\u0277\13\60\3\61"+ + "\3\61\3\61\5\61\u027c\n\61\3\62\3\62\3\62\7\62\u0281\n\62\f\62\16\62\u0284"+ + "\13\62\3\63\3\63\3\63\7\63\u0289\n\63\f\63\16\63\u028c\13\63\3\64\3\64"+ + "\3\64\3\64\5\64\u0292\n\64\3\65\3\65\3\65\3\65\5\65\u0298\n\65\3\66\3"+ + "\66\3\66\3\66\5\66\u029e\n\66\3\67\3\67\3\67\3\67\5\67\u02a4\n\67\38\3"+ + "8\38\38\58\u02aa\n8\39\39\39\39\39\79\u02b1\n9\f9\169\u02b4\139\3:\7:"+ + "\u02b7\n:\f:\16:\u02ba\13:\3:\3:\3;\3;\3;\7;\u02c1\n;\f;\16;\u02c4\13"+ + ";\3<\3<\3<\3<\3<\3<\7<\u02cc\n<\f<\16<\u02cf\13<\3=\3=\3=\3=\3=\3=\3>"+ + "\3>\3>\3?\3?\3?\3?\3@\3@\3@\3@\3@\3@\3@\5@\u02e5\n@\3A\3A\3A\3A\3A\3A"+ + "\3A\3A\3A\3A\3A\3A\5A\u02f3\nA\3B\3B\3B\3C\3C\5C\u02fa\nC\3C\3C\3D\3D"+ + "\3E\3E\3E\3E\3E\3F\3F\3F\3F\3F\3G\3G\3G\3H\3H\3H\5H\u0310\nH\7H\u0312"+ + "\nH\fH\16H\u0315\13H\3H\3H\3I\3I\5I\u031b\nI\3J\3J\5J\u031f\nJ\3K\3K\3"+ + "K\3K\3L\3L\3L\5L\u0328\nL\3L\3L\3L\5L\u032d\nL\3L\3L\5L\u0331\nL\3L\3"+ + "L\3M\3M\3M\3M\3M\3M\5M\u033b\nM\5M\u033d\nM\3N\3N\3N\3N\7N\u0343\nN\f"+ + "N\16N\u0346\13N\5N\u0348\nN\3N\3N\3N\3N\3N\5N\u034f\nN\3O\3O\5O\u0353"+ + "\nO\3P\3P\5P\u0357\nP\3Q\3Q\5Q\u035b\nQ\3Q\3Q\3Q\3R\3R\5R\u0362\nR\3R"+ + "\3R\3S\3S\3T\3T\3U\3U\3U\2\2V\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 "+ + "\"$&(*,.\60\62\64\668:<>@BDFHJLNPRTVXZ\\^`bdfhjlnprtvxz|~\u0080\u0082"+ + "\u0084\u0086\u0088\u008a\u008c\u008e\u0090\u0092\u0094\u0096\u0098\u009a"+ + "\u009c\u009e\u00a0\u00a2\u00a4\u00a6\u00a8\2\13\3\2\t\n\3\2RS\4\2kkss"+ + "\3\2\r\26\4\2\6\6$.\3\2\60\61\4\2##\62\64\4\2\f\fjj\4\2=hkk\2\u0396\2"+ + "\u00aa\3\2\2\2\4\u00b2\3\2\2\2\6\u00b8\3\2\2\2\b\u00bb\3\2\2\2\n\u00cc"+ + "\3\2\2\2\f\u00db\3\2\2\2\16\u00dd\3\2\2\2\20\u00e5\3\2\2\2\22\u00e7\3"+ + "\2\2\2\24\u00ec\3\2\2\2\26\u00f0\3\2\2\2\30\u00f6\3\2\2\2\32\u010b\3\2"+ + "\2\2\34\u0111\3\2\2\2\36\u0113\3\2\2\2 \u0115\3\2\2\2\"\u0128\3\2\2\2"+ + "$\u0138\3\2\2\2&\u014c\3\2\2\2(\u0154\3\2\2\2*\u015a\3\2\2\2,\u0169\3"+ + "\2\2\2.\u016d\3\2\2\2\60\u017d\3\2\2\2\62\u0186\3\2\2\2\64\u0196\3\2\2"+ + "\2\66\u019f\3\2\2\28\u01a7\3\2\2\2:\u01aa\3\2\2\2<\u01b4\3\2\2\2>\u01c6"+ + "\3\2\2\2@\u01d0\3\2\2\2B\u01e0\3\2\2\2D\u01e5\3\2\2\2F\u01f2\3\2\2\2H"+ + "\u01fa\3\2\2\2J\u0209\3\2\2\2L\u0210\3\2\2\2N\u0220\3\2\2\2P\u0231\3\2"+ + "\2\2R\u023a\3\2\2\2T\u0243\3\2\2\2V\u0256\3\2\2\2X\u025e\3\2\2\2Z\u0267"+ + "\3\2\2\2\\\u026b\3\2\2\2^\u0270\3\2\2\2`\u0278\3\2\2\2b\u027d\3\2\2\2"+ + "d\u0285\3\2\2\2f\u028d\3\2\2\2h\u0293\3\2\2\2j\u0299\3\2\2\2l\u029f\3"+ + "\2\2\2n\u02a5\3\2\2\2p\u02ab\3\2\2\2r\u02b8\3\2\2\2t\u02bd\3\2\2\2v\u02c5"+ + "\3\2\2\2x\u02d0\3\2\2\2z\u02d6\3\2\2\2|\u02d9\3\2\2\2~\u02dd\3\2\2\2\u0080"+ + "\u02f2\3\2\2\2\u0082\u02f4\3\2\2\2\u0084\u02f7\3\2\2\2\u0086\u02fd\3\2"+ + "\2\2\u0088\u02ff\3\2\2\2\u008a\u0304\3\2\2\2\u008c\u0309\3\2\2\2\u008e"+ + "\u030c\3\2\2\2\u0090\u031a\3\2\2\2\u0092\u031e\3\2\2\2\u0094\u0320\3\2"+ + "\2\2\u0096\u0324\3\2\2\2\u0098\u033c\3\2\2\2\u009a\u034e\3\2\2\2\u009c"+ + "\u0352\3\2\2\2\u009e\u0354\3\2\2\2\u00a0\u035a\3\2\2\2\u00a2\u035f\3\2"+ + "\2\2\u00a4\u0365\3\2\2\2\u00a6\u0367\3\2\2\2\u00a8\u0369\3\2\2\2\u00aa"+ + "\u00ab\5\4\3\2\u00ab\u00ac\7\2\2\3\u00ac\3\3\2\2\2\u00ad\u00ae\7h\2\2"+ + "\u00ae\u00af\7g\2\2\u00af\u00b0\5\u00a6T\2\u00b0\u00b1\7\3\2\2\u00b1\u00b3"+ + "\3\2\2\2\u00b2\u00ad\3\2\2\2\u00b2\u00b3\3\2\2\2\u00b3\u00b6\3\2\2\2\u00b4"+ + "\u00b7\5\b\5\2\u00b5\u00b7\5\6\4\2\u00b6\u00b4\3\2\2\2\u00b6\u00b5\3\2"+ + "\2\2\u00b7\5\3\2\2\2\u00b8\u00b9\5\n\6\2\u00b9\u00ba\5*\26\2\u00ba\7\3"+ + "\2\2\2\u00bb\u00bc\7\4\2\2\u00bc\u00bd\7\5\2\2\u00bd\u00be\7s\2\2\u00be"+ + "\u00bf\7\6\2\2\u00bf\u00c0\5\u00a4S\2\u00c0\u00c1\7\3\2\2\u00c1\u00c2"+ + "\5\n\6\2\u00c2\t\3\2\2\2\u00c3\u00c7\5\f\7\2\u00c4\u00c7\5\16\b\2\u00c5"+ + "\u00c7\5 \21\2\u00c6\u00c3\3\2\2\2\u00c6\u00c4\3\2\2\2\u00c6\u00c5\3\2"+ + "\2\2\u00c7\u00c8\3\2\2\2\u00c8\u00c9\7\3\2\2\u00c9\u00cb\3\2\2\2\u00ca"+ + "\u00c6\3\2\2\2\u00cb\u00ce\3\2\2\2\u00cc\u00ca\3\2\2\2\u00cc\u00cd\3\2"+ + "\2\2\u00cd\u00d4\3\2\2\2\u00ce\u00cc\3\2\2\2\u00cf\u00d0\5\20\t\2\u00d0"+ + "\u00d1\7\3\2\2\u00d1\u00d3\3\2\2\2\u00d2\u00cf\3\2\2\2\u00d3\u00d6\3\2"+ + "\2\2\u00d4\u00d2\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5\13\3\2\2\2\u00d6\u00d4"+ + "\3\2\2\2\u00d7\u00dc\5\22\n\2\u00d8\u00dc\5\24\13\2\u00d9\u00dc\5\26\f"+ + "\2\u00da\u00dc\5\30\r\2\u00db\u00d7\3\2\2\2\u00db\u00d8\3\2\2\2\u00db"+ + "\u00d9\3\2\2\2\u00db\u00da\3\2\2\2\u00dc\r\3\2\2\2\u00dd\u00de\7\7\2\2"+ + "\u00de\u00df\7\5\2\2\u00df\u00e0\7s\2\2\u00e0\u00e1\7\6\2\2\u00e1\u00e2"+ + "\5\u00a4S\2\u00e2\17\3\2\2\2\u00e3\u00e6\5$\23\2\u00e4\u00e6\5\"\22\2"+ + "\u00e5\u00e3\3\2\2\2\u00e5\u00e4\3\2\2\2\u00e6\21\3\2\2\2\u00e7\u00e8"+ + "\7\7\2\2\u00e8\u00e9\7X\2\2\u00e9\u00ea\7Q\2\2\u00ea\u00eb\5\u00a4S\2"+ + "\u00eb\23\3\2\2\2\u00ec\u00ed\7\7\2\2\u00ed\u00ee\7\b\2\2\u00ee\u00ef"+ + "\t\2\2\2\u00ef\25\3\2\2\2\u00f0\u00f1\7\7\2\2\u00f1\u00f2\7X\2\2\u00f2"+ + "\u00f3\7B\2\2\u00f3\u00f4\7I\2\2\u00f4\u00f5\t\3\2\2\u00f5\27\3\2\2\2"+ + "\u00f6\u00fb\7\7\2\2\u00f7\u00f8\7\13\2\2\u00f8\u00fc\5\32\16\2\u00f9"+ + "\u00fa\7X\2\2\u00fa\u00fc\7\13\2\2\u00fb\u00f7\3\2\2\2\u00fb\u00f9\3\2"+ + "\2\2\u00fc\u0103\3\2\2\2\u00fd\u00fe\5\36\20\2\u00fe\u00ff\7\6\2\2\u00ff"+ + "\u0100\5\u00a6T\2\u0100\u0102\3\2\2\2\u0101\u00fd\3\2\2\2\u0102\u0105"+ + "\3\2\2\2\u0103\u0101\3\2\2\2\u0103\u0104\3\2\2\2\u0104\31\3\2\2\2\u0105"+ + "\u0103\3\2\2\2\u0106\u0109\7s\2\2\u0107\u0109\5\u00a8U\2\u0108\u0106\3"+ + "\2\2\2\u0108\u0107\3\2\2\2\u0109\u010a\3\2\2\2\u010a\u010c\7\f\2\2\u010b"+ + "\u0108\3\2\2\2\u010b\u010c\3\2\2\2\u010c\u010f\3\2\2\2\u010d\u0110\5\34"+ + "\17\2\u010e\u0110\5\u00a8U\2\u010f\u010d\3\2\2\2\u010f\u010e\3\2\2\2\u0110"+ + "\33\3\2\2\2\u0111\u0112\t\4\2\2\u0112\35\3\2\2\2\u0113\u0114\t\5\2\2\u0114"+ + "\37\3\2\2\2\u0115\u0116\7\27\2\2\u0116\u011a\7\4\2\2\u0117\u0118\7\5\2"+ + "\2\u0118\u0119\7s\2\2\u0119\u011b\7\6\2\2\u011a\u0117\3\2\2\2\u011a\u011b"+ + "\3\2\2\2\u011b\u011c\3\2\2\2\u011c\u0126\5\u00a4S\2\u011d\u011e\7G\2\2"+ + "\u011e\u0123\5\u00a4S\2\u011f\u0120\7\30\2\2\u0120\u0122\5\u00a4S\2\u0121"+ + "\u011f\3\2\2\2\u0122\u0125\3\2\2\2\u0123\u0121\3\2\2\2\u0123\u0124\3\2"+ + "\2\2\u0124\u0127\3\2\2\2\u0125\u0123\3\2\2\2\u0126\u011d\3\2\2\2\u0126"+ + "\u0127\3\2\2\2\u0127!\3\2\2\2\u0128\u0129\7\7\2\2\u0129\u012a\7\31\2\2"+ + "\u012a\u012d\5\u0082B\2\u012b\u012c\7F\2\2\u012c\u012e\5\u0098M\2\u012d"+ + "\u012b\3\2\2\2\u012d\u012e\3\2\2\2\u012e\u0136\3\2\2\2\u012f\u0130\7\32"+ + "\2\2\u0130\u0137\5,\27\2\u0131\u0134\7\33\2\2\u0132\u0133\7\32\2\2\u0133"+ + "\u0135\5,\27\2\u0134\u0132\3\2\2\2\u0134\u0135\3\2\2\2\u0135\u0137\3\2"+ + "\2\2\u0136\u012f\3\2\2\2\u0136\u0131\3\2\2\2\u0137#\3\2\2\2\u0138\u0139"+ + "\7\7\2\2\u0139\u013a\7\34\2\2\u013a\u013b\5\32\16\2\u013b\u013d\7\35\2"+ + "\2\u013c\u013e\5&\24\2\u013d\u013c\3\2\2\2\u013d\u013e\3\2\2\2\u013e\u013f"+ + "\3\2\2\2\u013f\u0142\7\36\2\2\u0140\u0141\7F\2\2\u0141\u0143\5\u0098M"+ + "\2\u0142\u0140\3\2\2\2\u0142\u0143\3\2\2\2\u0143\u014a\3\2\2\2\u0144\u0146"+ + "\7\37\2\2\u0145\u0147\5*\26\2\u0146\u0145\3\2\2\2\u0146\u0147\3\2\2\2"+ + "\u0147\u0148\3\2\2\2\u0148\u014b\7 \2\2\u0149\u014b\7\33\2\2\u014a\u0144"+ + "\3\2\2\2\u014a\u0149\3\2\2\2\u014b%\3\2\2\2\u014c\u0151\5(\25\2\u014d"+ + "\u014e\7\30\2\2\u014e\u0150\5(\25\2\u014f\u014d\3\2\2\2\u0150\u0153\3"+ + "\2\2\2\u0151\u014f\3\2\2\2\u0151\u0152\3\2\2\2\u0152\'\3\2\2\2\u0153\u0151"+ + "\3\2\2\2\u0154\u0155\7!\2\2\u0155\u0158\5\32\16\2\u0156\u0157\7F\2\2\u0157"+ + "\u0159\5\u0098M\2\u0158\u0156\3\2\2\2\u0158\u0159\3\2\2\2\u0159)\3\2\2"+ + "\2\u015a\u015f\5,\27\2\u015b\u015c\7\30\2\2\u015c\u015e\5,\27\2\u015d"+ + "\u015b\3\2\2\2\u015e\u0161\3\2\2\2\u015f\u015d\3\2\2\2\u015f\u0160\3\2"+ + "\2\2\u0160+\3\2\2\2\u0161\u015f\3\2\2\2\u0162\u016a\5.\30\2\u0163\u016a"+ + "\5D#\2\u0164\u016a\5H%\2\u0165\u016a\5L\'\2\u0166\u016a\5P)\2\u0167\u016a"+ + "\5R*\2\u0168\u016a\5V,\2\u0169\u0162\3\2\2\2\u0169\u0163\3\2\2\2\u0169"+ + "\u0164\3\2\2\2\u0169\u0165\3\2\2\2\u0169\u0166\3\2\2\2\u0169\u0167\3\2"+ + "\2\2\u0169\u0168\3\2\2\2\u016a-\3\2\2\2\u016b\u016e\5\60\31\2\u016c\u016e"+ + "\5\64\33\2\u016d\u016b\3\2\2\2\u016d\u016c\3\2\2\2\u016e\u0177\3\2\2\2"+ + "\u016f\u0176\5\60\31\2\u0170\u0176\58\35\2\u0171\u0176\5\64\33\2\u0172"+ + "\u0176\5:\36\2\u0173\u0176\5> \2\u0174\u0176\5B\"\2\u0175\u016f\3\2\2"+ + "\2\u0175\u0170\3\2\2\2\u0175\u0171\3\2\2\2\u0175\u0172\3\2\2\2\u0175\u0173"+ + "\3\2\2\2\u0175\u0174\3\2\2\2\u0176\u0179\3\2\2\2\u0177\u0175\3\2\2\2\u0177"+ + "\u0178\3\2\2\2\u0178\u017a\3\2\2\2\u0179\u0177\3\2\2\2\u017a\u017b\7C"+ + "\2\2\u017b\u017c\5,\27\2\u017c/\3\2\2\2\u017d\u017e\7=\2\2\u017e\u0183"+ + "\5\62\32\2\u017f\u0180\7\30\2\2\u0180\u0182\5\62\32\2\u0181\u017f\3\2"+ + "\2\2\u0182\u0185\3\2\2\2\u0183\u0181\3\2\2\2\u0183\u0184\3\2\2\2\u0184"+ + "\61\3\2\2\2\u0185\u0183\3\2\2\2\u0186\u0189\5\u0082B\2\u0187\u0188\7F"+ + "\2\2\u0188\u018a\5\u0098M\2\u0189\u0187\3\2\2\2\u0189\u018a\3\2\2\2\u018a"+ + "\u018d\3\2\2\2\u018b\u018c\7H\2\2\u018c\u018e\7I\2\2\u018d\u018b\3\2\2"+ + "\2\u018d\u018e\3\2\2\2\u018e\u0191\3\2\2\2\u018f\u0190\7G\2\2\u0190\u0192"+ + "\5\u0082B\2\u0191\u018f\3\2\2\2\u0191\u0192\3\2\2\2\u0192\u0193\3\2\2"+ + "\2\u0193\u0194\7E\2\2\u0194\u0195\5,\27\2\u0195\63\3\2\2\2\u0196\u0197"+ + "\7>\2\2\u0197\u019c\5\66\34\2\u0198\u0199\7\30\2\2\u0199\u019b\5\66\34"+ + "\2\u019a\u0198\3\2\2\2\u019b\u019e\3\2\2\2\u019c\u019a\3\2\2\2\u019c\u019d"+ + "\3\2\2\2\u019d\65\3\2\2\2\u019e\u019c\3\2\2\2\u019f\u01a2\5\u0082B\2\u01a0"+ + "\u01a1\7F\2\2\u01a1\u01a3\5\u0098M\2\u01a2\u01a0\3\2\2\2\u01a2\u01a3\3"+ + "\2\2\2\u01a3\u01a4\3\2\2\2\u01a4\u01a5\7\32\2\2\u01a5\u01a6\5,\27\2\u01a6"+ + "\67\3\2\2\2\u01a7\u01a8\7?\2\2\u01a8\u01a9\5,\27\2\u01a99\3\2\2\2\u01aa"+ + "\u01ab\7@\2\2\u01ab\u01ac\7A\2\2\u01ac\u01b1\5<\37\2\u01ad\u01ae\7\30"+ + "\2\2\u01ae\u01b0\5<\37\2\u01af\u01ad\3\2\2\2\u01b0\u01b3\3\2\2\2\u01b1"+ + "\u01af\3\2\2\2\u01b1\u01b2\3\2\2\2\u01b2;\3\2\2\2\u01b3\u01b1\3\2\2\2"+ + "\u01b4\u01bb\5\u0082B\2\u01b5\u01b6\7F\2\2\u01b6\u01b8\5\u0098M\2\u01b7"+ + "\u01b5\3\2\2\2\u01b7\u01b8\3\2\2\2\u01b8\u01b9\3\2\2\2\u01b9\u01ba\7\32"+ + "\2\2\u01ba\u01bc\5,\27\2\u01bb\u01b7\3\2\2\2\u01bb\u01bc\3\2\2\2\u01bc"+ + "\u01bf\3\2\2\2\u01bd\u01be\7Q\2\2\u01be\u01c0\5\u00a4S\2\u01bf\u01bd\3"+ + "\2\2\2\u01bf\u01c0\3\2\2\2\u01c0=\3\2\2\2\u01c1\u01c2\7B\2\2\u01c2\u01c7"+ + "\7A\2\2\u01c3\u01c4\7K\2\2\u01c4\u01c5\7B\2\2\u01c5\u01c7\7A\2\2\u01c6"+ + "\u01c1\3\2\2\2\u01c6\u01c3\3\2\2\2\u01c7\u01c8\3\2\2\2\u01c8\u01cd\5@"+ + "!\2\u01c9\u01ca\7\30\2\2\u01ca\u01cc\5@!\2\u01cb\u01c9\3\2\2\2\u01cc\u01cf"+ + "\3\2\2\2\u01cd\u01cb\3\2\2\2\u01cd\u01ce\3\2\2\2\u01ce?\3\2\2\2\u01cf"+ + "\u01cd\3\2\2\2\u01d0\u01d3\5,\27\2\u01d1\u01d4\7L\2\2\u01d2\u01d4\7M\2"+ + "\2\u01d3\u01d1\3\2\2\2\u01d3\u01d2\3\2\2\2\u01d3\u01d4\3\2\2\2\u01d4\u01da"+ + "\3\2\2\2\u01d5\u01d8\7I\2\2\u01d6\u01d9\7R\2\2\u01d7\u01d9\7S\2\2\u01d8"+ + "\u01d6\3\2\2\2\u01d8\u01d7\3\2\2\2\u01d9\u01db\3\2\2\2\u01da\u01d5\3\2"+ + "\2\2\u01da\u01db\3\2\2\2\u01db\u01de\3\2\2\2\u01dc\u01dd\7Q\2\2\u01dd"+ + "\u01df\5\u00a4S\2\u01de\u01dc\3\2\2\2\u01de\u01df\3\2\2\2\u01dfA\3\2\2"+ + "\2\u01e0\u01e1\7J\2\2\u01e1\u01e2\5\u0082B\2\u01e2C\3\2\2\2\u01e3\u01e6"+ + "\7N\2\2\u01e4\u01e6\7O\2\2\u01e5\u01e3\3\2\2\2\u01e5\u01e4\3\2\2\2\u01e6"+ + "\u01e7\3\2\2\2\u01e7\u01ec\5F$\2\u01e8\u01e9\7\30\2\2\u01e9\u01eb\5F$"+ + "\2\u01ea\u01e8\3\2\2\2\u01eb\u01ee\3\2\2\2\u01ec\u01ea\3\2\2\2\u01ec\u01ed"+ + "\3\2\2\2\u01ed\u01ef\3\2\2\2\u01ee\u01ec\3\2\2\2\u01ef\u01f0\7P\2\2\u01f0"+ + "\u01f1\5,\27\2\u01f1E\3\2\2\2\u01f2\u01f5\5\u0082B\2\u01f3\u01f4\7F\2"+ + "\2\u01f4\u01f6\5\u0098M\2\u01f5\u01f3\3\2\2\2\u01f5\u01f6\3\2\2\2\u01f6"+ + "\u01f7\3\2\2\2\u01f7\u01f8\7E\2\2\u01f8\u01f9\5,\27\2\u01f9G\3\2\2\2\u01fa"+ + "\u01fb\7T\2\2\u01fb\u01fc\7\35\2\2\u01fc\u01fd\5*\26\2\u01fd\u01ff\7\36"+ + "\2\2\u01fe\u0200\5J&\2\u01ff\u01fe\3\2\2\2\u0200\u0201\3\2\2\2\u0201\u01ff"+ + "\3\2\2\2\u0201\u0202\3\2\2\2\u0202\u0203\3\2\2\2\u0203\u0204\7X\2\2\u0204"+ + "\u0205\7C\2\2\u0205\u0206\5,\27\2\u0206I\3\2\2\2\u0207\u0208\7U\2\2\u0208"+ + "\u020a\5,\27\2\u0209\u0207\3\2\2\2\u020a\u020b\3\2\2\2\u020b\u0209\3\2"+ + "\2\2\u020b\u020c\3\2\2\2\u020c\u020d\3\2\2\2\u020d\u020e\7C\2\2\u020e"+ + "\u020f\5,\27\2\u020fK\3\2\2\2\u0210\u0211\7[\2\2\u0211\u0212\7\35\2\2"+ + "\u0212\u0213\5*\26\2\u0213\u0215\7\36\2\2\u0214\u0216\5N(\2\u0215\u0214"+ + "\3\2\2\2\u0216\u0217\3\2\2\2\u0217\u0215\3\2\2\2\u0217\u0218\3\2\2\2\u0218"+ + "\u0219\3\2\2\2\u0219\u021b\7X\2\2\u021a\u021c\5\u0082B\2\u021b\u021a\3"+ + "\2\2\2\u021b\u021c\3\2\2\2\u021c\u021d\3\2\2\2\u021d\u021e\7C\2\2\u021e"+ + "\u021f\5,\27\2\u021fM\3\2\2\2\u0220\u0224\7U\2\2\u0221\u0222\5\u0082B"+ + "\2\u0222\u0223\7F\2\2\u0223\u0225\3\2\2\2\u0224\u0221\3\2\2\2\u0224\u0225"+ + "\3\2\2\2\u0225\u0226\3\2\2\2\u0226\u022b\5\u0098M\2\u0227\u0228\7\"\2"+ + "\2\u0228\u022a\5\u0098M\2\u0229\u0227\3\2\2\2\u022a\u022d\3\2\2\2\u022b"+ + "\u0229\3\2\2\2\u022b\u022c\3\2\2\2\u022c\u022e\3\2\2\2\u022d\u022b\3\2"+ + "\2\2\u022e\u022f\7C\2\2\u022f\u0230\5,\27\2\u0230O\3\2\2\2\u0231\u0232"+ + "\7D\2\2\u0232\u0233\7\35\2\2\u0233\u0234\5*\26\2\u0234\u0235\7\36\2\2"+ + "\u0235\u0236\7Y\2\2\u0236\u0237\5,\27\2\u0237\u0238\7Z\2\2\u0238\u0239"+ + "\5,\27\2\u0239Q\3\2\2\2\u023a\u023b\7V\2\2\u023b\u023c\7\37\2\2\u023c"+ + "\u023d\5*\26\2\u023d\u023f\7 \2\2\u023e\u0240\5T+\2\u023f\u023e\3\2\2"+ + "\2\u0240\u0241\3\2\2\2\u0241\u023f\3\2\2\2\u0241\u0242\3\2\2\2\u0242S"+ + "\3\2\2\2\u0243\u0246\7W\2\2\u0244\u0247\7#\2\2\u0245\u0247\5\32\16\2\u0246"+ + "\u0244\3\2\2\2\u0246\u0245\3\2\2\2\u0247\u024f\3\2\2\2\u0248\u024b\7\""+ + "\2\2\u0249\u024c\7#\2\2\u024a\u024c\5\32\16\2\u024b\u0249\3\2\2\2\u024b"+ + "\u024a\3\2\2\2\u024c\u024e\3\2\2\2\u024d\u0248\3\2\2\2\u024e\u0251\3\2"+ + "\2\2\u024f\u024d\3\2\2\2\u024f\u0250\3\2\2\2\u0250\u0252\3\2\2\2\u0251"+ + "\u024f\3\2\2\2\u0252\u0253\7\37\2\2\u0253\u0254\5*\26\2\u0254\u0255\7"+ + " \2\2\u0255U\3\2\2\2\u0256\u025b\5X-\2\u0257\u0258\7\\\2\2\u0258\u025a"+ + "\5X-\2\u0259\u0257\3\2\2\2\u025a\u025d\3\2\2\2\u025b\u0259\3\2\2\2\u025b"+ + "\u025c\3\2\2\2\u025cW\3\2\2\2\u025d\u025b\3\2\2\2\u025e\u0263\5Z.\2\u025f"+ + "\u0260\7]\2\2\u0260\u0262\5Z.\2\u0261\u025f\3\2\2\2\u0262\u0265\3\2\2"+ + "\2\u0263\u0261\3\2\2\2\u0263\u0264\3\2\2\2\u0264Y\3\2\2\2\u0265\u0263"+ + "\3\2\2\2\u0266\u0268\7^\2\2\u0267\u0266\3\2\2\2\u0267\u0268\3\2\2\2\u0268"+ + "\u0269\3\2\2\2\u0269\u026a\5\\/\2\u026a[\3\2\2\2\u026b\u026e\5^\60\2\u026c"+ + "\u026d\t\6\2\2\u026d\u026f\5^\60\2\u026e\u026c\3\2\2\2\u026e\u026f\3\2"+ + "\2\2\u026f]\3\2\2\2\u0270\u0275\5`\61\2\u0271\u0272\7/\2\2\u0272\u0274"+ + "\5`\61\2\u0273\u0271\3\2\2\2\u0274\u0277\3\2\2\2\u0275\u0273\3\2\2\2\u0275"+ + "\u0276\3\2\2\2\u0276_\3\2\2\2\u0277\u0275\3\2\2\2\u0278\u027b\5b\62\2"+ + "\u0279\u027a\7_\2\2\u027a\u027c\5b\62\2\u027b\u0279\3\2\2\2\u027b\u027c"+ + "\3\2\2\2\u027ca\3\2\2\2\u027d\u0282\5d\63\2\u027e\u027f\t\7\2\2\u027f"+ + "\u0281\5d\63\2\u0280\u027e\3\2\2\2\u0281\u0284\3\2\2\2\u0282\u0280\3\2"+ + "\2\2\u0282\u0283\3\2\2\2\u0283c\3\2\2\2\u0284\u0282\3\2\2\2\u0285\u028a"+ + "\5f\64\2\u0286\u0287\t\b\2\2\u0287\u0289\5f\64\2\u0288\u0286\3\2\2\2\u0289"+ + "\u028c\3\2\2\2\u028a\u0288\3\2\2\2\u028a\u028b\3\2\2\2\u028be\3\2\2\2"+ + "\u028c\u028a\3\2\2\2\u028d\u0291\5h\65\2\u028e\u028f\7`\2\2\u028f\u0290"+ + "\7a\2\2\u0290\u0292\5\u0098M\2\u0291\u028e\3\2\2\2\u0291\u0292\3\2\2\2"+ + "\u0292g\3\2\2\2\u0293\u0297\5j\66\2\u0294\u0295\7c\2\2\u0295\u0296\7b"+ + "\2\2\u0296\u0298\5\u0098M\2\u0297\u0294\3\2\2\2\u0297\u0298\3\2\2\2\u0298"+ + "i\3\2\2\2\u0299\u029d\5l\67\2\u029a\u029b\7d\2\2\u029b\u029c\7F\2\2\u029c"+ + "\u029e\5\u0098M\2\u029d\u029a\3\2\2\2\u029d\u029e\3\2\2\2\u029ek\3\2\2"+ + "\2\u029f\u02a3\5n8\2\u02a0\u02a1\7f\2\2\u02a1\u02a2\7F\2\2\u02a2\u02a4"+ + "\5\u009eP\2\u02a3\u02a0\3\2\2\2\u02a3\u02a4\3\2\2\2\u02a4m\3\2\2\2\u02a5"+ + "\u02a9\5p9\2\u02a6\u02a7\7e\2\2\u02a7\u02a8\7F\2\2\u02a8\u02aa\5\u009e"+ + "P\2\u02a9\u02a6\3\2\2\2\u02a9\u02aa\3\2\2\2\u02aao\3\2\2\2\u02ab\u02b2"+ + "\5r:\2\u02ac\u02ad\7\6\2\2\u02ad\u02ae\7-\2\2\u02ae\u02af\3\2\2\2\u02af"+ + "\u02b1\5\u008cG\2\u02b0\u02ac\3\2\2\2\u02b1\u02b4\3\2\2\2\u02b2\u02b0"+ + "\3\2\2\2\u02b2\u02b3\3\2\2\2\u02b3q\3\2\2\2\u02b4\u02b2\3\2\2\2\u02b5"+ + "\u02b7\t\7\2\2\u02b6\u02b5\3\2\2\2\u02b7\u02ba\3\2\2\2\u02b8\u02b6\3\2"+ + "\2\2\u02b8\u02b9\3\2\2\2\u02b9\u02bb\3\2\2\2\u02ba\u02b8\3\2\2\2\u02bb"+ + "\u02bc\5t;\2\u02bcs\3\2\2\2\u02bd\u02c2\5v<\2\u02be\u02bf\7\65\2\2\u02bf"+ + "\u02c1\5v<\2\u02c0\u02be\3\2\2\2\u02c1\u02c4\3\2\2\2\u02c2\u02c0\3\2\2"+ + "\2\u02c2\u02c3\3\2\2\2\u02c3u\3\2\2\2\u02c4\u02c2\3\2\2\2\u02c5\u02cd"+ + "\5\u0080A\2\u02c6\u02cc\5x=\2\u02c7\u02cc\5|?\2\u02c8\u02cc\5~@\2\u02c9"+ + "\u02cc\5z>\2\u02ca\u02cc\5\u008eH\2\u02cb\u02c6\3\2\2\2\u02cb\u02c7\3"+ + "\2\2\2\u02cb\u02c8\3\2\2\2\u02cb\u02c9\3\2\2\2\u02cb\u02ca\3\2\2\2\u02cc"+ + "\u02cf\3\2\2\2\u02cd\u02cb\3\2\2\2\u02cd\u02ce\3\2\2\2\u02cew\3\2\2\2"+ + "\u02cf\u02cd\3\2\2\2\u02d0\u02d1\7\66\2\2\u02d1\u02d2\7\66\2\2\u02d2\u02d3"+ + "\5*\26\2\u02d3\u02d4\7\67\2\2\u02d4\u02d5\7\67\2\2\u02d5y\3\2\2\2\u02d6"+ + "\u02d7\7\66\2\2\u02d7\u02d8\7\67\2\2\u02d8{\3\2\2\2\u02d9\u02da\7\66\2"+ + "\2\u02da\u02db\5*\26\2\u02db\u02dc\7\67\2\2\u02dc}\3\2\2\2\u02dd\u02e4"+ + "\78\2\2\u02de\u02e5\5\u00a8U\2\u02df\u02e5\5\u00a6T\2\u02e0\u02e5\7s\2"+ + "\2\u02e1\u02e5\5\u0084C\2\u02e2\u02e5\5\u0082B\2\u02e3\u02e5\5\u0086D"+ + "\2\u02e4\u02de\3\2\2\2\u02e4\u02df\3\2\2\2\u02e4\u02e0\3\2\2\2\u02e4\u02e1"+ + "\3\2\2\2\u02e4\u02e2\3\2\2\2\u02e4\u02e3\3\2\2\2\u02e5\177\3\2\2\2\u02e6"+ + "\u02f3\7k\2\2\u02e7\u02f3\7l\2\2\u02e8\u02f3\5\u00a6T\2\u02e9\u02f3\5"+ + "\u0082B\2\u02ea\u02f3\5\u0084C\2\u02eb\u02f3\5\u0086D\2\u02ec\u02f3\5"+ + "\u009aN\2\u02ed\u02f3\5\u008cG\2\u02ee\u02f3\5\u0088E\2\u02ef\u02f3\5"+ + "\u008aF\2\u02f0\u02f3\5\u00a2R\2\u02f1\u02f3\5\u0092J\2\u02f2\u02e6\3"+ + "\2\2\2\u02f2\u02e7\3\2\2\2\u02f2\u02e8\3\2\2\2\u02f2\u02e9\3\2\2\2\u02f2"+ + "\u02ea\3\2\2\2\u02f2\u02eb\3\2\2\2\u02f2\u02ec\3\2\2\2\u02f2\u02ed\3\2"+ + "\2\2\u02f2\u02ee\3\2\2\2\u02f2\u02ef\3\2\2\2\u02f2\u02f0\3\2\2\2\u02f2"+ + "\u02f1\3\2\2\2\u02f3\u0081\3\2\2\2\u02f4\u02f5\7!\2\2\u02f5\u02f6\5\32"+ + "\16\2\u02f6\u0083\3\2\2\2\u02f7\u02f9\7\35\2\2\u02f8\u02fa\5*\26\2\u02f9"+ + "\u02f8\3\2\2\2\u02f9\u02fa\3\2\2\2\u02fa\u02fb\3\2\2\2\u02fb\u02fc\7\36"+ + "\2\2\u02fc\u0085\3\2\2\2\u02fd\u02fe\79\2\2\u02fe\u0087\3\2\2\2\u02ff"+ + "\u0300\7\t\2\2\u0300\u0301\7\37\2\2\u0301\u0302\5*\26\2\u0302\u0303\7"+ + " \2\2\u0303\u0089\3\2\2\2\u0304\u0305\7\n\2\2\u0305\u0306\7\37\2\2\u0306"+ + "\u0307\5*\26\2\u0307\u0308\7 \2\2\u0308\u008b\3\2\2\2\u0309\u030a\5\32"+ + "\16\2\u030a\u030b\5\u008eH\2\u030b\u008d\3\2\2\2\u030c\u0313\7\35\2\2"+ + "\u030d\u030f\5\u0090I\2\u030e\u0310\7\30\2\2\u030f\u030e\3\2\2\2\u030f"+ + "\u0310\3\2\2\2\u0310\u0312\3\2\2\2\u0311\u030d\3\2\2\2\u0312\u0315\3\2"+ + "\2\2\u0313\u0311\3\2\2\2\u0313\u0314\3\2\2\2\u0314\u0316\3\2\2\2\u0315"+ + "\u0313\3\2\2\2\u0316\u0317\7\36\2\2\u0317\u008f\3\2\2\2\u0318\u031b\5"+ + ",\27\2\u0319\u031b\7j\2\2\u031a\u0318\3\2\2\2\u031a\u0319\3\2\2\2\u031b"+ + "\u0091\3\2\2\2\u031c\u031f\5\u0094K\2\u031d\u031f\5\u0096L\2\u031e\u031c"+ + "\3\2\2\2\u031e\u031d\3\2\2\2\u031f\u0093\3\2\2\2\u0320\u0321\5\32\16\2"+ + "\u0321\u0322\7:\2\2\u0322\u0323\7l\2\2\u0323\u0095\3\2\2\2\u0324\u0325"+ + "\7\34\2\2\u0325\u0327\7\35\2\2\u0326\u0328\5&\24\2\u0327\u0326\3\2\2\2"+ + "\u0327\u0328\3\2\2\2\u0328\u0329\3\2\2\2\u0329\u032c\7\36\2\2\u032a\u032b"+ + "\7F\2\2\u032b\u032d\5\u0098M\2\u032c\u032a\3\2\2\2\u032c\u032d\3\2\2\2"+ + "\u032d\u032e\3\2\2\2\u032e\u0330\7\37\2\2\u032f\u0331\5*\26\2\u0330\u032f"+ + "\3\2\2\2\u0330\u0331\3\2\2\2\u0331\u0332\3\2\2\2\u0332\u0333\7 \2\2\u0333"+ + "\u0097\3\2\2\2\u0334\u0335\7\35\2\2\u0335\u033d\7\36\2\2\u0336\u033a\5"+ + "\u009cO\2\u0337\u033b\7j\2\2\u0338\u033b\7#\2\2\u0339\u033b\7\60\2\2\u033a"+ + "\u0337\3\2\2\2\u033a\u0338\3\2\2\2\u033a\u0339\3\2\2\2\u033a\u033b\3\2"+ + "\2\2\u033b\u033d\3\2\2\2\u033c\u0334\3\2\2\2\u033c\u0336\3\2\2\2\u033d"+ + "\u0099\3\2\2\2\u033e\u0347\7\37\2\2\u033f\u0344\5\u00a0Q\2\u0340\u0341"+ + "\7\30\2\2\u0341\u0343\5\u00a0Q\2\u0342\u0340\3\2\2\2\u0343\u0346\3\2\2"+ + "\2\u0344\u0342\3\2\2\2\u0344\u0345\3\2\2\2\u0345\u0348\3\2\2\2\u0346\u0344"+ + "\3\2\2\2\u0347\u033f\3\2\2\2\u0347\u0348\3\2\2\2\u0348\u0349\3\2\2\2\u0349"+ + "\u034f\7 \2\2\u034a\u034b\7;\2\2\u034b\u034c\5*\26\2\u034c\u034d\7<\2"+ + "\2\u034d\u034f\3\2\2\2\u034e\u033e\3\2\2\2\u034e\u034a\3\2\2\2\u034f\u009b"+ + "\3\2\2\2\u0350\u0353\5\32\16\2\u0351\u0353\7k\2\2\u0352\u0350\3\2\2\2"+ + "\u0352\u0351\3\2\2\2\u0353\u009d\3\2\2\2\u0354\u0356\5\u009cO\2\u0355"+ + "\u0357\7j\2\2\u0356\u0355\3\2\2\2\u0356\u0357\3\2\2\2\u0357\u009f\3\2"+ + "\2\2\u0358\u035b\5,\27\2\u0359\u035b\7s\2\2\u035a\u0358\3\2\2\2\u035a"+ + "\u0359\3\2\2\2\u035b\u035c\3\2\2\2\u035c\u035d\t\t\2\2\u035d\u035e\5,"+ + "\27\2\u035e\u00a1\3\2\2\2\u035f\u0361\7\66\2\2\u0360\u0362\5*\26\2\u0361"+ + "\u0360\3\2\2\2\u0361\u0362\3\2\2\2\u0362\u0363\3\2\2\2\u0363\u0364\7\67"+ + "\2\2\u0364\u00a3\3\2\2\2\u0365\u0366\5\u00a6T\2\u0366\u00a5\3\2\2\2\u0367"+ + "\u0368\7i\2\2\u0368\u00a7\3\2\2\2\u0369\u036a\t\n\2\2\u036a\u00a9\3\2"+ + "\2\2a\u00b2\u00b6\u00c6\u00cc\u00d4\u00db\u00e5\u00fb\u0103\u0108\u010b"+ + "\u010f\u011a\u0123\u0126\u012d\u0134\u0136\u013d\u0142\u0146\u014a\u0151"+ + "\u0158\u015f\u0169\u016d\u0175\u0177\u0183\u0189\u018d\u0191\u019c\u01a2"+ + "\u01b1\u01b7\u01bb\u01bf\u01c6\u01cd\u01d3\u01d8\u01da\u01de\u01e5\u01ec"+ + "\u01f5\u0201\u020b\u0217\u021b\u0224\u022b\u0241\u0246\u024b\u024f\u025b"+ + "\u0263\u0267\u026e\u0275\u027b\u0282\u028a\u0291\u0297\u029d\u02a3\u02a9"+ + "\u02b2\u02b8\u02c2\u02cb\u02cd\u02e4\u02f2\u02f9\u030f\u0313\u031a\u031e"+ + "\u0327\u032c\u0330\u033a\u033c\u0344\u0347\u034e\u0352\u0356\u035a\u0361"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/src/main/java/org/rumbledb/parser/JsoniqVisitor.java b/src/main/java/org/rumbledb/parser/JsoniqVisitor.java index e7f7d91cd7..4024f0f701 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqVisitor.java +++ b/src/main/java/org/rumbledb/parser/JsoniqVisitor.java @@ -319,6 +319,12 @@ public interface JsoniqVisitor extends ParseTreeVisitor { * @return the visitor result */ T visitInstanceOfExpr(JsoniqParser.InstanceOfExprContext ctx); + /** + * Visit a parse tree produced by {@link JsoniqParser#isStaticallyExpr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIsStaticallyExpr(JsoniqParser.IsStaticallyExprContext ctx); /** * Visit a parse tree produced by {@link JsoniqParser#treatExpr}. * @param ctx the parse tree From c2efeaa9ac6a613d14119f68298befe2969c36a4 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 4 Feb 2021 17:33:31 +0100 Subject: [PATCH 143/206] compilable --- .../rumbledb/compiler/InferTypeVisitor.java | 54 +------------------ 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index e6e6f98c85..8db6e94367 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -25,8 +25,6 @@ import org.rumbledb.expressions.module.VariableDeclaration; import org.rumbledb.expressions.postfix.*; import org.rumbledb.expressions.primary.*; -import org.rumbledb.expressions.quantifiers.QuantifiedExpression; -import org.rumbledb.expressions.quantifiers.QuantifiedExpressionVar; import org.rumbledb.expressions.typing.*; import org.rumbledb.types.*; import org.rumbledb.types.AtomicItemType; @@ -426,7 +424,7 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex : ErrorCode.AtomizationError ); } - if (!expressionSequenceType.getItemType().staticallyCastableAs(castedSequenceType.getItemType())) { + if (!expressionSequenceType.getItemType().isStaticallyCastableAs(castedSequenceType.getItemType())) { throw new UnexpectedStaticTypeException( "It is never possible to cast a " + @@ -889,7 +887,7 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static !(leftItemType.isSubtypeOf(AtomicItemType.durationItem) && rightItemType.isSubtypeOf(AtomicItemType.durationItem)) && - !(leftItemType.canBePromotedToString() && rightItemType.canBePromotedToString()) + !(leftItemType.canBePromotedTo(AtomicItemType.stringItem) && rightItemType.canBePromotedTo(AtomicItemType.stringItem)) ) { throw new UnexpectedStaticTypeException( "It is not possible to compare these types: " + leftItemType + " and " + rightItemType @@ -1178,54 +1176,6 @@ public StaticContext visitStringConcatExpr(StringConcatExpression expression, St return argument; } - // endregion - - // region quantified - - @Override - public StaticContext visitQuantifiedExpression(QuantifiedExpression expression, StaticContext argument) { - Expression evaluationExpression = (Expression) expression.getEvaluationExpression(); - boolean skipTestInference = false; - for (QuantifiedExpressionVar var : expression.getVariables()) { - visit(var.getExpression(), argument); - SequenceType inferredType = var.getExpression().getInferredSequenceType(); - basicChecks(inferredType, expression.getClass().getSimpleName(), true, false); - - SequenceType varType = var.getActualSequenceType(); - - if (inferredType.isEmptySequence()) { - skipTestInference = true; - } else { - // we use the single arity version of the inferred type - checkVariableType( - varType, - new SequenceType(inferredType.getItemType()), - evaluationExpression.getStaticContext(), - expression.getClass().getSimpleName(), - var.getVariableName() - ); - } - } - - if (!skipTestInference) { - visit(evaluationExpression, argument); - SequenceType evaluationType = evaluationExpression.getInferredSequenceType(); - basicChecks(evaluationType, expression.getClass().getSimpleName(), true, false); - if (!evaluationType.hasEffectiveBooleanValue()) { - throw new UnexpectedStaticTypeException( - "evaluation expression of quantified expression has " - + evaluationType - + " inferred type, which has no effective boolean value" - ); - } - } - - expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem)); - System.out.println("visiting Quantified expression, type set to: " + expression.getInferredSequenceType()); - return argument; - } - - // endregion // region postfix From 68309cb505c88692cb826837dc946732e6d3c631 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 4 Feb 2021 19:51:31 +0100 Subject: [PATCH 144/206] fixed code to use anyfunction in functionItemType --- .../java/org/rumbledb/items/FunctionItem.java | 7 ++----- .../org/rumbledb/types/AtomicItemType.java | 6 +----- .../org/rumbledb/types/FunctionItemType.java | 18 ++++++++++++++---- .../spark/ml/GetEstimatorFunctionIterator.java | 3 ++- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/rumbledb/items/FunctionItem.java b/src/main/java/org/rumbledb/items/FunctionItem.java index 1b6d658feb..49bad50296 100644 --- a/src/main/java/org/rumbledb/items/FunctionItem.java +++ b/src/main/java/org/rumbledb/items/FunctionItem.java @@ -35,10 +35,7 @@ import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.RumbleException; import org.rumbledb.runtime.RuntimeIterator; -import org.rumbledb.types.AtomicItemType; -import org.rumbledb.types.FunctionSignature; -import org.rumbledb.types.ItemType; -import org.rumbledb.types.SequenceType; +import org.rumbledb.types.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -284,7 +281,7 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return AtomicItemType.functionItem; + return FunctionItemType.ANYFUNCTION; } public FunctionItem deepCopy() { diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 33745e145c..4e406d7bff 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -67,9 +67,6 @@ public class AtomicItemType extends ItemType implements Serializable { new Name(Name.JS_NS, "js", "array") ); public static final AtomicItemType intItem = new AtomicItemType(Name.createVariableInDefaultTypeNamespace("int")); - public static final AtomicItemType functionItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "function") - ); private static List builtInItemTypes = Arrays.asList( objectItem, @@ -93,8 +90,7 @@ public class AtomicItemType extends ItemType implements Serializable { hexBinaryItem, anyURIItem, base64BinaryItem, - item, - functionItem + item ); public AtomicItemType() { diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index a87b305bc9..00fb01c814 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -15,14 +15,24 @@ public FunctionItemType(FunctionSignature signature) { } this.isGeneric = false; this.signature = signature; - this.name = new Name(Name.XS_NS, "xs", signature.toString()); + this.name = null; } // we have a parameter because the empty one is public and inherited private FunctionItemType(boolean isGeneric) { this.isGeneric = true; this.signature = null; - this.name = new Name(Name.XS_NS, "xs", "function(*)"); + this.name = null; + } + + @Override + public Name getName() { + throw new UnsupportedOperationException("function types have no name"); + } + + @Override + public String toString() { + return this.isGeneric ? "function(*)" : this.signature.toString(); } @Override @@ -37,10 +47,10 @@ public FunctionSignature getSignature() { @Override public boolean equals(Object other) { - if (!(other instanceof ItemType)) { + if (!(other instanceof FunctionItemType)) { return false; } - return this.name.toString().equals(other.toString()); + return this.toString().equals(other.toString()); } @Override diff --git a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java index f81a001527..e69508eb81 100644 --- a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java +++ b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java @@ -34,6 +34,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.FunctionItemType; import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.SequenceType; @@ -126,7 +127,7 @@ public Item next() { ) ); SequenceType returnType = new SequenceType( - AtomicItemType.functionItem, + FunctionItemType.ANYFUNCTION, SequenceType.Arity.One ); From 73a585d47dd55cb8f132ad77252f0106c64c16f3 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 4 Feb 2021 19:59:36 +0100 Subject: [PATCH 145/206] fix order by integer --- .../runtime/flwor/clauses/OrderByClauseSparkIterator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index ed41e8a356..cc49e8fd86 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -533,7 +533,7 @@ public static Dataset tryNativeQuery( // special check to avoid ordering by an integer constant in an ordering clause // because of meaning mismatch between sparksql (where it is supposed to order by the i-th col) // and jsoniq (order by a costant, so no actual ordering is performed) - if (nativeQuery.getResultingType() == AtomicItemType.integerItem) { + if (nativeQuery.getResultingType() == AtomicItemType.integerItem || nativeQuery.getResultingType() == AtomicItemType.intItem) { orderSql.append('"'); orderSql.append(nativeQuery.getResultingQuery()); orderSql.append('"'); From 17a8cf37cfdf98e734210d001b55b0198787dcb9 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 4 Feb 2021 20:26:08 +0100 Subject: [PATCH 146/206] fixed quantified test --- src/test/resources/test_files/static-typing/quantified1.jq | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/test_files/static-typing/quantified1.jq b/src/test/resources/test_files/static-typing/quantified1.jq index 4ccd76f612..d5a2bdd8d3 100644 --- a/src/test/resources/test_files/static-typing/quantified1.jq +++ b/src/test/resources/test_files/static-typing/quantified1.jq @@ -1,2 +1,2 @@ (:JIQS: ShouldRun :) -(some $a in (1, 2) satisfies $a gt 12) is statically boolean, (some $a in () satisfies $a div 5) is statically boolean \ No newline at end of file +(some $a in (1, 2) satisfies $a gt 12) is statically boolean, (every $a in (12) satisfies $a div 5) is statically boolean \ No newline at end of file From a9b4a51d96b2515240c03b8d2a9a5f51d05cd064 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 4 Feb 2021 20:28:13 +0100 Subject: [PATCH 147/206] spotless --- src/main/java/org/rumbledb/api/Item.java | 1 + .../rumbledb/compiler/InferTypeVisitor.java | 3 +- .../rumbledb/compiler/TranslationVisitor.java | 1 - .../java/org/rumbledb/items/TimeItem.java | 1 - .../runtime/flwor/FlworDataFrameUtils.java | 42 ++++++++++++------- .../flwor/clauses/ForClauseSparkIterator.java | 7 ++-- .../clauses/OrderByClauseSparkIterator.java | 5 ++- .../operational/ComparisonIterator.java | 5 ++- .../runtime/postfix/ArrayLookupIterator.java | 8 +++- .../runtime/postfix/ObjectLookupIterator.java | 8 +++- .../primary/DecimalRuntimeIterator.java | 6 ++- .../primary/StringRuntimeIterator.java | 6 ++- .../java/org/rumbledb/types/ItemType.java | 1 + 13 files changed, 65 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/rumbledb/api/Item.java b/src/main/java/org/rumbledb/api/Item.java index 39b15e7d36..acc5471405 100644 --- a/src/main/java/org/rumbledb/api/Item.java +++ b/src/main/java/org/rumbledb/api/Item.java @@ -593,6 +593,7 @@ default int castToIntValue() { /** * Get sparkSql string for the item + * * @param context input context * @return String representing the item in a sparksql query or null if it is not supported for the item */ diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 8db6e94367..9ccdf86289 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -887,7 +887,8 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static !(leftItemType.isSubtypeOf(AtomicItemType.durationItem) && rightItemType.isSubtypeOf(AtomicItemType.durationItem)) && - !(leftItemType.canBePromotedTo(AtomicItemType.stringItem) && rightItemType.canBePromotedTo(AtomicItemType.stringItem)) + !(leftItemType.canBePromotedTo(AtomicItemType.stringItem) + && rightItemType.canBePromotedTo(AtomicItemType.stringItem)) ) { throw new UnexpectedStaticTypeException( "It is not possible to compare these types: " + leftItemType + " and " + rightItemType diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 3e9b40d0b8..43b1517dae 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -124,7 +124,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; /** diff --git a/src/main/java/org/rumbledb/items/TimeItem.java b/src/main/java/org/rumbledb/items/TimeItem.java index 44b5a72362..ff271b5efa 100644 --- a/src/main/java/org/rumbledb/items/TimeItem.java +++ b/src/main/java/org/rumbledb/items/TimeItem.java @@ -8,7 +8,6 @@ import org.rumbledb.api.Item; import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; -import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.ItemType; diff --git a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java index 1c853ce8c5..c7b573634d 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java +++ b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java @@ -67,7 +67,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collector; import static org.apache.spark.sql.functions.col; import static org.apache.spark.sql.functions.count; @@ -342,17 +341,32 @@ public static String getSQLProjection( return queryColumnString.toString(); } - public static StructField[] recursiveRename(StructType schema, boolean inverse){ + public static StructField[] recursiveRename(StructType schema, boolean inverse) { return Arrays.stream(schema.fields()).map(field -> { - String newName = inverse ? field.name().replace(FlworDataFrameUtils.backtickEscape, "`") : field.name().replace("`", FlworDataFrameUtils.backtickEscape); - if(field.dataType() instanceof StructType){ + String newName = inverse + ? field.name().replace(FlworDataFrameUtils.backtickEscape, "`") + : field.name().replace("`", FlworDataFrameUtils.backtickEscape); + if (field.dataType() instanceof StructType) { StructType castedField = (StructType) field.dataType(); - return new StructField(newName, new StructType(recursiveRename(castedField, inverse)), field.nullable(), field.metadata()); - } else if(field.dataType() instanceof ArrayType){ + return new StructField( + newName, + new StructType(recursiveRename(castedField, inverse)), + field.nullable(), + field.metadata() + ); + } else if (field.dataType() instanceof ArrayType) { ArrayType castedField = (ArrayType) field.dataType(); - if(castedField.elementType() instanceof StructType){ + if (castedField.elementType() instanceof StructType) { StructType castedElementType = (StructType) castedField.elementType(); - return new StructField(newName, new ArrayType(new StructType(recursiveRename(castedElementType, inverse)), castedField.containsNull()), field.nullable(), field.metadata()); + return new StructField( + newName, + new ArrayType( + new StructType(recursiveRename(castedElementType, inverse)), + castedField.containsNull() + ), + field.nullable(), + field.metadata() + ); } else { return new StructField(newName, field.dataType(), field.nullable(), field.metadata()); } @@ -369,20 +383,20 @@ public static StructField[] recursiveRename(StructType schema, boolean inverse){ * @param inverse if true, perform de-escaping, otherwise escape * @return the new schema appropriately escaped/de-escaped */ - public static StructType escapeSchema(StructType schema, boolean inverse){ + public static StructType escapeSchema(StructType schema, boolean inverse) { return new StructType(recursiveRename(schema, inverse)); } - public static ItemType mapToJsoniqType(DataType type){ + public static ItemType mapToJsoniqType(DataType type) { // TODO: once type mapping is defined add string field to determine and document properly - if(type == DataTypes.StringType) { + if (type == DataTypes.StringType) { return AtomicItemType.stringItem; - } else if(type == DataTypes.IntegerType) { + } else if (type == DataTypes.IntegerType) { return AtomicItemType.integerItem; - } else if(type.equals(DataTypes.createDecimalType())) { + } else if (type.equals(DataTypes.createDecimalType())) { // TODO: test correct working return AtomicItemType.integerItem; - } else if(type == DataTypes.DoubleType) { + } else if (type == DataTypes.DoubleType) { return AtomicItemType.doubleItem; } else { return null; diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index db7f915537..0a37fd7025 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -22,7 +22,6 @@ import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; -import org.apache.spark.sql.Column; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; import org.apache.spark.sql.RowFactory; @@ -70,7 +69,6 @@ import java.util.Stack; import java.util.TreeMap; -import static org.apache.spark.sql.functions.struct; public class ForClauseSparkIterator extends RuntimeTupleIterator { @@ -1032,9 +1030,10 @@ public static Dataset getDataFrameStartingClause( Dataset df = null;; if (iterator.isDataFrame()) { Dataset rows = iterator.getDataFrame(context); - + // escape backticks (`) - rows = rows.sparkSession().createDataFrame(rows.rdd(), FlworDataFrameUtils.escapeSchema(rows.schema(), false)); + rows = rows.sparkSession() + .createDataFrame(rows.rdd(), FlworDataFrameUtils.escapeSchema(rows.schema(), false)); String[] fields = rows.schema().fieldNames(); rows.createOrReplaceTempView("assignment"); diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index cc49e8fd86..5f46744a44 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -533,7 +533,10 @@ public static Dataset tryNativeQuery( // special check to avoid ordering by an integer constant in an ordering clause // because of meaning mismatch between sparksql (where it is supposed to order by the i-th col) // and jsoniq (order by a costant, so no actual ordering is performed) - if (nativeQuery.getResultingType() == AtomicItemType.integerItem || nativeQuery.getResultingType() == AtomicItemType.intItem) { + if ( + nativeQuery.getResultingType() == AtomicItemType.integerItem + || nativeQuery.getResultingType() == AtomicItemType.intItem + ) { orderSql.append('"'); orderSql.append(nativeQuery.getResultingQuery()); orderSql.append('"'); diff --git a/src/main/java/org/rumbledb/runtime/operational/ComparisonIterator.java b/src/main/java/org/rumbledb/runtime/operational/ComparisonIterator.java index 47df5c70a9..6ac328cb48 100644 --- a/src/main/java/org/rumbledb/runtime/operational/ComparisonIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/ComparisonIterator.java @@ -477,7 +477,10 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC } // TODO: once done type system do proper comparison - if(!(leftResult.getResultingType().isNumeric() && rightResult.getResultingType().isNumeric() || leftResult.getResultingType() == rightResult.getResultingType())){ + if ( + !(leftResult.getResultingType().isNumeric() && rightResult.getResultingType().isNumeric() + || leftResult.getResultingType() == rightResult.getResultingType()) + ) { return NativeClauseContext.NoNativeQuery; } diff --git a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java index 66dd46b0fc..7f1afe9fce 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ArrayLookupIterator.java @@ -165,13 +165,17 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC if (newContext != NativeClauseContext.NoNativeQuery) { // check if the key has variable dependencies inside the FLWOR expression // in that case we switch over to UDF - Map keyDependencies = this.children.get(1).getVariableDependencies(); + Map keyDependencies = this.children.get(1) + .getVariableDependencies(); // we use nativeClauseContext that contains the top level schema DataType schema = nativeClauseContext.getSchema(); StructType structSchema; if (schema instanceof StructType) { structSchema = (StructType) schema; - if(Arrays.stream(structSchema.fieldNames()).anyMatch(field -> keyDependencies.containsKey(Name.createVariableInNoNamespace(field)))){ + if ( + Arrays.stream(structSchema.fieldNames()) + .anyMatch(field -> keyDependencies.containsKey(Name.createVariableInNoNamespace(field))) + ) { return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java index 37f4750fb8..b004be5a95 100644 --- a/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java +++ b/src/main/java/org/rumbledb/runtime/postfix/ObjectLookupIterator.java @@ -220,13 +220,17 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC if (newContext != NativeClauseContext.NoNativeQuery) { // check if the key has variable dependencies inside the FLWOR expression // in that case we switch over to UDF - Map keyDependencies = this.children.get(1).getVariableDependencies(); + Map keyDependencies = this.children.get(1) + .getVariableDependencies(); // we use nativeClauseContext that contains the top level schema DataType schema = nativeClauseContext.getSchema(); StructType structSchema; if (schema instanceof StructType) { structSchema = (StructType) schema; - if(Arrays.stream(structSchema.fieldNames()).anyMatch(field -> keyDependencies.containsKey(Name.createVariableInNoNamespace(field)))){ + if ( + Arrays.stream(structSchema.fieldNames()) + .anyMatch(field -> keyDependencies.containsKey(Name.createVariableInNoNamespace(field))) + ) { return NativeClauseContext.NoNativeQuery; } } diff --git a/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java index 78fa5df1a1..b92321fcd2 100644 --- a/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java @@ -49,6 +49,10 @@ public Item materializeFirstItemOrNull(DynamicContext context) { @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - return new NativeClauseContext(nativeClauseContext, "" + this.item.getDecimalValue(), AtomicItemType.decimalItem); + return new NativeClauseContext( + nativeClauseContext, + "" + this.item.getDecimalValue(), + AtomicItemType.decimalItem + ); } } diff --git a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java index 40daa59cda..9083ebad4e 100644 --- a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java @@ -47,6 +47,10 @@ public Item materializeFirstItemOrNull(DynamicContext context) { @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - return new NativeClauseContext(nativeClauseContext, '"' + this.item.getStringValue() + '"', AtomicItemType.stringItem); + return new NativeClauseContext( + nativeClauseContext, + '"' + this.item.getStringValue() + '"', + AtomicItemType.stringItem + ); } } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index ef43af27db..7f750178d9 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -56,6 +56,7 @@ public boolean equals(Object other) { public boolean isFunctionItem() { return false; } + // Returns the signature of a function item public FunctionSignature getSignature() { throw new OurBadException("called getSignature on a non-function item"); From 34a0e38739ef4acb5bcb59c9135218b78e12fb03 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 8 Feb 2021 09:59:23 +0100 Subject: [PATCH 148/206] fix static typing inference, null is comparable with any type and added test --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 4 +++- .../resources/test_files/static-typing/comparison/comp2.jq | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 9ccdf86289..0aa7a6c4af 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -878,7 +878,7 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types"); } - // Type must match exactly or be both numeric or both promotable to string or both durations + // Type must match exactly or be both numeric or both promotable to string or both durations or one must be null if ( !leftItemType.equals(rightItemType) && @@ -889,6 +889,8 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static && !(leftItemType.canBePromotedTo(AtomicItemType.stringItem) && rightItemType.canBePromotedTo(AtomicItemType.stringItem)) + && + !(leftItemType.equals(AtomicItemType.nullItem) || rightItemType.equals(AtomicItemType.nullItem)) ) { throw new UnexpectedStaticTypeException( "It is not possible to compare these types: " + leftItemType + " and " + rightItemType diff --git a/src/test/resources/test_files/static-typing/comparison/comp2.jq b/src/test/resources/test_files/static-typing/comparison/comp2.jq index 83c8ba8228..f31cf42bf4 100644 --- a/src/test/resources/test_files/static-typing/comparison/comp2.jq +++ b/src/test/resources/test_files/static-typing/comparison/comp2.jq @@ -6,4 +6,4 @@ declare variable $dtdur := "P2DT3H" cast as dayTimeDuration; declare variable $ymdur := "P1Y2M" cast as yearMonthDuration; declare variable $hexb := "0cd7" cast as hexBinary; declare variable $base64b := "DNc=" cast as base64Binary; -($date eq $date) is statically boolean, ($date lt $date) is statically boolean, ($dt eq $dt) is statically boolean, ($dt lt $dt) is statically boolean, ($time eq $time) is statically boolean, ($time gt $time) is statically boolean, ($ymdur eq $ymdur) is statically boolean, ($ymdur lt $ymdur) is statically boolean, ($dtdur eq $dtdur) is statically boolean, ($dtdur lt $dtdur) is statically boolean, ($ymdur eq $dtdur) is statically boolean, (($ymdur treat as duration) eq $dtdur) is statically boolean, ($hexb eq $hexb) is statically boolean, ($base64b eq $base64b) is statically boolean \ No newline at end of file +($date eq $date) is statically boolean, ($date lt $date) is statically boolean, ($dt eq $dt) is statically boolean, ($dt lt $dt) is statically boolean, ($time eq $time) is statically boolean, ($time gt $time) is statically boolean, ($ymdur eq $ymdur) is statically boolean, ($ymdur lt $ymdur) is statically boolean, ($dtdur eq $dtdur) is statically boolean, ($dtdur lt $dtdur) is statically boolean, ($ymdur eq $dtdur) is statically boolean, (($ymdur treat as duration) eq $dtdur) is statically boolean, ($hexb eq $hexb) is statically boolean, ($base64b eq $base64b) is statically boolean, (null eq 32) is statically boolean, ("a" < null) is statically boolean \ No newline at end of file From 05d8b8e37762a642503cce970be877ae9c310c91 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 8 Feb 2021 10:11:06 +0100 Subject: [PATCH 149/206] test '1' = 1 for spark jsoniq behavior mismatch --- .../resources/test_files/runtime-native-flwor/where/eq1.jq | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/test/resources/test_files/runtime-native-flwor/where/eq1.jq diff --git a/src/test/resources/test_files/runtime-native-flwor/where/eq1.jq b/src/test/resources/test_files/runtime-native-flwor/where/eq1.jq new file mode 100644 index 0000000000..8563fa0557 --- /dev/null +++ b/src/test/resources/test_files/runtime-native-flwor/where/eq1.jq @@ -0,0 +1,4 @@ +(:JIQS: ShouldCrash; ErrorCode="XPTY0004" :) +for $i in structured-json-file("../../../queries/difficult-names.json") +where $i.keyToUse eq $i.indexToUse +return $i \ No newline at end of file From dc9849ddbc6fc1b9713ac348229ecd2c697bfc4a Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 8 Feb 2021 11:46:52 +0100 Subject: [PATCH 150/206] ItemType to interface --- .../org/rumbledb/types/AtomicItemType.java | 8 + .../java/org/rumbledb/types/ItemType.java | 147 +++++++++--------- 2 files changed, 84 insertions(+), 71 deletions(-) diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 4e406d7bff..fa6c0fbdd3 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -115,6 +115,14 @@ public static boolean typeExists(Name name) { return false; } + @Override + public boolean equals(Object other) { + if (!(other instanceof ItemType)) { + return false; + } + return this.name.toString().equals(other.toString()); + } + public static ItemType getItemTypeByName(Name name) { for (int i = 0; i < builtInItemTypes.size(); ++i) { if (name.getNamespace() != null && name.getNamespace().equals(Name.JSONIQ_DEFAULT_TYPE_NS)) { diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 7f750178d9..c706fd70e7 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -26,106 +26,111 @@ import java.io.Serializable; -public class ItemType implements Serializable { +public interface ItemType extends Serializable { - protected static final long serialVersionUID = 1L; - protected Name name; + // protected static final long serialVersionUID = 1L; - public static final ItemType item = new ItemType(Name.createVariableInDefaultTypeNamespace("item")); + /** + * Tests for itemType equality. + * + * @param other another item type. + * @return true it is equal to other, false otherwise. + */ + public boolean equals(Object other); - public ItemType() { + /** + * @return true it [this] is a subtype of an atomic item type. + */ + public default boolean isSubtypeOfAtomicItem() { + return false; } - protected ItemType(Name name) { - this.name = name; + /** + * @return true it [this] is an object item type. + */ + public default boolean isObjectItem() { + return false; } - public Name getName() { - return this.name; + /** + * @return true it [this] is an array item type. + */ + public default boolean isArrayItem() { + return false; } - @Override - public boolean equals(Object other) { - if (!(other instanceof ItemType)) { - return false; - } - return this.name.toString().equals(other.toString()); + /** + * @return true it [this] is a function item type. + */ + public default boolean isFunctionItem() { + return false; } - // Returns true if [this] is a function item - public boolean isFunctionItem() { + /** + * + * @return [true] if this is a numeric item type, false otherwise + */ + public default boolean isNumeric() { return false; } - // Returns the signature of a function item - public FunctionSignature getSignature() { - throw new OurBadException("called getSignature on a non-function item"); + /** + * Tests for QName. + * + * @return true if [this] item type has a QName + */ + public default boolean hasName() { + return false; } - // Returns true if [this] is a subtype of [superType], any type is considered a subtype of itself - public boolean isSubtypeOf(ItemType superType) { - if (superType.equals(item)) { - return true; - } else if (superType.equals(AtomicItemType.JSONItem)) { - return this.equals(AtomicItemType.objectItem) - || this.equals(AtomicItemType.arrayItem) - || this.equals(AtomicItemType.JSONItem); - } else if (superType.equals(AtomicItemType.atomicItem)) { - return this.equals(AtomicItemType.stringItem) - || this.equals(AtomicItemType.integerItem) - || this.equals(AtomicItemType.decimalItem) - || this.equals(AtomicItemType.doubleItem) - || this.equals(AtomicItemType.booleanItem) - || this.equals(AtomicItemType.nullItem) - || this.equals(AtomicItemType.anyURIItem) - || this.equals(AtomicItemType.hexBinaryItem) - || this.equals(AtomicItemType.base64BinaryItem) - || this.equals(AtomicItemType.dateTimeItem) - || this.equals(AtomicItemType.dateItem) - || this.equals(AtomicItemType.timeItem) - || this.equals(AtomicItemType.durationItem) - || this.equals(AtomicItemType.yearMonthDurationItem) - || this.equals(AtomicItemType.dayTimeDurationItem) - || this.equals(AtomicItemType.atomicItem); - } else if (superType.equals(AtomicItemType.durationItem)) { - return this.equals(AtomicItemType.yearMonthDurationItem) - || this.equals(AtomicItemType.dayTimeDurationItem) - || this.equals(AtomicItemType.durationItem); - } else if (superType.equals(AtomicItemType.decimalItem)) { - return this.equals(AtomicItemType.integerItem) || this.equals(AtomicItemType.decimalItem); - } - return this.equals(superType); + /** + * + * @return the itemtype QName if available + */ + public default Name getName() { + throw new UnsupportedOperationException("getName operation is not supported for this itemType"); } - public ItemType findCommonSuperType(ItemType other) { - // item is the most generic type - return this; + /** + * + * @return the signature of the function item type if available + */ + public default FunctionSignature getSignature() { + throw new UnsupportedOperationException("getSignature operation is not supported for non-function item types"); } + /** + * + * @param superType another item type + * @return true if [this] is a subtype of [superType], any type is considered a subtype of itself + */ + public boolean isSubtypeOf(ItemType superType); + + /** + * + * @param other another item type + * @return the common supertype between [this] and [other], that would be the LCA in the item type tree of [this] and [other] + */ + public ItemType findCommonSuperType(ItemType other); + /** * Check at static time if [this] could be casted to [other] item type, requires [this] to be an atomic type * * @param other a strict subtype of atomic item type to which we are trying to cast * @return true if it is possible at static time to cast [this] to [other], false otherwise */ - public boolean isStaticallyCastableAs(ItemType other) { - // this is not atomic and therefore cannot be casted - // TODO: consider throwing error here - return false; + public default boolean isStaticallyCastableAs(ItemType other) { + throw new UnsupportedOperationException("isStaticallyCastableAs operation is not supported for non-atomic item types"); } - // return [true] if this is a numeric type (i.e. [integerItem], [decimalItem] or [doubleItem]), false otherwise - public boolean isNumeric() { - return false; - } - - // returns [true] if this can be promoted to itemType - public boolean canBePromotedTo(ItemType itemType) { + /** + * + * @param itemType another item type + * @return true if [this] can be promoted to [itemType] + */ + public default boolean canBePromotedTo(ItemType itemType) { return false; } - @Override - public String toString() { - return this.name.toString(); - } + public String toString(); } From 435fc4765de7ce1c5d5bfa1441bb44424d9ed1d3 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 8 Feb 2021 12:51:44 +0100 Subject: [PATCH 151/206] added 'item' itemtype --- .../java/org/rumbledb/types/ItemItemType.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/main/java/org/rumbledb/types/ItemItemType.java diff --git a/src/main/java/org/rumbledb/types/ItemItemType.java b/src/main/java/org/rumbledb/types/ItemItemType.java new file mode 100644 index 0000000000..b0a703c38c --- /dev/null +++ b/src/main/java/org/rumbledb/types/ItemItemType.java @@ -0,0 +1,53 @@ +package org.rumbledb.types; + +import org.rumbledb.context.Name; + +/** + * Class representing the generic 'item' item type + */ +public class ItemItemType implements ItemType { + + private static final long serialVersionUID = 1L; + + static final ItemType item = new ItemItemType(Name.createVariableInDefaultTypeNamespace("item")); + private Name name; + + public ItemItemType(){ + + } + + private ItemItemType(Name name){ + this.name = name; + } + + @Override + public boolean equals(Object o) { + // no need to check the class because ItemItemType is a singleton and it is only equal to its only instance + return o == item; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Name getName() { + return name; + } + + @Override + public boolean isSubtypeOf(ItemType superType) { + return superType == item; + } + + @Override + public ItemType findCommonSuperType(ItemType other) { + return item; + } + + @Override + public String toString() { + return this.name.toString(); + } +} From efa6c4a2c001f6a7b7ecafb6b71211a70a2cbae8 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 8 Feb 2021 19:26:18 +0100 Subject: [PATCH 152/206] completed item type refactoring, added builtin types catalogue --- .../compiler/DynamicContextVisitor.java | 3 +- .../rumbledb/compiler/InferTypeVisitor.java | 151 +++++++++--------- .../compiler/StaticContextVisitor.java | 5 +- .../rumbledb/compiler/TranslationVisitor.java | 9 +- .../java/org/rumbledb/items/AnyURIItem.java | 3 +- .../java/org/rumbledb/items/ArrayItem.java | 3 +- .../org/rumbledb/items/Base64BinaryItem.java | 3 +- .../java/org/rumbledb/items/BooleanItem.java | 3 +- .../java/org/rumbledb/items/DateItem.java | 5 +- .../java/org/rumbledb/items/DateTimeItem.java | 17 +- .../rumbledb/items/DayTimeDurationItem.java | 5 +- .../java/org/rumbledb/items/DecimalItem.java | 5 +- .../java/org/rumbledb/items/DoubleItem.java | 5 +- .../java/org/rumbledb/items/DurationItem.java | 23 +-- .../java/org/rumbledb/items/FloatItem.java | 3 +- .../java/org/rumbledb/items/FunctionItem.java | 2 +- .../org/rumbledb/items/HexBinaryItem.java | 3 +- src/main/java/org/rumbledb/items/IntItem.java | 5 +- .../java/org/rumbledb/items/IntegerItem.java | 5 +- .../java/org/rumbledb/items/NullItem.java | 3 +- .../java/org/rumbledb/items/ObjectItem.java | 3 +- .../java/org/rumbledb/items/StringItem.java | 5 +- .../java/org/rumbledb/items/TimeItem.java | 5 +- .../rumbledb/items/YearMonthDurationItem.java | 5 +- .../rumbledb/items/parsing/ItemParser.java | 93 +++++------ .../AtMostOneItemLocalRuntimeIterator.java | 3 +- .../org/rumbledb/runtime/RuntimeIterator.java | 3 +- .../runtime/flwor/FlworDataFrameUtils.java | 9 +- .../flwor/clauses/LetClauseSparkIterator.java | 9 +- .../clauses/OrderByClauseSparkIterator.java | 69 ++++---- .../udfs/OrderClauseCreateColumnsUDF.java | 23 +-- .../DayTimeDurationFunctionIterator.java | 3 +- .../durations/DurationFunctionIterator.java | 3 +- .../YearMonthDurationFunctionIterator.java | 3 +- .../numerics/NumberFunctionIterator.java | 3 +- .../operational/AndOperationIterator.java | 3 +- .../operational/ComparisonIterator.java | 3 +- .../operational/NotOperationIterator.java | 3 +- .../operational/OrOperationIterator.java | 3 +- .../primary/DecimalRuntimeIterator.java | 3 +- .../primary/DoubleRuntimeIterator.java | 3 +- .../primary/IntegerRuntimeIterator.java | 3 +- .../primary/StringRuntimeIterator.java | 3 +- .../rumbledb/runtime/typing/CastIterator.java | 41 ++--- .../runtime/typing/CastableIterator.java | 3 +- .../runtime/typing/InstanceOfIterator.java | 43 ++--- .../runtime/typing/TypePromotionIterator.java | 3 +- .../org/rumbledb/types/AtomicItemType.java | 129 ++++++--------- .../rumbledb/types/BuiltinTypesCatalogue.java | 88 ++++++++++ .../org/rumbledb/types/FunctionItemType.java | 37 ++--- .../java/org/rumbledb/types/ItemItemType.java | 2 +- .../java/org/rumbledb/types/SequenceType.java | 86 +++++----- .../java/sparksoniq/spark/DataFrameUtils.java | 3 +- .../ml/ApplyEstimatorRuntimeIterator.java | 7 +- .../ml/GetEstimatorFunctionIterator.java | 7 +- .../ml/GetTransformerFunctionIterator.java | 7 +- .../sparksoniq/spark/ml/RumbleMLUtils.java | 11 +- src/test/java/iq/FrontendTests.java | 11 +- 58 files changed, 548 insertions(+), 454 deletions(-) create mode 100644 src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java diff --git a/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java b/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java index 45c352f54e..0366ef2e29 100644 --- a/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java @@ -46,6 +46,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.input.FileSystemUtil; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.runtime.typing.InstanceOfIterator; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; @@ -187,7 +188,7 @@ public DynamicContext visitVariableDeclaration(VariableDeclaration variableDecla Item item = null; if ( !sequenceType.equals(SequenceType.EMPTY_SEQUENCE) - && sequenceType.getItemType().equals(AtomicItemType.anyURIItem) + && sequenceType.getItemType().equals(BuiltinTypesCatalogue.anyURIItem) ) { URI resolvedURI = FileSystemUtil.resolveURIAgainstWorkingDirectory( value, diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 0aa7a6c4af..82826c6b8b 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -28,6 +28,7 @@ import org.rumbledb.expressions.typing.*; import org.rumbledb.types.*; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import java.util.*; import java.util.stream.Collectors; @@ -150,42 +151,42 @@ public StaticContext visitCommaExpression(CommaExpression expression, StaticCont @Override public StaticContext visitString(StringLiteralExpression expression, StaticContext argument) { System.out.println("visiting String literal"); - expression.setInferredSequenceType(new SequenceType(AtomicItemType.stringItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.stringItem)); return argument; } @Override public StaticContext visitInteger(IntegerLiteralExpression expression, StaticContext argument) { System.out.println("visiting Int literal"); - expression.setInferredSequenceType(new SequenceType(AtomicItemType.integerItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.integerItem)); return argument; } @Override public StaticContext visitDouble(DoubleLiteralExpression expression, StaticContext argument) { System.out.println("visiting Double literal"); - expression.setInferredSequenceType(new SequenceType(AtomicItemType.doubleItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.doubleItem)); return argument; } @Override public StaticContext visitDecimal(DecimalLiteralExpression expression, StaticContext argument) { System.out.println("visiting Decimal literal"); - expression.setInferredSequenceType(new SequenceType(AtomicItemType.decimalItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.decimalItem)); return argument; } @Override public StaticContext visitNull(NullLiteralExpression expression, StaticContext argument) { System.out.println("visiting Null literal"); - expression.setInferredSequenceType(new SequenceType(AtomicItemType.nullItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.nullItem)); return argument; } @Override public StaticContext visitBoolean(BooleanLiteralExpression expression, StaticContext argument) { System.out.println("visiting Boolean literal"); - expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.booleanItem)); return argument; } @@ -209,7 +210,7 @@ public StaticContext visitVariableReference(VariableReferenceExpression expressi public StaticContext visitArrayConstructor(ArrayConstructorExpression expression, StaticContext argument) { System.out.println("visiting Array constructor literal"); visitDescendants(expression, argument); - expression.setInferredSequenceType(new SequenceType(AtomicItemType.arrayItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.arrayItem)); return argument; } @@ -247,7 +248,7 @@ public StaticContext visitObjectConstructor(ObjectConstructorExpression expressi } } } - expression.setInferredSequenceType(new SequenceType(AtomicItemType.objectItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.objectItem)); return argument; } @@ -255,7 +256,7 @@ public StaticContext visitObjectConstructor(ObjectConstructorExpression expressi public StaticContext visitContextExpr(ContextItemExpression expression, StaticContext argument) { SequenceType contextType = expression.getStaticContext().getContextItemStaticType(); if (contextType == null) { - contextType = new SequenceType(ItemType.item); + contextType = new SequenceType(BuiltinTypesCatalogue.item); } expression.setInferredSequenceType(contextType); System.out.println("Visited context expression, set type: " + contextType); @@ -353,7 +354,7 @@ public StaticContext visitCastableExpression(CastableExpression expression, Stat System.out.println("visiting Castable expression"); visitDescendants(expression, argument); ItemType itemType = expression.getSequenceType().getItemType(); - if (itemType.equals(AtomicItemType.atomicItem)) { + if (itemType.equals(BuiltinTypesCatalogue.atomicItem)) { throw new UnexpectedStaticTypeException( "atomic item type is not allowed in castable expression", ErrorCode.CastableErrorCode @@ -361,16 +362,16 @@ public StaticContext visitCastableExpression(CastableExpression expression, Stat } SequenceType expressionType = expression.getMainExpression().getInferredSequenceType(); basicChecks(expressionType, expression.getClass().getSimpleName(), true, false); - if (!expressionType.isEmptySequence() && !expressionType.getItemType().isSubtypeOf(AtomicItemType.atomicItem)) { + if (!expressionType.isEmptySequence() && !expressionType.getItemType().isSubtypeOf(BuiltinTypesCatalogue.atomicItem)) { throw new UnexpectedStaticTypeException( "non-atomic item types are not allowed in castable expression, found " + expressionType.getItemType(), - expressionType.getItemType().isSubtypeOf(AtomicItemType.JSONItem) + expressionType.getItemType().isSubtypeOf(BuiltinTypesCatalogue.JSONItem) ? ErrorCode.NonAtomicElementErrorCode : ErrorCode.AtomizationError ); } - expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.booleanItem)); return argument; } @@ -383,7 +384,7 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex SequenceType expressionSequenceType = expression.getMainExpression().getInferredSequenceType(); SequenceType castedSequenceType = expression.getSequenceType(); - if (castedSequenceType.getItemType().equals(AtomicItemType.atomicItem)) { + if (castedSequenceType.getItemType().equals(BuiltinTypesCatalogue.atomicItem)) { throw new UnexpectedStaticTypeException( "atomic item type is not allowed in cast expression", ErrorCode.CastableErrorCode @@ -414,12 +415,12 @@ public StaticContext visitCastExpression(CastExpression expression, StaticContex } // ItemType static castability check - if (!expressionSequenceType.getItemType().isSubtypeOf(AtomicItemType.atomicItem)) { + if (!expressionSequenceType.getItemType().isSubtypeOf(BuiltinTypesCatalogue.atomicItem)) { throw new UnexpectedStaticTypeException( "It is never possible to cast a non-atomic sequence type: " + expressionSequenceType, - expressionSequenceType.getItemType().isSubtypeOf(AtomicItemType.JSONItem) + expressionSequenceType.getItemType().isSubtypeOf(BuiltinTypesCatalogue.JSONItem) ? ErrorCode.NonAtomicElementErrorCode : ErrorCode.AtomizationError ); @@ -459,7 +460,7 @@ public StaticContext visitIsStaticallyExpr(IsStaticallyExpression expression, St public StaticContext visitInstanceOfExpression(InstanceOfExpression expression, StaticContext argument) { System.out.println("visiting InstanceOf expression"); visitDescendants(expression, argument); - expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.booleanItem)); return argument; } @@ -516,39 +517,39 @@ public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticCont if (rightItemType.isNumeric()) { inferredType = resolveNumericType(leftItemType, rightItemType); } - } else if (leftItemType.equals(AtomicItemType.dateItem) || leftItemType.equals(AtomicItemType.dateTimeItem)) { + } else if (leftItemType.equals(BuiltinTypesCatalogue.dateItem) || leftItemType.equals(BuiltinTypesCatalogue.dateTimeItem)) { if ( - rightItemType.equals(AtomicItemType.dayTimeDurationItem) - || rightItemType.equals(AtomicItemType.yearMonthDurationItem) + rightItemType.equals(BuiltinTypesCatalogue.dayTimeDurationItem) + || rightItemType.equals(BuiltinTypesCatalogue.yearMonthDurationItem) ) { inferredType = leftItemType; } else if (expression.isMinus() && rightItemType.equals(leftItemType)) { - inferredType = AtomicItemType.dayTimeDurationItem; + inferredType = BuiltinTypesCatalogue.dayTimeDurationItem; } - } else if (leftItemType.equals(AtomicItemType.timeItem)) { - if (rightItemType.equals(AtomicItemType.dayTimeDurationItem)) { + } else if (leftItemType.equals(BuiltinTypesCatalogue.timeItem)) { + if (rightItemType.equals(BuiltinTypesCatalogue.dayTimeDurationItem)) { inferredType = leftItemType; } else if (expression.isMinus() && rightItemType.equals(leftItemType)) { - inferredType = AtomicItemType.dayTimeDurationItem; + inferredType = BuiltinTypesCatalogue.dayTimeDurationItem; } - } else if (leftItemType.equals(AtomicItemType.dayTimeDurationItem)) { + } else if (leftItemType.equals(BuiltinTypesCatalogue.dayTimeDurationItem)) { if (rightItemType.equals(leftItemType)) { inferredType = leftItemType; } else if ( !expression.isMinus() - && (rightItemType.equals(AtomicItemType.dateTimeItem) - || rightItemType.equals(AtomicItemType.dateItem) - || rightItemType.equals(AtomicItemType.timeItem)) + && (rightItemType.equals(BuiltinTypesCatalogue.dateTimeItem) + || rightItemType.equals(BuiltinTypesCatalogue.dateItem) + || rightItemType.equals(BuiltinTypesCatalogue.timeItem)) ) { inferredType = rightItemType; } - } else if (leftItemType.equals(AtomicItemType.yearMonthDurationItem)) { + } else if (leftItemType.equals(BuiltinTypesCatalogue.yearMonthDurationItem)) { if (rightItemType.equals(leftItemType)) { inferredType = leftItemType; } else if ( !expression.isMinus() - && (rightItemType.equals(AtomicItemType.dateTimeItem) - || rightItemType.equals(AtomicItemType.dateItem)) + && (rightItemType.equals(BuiltinTypesCatalogue.dateTimeItem) + || rightItemType.equals(BuiltinTypesCatalogue.dateItem)) ) { inferredType = rightItemType; } @@ -578,12 +579,12 @@ public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticCont // This function assume 2 numeric ItemType private ItemType resolveNumericType(ItemType left, ItemType right) { - if (left.equals(AtomicItemType.doubleItem) || right.equals(AtomicItemType.doubleItem)) { - return AtomicItemType.doubleItem; - } else if (left.equals(AtomicItemType.decimalItem) || right.equals(AtomicItemType.decimalItem)) { - return AtomicItemType.decimalItem; + if (left.equals(BuiltinTypesCatalogue.doubleItem) || right.equals(BuiltinTypesCatalogue.doubleItem)) { + return BuiltinTypesCatalogue.doubleItem; + } else if (left.equals(BuiltinTypesCatalogue.decimalItem) || right.equals(BuiltinTypesCatalogue.decimalItem)) { + return BuiltinTypesCatalogue.decimalItem; } else { - return AtomicItemType.integerItem; + return BuiltinTypesCatalogue.integerItem; } } @@ -638,27 +639,27 @@ public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression if (leftItemType.isNumeric()) { if (rightItemType.isNumeric()) { if (expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.IDIV) { - inferredType = AtomicItemType.integerItem; + inferredType = BuiltinTypesCatalogue.integerItem; } else if ( expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.DIV ) { inferredType = resolveNumericType( - AtomicItemType.decimalItem, + BuiltinTypesCatalogue.decimalItem, resolveNumericType(leftItemType, rightItemType) ); } else { inferredType = resolveNumericType(leftItemType, rightItemType); } } else if ( - rightItemType.isSubtypeOf(AtomicItemType.durationItem) - && !rightItemType.equals(AtomicItemType.durationItem) + rightItemType.isSubtypeOf(BuiltinTypesCatalogue.durationItem) + && !rightItemType.equals(BuiltinTypesCatalogue.durationItem) && expression.getMultiplicativeOperator() == MultiplicativeExpression.MultiplicativeOperator.MUL ) { inferredType = rightItemType; } } else if ( - leftItemType.isSubtypeOf(AtomicItemType.durationItem) && !leftItemType.equals(AtomicItemType.durationItem) + leftItemType.isSubtypeOf(BuiltinTypesCatalogue.durationItem) && !leftItemType.equals(BuiltinTypesCatalogue.durationItem) ) { if ( rightItemType.isNumeric() @@ -668,7 +669,7 @@ public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression ) { inferredType = leftItemType; } else if (rightItemType.equals(leftItemType)) { - inferredType = AtomicItemType.decimalItem; + inferredType = BuiltinTypesCatalogue.decimalItem; } } @@ -779,7 +780,7 @@ private StaticContext visitAndOrExpr(Expression expression, StaticContext argume ); } - expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.booleanItem)); return argument; } @@ -809,7 +810,7 @@ public StaticContext visitNotExpr(NotExpression expression, StaticContext argume ); } - expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.booleanItem)); return argument; } @@ -862,7 +863,7 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static // Type must be a strict subtype of atomic if ( - leftItemType.isSubtypeOf(AtomicItemType.JSONItem) || rightItemType.isSubtypeOf(AtomicItemType.JSONItem) + leftItemType.isSubtypeOf(BuiltinTypesCatalogue.JSONItem) || rightItemType.isSubtypeOf(BuiltinTypesCatalogue.JSONItem) ) { throw new UnexpectedStaticTypeException( "It is not possible to compare with non-atomic types", @@ -870,10 +871,10 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static ); } if ( - !leftItemType.isSubtypeOf(AtomicItemType.atomicItem) - || !rightItemType.isSubtypeOf(AtomicItemType.atomicItem) - || leftItemType.equals(AtomicItemType.atomicItem) - || rightItemType.equals(AtomicItemType.atomicItem) + !leftItemType.isSubtypeOf(BuiltinTypesCatalogue.atomicItem) + || !rightItemType.isSubtypeOf(BuiltinTypesCatalogue.atomicItem) + || leftItemType.equals(BuiltinTypesCatalogue.atomicItem) + || rightItemType.equals(BuiltinTypesCatalogue.atomicItem) ) { throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types"); } @@ -884,13 +885,13 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static && !(leftItemType.isNumeric() && rightItemType.isNumeric()) && - !(leftItemType.isSubtypeOf(AtomicItemType.durationItem) - && rightItemType.isSubtypeOf(AtomicItemType.durationItem)) + !(leftItemType.isSubtypeOf(BuiltinTypesCatalogue.durationItem) + && rightItemType.isSubtypeOf(BuiltinTypesCatalogue.durationItem)) && - !(leftItemType.canBePromotedTo(AtomicItemType.stringItem) - && rightItemType.canBePromotedTo(AtomicItemType.stringItem)) + !(leftItemType.canBePromotedTo(BuiltinTypesCatalogue.stringItem) + && rightItemType.canBePromotedTo(BuiltinTypesCatalogue.stringItem)) && - !(leftItemType.equals(AtomicItemType.nullItem) || rightItemType.equals(AtomicItemType.nullItem)) + !(leftItemType.equals(BuiltinTypesCatalogue.nullItem) || rightItemType.equals(BuiltinTypesCatalogue.nullItem)) ) { throw new UnexpectedStaticTypeException( "It is not possible to compare these types: " + leftItemType + " and " + rightItemType @@ -906,14 +907,14 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static operator != ComparisonExpression.ComparisonOperator.GC_EQ && operator != ComparisonExpression.ComparisonOperator.GC_NE) - && (leftItemType.equals(AtomicItemType.hexBinaryItem) - || leftItemType.equals(AtomicItemType.base64BinaryItem) + && (leftItemType.equals(BuiltinTypesCatalogue.hexBinaryItem) + || leftItemType.equals(BuiltinTypesCatalogue.base64BinaryItem) || - leftItemType.equals(AtomicItemType.durationItem) - || rightItemType.equals(AtomicItemType.durationItem) + leftItemType.equals(BuiltinTypesCatalogue.durationItem) + || rightItemType.equals(BuiltinTypesCatalogue.durationItem) || - ((leftItemType.equals(AtomicItemType.dayTimeDurationItem) - || leftItemType.equals(AtomicItemType.yearMonthDurationItem)) + ((leftItemType.equals(BuiltinTypesCatalogue.dayTimeDurationItem) + || leftItemType.equals(BuiltinTypesCatalogue.yearMonthDurationItem)) && !rightItemType.equals(leftItemType))) ) { throw new UnexpectedStaticTypeException( @@ -927,7 +928,7 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static } } - expression.setInferredSequenceType(new SequenceType(AtomicItemType.booleanItem, returnArity)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.booleanItem, returnArity)); return argument; } @@ -992,14 +993,14 @@ public void checkSwitchType(SequenceType type) { ErrorCode.UnexpectedFunctionItem ); } - if (itemType.isSubtypeOf(AtomicItemType.JSONItem)) { + if (itemType.isSubtypeOf(BuiltinTypesCatalogue.JSONItem)) { throw new UnexpectedStaticTypeException( "switch test condition and cases expressions' item type must match atomic, instead inferred: " + itemType, ErrorCode.NonAtomicElementErrorCode ); } - if (!itemType.isSubtypeOf(AtomicItemType.atomicItem)) { + if (!itemType.isSubtypeOf(BuiltinTypesCatalogue.atomicItem)) { throw new UnexpectedStaticTypeException( "switch test condition and cases expressions' item type must match atomic, instead inferred: " + itemType @@ -1137,7 +1138,7 @@ public StaticContext visitRangeExpr(RangeExpression expression, StaticContext ar ); } - SequenceType intOpt = new SequenceType(AtomicItemType.integerItem, SequenceType.Arity.OneOrZero); + SequenceType intOpt = new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.OneOrZero); if (!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)) { throw new UnexpectedStaticTypeException( "operands of the range expression must match type integer? instead found: " @@ -1147,7 +1148,7 @@ public StaticContext visitRangeExpr(RangeExpression expression, StaticContext ar ); } - expression.setInferredSequenceType(new SequenceType(AtomicItemType.integerItem, SequenceType.Arity.ZeroOrMore)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.ZeroOrMore)); System.out.println("visiting Range expression, type set to: " + expression.getInferredSequenceType()); return argument; } @@ -1164,7 +1165,7 @@ public StaticContext visitStringConcatExpr(StringConcatExpression expression, St throw new OurBadException("A child expression of a ConcatExpression has no inferred type"); } - SequenceType intOpt = new SequenceType(AtomicItemType.atomicItem, SequenceType.Arity.OneOrZero); + SequenceType intOpt = new SequenceType(BuiltinTypesCatalogue.atomicItem, SequenceType.Arity.OneOrZero); if (!leftType.isSubtypeOf(intOpt) || !rightType.isSubtypeOf(intOpt)) { throw new UnexpectedStaticTypeException( "operands of the concat expression must match type atomic? instead found: " @@ -1174,7 +1175,7 @@ public StaticContext visitStringConcatExpr(StringConcatExpression expression, St ); } - expression.setInferredSequenceType(new SequenceType(AtomicItemType.stringItem)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.stringItem)); System.out.println("visiting Concat expression, type set to: " + expression.getInferredSequenceType()); return argument; } @@ -1210,7 +1211,7 @@ public StaticContext visitArrayLookupExpression(ArrayLookupExpression expression SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; - expression.setInferredSequenceType(new SequenceType(ItemType.item, inferredArity)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.item, inferredArity)); System.out.println("visiting ArrayLookup expression, type set to: " + expression.getInferredSequenceType()); return argument; } @@ -1245,7 +1246,7 @@ public StaticContext visitObjectLookupExpression(ObjectLookupExpression expressi SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; - expression.setInferredSequenceType(new SequenceType(ItemType.item, inferredArity)); + expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.item, inferredArity)); System.out.println("visiting ObjectLookup expression, type set to: " + expression.getInferredSequenceType()); return argument; } @@ -1305,7 +1306,7 @@ public StaticContext visitFilterExpression(FilterExpression expression, StaticCo // if we are filter one or less items or we use an integer to select a specific position we return at most one // element, otherwise * SequenceType.Arity inferredArity = (mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) - || predicateType.getItemType().equals(AtomicItemType.integerItem)) + || predicateType.getItemType().equals(BuiltinTypesCatalogue.integerItem)) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; expression.setInferredSequenceType(new SequenceType(mainType.getItemType(), inferredArity)); @@ -1343,7 +1344,7 @@ public StaticContext visitDynamicFunctionCallExpression( if (!mainType.isEmptySequence()) { ItemType type = mainType.getItemType(); if (type.isFunctionItem()) { - if (type.equals(FunctionItemType.ANYFUNCTION)) { + if (type.equals(BuiltinTypesCatalogue.anyFunctionItem)) { isAnyFunction = true; } else { signature = type.getSignature(); @@ -1590,13 +1591,13 @@ public StaticContext visitOrderByClause(OrderByClause expression, StaticContext if ( !orderType.isSubtypeOf(SequenceType.createSequenceType("atomic?")) || - orderType.getItemType().equals(AtomicItemType.atomicItem) + orderType.getItemType().equals(BuiltinTypesCatalogue.atomicItem) || - orderType.getItemType().equals(AtomicItemType.durationItem) + orderType.getItemType().equals(BuiltinTypesCatalogue.durationItem) || - orderType.getItemType().equals(AtomicItemType.hexBinaryItem) + orderType.getItemType().equals(BuiltinTypesCatalogue.hexBinaryItem) || - orderType.getItemType().equals(AtomicItemType.base64BinaryItem) + orderType.getItemType().equals(BuiltinTypesCatalogue.base64BinaryItem) ) { throw new UnexpectedStaticTypeException( "order by sorting expression's type must match atomic? and be comparable using 'gt' operator (so duration, hexBinary, base64Binary and atomic item type are not allowed), instead inferred: " diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index ebbf1cf8e3..a0cd6b65e8 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -53,6 +53,7 @@ import org.rumbledb.expressions.primary.InlineFunctionExpression; import org.rumbledb.expressions.primary.VariableReferenceExpression; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; @@ -269,7 +270,7 @@ public StaticContext visitForClause(ForClause clause, StaticContext argument) { if (clause.getPositionalVariableName() != null) { result.addVariable( clause.getPositionalVariableName(), - new SequenceType(AtomicItemType.integerItem), + new SequenceType(BuiltinTypesCatalogue.integerItem), clause.getMetadata(), ExecutionMode.LOCAL ); @@ -323,7 +324,7 @@ public StaticContext visitCountClause(CountClause expression, StaticContext argu StaticContext result = new StaticContext(argument); result.addVariable( expression.getCountVariable().getVariableName(), - new SequenceType(AtomicItemType.integerItem, SequenceType.Arity.One), + new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.One), expression.getMetadata(), ExecutionMode.LOCAL ); diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 43b1517dae..07e5dffe49 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -108,6 +108,7 @@ import org.rumbledb.parser.JsoniqParser.UriLiteralContext; import org.rumbledb.runtime.functions.input.FileSystemUtil; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -1169,15 +1170,15 @@ public SequenceType processSingleType(JsoniqParser.SingleTypeContext ctx) { public ItemType processItemType(JsoniqParser.ItemTypeContext itemTypeContext) { if (itemTypeContext.NullLiteral() != null) { - return AtomicItemType.nullItem; + return BuiltinTypesCatalogue.nullItem; } - return AtomicItemType.getItemTypeByName(parseName(itemTypeContext.qname(), false, true)); + return BuiltinTypesCatalogue.getItemTypeByName(parseName(itemTypeContext.qname(), false, true)); } private Expression processFunctionCall(JsoniqParser.FunctionCallContext ctx, List children) { Name name = parseName(ctx.fn_name, true, false); if ( - AtomicItemType.typeExists(name) + BuiltinTypesCatalogue.typeExists(name) && children.size() == 1 ) { return new CastExpression( @@ -1187,7 +1188,7 @@ private Expression processFunctionCall(JsoniqParser.FunctionCallContext ctx, Lis ); } if ( - AtomicItemType.typeExists(Name.createVariableInDefaultTypeNamespace(name.getLocalName())) + BuiltinTypesCatalogue.typeExists(Name.createVariableInDefaultTypeNamespace(name.getLocalName())) && children.size() == 1 && name.getNamespace() != null && name.getNamespace().equals(Name.JSONIQ_DEFAULT_FUNCTION_NS) diff --git a/src/main/java/org/rumbledb/items/AnyURIItem.java b/src/main/java/org/rumbledb/items/AnyURIItem.java index ad6f7a3d1a..f4f59a8b5e 100644 --- a/src/main/java/org/rumbledb/items/AnyURIItem.java +++ b/src/main/java/org/rumbledb/items/AnyURIItem.java @@ -29,6 +29,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.net.URI; @@ -114,7 +115,7 @@ public boolean isAnyURI() { @Override public ItemType getDynamicType() { - return AtomicItemType.anyURIItem; + return BuiltinTypesCatalogue.anyURIItem; } @Override diff --git a/src/main/java/org/rumbledb/items/ArrayItem.java b/src/main/java/org/rumbledb/items/ArrayItem.java index 5795955124..c9168b4e3f 100644 --- a/src/main/java/org/rumbledb/items/ArrayItem.java +++ b/src/main/java/org/rumbledb/items/ArrayItem.java @@ -26,6 +26,7 @@ import org.apache.commons.text.StringEscapeUtils; import org.rumbledb.api.Item; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.util.ArrayList; import java.util.List; @@ -139,7 +140,7 @@ public int hashCode() { @Override public ItemType getDynamicType() { - return AtomicItemType.arrayItem; + return BuiltinTypesCatalogue.arrayItem; } @Override diff --git a/src/main/java/org/rumbledb/items/Base64BinaryItem.java b/src/main/java/org/rumbledb/items/Base64BinaryItem.java index 5e260ebfd6..e618a8900c 100644 --- a/src/main/java/org/rumbledb/items/Base64BinaryItem.java +++ b/src/main/java/org/rumbledb/items/Base64BinaryItem.java @@ -10,6 +10,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import javax.xml.bind.DatatypeConverter; import java.util.Arrays; @@ -123,7 +124,7 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return AtomicItemType.base64BinaryItem; + return BuiltinTypesCatalogue.base64BinaryItem; } @Override diff --git a/src/main/java/org/rumbledb/items/BooleanItem.java b/src/main/java/org/rumbledb/items/BooleanItem.java index b23901a76a..94055fb32b 100644 --- a/src/main/java/org/rumbledb/items/BooleanItem.java +++ b/src/main/java/org/rumbledb/items/BooleanItem.java @@ -25,6 +25,7 @@ import com.esotericsoftware.kryo.io.Output; import org.rumbledb.api.Item; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; public class BooleanItem implements Item { @@ -93,7 +94,7 @@ public int hashCode() { @Override public ItemType getDynamicType() { - return AtomicItemType.booleanItem; + return BuiltinTypesCatalogue.booleanItem; } @Override diff --git a/src/main/java/org/rumbledb/items/DateItem.java b/src/main/java/org/rumbledb/items/DateItem.java index 66a017bc90..3b0d42bdc7 100644 --- a/src/main/java/org/rumbledb/items/DateItem.java +++ b/src/main/java/org/rumbledb/items/DateItem.java @@ -10,6 +10,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; public class DateItem implements Item { @@ -29,7 +30,7 @@ public DateItem() { } DateItem(String dateTimeString) { - this.value = DateTimeItem.parseDateTime(dateTimeString, AtomicItemType.dateItem); + this.value = DateTimeItem.parseDateTime(dateTimeString, BuiltinTypesCatalogue.dateItem); if (!dateTimeString.endsWith("Z") && this.value.getZone() == DateTimeZone.getDefault()) { this.hasTimeZone = false; this.value = this.value.withZoneRetainFields(DateTimeZone.UTC); @@ -109,7 +110,7 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return AtomicItemType.dateItem; + return BuiltinTypesCatalogue.dateItem; } @Override diff --git a/src/main/java/org/rumbledb/items/DateTimeItem.java b/src/main/java/org/rumbledb/items/DateTimeItem.java index f621a1bbc2..86ebcde1b5 100644 --- a/src/main/java/org/rumbledb/items/DateTimeItem.java +++ b/src/main/java/org/rumbledb/items/DateTimeItem.java @@ -14,6 +14,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.util.regex.Pattern; @@ -65,7 +66,7 @@ public DateTimeItem() { } DateTimeItem(String dateTimeString) { - this.value = parseDateTime(dateTimeString, AtomicItemType.dateTimeItem); + this.value = parseDateTime(dateTimeString, BuiltinTypesCatalogue.dateTimeItem); if (!dateTimeString.endsWith("Z") && this.value.getZone() == DateTimeZone.getDefault()) { this.hasTimeZone = false; this.value = this.value.withZoneRetainFields(DateTimeZone.UTC); @@ -149,10 +150,10 @@ public void read(Kryo kryo, Input input) { } private static DateTimeFormatter getDateTimeFormatter(ItemType dateTimeType) { - if (dateTimeType.equals(AtomicItemType.dateTimeItem)) { + if (dateTimeType.equals(BuiltinTypesCatalogue.dateTimeItem)) { return ISODateTimeFormat.dateTimeParser().withOffsetParsed(); } - if (dateTimeType.equals(AtomicItemType.dateItem)) { + if (dateTimeType.equals(BuiltinTypesCatalogue.dateItem)) { DateTimeParser dtParser = new DateTimeFormatterBuilder().appendOptional( ((new DateTimeFormatterBuilder()).appendTimeZoneOffset("Z", true, 2, 4).toFormatter()).getParser() ).toParser(); @@ -161,20 +162,20 @@ private static DateTimeFormatter getDateTimeFormatter(ItemType dateTimeType) { .toFormatter() .withOffsetParsed(); } - if (dateTimeType.equals(AtomicItemType.timeItem)) { + if (dateTimeType.equals(BuiltinTypesCatalogue.timeItem)) { return ISODateTimeFormat.timeParser().withOffsetParsed(); } throw new IllegalArgumentException(); } private static boolean checkInvalidDateTimeFormat(String dateTime, ItemType dateTimeType) { - if (dateTimeType.equals(AtomicItemType.dateTimeItem)) { + if (dateTimeType.equals(BuiltinTypesCatalogue.dateTimeItem)) { return dateTimePattern.matcher(dateTime).matches(); } - if (dateTimeType.equals(AtomicItemType.dateItem)) { + if (dateTimeType.equals(BuiltinTypesCatalogue.dateItem)) { return datePattern.matcher(dateTime).matches(); } - if (dateTimeType.equals(AtomicItemType.timeItem)) { + if (dateTimeType.equals(BuiltinTypesCatalogue.timeItem)) { return timePattern.matcher(dateTime).matches(); } return false; @@ -222,7 +223,7 @@ static DateTime parseDateTime(String dateTime, ItemType dateTimeType) throws Ill @Override public ItemType getDynamicType() { - return AtomicItemType.dateTimeItem; + return BuiltinTypesCatalogue.dateTimeItem; } @Override diff --git a/src/main/java/org/rumbledb/items/DayTimeDurationItem.java b/src/main/java/org/rumbledb/items/DayTimeDurationItem.java index e5865ee0d8..0f197ee1d6 100644 --- a/src/main/java/org/rumbledb/items/DayTimeDurationItem.java +++ b/src/main/java/org/rumbledb/items/DayTimeDurationItem.java @@ -5,6 +5,7 @@ import org.joda.time.Period; import org.joda.time.PeriodType; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; public class DayTimeDurationItem extends DurationItem { @@ -43,7 +44,7 @@ public boolean isDayTimeDuration() { @Override public void read(Kryo kryo, Input input) { - this.value = getDurationFromString(input.readString(), AtomicItemType.dayTimeDurationItem).normalizedStandard( + this.value = getDurationFromString(input.readString(), BuiltinTypesCatalogue.dayTimeDurationItem).normalizedStandard( PeriodType.dayTime() ); this.isNegative = this.value.toString().contains("-"); @@ -51,6 +52,6 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return AtomicItemType.dayTimeDurationItem; + return BuiltinTypesCatalogue.dayTimeDurationItem; } } diff --git a/src/main/java/org/rumbledb/items/DecimalItem.java b/src/main/java/org/rumbledb/items/DecimalItem.java index d53b1e5ffa..9e55da5157 100644 --- a/src/main/java/org/rumbledb/items/DecimalItem.java +++ b/src/main/java/org/rumbledb/items/DecimalItem.java @@ -29,6 +29,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.math.BigDecimal; import java.math.BigInteger; @@ -126,12 +127,12 @@ public int hashCode() { @Override public ItemType getDynamicType() { - return AtomicItemType.decimalItem; + return BuiltinTypesCatalogue.decimalItem; } @Override public NativeClauseContext generateNativeQuery(NativeClauseContext context) { - return new NativeClauseContext(context, this.value.toString(), AtomicItemType.stringItem); + return new NativeClauseContext(context, this.value.toString(), BuiltinTypesCatalogue.stringItem); } public boolean isNumeric() { diff --git a/src/main/java/org/rumbledb/items/DoubleItem.java b/src/main/java/org/rumbledb/items/DoubleItem.java index a40c562ddc..25d6007b4c 100644 --- a/src/main/java/org/rumbledb/items/DoubleItem.java +++ b/src/main/java/org/rumbledb/items/DoubleItem.java @@ -31,6 +31,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.math.BigDecimal; import java.math.BigInteger; @@ -143,12 +144,12 @@ public int hashCode() { @Override public ItemType getDynamicType() { - return AtomicItemType.doubleItem; + return BuiltinTypesCatalogue.doubleItem; } @Override public NativeClauseContext generateNativeQuery(NativeClauseContext context) { - return new NativeClauseContext(context, "" + this.value, AtomicItemType.doubleItem); + return new NativeClauseContext(context, "" + this.value, BuiltinTypesCatalogue.doubleItem); } @Override diff --git a/src/main/java/org/rumbledb/items/DurationItem.java b/src/main/java/org/rumbledb/items/DurationItem.java index f833914070..89e85ecf0a 100644 --- a/src/main/java/org/rumbledb/items/DurationItem.java +++ b/src/main/java/org/rumbledb/items/DurationItem.java @@ -15,6 +15,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.util.regex.Pattern; @@ -133,17 +134,17 @@ public void write(Kryo kryo, Output output) { @Override public void read(Kryo kryo, Input input) { - this.value = getDurationFromString(input.readString(), AtomicItemType.durationItem).normalizedStandard( + this.value = getDurationFromString(input.readString(), BuiltinTypesCatalogue.durationItem).normalizedStandard( PeriodType.yearMonthDayTime() ); this.isNegative = this.value.toString().contains("-"); } private static PeriodFormatter getPeriodFormatter(ItemType durationType) { - if (durationType.equals(AtomicItemType.durationItem)) { + if (durationType.equals(BuiltinTypesCatalogue.durationItem)) { return ISOPeriodFormat.standard(); } - if (durationType.equals(AtomicItemType.yearMonthDurationItem)) { + if (durationType.equals(BuiltinTypesCatalogue.yearMonthDurationItem)) { return new PeriodFormatterBuilder().appendLiteral("P") .appendYears() .appendSuffix("Y") @@ -152,7 +153,7 @@ private static PeriodFormatter getPeriodFormatter(ItemType durationType) { .toFormatter(); } - if (durationType.equals(AtomicItemType.dayTimeDurationItem)) { + if (durationType.equals(BuiltinTypesCatalogue.dayTimeDurationItem)) { return new PeriodFormatterBuilder().appendLiteral("P") .appendDays() .appendSuffix("D") @@ -169,28 +170,28 @@ private static PeriodFormatter getPeriodFormatter(ItemType durationType) { } private static PeriodType getPeriodType(ItemType durationType) { - if (durationType.equals(AtomicItemType.durationItem)) { + if (durationType.equals(BuiltinTypesCatalogue.durationItem)) { return PeriodType.yearMonthDayTime(); } - if (durationType.equals(AtomicItemType.yearMonthDurationItem)) { + if (durationType.equals(BuiltinTypesCatalogue.yearMonthDurationItem)) { return PeriodType.forFields( new DurationFieldType[] { DurationFieldType.years(), DurationFieldType.months() } ); } - if (durationType.equals(AtomicItemType.dayTimeDurationItem)) { + if (durationType.equals(BuiltinTypesCatalogue.dayTimeDurationItem)) { return PeriodType.dayTime(); } throw new IllegalArgumentException(); } private static boolean checkInvalidDurationFormat(String duration, ItemType durationType) { - if (durationType.equals(AtomicItemType.durationItem)) { + if (durationType.equals(BuiltinTypesCatalogue.durationItem)) { return durationPattern.matcher(duration).matches(); } - if (durationType.equals(AtomicItemType.yearMonthDurationItem)) { + if (durationType.equals(BuiltinTypesCatalogue.yearMonthDurationItem)) { return yearMonthDurationPattern.matcher(duration).matches(); } - if (durationType.equals(AtomicItemType.dayTimeDurationItem)) { + if (durationType.equals(BuiltinTypesCatalogue.dayTimeDurationItem)) { return dayTimeDurationPattern.matcher(duration).matches(); } return false; @@ -215,6 +216,6 @@ public static Period getDurationFromString(String duration, ItemType durationTyp @Override public ItemType getDynamicType() { - return AtomicItemType.durationItem; + return BuiltinTypesCatalogue.durationItem; } } diff --git a/src/main/java/org/rumbledb/items/FloatItem.java b/src/main/java/org/rumbledb/items/FloatItem.java index fead2593a0..b63ae41ade 100644 --- a/src/main/java/org/rumbledb/items/FloatItem.java +++ b/src/main/java/org/rumbledb/items/FloatItem.java @@ -30,6 +30,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.math.BigDecimal; import java.math.BigInteger; @@ -140,7 +141,7 @@ public int hashCode() { @Override public ItemType getDynamicType() { - return AtomicItemType.floatItem; + return BuiltinTypesCatalogue.floatItem; } @Override diff --git a/src/main/java/org/rumbledb/items/FunctionItem.java b/src/main/java/org/rumbledb/items/FunctionItem.java index 49bad50296..6e2a674dff 100644 --- a/src/main/java/org/rumbledb/items/FunctionItem.java +++ b/src/main/java/org/rumbledb/items/FunctionItem.java @@ -281,7 +281,7 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return FunctionItemType.ANYFUNCTION; + return BuiltinTypesCatalogue.anyFunctionItem; } public FunctionItem deepCopy() { diff --git a/src/main/java/org/rumbledb/items/HexBinaryItem.java b/src/main/java/org/rumbledb/items/HexBinaryItem.java index af9aba8109..8e2fda8200 100644 --- a/src/main/java/org/rumbledb/items/HexBinaryItem.java +++ b/src/main/java/org/rumbledb/items/HexBinaryItem.java @@ -10,6 +10,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.util.Arrays; import java.util.regex.Pattern; @@ -117,7 +118,7 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return AtomicItemType.hexBinaryItem; + return BuiltinTypesCatalogue.hexBinaryItem; } @Override diff --git a/src/main/java/org/rumbledb/items/IntItem.java b/src/main/java/org/rumbledb/items/IntItem.java index 79a815af23..4b0cadd31f 100644 --- a/src/main/java/org/rumbledb/items/IntItem.java +++ b/src/main/java/org/rumbledb/items/IntItem.java @@ -30,6 +30,7 @@ import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.math.BigDecimal; import java.math.BigInteger; @@ -144,12 +145,12 @@ public int hashCode() { @Override public ItemType getDynamicType() { - return AtomicItemType.integerItem; + return BuiltinTypesCatalogue.integerItem; } @Override public NativeClauseContext generateNativeQuery(NativeClauseContext context) { - return new NativeClauseContext(context, "" + this.value, AtomicItemType.intItem); + return new NativeClauseContext(context, "" + this.value, BuiltinTypesCatalogue.intItem); } public boolean isNumeric() { diff --git a/src/main/java/org/rumbledb/items/IntegerItem.java b/src/main/java/org/rumbledb/items/IntegerItem.java index 92c4c80069..91cab950ce 100644 --- a/src/main/java/org/rumbledb/items/IntegerItem.java +++ b/src/main/java/org/rumbledb/items/IntegerItem.java @@ -29,6 +29,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.math.BigDecimal; import java.math.BigInteger; @@ -133,12 +134,12 @@ public int hashCode() { @Override public ItemType getDynamicType() { - return AtomicItemType.integerItem; + return BuiltinTypesCatalogue.integerItem; } @Override public NativeClauseContext generateNativeQuery(NativeClauseContext context) { - return new NativeClauseContext(context, this.value.toString(), AtomicItemType.integerItem); + return new NativeClauseContext(context, this.value.toString(), BuiltinTypesCatalogue.integerItem); } public boolean isNumeric() { diff --git a/src/main/java/org/rumbledb/items/NullItem.java b/src/main/java/org/rumbledb/items/NullItem.java index 6c1f182bdb..e3328f85b2 100644 --- a/src/main/java/org/rumbledb/items/NullItem.java +++ b/src/main/java/org/rumbledb/items/NullItem.java @@ -44,6 +44,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.ItemType; @@ -102,7 +103,7 @@ public int hashCode() { @Override public ItemType getDynamicType() { - return AtomicItemType.nullItem; + return BuiltinTypesCatalogue.nullItem; } @Override diff --git a/src/main/java/org/rumbledb/items/ObjectItem.java b/src/main/java/org/rumbledb/items/ObjectItem.java index 7f070d6609..1b359d3f69 100644 --- a/src/main/java/org/rumbledb/items/ObjectItem.java +++ b/src/main/java/org/rumbledb/items/ObjectItem.java @@ -28,6 +28,7 @@ import org.rumbledb.exceptions.DuplicateObjectKeyException; import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.util.ArrayList; import java.util.HashMap; @@ -209,7 +210,7 @@ public int hashCode() { @Override public ItemType getDynamicType() { - return AtomicItemType.objectItem; + return BuiltinTypesCatalogue.objectItem; } @Override diff --git a/src/main/java/org/rumbledb/items/StringItem.java b/src/main/java/org/rumbledb/items/StringItem.java index e0150c6dd9..5d4944c862 100644 --- a/src/main/java/org/rumbledb/items/StringItem.java +++ b/src/main/java/org/rumbledb/items/StringItem.java @@ -30,6 +30,7 @@ import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.math.BigDecimal; import java.math.BigInteger; @@ -141,12 +142,12 @@ public int hashCode() { @Override public ItemType getDynamicType() { - return AtomicItemType.stringItem; + return BuiltinTypesCatalogue.stringItem; } @Override public NativeClauseContext generateNativeQuery(NativeClauseContext context) { - return new NativeClauseContext(context, '"' + this.value + '"', AtomicItemType.stringItem); + return new NativeClauseContext(context, '"' + this.value + '"', BuiltinTypesCatalogue.stringItem); } @Override diff --git a/src/main/java/org/rumbledb/items/TimeItem.java b/src/main/java/org/rumbledb/items/TimeItem.java index ff271b5efa..5bbb34d104 100644 --- a/src/main/java/org/rumbledb/items/TimeItem.java +++ b/src/main/java/org/rumbledb/items/TimeItem.java @@ -10,6 +10,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; @@ -30,7 +31,7 @@ public TimeItem() { } TimeItem(String dateTimeString) { - this.value = DateTimeItem.parseDateTime(dateTimeString, AtomicItemType.timeItem); + this.value = DateTimeItem.parseDateTime(dateTimeString, BuiltinTypesCatalogue.timeItem); if (!dateTimeString.endsWith("Z") && this.value.getZone() == DateTimeZone.getDefault()) { this.hasTimeZone = false; this.value = this.value.withZoneRetainFields(DateTimeZone.UTC); @@ -112,7 +113,7 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return AtomicItemType.timeItem; + return BuiltinTypesCatalogue.timeItem; } @Override diff --git a/src/main/java/org/rumbledb/items/YearMonthDurationItem.java b/src/main/java/org/rumbledb/items/YearMonthDurationItem.java index 7c45dca146..a58f112f03 100644 --- a/src/main/java/org/rumbledb/items/YearMonthDurationItem.java +++ b/src/main/java/org/rumbledb/items/YearMonthDurationItem.java @@ -7,6 +7,7 @@ import org.joda.time.Period; import org.joda.time.PeriodType; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; @@ -45,7 +46,7 @@ public boolean isYearMonthDuration() { @Override public void read(Kryo kryo, Input input) { - this.value = getDurationFromString(input.readString(), AtomicItemType.yearMonthDurationItem).normalizedStandard( + this.value = getDurationFromString(input.readString(), BuiltinTypesCatalogue.yearMonthDurationItem).normalizedStandard( yearMonthPeriodType ); this.isNegative = this.value.toString().contains("-"); @@ -53,7 +54,7 @@ public void read(Kryo kryo, Input input) { @Override public ItemType getDynamicType() { - return AtomicItemType.yearMonthDurationItem; + return BuiltinTypesCatalogue.yearMonthDurationItem; } diff --git a/src/main/java/org/rumbledb/items/parsing/ItemParser.java b/src/main/java/org/rumbledb/items/parsing/ItemParser.java index 66a8b4285d..fe75cc1a12 100644 --- a/src/main/java/org/rumbledb/items/parsing/ItemParser.java +++ b/src/main/java/org/rumbledb/items/parsing/ItemParser.java @@ -46,6 +46,7 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import scala.collection.mutable.WrappedArray; import sparksoniq.spark.SparkSessionManager; @@ -151,37 +152,37 @@ public static Item convertValueToItem( public static ItemType convertDataTypeToItemType(DataType dt) { if (dt instanceof StructType) { - return AtomicItemType.objectItem; + return BuiltinTypesCatalogue.objectItem; } if (dt instanceof ArrayType) { - return AtomicItemType.arrayItem; + return BuiltinTypesCatalogue.arrayItem; } if (dt.equals(DataTypes.StringType)) { - return AtomicItemType.stringItem; + return BuiltinTypesCatalogue.stringItem; } else if (dt.equals(DataTypes.BooleanType)) { - return AtomicItemType.booleanItem; + return BuiltinTypesCatalogue.booleanItem; } else if (dt.equals(DataTypes.DoubleType)) { - return AtomicItemType.doubleItem; + return BuiltinTypesCatalogue.doubleItem; } else if (dt.equals(DataTypes.IntegerType)) { - return AtomicItemType.integerItem; + return BuiltinTypesCatalogue.integerItem; } else if (dt.equals(DataTypes.FloatType)) { - return AtomicItemType.floatItem; + return BuiltinTypesCatalogue.floatItem; } else if (dt.equals(decimalType)) { - return AtomicItemType.decimalItem; + return BuiltinTypesCatalogue.decimalItem; } else if (dt.equals(DataTypes.LongType)) { - return AtomicItemType.integerItem; + return BuiltinTypesCatalogue.integerItem; } else if (dt.equals(DataTypes.NullType)) { - return AtomicItemType.nullItem; + return BuiltinTypesCatalogue.nullItem; } else if (dt.equals(DataTypes.ShortType)) { - return AtomicItemType.integerItem; + return BuiltinTypesCatalogue.integerItem; } else if (dt.equals(DataTypes.TimestampType)) { - return AtomicItemType.dateTimeItem; + return BuiltinTypesCatalogue.dateTimeItem; } else if (dt.equals(DataTypes.DateType)) { - return AtomicItemType.dateItem; + return BuiltinTypesCatalogue.dateItem; } else if (dt.equals(DataTypes.BinaryType)) { - return AtomicItemType.hexBinaryItem; + return BuiltinTypesCatalogue.hexBinaryItem; } else if (dt instanceof VectorUDT) { - return AtomicItemType.arrayItem; + return BuiltinTypesCatalogue.arrayItem; } throw new OurBadException("DataFrame type unsupported: " + dt); } @@ -351,37 +352,37 @@ private static Item convertValueToItem( } public static DataType getDataFrameDataTypeFromItemType(ItemType itemType) { - if (itemType.equals(AtomicItemType.booleanItem)) { + if (itemType.equals(BuiltinTypesCatalogue.booleanItem)) { return DataTypes.BooleanType; } - if (itemType.equals(AtomicItemType.integerItem)) { + if (itemType.equals(BuiltinTypesCatalogue.integerItem)) { return DataTypes.IntegerType; } - if (itemType.equals(AtomicItemType.doubleItem)) { + if (itemType.equals(BuiltinTypesCatalogue.doubleItem)) { return DataTypes.DoubleType; } - if (itemType.equals(AtomicItemType.floatItem)) { + if (itemType.equals(BuiltinTypesCatalogue.floatItem)) { return DataTypes.FloatType; } - if (itemType.equals(AtomicItemType.decimalItem)) { + if (itemType.equals(BuiltinTypesCatalogue.decimalItem)) { return decimalType; } - if (itemType.equals(AtomicItemType.stringItem)) { + if (itemType.equals(BuiltinTypesCatalogue.stringItem)) { return DataTypes.StringType; } - if (itemType.equals(AtomicItemType.nullItem)) { + if (itemType.equals(BuiltinTypesCatalogue.nullItem)) { return DataTypes.NullType; } - if (itemType.equals(AtomicItemType.dateItem)) { + if (itemType.equals(BuiltinTypesCatalogue.dateItem)) { return DataTypes.DateType; } - if (itemType.equals(AtomicItemType.dateTimeItem)) { + if (itemType.equals(BuiltinTypesCatalogue.dateTimeItem)) { return DataTypes.TimestampType; } - if (itemType.equals(AtomicItemType.hexBinaryItem)) { + if (itemType.equals(BuiltinTypesCatalogue.hexBinaryItem)) { return DataTypes.BinaryType; } - if (itemType.equals(AtomicItemType.objectItem)) { + if (itemType.equals(BuiltinTypesCatalogue.objectItem)) { return vectorType; } throw new IllegalArgumentException( @@ -391,37 +392,37 @@ public static DataType getDataFrameDataTypeFromItemType(ItemType itemType) { public static Name getItemTypeNameFromDataFrameDataType(DataType dataType) { if (DataTypes.BooleanType.equals(dataType)) { - return AtomicItemType.booleanItem.getName(); + return BuiltinTypesCatalogue.booleanItem.getName(); } if (DataTypes.IntegerType.equals(dataType) || DataTypes.ShortType.equals(dataType)) { - return AtomicItemType.integerItem.getName(); + return BuiltinTypesCatalogue.integerItem.getName(); } if (DataTypes.DoubleType.equals(dataType)) { - return AtomicItemType.doubleItem.getName(); + return BuiltinTypesCatalogue.doubleItem.getName(); } if (DataTypes.FloatType.equals(dataType)) { - return AtomicItemType.floatItem.getName(); + return BuiltinTypesCatalogue.floatItem.getName(); } if (dataType.equals(decimalType) || DataTypes.LongType.equals(dataType)) { - return AtomicItemType.decimalItem.getName(); + return BuiltinTypesCatalogue.decimalItem.getName(); } if (DataTypes.StringType.equals(dataType)) { - return AtomicItemType.stringItem.getName(); + return BuiltinTypesCatalogue.stringItem.getName(); } if (DataTypes.NullType.equals(dataType)) { - return AtomicItemType.nullItem.getName(); + return BuiltinTypesCatalogue.nullItem.getName(); } if (DataTypes.DateType.equals(dataType)) { - return AtomicItemType.dateItem.getName(); + return BuiltinTypesCatalogue.dateItem.getName(); } if (DataTypes.TimestampType.equals(dataType)) { - return AtomicItemType.dateTimeItem.getName(); + return BuiltinTypesCatalogue.dateTimeItem.getName(); } if (DataTypes.BinaryType.equals(dataType)) { - return AtomicItemType.hexBinaryItem.getName(); + return BuiltinTypesCatalogue.hexBinaryItem.getName(); } if (vectorType.equals(dataType)) { - return AtomicItemType.objectItem.getName(); + return BuiltinTypesCatalogue.objectItem.getName(); } throw new OurBadException("Unexpected DataFrame data type found: '" + dataType.toString() + "'."); } @@ -493,7 +494,7 @@ private static Object getRowColumnFromItemUsingDataType(Item item, DataType data if (!item.isBoolean()) { Item i = CastIterator.castItemToType( item, - AtomicItemType.booleanItem, + BuiltinTypesCatalogue.booleanItem, ExceptionMetadata.EMPTY_METADATA ); if (i == null) { @@ -509,7 +510,7 @@ private static Object getRowColumnFromItemUsingDataType(Item item, DataType data if (!item.isInt()) { Item i = CastIterator.castItemToType( item, - AtomicItemType.intItem, + BuiltinTypesCatalogue.intItem, ExceptionMetadata.EMPTY_METADATA ); if (i == null) { @@ -525,7 +526,7 @@ private static Object getRowColumnFromItemUsingDataType(Item item, DataType data if (!item.isDouble()) { Item i = CastIterator.castItemToType( item, - AtomicItemType.doubleItem, + BuiltinTypesCatalogue.doubleItem, ExceptionMetadata.EMPTY_METADATA ); if (i == null) { @@ -541,7 +542,7 @@ private static Object getRowColumnFromItemUsingDataType(Item item, DataType data if (!item.isFloat()) { Item i = CastIterator.castItemToType( item, - AtomicItemType.floatItem, + BuiltinTypesCatalogue.floatItem, ExceptionMetadata.EMPTY_METADATA ); if (i == null) { @@ -557,7 +558,7 @@ private static Object getRowColumnFromItemUsingDataType(Item item, DataType data if (!item.isDecimal()) { Item i = CastIterator.castItemToType( item, - AtomicItemType.decimalItem, + BuiltinTypesCatalogue.decimalItem, ExceptionMetadata.EMPTY_METADATA ); if (i == null) { @@ -573,7 +574,7 @@ private static Object getRowColumnFromItemUsingDataType(Item item, DataType data if (!item.isString()) { Item i = CastIterator.castItemToType( item, - AtomicItemType.stringItem, + BuiltinTypesCatalogue.stringItem, ExceptionMetadata.EMPTY_METADATA ); if (i == null) { @@ -589,7 +590,7 @@ private static Object getRowColumnFromItemUsingDataType(Item item, DataType data if (!item.isNull()) { Item i = CastIterator.castItemToType( item, - AtomicItemType.nullItem, + BuiltinTypesCatalogue.nullItem, ExceptionMetadata.EMPTY_METADATA ); if (i == null) { @@ -605,7 +606,7 @@ private static Object getRowColumnFromItemUsingDataType(Item item, DataType data if (!item.isDate()) { Item i = CastIterator.castItemToType( item, - AtomicItemType.dateItem, + BuiltinTypesCatalogue.dateItem, ExceptionMetadata.EMPTY_METADATA ); if (i == null) { @@ -621,7 +622,7 @@ private static Object getRowColumnFromItemUsingDataType(Item item, DataType data if (!item.isDateTime()) { Item i = CastIterator.castItemToType( item, - AtomicItemType.dateTimeItem, + BuiltinTypesCatalogue.dateTimeItem, ExceptionMetadata.EMPTY_METADATA ); if (i == null) { diff --git a/src/main/java/org/rumbledb/runtime/AtMostOneItemLocalRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/AtMostOneItemLocalRuntimeIterator.java index 885ccd4a5c..986ee438ec 100644 --- a/src/main/java/org/rumbledb/runtime/AtMostOneItemLocalRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/AtMostOneItemLocalRuntimeIterator.java @@ -32,6 +32,7 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import java.math.BigDecimal; import java.math.BigInteger; @@ -156,7 +157,7 @@ public boolean getEffectiveBooleanValueOrCheckPosition(DynamicContext dynamicCon if (item.isNull()) { return false; } - if (item.getDynamicType().canBePromotedTo(AtomicItemType.stringItem)) { + if (item.getDynamicType().canBePromotedTo(BuiltinTypesCatalogue.stringItem)) { return !item.getStringValue().isEmpty(); } if (item.isObject()) { diff --git a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java index 547a78e8a3..48dc1eb029 100644 --- a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java @@ -35,6 +35,7 @@ import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; import java.io.ByteArrayInputStream; @@ -131,7 +132,7 @@ public boolean getEffectiveBooleanValueOrCheckPosition(DynamicContext dynamicCon } } else if (item.isNull()) { result = false; - } else if (item.getDynamicType().canBePromotedTo(AtomicItemType.stringItem)) { + } else if (item.getDynamicType().canBePromotedTo(BuiltinTypesCatalogue.stringItem)) { result = !item.getStringValue().isEmpty(); } else if (item.isObject()) { this.close(); diff --git a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java index c7b573634d..9d44bf9ccf 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java +++ b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java @@ -54,6 +54,7 @@ import org.rumbledb.items.TimeItem; import org.rumbledb.items.YearMonthDurationItem; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -390,14 +391,14 @@ public static StructType escapeSchema(StructType schema, boolean inverse) { public static ItemType mapToJsoniqType(DataType type) { // TODO: once type mapping is defined add string field to determine and document properly if (type == DataTypes.StringType) { - return AtomicItemType.stringItem; + return BuiltinTypesCatalogue.stringItem; } else if (type == DataTypes.IntegerType) { - return AtomicItemType.integerItem; + return BuiltinTypesCatalogue.integerItem; } else if (type.equals(DataTypes.createDecimalType())) { // TODO: test correct working - return AtomicItemType.integerItem; + return BuiltinTypesCatalogue.integerItem; } else if (type == DataTypes.DoubleType) { - return AtomicItemType.doubleItem; + return BuiltinTypesCatalogue.doubleItem; } else { return null; } diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index 541350023f..a879a741e3 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -47,6 +47,7 @@ import org.rumbledb.runtime.postfix.PredicateIterator; import org.rumbledb.runtime.primary.VariableReferenceIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -632,7 +633,7 @@ private static void registerLetClauseUDF( ) { ItemType itemType = sequenceType.getItemType(); - if (itemType.equals(AtomicItemType.stringItem)) { + if (itemType.equals(BuiltinTypesCatalogue.stringItem)) { dataFrame.sparkSession() .udf() .register( @@ -649,7 +650,7 @@ private static void registerLetClauseUDF( return; } - if (itemType.equals(AtomicItemType.integerItem)) { + if (itemType.equals(BuiltinTypesCatalogue.integerItem)) { dataFrame.sparkSession() .udf() .register( @@ -666,7 +667,7 @@ private static void registerLetClauseUDF( return; } - if (itemType.equals(AtomicItemType.decimalItem)) { + if (itemType.equals(BuiltinTypesCatalogue.decimalItem)) { dataFrame.sparkSession() .udf() .register( @@ -683,7 +684,7 @@ private static void registerLetClauseUDF( return; } - if (itemType.equals(AtomicItemType.doubleItem)) { + if (itemType.equals(BuiltinTypesCatalogue.doubleItem)) { dataFrame.sparkSession() .udf() .register( diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index 5f46744a44..d92e223e73 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -46,6 +46,7 @@ import org.rumbledb.runtime.flwor.udfs.OrderClauseCreateColumnsUDF; import org.rumbledb.runtime.flwor.udfs.OrderClauseDetermineTypeUDF; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import sparksoniq.jsoniq.tuple.FlworKey; import sparksoniq.jsoniq.tuple.FlworKeyComparator; @@ -290,46 +291,46 @@ public Dataset getDataFrame( String typeString = (String) columnsTypesOfRowAsList.get(columnIndex); boolean isEmptySequence = typeString.contentEquals(StringFlagForEmptySequence); if (!isEmptySequence) { - Name columnType = AtomicItemType.getItemTypeByName( + Name columnType = BuiltinTypesCatalogue.getItemTypeByName( Name.createVariableInDefaultTypeNamespace(typeString) ).getName(); if ( - !columnType.equals(AtomicItemType.nullItem.getName()) + !columnType.equals(BuiltinTypesCatalogue.nullItem.getName()) ) { Name currentColumnType = typesForAllColumns.get(columnIndex); if (currentColumnType == null) { typesForAllColumns.put(columnIndex, columnType); } else if ( - (currentColumnType.equals(AtomicItemType.integerItem.getName()) - || currentColumnType.equals(AtomicItemType.doubleItem.getName()) - || currentColumnType.equals(AtomicItemType.decimalItem.getName())) - && (columnType.equals(AtomicItemType.integerItem.getName()) - || columnType.equals(AtomicItemType.doubleItem.getName()) - || columnType.equals(AtomicItemType.decimalItem.getName())) + (currentColumnType.equals(BuiltinTypesCatalogue.integerItem.getName()) + || currentColumnType.equals(BuiltinTypesCatalogue.doubleItem.getName()) + || currentColumnType.equals(BuiltinTypesCatalogue.decimalItem.getName())) + && (columnType.equals(BuiltinTypesCatalogue.integerItem.getName()) + || columnType.equals(BuiltinTypesCatalogue.doubleItem.getName()) + || columnType.equals(BuiltinTypesCatalogue.decimalItem.getName())) ) { // the numeric type calculation is identical to Item::getNumericResultType() if ( - currentColumnType.equals(AtomicItemType.doubleItem.getName()) - || columnType.equals(AtomicItemType.doubleItem.getName()) + currentColumnType.equals(BuiltinTypesCatalogue.doubleItem.getName()) + || columnType.equals(BuiltinTypesCatalogue.doubleItem.getName()) ) { - typesForAllColumns.put(columnIndex, AtomicItemType.doubleItem.getName()); + typesForAllColumns.put(columnIndex, BuiltinTypesCatalogue.doubleItem.getName()); } else if ( - currentColumnType.equals(AtomicItemType.decimalItem.getName()) - || columnType.equals(AtomicItemType.decimalItem.getName()) + currentColumnType.equals(BuiltinTypesCatalogue.decimalItem.getName()) + || columnType.equals(BuiltinTypesCatalogue.decimalItem.getName()) ) { - typesForAllColumns.put(columnIndex, AtomicItemType.decimalItem.getName()); + typesForAllColumns.put(columnIndex, BuiltinTypesCatalogue.decimalItem.getName()); } else { // do nothing, type is already set to integer } } else if ( - (currentColumnType.equals(AtomicItemType.dayTimeDurationItem.getName()) - || currentColumnType.equals(AtomicItemType.yearMonthDurationItem.getName()) - || currentColumnType.equals(AtomicItemType.durationItem.getName())) - && (columnType.equals(AtomicItemType.dayTimeDurationItem.getName()) - || columnType.equals(AtomicItemType.yearMonthDurationItem.getName()) - || columnType.equals(AtomicItemType.durationItem.getName())) + (currentColumnType.equals(BuiltinTypesCatalogue.dayTimeDurationItem.getName()) + || currentColumnType.equals(BuiltinTypesCatalogue.yearMonthDurationItem.getName()) + || currentColumnType.equals(BuiltinTypesCatalogue.durationItem.getName())) + && (columnType.equals(BuiltinTypesCatalogue.dayTimeDurationItem.getName()) + || columnType.equals(BuiltinTypesCatalogue.yearMonthDurationItem.getName()) + || columnType.equals(BuiltinTypesCatalogue.durationItem.getName())) ) { - typesForAllColumns.put(columnIndex, AtomicItemType.durationItem.getName()); + typesForAllColumns.put(columnIndex, BuiltinTypesCatalogue.durationItem.getName()); } else if (!currentColumnType.equals(columnType)) { throw new UnexpectedTypeException( "Order by variable must contain values of a single type.", @@ -358,24 +359,24 @@ public Dataset getDataFrame( columnName = columnIndex + "-valueField"; if (columnTypeString == null) { columnType = DataTypes.BooleanType; - } else if (columnTypeString.equals(AtomicItemType.booleanItem.getName())) { + } else if (columnTypeString.equals(BuiltinTypesCatalogue.booleanItem.getName())) { columnType = DataTypes.BooleanType; - } else if (columnTypeString.equals(AtomicItemType.stringItem.getName())) { + } else if (columnTypeString.equals(BuiltinTypesCatalogue.stringItem.getName())) { columnType = DataTypes.StringType; - } else if (columnTypeString.equals(AtomicItemType.integerItem.getName())) { + } else if (columnTypeString.equals(BuiltinTypesCatalogue.integerItem.getName())) { columnType = DataTypes.IntegerType; - } else if (columnTypeString.equals(AtomicItemType.doubleItem.getName())) { + } else if (columnTypeString.equals(BuiltinTypesCatalogue.doubleItem.getName())) { columnType = DataTypes.DoubleType; - } else if (columnTypeString.equals(AtomicItemType.decimalItem.getName())) { + } else if (columnTypeString.equals(BuiltinTypesCatalogue.decimalItem.getName())) { columnType = decimalType; // columnType = DataTypes.createDecimalType(); } else if ( - columnTypeString.equals(AtomicItemType.durationItem.getName()) - || columnTypeString.equals(AtomicItemType.yearMonthDurationItem.getName()) - || columnTypeString.equals(AtomicItemType.dayTimeDurationItem.getName()) - || columnTypeString.equals(AtomicItemType.dateTimeItem.getName()) - || columnTypeString.equals(AtomicItemType.dateItem.getName()) - || columnTypeString.equals(AtomicItemType.timeItem.getName()) + columnTypeString.equals(BuiltinTypesCatalogue.durationItem.getName()) + || columnTypeString.equals(BuiltinTypesCatalogue.yearMonthDurationItem.getName()) + || columnTypeString.equals(BuiltinTypesCatalogue.dayTimeDurationItem.getName()) + || columnTypeString.equals(BuiltinTypesCatalogue.dateTimeItem.getName()) + || columnTypeString.equals(BuiltinTypesCatalogue.dateItem.getName()) + || columnTypeString.equals(BuiltinTypesCatalogue.timeItem.getName()) ) { columnType = DataTypes.LongType; } else { @@ -534,8 +535,8 @@ public static Dataset tryNativeQuery( // because of meaning mismatch between sparksql (where it is supposed to order by the i-th col) // and jsoniq (order by a costant, so no actual ordering is performed) if ( - nativeQuery.getResultingType() == AtomicItemType.integerItem - || nativeQuery.getResultingType() == AtomicItemType.intItem + nativeQuery.getResultingType() == BuiltinTypesCatalogue.integerItem + || nativeQuery.getResultingType() == BuiltinTypesCatalogue.intItem ) { orderSql.append('"'); orderSql.append(nativeQuery.getResultingQuery()); diff --git a/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java b/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java index 1ab71c9281..059180c123 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java +++ b/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java @@ -34,6 +34,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.expression.OrderByClauseAnnotatedChildIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -118,28 +119,28 @@ private void createColumnsForItem(Item nextItem, int expressionIndex) { // extract type information for the sorting column Name typeName = this.sortingKeyTypes.get(expressionIndex); try { - if (typeName.equals(AtomicItemType.booleanItem.getName())) { + if (typeName.equals(BuiltinTypesCatalogue.booleanItem.getName())) { this.results.add(nextItem.getBooleanValue()); - } else if (typeName.equals(AtomicItemType.stringItem.getName())) { + } else if (typeName.equals(BuiltinTypesCatalogue.stringItem.getName())) { this.results.add(nextItem.getStringValue()); - } else if (typeName.equals(AtomicItemType.integerItem.getName())) { + } else if (typeName.equals(BuiltinTypesCatalogue.integerItem.getName())) { this.results.add(nextItem.castToIntValue()); - } else if (typeName.equals(AtomicItemType.doubleItem.getName())) { + } else if (typeName.equals(BuiltinTypesCatalogue.doubleItem.getName())) { this.results.add(nextItem.castToDoubleValue()); - } else if (typeName.equals(AtomicItemType.decimalItem.getName())) { + } else if (typeName.equals(BuiltinTypesCatalogue.decimalItem.getName())) { this.results.add(nextItem.castToDecimalValue()); } else if ( - typeName.equals(AtomicItemType.durationItem.getName()) - || typeName.equals(AtomicItemType.yearMonthDurationItem.getName()) - || typeName.equals(AtomicItemType.dayTimeDurationItem.getName()) + typeName.equals(BuiltinTypesCatalogue.durationItem.getName()) + || typeName.equals(BuiltinTypesCatalogue.yearMonthDurationItem.getName()) + || typeName.equals(BuiltinTypesCatalogue.dayTimeDurationItem.getName()) ) { this.results.add( nextItem.getDurationValue().toDurationFrom(Instant.now()).getMillis() ); } else if ( - typeName.equals(AtomicItemType.dateTimeItem.getName()) - || typeName.equals(AtomicItemType.dateItem.getName()) - || typeName.equals(AtomicItemType.timeItem.getName()) + typeName.equals(BuiltinTypesCatalogue.dateTimeItem.getName()) + || typeName.equals(BuiltinTypesCatalogue.dateItem.getName()) + || typeName.equals(BuiltinTypesCatalogue.timeItem.getName()) ) { this.results.add(nextItem.getDateTimeValue().getMillis()); } else { diff --git a/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java index 4761737bd5..4cf6c30efd 100644 --- a/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java @@ -12,6 +12,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import java.util.List; public class DayTimeDurationFunctionIterator extends LocalFunctionCallIterator { @@ -34,7 +35,7 @@ public Item next() { try { Period period = DurationItem.getDurationFromString( this.durationStringItem.getStringValue(), - AtomicItemType.dayTimeDurationItem + BuiltinTypesCatalogue.dayTimeDurationItem ); return ItemFactory.getInstance().createDayTimeDurationItem(period); } catch (UnsupportedOperationException | IllegalArgumentException e) { diff --git a/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java index 0cfc629e1d..2e19693fc3 100644 --- a/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java @@ -12,6 +12,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import java.util.List; public class DurationFunctionIterator extends LocalFunctionCallIterator { @@ -34,7 +35,7 @@ public Item next() { try { Period period = DurationItem.getDurationFromString( this.durationStringItem.getStringValue(), - AtomicItemType.durationItem + BuiltinTypesCatalogue.durationItem ); return ItemFactory.getInstance().createDurationItem(period); } catch (UnsupportedOperationException | IllegalArgumentException e) { diff --git a/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java index 31219df2e1..b16bd8bcd6 100644 --- a/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java @@ -12,6 +12,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import java.util.List; public class YearMonthDurationFunctionIterator extends LocalFunctionCallIterator { @@ -34,7 +35,7 @@ public Item next() { try { Period period = DurationItem.getDurationFromString( this.durationStringItem.getStringValue(), - AtomicItemType.yearMonthDurationItem + BuiltinTypesCatalogue.yearMonthDurationItem ); return ItemFactory.getInstance().createYearMonthDurationItem(period); } catch (UnsupportedOperationException | IllegalArgumentException e) { diff --git a/src/main/java/org/rumbledb/runtime/functions/numerics/NumberFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/numerics/NumberFunctionIterator.java index 09a1887b1c..e622516b03 100644 --- a/src/main/java/org/rumbledb/runtime/functions/numerics/NumberFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/numerics/NumberFunctionIterator.java @@ -29,6 +29,7 @@ import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.runtime.typing.CastIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import java.util.List; public class NumberFunctionIterator extends LocalFunctionCallIterator { @@ -52,7 +53,7 @@ public Item next() { return ItemFactory.getInstance().createDoubleItem(Double.NaN); } - Item result = CastIterator.castItemToType(anyItem, AtomicItemType.doubleItem, getMetadata()); + Item result = CastIterator.castItemToType(anyItem, BuiltinTypesCatalogue.doubleItem, getMetadata()); if (result != null) { return result; } diff --git a/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java index 39e8878a4d..4bd40ab773 100644 --- a/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java @@ -31,6 +31,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; public class AndOperationIterator extends AtMostOneItemLocalRuntimeIterator { @@ -81,6 +82,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC + " AND " + rightResult.getResultingQuery() + " )"; - return new NativeClauseContext(nativeClauseContext, resultingQuery, AtomicItemType.booleanItem); + return new NativeClauseContext(nativeClauseContext, resultingQuery, BuiltinTypesCatalogue.booleanItem); } } diff --git a/src/main/java/org/rumbledb/runtime/operational/ComparisonIterator.java b/src/main/java/org/rumbledb/runtime/operational/ComparisonIterator.java index 6ac328cb48..7baa31e149 100644 --- a/src/main/java/org/rumbledb/runtime/operational/ComparisonIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/ComparisonIterator.java @@ -38,6 +38,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import java.math.BigDecimal; import java.math.BigInteger; @@ -506,7 +507,7 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC break; } String query = "( " + leftResult.getResultingQuery() + operator + rightResult.getResultingQuery() + " )"; - return new NativeClauseContext(nativeClauseContext, query, AtomicItemType.booleanItem); + return new NativeClauseContext(nativeClauseContext, query, BuiltinTypesCatalogue.booleanItem); } else { return NativeClauseContext.NoNativeQuery; } diff --git a/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java index 57bd13b82f..60433ae022 100644 --- a/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java @@ -31,6 +31,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; public class NotOperationIterator extends AtMostOneItemLocalRuntimeIterator { @@ -60,6 +61,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC } String resultingQuery = "( NOT " + childResult.getResultingQuery() + " )"; - return new NativeClauseContext(nativeClauseContext, resultingQuery, AtomicItemType.booleanItem); + return new NativeClauseContext(nativeClauseContext, resultingQuery, BuiltinTypesCatalogue.booleanItem); } } diff --git a/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java index af9e4e7b27..2abc8da4b3 100644 --- a/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java @@ -31,6 +31,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; public class OrOperationIterator extends AtMostOneItemLocalRuntimeIterator { @@ -67,6 +68,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC } String resultingQuery = "( " + leftResult.getResultingQuery() + " OR " + rightResult.getResultingQuery() + " )"; - return new NativeClauseContext(nativeClauseContext, resultingQuery, AtomicItemType.booleanItem); + return new NativeClauseContext(nativeClauseContext, resultingQuery, BuiltinTypesCatalogue.booleanItem); } } diff --git a/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java index b92321fcd2..ca968f6e50 100644 --- a/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java @@ -27,6 +27,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import java.math.BigDecimal; @@ -52,7 +53,7 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC return new NativeClauseContext( nativeClauseContext, "" + this.item.getDecimalValue(), - AtomicItemType.decimalItem + BuiltinTypesCatalogue.decimalItem ); } } diff --git a/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java index a8d71aa962..9884462f78 100644 --- a/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java @@ -27,6 +27,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; public class DoubleRuntimeIterator extends AtMostOneItemLocalRuntimeIterator { @@ -48,6 +49,6 @@ public Item materializeFirstItemOrNull(DynamicContext context) { @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - return new NativeClauseContext(nativeClauseContext, "" + this.item.getDoubleValue(), AtomicItemType.doubleItem); + return new NativeClauseContext(nativeClauseContext, "" + this.item.getDoubleValue(), BuiltinTypesCatalogue.doubleItem); } } diff --git a/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java index f10b8a49c7..ad7f098abd 100644 --- a/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java @@ -27,6 +27,7 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; public class IntegerRuntimeIterator extends AtMostOneItemLocalRuntimeIterator { @@ -51,6 +52,6 @@ public Item materializeFirstItemOrNull(DynamicContext context) { @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - return new NativeClauseContext(nativeClauseContext, "" + this.item.getIntValue(), AtomicItemType.integerItem); + return new NativeClauseContext(nativeClauseContext, "" + this.item.getIntValue(), BuiltinTypesCatalogue.integerItem); } } diff --git a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java index 9083ebad4e..74c333de34 100644 --- a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java @@ -29,6 +29,7 @@ import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; public class StringRuntimeIterator extends AtMostOneItemLocalRuntimeIterator { @@ -50,7 +51,7 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC return new NativeClauseContext( nativeClauseContext, '"' + this.item.getStringValue() + '"', - AtomicItemType.stringItem + BuiltinTypesCatalogue.stringItem ); } } diff --git a/src/main/java/org/rumbledb/runtime/typing/CastIterator.java b/src/main/java/org/rumbledb/runtime/typing/CastIterator.java index 747054e8cf..e1c28eb43e 100644 --- a/src/main/java/org/rumbledb/runtime/typing/CastIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/CastIterator.java @@ -14,6 +14,7 @@ import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; @@ -98,17 +99,17 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad return item; } - if (targetType.equals(AtomicItemType.nullItem)) { + if (targetType.equals(BuiltinTypesCatalogue.nullItem)) { if (item.isString() && item.getStringValue().trim().equals("null")) { return ItemFactory.getInstance().createNullItem(); } } - if (targetType.equals(AtomicItemType.stringItem)) { + if (targetType.equals(BuiltinTypesCatalogue.stringItem)) { return ItemFactory.getInstance().createStringItem(item.serialize()); } - if (targetType.equals(AtomicItemType.booleanItem)) { + if (targetType.equals(BuiltinTypesCatalogue.booleanItem)) { if (item.isString()) { return ItemFactory.getInstance() .createBooleanItem(Boolean.parseBoolean(item.getStringValue().trim())); @@ -130,7 +131,7 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad } } - if (targetType.equals(AtomicItemType.doubleItem)) { + if (targetType.equals(BuiltinTypesCatalogue.doubleItem)) { if (item.isString()) { return ItemFactory.getInstance().createDoubleItem(item.castToDoubleValue()); } @@ -141,7 +142,7 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad return ItemFactory.getInstance().createDoubleItem(item.castToDoubleValue()); } } - if (targetType.equals(AtomicItemType.floatItem)) { + if (targetType.equals(BuiltinTypesCatalogue.floatItem)) { if (item.isString()) { return ItemFactory.getInstance().createFloatItem(item.castToFloatValue()); } @@ -153,7 +154,7 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad } } - if (targetType.equals(AtomicItemType.decimalItem)) { + if (targetType.equals(BuiltinTypesCatalogue.decimalItem)) { if (item.isString()) { return ItemFactory.getInstance().createDecimalItem(item.castToDecimalValue()); } @@ -166,7 +167,7 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad } } - if (targetType.equals(AtomicItemType.integerItem)) { + if (targetType.equals(BuiltinTypesCatalogue.integerItem)) { if (item.isString()) { return ItemFactory.getInstance().createIntegerItem(item.castToIntegerValue()); } @@ -179,7 +180,7 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad } } - if (targetType.equals(AtomicItemType.intItem)) { + if (targetType.equals(BuiltinTypesCatalogue.intItem)) { if (item.isString()) { return ItemFactory.getInstance().createIntItem(item.castToIntValue()); } @@ -192,13 +193,13 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad } } - if (targetType.equals(AtomicItemType.anyURIItem)) { + if (targetType.equals(BuiltinTypesCatalogue.anyURIItem)) { if (item.isString()) { return ItemFactory.getInstance().createAnyURIItem(item.getStringValue().trim()); } } - if (targetType.equals(AtomicItemType.base64BinaryItem)) { + if (targetType.equals(BuiltinTypesCatalogue.base64BinaryItem)) { if (item.isString()) { return ItemFactory.getInstance().createBase64BinaryItem(item.getStringValue().trim()); } @@ -208,7 +209,7 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad } } - if (targetType.equals(AtomicItemType.hexBinaryItem)) { + if (targetType.equals(BuiltinTypesCatalogue.hexBinaryItem)) { if (item.isString()) { return ItemFactory.getInstance().createHexBinaryItem(item.getStringValue().trim()); } @@ -217,7 +218,7 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad } } - if (targetType.equals(AtomicItemType.dateItem)) { + if (targetType.equals(BuiltinTypesCatalogue.dateItem)) { if (item.isString()) { return ItemFactory.getInstance().createDateItem(item.getStringValue().trim()); } @@ -225,7 +226,7 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad return ItemFactory.getInstance().createDateItem(item.getDateTimeValue(), item.hasTimeZone()); } } - if (targetType.equals(AtomicItemType.timeItem)) { + if (targetType.equals(BuiltinTypesCatalogue.timeItem)) { if (item.isString()) { return ItemFactory.getInstance().createTimeItem(item.getStringValue().trim()); } @@ -233,7 +234,7 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad return ItemFactory.getInstance().createTimeItem(item.getDateTimeValue(), item.hasTimeZone()); } } - if (targetType.equals(AtomicItemType.dateTimeItem)) { + if (targetType.equals(BuiltinTypesCatalogue.dateTimeItem)) { if (item.isString()) { return ItemFactory.getInstance().createDateTimeItem(item.getStringValue().trim()); } @@ -241,13 +242,13 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad return ItemFactory.getInstance().createDateTimeItem(item.getDateTimeValue(), item.hasTimeZone()); } } - if (targetType.equals(AtomicItemType.yearMonthDurationItem)) { + if (targetType.equals(BuiltinTypesCatalogue.yearMonthDurationItem)) { if (item.isString()) { return ItemFactory.getInstance() .createYearMonthDurationItem( DurationItem.getDurationFromString( item.getStringValue().trim(), - AtomicItemType.yearMonthDurationItem + BuiltinTypesCatalogue.yearMonthDurationItem ) ); } @@ -258,13 +259,13 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad return ItemFactory.getInstance().createYearMonthDurationItem(item.getDurationValue()); } } - if (targetType.equals(AtomicItemType.dayTimeDurationItem)) { + if (targetType.equals(BuiltinTypesCatalogue.dayTimeDurationItem)) { if (item.isString()) { return ItemFactory.getInstance() .createDayTimeDurationItem( DurationItem.getDurationFromString( item.getStringValue().trim(), - AtomicItemType.dayTimeDurationItem + BuiltinTypesCatalogue.dayTimeDurationItem ) ); } @@ -275,13 +276,13 @@ public static Item castItemToType(Item item, ItemType targetType, ExceptionMetad return ItemFactory.getInstance().createDayTimeDurationItem(item.getDurationValue()); } } - if (targetType.equals(AtomicItemType.durationItem)) { + if (targetType.equals(BuiltinTypesCatalogue.durationItem)) { if (item.isString()) { return ItemFactory.getInstance() .createDurationItem( DurationItem.getDurationFromString( item.getStringValue().trim(), - AtomicItemType.durationItem + BuiltinTypesCatalogue.durationItem ) ); } diff --git a/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java b/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java index cd10de518b..b26fa23d46 100644 --- a/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java @@ -11,6 +11,7 @@ import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; @@ -60,7 +61,7 @@ public Item materializeFirstItemOrNull( static void checkInvalidCastable(Item item, ExceptionMetadata metadata, ItemType type) { - if (type.equals(AtomicItemType.atomicItem)) { + if (type.equals(BuiltinTypesCatalogue.atomicItem)) { throw new CastableException("\"atomic\": invalid type for \"cast\" or \"castable\" expression", metadata); } if (item.isAtomic()) { diff --git a/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java b/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java index f7841db6e2..39dbbe351c 100644 --- a/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java @@ -31,6 +31,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.sequences.general.InstanceOfClosure; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -120,67 +121,67 @@ private boolean isInvalidArity(long numOfItems) { * @return true if itemToMatch matches itemType. */ public static boolean doesItemTypeMatchItem(ItemType itemType, Item itemToMatch) { - if (itemType.equals(AtomicItemType.item)) { + if (itemType.equals(BuiltinTypesCatalogue.item)) { return true; } - if (itemType.equals(AtomicItemType.objectItem)) { + if (itemType.equals(BuiltinTypesCatalogue.objectItem)) { return itemToMatch.isObject(); } - if (itemType.equals(AtomicItemType.atomicItem)) { + if (itemType.equals(BuiltinTypesCatalogue.atomicItem)) { return itemToMatch.isAtomic(); } - if (itemType.equals(AtomicItemType.stringItem)) { + if (itemType.equals(BuiltinTypesCatalogue.stringItem)) { return itemToMatch.isString(); } - if (itemType.equals(AtomicItemType.integerItem)) { + if (itemType.equals(BuiltinTypesCatalogue.integerItem)) { return itemToMatch.isInteger(); } - if (itemType.equals(AtomicItemType.decimalItem)) { + if (itemType.equals(BuiltinTypesCatalogue.decimalItem)) { return itemToMatch.isDecimal(); } - if (itemType.equals(AtomicItemType.doubleItem)) { + if (itemType.equals(BuiltinTypesCatalogue.doubleItem)) { return itemToMatch.isDouble(); } - if (itemType.equals(AtomicItemType.floatItem)) { + if (itemType.equals(BuiltinTypesCatalogue.floatItem)) { return itemToMatch.isFloat(); } - if (itemType.equals(AtomicItemType.booleanItem)) { + if (itemType.equals(BuiltinTypesCatalogue.booleanItem)) { return itemToMatch.isBoolean(); } - if (itemType.equals(AtomicItemType.nullItem)) { + if (itemType.equals(BuiltinTypesCatalogue.nullItem)) { return itemToMatch.isNull(); } - if (itemType.equals(AtomicItemType.arrayItem)) { + if (itemType.equals(BuiltinTypesCatalogue.arrayItem)) { return itemToMatch.isArray(); } - if (itemType.equals(AtomicItemType.JSONItem)) { + if (itemType.equals(BuiltinTypesCatalogue.JSONItem)) { return itemToMatch.isObject() || itemToMatch.isArray(); } - if (itemType.equals(AtomicItemType.durationItem)) { + if (itemType.equals(BuiltinTypesCatalogue.durationItem)) { return itemToMatch.isDuration(); } - if (itemType.equals(AtomicItemType.yearMonthDurationItem)) { + if (itemType.equals(BuiltinTypesCatalogue.yearMonthDurationItem)) { return itemToMatch.isYearMonthDuration(); } - if (itemType.equals(AtomicItemType.dayTimeDurationItem)) { + if (itemType.equals(BuiltinTypesCatalogue.dayTimeDurationItem)) { return itemToMatch.isDayTimeDuration(); } - if (itemType.equals(AtomicItemType.dateTimeItem)) { + if (itemType.equals(BuiltinTypesCatalogue.dateTimeItem)) { return itemToMatch.isDateTime(); } - if (itemType.equals(AtomicItemType.dateItem)) { + if (itemType.equals(BuiltinTypesCatalogue.dateItem)) { return itemToMatch.isDate(); } - if (itemType.equals(AtomicItemType.timeItem)) { + if (itemType.equals(BuiltinTypesCatalogue.timeItem)) { return itemToMatch.isTime(); } - if (itemType.equals(AtomicItemType.anyURIItem)) { + if (itemType.equals(BuiltinTypesCatalogue.anyURIItem)) { return itemToMatch.isAnyURI(); } - if (itemType.equals(AtomicItemType.hexBinaryItem)) { + if (itemType.equals(BuiltinTypesCatalogue.hexBinaryItem)) { return itemToMatch.isHexBinary(); } - if (itemType.equals(AtomicItemType.base64BinaryItem)) { + if (itemType.equals(BuiltinTypesCatalogue.base64BinaryItem)) { return itemToMatch.isBase64Binary(); } if (itemType.isFunctionItem()) { diff --git a/src/main/java/org/rumbledb/runtime/typing/TypePromotionIterator.java b/src/main/java/org/rumbledb/runtime/typing/TypePromotionIterator.java index 3d52e61654..fde2837033 100644 --- a/src/main/java/org/rumbledb/runtime/typing/TypePromotionIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/TypePromotionIterator.java @@ -15,6 +15,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.sequences.general.TypePromotionClosure; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; @@ -169,7 +170,7 @@ public Dataset getDataFrame(DynamicContext dynamicContext) { return df; } ItemType dataItemType = TreatIterator.getItemType(df); - if (dataItemType.isSubtypeOf(AtomicItemType.decimalItem) && this.itemType.equals(AtomicItemType.doubleItem)) { + if (dataItemType.isSubtypeOf(BuiltinTypesCatalogue.decimalItem) && this.itemType.equals(BuiltinTypesCatalogue.doubleItem)) { df.createOrReplaceTempView("input"); df = df.sparkSession() .sql( diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index fa6c0fbdd3..27288f2c7d 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -1,118 +1,75 @@ package org.rumbledb.types; -import java.io.Serializable; -import java.util.Arrays; -import java.util.List; - import org.rumbledb.context.Name; -import org.rumbledb.exceptions.OurBadException; -public class AtomicItemType extends ItemType implements Serializable { +public class AtomicItemType implements ItemType { private static final long serialVersionUID = 1L; // TODO: extract array and object into its own types - public static final AtomicItemType atomicItem = new AtomicItemType( + static final AtomicItemType atomicItem = new AtomicItemType( new Name(Name.JS_NS, "js", "atomic") ); - public static final AtomicItemType stringItem = new AtomicItemType( + static final AtomicItemType stringItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "string") ); - public static final AtomicItemType integerItem = new AtomicItemType( + static final AtomicItemType integerItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "integer") ); - public static final AtomicItemType decimalItem = new AtomicItemType( + static final AtomicItemType decimalItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "decimal") ); - public static final AtomicItemType doubleItem = new AtomicItemType( + static final AtomicItemType doubleItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "double") ); - public static final AtomicItemType floatItem = new AtomicItemType( + static final AtomicItemType floatItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "float") ); - public static final AtomicItemType booleanItem = new AtomicItemType( + static final AtomicItemType booleanItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "boolean") ); - public static final AtomicItemType nullItem = new AtomicItemType(new Name(Name.JS_NS, "js", "null")); - public static final AtomicItemType durationItem = new AtomicItemType( + static final AtomicItemType nullItem = new AtomicItemType(new Name(Name.JS_NS, "js", "null")); + static final AtomicItemType durationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "duration") ); - public static final AtomicItemType yearMonthDurationItem = new AtomicItemType( + static final AtomicItemType yearMonthDurationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "yearMonthDuration") ); - public static final AtomicItemType dayTimeDurationItem = new AtomicItemType( + static final AtomicItemType dayTimeDurationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "dayTimeDuration") ); - public static final AtomicItemType dateTimeItem = new AtomicItemType( + static final AtomicItemType dateTimeItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "dateTime") ); - public static final AtomicItemType dateItem = new AtomicItemType(new Name(Name.XS_NS, "xs", "date")); - public static final AtomicItemType timeItem = new AtomicItemType(new Name(Name.XS_NS, "xs", "time")); - public static final AtomicItemType hexBinaryItem = new AtomicItemType( + static final AtomicItemType dateItem = new AtomicItemType(new Name(Name.XS_NS, "xs", "date")); + static final AtomicItemType timeItem = new AtomicItemType(new Name(Name.XS_NS, "xs", "time")); + static final AtomicItemType hexBinaryItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "hexBinary") ); - public static final AtomicItemType anyURIItem = new AtomicItemType( + static final AtomicItemType anyURIItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "anyURI") ); - public static final AtomicItemType base64BinaryItem = new AtomicItemType( + static final AtomicItemType base64BinaryItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "base64Binary") ); - public static final AtomicItemType JSONItem = new AtomicItemType( + static final AtomicItemType JSONItem = new AtomicItemType( new Name(Name.JS_NS, "xs", "json-item") ); - public static final AtomicItemType objectItem = new AtomicItemType( + static final AtomicItemType objectItem = new AtomicItemType( new Name(Name.JS_NS, "js", "object") ); - public static final AtomicItemType arrayItem = new AtomicItemType( + static final AtomicItemType arrayItem = new AtomicItemType( new Name(Name.JS_NS, "js", "array") ); - public static final AtomicItemType intItem = new AtomicItemType(Name.createVariableInDefaultTypeNamespace("int")); + static final AtomicItemType intItem = new AtomicItemType(Name.createVariableInDefaultTypeNamespace("int")); - private static List builtInItemTypes = Arrays.asList( - objectItem, - atomicItem, - stringItem, - integerItem, - intItem, - decimalItem, - doubleItem, - floatItem, - booleanItem, - arrayItem, - nullItem, - JSONItem, - durationItem, - yearMonthDurationItem, - dayTimeDurationItem, - dateTimeItem, - dateItem, - timeItem, - hexBinaryItem, - anyURIItem, - base64BinaryItem, - item - ); + private Name name; public AtomicItemType() { } private AtomicItemType(Name name) { - super(name); - } - - public static boolean typeExists(Name name) { - for (int i = 0; i < builtInItemTypes.size(); ++i) { - if (name.getNamespace() != null && name.getNamespace().equals(Name.JSONIQ_DEFAULT_TYPE_NS)) { - if (builtInItemTypes.get(i).getName().getLocalName().equals(name.getLocalName())) { - return true; - } - } else { - if (builtInItemTypes.get(i).getName().equals(name)) { - return true; - } - } - } - return false; + this.name = name; } @Override @@ -120,28 +77,27 @@ public boolean equals(Object other) { if (!(other instanceof ItemType)) { return false; } - return this.name.toString().equals(other.toString()); + return this.toString().equals(other.toString()); } - public static ItemType getItemTypeByName(Name name) { - for (int i = 0; i < builtInItemTypes.size(); ++i) { - if (name.getNamespace() != null && name.getNamespace().equals(Name.JSONIQ_DEFAULT_TYPE_NS)) { - if (builtInItemTypes.get(i).getName().getLocalName().equals(name.getLocalName())) { - return builtInItemTypes.get(i); - } - } else { - if (builtInItemTypes.get(i).getName().equals(name)) { - return builtInItemTypes.get(i); - } - } - } - throw new OurBadException("Type unrecognized: " + name + "(namespace: " + name.getNamespace() + ")"); + @Override + public boolean isSubtypeOfAtomicItem() { + return true; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Name getName() { + return this.name; } - // Returns true if [this] is a subtype of [superType], any type is considered a subtype of itself @Override public boolean isSubtypeOf(ItemType superType) { - if (superType.equals(AtomicItemType.item)) { + if (superType.equals(BuiltinTypesCatalogue.item)) { return true; } else if (superType.equals(JSONItem)) { return this.equals(objectItem) @@ -187,7 +143,7 @@ public ItemType findCommonSuperType(ItemType other) { } else if (this.isSubtypeOf(JSONItem) && other.isSubtypeOf(JSONItem)) { return JSONItem; } else { - return AtomicItemType.item; + return BuiltinTypesCatalogue.item; } } @@ -268,4 +224,9 @@ public boolean canBePromotedTo(ItemType other) { } return false; } + + @Override + public String toString() { + return this.name.toString(); + } } diff --git a/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java b/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java new file mode 100644 index 0000000000..dcb6385242 --- /dev/null +++ b/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java @@ -0,0 +1,88 @@ +package org.rumbledb.types; + +import org.rumbledb.context.Name; +import org.rumbledb.exceptions.OurBadException; + +import java.util.Arrays; +import java.util.List; + +public class BuiltinTypesCatalogue { + public static final ItemType item = ItemItemType.item; + public static final ItemType atomicItem = AtomicItemType.atomicItem; + public static final ItemType stringItem = AtomicItemType.stringItem; + public static final ItemType integerItem = AtomicItemType.integerItem; + public static final ItemType decimalItem = AtomicItemType.decimalItem; + public static final ItemType doubleItem = AtomicItemType.doubleItem; + public static final ItemType floatItem = AtomicItemType.floatItem; + public static final ItemType booleanItem = AtomicItemType.booleanItem; + public static final ItemType nullItem = AtomicItemType.nullItem; + public static final ItemType durationItem = AtomicItemType.durationItem; + public static final ItemType yearMonthDurationItem = AtomicItemType.yearMonthDurationItem; + public static final ItemType dayTimeDurationItem = AtomicItemType.dayTimeDurationItem; + public static final ItemType dateTimeItem = AtomicItemType.dateTimeItem; + public static final ItemType dateItem = AtomicItemType.dateItem; + public static final ItemType timeItem = AtomicItemType.timeItem; + public static final ItemType hexBinaryItem = AtomicItemType.hexBinaryItem; + public static final ItemType anyURIItem = AtomicItemType.anyURIItem; + public static final ItemType base64BinaryItem = AtomicItemType.base64BinaryItem; + public static final ItemType JSONItem = AtomicItemType.JSONItem; + public static final ItemType objectItem = AtomicItemType.objectItem; + public static final ItemType arrayItem = AtomicItemType.arrayItem; + public static final ItemType intItem = AtomicItemType.intItem; + public static final ItemType anyFunctionItem = FunctionItemType.anyFunctionItem; + + public static boolean typeExists(Name name) { + for (ItemType builtInItemType : builtInItemTypes) { + if (name.getNamespace() != null && name.getNamespace().equals(Name.JSONIQ_DEFAULT_TYPE_NS)) { + if (builtInItemType.getName().getLocalName().equals(name.getLocalName())) { + return true; + } + } else { + if (builtInItemType.getName().equals(name)) { + return true; + } + } + } + return false; + } + + private static final List builtInItemTypes = Arrays.asList( + objectItem, + atomicItem, + stringItem, + integerItem, + intItem, + decimalItem, + doubleItem, + floatItem, + booleanItem, + arrayItem, + nullItem, + JSONItem, + durationItem, + yearMonthDurationItem, + dayTimeDurationItem, + dateTimeItem, + dateItem, + timeItem, + hexBinaryItem, + anyURIItem, + base64BinaryItem, + item + ); + + public static ItemType getItemTypeByName(Name name) { + for (ItemType builtInItemType : builtInItemTypes) { + if (name.getNamespace() != null && name.getNamespace().equals(Name.JSONIQ_DEFAULT_TYPE_NS)) { + if (builtInItemType.getName().getLocalName().equals(name.getLocalName())) { + return builtInItemType; + } + } else { + if (builtInItemType.getName().equals(name)) { + return builtInItemType; + } + } + } + throw new OurBadException("Type unrecognized: " + name + "(namespace: " + name.getNamespace() + ")"); + } +} diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index 00fb01c814..8f766e300c 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -3,11 +3,11 @@ import org.rumbledb.context.Name; import org.rumbledb.exceptions.OurBadException; -public class FunctionItemType extends ItemType { +public class FunctionItemType implements ItemType { private boolean isGeneric; private FunctionSignature signature; - public static FunctionItemType ANYFUNCTION = new FunctionItemType(true); + static FunctionItemType anyFunctionItem = new FunctionItemType(true); public FunctionItemType(FunctionSignature signature) { if (signature == null) { @@ -15,24 +15,20 @@ public FunctionItemType(FunctionSignature signature) { } this.isGeneric = false; this.signature = signature; - this.name = null; } // we have a parameter because the empty one is public and inherited private FunctionItemType(boolean isGeneric) { this.isGeneric = true; this.signature = null; - this.name = null; } @Override - public Name getName() { - throw new UnsupportedOperationException("function types have no name"); - } - - @Override - public String toString() { - return this.isGeneric ? "function(*)" : this.signature.toString(); + public boolean equals(Object other) { + if (!(other instanceof FunctionItemType)) { + return false; + } + return this.toString().equals(other.toString()); } @Override @@ -45,17 +41,9 @@ public FunctionSignature getSignature() { return this.signature; } - @Override - public boolean equals(Object other) { - if (!(other instanceof FunctionItemType)) { - return false; - } - return this.toString().equals(other.toString()); - } - @Override public boolean isSubtypeOf(ItemType superType) { - if (this.equals(superType) || superType.equals(ANYFUNCTION) || superType.equals(ItemType.item)) { + if (this.equals(superType) || superType.equals(anyFunctionItem) || superType.equals(BuiltinTypesCatalogue.item)) { return true; } if (superType.isFunctionItem() && this.signature.isSubtypeOf(superType.getSignature())) { @@ -70,8 +58,13 @@ public ItemType findCommonSuperType(ItemType other) { return this; } if (other.isFunctionItem()) { - return ANYFUNCTION; + return anyFunctionItem; } - return ItemType.item; + return BuiltinTypesCatalogue.item; + } + + @Override + public String toString() { + return this.isGeneric ? "function(*)" : this.signature.toString(); } } diff --git a/src/main/java/org/rumbledb/types/ItemItemType.java b/src/main/java/org/rumbledb/types/ItemItemType.java index b0a703c38c..e0016dc0e7 100644 --- a/src/main/java/org/rumbledb/types/ItemItemType.java +++ b/src/main/java/org/rumbledb/types/ItemItemType.java @@ -33,7 +33,7 @@ public boolean hasName() { @Override public Name getName() { - return name; + return this.name; } @Override diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index 5c46abf15e..76de65fba4 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -34,7 +34,7 @@ public class SequenceType implements Serializable { private boolean isEmptySequence = false; public final static SequenceType MOST_GENERAL_SEQUENCE_TYPE = new SequenceType( - AtomicItemType.item, + BuiltinTypesCatalogue.item, Arity.ZeroOrMore ); @@ -104,19 +104,19 @@ public boolean isAritySubtypeOf(Arity superArity) { public boolean hasEffectiveBooleanValue() { if (this.isEmptySequence) { return true; - } else if (this.itemType.isSubtypeOf(AtomicItemType.JSONItem)) { + } else if (this.itemType.isSubtypeOf(BuiltinTypesCatalogue.JSONItem)) { return true; } else if ( (this.arity == Arity.One || this.arity == Arity.OneOrZero) && (this.itemType.isNumeric() || - this.itemType.equals(AtomicItemType.stringItem) + this.itemType.equals(BuiltinTypesCatalogue.stringItem) || - this.itemType.equals(AtomicItemType.anyURIItem) + this.itemType.equals(BuiltinTypesCatalogue.anyURIItem) || - this.itemType.equals(AtomicItemType.nullItem) + this.itemType.equals(BuiltinTypesCatalogue.nullItem) || - this.itemType.equals(AtomicItemType.booleanItem)) + this.itemType.equals(BuiltinTypesCatalogue.booleanItem)) ) { return true; } else { @@ -265,72 +265,72 @@ public String toString() { static { sequenceTypes = new HashMap<>(); - sequenceTypes.put("item", new SequenceType(AtomicItemType.item, SequenceType.Arity.One)); - sequenceTypes.put("item?", new SequenceType(AtomicItemType.item, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("item*", new SequenceType(AtomicItemType.item, SequenceType.Arity.ZeroOrMore)); - sequenceTypes.put("item+", new SequenceType(AtomicItemType.item, SequenceType.Arity.OneOrMore)); + sequenceTypes.put("item", new SequenceType(BuiltinTypesCatalogue.item, SequenceType.Arity.One)); + sequenceTypes.put("item?", new SequenceType(BuiltinTypesCatalogue.item, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("item*", new SequenceType(BuiltinTypesCatalogue.item, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("item+", new SequenceType(BuiltinTypesCatalogue.item, SequenceType.Arity.OneOrMore)); - sequenceTypes.put("object", new SequenceType(AtomicItemType.objectItem, SequenceType.Arity.One)); - sequenceTypes.put("object+", new SequenceType(AtomicItemType.objectItem, SequenceType.Arity.OneOrMore)); - sequenceTypes.put("object*", new SequenceType(AtomicItemType.objectItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("object", new SequenceType(BuiltinTypesCatalogue.objectItem, SequenceType.Arity.One)); + sequenceTypes.put("object+", new SequenceType(BuiltinTypesCatalogue.objectItem, SequenceType.Arity.OneOrMore)); + sequenceTypes.put("object*", new SequenceType(BuiltinTypesCatalogue.objectItem, SequenceType.Arity.ZeroOrMore)); - sequenceTypes.put("json-item*", new SequenceType(AtomicItemType.JSONItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("json-item*", new SequenceType(BuiltinTypesCatalogue.JSONItem, SequenceType.Arity.ZeroOrMore)); - sequenceTypes.put("array?", new SequenceType(AtomicItemType.arrayItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("array*", new SequenceType(AtomicItemType.arrayItem, Arity.ZeroOrMore)); + sequenceTypes.put("array?", new SequenceType(BuiltinTypesCatalogue.arrayItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("array*", new SequenceType(BuiltinTypesCatalogue.arrayItem, Arity.ZeroOrMore)); - sequenceTypes.put("atomic", new SequenceType(AtomicItemType.atomicItem, SequenceType.Arity.One)); - sequenceTypes.put("atomic?", new SequenceType(AtomicItemType.atomicItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("atomic*", new SequenceType(AtomicItemType.atomicItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("atomic", new SequenceType(BuiltinTypesCatalogue.atomicItem, SequenceType.Arity.One)); + sequenceTypes.put("atomic?", new SequenceType(BuiltinTypesCatalogue.atomicItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("atomic*", new SequenceType(BuiltinTypesCatalogue.atomicItem, SequenceType.Arity.ZeroOrMore)); - sequenceTypes.put("string", new SequenceType(AtomicItemType.stringItem, SequenceType.Arity.One)); - sequenceTypes.put("string?", new SequenceType(AtomicItemType.stringItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("string*", new SequenceType(AtomicItemType.stringItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("string", new SequenceType(BuiltinTypesCatalogue.stringItem, SequenceType.Arity.One)); + sequenceTypes.put("string?", new SequenceType(BuiltinTypesCatalogue.stringItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("string*", new SequenceType(BuiltinTypesCatalogue.stringItem, SequenceType.Arity.ZeroOrMore)); - sequenceTypes.put("integer", new SequenceType(AtomicItemType.integerItem, SequenceType.Arity.One)); - sequenceTypes.put("integer?", new SequenceType(AtomicItemType.integerItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("integer*", new SequenceType(AtomicItemType.integerItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put("integer", new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.One)); + sequenceTypes.put("integer?", new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("integer*", new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.ZeroOrMore)); - sequenceTypes.put("decimal?", new SequenceType(AtomicItemType.decimalItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("decimal?", new SequenceType(BuiltinTypesCatalogue.decimalItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("double", new SequenceType(AtomicItemType.doubleItem, SequenceType.Arity.One)); - sequenceTypes.put("double?", new SequenceType(AtomicItemType.doubleItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("double", new SequenceType(BuiltinTypesCatalogue.doubleItem, SequenceType.Arity.One)); + sequenceTypes.put("double?", new SequenceType(BuiltinTypesCatalogue.doubleItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("float", new SequenceType(AtomicItemType.floatItem, SequenceType.Arity.One)); - sequenceTypes.put("float?", new SequenceType(AtomicItemType.floatItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("float", new SequenceType(BuiltinTypesCatalogue.floatItem, SequenceType.Arity.One)); + sequenceTypes.put("float?", new SequenceType(BuiltinTypesCatalogue.floatItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("boolean", new SequenceType(AtomicItemType.booleanItem, SequenceType.Arity.One)); - sequenceTypes.put("boolean?", new SequenceType(AtomicItemType.booleanItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("boolean", new SequenceType(BuiltinTypesCatalogue.booleanItem, SequenceType.Arity.One)); + sequenceTypes.put("boolean?", new SequenceType(BuiltinTypesCatalogue.booleanItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("duration?", new SequenceType(AtomicItemType.durationItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("duration?", new SequenceType(BuiltinTypesCatalogue.durationItem, SequenceType.Arity.OneOrZero)); sequenceTypes.put( "yearMonthDuration?", - new SequenceType(AtomicItemType.yearMonthDurationItem, SequenceType.Arity.OneOrZero) + new SequenceType(BuiltinTypesCatalogue.yearMonthDurationItem, SequenceType.Arity.OneOrZero) ); sequenceTypes.put( "dayTimeDuration?", - new SequenceType(AtomicItemType.dayTimeDurationItem, SequenceType.Arity.OneOrZero) + new SequenceType(BuiltinTypesCatalogue.dayTimeDurationItem, SequenceType.Arity.OneOrZero) ); - sequenceTypes.put("dateTime?", new SequenceType(AtomicItemType.dateTimeItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("dateTime?", new SequenceType(BuiltinTypesCatalogue.dateTimeItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("date?", new SequenceType(AtomicItemType.dateItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("date?", new SequenceType(BuiltinTypesCatalogue.dateItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("time?", new SequenceType(AtomicItemType.timeItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("time?", new SequenceType(BuiltinTypesCatalogue.timeItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("anyURI", new SequenceType(AtomicItemType.anyURIItem)); - sequenceTypes.put("anyURI?", new SequenceType(AtomicItemType.anyURIItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("anyURI", new SequenceType(BuiltinTypesCatalogue.anyURIItem)); + sequenceTypes.put("anyURI?", new SequenceType(BuiltinTypesCatalogue.anyURIItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("hexBinary?", new SequenceType(AtomicItemType.hexBinaryItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("hexBinary?", new SequenceType(BuiltinTypesCatalogue.hexBinaryItem, SequenceType.Arity.OneOrZero)); sequenceTypes.put( "base64Binary?", - new SequenceType(AtomicItemType.base64BinaryItem, SequenceType.Arity.OneOrZero) + new SequenceType(BuiltinTypesCatalogue.base64BinaryItem, SequenceType.Arity.OneOrZero) ); - sequenceTypes.put("null?", new SequenceType(AtomicItemType.nullItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("null?", new SequenceType(BuiltinTypesCatalogue.nullItem, SequenceType.Arity.OneOrZero)); } public static SequenceType createSequenceType(String userFriendlyName) { diff --git a/src/main/java/sparksoniq/spark/DataFrameUtils.java b/src/main/java/sparksoniq/spark/DataFrameUtils.java index fc3b76e3bf..b38f4f3ca4 100644 --- a/src/main/java/sparksoniq/spark/DataFrameUtils.java +++ b/src/main/java/sparksoniq/spark/DataFrameUtils.java @@ -14,6 +14,7 @@ import org.rumbledb.items.ObjectItem; import org.rumbledb.items.parsing.ItemParser; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.util.ArrayList; @@ -120,7 +121,7 @@ private static DataType generateDataTypeFromItem(Item item) { } if (item.isString()) { - ItemType itemType = AtomicItemType.getItemTypeByName( + ItemType itemType = BuiltinTypesCatalogue.getItemTypeByName( Name.createVariableInDefaultTypeNamespace(item.getStringValue()) ); return ItemParser.getDataFrameDataTypeFromItemType(itemType); diff --git a/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java b/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java index d7f4522f86..22ff76a467 100644 --- a/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java +++ b/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java @@ -22,6 +22,7 @@ import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.SequenceType; @@ -242,17 +243,17 @@ private Item generateTransformerFunctionItem(Transformer fittedModel) { List paramTypes = Collections.unmodifiableList( Arrays.asList( new SequenceType( - AtomicItemType.item, // TODO: revert back to ObjectItem + BuiltinTypesCatalogue.item, // TODO: revert back to ObjectItem SequenceType.Arity.ZeroOrMore ), new SequenceType( - AtomicItemType.objectItem, + BuiltinTypesCatalogue.objectItem, SequenceType.Arity.One ) ) ); SequenceType returnType = new SequenceType( - AtomicItemType.objectItem, + BuiltinTypesCatalogue.objectItem, SequenceType.Arity.ZeroOrMore ); diff --git a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java index e69508eb81..73a6f534d6 100644 --- a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java +++ b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java @@ -34,6 +34,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.FunctionItemType; import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.SequenceType; @@ -117,17 +118,17 @@ public Item next() { List paramTypes = Collections.unmodifiableList( Arrays.asList( new SequenceType( - AtomicItemType.item, // TODO: revert back to ObjectItem + BuiltinTypesCatalogue.item, // TODO: revert back to ObjectItem SequenceType.Arity.ZeroOrMore ), new SequenceType( - AtomicItemType.objectItem, + BuiltinTypesCatalogue.objectItem, SequenceType.Arity.One ) ) ); SequenceType returnType = new SequenceType( - FunctionItemType.ANYFUNCTION, + BuiltinTypesCatalogue.anyFunctionItem, SequenceType.Arity.One ); diff --git a/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java b/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java index a61ad881d9..ac24a16a11 100644 --- a/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java +++ b/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java @@ -34,6 +34,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.SequenceType; @@ -116,17 +117,17 @@ public Item next() { List paramTypes = Collections.unmodifiableList( Arrays.asList( new SequenceType( - AtomicItemType.item, // TODO: revert back to ObjectItem + BuiltinTypesCatalogue.item, // TODO: revert back to ObjectItem SequenceType.Arity.ZeroOrMore ), new SequenceType( - AtomicItemType.objectItem, + BuiltinTypesCatalogue.objectItem, SequenceType.Arity.One ) ) ); SequenceType returnType = new SequenceType( - AtomicItemType.objectItem, + BuiltinTypesCatalogue.objectItem, SequenceType.Arity.ZeroOrMore ); diff --git a/src/main/java/sparksoniq/spark/ml/RumbleMLUtils.java b/src/main/java/sparksoniq/spark/ml/RumbleMLUtils.java index cbd7029cb2..9f9c0da143 100644 --- a/src/main/java/sparksoniq/spark/ml/RumbleMLUtils.java +++ b/src/main/java/sparksoniq/spark/ml/RumbleMLUtils.java @@ -13,6 +13,7 @@ import org.rumbledb.exceptions.InvalidRumbleMLParamException; import org.rumbledb.exceptions.OurBadException; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.typing.CastIterator; @@ -168,7 +169,7 @@ private static Object convertRumbleAtomicToJava(Item atomicItem, String javaType case "boolean": castItem = CastIterator.castItemToType( atomicItem, - AtomicItemType.booleanItem, + BuiltinTypesCatalogue.booleanItem, ExceptionMetadata.EMPTY_METADATA ); if (castItem == null) { @@ -178,7 +179,7 @@ private static Object convertRumbleAtomicToJava(Item atomicItem, String javaType case "String": castItem = CastIterator.castItemToType( atomicItem, - AtomicItemType.stringItem, + BuiltinTypesCatalogue.stringItem, ExceptionMetadata.EMPTY_METADATA ); if (castItem == null) { @@ -188,7 +189,7 @@ private static Object convertRumbleAtomicToJava(Item atomicItem, String javaType case "int": castItem = CastIterator.castItemToType( atomicItem, - AtomicItemType.integerItem, + BuiltinTypesCatalogue.integerItem, ExceptionMetadata.EMPTY_METADATA ); if (castItem == null) { @@ -198,7 +199,7 @@ private static Object convertRumbleAtomicToJava(Item atomicItem, String javaType case "double": castItem = CastIterator.castItemToType( atomicItem, - AtomicItemType.doubleItem, + BuiltinTypesCatalogue.doubleItem, ExceptionMetadata.EMPTY_METADATA ); if (castItem == null) { @@ -208,7 +209,7 @@ private static Object convertRumbleAtomicToJava(Item atomicItem, String javaType case "long": castItem = CastIterator.castItemToType( atomicItem, - AtomicItemType.decimalItem, + BuiltinTypesCatalogue.decimalItem, ExceptionMetadata.EMPTY_METADATA ); if (castItem == null) { diff --git a/src/test/java/iq/FrontendTests.java b/src/test/java/iq/FrontendTests.java index ca088ce39a..615cd56b22 100644 --- a/src/test/java/iq/FrontendTests.java +++ b/src/test/java/iq/FrontendTests.java @@ -32,6 +32,7 @@ import org.rumbledb.expressions.primary.VariableReferenceExpression; import org.rumbledb.runtime.functions.input.FileSystemUtil; import org.rumbledb.types.AtomicItemType; +import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.io.File; import java.net.URI; @@ -207,7 +208,7 @@ private void testVariableTypes(File testFile, MainModule mainModule) { ); vars.forEach( var -> Assert.assertTrue( - ((VariableReferenceExpression) var).getType().getItemType().equals(AtomicItemType.integerItem) + ((VariableReferenceExpression) var).getType().getItemType().equals(BuiltinTypesCatalogue.integerItem) ) ); @@ -219,9 +220,9 @@ private void testVariableTypes(File testFile, MainModule mainModule) { ); js.forEach( j -> Assert.assertTrue( - ((VariableReferenceExpression) j).getType().getItemType().equals(ItemType.item) + ((VariableReferenceExpression) j).getType().getItemType().equals(BuiltinTypesCatalogue.item) || - ((VariableReferenceExpression) j).getType().getItemType().equals(AtomicItemType.stringItem) + ((VariableReferenceExpression) j).getType().getItemType().equals(BuiltinTypesCatalogue.stringItem) ) ); @@ -233,7 +234,7 @@ private void testVariableTypes(File testFile, MainModule mainModule) { ); internals.forEach( j -> Assert.assertTrue( - ((VariableReferenceExpression) j).getType().getItemType().equals(AtomicItemType.integerItem) + ((VariableReferenceExpression) j).getType().getItemType().equals(BuiltinTypesCatalogue.integerItem) ) ); @@ -245,7 +246,7 @@ private void testVariableTypes(File testFile, MainModule mainModule) { ); arry.forEach( j -> Assert.assertTrue( - ((VariableReferenceExpression) j).getType().getItemType().equals(AtomicItemType.arrayItem) + ((VariableReferenceExpression) j).getType().getItemType().equals(BuiltinTypesCatalogue.arrayItem) ) ); From 60a0726e3b96933683db97d39025120ba163ebfb Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 9 Feb 2021 11:28:08 +0100 Subject: [PATCH 153/206] corrected semantics of class item type testing for atomic item types (account for object and array part of this class for now) --- src/main/java/org/rumbledb/types/AtomicItemType.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 27288f2c7d..6ba2ea1e31 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -82,7 +82,17 @@ public boolean equals(Object other) { @Override public boolean isSubtypeOfAtomicItem() { - return true; + return !(this.equals(arrayItem) || this.equals(objectItem)); + } + + @Override + public boolean isObjectItem() { + return this.equals(objectItem); + } + + @Override + public boolean isArrayItem() { + return this.equals(arrayItem); } @Override From bdd6e1e0c58c1e335c23d00e10e47538674e1440 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 11 Feb 2021 11:15:14 +0100 Subject: [PATCH 154/206] turned backtick escaping into a flag --- .../compiler/RuntimeIteratorVisitor.java | 12 +++++--- .../config/RumbleRuntimeConfiguration.java | 5 ++++ .../flwor/clauses/ForClauseSparkIterator.java | 29 +++++++++++++------ .../flwor/clauses/LetClauseSparkIterator.java | 8 +++-- .../clauses/ReturnClauseSparkIterator.java | 9 ++++-- .../clauses/WhereClauseSparkIterator.java | 8 +++-- src/test/java/iq/NativeFLWORRuntimeTests.java | 13 +++++++++ 7 files changed, 65 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java b/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java index 8d312c07ca..6edbd79810 100644 --- a/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java +++ b/src/main/java/org/rumbledb/compiler/RuntimeIteratorVisitor.java @@ -210,7 +210,8 @@ public RuntimeIterator visitFlowrExpression(FlworExpression expression, RuntimeI argument ), expression.getReturnClause().getHighestExecutionMode(this.visitorConfig), - expression.getReturnClause().getMetadata() + expression.getReturnClause().getMetadata(), + this.config.escapeBackticks() ); runtimeIterator.setStaticContext(expression.getStaticContext()); return runtimeIterator; @@ -234,7 +235,8 @@ private RuntimeTupleIterator visitFlowrClause( forClause.isAllowEmpty(), assignmentIterator, forClause.getHighestExecutionMode(this.visitorConfig), - clause.getMetadata() + clause.getMetadata(), + this.config.escapeBackticks() ); } else if (clause instanceof LetClause) { LetClause letClause = (LetClause) clause; @@ -245,7 +247,8 @@ private RuntimeTupleIterator visitFlowrClause( letClause.getActualSequenceType(), assignmentIterator, letClause.getHighestExecutionMode(this.visitorConfig), - clause.getMetadata() + clause.getMetadata(), + this.config.escapeBackticks() ); } else if (clause instanceof GroupByClause) { List groupingExpressions = new ArrayList<>(); @@ -304,7 +307,8 @@ private RuntimeTupleIterator visitFlowrClause( previousIterator, this.visit(((WhereClause) clause).getWhereExpression(), argument), clause.getHighestExecutionMode(this.visitorConfig), - clause.getMetadata() + clause.getMetadata(), + this.config.escapeBackticks() ); } else if (clause instanceof CountClause) { return new CountClauseSparkIterator( diff --git a/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java b/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java index 523ec4124f..141e32c980 100644 --- a/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java +++ b/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java @@ -310,6 +310,11 @@ public boolean printInferredTypes() { && this.arguments.get("print-inferred-types").equals("yes"); } + public boolean escapeBackticks() { + return this.arguments.containsKey("escape-backticks") + && this.arguments.get("escape-backticks").equals("yes"); + } + public boolean isLocal() { String masterConfig = SparkSessionManager.getInstance().getJavaSparkContext().getConf().get("spark.master"); return masterConfig.contains("local"); diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index 0a37fd7025..78a6d3df48 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -81,6 +81,7 @@ public class ForClauseSparkIterator extends RuntimeTupleIterator { private RuntimeIterator assignmentIterator; private boolean allowingEmpty; private DataFrameContext dataFrameContext; + private final boolean escapeBackticks; // Computation state private transient DynamicContext tupleContext; // re-use same DynamicContext object for efficiency @@ -96,7 +97,8 @@ public ForClauseSparkIterator( boolean allowingEmpty, RuntimeIterator assignmentIterator, ExecutionMode executionMode, - ExceptionMetadata iteratorMetadata + ExceptionMetadata iteratorMetadata, + boolean escapeBackticks ) { super(child, executionMode, iteratorMetadata); this.variableName = variableName; @@ -105,6 +107,7 @@ public ForClauseSparkIterator( this.allowingEmpty = allowingEmpty; this.assignmentIterator.getVariableDependencies(); this.dataFrameContext = new DataFrameContext(); + this.escapeBackticks = escapeBackticks; } public Name getVariableName() { @@ -411,7 +414,8 @@ private Dataset getDataFrameFromJoin( this.variableName, this.positionalVariableName, Name.CONTEXT_ITEM, - getMetadata() + getMetadata(), + this.escapeBackticks ); } @@ -426,7 +430,8 @@ public static Dataset joinInputTupleWithSequenceOnPredicate( Name forVariableName, Name positionalVariableName, Name sequenceVariableName, - ExceptionMetadata metadata + ExceptionMetadata metadata, + boolean escapeBackticks ) { String inputDFTableName = "inputTuples"; String expressionDFTableName = "sequenceExpression"; @@ -471,7 +476,8 @@ public static Dataset joinInputTupleWithSequenceOnPredicate( Name.CONTEXT_POSITION, false, context, - startingClauseDependencies + startingClauseDependencies, + escapeBackticks ); variablesInExpressionSideTuple.add(sequenceVariableName); variablesInExpressionSideTuple.add(Name.CONTEXT_POSITION); @@ -484,7 +490,8 @@ public static Dataset joinInputTupleWithSequenceOnPredicate( null, false, context, - startingClauseDependencies + startingClauseDependencies, + escapeBackticks ); variablesInExpressionSideTuple.add(sequenceVariableName); } @@ -1003,7 +1010,8 @@ private Dataset getDataFrameStartingClause( this.positionalVariableName, this.allowingEmpty, context, - parentProjection + parentProjection, + this.escapeBackticks ); } @@ -1025,15 +1033,18 @@ public static Dataset getDataFrameStartingClause( Name positionalVariableName, boolean allowingEmpty, DynamicContext context, - Map outputDependencies + Map outputDependencies, + boolean escapeBackticks ) { Dataset df = null;; if (iterator.isDataFrame()) { Dataset rows = iterator.getDataFrame(context); // escape backticks (`) - rows = rows.sparkSession() - .createDataFrame(rows.rdd(), FlworDataFrameUtils.escapeSchema(rows.schema(), false)); + if(escapeBackticks) { + rows = rows.sparkSession() + .createDataFrame(rows.rdd(), FlworDataFrameUtils.escapeSchema(rows.schema(), false)); + } String[] fields = rows.schema().fieldNames(); rows.createOrReplaceTempView("assignment"); diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index a879a741e3..55bfb1218b 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -73,6 +73,7 @@ public class LetClauseSparkIterator extends RuntimeTupleIterator { private RuntimeIterator assignmentIterator; private DynamicContext tupleContext; // re-use same DynamicContext object for efficiency private FlworTuple nextLocalTupleResult; + private final boolean escapeBackticks; public LetClauseSparkIterator( RuntimeTupleIterator child, @@ -80,12 +81,14 @@ public LetClauseSparkIterator( SequenceType sequenceType, RuntimeIterator assignmentIterator, ExecutionMode executionMode, - ExceptionMetadata iteratorMetadata + ExceptionMetadata iteratorMetadata, + boolean escapeBackticks ) { super(child, executionMode, iteratorMetadata); this.variableName = variableName; this.sequenceType = sequenceType; this.assignmentIterator = assignmentIterator; + this.escapeBackticks = escapeBackticks; } @Override @@ -320,7 +323,8 @@ public Dataset getDataFrameAsJoin( null, false, context, - sequenceDependencies + sequenceDependencies, + this.escapeBackticks ); System.err.println("[INFO] Rumble detected an equi-join in the left clause."); diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ReturnClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ReturnClauseSparkIterator.java index 1847dde06e..df7e30002c 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ReturnClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ReturnClauseSparkIterator.java @@ -57,16 +57,19 @@ public class ReturnClauseSparkIterator extends HybridRuntimeIterator { private DynamicContext tupleContext; // re-use same DynamicContext object for efficiency private RuntimeIterator expression; private Item nextResult; + private final boolean escapeBackticks; public ReturnClauseSparkIterator( RuntimeTupleIterator child, RuntimeIterator expression, ExecutionMode executionMode, - ExceptionMetadata iteratorMetadata + ExceptionMetadata iteratorMetadata, + boolean escapeBackticks ) { super(Collections.singletonList(expression), executionMode, iteratorMetadata); this.child = child; this.expression = expression; + this.escapeBackticks = escapeBackticks; } @Override @@ -111,7 +114,9 @@ public JavaRDD getRDDAux(DynamicContext context) { Dataset df = this.child.getDataFrame(context, projection); // unescape backticks (`) - df = df.sparkSession().createDataFrame(df.rdd(), FlworDataFrameUtils.escapeSchema(df.schema(), true)); + if(this.escapeBackticks) { + df = df.sparkSession().createDataFrame(df.rdd(), FlworDataFrameUtils.escapeSchema(df.schema(), true)); + } StructType oldSchema = df.schema(); List UDFcolumns = FlworDataFrameUtils.getColumnNames( diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java index dca5d6d307..c9a1305745 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/WhereClauseSparkIterator.java @@ -54,16 +54,19 @@ public class WhereClauseSparkIterator extends RuntimeTupleIterator { private RuntimeIterator expression; private DynamicContext tupleContext; // re-use same DynamicContext object for efficiency private FlworTuple nextLocalTupleResult; + private final boolean escapeBackticks; public WhereClauseSparkIterator( RuntimeTupleIterator child, RuntimeIterator whereExpression, ExecutionMode executionMode, - ExceptionMetadata iteratorMetadata + ExceptionMetadata iteratorMetadata, + boolean escapeBackticks ) { super(child, executionMode, iteratorMetadata); this.expression = whereExpression; this.expression.getVariableDependencies(); + this.escapeBackticks = escapeBackticks; } @Override @@ -191,7 +194,8 @@ public Dataset getDataFrame( forVariable, null, forVariable, - getMetadata() + getMetadata(), + this.escapeBackticks ); } } diff --git a/src/test/java/iq/NativeFLWORRuntimeTests.java b/src/test/java/iq/NativeFLWORRuntimeTests.java index eeacbb8259..9904df0df4 100644 --- a/src/test/java/iq/NativeFLWORRuntimeTests.java +++ b/src/test/java/iq/NativeFLWORRuntimeTests.java @@ -20,10 +20,13 @@ package iq; +import iq.base.AnnotationsTestsBase; import org.junit.Assert; +import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.rumbledb.api.SequenceOfItems; +import org.rumbledb.config.RumbleRuntimeConfiguration; import java.io.File; import java.util.ArrayList; @@ -33,6 +36,10 @@ @RunWith(Parameterized.class) public class NativeFLWORRuntimeTests extends RuntimeTests { + protected static final RumbleRuntimeConfiguration configuration = new RumbleRuntimeConfiguration( + new String[] { "--variable:externalUnparsedString", "unparsed string", "--escape-backticks", "yes" } + ); + public static final File nativeFlworRuntimeTestsDirectory = new File( System.getProperty("user.dir") + @@ -52,6 +59,12 @@ public static Collection testFiles() { return result; } + @Test(timeout = 1000000) + public void testRuntimeIterators() throws Throwable { + System.err.println(AnnotationsTestsBase.counter++ + " : " + this.testFile); + testAnnotations(this.testFile.getAbsolutePath(), NativeFLWORRuntimeTests.configuration); + } + @Override protected void checkExpectedOutput( String expectedOutput, From 0bbf400947d2744fa3d5292712dca2dd2472cbff Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Thu, 11 Feb 2021 12:03:33 +0100 Subject: [PATCH 155/206] spotless --- .../compiler/DynamicContextVisitor.java | 1 - .../rumbledb/compiler/InferTypeVisitor.java | 27 ++++++++---- .../compiler/StaticContextVisitor.java | 1 - .../rumbledb/compiler/TranslationVisitor.java | 1 - .../config/RumbleRuntimeConfiguration.java | 2 +- .../java/org/rumbledb/items/AnyURIItem.java | 1 - .../java/org/rumbledb/items/ArrayItem.java | 1 - .../org/rumbledb/items/Base64BinaryItem.java | 1 - .../java/org/rumbledb/items/BooleanItem.java | 1 - .../java/org/rumbledb/items/DateItem.java | 1 - .../java/org/rumbledb/items/DateTimeItem.java | 1 - .../rumbledb/items/DayTimeDurationItem.java | 8 ++-- .../java/org/rumbledb/items/DecimalItem.java | 1 - .../java/org/rumbledb/items/DoubleItem.java | 1 - .../java/org/rumbledb/items/DurationItem.java | 1 - .../java/org/rumbledb/items/FloatItem.java | 1 - .../org/rumbledb/items/HexBinaryItem.java | 1 - src/main/java/org/rumbledb/items/IntItem.java | 1 - .../java/org/rumbledb/items/IntegerItem.java | 1 - .../java/org/rumbledb/items/NullItem.java | 1 - .../java/org/rumbledb/items/ObjectItem.java | 1 - .../java/org/rumbledb/items/StringItem.java | 1 - .../java/org/rumbledb/items/TimeItem.java | 1 - .../rumbledb/items/YearMonthDurationItem.java | 8 ++-- .../rumbledb/items/parsing/ItemParser.java | 1 - .../AtMostOneItemLocalRuntimeIterator.java | 1 - .../org/rumbledb/runtime/RuntimeIterator.java | 1 - .../runtime/flwor/FlworDataFrameUtils.java | 1 - .../flwor/clauses/ForClauseSparkIterator.java | 4 +- .../flwor/clauses/LetClauseSparkIterator.java | 1 - .../clauses/OrderByClauseSparkIterator.java | 1 - .../clauses/ReturnClauseSparkIterator.java | 2 +- .../udfs/OrderClauseCreateColumnsUDF.java | 1 - .../DayTimeDurationFunctionIterator.java | 1 - .../durations/DurationFunctionIterator.java | 1 - .../YearMonthDurationFunctionIterator.java | 1 - .../numerics/NumberFunctionIterator.java | 1 - .../operational/AndOperationIterator.java | 1 - .../operational/ComparisonIterator.java | 1 - .../operational/NotOperationIterator.java | 1 - .../operational/OrOperationIterator.java | 1 - .../primary/DecimalRuntimeIterator.java | 1 - .../primary/DoubleRuntimeIterator.java | 7 ++- .../primary/IntegerRuntimeIterator.java | 7 ++- .../primary/StringRuntimeIterator.java | 1 - .../rumbledb/runtime/typing/CastIterator.java | 1 - .../runtime/typing/CastableIterator.java | 1 - .../runtime/typing/InstanceOfIterator.java | 1 - .../runtime/typing/TypePromotionIterator.java | 6 ++- .../org/rumbledb/types/AtomicItemType.java | 42 +++++++++--------- .../rumbledb/types/BuiltinTypesCatalogue.java | 44 +++++++++---------- .../org/rumbledb/types/FunctionItemType.java | 5 ++- .../java/org/rumbledb/types/ItemItemType.java | 4 +- .../java/org/rumbledb/types/ItemType.java | 8 ++-- .../java/org/rumbledb/types/SequenceType.java | 40 +++++++++++++---- .../java/sparksoniq/spark/DataFrameUtils.java | 1 - .../ml/ApplyEstimatorRuntimeIterator.java | 1 - .../ml/GetEstimatorFunctionIterator.java | 2 - .../ml/GetTransformerFunctionIterator.java | 1 - .../sparksoniq/spark/ml/RumbleMLUtils.java | 1 - src/test/java/iq/FrontendTests.java | 2 - 61 files changed, 130 insertions(+), 132 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java b/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java index 0366ef2e29..03f5aaf383 100644 --- a/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/DynamicContextVisitor.java @@ -45,7 +45,6 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.input.FileSystemUtil; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.runtime.typing.InstanceOfIterator; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 82826c6b8b..433e7a7bc2 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -27,7 +27,6 @@ import org.rumbledb.expressions.primary.*; import org.rumbledb.expressions.typing.*; import org.rumbledb.types.*; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import java.util.*; @@ -362,7 +361,10 @@ public StaticContext visitCastableExpression(CastableExpression expression, Stat } SequenceType expressionType = expression.getMainExpression().getInferredSequenceType(); basicChecks(expressionType, expression.getClass().getSimpleName(), true, false); - if (!expressionType.isEmptySequence() && !expressionType.getItemType().isSubtypeOf(BuiltinTypesCatalogue.atomicItem)) { + if ( + !expressionType.isEmptySequence() + && !expressionType.getItemType().isSubtypeOf(BuiltinTypesCatalogue.atomicItem) + ) { throw new UnexpectedStaticTypeException( "non-atomic item types are not allowed in castable expression, found " + expressionType.getItemType(), @@ -517,7 +519,10 @@ public StaticContext visitAdditiveExpr(AdditiveExpression expression, StaticCont if (rightItemType.isNumeric()) { inferredType = resolveNumericType(leftItemType, rightItemType); } - } else if (leftItemType.equals(BuiltinTypesCatalogue.dateItem) || leftItemType.equals(BuiltinTypesCatalogue.dateTimeItem)) { + } else if ( + leftItemType.equals(BuiltinTypesCatalogue.dateItem) + || leftItemType.equals(BuiltinTypesCatalogue.dateTimeItem) + ) { if ( rightItemType.equals(BuiltinTypesCatalogue.dayTimeDurationItem) || rightItemType.equals(BuiltinTypesCatalogue.yearMonthDurationItem) @@ -659,7 +664,8 @@ public StaticContext visitMultiplicativeExpr(MultiplicativeExpression expression inferredType = rightItemType; } } else if ( - leftItemType.isSubtypeOf(BuiltinTypesCatalogue.durationItem) && !leftItemType.equals(BuiltinTypesCatalogue.durationItem) + leftItemType.isSubtypeOf(BuiltinTypesCatalogue.durationItem) + && !leftItemType.equals(BuiltinTypesCatalogue.durationItem) ) { if ( rightItemType.isNumeric() @@ -863,7 +869,8 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static // Type must be a strict subtype of atomic if ( - leftItemType.isSubtypeOf(BuiltinTypesCatalogue.JSONItem) || rightItemType.isSubtypeOf(BuiltinTypesCatalogue.JSONItem) + leftItemType.isSubtypeOf(BuiltinTypesCatalogue.JSONItem) + || rightItemType.isSubtypeOf(BuiltinTypesCatalogue.JSONItem) ) { throw new UnexpectedStaticTypeException( "It is not possible to compare with non-atomic types", @@ -879,7 +886,8 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static throw new UnexpectedStaticTypeException("It is not possible to compare with non-atomic types"); } - // Type must match exactly or be both numeric or both promotable to string or both durations or one must be null + // Type must match exactly or be both numeric or both promotable to string or both durations or one must be + // null if ( !leftItemType.equals(rightItemType) && @@ -891,7 +899,8 @@ public StaticContext visitComparisonExpr(ComparisonExpression expression, Static !(leftItemType.canBePromotedTo(BuiltinTypesCatalogue.stringItem) && rightItemType.canBePromotedTo(BuiltinTypesCatalogue.stringItem)) && - !(leftItemType.equals(BuiltinTypesCatalogue.nullItem) || rightItemType.equals(BuiltinTypesCatalogue.nullItem)) + !(leftItemType.equals(BuiltinTypesCatalogue.nullItem) + || rightItemType.equals(BuiltinTypesCatalogue.nullItem)) ) { throw new UnexpectedStaticTypeException( "It is not possible to compare these types: " + leftItemType + " and " + rightItemType @@ -1148,7 +1157,9 @@ public StaticContext visitRangeExpr(RangeExpression expression, StaticContext ar ); } - expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.ZeroOrMore)); + expression.setInferredSequenceType( + new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.ZeroOrMore) + ); System.out.println("visiting Range expression, type set to: " + expression.getInferredSequenceType()); return argument; } diff --git a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java index a0cd6b65e8..3d95657546 100644 --- a/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java +++ b/src/main/java/org/rumbledb/compiler/StaticContextVisitor.java @@ -52,7 +52,6 @@ import org.rumbledb.expressions.primary.FunctionCallExpression; import org.rumbledb.expressions.primary.InlineFunctionExpression; import org.rumbledb.expressions.primary.VariableReferenceExpression; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.SequenceType; import org.rumbledb.types.SequenceType.Arity; diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 07e5dffe49..50d1246f09 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -107,7 +107,6 @@ import org.rumbledb.parser.JsoniqParser.SetterContext; import org.rumbledb.parser.JsoniqParser.UriLiteralContext; import org.rumbledb.runtime.functions.input.FileSystemUtil; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java b/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java index 141e32c980..887fc6a784 100644 --- a/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java +++ b/src/main/java/org/rumbledb/config/RumbleRuntimeConfiguration.java @@ -312,7 +312,7 @@ public boolean printInferredTypes() { public boolean escapeBackticks() { return this.arguments.containsKey("escape-backticks") - && this.arguments.get("escape-backticks").equals("yes"); + && this.arguments.get("escape-backticks").equals("yes"); } public boolean isLocal() { diff --git a/src/main/java/org/rumbledb/items/AnyURIItem.java b/src/main/java/org/rumbledb/items/AnyURIItem.java index f4f59a8b5e..3d2308a56e 100644 --- a/src/main/java/org/rumbledb/items/AnyURIItem.java +++ b/src/main/java/org/rumbledb/items/AnyURIItem.java @@ -28,7 +28,6 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; diff --git a/src/main/java/org/rumbledb/items/ArrayItem.java b/src/main/java/org/rumbledb/items/ArrayItem.java index c9168b4e3f..08929c76f3 100644 --- a/src/main/java/org/rumbledb/items/ArrayItem.java +++ b/src/main/java/org/rumbledb/items/ArrayItem.java @@ -25,7 +25,6 @@ import com.esotericsoftware.kryo.io.Output; import org.apache.commons.text.StringEscapeUtils; import org.rumbledb.api.Item; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.util.ArrayList; diff --git a/src/main/java/org/rumbledb/items/Base64BinaryItem.java b/src/main/java/org/rumbledb/items/Base64BinaryItem.java index e618a8900c..68cdb5d6a9 100644 --- a/src/main/java/org/rumbledb/items/Base64BinaryItem.java +++ b/src/main/java/org/rumbledb/items/Base64BinaryItem.java @@ -9,7 +9,6 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import javax.xml.bind.DatatypeConverter; diff --git a/src/main/java/org/rumbledb/items/BooleanItem.java b/src/main/java/org/rumbledb/items/BooleanItem.java index 94055fb32b..9eef00ad7b 100644 --- a/src/main/java/org/rumbledb/items/BooleanItem.java +++ b/src/main/java/org/rumbledb/items/BooleanItem.java @@ -24,7 +24,6 @@ import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; import org.rumbledb.api.Item; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; diff --git a/src/main/java/org/rumbledb/items/DateItem.java b/src/main/java/org/rumbledb/items/DateItem.java index 3b0d42bdc7..c6131fca6a 100644 --- a/src/main/java/org/rumbledb/items/DateItem.java +++ b/src/main/java/org/rumbledb/items/DateItem.java @@ -9,7 +9,6 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; diff --git a/src/main/java/org/rumbledb/items/DateTimeItem.java b/src/main/java/org/rumbledb/items/DateTimeItem.java index 86ebcde1b5..aaa21d31c7 100644 --- a/src/main/java/org/rumbledb/items/DateTimeItem.java +++ b/src/main/java/org/rumbledb/items/DateTimeItem.java @@ -13,7 +13,6 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; diff --git a/src/main/java/org/rumbledb/items/DayTimeDurationItem.java b/src/main/java/org/rumbledb/items/DayTimeDurationItem.java index 0f197ee1d6..3b2e9a8c96 100644 --- a/src/main/java/org/rumbledb/items/DayTimeDurationItem.java +++ b/src/main/java/org/rumbledb/items/DayTimeDurationItem.java @@ -4,7 +4,6 @@ import com.esotericsoftware.kryo.io.Input; import org.joda.time.Period; import org.joda.time.PeriodType; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; @@ -44,9 +43,10 @@ public boolean isDayTimeDuration() { @Override public void read(Kryo kryo, Input input) { - this.value = getDurationFromString(input.readString(), BuiltinTypesCatalogue.dayTimeDurationItem).normalizedStandard( - PeriodType.dayTime() - ); + this.value = getDurationFromString(input.readString(), BuiltinTypesCatalogue.dayTimeDurationItem) + .normalizedStandard( + PeriodType.dayTime() + ); this.isNegative = this.value.toString().contains("-"); } diff --git a/src/main/java/org/rumbledb/items/DecimalItem.java b/src/main/java/org/rumbledb/items/DecimalItem.java index 9e55da5157..9bee0ef344 100644 --- a/src/main/java/org/rumbledb/items/DecimalItem.java +++ b/src/main/java/org/rumbledb/items/DecimalItem.java @@ -28,7 +28,6 @@ import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.math.BigDecimal; diff --git a/src/main/java/org/rumbledb/items/DoubleItem.java b/src/main/java/org/rumbledb/items/DoubleItem.java index 25d6007b4c..56a5bbc51d 100644 --- a/src/main/java/org/rumbledb/items/DoubleItem.java +++ b/src/main/java/org/rumbledb/items/DoubleItem.java @@ -30,7 +30,6 @@ import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.math.BigDecimal; diff --git a/src/main/java/org/rumbledb/items/DurationItem.java b/src/main/java/org/rumbledb/items/DurationItem.java index 89e85ecf0a..41ed6d7ca8 100644 --- a/src/main/java/org/rumbledb/items/DurationItem.java +++ b/src/main/java/org/rumbledb/items/DurationItem.java @@ -14,7 +14,6 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; diff --git a/src/main/java/org/rumbledb/items/FloatItem.java b/src/main/java/org/rumbledb/items/FloatItem.java index b63ae41ade..83b1e9d09f 100644 --- a/src/main/java/org/rumbledb/items/FloatItem.java +++ b/src/main/java/org/rumbledb/items/FloatItem.java @@ -29,7 +29,6 @@ import org.rumbledb.exceptions.IteratorFlowException; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.math.BigDecimal; diff --git a/src/main/java/org/rumbledb/items/HexBinaryItem.java b/src/main/java/org/rumbledb/items/HexBinaryItem.java index 8e2fda8200..9f4b8af58b 100644 --- a/src/main/java/org/rumbledb/items/HexBinaryItem.java +++ b/src/main/java/org/rumbledb/items/HexBinaryItem.java @@ -9,7 +9,6 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.util.Arrays; diff --git a/src/main/java/org/rumbledb/items/IntItem.java b/src/main/java/org/rumbledb/items/IntItem.java index 4b0cadd31f..2459fb3adc 100644 --- a/src/main/java/org/rumbledb/items/IntItem.java +++ b/src/main/java/org/rumbledb/items/IntItem.java @@ -29,7 +29,6 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.math.BigDecimal; diff --git a/src/main/java/org/rumbledb/items/IntegerItem.java b/src/main/java/org/rumbledb/items/IntegerItem.java index 91cab950ce..5ded036d70 100644 --- a/src/main/java/org/rumbledb/items/IntegerItem.java +++ b/src/main/java/org/rumbledb/items/IntegerItem.java @@ -28,7 +28,6 @@ import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.math.BigDecimal; diff --git a/src/main/java/org/rumbledb/items/NullItem.java b/src/main/java/org/rumbledb/items/NullItem.java index e3328f85b2..e49253e701 100644 --- a/src/main/java/org/rumbledb/items/NullItem.java +++ b/src/main/java/org/rumbledb/items/NullItem.java @@ -43,7 +43,6 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.ItemType; diff --git a/src/main/java/org/rumbledb/items/ObjectItem.java b/src/main/java/org/rumbledb/items/ObjectItem.java index 1b359d3f69..69ee4a5020 100644 --- a/src/main/java/org/rumbledb/items/ObjectItem.java +++ b/src/main/java/org/rumbledb/items/ObjectItem.java @@ -27,7 +27,6 @@ import org.rumbledb.api.Item; import org.rumbledb.exceptions.DuplicateObjectKeyException; import org.rumbledb.exceptions.ExceptionMetadata; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.util.ArrayList; diff --git a/src/main/java/org/rumbledb/items/StringItem.java b/src/main/java/org/rumbledb/items/StringItem.java index 5d4944c862..fc0df30b82 100644 --- a/src/main/java/org/rumbledb/items/StringItem.java +++ b/src/main/java/org/rumbledb/items/StringItem.java @@ -29,7 +29,6 @@ import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import java.math.BigDecimal; diff --git a/src/main/java/org/rumbledb/items/TimeItem.java b/src/main/java/org/rumbledb/items/TimeItem.java index 5bbb34d104..2f1f135ab5 100644 --- a/src/main/java/org/rumbledb/items/TimeItem.java +++ b/src/main/java/org/rumbledb/items/TimeItem.java @@ -9,7 +9,6 @@ import org.rumbledb.exceptions.ExceptionMetadata; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; diff --git a/src/main/java/org/rumbledb/items/YearMonthDurationItem.java b/src/main/java/org/rumbledb/items/YearMonthDurationItem.java index a58f112f03..0c5b29e779 100644 --- a/src/main/java/org/rumbledb/items/YearMonthDurationItem.java +++ b/src/main/java/org/rumbledb/items/YearMonthDurationItem.java @@ -6,7 +6,6 @@ import org.joda.time.DurationFieldType; import org.joda.time.Period; import org.joda.time.PeriodType; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; @@ -46,9 +45,10 @@ public boolean isYearMonthDuration() { @Override public void read(Kryo kryo, Input input) { - this.value = getDurationFromString(input.readString(), BuiltinTypesCatalogue.yearMonthDurationItem).normalizedStandard( - yearMonthPeriodType - ); + this.value = getDurationFromString(input.readString(), BuiltinTypesCatalogue.yearMonthDurationItem) + .normalizedStandard( + yearMonthPeriodType + ); this.isNegative = this.value.toString().contains("-"); } diff --git a/src/main/java/org/rumbledb/items/parsing/ItemParser.java b/src/main/java/org/rumbledb/items/parsing/ItemParser.java index fe75cc1a12..6d45463523 100644 --- a/src/main/java/org/rumbledb/items/parsing/ItemParser.java +++ b/src/main/java/org/rumbledb/items/parsing/ItemParser.java @@ -45,7 +45,6 @@ import org.rumbledb.runtime.typing.CastIterator; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import scala.collection.mutable.WrappedArray; diff --git a/src/main/java/org/rumbledb/runtime/AtMostOneItemLocalRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/AtMostOneItemLocalRuntimeIterator.java index 986ee438ec..288aebac23 100644 --- a/src/main/java/org/rumbledb/runtime/AtMostOneItemLocalRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/AtMostOneItemLocalRuntimeIterator.java @@ -31,7 +31,6 @@ import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import java.math.BigDecimal; diff --git a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java index 48dc1eb029..ed92dbcdaa 100644 --- a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java @@ -34,7 +34,6 @@ import org.rumbledb.exceptions.*; import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.runtime.flwor.NativeClauseContext; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; import org.rumbledb.runtime.operational.ComparisonIterator; diff --git a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java index 9d44bf9ccf..cfff251c63 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java +++ b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java @@ -53,7 +53,6 @@ import org.rumbledb.items.StringItem; import org.rumbledb.items.TimeItem; import org.rumbledb.items.YearMonthDurationItem; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index 78a6d3df48..c4b21ac39d 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -1041,9 +1041,9 @@ public static Dataset getDataFrameStartingClause( Dataset rows = iterator.getDataFrame(context); // escape backticks (`) - if(escapeBackticks) { + if (escapeBackticks) { rows = rows.sparkSession() - .createDataFrame(rows.rdd(), FlworDataFrameUtils.escapeSchema(rows.schema(), false)); + .createDataFrame(rows.rdd(), FlworDataFrameUtils.escapeSchema(rows.schema(), false)); } String[] fields = rows.schema().fieldNames(); diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java index 55bfb1218b..b20211d7cb 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/LetClauseSparkIterator.java @@ -46,7 +46,6 @@ import org.rumbledb.runtime.operational.ComparisonIterator; import org.rumbledb.runtime.postfix.PredicateIterator; import org.rumbledb.runtime.primary.VariableReferenceIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index d92e223e73..0add3e6cf9 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -45,7 +45,6 @@ import org.rumbledb.runtime.flwor.expression.OrderByClauseAnnotatedChildIterator; import org.rumbledb.runtime.flwor.udfs.OrderClauseCreateColumnsUDF; import org.rumbledb.runtime.flwor.udfs.OrderClauseDetermineTypeUDF; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import sparksoniq.jsoniq.tuple.FlworKey; diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ReturnClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ReturnClauseSparkIterator.java index df7e30002c..6593aef9c1 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ReturnClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ReturnClauseSparkIterator.java @@ -114,7 +114,7 @@ public JavaRDD getRDDAux(DynamicContext context) { Dataset df = this.child.getDataFrame(context, projection); // unescape backticks (`) - if(this.escapeBackticks) { + if (this.escapeBackticks) { df = df.sparkSession().createDataFrame(df.rdd(), FlworDataFrameUtils.escapeSchema(df.schema(), true)); } diff --git a/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java b/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java index 059180c123..8290592924 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java +++ b/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java @@ -33,7 +33,6 @@ import org.rumbledb.items.NullItem; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.expression.OrderByClauseAnnotatedChildIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java index 4cf6c30efd..0c0c9160f2 100644 --- a/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/durations/DayTimeDurationFunctionIterator.java @@ -11,7 +11,6 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import java.util.List; diff --git a/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java index 2e19693fc3..4bc7440c72 100644 --- a/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/durations/DurationFunctionIterator.java @@ -11,7 +11,6 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import java.util.List; diff --git a/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java index b16bd8bcd6..c2d4e6038f 100644 --- a/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/durations/YearMonthDurationFunctionIterator.java @@ -11,7 +11,6 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import java.util.List; diff --git a/src/main/java/org/rumbledb/runtime/functions/numerics/NumberFunctionIterator.java b/src/main/java/org/rumbledb/runtime/functions/numerics/NumberFunctionIterator.java index e622516b03..b3e64d2550 100644 --- a/src/main/java/org/rumbledb/runtime/functions/numerics/NumberFunctionIterator.java +++ b/src/main/java/org/rumbledb/runtime/functions/numerics/NumberFunctionIterator.java @@ -28,7 +28,6 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; import org.rumbledb.runtime.typing.CastIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import java.util.List; diff --git a/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java index 4bd40ab773..031d1a6147 100644 --- a/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/AndOperationIterator.java @@ -30,7 +30,6 @@ import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; public class AndOperationIterator extends AtMostOneItemLocalRuntimeIterator { diff --git a/src/main/java/org/rumbledb/runtime/operational/ComparisonIterator.java b/src/main/java/org/rumbledb/runtime/operational/ComparisonIterator.java index 7baa31e149..b6a2174382 100644 --- a/src/main/java/org/rumbledb/runtime/operational/ComparisonIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/ComparisonIterator.java @@ -37,7 +37,6 @@ import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import java.math.BigDecimal; diff --git a/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java index 60433ae022..34828ec351 100644 --- a/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/NotOperationIterator.java @@ -30,7 +30,6 @@ import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; public class NotOperationIterator extends AtMostOneItemLocalRuntimeIterator { diff --git a/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java b/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java index 2abc8da4b3..0af8a2702b 100644 --- a/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java +++ b/src/main/java/org/rumbledb/runtime/operational/OrOperationIterator.java @@ -30,7 +30,6 @@ import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; public class OrOperationIterator extends AtMostOneItemLocalRuntimeIterator { diff --git a/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java index ca968f6e50..d97161b1ba 100644 --- a/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/DecimalRuntimeIterator.java @@ -26,7 +26,6 @@ import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.flwor.NativeClauseContext; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import java.math.BigDecimal; diff --git a/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java index 9884462f78..0fd867f3f1 100644 --- a/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/DoubleRuntimeIterator.java @@ -26,7 +26,6 @@ import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.flwor.NativeClauseContext; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; @@ -49,6 +48,10 @@ public Item materializeFirstItemOrNull(DynamicContext context) { @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - return new NativeClauseContext(nativeClauseContext, "" + this.item.getDoubleValue(), BuiltinTypesCatalogue.doubleItem); + return new NativeClauseContext( + nativeClauseContext, + "" + this.item.getDoubleValue(), + BuiltinTypesCatalogue.doubleItem + ); } } diff --git a/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java index ad7f098abd..e6fcb72019 100644 --- a/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/IntegerRuntimeIterator.java @@ -26,7 +26,6 @@ import org.rumbledb.expressions.ExecutionMode; import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.flwor.NativeClauseContext; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; @@ -52,6 +51,10 @@ public Item materializeFirstItemOrNull(DynamicContext context) { @Override public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseContext) { - return new NativeClauseContext(nativeClauseContext, "" + this.item.getIntValue(), BuiltinTypesCatalogue.integerItem); + return new NativeClauseContext( + nativeClauseContext, + "" + this.item.getIntValue(), + BuiltinTypesCatalogue.integerItem + ); } } diff --git a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java index 74c333de34..2c86e683b5 100644 --- a/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/primary/StringRuntimeIterator.java @@ -28,7 +28,6 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.flwor.NativeClauseContext; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; public class StringRuntimeIterator extends AtMostOneItemLocalRuntimeIterator { diff --git a/src/main/java/org/rumbledb/runtime/typing/CastIterator.java b/src/main/java/org/rumbledb/runtime/typing/CastIterator.java index e1c28eb43e..c71f566938 100644 --- a/src/main/java/org/rumbledb/runtime/typing/CastIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/CastIterator.java @@ -13,7 +13,6 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java b/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java index b26fa23d46..184e95707c 100644 --- a/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java @@ -10,7 +10,6 @@ import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java b/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java index 39dbbe351c..4855e63200 100644 --- a/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java @@ -30,7 +30,6 @@ import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.sequences.general.InstanceOfClosure; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/org/rumbledb/runtime/typing/TypePromotionIterator.java b/src/main/java/org/rumbledb/runtime/typing/TypePromotionIterator.java index fde2837033..b4a26be4d8 100644 --- a/src/main/java/org/rumbledb/runtime/typing/TypePromotionIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/TypePromotionIterator.java @@ -14,7 +14,6 @@ import org.rumbledb.runtime.HybridRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.sequences.general.TypePromotionClosure; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -170,7 +169,10 @@ public Dataset getDataFrame(DynamicContext dynamicContext) { return df; } ItemType dataItemType = TreatIterator.getItemType(df); - if (dataItemType.isSubtypeOf(BuiltinTypesCatalogue.decimalItem) && this.itemType.equals(BuiltinTypesCatalogue.doubleItem)) { + if ( + dataItemType.isSubtypeOf(BuiltinTypesCatalogue.decimalItem) + && this.itemType.equals(BuiltinTypesCatalogue.doubleItem) + ) { df.createOrReplaceTempView("input"); df = df.sparkSession() .sql( diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 6ba2ea1e31..1314631ecd 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -7,61 +7,61 @@ public class AtomicItemType implements ItemType { private static final long serialVersionUID = 1L; // TODO: extract array and object into its own types - static final AtomicItemType atomicItem = new AtomicItemType( + static final AtomicItemType atomicItem = new AtomicItemType( new Name(Name.JS_NS, "js", "atomic") ); - static final AtomicItemType stringItem = new AtomicItemType( + static final AtomicItemType stringItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "string") ); - static final AtomicItemType integerItem = new AtomicItemType( + static final AtomicItemType integerItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "integer") ); - static final AtomicItemType decimalItem = new AtomicItemType( + static final AtomicItemType decimalItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "decimal") ); - static final AtomicItemType doubleItem = new AtomicItemType( + static final AtomicItemType doubleItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "double") ); - static final AtomicItemType floatItem = new AtomicItemType( + static final AtomicItemType floatItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "float") ); - static final AtomicItemType booleanItem = new AtomicItemType( + static final AtomicItemType booleanItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "boolean") ); - static final AtomicItemType nullItem = new AtomicItemType(new Name(Name.JS_NS, "js", "null")); - static final AtomicItemType durationItem = new AtomicItemType( + static final AtomicItemType nullItem = new AtomicItemType(new Name(Name.JS_NS, "js", "null")); + static final AtomicItemType durationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "duration") ); - static final AtomicItemType yearMonthDurationItem = new AtomicItemType( + static final AtomicItemType yearMonthDurationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "yearMonthDuration") ); - static final AtomicItemType dayTimeDurationItem = new AtomicItemType( + static final AtomicItemType dayTimeDurationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "dayTimeDuration") ); - static final AtomicItemType dateTimeItem = new AtomicItemType( + static final AtomicItemType dateTimeItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "dateTime") ); - static final AtomicItemType dateItem = new AtomicItemType(new Name(Name.XS_NS, "xs", "date")); - static final AtomicItemType timeItem = new AtomicItemType(new Name(Name.XS_NS, "xs", "time")); - static final AtomicItemType hexBinaryItem = new AtomicItemType( + static final AtomicItemType dateItem = new AtomicItemType(new Name(Name.XS_NS, "xs", "date")); + static final AtomicItemType timeItem = new AtomicItemType(new Name(Name.XS_NS, "xs", "time")); + static final AtomicItemType hexBinaryItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "hexBinary") ); - static final AtomicItemType anyURIItem = new AtomicItemType( + static final AtomicItemType anyURIItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "anyURI") ); - static final AtomicItemType base64BinaryItem = new AtomicItemType( + static final AtomicItemType base64BinaryItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "base64Binary") ); - static final AtomicItemType JSONItem = new AtomicItemType( + static final AtomicItemType JSONItem = new AtomicItemType( new Name(Name.JS_NS, "xs", "json-item") ); - static final AtomicItemType objectItem = new AtomicItemType( + static final AtomicItemType objectItem = new AtomicItemType( new Name(Name.JS_NS, "js", "object") ); - static final AtomicItemType arrayItem = new AtomicItemType( + static final AtomicItemType arrayItem = new AtomicItemType( new Name(Name.JS_NS, "js", "array") ); - static final AtomicItemType intItem = new AtomicItemType(Name.createVariableInDefaultTypeNamespace("int")); + static final AtomicItemType intItem = new AtomicItemType(Name.createVariableInDefaultTypeNamespace("int")); private Name name; diff --git a/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java b/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java index dcb6385242..9a4ddac519 100644 --- a/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java +++ b/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java @@ -47,28 +47,28 @@ public static boolean typeExists(Name name) { } private static final List builtInItemTypes = Arrays.asList( - objectItem, - atomicItem, - stringItem, - integerItem, - intItem, - decimalItem, - doubleItem, - floatItem, - booleanItem, - arrayItem, - nullItem, - JSONItem, - durationItem, - yearMonthDurationItem, - dayTimeDurationItem, - dateTimeItem, - dateItem, - timeItem, - hexBinaryItem, - anyURIItem, - base64BinaryItem, - item + objectItem, + atomicItem, + stringItem, + integerItem, + intItem, + decimalItem, + doubleItem, + floatItem, + booleanItem, + arrayItem, + nullItem, + JSONItem, + durationItem, + yearMonthDurationItem, + dayTimeDurationItem, + dateTimeItem, + dateItem, + timeItem, + hexBinaryItem, + anyURIItem, + base64BinaryItem, + item ); public static ItemType getItemTypeByName(Name name) { diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index 8f766e300c..36862b1bbd 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -1,6 +1,5 @@ package org.rumbledb.types; -import org.rumbledb.context.Name; import org.rumbledb.exceptions.OurBadException; public class FunctionItemType implements ItemType { @@ -43,7 +42,9 @@ public FunctionSignature getSignature() { @Override public boolean isSubtypeOf(ItemType superType) { - if (this.equals(superType) || superType.equals(anyFunctionItem) || superType.equals(BuiltinTypesCatalogue.item)) { + if ( + this.equals(superType) || superType.equals(anyFunctionItem) || superType.equals(BuiltinTypesCatalogue.item) + ) { return true; } if (superType.isFunctionItem() && this.signature.isSubtypeOf(superType.getSignature())) { diff --git a/src/main/java/org/rumbledb/types/ItemItemType.java b/src/main/java/org/rumbledb/types/ItemItemType.java index e0016dc0e7..6f5f024c88 100644 --- a/src/main/java/org/rumbledb/types/ItemItemType.java +++ b/src/main/java/org/rumbledb/types/ItemItemType.java @@ -12,11 +12,11 @@ public class ItemItemType implements ItemType { static final ItemType item = new ItemItemType(Name.createVariableInDefaultTypeNamespace("item")); private Name name; - public ItemItemType(){ + public ItemItemType() { } - private ItemItemType(Name name){ + private ItemItemType(Name name) { this.name = name; } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index c706fd70e7..566f347fa7 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -22,7 +22,6 @@ import org.rumbledb.context.Name; -import org.rumbledb.exceptions.OurBadException; import java.io.Serializable; @@ -109,7 +108,8 @@ public default FunctionSignature getSignature() { /** * * @param other another item type - * @return the common supertype between [this] and [other], that would be the LCA in the item type tree of [this] and [other] + * @return the common supertype between [this] and [other], that would be the LCA in the item type tree of [this] + * and [other] */ public ItemType findCommonSuperType(ItemType other); @@ -120,7 +120,9 @@ public default FunctionSignature getSignature() { * @return true if it is possible at static time to cast [this] to [other], false otherwise */ public default boolean isStaticallyCastableAs(ItemType other) { - throw new UnsupportedOperationException("isStaticallyCastableAs operation is not supported for non-atomic item types"); + throw new UnsupportedOperationException( + "isStaticallyCastableAs operation is not supported for non-atomic item types" + ); } /** diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index 76de65fba4..f3de78132d 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -274,7 +274,10 @@ public String toString() { sequenceTypes.put("object+", new SequenceType(BuiltinTypesCatalogue.objectItem, SequenceType.Arity.OneOrMore)); sequenceTypes.put("object*", new SequenceType(BuiltinTypesCatalogue.objectItem, SequenceType.Arity.ZeroOrMore)); - sequenceTypes.put("json-item*", new SequenceType(BuiltinTypesCatalogue.JSONItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put( + "json-item*", + new SequenceType(BuiltinTypesCatalogue.JSONItem, SequenceType.Arity.ZeroOrMore) + ); sequenceTypes.put("array?", new SequenceType(BuiltinTypesCatalogue.arrayItem, SequenceType.Arity.OneOrZero)); sequenceTypes.put("array*", new SequenceType(BuiltinTypesCatalogue.arrayItem, Arity.ZeroOrMore)); @@ -288,10 +291,19 @@ public String toString() { sequenceTypes.put("string*", new SequenceType(BuiltinTypesCatalogue.stringItem, SequenceType.Arity.ZeroOrMore)); sequenceTypes.put("integer", new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.One)); - sequenceTypes.put("integer?", new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("integer*", new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.ZeroOrMore)); + sequenceTypes.put( + "integer?", + new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.OneOrZero) + ); + sequenceTypes.put( + "integer*", + new SequenceType(BuiltinTypesCatalogue.integerItem, SequenceType.Arity.ZeroOrMore) + ); - sequenceTypes.put("decimal?", new SequenceType(BuiltinTypesCatalogue.decimalItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put( + "decimal?", + new SequenceType(BuiltinTypesCatalogue.decimalItem, SequenceType.Arity.OneOrZero) + ); sequenceTypes.put("double", new SequenceType(BuiltinTypesCatalogue.doubleItem, SequenceType.Arity.One)); sequenceTypes.put("double?", new SequenceType(BuiltinTypesCatalogue.doubleItem, SequenceType.Arity.OneOrZero)); @@ -300,9 +312,15 @@ public String toString() { sequenceTypes.put("float?", new SequenceType(BuiltinTypesCatalogue.floatItem, SequenceType.Arity.OneOrZero)); sequenceTypes.put("boolean", new SequenceType(BuiltinTypesCatalogue.booleanItem, SequenceType.Arity.One)); - sequenceTypes.put("boolean?", new SequenceType(BuiltinTypesCatalogue.booleanItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put( + "boolean?", + new SequenceType(BuiltinTypesCatalogue.booleanItem, SequenceType.Arity.OneOrZero) + ); - sequenceTypes.put("duration?", new SequenceType(BuiltinTypesCatalogue.durationItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put( + "duration?", + new SequenceType(BuiltinTypesCatalogue.durationItem, SequenceType.Arity.OneOrZero) + ); sequenceTypes.put( "yearMonthDuration?", @@ -314,7 +332,10 @@ public String toString() { new SequenceType(BuiltinTypesCatalogue.dayTimeDurationItem, SequenceType.Arity.OneOrZero) ); - sequenceTypes.put("dateTime?", new SequenceType(BuiltinTypesCatalogue.dateTimeItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put( + "dateTime?", + new SequenceType(BuiltinTypesCatalogue.dateTimeItem, SequenceType.Arity.OneOrZero) + ); sequenceTypes.put("date?", new SequenceType(BuiltinTypesCatalogue.dateItem, SequenceType.Arity.OneOrZero)); @@ -323,7 +344,10 @@ public String toString() { sequenceTypes.put("anyURI", new SequenceType(BuiltinTypesCatalogue.anyURIItem)); sequenceTypes.put("anyURI?", new SequenceType(BuiltinTypesCatalogue.anyURIItem, SequenceType.Arity.OneOrZero)); - sequenceTypes.put("hexBinary?", new SequenceType(BuiltinTypesCatalogue.hexBinaryItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put( + "hexBinary?", + new SequenceType(BuiltinTypesCatalogue.hexBinaryItem, SequenceType.Arity.OneOrZero) + ); sequenceTypes.put( "base64Binary?", diff --git a/src/main/java/sparksoniq/spark/DataFrameUtils.java b/src/main/java/sparksoniq/spark/DataFrameUtils.java index b38f4f3ca4..43357394d3 100644 --- a/src/main/java/sparksoniq/spark/DataFrameUtils.java +++ b/src/main/java/sparksoniq/spark/DataFrameUtils.java @@ -13,7 +13,6 @@ import org.rumbledb.exceptions.MLInvalidDataFrameSchemaException; import org.rumbledb.items.ObjectItem; import org.rumbledb.items.parsing.ItemParser; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; diff --git a/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java b/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java index 22ff76a467..502aba83a2 100644 --- a/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java +++ b/src/main/java/sparksoniq/spark/ml/ApplyEstimatorRuntimeIterator.java @@ -21,7 +21,6 @@ import org.rumbledb.items.FunctionItem; import org.rumbledb.runtime.AtMostOneItemLocalRuntimeIterator; import org.rumbledb.runtime.RuntimeIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java index 73a6f534d6..011ba47834 100644 --- a/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java +++ b/src/main/java/sparksoniq/spark/ml/GetEstimatorFunctionIterator.java @@ -33,9 +33,7 @@ import org.rumbledb.items.FunctionItem; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; -import org.rumbledb.types.FunctionItemType; import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java b/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java index ac24a16a11..c12ab7b965 100644 --- a/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java +++ b/src/main/java/sparksoniq/spark/ml/GetTransformerFunctionIterator.java @@ -33,7 +33,6 @@ import org.rumbledb.items.FunctionItem; import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.functions.base.LocalFunctionCallIterator; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.FunctionSignature; import org.rumbledb.types.SequenceType; diff --git a/src/main/java/sparksoniq/spark/ml/RumbleMLUtils.java b/src/main/java/sparksoniq/spark/ml/RumbleMLUtils.java index 9f9c0da143..ea130a2bd3 100644 --- a/src/main/java/sparksoniq/spark/ml/RumbleMLUtils.java +++ b/src/main/java/sparksoniq/spark/ml/RumbleMLUtils.java @@ -12,7 +12,6 @@ import org.rumbledb.exceptions.InvalidArgumentTypeException; import org.rumbledb.exceptions.InvalidRumbleMLParamException; import org.rumbledb.exceptions.OurBadException; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.items.ItemFactory; import org.rumbledb.runtime.typing.CastIterator; diff --git a/src/test/java/iq/FrontendTests.java b/src/test/java/iq/FrontendTests.java index 615cd56b22..2f334ac621 100644 --- a/src/test/java/iq/FrontendTests.java +++ b/src/test/java/iq/FrontendTests.java @@ -31,9 +31,7 @@ import org.rumbledb.expressions.module.MainModule; import org.rumbledb.expressions.primary.VariableReferenceExpression; import org.rumbledb.runtime.functions.input.FileSystemUtil; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; -import org.rumbledb.types.ItemType; import java.io.File; import java.net.URI; import java.util.Arrays; From 91dc23f39b8030b4bbfa2843328fedfbed1a1c3e Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sat, 13 Feb 2021 11:19:54 +0100 Subject: [PATCH 156/206] added function test parsing in grammar --- .../rumbledb/compiler/TranslationVisitor.java | 22 +- src/main/java/org/rumbledb/parser/Jsoniq.g4 | 9 +- .../rumbledb/parser/JsoniqBaseVisitor.java | 21 + .../org/rumbledb/parser/JsoniqParser.java | 1880 +++++++++-------- .../org/rumbledb/parser/JsoniqVisitor.java | 18 + 5 files changed, 1104 insertions(+), 846 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 50d1246f09..02795e5ee7 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -107,9 +107,7 @@ import org.rumbledb.parser.JsoniqParser.SetterContext; import org.rumbledb.parser.JsoniqParser.UriLiteralContext; import org.rumbledb.runtime.functions.input.FileSystemUtil; -import org.rumbledb.types.BuiltinTypesCatalogue; -import org.rumbledb.types.ItemType; -import org.rumbledb.types.SequenceType; +import org.rumbledb.types.*; import static org.rumbledb.types.SequenceType.MOST_GENERAL_SEQUENCE_TYPE; @@ -124,6 +122,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; /** @@ -1171,6 +1170,23 @@ public ItemType processItemType(JsoniqParser.ItemTypeContext itemTypeContext) { if (itemTypeContext.NullLiteral() != null) { return BuiltinTypesCatalogue.nullItem; } + JsoniqParser.FunctionTestContext fnCtx = itemTypeContext.functionTest(); + if(fnCtx != null){ + // we have a function item type + JsoniqParser.TypedFunctionTestContext typedFnCtx = fnCtx.typedFunctionTest(); + if(typedFnCtx != null){ + SequenceType rt = processSequenceType(typedFnCtx.rt); + List st = typedFnCtx.st.stream() + .map(this::processSequenceType) + .collect(Collectors.toList()); + FunctionSignature signature = new FunctionSignature(st, rt); + // TODO: move item type creation to ItemFactory + return new FunctionItemType(signature); + + } else { + return BuiltinTypesCatalogue.anyFunctionItem; + } + } return BuiltinTypesCatalogue.getItemTypeByName(parseName(itemTypeContext.qname(), false, true)); } diff --git a/src/main/java/org/rumbledb/parser/Jsoniq.g4 b/src/main/java/org/rumbledb/parser/Jsoniq.g4 index 93ac90ff79..0bddd67c89 100644 --- a/src/main/java/org/rumbledb/parser/Jsoniq.g4 +++ b/src/main/java/org/rumbledb/parser/Jsoniq.g4 @@ -227,7 +227,14 @@ objectConstructor : '{' ( pairConstructor (',' pairConstructor)* )? '}' | merge_operator+='{|' expr '|}'; itemType : qname - | NullLiteral; + | NullLiteral + | functionTest; + +functionTest : (anyFunctionTest | typedFunctionTest); + +anyFunctionTest : 'function' '(' '*' ')'; + +typedFunctionTest : 'function' '(' (st+=sequenceType (',' st+=sequenceType)*)? ')' 'as' rt=sequenceType; singleType : item=itemType (question +='?')?; diff --git a/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java b/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java index 05ba57584b..0438f83d0d 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java +++ b/src/main/java/org/rumbledb/parser/JsoniqBaseVisitor.java @@ -560,6 +560,27 @@ public class JsoniqBaseVisitor extends AbstractParseTreeVisitor implements * {@link #visitChildren} on {@code ctx}.

*/ @Override public T visitItemType(JsoniqParser.ItemTypeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFunctionTest(JsoniqParser.FunctionTestContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAnyFunctionTest(JsoniqParser.AnyFunctionTestContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTypedFunctionTest(JsoniqParser.TypedFunctionTestContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * diff --git a/src/main/java/org/rumbledb/parser/JsoniqParser.java b/src/main/java/org/rumbledb/parser/JsoniqParser.java index 3d29217c58..2614fe29fd 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqParser.java +++ b/src/main/java/org/rumbledb/parser/JsoniqParser.java @@ -71,9 +71,10 @@ public class JsoniqParser extends Parser { RULE_contextItemExpr = 66, RULE_orderedExpr = 67, RULE_unorderedExpr = 68, RULE_functionCall = 69, RULE_argumentList = 70, RULE_argument = 71, RULE_functionItemExpr = 72, RULE_namedFunctionRef = 73, RULE_inlineFunctionExpr = 74, RULE_sequenceType = 75, - RULE_objectConstructor = 76, RULE_itemType = 77, RULE_singleType = 78, - RULE_pairConstructor = 79, RULE_arrayConstructor = 80, RULE_uriLiteral = 81, - RULE_stringLiteral = 82, RULE_keyWords = 83; + RULE_objectConstructor = 76, RULE_itemType = 77, RULE_functionTest = 78, + RULE_anyFunctionTest = 79, RULE_typedFunctionTest = 80, RULE_singleType = 81, + RULE_pairConstructor = 82, RULE_arrayConstructor = 83, RULE_uriLiteral = 84, + RULE_stringLiteral = 85, RULE_keyWords = 86; public static final String[] ruleNames = { "moduleAndThisIsIt", "module", "mainModule", "libraryModule", "prolog", "setter", "namespaceDecl", "annotatedDecl", "defaultCollationDecl", "orderingModeDecl", @@ -90,8 +91,9 @@ public class JsoniqParser extends Parser { "primaryExpr", "varRef", "parenthesizedExpr", "contextItemExpr", "orderedExpr", "unorderedExpr", "functionCall", "argumentList", "argument", "functionItemExpr", "namedFunctionRef", "inlineFunctionExpr", "sequenceType", "objectConstructor", - "itemType", "singleType", "pairConstructor", "arrayConstructor", "uriLiteral", - "stringLiteral", "keyWords" + "itemType", "functionTest", "anyFunctionTest", "typedFunctionTest", "singleType", + "pairConstructor", "arrayConstructor", "uriLiteral", "stringLiteral", + "keyWords" }; private static final String[] _LITERAL_NAMES = { @@ -198,9 +200,9 @@ public final ModuleAndThisIsItContext moduleAndThisIsIt() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(168); + setState(174); module(); - setState(169); + setState(175); match(EOF); } } @@ -246,28 +248,28 @@ public final ModuleContext module() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(176); + setState(182); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,0,_ctx) ) { case 1: { - setState(171); + setState(177); match(Kjsoniq); - setState(172); + setState(178); match(Kversion); - setState(173); + setState(179); ((ModuleContext)_localctx).vers = stringLiteral(); - setState(174); + setState(180); match(T__0); } break; } - setState(180); + setState(186); _errHandler.sync(this); switch (_input.LA(1)) { case T__1: { - setState(178); + setState(184); libraryModule(); } break; @@ -333,7 +335,7 @@ public final ModuleContext module() throws RecognitionException { case Literal: case NCName: { - setState(179); + setState(185); ((ModuleContext)_localctx).main = mainModule(); } break; @@ -377,9 +379,9 @@ public final MainModuleContext mainModule() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(182); + setState(188); prolog(); - setState(183); + setState(189); expr(); } } @@ -419,19 +421,19 @@ public final LibraryModuleContext libraryModule() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(185); + setState(191); match(T__1); - setState(186); + setState(192); match(T__2); - setState(187); + setState(193); match(NCName); - setState(188); + setState(194); match(T__3); - setState(189); + setState(195); uriLiteral(); - setState(190); + setState(196); match(T__0); - setState(191); + setState(197); prolog(); } } @@ -490,57 +492,57 @@ public final PrologContext prolog() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(202); + setState(208); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,3,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(196); + setState(202); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) { case 1: { - setState(193); + setState(199); setter(); } break; case 2: { - setState(194); + setState(200); namespaceDecl(); } break; case 3: { - setState(195); + setState(201); moduleImport(); } break; } - setState(198); + setState(204); match(T__0); } } } - setState(204); + setState(210); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,3,_ctx); } - setState(210); + setState(216); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__4) { { { - setState(205); + setState(211); annotatedDecl(); - setState(206); + setState(212); match(T__0); } } - setState(212); + setState(218); _errHandler.sync(this); _la = _input.LA(1); } @@ -585,34 +587,34 @@ public final SetterContext setter() throws RecognitionException { SetterContext _localctx = new SetterContext(_ctx, getState()); enterRule(_localctx, 10, RULE_setter); try { - setState(217); + setState(223); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,5,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(213); + setState(219); defaultCollationDecl(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(214); + setState(220); orderingModeDecl(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(215); + setState(221); emptyOrderDecl(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(216); + setState(222); decimalFormatDecl(); } break; @@ -651,15 +653,15 @@ public final NamespaceDeclContext namespaceDecl() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(219); + setState(225); match(T__4); - setState(220); + setState(226); match(T__2); - setState(221); + setState(227); match(NCName); - setState(222); + setState(228); match(T__3); - setState(223); + setState(229); uriLiteral(); } } @@ -696,20 +698,20 @@ public final AnnotatedDeclContext annotatedDecl() throws RecognitionException { AnnotatedDeclContext _localctx = new AnnotatedDeclContext(_ctx, getState()); enterRule(_localctx, 14, RULE_annotatedDecl); try { - setState(227); + setState(233); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(225); + setState(231); functionDecl(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(226); + setState(232); varDecl(); } break; @@ -749,13 +751,13 @@ public final DefaultCollationDeclContext defaultCollationDecl() throws Recogniti try { enterOuterAlt(_localctx, 1); { - setState(229); + setState(235); match(T__4); - setState(230); + setState(236); match(Kdefault); - setState(231); + setState(237); match(Kcollation); - setState(232); + setState(238); uriLiteral(); } } @@ -789,11 +791,11 @@ public final OrderingModeDeclContext orderingModeDecl() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(234); + setState(240); match(T__4); - setState(235); + setState(241); match(T__5); - setState(236); + setState(242); _la = _input.LA(1); if ( !(_la==T__6 || _la==T__7) ) { _errHandler.recoverInline(this); @@ -840,16 +842,16 @@ public final EmptyOrderDeclContext emptyOrderDecl() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(238); + setState(244); match(T__4); - setState(239); + setState(245); match(Kdefault); - setState(240); + setState(246); match(Korder); - setState(241); + setState(247); match(Kempty); { - setState(242); + setState(248); ((EmptyOrderDeclContext)_localctx).emptySequenceOrder = _input.LT(1); _la = _input.LA(1); if ( !(_la==Kgreatest || _la==Kleast) ) { @@ -909,17 +911,17 @@ public final DecimalFormatDeclContext decimalFormatDecl() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(244); + setState(250); match(T__4); - setState(249); + setState(255); _errHandler.sync(this); switch (_input.LA(1)) { case T__8: { { - setState(245); + setState(251); match(T__8); - setState(246); + setState(252); qname(); } } @@ -927,9 +929,9 @@ public final DecimalFormatDeclContext decimalFormatDecl() throws RecognitionExce case Kdefault: { { - setState(247); + setState(253); match(Kdefault); - setState(248); + setState(254); match(T__8); } } @@ -937,21 +939,21 @@ public final DecimalFormatDeclContext decimalFormatDecl() throws RecognitionExce default: throw new NoViableAltException(this); } - setState(257); + setState(263); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__14) | (1L << T__15) | (1L << T__16) | (1L << T__17) | (1L << T__18) | (1L << T__19))) != 0)) { { { - setState(251); + setState(257); dfPropertyName(); - setState(252); + setState(258); match(T__3); - setState(253); + setState(259); stringLiteral(); } } - setState(259); + setState(265); _errHandler.sync(this); _la = _input.LA(1); } @@ -1000,17 +1002,17 @@ public final QnameContext qname() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(265); + setState(271); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,10,_ctx) ) { case 1: { - setState(262); + setState(268); _errHandler.sync(this); switch (_input.LA(1)) { case NCName: { - setState(260); + setState(266); ((QnameContext)_localctx).ns = match(NCName); } break; @@ -1060,30 +1062,30 @@ public final QnameContext qname() throws RecognitionException { case Kjsoniq: case NullLiteral: { - setState(261); + setState(267); ((QnameContext)_localctx).nskw = keyWords(); } break; default: throw new NoViableAltException(this); } - setState(264); + setState(270); match(T__9); } break; } - setState(269); + setState(275); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,11,_ctx) ) { case 1: { - setState(267); + setState(273); ((QnameContext)_localctx).local_name = nCNameOrKeyWord(); } break; case 2: { - setState(268); + setState(274); ((QnameContext)_localctx).local_namekw = keyWords(); } break; @@ -1122,7 +1124,7 @@ public final NCNameOrKeyWordContext nCNameOrKeyWord() throws RecognitionExceptio try { enterOuterAlt(_localctx, 1); { - setState(271); + setState(277); _la = _input.LA(1); if ( !(_la==NullLiteral || _la==NCName) ) { _errHandler.recoverInline(this); @@ -1164,7 +1166,7 @@ public final DfPropertyNameContext dfPropertyName() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(273); + setState(279); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__14) | (1L << T__15) | (1L << T__16) | (1L << T__17) | (1L << T__18) | (1L << T__19))) != 0)) ) { _errHandler.recoverInline(this); @@ -1216,48 +1218,48 @@ public final ModuleImportContext moduleImport() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(275); + setState(281); match(T__20); - setState(276); + setState(282); match(T__1); - setState(280); + setState(286); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__2) { { - setState(277); + setState(283); match(T__2); - setState(278); + setState(284); ((ModuleImportContext)_localctx).prefix = match(NCName); - setState(279); + setState(285); match(T__3); } } - setState(282); + setState(288); ((ModuleImportContext)_localctx).targetNamespace = uriLiteral(); - setState(292); + setState(298); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kat) { { - setState(283); + setState(289); match(Kat); - setState(284); + setState(290); uriLiteral(); - setState(289); + setState(295); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(285); + setState(291); match(T__21); - setState(286); + setState(292); uriLiteral(); } } - setState(291); + setState(297); _errHandler.sync(this); _la = _input.LA(1); } @@ -1307,33 +1309,33 @@ public final VarDeclContext varDecl() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(294); + setState(300); match(T__4); - setState(295); + setState(301); match(T__22); - setState(296); + setState(302); varRef(); - setState(299); + setState(305); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(297); + setState(303); match(Kas); - setState(298); + setState(304); sequenceType(); } } - setState(308); + setState(314); _errHandler.sync(this); switch (_input.LA(1)) { case T__23: { { - setState(301); + setState(307); match(T__23); - setState(302); + setState(308); exprSingle(); } } @@ -1341,16 +1343,16 @@ public final VarDeclContext varDecl() throws RecognitionException { case T__24: { { - setState(303); + setState(309); ((VarDeclContext)_localctx).external = match(T__24); - setState(306); + setState(312); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__23) { { - setState(304); + setState(310); match(T__23); - setState(305); + setState(311); exprSingle(); } } @@ -1409,62 +1411,62 @@ public final FunctionDeclContext functionDecl() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(310); + setState(316); match(T__4); - setState(311); + setState(317); match(T__25); - setState(312); + setState(318); ((FunctionDeclContext)_localctx).fn_name = qname(); - setState(313); + setState(319); match(T__26); - setState(315); + setState(321); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(314); + setState(320); paramList(); } } - setState(317); + setState(323); match(T__27); - setState(320); + setState(326); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(318); + setState(324); match(Kas); - setState(319); + setState(325); ((FunctionDeclContext)_localctx).return_type = sequenceType(); } } - setState(328); + setState(334); _errHandler.sync(this); switch (_input.LA(1)) { case T__28: { - setState(322); + setState(328); match(T__28); - setState(324); + setState(330); _errHandler.sync(this); _la = _input.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { { - setState(323); + setState(329); ((FunctionDeclContext)_localctx).fn_body = expr(); } } - setState(326); + setState(332); match(T__29); } break; case T__24: { - setState(327); + setState(333); match(T__24); } break; @@ -1509,21 +1511,21 @@ public final ParamListContext paramList() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(330); + setState(336); param(); - setState(335); + setState(341); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(331); + setState(337); match(T__21); - setState(332); + setState(338); param(); } } - setState(337); + setState(343); _errHandler.sync(this); _la = _input.LA(1); } @@ -1566,18 +1568,18 @@ public final ParamContext param() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(338); + setState(344); match(T__30); - setState(339); + setState(345); qname(); - setState(342); + setState(348); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(340); + setState(346); match(Kas); - setState(341); + setState(347); sequenceType(); } } @@ -1620,21 +1622,21 @@ public final ExprContext expr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(344); + setState(350); exprSingle(); - setState(349); + setState(355); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(345); + setState(351); match(T__21); - setState(346); + setState(352); exprSingle(); } } - setState(351); + setState(357); _errHandler.sync(this); _la = _input.LA(1); } @@ -1688,55 +1690,55 @@ public final ExprSingleContext exprSingle() throws RecognitionException { ExprSingleContext _localctx = new ExprSingleContext(_ctx, getState()); enterRule(_localctx, 42, RULE_exprSingle); try { - setState(359); + setState(365); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,25,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(352); + setState(358); flowrExpr(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(353); + setState(359); quantifiedExpr(); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(354); + setState(360); switchExpr(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(355); + setState(361); typeSwitchExpr(); } break; case 5: enterOuterAlt(_localctx, 5); { - setState(356); + setState(362); ifExpr(); } break; case 6: enterOuterAlt(_localctx, 6); { - setState(357); + setState(363); tryCatchExpr(); } break; case 7: enterOuterAlt(_localctx, 7); { - setState(358); + setState(364); orExpr(); } break; @@ -1815,66 +1817,66 @@ public final FlowrExprContext flowrExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(363); + setState(369); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: { - setState(361); + setState(367); ((FlowrExprContext)_localctx).start_for = forClause(); } break; case Klet: { - setState(362); + setState(368); ((FlowrExprContext)_localctx).start_let = letClause(); } break; default: throw new NoViableAltException(this); } - setState(373); + setState(379); _errHandler.sync(this); _la = _input.LA(1); while (((((_la - 59)) & ~0x3f) == 0 && ((1L << (_la - 59)) & ((1L << (Kfor - 59)) | (1L << (Klet - 59)) | (1L << (Kwhere - 59)) | (1L << (Kgroup - 59)) | (1L << (Korder - 59)) | (1L << (Kcount - 59)) | (1L << (Kstable - 59)))) != 0)) { { - setState(371); + setState(377); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: { - setState(365); + setState(371); forClause(); } break; case Kwhere: { - setState(366); + setState(372); whereClause(); } break; case Klet: { - setState(367); + setState(373); letClause(); } break; case Kgroup: { - setState(368); + setState(374); groupByClause(); } break; case Korder: case Kstable: { - setState(369); + setState(375); orderByClause(); } break; case Kcount: { - setState(370); + setState(376); countClause(); } break; @@ -1882,13 +1884,13 @@ public final FlowrExprContext flowrExpr() throws RecognitionException { throw new NoViableAltException(this); } } - setState(375); + setState(381); _errHandler.sync(this); _la = _input.LA(1); } - setState(376); + setState(382); match(Kreturn); - setState(377); + setState(383); ((FlowrExprContext)_localctx).return_expr = exprSingle(); } } @@ -1931,25 +1933,25 @@ public final ForClauseContext forClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(379); + setState(385); match(Kfor); - setState(380); + setState(386); ((ForClauseContext)_localctx).forVar = forVar(); ((ForClauseContext)_localctx).vars.add(((ForClauseContext)_localctx).forVar); - setState(385); + setState(391); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(381); + setState(387); match(T__21); - setState(382); + setState(388); ((ForClauseContext)_localctx).forVar = forVar(); ((ForClauseContext)_localctx).vars.add(((ForClauseContext)_localctx).forVar); } } - setState(387); + setState(393); _errHandler.sync(this); _la = _input.LA(1); } @@ -2007,47 +2009,47 @@ public final ForVarContext forVar() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(388); + setState(394); ((ForVarContext)_localctx).var_ref = varRef(); - setState(391); + setState(397); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(389); + setState(395); match(Kas); - setState(390); + setState(396); ((ForVarContext)_localctx).seq = sequenceType(); } } - setState(395); + setState(401); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kallowing) { { - setState(393); + setState(399); ((ForVarContext)_localctx).flag = match(Kallowing); - setState(394); + setState(400); match(Kempty); } } - setState(399); + setState(405); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kat) { { - setState(397); + setState(403); match(Kat); - setState(398); + setState(404); ((ForVarContext)_localctx).at = varRef(); } } - setState(401); + setState(407); match(Kin); - setState(402); + setState(408); ((ForVarContext)_localctx).ex = exprSingle(); } } @@ -2090,25 +2092,25 @@ public final LetClauseContext letClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(404); + setState(410); match(Klet); - setState(405); + setState(411); ((LetClauseContext)_localctx).letVar = letVar(); ((LetClauseContext)_localctx).vars.add(((LetClauseContext)_localctx).letVar); - setState(410); + setState(416); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(406); + setState(412); match(T__21); - setState(407); + setState(413); ((LetClauseContext)_localctx).letVar = letVar(); ((LetClauseContext)_localctx).vars.add(((LetClauseContext)_localctx).letVar); } } - setState(412); + setState(418); _errHandler.sync(this); _la = _input.LA(1); } @@ -2157,23 +2159,23 @@ public final LetVarContext letVar() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(413); + setState(419); ((LetVarContext)_localctx).var_ref = varRef(); - setState(416); + setState(422); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(414); + setState(420); match(Kas); - setState(415); + setState(421); ((LetVarContext)_localctx).seq = sequenceType(); } } - setState(418); + setState(424); match(T__23); - setState(419); + setState(425); ((LetVarContext)_localctx).ex = exprSingle(); } } @@ -2210,9 +2212,9 @@ public final WhereClauseContext whereClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(421); + setState(427); match(Kwhere); - setState(422); + setState(428); exprSingle(); } } @@ -2256,27 +2258,27 @@ public final GroupByClauseContext groupByClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(424); + setState(430); match(Kgroup); - setState(425); + setState(431); match(Kby); - setState(426); + setState(432); ((GroupByClauseContext)_localctx).groupByVar = groupByVar(); ((GroupByClauseContext)_localctx).vars.add(((GroupByClauseContext)_localctx).groupByVar); - setState(431); + setState(437); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(427); + setState(433); match(T__21); - setState(428); + setState(434); ((GroupByClauseContext)_localctx).groupByVar = groupByVar(); ((GroupByClauseContext)_localctx).vars.add(((GroupByClauseContext)_localctx).groupByVar); } } - setState(433); + setState(439); _errHandler.sync(this); _la = _input.LA(1); } @@ -2331,40 +2333,40 @@ public final GroupByVarContext groupByVar() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(434); + setState(440); ((GroupByVarContext)_localctx).var_ref = varRef(); - setState(441); + setState(447); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__23 || _la==Kas) { { - setState(437); + setState(443); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(435); + setState(441); match(Kas); - setState(436); + setState(442); ((GroupByVarContext)_localctx).seq = sequenceType(); } } - setState(439); + setState(445); ((GroupByVarContext)_localctx).decl = match(T__23); - setState(440); + setState(446); ((GroupByVarContext)_localctx).ex = exprSingle(); } } - setState(445); + setState(451); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kcollation) { { - setState(443); + setState(449); match(Kcollation); - setState(444); + setState(450); ((GroupByVarContext)_localctx).uri = uriLiteral(); } } @@ -2411,15 +2413,15 @@ public final OrderByClauseContext orderByClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(452); + setState(458); _errHandler.sync(this); switch (_input.LA(1)) { case Korder: { { - setState(447); + setState(453); match(Korder); - setState(448); + setState(454); match(Kby); } } @@ -2427,11 +2429,11 @@ public final OrderByClauseContext orderByClause() throws RecognitionException { case Kstable: { { - setState(449); + setState(455); ((OrderByClauseContext)_localctx).stb = match(Kstable); - setState(450); + setState(456); match(Korder); - setState(451); + setState(457); match(Kby); } } @@ -2439,21 +2441,21 @@ public final OrderByClauseContext orderByClause() throws RecognitionException { default: throw new NoViableAltException(this); } - setState(454); + setState(460); orderByExpr(); - setState(459); + setState(465); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(455); + setState(461); match(T__21); - setState(456); + setState(462); orderByExpr(); } } - setState(461); + setState(467); _errHandler.sync(this); _la = _input.LA(1); } @@ -2506,20 +2508,20 @@ public final OrderByExprContext orderByExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(462); + setState(468); ((OrderByExprContext)_localctx).ex = exprSingle(); - setState(465); + setState(471); _errHandler.sync(this); switch (_input.LA(1)) { case Kascending: { - setState(463); + setState(469); match(Kascending); } break; case Kdescending: { - setState(464); + setState(470); ((OrderByExprContext)_localctx).desc = match(Kdescending); } break; @@ -2538,25 +2540,25 @@ public final OrderByExprContext orderByExpr() throws RecognitionException { default: break; } - setState(472); + setState(478); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kempty) { { - setState(467); + setState(473); match(Kempty); - setState(470); + setState(476); _errHandler.sync(this); switch (_input.LA(1)) { case Kgreatest: { - setState(468); + setState(474); ((OrderByExprContext)_localctx).gr = match(Kgreatest); } break; case Kleast: { - setState(469); + setState(475); ((OrderByExprContext)_localctx).ls = match(Kleast); } break; @@ -2566,14 +2568,14 @@ public final OrderByExprContext orderByExpr() throws RecognitionException { } } - setState(476); + setState(482); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kcollation) { { - setState(474); + setState(480); match(Kcollation); - setState(475); + setState(481); ((OrderByExprContext)_localctx).uril = uriLiteral(); } } @@ -2613,9 +2615,9 @@ public final CountClauseContext countClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(478); + setState(484); match(Kcount); - setState(479); + setState(485); varRef(); } } @@ -2665,47 +2667,47 @@ public final QuantifiedExprContext quantifiedExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(483); + setState(489); _errHandler.sync(this); switch (_input.LA(1)) { case Ksome: { - setState(481); + setState(487); ((QuantifiedExprContext)_localctx).so = match(Ksome); } break; case Kevery: { - setState(482); + setState(488); ((QuantifiedExprContext)_localctx).ev = match(Kevery); } break; default: throw new NoViableAltException(this); } - setState(485); + setState(491); ((QuantifiedExprContext)_localctx).quantifiedExprVar = quantifiedExprVar(); ((QuantifiedExprContext)_localctx).vars.add(((QuantifiedExprContext)_localctx).quantifiedExprVar); - setState(490); + setState(496); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(486); + setState(492); match(T__21); - setState(487); + setState(493); ((QuantifiedExprContext)_localctx).quantifiedExprVar = quantifiedExprVar(); ((QuantifiedExprContext)_localctx).vars.add(((QuantifiedExprContext)_localctx).quantifiedExprVar); } } - setState(492); + setState(498); _errHandler.sync(this); _la = _input.LA(1); } - setState(493); + setState(499); match(Ksatisfies); - setState(494); + setState(500); exprSingle(); } } @@ -2750,23 +2752,23 @@ public final QuantifiedExprVarContext quantifiedExprVar() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(496); + setState(502); varRef(); - setState(499); + setState(505); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(497); + setState(503); match(Kas); - setState(498); + setState(504); sequenceType(); } } - setState(501); + setState(507); match(Kin); - setState(502); + setState(508); exprSingle(); } } @@ -2819,34 +2821,34 @@ public final SwitchExprContext switchExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(504); + setState(510); match(Kswitch); - setState(505); + setState(511); match(T__26); - setState(506); + setState(512); ((SwitchExprContext)_localctx).cond = expr(); - setState(507); + setState(513); match(T__27); - setState(509); + setState(515); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(508); + setState(514); ((SwitchExprContext)_localctx).switchCaseClause = switchCaseClause(); ((SwitchExprContext)_localctx).cases.add(((SwitchExprContext)_localctx).switchCaseClause); } } - setState(511); + setState(517); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Kcase ); - setState(513); + setState(519); match(Kdefault); - setState(514); + setState(520); match(Kreturn); - setState(515); + setState(521); ((SwitchExprContext)_localctx).def = exprSingle(); } } @@ -2894,26 +2896,26 @@ public final SwitchCaseClauseContext switchCaseClause() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(519); + setState(525); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(517); + setState(523); match(Kcase); - setState(518); + setState(524); ((SwitchCaseClauseContext)_localctx).exprSingle = exprSingle(); ((SwitchCaseClauseContext)_localctx).cond.add(((SwitchCaseClauseContext)_localctx).exprSingle); } } - setState(521); + setState(527); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Kcase ); - setState(523); + setState(529); match(Kreturn); - setState(524); + setState(530); ((SwitchCaseClauseContext)_localctx).ret = exprSingle(); } } @@ -2970,44 +2972,44 @@ public final TypeSwitchExprContext typeSwitchExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(526); + setState(532); match(Ktypeswitch); - setState(527); + setState(533); match(T__26); - setState(528); + setState(534); ((TypeSwitchExprContext)_localctx).cond = expr(); - setState(529); + setState(535); match(T__27); - setState(531); + setState(537); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(530); + setState(536); ((TypeSwitchExprContext)_localctx).caseClause = caseClause(); ((TypeSwitchExprContext)_localctx).cses.add(((TypeSwitchExprContext)_localctx).caseClause); } } - setState(533); + setState(539); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==Kcase ); - setState(535); + setState(541); match(Kdefault); - setState(537); + setState(543); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(536); + setState(542); ((TypeSwitchExprContext)_localctx).var_ref = varRef(); } } - setState(539); + setState(545); match(Kreturn); - setState(540); + setState(546); ((TypeSwitchExprContext)_localctx).def = exprSingle(); } } @@ -3060,43 +3062,43 @@ public final CaseClauseContext caseClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(542); + setState(548); match(Kcase); - setState(546); + setState(552); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(543); + setState(549); ((CaseClauseContext)_localctx).var_ref = varRef(); - setState(544); + setState(550); match(Kas); } } - setState(548); + setState(554); ((CaseClauseContext)_localctx).sequenceType = sequenceType(); ((CaseClauseContext)_localctx).union.add(((CaseClauseContext)_localctx).sequenceType); - setState(553); + setState(559); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__31) { { { - setState(549); + setState(555); match(T__31); - setState(550); + setState(556); ((CaseClauseContext)_localctx).sequenceType = sequenceType(); ((CaseClauseContext)_localctx).union.add(((CaseClauseContext)_localctx).sequenceType); } } - setState(555); + setState(561); _errHandler.sync(this); _la = _input.LA(1); } - setState(556); + setState(562); match(Kreturn); - setState(557); + setState(563); ((CaseClauseContext)_localctx).ret = exprSingle(); } } @@ -3144,21 +3146,21 @@ public final IfExprContext ifExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(559); + setState(565); match(Kif); - setState(560); + setState(566); match(T__26); - setState(561); + setState(567); ((IfExprContext)_localctx).test_condition = expr(); - setState(562); + setState(568); match(T__27); - setState(563); + setState(569); match(Kthen); - setState(564); + setState(570); ((IfExprContext)_localctx).branch = exprSingle(); - setState(565); + setState(571); match(Kelse); - setState(566); + setState(572); ((IfExprContext)_localctx).else_branch = exprSingle(); } } @@ -3205,15 +3207,15 @@ public final TryCatchExprContext tryCatchExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(568); + setState(574); match(Ktry); - setState(569); + setState(575); match(T__28); - setState(570); + setState(576); ((TryCatchExprContext)_localctx).try_expression = expr(); - setState(571); + setState(577); match(T__29); - setState(573); + setState(579); _errHandler.sync(this); _alt = 1; do { @@ -3221,7 +3223,7 @@ public final TryCatchExprContext tryCatchExpr() throws RecognitionException { case 1: { { - setState(572); + setState(578); ((TryCatchExprContext)_localctx).catchClause = catchClause(); ((TryCatchExprContext)_localctx).catches.add(((TryCatchExprContext)_localctx).catchClause); } @@ -3230,7 +3232,7 @@ public final TryCatchExprContext tryCatchExpr() throws RecognitionException { default: throw new NoViableAltException(this); } - setState(575); + setState(581); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,54,_ctx); } while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); @@ -3281,14 +3283,14 @@ public final CatchClauseContext catchClause() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(577); + setState(583); match(Kcatch); - setState(580); + setState(586); _errHandler.sync(this); switch (_input.LA(1)) { case T__32: { - setState(578); + setState(584); ((CatchClauseContext)_localctx).s33 = match(T__32); ((CatchClauseContext)_localctx).jokers.add(((CatchClauseContext)_localctx).s33); } @@ -3340,7 +3342,7 @@ public final CatchClauseContext catchClause() throws RecognitionException { case NullLiteral: case NCName: { - setState(579); + setState(585); ((CatchClauseContext)_localctx).qname = qname(); ((CatchClauseContext)_localctx).errors.add(((CatchClauseContext)_localctx).qname); } @@ -3348,20 +3350,20 @@ public final CatchClauseContext catchClause() throws RecognitionException { default: throw new NoViableAltException(this); } - setState(589); + setState(595); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__31) { { { - setState(582); + setState(588); match(T__31); - setState(585); + setState(591); _errHandler.sync(this); switch (_input.LA(1)) { case T__32: { - setState(583); + setState(589); ((CatchClauseContext)_localctx).s33 = match(T__32); ((CatchClauseContext)_localctx).jokers.add(((CatchClauseContext)_localctx).s33); } @@ -3413,7 +3415,7 @@ public final CatchClauseContext catchClause() throws RecognitionException { case NullLiteral: case NCName: { - setState(584); + setState(590); ((CatchClauseContext)_localctx).qname = qname(); ((CatchClauseContext)_localctx).errors.add(((CatchClauseContext)_localctx).qname); } @@ -3423,15 +3425,15 @@ public final CatchClauseContext catchClause() throws RecognitionException { } } } - setState(591); + setState(597); _errHandler.sync(this); _la = _input.LA(1); } - setState(592); + setState(598); match(T__28); - setState(593); + setState(599); ((CatchClauseContext)_localctx).catch_expression = expr(); - setState(594); + setState(600); match(T__29); } } @@ -3478,24 +3480,24 @@ public final OrExprContext orExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(596); + setState(602); ((OrExprContext)_localctx).main_expr = andExpr(); - setState(601); + setState(607); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,58,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(597); + setState(603); match(Kor); - setState(598); + setState(604); ((OrExprContext)_localctx).andExpr = andExpr(); ((OrExprContext)_localctx).rhs.add(((OrExprContext)_localctx).andExpr); } } } - setState(603); + setState(609); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,58,_ctx); } @@ -3544,24 +3546,24 @@ public final AndExprContext andExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(604); + setState(610); ((AndExprContext)_localctx).main_expr = notExpr(); - setState(609); + setState(615); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,59,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(605); + setState(611); match(Kand); - setState(606); + setState(612); ((AndExprContext)_localctx).notExpr = notExpr(); ((AndExprContext)_localctx).rhs.add(((AndExprContext)_localctx).notExpr); } } } - setState(611); + setState(617); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,59,_ctx); } @@ -3603,18 +3605,18 @@ public final NotExprContext notExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(613); + setState(619); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,60,_ctx) ) { case 1: { - setState(612); + setState(618); ((NotExprContext)_localctx).Knot = match(Knot); ((NotExprContext)_localctx).op.add(((NotExprContext)_localctx).Knot); } break; } - setState(615); + setState(621); ((NotExprContext)_localctx).main_expr = comparisonExpr(); } } @@ -3671,14 +3673,14 @@ public final ComparisonExprContext comparisonExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(617); + setState(623); ((ComparisonExprContext)_localctx).main_expr = stringConcatExpr(); - setState(620); + setState(626); _errHandler.sync(this); _la = _input.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40) | (1L << T__41) | (1L << T__42) | (1L << T__43))) != 0)) { { - setState(618); + setState(624); ((ComparisonExprContext)_localctx)._tset1171 = _input.LT(1); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40) | (1L << T__41) | (1L << T__42) | (1L << T__43))) != 0)) ) { @@ -3690,7 +3692,7 @@ public final ComparisonExprContext comparisonExpr() throws RecognitionException consume(); } ((ComparisonExprContext)_localctx).op.add(((ComparisonExprContext)_localctx)._tset1171); - setState(619); + setState(625); ((ComparisonExprContext)_localctx).stringConcatExpr = stringConcatExpr(); ((ComparisonExprContext)_localctx).rhs.add(((ComparisonExprContext)_localctx).stringConcatExpr); } @@ -3737,22 +3739,22 @@ public final StringConcatExprContext stringConcatExpr() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(622); + setState(628); ((StringConcatExprContext)_localctx).main_expr = rangeExpr(); - setState(627); + setState(633); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__44) { { { - setState(623); + setState(629); match(T__44); - setState(624); + setState(630); ((StringConcatExprContext)_localctx).rangeExpr = rangeExpr(); ((StringConcatExprContext)_localctx).rhs.add(((StringConcatExprContext)_localctx).rangeExpr); } } - setState(629); + setState(635); _errHandler.sync(this); _la = _input.LA(1); } @@ -3797,16 +3799,16 @@ public final RangeExprContext rangeExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(630); + setState(636); ((RangeExprContext)_localctx).main_expr = additiveExpr(); - setState(633); + setState(639); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,63,_ctx) ) { case 1: { - setState(631); + setState(637); match(Kto); - setState(632); + setState(638); ((RangeExprContext)_localctx).additiveExpr = additiveExpr(); ((RangeExprContext)_localctx).rhs.add(((RangeExprContext)_localctx).additiveExpr); } @@ -3858,16 +3860,16 @@ public final AdditiveExprContext additiveExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(635); + setState(641); ((AdditiveExprContext)_localctx).main_expr = multiplicativeExpr(); - setState(640); + setState(646); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,64,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - setState(636); + setState(642); ((AdditiveExprContext)_localctx)._tset1280 = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__45 || _la==T__46) ) { @@ -3879,13 +3881,13 @@ public final AdditiveExprContext additiveExpr() throws RecognitionException { consume(); } ((AdditiveExprContext)_localctx).op.add(((AdditiveExprContext)_localctx)._tset1280); - setState(637); + setState(643); ((AdditiveExprContext)_localctx).multiplicativeExpr = multiplicativeExpr(); ((AdditiveExprContext)_localctx).rhs.add(((AdditiveExprContext)_localctx).multiplicativeExpr); } } } - setState(642); + setState(648); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,64,_ctx); } @@ -3936,15 +3938,15 @@ public final MultiplicativeExprContext multiplicativeExpr() throws RecognitionEx try { enterOuterAlt(_localctx, 1); { - setState(643); + setState(649); ((MultiplicativeExprContext)_localctx).main_expr = instanceOfExpr(); - setState(648); + setState(654); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__32) | (1L << T__47) | (1L << T__48) | (1L << T__49))) != 0)) { { { - setState(644); + setState(650); ((MultiplicativeExprContext)_localctx)._tset1308 = _input.LT(1); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__32) | (1L << T__47) | (1L << T__48) | (1L << T__49))) != 0)) ) { @@ -3956,12 +3958,12 @@ public final MultiplicativeExprContext multiplicativeExpr() throws RecognitionEx consume(); } ((MultiplicativeExprContext)_localctx).op.add(((MultiplicativeExprContext)_localctx)._tset1308); - setState(645); + setState(651); ((MultiplicativeExprContext)_localctx).instanceOfExpr = instanceOfExpr(); ((MultiplicativeExprContext)_localctx).rhs.add(((MultiplicativeExprContext)_localctx).instanceOfExpr); } } - setState(650); + setState(656); _errHandler.sync(this); _la = _input.LA(1); } @@ -4006,18 +4008,18 @@ public final InstanceOfExprContext instanceOfExpr() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(651); + setState(657); ((InstanceOfExprContext)_localctx).main_expr = isStaticallyExpr(); - setState(655); + setState(661); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,66,_ctx) ) { case 1: { - setState(652); + setState(658); match(Kinstance); - setState(653); + setState(659); match(Kof); - setState(654); + setState(660); ((InstanceOfExprContext)_localctx).seq = sequenceType(); } break; @@ -4063,18 +4065,18 @@ public final IsStaticallyExprContext isStaticallyExpr() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(657); + setState(663); ((IsStaticallyExprContext)_localctx).main_expr = treatExpr(); - setState(661); + setState(667); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,67,_ctx) ) { case 1: { - setState(658); + setState(664); match(Kis); - setState(659); + setState(665); match(Kstatically); - setState(660); + setState(666); ((IsStaticallyExprContext)_localctx).seq = sequenceType(); } break; @@ -4120,18 +4122,18 @@ public final TreatExprContext treatExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(663); + setState(669); ((TreatExprContext)_localctx).main_expr = castableExpr(); - setState(667); + setState(673); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,68,_ctx) ) { case 1: { - setState(664); + setState(670); match(Ktreat); - setState(665); + setState(671); match(Kas); - setState(666); + setState(672); ((TreatExprContext)_localctx).seq = sequenceType(); } break; @@ -4177,18 +4179,18 @@ public final CastableExprContext castableExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(669); + setState(675); ((CastableExprContext)_localctx).main_expr = castExpr(); - setState(673); + setState(679); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,69,_ctx) ) { case 1: { - setState(670); + setState(676); match(Kcastable); - setState(671); + setState(677); match(Kas); - setState(672); + setState(678); ((CastableExprContext)_localctx).single = singleType(); } break; @@ -4234,18 +4236,18 @@ public final CastExprContext castExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(675); + setState(681); ((CastExprContext)_localctx).main_expr = arrowExpr(); - setState(679); + setState(685); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,70,_ctx) ) { case 1: { - setState(676); + setState(682); match(Kcast); - setState(677); + setState(683); match(Kas); - setState(678); + setState(684); ((CastExprContext)_localctx).single = singleType(); } break; @@ -4294,9 +4296,9 @@ public final ArrowExprContext arrowExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(681); + setState(687); ((ArrowExprContext)_localctx).main_expr = unaryExpr(); - setState(688); + setState(694); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,71,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { @@ -4304,18 +4306,18 @@ public final ArrowExprContext arrowExpr() throws RecognitionException { { { { - setState(682); + setState(688); match(T__3); - setState(683); + setState(689); match(T__42); } - setState(685); + setState(691); ((ArrowExprContext)_localctx).functionCall = functionCall(); ((ArrowExprContext)_localctx).function_call_expr.add(((ArrowExprContext)_localctx).functionCall); } } } - setState(690); + setState(696); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,71,_ctx); } @@ -4359,13 +4361,13 @@ public final UnaryExprContext unaryExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(694); + setState(700); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__45 || _la==T__46) { { { - setState(691); + setState(697); ((UnaryExprContext)_localctx)._tset1468 = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__45 || _la==T__46) ) { @@ -4379,11 +4381,11 @@ public final UnaryExprContext unaryExpr() throws RecognitionException { ((UnaryExprContext)_localctx).op.add(((UnaryExprContext)_localctx)._tset1468); } } - setState(696); + setState(702); _errHandler.sync(this); _la = _input.LA(1); } - setState(697); + setState(703); ((UnaryExprContext)_localctx).main_expr = simpleMapExpr(); } } @@ -4426,22 +4428,22 @@ public final SimpleMapExprContext simpleMapExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(699); + setState(705); ((SimpleMapExprContext)_localctx).main_expr = postFixExpr(); - setState(704); + setState(710); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__50) { { { - setState(700); + setState(706); match(T__50); - setState(701); + setState(707); ((SimpleMapExprContext)_localctx).postFixExpr = postFixExpr(); ((SimpleMapExprContext)_localctx).map_expr.add(((SimpleMapExprContext)_localctx).postFixExpr); } } - setState(706); + setState(712); _errHandler.sync(this); _la = _input.LA(1); } @@ -4511,51 +4513,51 @@ public final PostFixExprContext postFixExpr() throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(707); + setState(713); ((PostFixExprContext)_localctx).main_expr = primaryExpr(); - setState(715); + setState(721); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,75,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { - setState(713); + setState(719); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,74,_ctx) ) { case 1: { - setState(708); + setState(714); arrayLookup(); } break; case 2: { - setState(709); + setState(715); predicate(); } break; case 3: { - setState(710); + setState(716); objectLookup(); } break; case 4: { - setState(711); + setState(717); arrayUnboxing(); } break; case 5: { - setState(712); + setState(718); argumentList(); } break; } } } - setState(717); + setState(723); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,75,_ctx); } @@ -4593,15 +4595,15 @@ public final ArrayLookupContext arrayLookup() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(718); + setState(724); match(T__51); - setState(719); + setState(725); match(T__51); - setState(720); + setState(726); expr(); - setState(721); + setState(727); match(T__52); - setState(722); + setState(728); match(T__52); } } @@ -4634,9 +4636,9 @@ public final ArrayUnboxingContext arrayUnboxing() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(724); + setState(730); match(T__51); - setState(725); + setState(731); match(T__52); } } @@ -4672,11 +4674,11 @@ public final PredicateContext predicate() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(727); + setState(733); match(T__51); - setState(728); + setState(734); expr(); - setState(729); + setState(735); match(T__52); } } @@ -4731,9 +4733,9 @@ public final ObjectLookupContext objectLookup() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(731); + setState(737); match(T__53); - setState(738); + setState(744); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: @@ -4782,37 +4784,37 @@ public final ObjectLookupContext objectLookup() throws RecognitionException { case Kjsoniq: case NullLiteral: { - setState(732); + setState(738); ((ObjectLookupContext)_localctx).kw = keyWords(); } break; case STRING: { - setState(733); + setState(739); ((ObjectLookupContext)_localctx).lt = stringLiteral(); } break; case NCName: { - setState(734); + setState(740); ((ObjectLookupContext)_localctx).nc = match(NCName); } break; case T__26: { - setState(735); + setState(741); ((ObjectLookupContext)_localctx).pe = parenthesizedExpr(); } break; case T__30: { - setState(736); + setState(742); ((ObjectLookupContext)_localctx).vr = varRef(); } break; case T__54: { - setState(737); + setState(743); ((ObjectLookupContext)_localctx).ci = contextItemExpr(); } break; @@ -4880,90 +4882,90 @@ public final PrimaryExprContext primaryExpr() throws RecognitionException { PrimaryExprContext _localctx = new PrimaryExprContext(_ctx, getState()); enterRule(_localctx, 126, RULE_primaryExpr); try { - setState(752); + setState(758); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,77,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(740); + setState(746); match(NullLiteral); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(741); + setState(747); match(Literal); } break; case 3: enterOuterAlt(_localctx, 3); { - setState(742); + setState(748); stringLiteral(); } break; case 4: enterOuterAlt(_localctx, 4); { - setState(743); + setState(749); varRef(); } break; case 5: enterOuterAlt(_localctx, 5); { - setState(744); + setState(750); parenthesizedExpr(); } break; case 6: enterOuterAlt(_localctx, 6); { - setState(745); + setState(751); contextItemExpr(); } break; case 7: enterOuterAlt(_localctx, 7); { - setState(746); + setState(752); objectConstructor(); } break; case 8: enterOuterAlt(_localctx, 8); { - setState(747); + setState(753); functionCall(); } break; case 9: enterOuterAlt(_localctx, 9); { - setState(748); + setState(754); orderedExpr(); } break; case 10: enterOuterAlt(_localctx, 10); { - setState(749); + setState(755); unorderedExpr(); } break; case 11: enterOuterAlt(_localctx, 11); { - setState(750); + setState(756); arrayConstructor(); } break; case 12: enterOuterAlt(_localctx, 12); { - setState(751); + setState(757); functionItemExpr(); } break; @@ -5002,9 +5004,9 @@ public final VarRefContext varRef() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(754); + setState(760); match(T__30); - setState(755); + setState(761); ((VarRefContext)_localctx).var_name = qname(); } } @@ -5041,19 +5043,19 @@ public final ParenthesizedExprContext parenthesizedExpr() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(757); + setState(763); match(T__26); - setState(759); + setState(765); _errHandler.sync(this); _la = _input.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { { - setState(758); + setState(764); expr(); } } - setState(761); + setState(767); match(T__27); } } @@ -5086,7 +5088,7 @@ public final ContextItemExprContext contextItemExpr() throws RecognitionExceptio try { enterOuterAlt(_localctx, 1); { - setState(763); + setState(769); match(T__54); } } @@ -5122,13 +5124,13 @@ public final OrderedExprContext orderedExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(765); + setState(771); match(T__6); - setState(766); + setState(772); match(T__28); - setState(767); + setState(773); expr(); - setState(768); + setState(774); match(T__29); } } @@ -5164,13 +5166,13 @@ public final UnorderedExprContext unorderedExpr() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(770); + setState(776); match(T__7); - setState(771); + setState(777); match(T__28); - setState(772); + setState(778); expr(); - setState(773); + setState(779); match(T__29); } } @@ -5210,9 +5212,9 @@ public final FunctionCallContext functionCall() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(775); + setState(781); ((FunctionCallContext)_localctx).fn_name = qname(); - setState(776); + setState(782); argumentList(); } } @@ -5254,34 +5256,34 @@ public final ArgumentListContext argumentList() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(778); + setState(784); match(T__26); - setState(785); + setState(791); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (ArgumentPlaceholder - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { { { - setState(779); + setState(785); ((ArgumentListContext)_localctx).argument = argument(); ((ArgumentListContext)_localctx).args.add(((ArgumentListContext)_localctx).argument); - setState(781); + setState(787); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__21) { { - setState(780); + setState(786); match(T__21); } } } } - setState(787); + setState(793); _errHandler.sync(this); _la = _input.LA(1); } - setState(788); + setState(794); match(T__27); } } @@ -5316,7 +5318,7 @@ public final ArgumentContext argument() throws RecognitionException { ArgumentContext _localctx = new ArgumentContext(_ctx, getState()); enterRule(_localctx, 142, RULE_argument); try { - setState(792); + setState(798); _errHandler.sync(this); switch (_input.LA(1)) { case T__6: @@ -5380,14 +5382,14 @@ public final ArgumentContext argument() throws RecognitionException { case NCName: enterOuterAlt(_localctx, 1); { - setState(790); + setState(796); exprSingle(); } break; case ArgumentPlaceholder: enterOuterAlt(_localctx, 2); { - setState(791); + setState(797); match(ArgumentPlaceholder); } break; @@ -5428,7 +5430,7 @@ public final FunctionItemExprContext functionItemExpr() throws RecognitionExcept FunctionItemExprContext _localctx = new FunctionItemExprContext(_ctx, getState()); enterRule(_localctx, 144, RULE_functionItemExpr); try { - setState(796); + setState(802); _errHandler.sync(this); switch (_input.LA(1)) { case Kfor: @@ -5479,14 +5481,14 @@ public final FunctionItemExprContext functionItemExpr() throws RecognitionExcept case NCName: enterOuterAlt(_localctx, 1); { - setState(794); + setState(800); namedFunctionRef(); } break; case T__25: enterOuterAlt(_localctx, 2); { - setState(795); + setState(801); inlineFunctionExpr(); } break; @@ -5529,11 +5531,11 @@ public final NamedFunctionRefContext namedFunctionRef() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(798); + setState(804); ((NamedFunctionRefContext)_localctx).fn_name = qname(); - setState(799); + setState(805); match(T__55); - setState(800); + setState(806); ((NamedFunctionRefContext)_localctx).arity = match(Literal); } } @@ -5579,48 +5581,48 @@ public final InlineFunctionExprContext inlineFunctionExpr() throws RecognitionEx try { enterOuterAlt(_localctx, 1); { - setState(802); + setState(808); match(T__25); - setState(803); + setState(809); match(T__26); - setState(805); + setState(811); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__30) { { - setState(804); + setState(810); paramList(); } } - setState(807); + setState(813); match(T__27); - setState(810); + setState(816); _errHandler.sync(this); _la = _input.LA(1); if (_la==Kas) { { - setState(808); + setState(814); match(Kas); - setState(809); + setState(815); ((InlineFunctionExprContext)_localctx).return_type = sequenceType(); } } { - setState(812); + setState(818); match(T__28); - setState(814); + setState(820); _errHandler.sync(this); _la = _input.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { { - setState(813); + setState(819); ((InlineFunctionExprContext)_localctx).fn_body = expr(); } } - setState(816); + setState(822); match(T__29); } } @@ -5662,18 +5664,19 @@ public final SequenceTypeContext sequenceType() throws RecognitionException { SequenceTypeContext _localctx = new SequenceTypeContext(_ctx, getState()); enterRule(_localctx, 150, RULE_sequenceType); try { - setState(826); + setState(832); _errHandler.sync(this); switch (_input.LA(1)) { case T__26: enterOuterAlt(_localctx, 1); { - setState(818); + setState(824); match(T__26); - setState(819); + setState(825); match(T__27); } break; + case T__25: case Kfor: case Klet: case Kwhere: @@ -5722,28 +5725,28 @@ public final SequenceTypeContext sequenceType() throws RecognitionException { case NCName: enterOuterAlt(_localctx, 2); { - setState(820); + setState(826); ((SequenceTypeContext)_localctx).item = itemType(); - setState(824); + setState(830); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,86,_ctx) ) { case 1: { - setState(821); + setState(827); ((SequenceTypeContext)_localctx).s104 = match(ArgumentPlaceholder); ((SequenceTypeContext)_localctx).question.add(((SequenceTypeContext)_localctx).s104); } break; case 2: { - setState(822); + setState(828); ((SequenceTypeContext)_localctx).s33 = match(T__32); ((SequenceTypeContext)_localctx).star.add(((SequenceTypeContext)_localctx).s33); } break; case 3: { - setState(823); + setState(829); ((SequenceTypeContext)_localctx).s46 = match(T__45); ((SequenceTypeContext)_localctx).plus.add(((SequenceTypeContext)_localctx).s46); } @@ -5794,53 +5797,53 @@ public final ObjectConstructorContext objectConstructor() throws RecognitionExce enterRule(_localctx, 152, RULE_objectConstructor); int _la; try { - setState(844); + setState(850); _errHandler.sync(this); switch (_input.LA(1)) { case T__28: enterOuterAlt(_localctx, 1); { - setState(828); + setState(834); match(T__28); - setState(837); + setState(843); _errHandler.sync(this); _la = _input.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { { - setState(829); + setState(835); pairConstructor(); - setState(834); + setState(840); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__21) { { { - setState(830); + setState(836); match(T__21); - setState(831); + setState(837); pairConstructor(); } } - setState(836); + setState(842); _errHandler.sync(this); _la = _input.LA(1); } } } - setState(839); + setState(845); match(T__29); } break; case T__56: enterOuterAlt(_localctx, 2); { - setState(840); + setState(846); ((ObjectConstructorContext)_localctx).s57 = match(T__56); ((ObjectConstructorContext)_localctx).merge_operator.add(((ObjectConstructorContext)_localctx).s57); - setState(841); + setState(847); expr(); - setState(842); + setState(848); match(T__57); } break; @@ -5864,6 +5867,9 @@ public QnameContext qname() { return getRuleContext(QnameContext.class,0); } public TerminalNode NullLiteral() { return getToken(JsoniqParser.NullLiteral, 0); } + public FunctionTestContext functionTest() { + return getRuleContext(FunctionTestContext.class,0); + } public ItemTypeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -5879,23 +5885,201 @@ public final ItemTypeContext itemType() throws RecognitionException { ItemTypeContext _localctx = new ItemTypeContext(_ctx, getState()); enterRule(_localctx, 154, RULE_itemType); try { - setState(848); + setState(855); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,91,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { - setState(846); + setState(852); qname(); } break; case 2: enterOuterAlt(_localctx, 2); { - setState(847); + setState(853); match(NullLiteral); } break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(854); + functionTest(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class FunctionTestContext extends ParserRuleContext { + public AnyFunctionTestContext anyFunctionTest() { + return getRuleContext(AnyFunctionTestContext.class,0); + } + public TypedFunctionTestContext typedFunctionTest() { + return getRuleContext(TypedFunctionTestContext.class,0); + } + public FunctionTestContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_functionTest; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor)visitor).visitFunctionTest(this); + else return visitor.visitChildren(this); + } + } + + public final FunctionTestContext functionTest() throws RecognitionException { + FunctionTestContext _localctx = new FunctionTestContext(_ctx, getState()); + enterRule(_localctx, 156, RULE_functionTest); + try { + enterOuterAlt(_localctx, 1); + { + setState(859); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,92,_ctx) ) { + case 1: + { + setState(857); + anyFunctionTest(); + } + break; + case 2: + { + setState(858); + typedFunctionTest(); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class AnyFunctionTestContext extends ParserRuleContext { + public AnyFunctionTestContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_anyFunctionTest; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor)visitor).visitAnyFunctionTest(this); + else return visitor.visitChildren(this); + } + } + + public final AnyFunctionTestContext anyFunctionTest() throws RecognitionException { + AnyFunctionTestContext _localctx = new AnyFunctionTestContext(_ctx, getState()); + enterRule(_localctx, 158, RULE_anyFunctionTest); + try { + enterOuterAlt(_localctx, 1); + { + setState(861); + match(T__25); + setState(862); + match(T__26); + setState(863); + match(T__32); + setState(864); + match(T__27); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class TypedFunctionTestContext extends ParserRuleContext { + public SequenceTypeContext sequenceType; + public List st = new ArrayList(); + public SequenceTypeContext rt; + public List sequenceType() { + return getRuleContexts(SequenceTypeContext.class); + } + public SequenceTypeContext sequenceType(int i) { + return getRuleContext(SequenceTypeContext.class,i); + } + public TypedFunctionTestContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_typedFunctionTest; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor)visitor).visitTypedFunctionTest(this); + else return visitor.visitChildren(this); + } + } + + public final TypedFunctionTestContext typedFunctionTest() throws RecognitionException { + TypedFunctionTestContext _localctx = new TypedFunctionTestContext(_ctx, getState()); + enterRule(_localctx, 160, RULE_typedFunctionTest); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(866); + match(T__25); + setState(867); + match(T__26); + setState(876); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__25) | (1L << T__26) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (NullLiteral - 64)) | (1L << (NCName - 64)))) != 0)) { + { + setState(868); + ((TypedFunctionTestContext)_localctx).sequenceType = sequenceType(); + ((TypedFunctionTestContext)_localctx).st.add(((TypedFunctionTestContext)_localctx).sequenceType); + setState(873); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__21) { + { + { + setState(869); + match(T__21); + setState(870); + ((TypedFunctionTestContext)_localctx).sequenceType = sequenceType(); + ((TypedFunctionTestContext)_localctx).st.add(((TypedFunctionTestContext)_localctx).sequenceType); + } + } + setState(875); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(878); + match(T__27); + setState(879); + match(Kas); + setState(880); + ((TypedFunctionTestContext)_localctx).rt = sequenceType(); } } catch (RecognitionException re) { @@ -5929,18 +6113,18 @@ public T accept(ParseTreeVisitor visitor) { public final SingleTypeContext singleType() throws RecognitionException { SingleTypeContext _localctx = new SingleTypeContext(_ctx, getState()); - enterRule(_localctx, 156, RULE_singleType); + enterRule(_localctx, 162, RULE_singleType); try { enterOuterAlt(_localctx, 1); { - setState(850); + setState(882); ((SingleTypeContext)_localctx).item = itemType(); - setState(852); + setState(884); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,92,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,95,_ctx) ) { case 1: { - setState(851); + setState(883); ((SingleTypeContext)_localctx).s104 = match(ArgumentPlaceholder); ((SingleTypeContext)_localctx).question.add(((SingleTypeContext)_localctx).s104); } @@ -5983,28 +6167,28 @@ public T accept(ParseTreeVisitor visitor) { public final PairConstructorContext pairConstructor() throws RecognitionException { PairConstructorContext _localctx = new PairConstructorContext(_ctx, getState()); - enterRule(_localctx, 158, RULE_pairConstructor); + enterRule(_localctx, 164, RULE_pairConstructor); int _la; try { enterOuterAlt(_localctx, 1); { - setState(856); + setState(888); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,93,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,96,_ctx) ) { case 1: { - setState(854); + setState(886); ((PairConstructorContext)_localctx).lhs = exprSingle(); } break; case 2: { - setState(855); + setState(887); ((PairConstructorContext)_localctx).name = match(NCName); } break; } - setState(858); + setState(890); _la = _input.LA(1); if ( !(_la==T__9 || _la==ArgumentPlaceholder) ) { _errHandler.recoverInline(this); @@ -6014,7 +6198,7 @@ public final PairConstructorContext pairConstructor() throws RecognitionExceptio _errHandler.reportMatch(this); consume(); } - setState(859); + setState(891); ((PairConstructorContext)_localctx).rhs = exprSingle(); } } @@ -6046,24 +6230,24 @@ public T accept(ParseTreeVisitor visitor) { public final ArrayConstructorContext arrayConstructor() throws RecognitionException { ArrayConstructorContext _localctx = new ArrayConstructorContext(_ctx, getState()); - enterRule(_localctx, 160, RULE_arrayConstructor); + enterRule(_localctx, 166, RULE_arrayConstructor); int _la; try { enterOuterAlt(_localctx, 1); { - setState(861); + setState(893); match(T__51); - setState(863); + setState(895); _errHandler.sync(this); _la = _input.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << T__30) | (1L << T__45) | (1L << T__46) | (1L << T__51) | (1L << T__54) | (1L << T__56) | (1L << Kfor) | (1L << Klet) | (1L << Kwhere) | (1L << Kgroup) | (1L << Kby))) != 0) || ((((_la - 64)) & ~0x3f) == 0 && ((1L << (_la - 64)) & ((1L << (Korder - 64)) | (1L << (Kreturn - 64)) | (1L << (Kif - 64)) | (1L << (Kin - 64)) | (1L << (Kas - 64)) | (1L << (Kat - 64)) | (1L << (Kallowing - 64)) | (1L << (Kempty - 64)) | (1L << (Kcount - 64)) | (1L << (Kstable - 64)) | (1L << (Kascending - 64)) | (1L << (Kdescending - 64)) | (1L << (Ksome - 64)) | (1L << (Kevery - 64)) | (1L << (Ksatisfies - 64)) | (1L << (Kcollation - 64)) | (1L << (Kgreatest - 64)) | (1L << (Kleast - 64)) | (1L << (Kswitch - 64)) | (1L << (Kcase - 64)) | (1L << (Ktry - 64)) | (1L << (Kcatch - 64)) | (1L << (Kdefault - 64)) | (1L << (Kthen - 64)) | (1L << (Kelse - 64)) | (1L << (Ktypeswitch - 64)) | (1L << (Kor - 64)) | (1L << (Kand - 64)) | (1L << (Knot - 64)) | (1L << (Kto - 64)) | (1L << (Kinstance - 64)) | (1L << (Kof - 64)) | (1L << (Kstatically - 64)) | (1L << (Kis - 64)) | (1L << (Ktreat - 64)) | (1L << (Kcast - 64)) | (1L << (Kcastable - 64)) | (1L << (Kversion - 64)) | (1L << (Kjsoniq - 64)) | (1L << (STRING - 64)) | (1L << (NullLiteral - 64)) | (1L << (Literal - 64)) | (1L << (NCName - 64)))) != 0)) { { - setState(862); + setState(894); expr(); } } - setState(865); + setState(897); match(T__52); } } @@ -6095,11 +6279,11 @@ public T accept(ParseTreeVisitor visitor) { public final UriLiteralContext uriLiteral() throws RecognitionException { UriLiteralContext _localctx = new UriLiteralContext(_ctx, getState()); - enterRule(_localctx, 162, RULE_uriLiteral); + enterRule(_localctx, 168, RULE_uriLiteral); try { enterOuterAlt(_localctx, 1); { - setState(867); + setState(899); stringLiteral(); } } @@ -6129,11 +6313,11 @@ public T accept(ParseTreeVisitor visitor) { public final StringLiteralContext stringLiteral() throws RecognitionException { StringLiteralContext _localctx = new StringLiteralContext(_ctx, getState()); - enterRule(_localctx, 164, RULE_stringLiteral); + enterRule(_localctx, 170, RULE_stringLiteral); try { enterOuterAlt(_localctx, 1); { - setState(869); + setState(901); match(STRING); } } @@ -6207,12 +6391,12 @@ public T accept(ParseTreeVisitor visitor) { public final KeyWordsContext keyWords() throws RecognitionException { KeyWordsContext _localctx = new KeyWordsContext(_ctx, getState()); - enterRule(_localctx, 166, RULE_keyWords); + enterRule(_localctx, 172, RULE_keyWords); int _la; try { enterOuterAlt(_localctx, 1); { - setState(871); + setState(903); _la = _input.LA(1); if ( !(((((_la - 59)) & ~0x3f) == 0 && ((1L << (_la - 59)) & ((1L << (Kfor - 59)) | (1L << (Klet - 59)) | (1L << (Kwhere - 59)) | (1L << (Kgroup - 59)) | (1L << (Kby - 59)) | (1L << (Korder - 59)) | (1L << (Kreturn - 59)) | (1L << (Kif - 59)) | (1L << (Kin - 59)) | (1L << (Kas - 59)) | (1L << (Kat - 59)) | (1L << (Kallowing - 59)) | (1L << (Kempty - 59)) | (1L << (Kcount - 59)) | (1L << (Kstable - 59)) | (1L << (Kascending - 59)) | (1L << (Kdescending - 59)) | (1L << (Ksome - 59)) | (1L << (Kevery - 59)) | (1L << (Ksatisfies - 59)) | (1L << (Kcollation - 59)) | (1L << (Kgreatest - 59)) | (1L << (Kleast - 59)) | (1L << (Kswitch - 59)) | (1L << (Kcase - 59)) | (1L << (Ktry - 59)) | (1L << (Kcatch - 59)) | (1L << (Kdefault - 59)) | (1L << (Kthen - 59)) | (1L << (Kelse - 59)) | (1L << (Ktypeswitch - 59)) | (1L << (Kor - 59)) | (1L << (Kand - 59)) | (1L << (Knot - 59)) | (1L << (Kto - 59)) | (1L << (Kinstance - 59)) | (1L << (Kof - 59)) | (1L << (Kstatically - 59)) | (1L << (Kis - 59)) | (1L << (Ktreat - 59)) | (1L << (Kcast - 59)) | (1L << (Kcastable - 59)) | (1L << (Kversion - 59)) | (1L << (Kjsoniq - 59)) | (1L << (NullLiteral - 59)))) != 0)) ) { _errHandler.recoverInline(this); @@ -6236,7 +6420,7 @@ public final KeyWordsContext keyWords() throws RecognitionException { } public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3u\u036c\4\2\t\2\4"+ + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3u\u038c\4\2\t\2\4"+ "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ @@ -6246,322 +6430,334 @@ public final KeyWordsContext keyWords() throws RecognitionException { "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+ "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I"+ "\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT"+ - "\4U\tU\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\5\3\u00b3\n\3\3\3\3\3\5\3\u00b7"+ - "\n\3\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\5\6\u00c7"+ - "\n\6\3\6\3\6\7\6\u00cb\n\6\f\6\16\6\u00ce\13\6\3\6\3\6\3\6\7\6\u00d3\n"+ - "\6\f\6\16\6\u00d6\13\6\3\7\3\7\3\7\3\7\5\7\u00dc\n\7\3\b\3\b\3\b\3\b\3"+ - "\b\3\b\3\t\3\t\5\t\u00e6\n\t\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3"+ - "\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\5\r\u00fc\n\r\3\r\3\r\3\r\3"+ - "\r\7\r\u0102\n\r\f\r\16\r\u0105\13\r\3\16\3\16\5\16\u0109\n\16\3\16\5"+ - "\16\u010c\n\16\3\16\3\16\5\16\u0110\n\16\3\17\3\17\3\20\3\20\3\21\3\21"+ - "\3\21\3\21\3\21\5\21\u011b\n\21\3\21\3\21\3\21\3\21\3\21\7\21\u0122\n"+ - "\21\f\21\16\21\u0125\13\21\5\21\u0127\n\21\3\22\3\22\3\22\3\22\3\22\5"+ - "\22\u012e\n\22\3\22\3\22\3\22\3\22\3\22\5\22\u0135\n\22\5\22\u0137\n\22"+ - "\3\23\3\23\3\23\3\23\3\23\5\23\u013e\n\23\3\23\3\23\3\23\5\23\u0143\n"+ - "\23\3\23\3\23\5\23\u0147\n\23\3\23\3\23\5\23\u014b\n\23\3\24\3\24\3\24"+ - "\7\24\u0150\n\24\f\24\16\24\u0153\13\24\3\25\3\25\3\25\3\25\5\25\u0159"+ - "\n\25\3\26\3\26\3\26\7\26\u015e\n\26\f\26\16\26\u0161\13\26\3\27\3\27"+ - "\3\27\3\27\3\27\3\27\3\27\5\27\u016a\n\27\3\30\3\30\5\30\u016e\n\30\3"+ - "\30\3\30\3\30\3\30\3\30\3\30\7\30\u0176\n\30\f\30\16\30\u0179\13\30\3"+ - "\30\3\30\3\30\3\31\3\31\3\31\3\31\7\31\u0182\n\31\f\31\16\31\u0185\13"+ - "\31\3\32\3\32\3\32\5\32\u018a\n\32\3\32\3\32\5\32\u018e\n\32\3\32\3\32"+ - "\5\32\u0192\n\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\7\33\u019b\n\33\f"+ - "\33\16\33\u019e\13\33\3\34\3\34\3\34\5\34\u01a3\n\34\3\34\3\34\3\34\3"+ - "\35\3\35\3\35\3\36\3\36\3\36\3\36\3\36\7\36\u01b0\n\36\f\36\16\36\u01b3"+ - "\13\36\3\37\3\37\3\37\5\37\u01b8\n\37\3\37\3\37\5\37\u01bc\n\37\3\37\3"+ - "\37\5\37\u01c0\n\37\3 \3 \3 \3 \3 \5 \u01c7\n \3 \3 \3 \7 \u01cc\n \f"+ - " \16 \u01cf\13 \3!\3!\3!\5!\u01d4\n!\3!\3!\3!\5!\u01d9\n!\5!\u01db\n!"+ - "\3!\3!\5!\u01df\n!\3\"\3\"\3\"\3#\3#\5#\u01e6\n#\3#\3#\3#\7#\u01eb\n#"+ - "\f#\16#\u01ee\13#\3#\3#\3#\3$\3$\3$\5$\u01f6\n$\3$\3$\3$\3%\3%\3%\3%\3"+ - "%\6%\u0200\n%\r%\16%\u0201\3%\3%\3%\3%\3&\3&\6&\u020a\n&\r&\16&\u020b"+ - "\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\6\'\u0216\n\'\r\'\16\'\u0217\3\'\3\'\5\'"+ - "\u021c\n\'\3\'\3\'\3\'\3(\3(\3(\3(\5(\u0225\n(\3(\3(\3(\7(\u022a\n(\f"+ - "(\16(\u022d\13(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3)\3)\3)\3*\3*\3*\3*\3*\6*"+ - "\u0240\n*\r*\16*\u0241\3+\3+\3+\5+\u0247\n+\3+\3+\3+\5+\u024c\n+\7+\u024e"+ - "\n+\f+\16+\u0251\13+\3+\3+\3+\3+\3,\3,\3,\7,\u025a\n,\f,\16,\u025d\13"+ - ",\3-\3-\3-\7-\u0262\n-\f-\16-\u0265\13-\3.\5.\u0268\n.\3.\3.\3/\3/\3/"+ - "\5/\u026f\n/\3\60\3\60\3\60\7\60\u0274\n\60\f\60\16\60\u0277\13\60\3\61"+ - "\3\61\3\61\5\61\u027c\n\61\3\62\3\62\3\62\7\62\u0281\n\62\f\62\16\62\u0284"+ - "\13\62\3\63\3\63\3\63\7\63\u0289\n\63\f\63\16\63\u028c\13\63\3\64\3\64"+ - "\3\64\3\64\5\64\u0292\n\64\3\65\3\65\3\65\3\65\5\65\u0298\n\65\3\66\3"+ - "\66\3\66\3\66\5\66\u029e\n\66\3\67\3\67\3\67\3\67\5\67\u02a4\n\67\38\3"+ - "8\38\38\58\u02aa\n8\39\39\39\39\39\79\u02b1\n9\f9\169\u02b4\139\3:\7:"+ - "\u02b7\n:\f:\16:\u02ba\13:\3:\3:\3;\3;\3;\7;\u02c1\n;\f;\16;\u02c4\13"+ - ";\3<\3<\3<\3<\3<\3<\7<\u02cc\n<\f<\16<\u02cf\13<\3=\3=\3=\3=\3=\3=\3>"+ - "\3>\3>\3?\3?\3?\3?\3@\3@\3@\3@\3@\3@\3@\5@\u02e5\n@\3A\3A\3A\3A\3A\3A"+ - "\3A\3A\3A\3A\3A\3A\5A\u02f3\nA\3B\3B\3B\3C\3C\5C\u02fa\nC\3C\3C\3D\3D"+ - "\3E\3E\3E\3E\3E\3F\3F\3F\3F\3F\3G\3G\3G\3H\3H\3H\5H\u0310\nH\7H\u0312"+ - "\nH\fH\16H\u0315\13H\3H\3H\3I\3I\5I\u031b\nI\3J\3J\5J\u031f\nJ\3K\3K\3"+ - "K\3K\3L\3L\3L\5L\u0328\nL\3L\3L\3L\5L\u032d\nL\3L\3L\5L\u0331\nL\3L\3"+ - "L\3M\3M\3M\3M\3M\3M\5M\u033b\nM\5M\u033d\nM\3N\3N\3N\3N\7N\u0343\nN\f"+ - "N\16N\u0346\13N\5N\u0348\nN\3N\3N\3N\3N\3N\5N\u034f\nN\3O\3O\5O\u0353"+ - "\nO\3P\3P\5P\u0357\nP\3Q\3Q\5Q\u035b\nQ\3Q\3Q\3Q\3R\3R\5R\u0362\nR\3R"+ - "\3R\3S\3S\3T\3T\3U\3U\3U\2\2V\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 "+ - "\"$&(*,.\60\62\64\668:<>@BDFHJLNPRTVXZ\\^`bdfhjlnprtvxz|~\u0080\u0082"+ - "\u0084\u0086\u0088\u008a\u008c\u008e\u0090\u0092\u0094\u0096\u0098\u009a"+ - "\u009c\u009e\u00a0\u00a2\u00a4\u00a6\u00a8\2\13\3\2\t\n\3\2RS\4\2kkss"+ - "\3\2\r\26\4\2\6\6$.\3\2\60\61\4\2##\62\64\4\2\f\fjj\4\2=hkk\2\u0396\2"+ - "\u00aa\3\2\2\2\4\u00b2\3\2\2\2\6\u00b8\3\2\2\2\b\u00bb\3\2\2\2\n\u00cc"+ - "\3\2\2\2\f\u00db\3\2\2\2\16\u00dd\3\2\2\2\20\u00e5\3\2\2\2\22\u00e7\3"+ - "\2\2\2\24\u00ec\3\2\2\2\26\u00f0\3\2\2\2\30\u00f6\3\2\2\2\32\u010b\3\2"+ - "\2\2\34\u0111\3\2\2\2\36\u0113\3\2\2\2 \u0115\3\2\2\2\"\u0128\3\2\2\2"+ - "$\u0138\3\2\2\2&\u014c\3\2\2\2(\u0154\3\2\2\2*\u015a\3\2\2\2,\u0169\3"+ - "\2\2\2.\u016d\3\2\2\2\60\u017d\3\2\2\2\62\u0186\3\2\2\2\64\u0196\3\2\2"+ - "\2\66\u019f\3\2\2\28\u01a7\3\2\2\2:\u01aa\3\2\2\2<\u01b4\3\2\2\2>\u01c6"+ - "\3\2\2\2@\u01d0\3\2\2\2B\u01e0\3\2\2\2D\u01e5\3\2\2\2F\u01f2\3\2\2\2H"+ - "\u01fa\3\2\2\2J\u0209\3\2\2\2L\u0210\3\2\2\2N\u0220\3\2\2\2P\u0231\3\2"+ - "\2\2R\u023a\3\2\2\2T\u0243\3\2\2\2V\u0256\3\2\2\2X\u025e\3\2\2\2Z\u0267"+ - "\3\2\2\2\\\u026b\3\2\2\2^\u0270\3\2\2\2`\u0278\3\2\2\2b\u027d\3\2\2\2"+ - "d\u0285\3\2\2\2f\u028d\3\2\2\2h\u0293\3\2\2\2j\u0299\3\2\2\2l\u029f\3"+ - "\2\2\2n\u02a5\3\2\2\2p\u02ab\3\2\2\2r\u02b8\3\2\2\2t\u02bd\3\2\2\2v\u02c5"+ - "\3\2\2\2x\u02d0\3\2\2\2z\u02d6\3\2\2\2|\u02d9\3\2\2\2~\u02dd\3\2\2\2\u0080"+ - "\u02f2\3\2\2\2\u0082\u02f4\3\2\2\2\u0084\u02f7\3\2\2\2\u0086\u02fd\3\2"+ - "\2\2\u0088\u02ff\3\2\2\2\u008a\u0304\3\2\2\2\u008c\u0309\3\2\2\2\u008e"+ - "\u030c\3\2\2\2\u0090\u031a\3\2\2\2\u0092\u031e\3\2\2\2\u0094\u0320\3\2"+ - "\2\2\u0096\u0324\3\2\2\2\u0098\u033c\3\2\2\2\u009a\u034e\3\2\2\2\u009c"+ - "\u0352\3\2\2\2\u009e\u0354\3\2\2\2\u00a0\u035a\3\2\2\2\u00a2\u035f\3\2"+ - "\2\2\u00a4\u0365\3\2\2\2\u00a6\u0367\3\2\2\2\u00a8\u0369\3\2\2\2\u00aa"+ - "\u00ab\5\4\3\2\u00ab\u00ac\7\2\2\3\u00ac\3\3\2\2\2\u00ad\u00ae\7h\2\2"+ - "\u00ae\u00af\7g\2\2\u00af\u00b0\5\u00a6T\2\u00b0\u00b1\7\3\2\2\u00b1\u00b3"+ - "\3\2\2\2\u00b2\u00ad\3\2\2\2\u00b2\u00b3\3\2\2\2\u00b3\u00b6\3\2\2\2\u00b4"+ - "\u00b7\5\b\5\2\u00b5\u00b7\5\6\4\2\u00b6\u00b4\3\2\2\2\u00b6\u00b5\3\2"+ - "\2\2\u00b7\5\3\2\2\2\u00b8\u00b9\5\n\6\2\u00b9\u00ba\5*\26\2\u00ba\7\3"+ - "\2\2\2\u00bb\u00bc\7\4\2\2\u00bc\u00bd\7\5\2\2\u00bd\u00be\7s\2\2\u00be"+ - "\u00bf\7\6\2\2\u00bf\u00c0\5\u00a4S\2\u00c0\u00c1\7\3\2\2\u00c1\u00c2"+ - "\5\n\6\2\u00c2\t\3\2\2\2\u00c3\u00c7\5\f\7\2\u00c4\u00c7\5\16\b\2\u00c5"+ - "\u00c7\5 \21\2\u00c6\u00c3\3\2\2\2\u00c6\u00c4\3\2\2\2\u00c6\u00c5\3\2"+ - "\2\2\u00c7\u00c8\3\2\2\2\u00c8\u00c9\7\3\2\2\u00c9\u00cb\3\2\2\2\u00ca"+ - "\u00c6\3\2\2\2\u00cb\u00ce\3\2\2\2\u00cc\u00ca\3\2\2\2\u00cc\u00cd\3\2"+ - "\2\2\u00cd\u00d4\3\2\2\2\u00ce\u00cc\3\2\2\2\u00cf\u00d0\5\20\t\2\u00d0"+ - "\u00d1\7\3\2\2\u00d1\u00d3\3\2\2\2\u00d2\u00cf\3\2\2\2\u00d3\u00d6\3\2"+ - "\2\2\u00d4\u00d2\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5\13\3\2\2\2\u00d6\u00d4"+ - "\3\2\2\2\u00d7\u00dc\5\22\n\2\u00d8\u00dc\5\24\13\2\u00d9\u00dc\5\26\f"+ - "\2\u00da\u00dc\5\30\r\2\u00db\u00d7\3\2\2\2\u00db\u00d8\3\2\2\2\u00db"+ - "\u00d9\3\2\2\2\u00db\u00da\3\2\2\2\u00dc\r\3\2\2\2\u00dd\u00de\7\7\2\2"+ - "\u00de\u00df\7\5\2\2\u00df\u00e0\7s\2\2\u00e0\u00e1\7\6\2\2\u00e1\u00e2"+ - "\5\u00a4S\2\u00e2\17\3\2\2\2\u00e3\u00e6\5$\23\2\u00e4\u00e6\5\"\22\2"+ - "\u00e5\u00e3\3\2\2\2\u00e5\u00e4\3\2\2\2\u00e6\21\3\2\2\2\u00e7\u00e8"+ - "\7\7\2\2\u00e8\u00e9\7X\2\2\u00e9\u00ea\7Q\2\2\u00ea\u00eb\5\u00a4S\2"+ - "\u00eb\23\3\2\2\2\u00ec\u00ed\7\7\2\2\u00ed\u00ee\7\b\2\2\u00ee\u00ef"+ - "\t\2\2\2\u00ef\25\3\2\2\2\u00f0\u00f1\7\7\2\2\u00f1\u00f2\7X\2\2\u00f2"+ - "\u00f3\7B\2\2\u00f3\u00f4\7I\2\2\u00f4\u00f5\t\3\2\2\u00f5\27\3\2\2\2"+ - "\u00f6\u00fb\7\7\2\2\u00f7\u00f8\7\13\2\2\u00f8\u00fc\5\32\16\2\u00f9"+ - "\u00fa\7X\2\2\u00fa\u00fc\7\13\2\2\u00fb\u00f7\3\2\2\2\u00fb\u00f9\3\2"+ - "\2\2\u00fc\u0103\3\2\2\2\u00fd\u00fe\5\36\20\2\u00fe\u00ff\7\6\2\2\u00ff"+ - "\u0100\5\u00a6T\2\u0100\u0102\3\2\2\2\u0101\u00fd\3\2\2\2\u0102\u0105"+ - "\3\2\2\2\u0103\u0101\3\2\2\2\u0103\u0104\3\2\2\2\u0104\31\3\2\2\2\u0105"+ - "\u0103\3\2\2\2\u0106\u0109\7s\2\2\u0107\u0109\5\u00a8U\2\u0108\u0106\3"+ - "\2\2\2\u0108\u0107\3\2\2\2\u0109\u010a\3\2\2\2\u010a\u010c\7\f\2\2\u010b"+ - "\u0108\3\2\2\2\u010b\u010c\3\2\2\2\u010c\u010f\3\2\2\2\u010d\u0110\5\34"+ - "\17\2\u010e\u0110\5\u00a8U\2\u010f\u010d\3\2\2\2\u010f\u010e\3\2\2\2\u0110"+ - "\33\3\2\2\2\u0111\u0112\t\4\2\2\u0112\35\3\2\2\2\u0113\u0114\t\5\2\2\u0114"+ - "\37\3\2\2\2\u0115\u0116\7\27\2\2\u0116\u011a\7\4\2\2\u0117\u0118\7\5\2"+ - "\2\u0118\u0119\7s\2\2\u0119\u011b\7\6\2\2\u011a\u0117\3\2\2\2\u011a\u011b"+ - "\3\2\2\2\u011b\u011c\3\2\2\2\u011c\u0126\5\u00a4S\2\u011d\u011e\7G\2\2"+ - "\u011e\u0123\5\u00a4S\2\u011f\u0120\7\30\2\2\u0120\u0122\5\u00a4S\2\u0121"+ - "\u011f\3\2\2\2\u0122\u0125\3\2\2\2\u0123\u0121\3\2\2\2\u0123\u0124\3\2"+ - "\2\2\u0124\u0127\3\2\2\2\u0125\u0123\3\2\2\2\u0126\u011d\3\2\2\2\u0126"+ - "\u0127\3\2\2\2\u0127!\3\2\2\2\u0128\u0129\7\7\2\2\u0129\u012a\7\31\2\2"+ - "\u012a\u012d\5\u0082B\2\u012b\u012c\7F\2\2\u012c\u012e\5\u0098M\2\u012d"+ - "\u012b\3\2\2\2\u012d\u012e\3\2\2\2\u012e\u0136\3\2\2\2\u012f\u0130\7\32"+ - "\2\2\u0130\u0137\5,\27\2\u0131\u0134\7\33\2\2\u0132\u0133\7\32\2\2\u0133"+ - "\u0135\5,\27\2\u0134\u0132\3\2\2\2\u0134\u0135\3\2\2\2\u0135\u0137\3\2"+ - "\2\2\u0136\u012f\3\2\2\2\u0136\u0131\3\2\2\2\u0137#\3\2\2\2\u0138\u0139"+ - "\7\7\2\2\u0139\u013a\7\34\2\2\u013a\u013b\5\32\16\2\u013b\u013d\7\35\2"+ - "\2\u013c\u013e\5&\24\2\u013d\u013c\3\2\2\2\u013d\u013e\3\2\2\2\u013e\u013f"+ - "\3\2\2\2\u013f\u0142\7\36\2\2\u0140\u0141\7F\2\2\u0141\u0143\5\u0098M"+ - "\2\u0142\u0140\3\2\2\2\u0142\u0143\3\2\2\2\u0143\u014a\3\2\2\2\u0144\u0146"+ - "\7\37\2\2\u0145\u0147\5*\26\2\u0146\u0145\3\2\2\2\u0146\u0147\3\2\2\2"+ - "\u0147\u0148\3\2\2\2\u0148\u014b\7 \2\2\u0149\u014b\7\33\2\2\u014a\u0144"+ - "\3\2\2\2\u014a\u0149\3\2\2\2\u014b%\3\2\2\2\u014c\u0151\5(\25\2\u014d"+ - "\u014e\7\30\2\2\u014e\u0150\5(\25\2\u014f\u014d\3\2\2\2\u0150\u0153\3"+ - "\2\2\2\u0151\u014f\3\2\2\2\u0151\u0152\3\2\2\2\u0152\'\3\2\2\2\u0153\u0151"+ - "\3\2\2\2\u0154\u0155\7!\2\2\u0155\u0158\5\32\16\2\u0156\u0157\7F\2\2\u0157"+ - "\u0159\5\u0098M\2\u0158\u0156\3\2\2\2\u0158\u0159\3\2\2\2\u0159)\3\2\2"+ - "\2\u015a\u015f\5,\27\2\u015b\u015c\7\30\2\2\u015c\u015e\5,\27\2\u015d"+ - "\u015b\3\2\2\2\u015e\u0161\3\2\2\2\u015f\u015d\3\2\2\2\u015f\u0160\3\2"+ - "\2\2\u0160+\3\2\2\2\u0161\u015f\3\2\2\2\u0162\u016a\5.\30\2\u0163\u016a"+ - "\5D#\2\u0164\u016a\5H%\2\u0165\u016a\5L\'\2\u0166\u016a\5P)\2\u0167\u016a"+ - "\5R*\2\u0168\u016a\5V,\2\u0169\u0162\3\2\2\2\u0169\u0163\3\2\2\2\u0169"+ - "\u0164\3\2\2\2\u0169\u0165\3\2\2\2\u0169\u0166\3\2\2\2\u0169\u0167\3\2"+ - "\2\2\u0169\u0168\3\2\2\2\u016a-\3\2\2\2\u016b\u016e\5\60\31\2\u016c\u016e"+ - "\5\64\33\2\u016d\u016b\3\2\2\2\u016d\u016c\3\2\2\2\u016e\u0177\3\2\2\2"+ - "\u016f\u0176\5\60\31\2\u0170\u0176\58\35\2\u0171\u0176\5\64\33\2\u0172"+ - "\u0176\5:\36\2\u0173\u0176\5> \2\u0174\u0176\5B\"\2\u0175\u016f\3\2\2"+ - "\2\u0175\u0170\3\2\2\2\u0175\u0171\3\2\2\2\u0175\u0172\3\2\2\2\u0175\u0173"+ - "\3\2\2\2\u0175\u0174\3\2\2\2\u0176\u0179\3\2\2\2\u0177\u0175\3\2\2\2\u0177"+ - "\u0178\3\2\2\2\u0178\u017a\3\2\2\2\u0179\u0177\3\2\2\2\u017a\u017b\7C"+ - "\2\2\u017b\u017c\5,\27\2\u017c/\3\2\2\2\u017d\u017e\7=\2\2\u017e\u0183"+ - "\5\62\32\2\u017f\u0180\7\30\2\2\u0180\u0182\5\62\32\2\u0181\u017f\3\2"+ - "\2\2\u0182\u0185\3\2\2\2\u0183\u0181\3\2\2\2\u0183\u0184\3\2\2\2\u0184"+ - "\61\3\2\2\2\u0185\u0183\3\2\2\2\u0186\u0189\5\u0082B\2\u0187\u0188\7F"+ - "\2\2\u0188\u018a\5\u0098M\2\u0189\u0187\3\2\2\2\u0189\u018a\3\2\2\2\u018a"+ - "\u018d\3\2\2\2\u018b\u018c\7H\2\2\u018c\u018e\7I\2\2\u018d\u018b\3\2\2"+ - "\2\u018d\u018e\3\2\2\2\u018e\u0191\3\2\2\2\u018f\u0190\7G\2\2\u0190\u0192"+ - "\5\u0082B\2\u0191\u018f\3\2\2\2\u0191\u0192\3\2\2\2\u0192\u0193\3\2\2"+ - "\2\u0193\u0194\7E\2\2\u0194\u0195\5,\27\2\u0195\63\3\2\2\2\u0196\u0197"+ - "\7>\2\2\u0197\u019c\5\66\34\2\u0198\u0199\7\30\2\2\u0199\u019b\5\66\34"+ - "\2\u019a\u0198\3\2\2\2\u019b\u019e\3\2\2\2\u019c\u019a\3\2\2\2\u019c\u019d"+ - "\3\2\2\2\u019d\65\3\2\2\2\u019e\u019c\3\2\2\2\u019f\u01a2\5\u0082B\2\u01a0"+ - "\u01a1\7F\2\2\u01a1\u01a3\5\u0098M\2\u01a2\u01a0\3\2\2\2\u01a2\u01a3\3"+ - "\2\2\2\u01a3\u01a4\3\2\2\2\u01a4\u01a5\7\32\2\2\u01a5\u01a6\5,\27\2\u01a6"+ - "\67\3\2\2\2\u01a7\u01a8\7?\2\2\u01a8\u01a9\5,\27\2\u01a99\3\2\2\2\u01aa"+ - "\u01ab\7@\2\2\u01ab\u01ac\7A\2\2\u01ac\u01b1\5<\37\2\u01ad\u01ae\7\30"+ - "\2\2\u01ae\u01b0\5<\37\2\u01af\u01ad\3\2\2\2\u01b0\u01b3\3\2\2\2\u01b1"+ - "\u01af\3\2\2\2\u01b1\u01b2\3\2\2\2\u01b2;\3\2\2\2\u01b3\u01b1\3\2\2\2"+ - "\u01b4\u01bb\5\u0082B\2\u01b5\u01b6\7F\2\2\u01b6\u01b8\5\u0098M\2\u01b7"+ - "\u01b5\3\2\2\2\u01b7\u01b8\3\2\2\2\u01b8\u01b9\3\2\2\2\u01b9\u01ba\7\32"+ - "\2\2\u01ba\u01bc\5,\27\2\u01bb\u01b7\3\2\2\2\u01bb\u01bc\3\2\2\2\u01bc"+ - "\u01bf\3\2\2\2\u01bd\u01be\7Q\2\2\u01be\u01c0\5\u00a4S\2\u01bf\u01bd\3"+ - "\2\2\2\u01bf\u01c0\3\2\2\2\u01c0=\3\2\2\2\u01c1\u01c2\7B\2\2\u01c2\u01c7"+ - "\7A\2\2\u01c3\u01c4\7K\2\2\u01c4\u01c5\7B\2\2\u01c5\u01c7\7A\2\2\u01c6"+ - "\u01c1\3\2\2\2\u01c6\u01c3\3\2\2\2\u01c7\u01c8\3\2\2\2\u01c8\u01cd\5@"+ - "!\2\u01c9\u01ca\7\30\2\2\u01ca\u01cc\5@!\2\u01cb\u01c9\3\2\2\2\u01cc\u01cf"+ - "\3\2\2\2\u01cd\u01cb\3\2\2\2\u01cd\u01ce\3\2\2\2\u01ce?\3\2\2\2\u01cf"+ - "\u01cd\3\2\2\2\u01d0\u01d3\5,\27\2\u01d1\u01d4\7L\2\2\u01d2\u01d4\7M\2"+ - "\2\u01d3\u01d1\3\2\2\2\u01d3\u01d2\3\2\2\2\u01d3\u01d4\3\2\2\2\u01d4\u01da"+ - "\3\2\2\2\u01d5\u01d8\7I\2\2\u01d6\u01d9\7R\2\2\u01d7\u01d9\7S\2\2\u01d8"+ - "\u01d6\3\2\2\2\u01d8\u01d7\3\2\2\2\u01d9\u01db\3\2\2\2\u01da\u01d5\3\2"+ - "\2\2\u01da\u01db\3\2\2\2\u01db\u01de\3\2\2\2\u01dc\u01dd\7Q\2\2\u01dd"+ - "\u01df\5\u00a4S\2\u01de\u01dc\3\2\2\2\u01de\u01df\3\2\2\2\u01dfA\3\2\2"+ - "\2\u01e0\u01e1\7J\2\2\u01e1\u01e2\5\u0082B\2\u01e2C\3\2\2\2\u01e3\u01e6"+ - "\7N\2\2\u01e4\u01e6\7O\2\2\u01e5\u01e3\3\2\2\2\u01e5\u01e4\3\2\2\2\u01e6"+ - "\u01e7\3\2\2\2\u01e7\u01ec\5F$\2\u01e8\u01e9\7\30\2\2\u01e9\u01eb\5F$"+ - "\2\u01ea\u01e8\3\2\2\2\u01eb\u01ee\3\2\2\2\u01ec\u01ea\3\2\2\2\u01ec\u01ed"+ - "\3\2\2\2\u01ed\u01ef\3\2\2\2\u01ee\u01ec\3\2\2\2\u01ef\u01f0\7P\2\2\u01f0"+ - "\u01f1\5,\27\2\u01f1E\3\2\2\2\u01f2\u01f5\5\u0082B\2\u01f3\u01f4\7F\2"+ - "\2\u01f4\u01f6\5\u0098M\2\u01f5\u01f3\3\2\2\2\u01f5\u01f6\3\2\2\2\u01f6"+ - "\u01f7\3\2\2\2\u01f7\u01f8\7E\2\2\u01f8\u01f9\5,\27\2\u01f9G\3\2\2\2\u01fa"+ - "\u01fb\7T\2\2\u01fb\u01fc\7\35\2\2\u01fc\u01fd\5*\26\2\u01fd\u01ff\7\36"+ - "\2\2\u01fe\u0200\5J&\2\u01ff\u01fe\3\2\2\2\u0200\u0201\3\2\2\2\u0201\u01ff"+ - "\3\2\2\2\u0201\u0202\3\2\2\2\u0202\u0203\3\2\2\2\u0203\u0204\7X\2\2\u0204"+ - "\u0205\7C\2\2\u0205\u0206\5,\27\2\u0206I\3\2\2\2\u0207\u0208\7U\2\2\u0208"+ - "\u020a\5,\27\2\u0209\u0207\3\2\2\2\u020a\u020b\3\2\2\2\u020b\u0209\3\2"+ - "\2\2\u020b\u020c\3\2\2\2\u020c\u020d\3\2\2\2\u020d\u020e\7C\2\2\u020e"+ - "\u020f\5,\27\2\u020fK\3\2\2\2\u0210\u0211\7[\2\2\u0211\u0212\7\35\2\2"+ - "\u0212\u0213\5*\26\2\u0213\u0215\7\36\2\2\u0214\u0216\5N(\2\u0215\u0214"+ - "\3\2\2\2\u0216\u0217\3\2\2\2\u0217\u0215\3\2\2\2\u0217\u0218\3\2\2\2\u0218"+ - "\u0219\3\2\2\2\u0219\u021b\7X\2\2\u021a\u021c\5\u0082B\2\u021b\u021a\3"+ - "\2\2\2\u021b\u021c\3\2\2\2\u021c\u021d\3\2\2\2\u021d\u021e\7C\2\2\u021e"+ - "\u021f\5,\27\2\u021fM\3\2\2\2\u0220\u0224\7U\2\2\u0221\u0222\5\u0082B"+ - "\2\u0222\u0223\7F\2\2\u0223\u0225\3\2\2\2\u0224\u0221\3\2\2\2\u0224\u0225"+ - "\3\2\2\2\u0225\u0226\3\2\2\2\u0226\u022b\5\u0098M\2\u0227\u0228\7\"\2"+ - "\2\u0228\u022a\5\u0098M\2\u0229\u0227\3\2\2\2\u022a\u022d\3\2\2\2\u022b"+ - "\u0229\3\2\2\2\u022b\u022c\3\2\2\2\u022c\u022e\3\2\2\2\u022d\u022b\3\2"+ - "\2\2\u022e\u022f\7C\2\2\u022f\u0230\5,\27\2\u0230O\3\2\2\2\u0231\u0232"+ - "\7D\2\2\u0232\u0233\7\35\2\2\u0233\u0234\5*\26\2\u0234\u0235\7\36\2\2"+ - "\u0235\u0236\7Y\2\2\u0236\u0237\5,\27\2\u0237\u0238\7Z\2\2\u0238\u0239"+ - "\5,\27\2\u0239Q\3\2\2\2\u023a\u023b\7V\2\2\u023b\u023c\7\37\2\2\u023c"+ - "\u023d\5*\26\2\u023d\u023f\7 \2\2\u023e\u0240\5T+\2\u023f\u023e\3\2\2"+ - "\2\u0240\u0241\3\2\2\2\u0241\u023f\3\2\2\2\u0241\u0242\3\2\2\2\u0242S"+ - "\3\2\2\2\u0243\u0246\7W\2\2\u0244\u0247\7#\2\2\u0245\u0247\5\32\16\2\u0246"+ - "\u0244\3\2\2\2\u0246\u0245\3\2\2\2\u0247\u024f\3\2\2\2\u0248\u024b\7\""+ - "\2\2\u0249\u024c\7#\2\2\u024a\u024c\5\32\16\2\u024b\u0249\3\2\2\2\u024b"+ - "\u024a\3\2\2\2\u024c\u024e\3\2\2\2\u024d\u0248\3\2\2\2\u024e\u0251\3\2"+ - "\2\2\u024f\u024d\3\2\2\2\u024f\u0250\3\2\2\2\u0250\u0252\3\2\2\2\u0251"+ - "\u024f\3\2\2\2\u0252\u0253\7\37\2\2\u0253\u0254\5*\26\2\u0254\u0255\7"+ - " \2\2\u0255U\3\2\2\2\u0256\u025b\5X-\2\u0257\u0258\7\\\2\2\u0258\u025a"+ - "\5X-\2\u0259\u0257\3\2\2\2\u025a\u025d\3\2\2\2\u025b\u0259\3\2\2\2\u025b"+ - "\u025c\3\2\2\2\u025cW\3\2\2\2\u025d\u025b\3\2\2\2\u025e\u0263\5Z.\2\u025f"+ - "\u0260\7]\2\2\u0260\u0262\5Z.\2\u0261\u025f\3\2\2\2\u0262\u0265\3\2\2"+ - "\2\u0263\u0261\3\2\2\2\u0263\u0264\3\2\2\2\u0264Y\3\2\2\2\u0265\u0263"+ - "\3\2\2\2\u0266\u0268\7^\2\2\u0267\u0266\3\2\2\2\u0267\u0268\3\2\2\2\u0268"+ - "\u0269\3\2\2\2\u0269\u026a\5\\/\2\u026a[\3\2\2\2\u026b\u026e\5^\60\2\u026c"+ - "\u026d\t\6\2\2\u026d\u026f\5^\60\2\u026e\u026c\3\2\2\2\u026e\u026f\3\2"+ - "\2\2\u026f]\3\2\2\2\u0270\u0275\5`\61\2\u0271\u0272\7/\2\2\u0272\u0274"+ - "\5`\61\2\u0273\u0271\3\2\2\2\u0274\u0277\3\2\2\2\u0275\u0273\3\2\2\2\u0275"+ - "\u0276\3\2\2\2\u0276_\3\2\2\2\u0277\u0275\3\2\2\2\u0278\u027b\5b\62\2"+ - "\u0279\u027a\7_\2\2\u027a\u027c\5b\62\2\u027b\u0279\3\2\2\2\u027b\u027c"+ - "\3\2\2\2\u027ca\3\2\2\2\u027d\u0282\5d\63\2\u027e\u027f\t\7\2\2\u027f"+ - "\u0281\5d\63\2\u0280\u027e\3\2\2\2\u0281\u0284\3\2\2\2\u0282\u0280\3\2"+ - "\2\2\u0282\u0283\3\2\2\2\u0283c\3\2\2\2\u0284\u0282\3\2\2\2\u0285\u028a"+ - "\5f\64\2\u0286\u0287\t\b\2\2\u0287\u0289\5f\64\2\u0288\u0286\3\2\2\2\u0289"+ - "\u028c\3\2\2\2\u028a\u0288\3\2\2\2\u028a\u028b\3\2\2\2\u028be\3\2\2\2"+ - "\u028c\u028a\3\2\2\2\u028d\u0291\5h\65\2\u028e\u028f\7`\2\2\u028f\u0290"+ - "\7a\2\2\u0290\u0292\5\u0098M\2\u0291\u028e\3\2\2\2\u0291\u0292\3\2\2\2"+ - "\u0292g\3\2\2\2\u0293\u0297\5j\66\2\u0294\u0295\7c\2\2\u0295\u0296\7b"+ - "\2\2\u0296\u0298\5\u0098M\2\u0297\u0294\3\2\2\2\u0297\u0298\3\2\2\2\u0298"+ - "i\3\2\2\2\u0299\u029d\5l\67\2\u029a\u029b\7d\2\2\u029b\u029c\7F\2\2\u029c"+ - "\u029e\5\u0098M\2\u029d\u029a\3\2\2\2\u029d\u029e\3\2\2\2\u029ek\3\2\2"+ - "\2\u029f\u02a3\5n8\2\u02a0\u02a1\7f\2\2\u02a1\u02a2\7F\2\2\u02a2\u02a4"+ - "\5\u009eP\2\u02a3\u02a0\3\2\2\2\u02a3\u02a4\3\2\2\2\u02a4m\3\2\2\2\u02a5"+ - "\u02a9\5p9\2\u02a6\u02a7\7e\2\2\u02a7\u02a8\7F\2\2\u02a8\u02aa\5\u009e"+ - "P\2\u02a9\u02a6\3\2\2\2\u02a9\u02aa\3\2\2\2\u02aao\3\2\2\2\u02ab\u02b2"+ - "\5r:\2\u02ac\u02ad\7\6\2\2\u02ad\u02ae\7-\2\2\u02ae\u02af\3\2\2\2\u02af"+ - "\u02b1\5\u008cG\2\u02b0\u02ac\3\2\2\2\u02b1\u02b4\3\2\2\2\u02b2\u02b0"+ - "\3\2\2\2\u02b2\u02b3\3\2\2\2\u02b3q\3\2\2\2\u02b4\u02b2\3\2\2\2\u02b5"+ - "\u02b7\t\7\2\2\u02b6\u02b5\3\2\2\2\u02b7\u02ba\3\2\2\2\u02b8\u02b6\3\2"+ - "\2\2\u02b8\u02b9\3\2\2\2\u02b9\u02bb\3\2\2\2\u02ba\u02b8\3\2\2\2\u02bb"+ - "\u02bc\5t;\2\u02bcs\3\2\2\2\u02bd\u02c2\5v<\2\u02be\u02bf\7\65\2\2\u02bf"+ - "\u02c1\5v<\2\u02c0\u02be\3\2\2\2\u02c1\u02c4\3\2\2\2\u02c2\u02c0\3\2\2"+ - "\2\u02c2\u02c3\3\2\2\2\u02c3u\3\2\2\2\u02c4\u02c2\3\2\2\2\u02c5\u02cd"+ - "\5\u0080A\2\u02c6\u02cc\5x=\2\u02c7\u02cc\5|?\2\u02c8\u02cc\5~@\2\u02c9"+ - "\u02cc\5z>\2\u02ca\u02cc\5\u008eH\2\u02cb\u02c6\3\2\2\2\u02cb\u02c7\3"+ - "\2\2\2\u02cb\u02c8\3\2\2\2\u02cb\u02c9\3\2\2\2\u02cb\u02ca\3\2\2\2\u02cc"+ - "\u02cf\3\2\2\2\u02cd\u02cb\3\2\2\2\u02cd\u02ce\3\2\2\2\u02cew\3\2\2\2"+ - "\u02cf\u02cd\3\2\2\2\u02d0\u02d1\7\66\2\2\u02d1\u02d2\7\66\2\2\u02d2\u02d3"+ - "\5*\26\2\u02d3\u02d4\7\67\2\2\u02d4\u02d5\7\67\2\2\u02d5y\3\2\2\2\u02d6"+ - "\u02d7\7\66\2\2\u02d7\u02d8\7\67\2\2\u02d8{\3\2\2\2\u02d9\u02da\7\66\2"+ - "\2\u02da\u02db\5*\26\2\u02db\u02dc\7\67\2\2\u02dc}\3\2\2\2\u02dd\u02e4"+ - "\78\2\2\u02de\u02e5\5\u00a8U\2\u02df\u02e5\5\u00a6T\2\u02e0\u02e5\7s\2"+ - "\2\u02e1\u02e5\5\u0084C\2\u02e2\u02e5\5\u0082B\2\u02e3\u02e5\5\u0086D"+ - "\2\u02e4\u02de\3\2\2\2\u02e4\u02df\3\2\2\2\u02e4\u02e0\3\2\2\2\u02e4\u02e1"+ - "\3\2\2\2\u02e4\u02e2\3\2\2\2\u02e4\u02e3\3\2\2\2\u02e5\177\3\2\2\2\u02e6"+ - "\u02f3\7k\2\2\u02e7\u02f3\7l\2\2\u02e8\u02f3\5\u00a6T\2\u02e9\u02f3\5"+ - "\u0082B\2\u02ea\u02f3\5\u0084C\2\u02eb\u02f3\5\u0086D\2\u02ec\u02f3\5"+ - "\u009aN\2\u02ed\u02f3\5\u008cG\2\u02ee\u02f3\5\u0088E\2\u02ef\u02f3\5"+ - "\u008aF\2\u02f0\u02f3\5\u00a2R\2\u02f1\u02f3\5\u0092J\2\u02f2\u02e6\3"+ - "\2\2\2\u02f2\u02e7\3\2\2\2\u02f2\u02e8\3\2\2\2\u02f2\u02e9\3\2\2\2\u02f2"+ - "\u02ea\3\2\2\2\u02f2\u02eb\3\2\2\2\u02f2\u02ec\3\2\2\2\u02f2\u02ed\3\2"+ - "\2\2\u02f2\u02ee\3\2\2\2\u02f2\u02ef\3\2\2\2\u02f2\u02f0\3\2\2\2\u02f2"+ - "\u02f1\3\2\2\2\u02f3\u0081\3\2\2\2\u02f4\u02f5\7!\2\2\u02f5\u02f6\5\32"+ - "\16\2\u02f6\u0083\3\2\2\2\u02f7\u02f9\7\35\2\2\u02f8\u02fa\5*\26\2\u02f9"+ - "\u02f8\3\2\2\2\u02f9\u02fa\3\2\2\2\u02fa\u02fb\3\2\2\2\u02fb\u02fc\7\36"+ - "\2\2\u02fc\u0085\3\2\2\2\u02fd\u02fe\79\2\2\u02fe\u0087\3\2\2\2\u02ff"+ - "\u0300\7\t\2\2\u0300\u0301\7\37\2\2\u0301\u0302\5*\26\2\u0302\u0303\7"+ - " \2\2\u0303\u0089\3\2\2\2\u0304\u0305\7\n\2\2\u0305\u0306\7\37\2\2\u0306"+ - "\u0307\5*\26\2\u0307\u0308\7 \2\2\u0308\u008b\3\2\2\2\u0309\u030a\5\32"+ - "\16\2\u030a\u030b\5\u008eH\2\u030b\u008d\3\2\2\2\u030c\u0313\7\35\2\2"+ - "\u030d\u030f\5\u0090I\2\u030e\u0310\7\30\2\2\u030f\u030e\3\2\2\2\u030f"+ - "\u0310\3\2\2\2\u0310\u0312\3\2\2\2\u0311\u030d\3\2\2\2\u0312\u0315\3\2"+ - "\2\2\u0313\u0311\3\2\2\2\u0313\u0314\3\2\2\2\u0314\u0316\3\2\2\2\u0315"+ - "\u0313\3\2\2\2\u0316\u0317\7\36\2\2\u0317\u008f\3\2\2\2\u0318\u031b\5"+ - ",\27\2\u0319\u031b\7j\2\2\u031a\u0318\3\2\2\2\u031a\u0319\3\2\2\2\u031b"+ - "\u0091\3\2\2\2\u031c\u031f\5\u0094K\2\u031d\u031f\5\u0096L\2\u031e\u031c"+ - "\3\2\2\2\u031e\u031d\3\2\2\2\u031f\u0093\3\2\2\2\u0320\u0321\5\32\16\2"+ - "\u0321\u0322\7:\2\2\u0322\u0323\7l\2\2\u0323\u0095\3\2\2\2\u0324\u0325"+ - "\7\34\2\2\u0325\u0327\7\35\2\2\u0326\u0328\5&\24\2\u0327\u0326\3\2\2\2"+ - "\u0327\u0328\3\2\2\2\u0328\u0329\3\2\2\2\u0329\u032c\7\36\2\2\u032a\u032b"+ - "\7F\2\2\u032b\u032d\5\u0098M\2\u032c\u032a\3\2\2\2\u032c\u032d\3\2\2\2"+ - "\u032d\u032e\3\2\2\2\u032e\u0330\7\37\2\2\u032f\u0331\5*\26\2\u0330\u032f"+ - "\3\2\2\2\u0330\u0331\3\2\2\2\u0331\u0332\3\2\2\2\u0332\u0333\7 \2\2\u0333"+ - "\u0097\3\2\2\2\u0334\u0335\7\35\2\2\u0335\u033d\7\36\2\2\u0336\u033a\5"+ - "\u009cO\2\u0337\u033b\7j\2\2\u0338\u033b\7#\2\2\u0339\u033b\7\60\2\2\u033a"+ - "\u0337\3\2\2\2\u033a\u0338\3\2\2\2\u033a\u0339\3\2\2\2\u033a\u033b\3\2"+ - "\2\2\u033b\u033d\3\2\2\2\u033c\u0334\3\2\2\2\u033c\u0336\3\2\2\2\u033d"+ - "\u0099\3\2\2\2\u033e\u0347\7\37\2\2\u033f\u0344\5\u00a0Q\2\u0340\u0341"+ - "\7\30\2\2\u0341\u0343\5\u00a0Q\2\u0342\u0340\3\2\2\2\u0343\u0346\3\2\2"+ - "\2\u0344\u0342\3\2\2\2\u0344\u0345\3\2\2\2\u0345\u0348\3\2\2\2\u0346\u0344"+ - "\3\2\2\2\u0347\u033f\3\2\2\2\u0347\u0348\3\2\2\2\u0348\u0349\3\2\2\2\u0349"+ - "\u034f\7 \2\2\u034a\u034b\7;\2\2\u034b\u034c\5*\26\2\u034c\u034d\7<\2"+ - "\2\u034d\u034f\3\2\2\2\u034e\u033e\3\2\2\2\u034e\u034a\3\2\2\2\u034f\u009b"+ - "\3\2\2\2\u0350\u0353\5\32\16\2\u0351\u0353\7k\2\2\u0352\u0350\3\2\2\2"+ - "\u0352\u0351\3\2\2\2\u0353\u009d\3\2\2\2\u0354\u0356\5\u009cO\2\u0355"+ - "\u0357\7j\2\2\u0356\u0355\3\2\2\2\u0356\u0357\3\2\2\2\u0357\u009f\3\2"+ - "\2\2\u0358\u035b\5,\27\2\u0359\u035b\7s\2\2\u035a\u0358\3\2\2\2\u035a"+ - "\u0359\3\2\2\2\u035b\u035c\3\2\2\2\u035c\u035d\t\t\2\2\u035d\u035e\5,"+ - "\27\2\u035e\u00a1\3\2\2\2\u035f\u0361\7\66\2\2\u0360\u0362\5*\26\2\u0361"+ - "\u0360\3\2\2\2\u0361\u0362\3\2\2\2\u0362\u0363\3\2\2\2\u0363\u0364\7\67"+ - "\2\2\u0364\u00a3\3\2\2\2\u0365\u0366\5\u00a6T\2\u0366\u00a5\3\2\2\2\u0367"+ - "\u0368\7i\2\2\u0368\u00a7\3\2\2\2\u0369\u036a\t\n\2\2\u036a\u00a9\3\2"+ - "\2\2a\u00b2\u00b6\u00c6\u00cc\u00d4\u00db\u00e5\u00fb\u0103\u0108\u010b"+ - "\u010f\u011a\u0123\u0126\u012d\u0134\u0136\u013d\u0142\u0146\u014a\u0151"+ - "\u0158\u015f\u0169\u016d\u0175\u0177\u0183\u0189\u018d\u0191\u019c\u01a2"+ - "\u01b1\u01b7\u01bb\u01bf\u01c6\u01cd\u01d3\u01d8\u01da\u01de\u01e5\u01ec"+ - "\u01f5\u0201\u020b\u0217\u021b\u0224\u022b\u0241\u0246\u024b\u024f\u025b"+ - "\u0263\u0267\u026e\u0275\u027b\u0282\u028a\u0291\u0297\u029d\u02a3\u02a9"+ - "\u02b2\u02b8\u02c2\u02cb\u02cd\u02e4\u02f2\u02f9\u030f\u0313\u031a\u031e"+ - "\u0327\u032c\u0330\u033a\u033c\u0344\u0347\u034e\u0352\u0356\u035a\u0361"; + "\4U\tU\4V\tV\4W\tW\4X\tX\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\5\3\u00b9\n\3"+ + "\3\3\3\3\5\3\u00bd\n\3\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6"+ + "\3\6\3\6\5\6\u00cd\n\6\3\6\3\6\7\6\u00d1\n\6\f\6\16\6\u00d4\13\6\3\6\3"+ + "\6\3\6\7\6\u00d9\n\6\f\6\16\6\u00dc\13\6\3\7\3\7\3\7\3\7\5\7\u00e2\n\7"+ + "\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3\t\5\t\u00ec\n\t\3\n\3\n\3\n\3\n\3\n\3\13"+ + "\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\5\r\u0102"+ + "\n\r\3\r\3\r\3\r\3\r\7\r\u0108\n\r\f\r\16\r\u010b\13\r\3\16\3\16\5\16"+ + "\u010f\n\16\3\16\5\16\u0112\n\16\3\16\3\16\5\16\u0116\n\16\3\17\3\17\3"+ + "\20\3\20\3\21\3\21\3\21\3\21\3\21\5\21\u0121\n\21\3\21\3\21\3\21\3\21"+ + "\3\21\7\21\u0128\n\21\f\21\16\21\u012b\13\21\5\21\u012d\n\21\3\22\3\22"+ + "\3\22\3\22\3\22\5\22\u0134\n\22\3\22\3\22\3\22\3\22\3\22\5\22\u013b\n"+ + "\22\5\22\u013d\n\22\3\23\3\23\3\23\3\23\3\23\5\23\u0144\n\23\3\23\3\23"+ + "\3\23\5\23\u0149\n\23\3\23\3\23\5\23\u014d\n\23\3\23\3\23\5\23\u0151\n"+ + "\23\3\24\3\24\3\24\7\24\u0156\n\24\f\24\16\24\u0159\13\24\3\25\3\25\3"+ + "\25\3\25\5\25\u015f\n\25\3\26\3\26\3\26\7\26\u0164\n\26\f\26\16\26\u0167"+ + "\13\26\3\27\3\27\3\27\3\27\3\27\3\27\3\27\5\27\u0170\n\27\3\30\3\30\5"+ + "\30\u0174\n\30\3\30\3\30\3\30\3\30\3\30\3\30\7\30\u017c\n\30\f\30\16\30"+ + "\u017f\13\30\3\30\3\30\3\30\3\31\3\31\3\31\3\31\7\31\u0188\n\31\f\31\16"+ + "\31\u018b\13\31\3\32\3\32\3\32\5\32\u0190\n\32\3\32\3\32\5\32\u0194\n"+ + "\32\3\32\3\32\5\32\u0198\n\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\7\33"+ + "\u01a1\n\33\f\33\16\33\u01a4\13\33\3\34\3\34\3\34\5\34\u01a9\n\34\3\34"+ + "\3\34\3\34\3\35\3\35\3\35\3\36\3\36\3\36\3\36\3\36\7\36\u01b6\n\36\f\36"+ + "\16\36\u01b9\13\36\3\37\3\37\3\37\5\37\u01be\n\37\3\37\3\37\5\37\u01c2"+ + "\n\37\3\37\3\37\5\37\u01c6\n\37\3 \3 \3 \3 \3 \5 \u01cd\n \3 \3 \3 \7"+ + " \u01d2\n \f \16 \u01d5\13 \3!\3!\3!\5!\u01da\n!\3!\3!\3!\5!\u01df\n!"+ + "\5!\u01e1\n!\3!\3!\5!\u01e5\n!\3\"\3\"\3\"\3#\3#\5#\u01ec\n#\3#\3#\3#"+ + "\7#\u01f1\n#\f#\16#\u01f4\13#\3#\3#\3#\3$\3$\3$\5$\u01fc\n$\3$\3$\3$\3"+ + "%\3%\3%\3%\3%\6%\u0206\n%\r%\16%\u0207\3%\3%\3%\3%\3&\3&\6&\u0210\n&\r"+ + "&\16&\u0211\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\6\'\u021c\n\'\r\'\16\'\u021d"+ + "\3\'\3\'\5\'\u0222\n\'\3\'\3\'\3\'\3(\3(\3(\3(\5(\u022b\n(\3(\3(\3(\7"+ + "(\u0230\n(\f(\16(\u0233\13(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3)\3)\3)\3*\3*"+ + "\3*\3*\3*\6*\u0246\n*\r*\16*\u0247\3+\3+\3+\5+\u024d\n+\3+\3+\3+\5+\u0252"+ + "\n+\7+\u0254\n+\f+\16+\u0257\13+\3+\3+\3+\3+\3,\3,\3,\7,\u0260\n,\f,\16"+ + ",\u0263\13,\3-\3-\3-\7-\u0268\n-\f-\16-\u026b\13-\3.\5.\u026e\n.\3.\3"+ + ".\3/\3/\3/\5/\u0275\n/\3\60\3\60\3\60\7\60\u027a\n\60\f\60\16\60\u027d"+ + "\13\60\3\61\3\61\3\61\5\61\u0282\n\61\3\62\3\62\3\62\7\62\u0287\n\62\f"+ + "\62\16\62\u028a\13\62\3\63\3\63\3\63\7\63\u028f\n\63\f\63\16\63\u0292"+ + "\13\63\3\64\3\64\3\64\3\64\5\64\u0298\n\64\3\65\3\65\3\65\3\65\5\65\u029e"+ + "\n\65\3\66\3\66\3\66\3\66\5\66\u02a4\n\66\3\67\3\67\3\67\3\67\5\67\u02aa"+ + "\n\67\38\38\38\38\58\u02b0\n8\39\39\39\39\39\79\u02b7\n9\f9\169\u02ba"+ + "\139\3:\7:\u02bd\n:\f:\16:\u02c0\13:\3:\3:\3;\3;\3;\7;\u02c7\n;\f;\16"+ + ";\u02ca\13;\3<\3<\3<\3<\3<\3<\7<\u02d2\n<\f<\16<\u02d5\13<\3=\3=\3=\3"+ + "=\3=\3=\3>\3>\3>\3?\3?\3?\3?\3@\3@\3@\3@\3@\3@\3@\5@\u02eb\n@\3A\3A\3"+ + "A\3A\3A\3A\3A\3A\3A\3A\3A\3A\5A\u02f9\nA\3B\3B\3B\3C\3C\5C\u0300\nC\3"+ + "C\3C\3D\3D\3E\3E\3E\3E\3E\3F\3F\3F\3F\3F\3G\3G\3G\3H\3H\3H\5H\u0316\n"+ + "H\7H\u0318\nH\fH\16H\u031b\13H\3H\3H\3I\3I\5I\u0321\nI\3J\3J\5J\u0325"+ + "\nJ\3K\3K\3K\3K\3L\3L\3L\5L\u032e\nL\3L\3L\3L\5L\u0333\nL\3L\3L\5L\u0337"+ + "\nL\3L\3L\3M\3M\3M\3M\3M\3M\5M\u0341\nM\5M\u0343\nM\3N\3N\3N\3N\7N\u0349"+ + "\nN\fN\16N\u034c\13N\5N\u034e\nN\3N\3N\3N\3N\3N\5N\u0355\nN\3O\3O\3O\5"+ + "O\u035a\nO\3P\3P\5P\u035e\nP\3Q\3Q\3Q\3Q\3Q\3R\3R\3R\3R\3R\7R\u036a\n"+ + "R\fR\16R\u036d\13R\5R\u036f\nR\3R\3R\3R\3R\3S\3S\5S\u0377\nS\3T\3T\5T"+ + "\u037b\nT\3T\3T\3T\3U\3U\5U\u0382\nU\3U\3U\3V\3V\3W\3W\3X\3X\3X\2\2Y\2"+ + "\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&(*,.\60\62\64\668:<>@BDFHJL"+ + "NPRTVXZ\\^`bdfhjlnprtvxz|~\u0080\u0082\u0084\u0086\u0088\u008a\u008c\u008e"+ + "\u0090\u0092\u0094\u0096\u0098\u009a\u009c\u009e\u00a0\u00a2\u00a4\u00a6"+ + "\u00a8\u00aa\u00ac\u00ae\2\13\3\2\t\n\3\2RS\4\2kkss\3\2\r\26\4\2\6\6$"+ + ".\3\2\60\61\4\2##\62\64\4\2\f\fjj\4\2=hkk\2\u03b7\2\u00b0\3\2\2\2\4\u00b8"+ + "\3\2\2\2\6\u00be\3\2\2\2\b\u00c1\3\2\2\2\n\u00d2\3\2\2\2\f\u00e1\3\2\2"+ + "\2\16\u00e3\3\2\2\2\20\u00eb\3\2\2\2\22\u00ed\3\2\2\2\24\u00f2\3\2\2\2"+ + "\26\u00f6\3\2\2\2\30\u00fc\3\2\2\2\32\u0111\3\2\2\2\34\u0117\3\2\2\2\36"+ + "\u0119\3\2\2\2 \u011b\3\2\2\2\"\u012e\3\2\2\2$\u013e\3\2\2\2&\u0152\3"+ + "\2\2\2(\u015a\3\2\2\2*\u0160\3\2\2\2,\u016f\3\2\2\2.\u0173\3\2\2\2\60"+ + "\u0183\3\2\2\2\62\u018c\3\2\2\2\64\u019c\3\2\2\2\66\u01a5\3\2\2\28\u01ad"+ + "\3\2\2\2:\u01b0\3\2\2\2<\u01ba\3\2\2\2>\u01cc\3\2\2\2@\u01d6\3\2\2\2B"+ + "\u01e6\3\2\2\2D\u01eb\3\2\2\2F\u01f8\3\2\2\2H\u0200\3\2\2\2J\u020f\3\2"+ + "\2\2L\u0216\3\2\2\2N\u0226\3\2\2\2P\u0237\3\2\2\2R\u0240\3\2\2\2T\u0249"+ + "\3\2\2\2V\u025c\3\2\2\2X\u0264\3\2\2\2Z\u026d\3\2\2\2\\\u0271\3\2\2\2"+ + "^\u0276\3\2\2\2`\u027e\3\2\2\2b\u0283\3\2\2\2d\u028b\3\2\2\2f\u0293\3"+ + "\2\2\2h\u0299\3\2\2\2j\u029f\3\2\2\2l\u02a5\3\2\2\2n\u02ab\3\2\2\2p\u02b1"+ + "\3\2\2\2r\u02be\3\2\2\2t\u02c3\3\2\2\2v\u02cb\3\2\2\2x\u02d6\3\2\2\2z"+ + "\u02dc\3\2\2\2|\u02df\3\2\2\2~\u02e3\3\2\2\2\u0080\u02f8\3\2\2\2\u0082"+ + "\u02fa\3\2\2\2\u0084\u02fd\3\2\2\2\u0086\u0303\3\2\2\2\u0088\u0305\3\2"+ + "\2\2\u008a\u030a\3\2\2\2\u008c\u030f\3\2\2\2\u008e\u0312\3\2\2\2\u0090"+ + "\u0320\3\2\2\2\u0092\u0324\3\2\2\2\u0094\u0326\3\2\2\2\u0096\u032a\3\2"+ + "\2\2\u0098\u0342\3\2\2\2\u009a\u0354\3\2\2\2\u009c\u0359\3\2\2\2\u009e"+ + "\u035d\3\2\2\2\u00a0\u035f\3\2\2\2\u00a2\u0364\3\2\2\2\u00a4\u0374\3\2"+ + "\2\2\u00a6\u037a\3\2\2\2\u00a8\u037f\3\2\2\2\u00aa\u0385\3\2\2\2\u00ac"+ + "\u0387\3\2\2\2\u00ae\u0389\3\2\2\2\u00b0\u00b1\5\4\3\2\u00b1\u00b2\7\2"+ + "\2\3\u00b2\3\3\2\2\2\u00b3\u00b4\7h\2\2\u00b4\u00b5\7g\2\2\u00b5\u00b6"+ + "\5\u00acW\2\u00b6\u00b7\7\3\2\2\u00b7\u00b9\3\2\2\2\u00b8\u00b3\3\2\2"+ + "\2\u00b8\u00b9\3\2\2\2\u00b9\u00bc\3\2\2\2\u00ba\u00bd\5\b\5\2\u00bb\u00bd"+ + "\5\6\4\2\u00bc\u00ba\3\2\2\2\u00bc\u00bb\3\2\2\2\u00bd\5\3\2\2\2\u00be"+ + "\u00bf\5\n\6\2\u00bf\u00c0\5*\26\2\u00c0\7\3\2\2\2\u00c1\u00c2\7\4\2\2"+ + "\u00c2\u00c3\7\5\2\2\u00c3\u00c4\7s\2\2\u00c4\u00c5\7\6\2\2\u00c5\u00c6"+ + "\5\u00aaV\2\u00c6\u00c7\7\3\2\2\u00c7\u00c8\5\n\6\2\u00c8\t\3\2\2\2\u00c9"+ + "\u00cd\5\f\7\2\u00ca\u00cd\5\16\b\2\u00cb\u00cd\5 \21\2\u00cc\u00c9\3"+ + "\2\2\2\u00cc\u00ca\3\2\2\2\u00cc\u00cb\3\2\2\2\u00cd\u00ce\3\2\2\2\u00ce"+ + "\u00cf\7\3\2\2\u00cf\u00d1\3\2\2\2\u00d0\u00cc\3\2\2\2\u00d1\u00d4\3\2"+ + "\2\2\u00d2\u00d0\3\2\2\2\u00d2\u00d3\3\2\2\2\u00d3\u00da\3\2\2\2\u00d4"+ + "\u00d2\3\2\2\2\u00d5\u00d6\5\20\t\2\u00d6\u00d7\7\3\2\2\u00d7\u00d9\3"+ + "\2\2\2\u00d8\u00d5\3\2\2\2\u00d9\u00dc\3\2\2\2\u00da\u00d8\3\2\2\2\u00da"+ + "\u00db\3\2\2\2\u00db\13\3\2\2\2\u00dc\u00da\3\2\2\2\u00dd\u00e2\5\22\n"+ + "\2\u00de\u00e2\5\24\13\2\u00df\u00e2\5\26\f\2\u00e0\u00e2\5\30\r\2\u00e1"+ + "\u00dd\3\2\2\2\u00e1\u00de\3\2\2\2\u00e1\u00df\3\2\2\2\u00e1\u00e0\3\2"+ + "\2\2\u00e2\r\3\2\2\2\u00e3\u00e4\7\7\2\2\u00e4\u00e5\7\5\2\2\u00e5\u00e6"+ + "\7s\2\2\u00e6\u00e7\7\6\2\2\u00e7\u00e8\5\u00aaV\2\u00e8\17\3\2\2\2\u00e9"+ + "\u00ec\5$\23\2\u00ea\u00ec\5\"\22\2\u00eb\u00e9\3\2\2\2\u00eb\u00ea\3"+ + "\2\2\2\u00ec\21\3\2\2\2\u00ed\u00ee\7\7\2\2\u00ee\u00ef\7X\2\2\u00ef\u00f0"+ + "\7Q\2\2\u00f0\u00f1\5\u00aaV\2\u00f1\23\3\2\2\2\u00f2\u00f3\7\7\2\2\u00f3"+ + "\u00f4\7\b\2\2\u00f4\u00f5\t\2\2\2\u00f5\25\3\2\2\2\u00f6\u00f7\7\7\2"+ + "\2\u00f7\u00f8\7X\2\2\u00f8\u00f9\7B\2\2\u00f9\u00fa\7I\2\2\u00fa\u00fb"+ + "\t\3\2\2\u00fb\27\3\2\2\2\u00fc\u0101\7\7\2\2\u00fd\u00fe\7\13\2\2\u00fe"+ + "\u0102\5\32\16\2\u00ff\u0100\7X\2\2\u0100\u0102\7\13\2\2\u0101\u00fd\3"+ + "\2\2\2\u0101\u00ff\3\2\2\2\u0102\u0109\3\2\2\2\u0103\u0104\5\36\20\2\u0104"+ + "\u0105\7\6\2\2\u0105\u0106\5\u00acW\2\u0106\u0108\3\2\2\2\u0107\u0103"+ + "\3\2\2\2\u0108\u010b\3\2\2\2\u0109\u0107\3\2\2\2\u0109\u010a\3\2\2\2\u010a"+ + "\31\3\2\2\2\u010b\u0109\3\2\2\2\u010c\u010f\7s\2\2\u010d\u010f\5\u00ae"+ + "X\2\u010e\u010c\3\2\2\2\u010e\u010d\3\2\2\2\u010f\u0110\3\2\2\2\u0110"+ + "\u0112\7\f\2\2\u0111\u010e\3\2\2\2\u0111\u0112\3\2\2\2\u0112\u0115\3\2"+ + "\2\2\u0113\u0116\5\34\17\2\u0114\u0116\5\u00aeX\2\u0115\u0113\3\2\2\2"+ + "\u0115\u0114\3\2\2\2\u0116\33\3\2\2\2\u0117\u0118\t\4\2\2\u0118\35\3\2"+ + "\2\2\u0119\u011a\t\5\2\2\u011a\37\3\2\2\2\u011b\u011c\7\27\2\2\u011c\u0120"+ + "\7\4\2\2\u011d\u011e\7\5\2\2\u011e\u011f\7s\2\2\u011f\u0121\7\6\2\2\u0120"+ + "\u011d\3\2\2\2\u0120\u0121\3\2\2\2\u0121\u0122\3\2\2\2\u0122\u012c\5\u00aa"+ + "V\2\u0123\u0124\7G\2\2\u0124\u0129\5\u00aaV\2\u0125\u0126\7\30\2\2\u0126"+ + "\u0128\5\u00aaV\2\u0127\u0125\3\2\2\2\u0128\u012b\3\2\2\2\u0129\u0127"+ + "\3\2\2\2\u0129\u012a\3\2\2\2\u012a\u012d\3\2\2\2\u012b\u0129\3\2\2\2\u012c"+ + "\u0123\3\2\2\2\u012c\u012d\3\2\2\2\u012d!\3\2\2\2\u012e\u012f\7\7\2\2"+ + "\u012f\u0130\7\31\2\2\u0130\u0133\5\u0082B\2\u0131\u0132\7F\2\2\u0132"+ + "\u0134\5\u0098M\2\u0133\u0131\3\2\2\2\u0133\u0134\3\2\2\2\u0134\u013c"+ + "\3\2\2\2\u0135\u0136\7\32\2\2\u0136\u013d\5,\27\2\u0137\u013a\7\33\2\2"+ + "\u0138\u0139\7\32\2\2\u0139\u013b\5,\27\2\u013a\u0138\3\2\2\2\u013a\u013b"+ + "\3\2\2\2\u013b\u013d\3\2\2\2\u013c\u0135\3\2\2\2\u013c\u0137\3\2\2\2\u013d"+ + "#\3\2\2\2\u013e\u013f\7\7\2\2\u013f\u0140\7\34\2\2\u0140\u0141\5\32\16"+ + "\2\u0141\u0143\7\35\2\2\u0142\u0144\5&\24\2\u0143\u0142\3\2\2\2\u0143"+ + "\u0144\3\2\2\2\u0144\u0145\3\2\2\2\u0145\u0148\7\36\2\2\u0146\u0147\7"+ + "F\2\2\u0147\u0149\5\u0098M\2\u0148\u0146\3\2\2\2\u0148\u0149\3\2\2\2\u0149"+ + "\u0150\3\2\2\2\u014a\u014c\7\37\2\2\u014b\u014d\5*\26\2\u014c\u014b\3"+ + "\2\2\2\u014c\u014d\3\2\2\2\u014d\u014e\3\2\2\2\u014e\u0151\7 \2\2\u014f"+ + "\u0151\7\33\2\2\u0150\u014a\3\2\2\2\u0150\u014f\3\2\2\2\u0151%\3\2\2\2"+ + "\u0152\u0157\5(\25\2\u0153\u0154\7\30\2\2\u0154\u0156\5(\25\2\u0155\u0153"+ + "\3\2\2\2\u0156\u0159\3\2\2\2\u0157\u0155\3\2\2\2\u0157\u0158\3\2\2\2\u0158"+ + "\'\3\2\2\2\u0159\u0157\3\2\2\2\u015a\u015b\7!\2\2\u015b\u015e\5\32\16"+ + "\2\u015c\u015d\7F\2\2\u015d\u015f\5\u0098M\2\u015e\u015c\3\2\2\2\u015e"+ + "\u015f\3\2\2\2\u015f)\3\2\2\2\u0160\u0165\5,\27\2\u0161\u0162\7\30\2\2"+ + "\u0162\u0164\5,\27\2\u0163\u0161\3\2\2\2\u0164\u0167\3\2\2\2\u0165\u0163"+ + "\3\2\2\2\u0165\u0166\3\2\2\2\u0166+\3\2\2\2\u0167\u0165\3\2\2\2\u0168"+ + "\u0170\5.\30\2\u0169\u0170\5D#\2\u016a\u0170\5H%\2\u016b\u0170\5L\'\2"+ + "\u016c\u0170\5P)\2\u016d\u0170\5R*\2\u016e\u0170\5V,\2\u016f\u0168\3\2"+ + "\2\2\u016f\u0169\3\2\2\2\u016f\u016a\3\2\2\2\u016f\u016b\3\2\2\2\u016f"+ + "\u016c\3\2\2\2\u016f\u016d\3\2\2\2\u016f\u016e\3\2\2\2\u0170-\3\2\2\2"+ + "\u0171\u0174\5\60\31\2\u0172\u0174\5\64\33\2\u0173\u0171\3\2\2\2\u0173"+ + "\u0172\3\2\2\2\u0174\u017d\3\2\2\2\u0175\u017c\5\60\31\2\u0176\u017c\5"+ + "8\35\2\u0177\u017c\5\64\33\2\u0178\u017c\5:\36\2\u0179\u017c\5> \2\u017a"+ + "\u017c\5B\"\2\u017b\u0175\3\2\2\2\u017b\u0176\3\2\2\2\u017b\u0177\3\2"+ + "\2\2\u017b\u0178\3\2\2\2\u017b\u0179\3\2\2\2\u017b\u017a\3\2\2\2\u017c"+ + "\u017f\3\2\2\2\u017d\u017b\3\2\2\2\u017d\u017e\3\2\2\2\u017e\u0180\3\2"+ + "\2\2\u017f\u017d\3\2\2\2\u0180\u0181\7C\2\2\u0181\u0182\5,\27\2\u0182"+ + "/\3\2\2\2\u0183\u0184\7=\2\2\u0184\u0189\5\62\32\2\u0185\u0186\7\30\2"+ + "\2\u0186\u0188\5\62\32\2\u0187\u0185\3\2\2\2\u0188\u018b\3\2\2\2\u0189"+ + "\u0187\3\2\2\2\u0189\u018a\3\2\2\2\u018a\61\3\2\2\2\u018b\u0189\3\2\2"+ + "\2\u018c\u018f\5\u0082B\2\u018d\u018e\7F\2\2\u018e\u0190\5\u0098M\2\u018f"+ + "\u018d\3\2\2\2\u018f\u0190\3\2\2\2\u0190\u0193\3\2\2\2\u0191\u0192\7H"+ + "\2\2\u0192\u0194\7I\2\2\u0193\u0191\3\2\2\2\u0193\u0194\3\2\2\2\u0194"+ + "\u0197\3\2\2\2\u0195\u0196\7G\2\2\u0196\u0198\5\u0082B\2\u0197\u0195\3"+ + "\2\2\2\u0197\u0198\3\2\2\2\u0198\u0199\3\2\2\2\u0199\u019a\7E\2\2\u019a"+ + "\u019b\5,\27\2\u019b\63\3\2\2\2\u019c\u019d\7>\2\2\u019d\u01a2\5\66\34"+ + "\2\u019e\u019f\7\30\2\2\u019f\u01a1\5\66\34\2\u01a0\u019e\3\2\2\2\u01a1"+ + "\u01a4\3\2\2\2\u01a2\u01a0\3\2\2\2\u01a2\u01a3\3\2\2\2\u01a3\65\3\2\2"+ + "\2\u01a4\u01a2\3\2\2\2\u01a5\u01a8\5\u0082B\2\u01a6\u01a7\7F\2\2\u01a7"+ + "\u01a9\5\u0098M\2\u01a8\u01a6\3\2\2\2\u01a8\u01a9\3\2\2\2\u01a9\u01aa"+ + "\3\2\2\2\u01aa\u01ab\7\32\2\2\u01ab\u01ac\5,\27\2\u01ac\67\3\2\2\2\u01ad"+ + "\u01ae\7?\2\2\u01ae\u01af\5,\27\2\u01af9\3\2\2\2\u01b0\u01b1\7@\2\2\u01b1"+ + "\u01b2\7A\2\2\u01b2\u01b7\5<\37\2\u01b3\u01b4\7\30\2\2\u01b4\u01b6\5<"+ + "\37\2\u01b5\u01b3\3\2\2\2\u01b6\u01b9\3\2\2\2\u01b7\u01b5\3\2\2\2\u01b7"+ + "\u01b8\3\2\2\2\u01b8;\3\2\2\2\u01b9\u01b7\3\2\2\2\u01ba\u01c1\5\u0082"+ + "B\2\u01bb\u01bc\7F\2\2\u01bc\u01be\5\u0098M\2\u01bd\u01bb\3\2\2\2\u01bd"+ + "\u01be\3\2\2\2\u01be\u01bf\3\2\2\2\u01bf\u01c0\7\32\2\2\u01c0\u01c2\5"+ + ",\27\2\u01c1\u01bd\3\2\2\2\u01c1\u01c2\3\2\2\2\u01c2\u01c5\3\2\2\2\u01c3"+ + "\u01c4\7Q\2\2\u01c4\u01c6\5\u00aaV\2\u01c5\u01c3\3\2\2\2\u01c5\u01c6\3"+ + "\2\2\2\u01c6=\3\2\2\2\u01c7\u01c8\7B\2\2\u01c8\u01cd\7A\2\2\u01c9\u01ca"+ + "\7K\2\2\u01ca\u01cb\7B\2\2\u01cb\u01cd\7A\2\2\u01cc\u01c7\3\2\2\2\u01cc"+ + "\u01c9\3\2\2\2\u01cd\u01ce\3\2\2\2\u01ce\u01d3\5@!\2\u01cf\u01d0\7\30"+ + "\2\2\u01d0\u01d2\5@!\2\u01d1\u01cf\3\2\2\2\u01d2\u01d5\3\2\2\2\u01d3\u01d1"+ + "\3\2\2\2\u01d3\u01d4\3\2\2\2\u01d4?\3\2\2\2\u01d5\u01d3\3\2\2\2\u01d6"+ + "\u01d9\5,\27\2\u01d7\u01da\7L\2\2\u01d8\u01da\7M\2\2\u01d9\u01d7\3\2\2"+ + "\2\u01d9\u01d8\3\2\2\2\u01d9\u01da\3\2\2\2\u01da\u01e0\3\2\2\2\u01db\u01de"+ + "\7I\2\2\u01dc\u01df\7R\2\2\u01dd\u01df\7S\2\2\u01de\u01dc\3\2\2\2\u01de"+ + "\u01dd\3\2\2\2\u01df\u01e1\3\2\2\2\u01e0\u01db\3\2\2\2\u01e0\u01e1\3\2"+ + "\2\2\u01e1\u01e4\3\2\2\2\u01e2\u01e3\7Q\2\2\u01e3\u01e5\5\u00aaV\2\u01e4"+ + "\u01e2\3\2\2\2\u01e4\u01e5\3\2\2\2\u01e5A\3\2\2\2\u01e6\u01e7\7J\2\2\u01e7"+ + "\u01e8\5\u0082B\2\u01e8C\3\2\2\2\u01e9\u01ec\7N\2\2\u01ea\u01ec\7O\2\2"+ + "\u01eb\u01e9\3\2\2\2\u01eb\u01ea\3\2\2\2\u01ec\u01ed\3\2\2\2\u01ed\u01f2"+ + "\5F$\2\u01ee\u01ef\7\30\2\2\u01ef\u01f1\5F$\2\u01f0\u01ee\3\2\2\2\u01f1"+ + "\u01f4\3\2\2\2\u01f2\u01f0\3\2\2\2\u01f2\u01f3\3\2\2\2\u01f3\u01f5\3\2"+ + "\2\2\u01f4\u01f2\3\2\2\2\u01f5\u01f6\7P\2\2\u01f6\u01f7\5,\27\2\u01f7"+ + "E\3\2\2\2\u01f8\u01fb\5\u0082B\2\u01f9\u01fa\7F\2\2\u01fa\u01fc\5\u0098"+ + "M\2\u01fb\u01f9\3\2\2\2\u01fb\u01fc\3\2\2\2\u01fc\u01fd\3\2\2\2\u01fd"+ + "\u01fe\7E\2\2\u01fe\u01ff\5,\27\2\u01ffG\3\2\2\2\u0200\u0201\7T\2\2\u0201"+ + "\u0202\7\35\2\2\u0202\u0203\5*\26\2\u0203\u0205\7\36\2\2\u0204\u0206\5"+ + "J&\2\u0205\u0204\3\2\2\2\u0206\u0207\3\2\2\2\u0207\u0205\3\2\2\2\u0207"+ + "\u0208\3\2\2\2\u0208\u0209\3\2\2\2\u0209\u020a\7X\2\2\u020a\u020b\7C\2"+ + "\2\u020b\u020c\5,\27\2\u020cI\3\2\2\2\u020d\u020e\7U\2\2\u020e\u0210\5"+ + ",\27\2\u020f\u020d\3\2\2\2\u0210\u0211\3\2\2\2\u0211\u020f\3\2\2\2\u0211"+ + "\u0212\3\2\2\2\u0212\u0213\3\2\2\2\u0213\u0214\7C\2\2\u0214\u0215\5,\27"+ + "\2\u0215K\3\2\2\2\u0216\u0217\7[\2\2\u0217\u0218\7\35\2\2\u0218\u0219"+ + "\5*\26\2\u0219\u021b\7\36\2\2\u021a\u021c\5N(\2\u021b\u021a\3\2\2\2\u021c"+ + "\u021d\3\2\2\2\u021d\u021b\3\2\2\2\u021d\u021e\3\2\2\2\u021e\u021f\3\2"+ + "\2\2\u021f\u0221\7X\2\2\u0220\u0222\5\u0082B\2\u0221\u0220\3\2\2\2\u0221"+ + "\u0222\3\2\2\2\u0222\u0223\3\2\2\2\u0223\u0224\7C\2\2\u0224\u0225\5,\27"+ + "\2\u0225M\3\2\2\2\u0226\u022a\7U\2\2\u0227\u0228\5\u0082B\2\u0228\u0229"+ + "\7F\2\2\u0229\u022b\3\2\2\2\u022a\u0227\3\2\2\2\u022a\u022b\3\2\2\2\u022b"+ + "\u022c\3\2\2\2\u022c\u0231\5\u0098M\2\u022d\u022e\7\"\2\2\u022e\u0230"+ + "\5\u0098M\2\u022f\u022d\3\2\2\2\u0230\u0233\3\2\2\2\u0231\u022f\3\2\2"+ + "\2\u0231\u0232\3\2\2\2\u0232\u0234\3\2\2\2\u0233\u0231\3\2\2\2\u0234\u0235"+ + "\7C\2\2\u0235\u0236\5,\27\2\u0236O\3\2\2\2\u0237\u0238\7D\2\2\u0238\u0239"+ + "\7\35\2\2\u0239\u023a\5*\26\2\u023a\u023b\7\36\2\2\u023b\u023c\7Y\2\2"+ + "\u023c\u023d\5,\27\2\u023d\u023e\7Z\2\2\u023e\u023f\5,\27\2\u023fQ\3\2"+ + "\2\2\u0240\u0241\7V\2\2\u0241\u0242\7\37\2\2\u0242\u0243\5*\26\2\u0243"+ + "\u0245\7 \2\2\u0244\u0246\5T+\2\u0245\u0244\3\2\2\2\u0246\u0247\3\2\2"+ + "\2\u0247\u0245\3\2\2\2\u0247\u0248\3\2\2\2\u0248S\3\2\2\2\u0249\u024c"+ + "\7W\2\2\u024a\u024d\7#\2\2\u024b\u024d\5\32\16\2\u024c\u024a\3\2\2\2\u024c"+ + "\u024b\3\2\2\2\u024d\u0255\3\2\2\2\u024e\u0251\7\"\2\2\u024f\u0252\7#"+ + "\2\2\u0250\u0252\5\32\16\2\u0251\u024f\3\2\2\2\u0251\u0250\3\2\2\2\u0252"+ + "\u0254\3\2\2\2\u0253\u024e\3\2\2\2\u0254\u0257\3\2\2\2\u0255\u0253\3\2"+ + "\2\2\u0255\u0256\3\2\2\2\u0256\u0258\3\2\2\2\u0257\u0255\3\2\2\2\u0258"+ + "\u0259\7\37\2\2\u0259\u025a\5*\26\2\u025a\u025b\7 \2\2\u025bU\3\2\2\2"+ + "\u025c\u0261\5X-\2\u025d\u025e\7\\\2\2\u025e\u0260\5X-\2\u025f\u025d\3"+ + "\2\2\2\u0260\u0263\3\2\2\2\u0261\u025f\3\2\2\2\u0261\u0262\3\2\2\2\u0262"+ + "W\3\2\2\2\u0263\u0261\3\2\2\2\u0264\u0269\5Z.\2\u0265\u0266\7]\2\2\u0266"+ + "\u0268\5Z.\2\u0267\u0265\3\2\2\2\u0268\u026b\3\2\2\2\u0269\u0267\3\2\2"+ + "\2\u0269\u026a\3\2\2\2\u026aY\3\2\2\2\u026b\u0269\3\2\2\2\u026c\u026e"+ + "\7^\2\2\u026d\u026c\3\2\2\2\u026d\u026e\3\2\2\2\u026e\u026f\3\2\2\2\u026f"+ + "\u0270\5\\/\2\u0270[\3\2\2\2\u0271\u0274\5^\60\2\u0272\u0273\t\6\2\2\u0273"+ + "\u0275\5^\60\2\u0274\u0272\3\2\2\2\u0274\u0275\3\2\2\2\u0275]\3\2\2\2"+ + "\u0276\u027b\5`\61\2\u0277\u0278\7/\2\2\u0278\u027a\5`\61\2\u0279\u0277"+ + "\3\2\2\2\u027a\u027d\3\2\2\2\u027b\u0279\3\2\2\2\u027b\u027c\3\2\2\2\u027c"+ + "_\3\2\2\2\u027d\u027b\3\2\2\2\u027e\u0281\5b\62\2\u027f\u0280\7_\2\2\u0280"+ + "\u0282\5b\62\2\u0281\u027f\3\2\2\2\u0281\u0282\3\2\2\2\u0282a\3\2\2\2"+ + "\u0283\u0288\5d\63\2\u0284\u0285\t\7\2\2\u0285\u0287\5d\63\2\u0286\u0284"+ + "\3\2\2\2\u0287\u028a\3\2\2\2\u0288\u0286\3\2\2\2\u0288\u0289\3\2\2\2\u0289"+ + "c\3\2\2\2\u028a\u0288\3\2\2\2\u028b\u0290\5f\64\2\u028c\u028d\t\b\2\2"+ + "\u028d\u028f\5f\64\2\u028e\u028c\3\2\2\2\u028f\u0292\3\2\2\2\u0290\u028e"+ + "\3\2\2\2\u0290\u0291\3\2\2\2\u0291e\3\2\2\2\u0292\u0290\3\2\2\2\u0293"+ + "\u0297\5h\65\2\u0294\u0295\7`\2\2\u0295\u0296\7a\2\2\u0296\u0298\5\u0098"+ + "M\2\u0297\u0294\3\2\2\2\u0297\u0298\3\2\2\2\u0298g\3\2\2\2\u0299\u029d"+ + "\5j\66\2\u029a\u029b\7c\2\2\u029b\u029c\7b\2\2\u029c\u029e\5\u0098M\2"+ + "\u029d\u029a\3\2\2\2\u029d\u029e\3\2\2\2\u029ei\3\2\2\2\u029f\u02a3\5"+ + "l\67\2\u02a0\u02a1\7d\2\2\u02a1\u02a2\7F\2\2\u02a2\u02a4\5\u0098M\2\u02a3"+ + "\u02a0\3\2\2\2\u02a3\u02a4\3\2\2\2\u02a4k\3\2\2\2\u02a5\u02a9\5n8\2\u02a6"+ + "\u02a7\7f\2\2\u02a7\u02a8\7F\2\2\u02a8\u02aa\5\u00a4S\2\u02a9\u02a6\3"+ + "\2\2\2\u02a9\u02aa\3\2\2\2\u02aam\3\2\2\2\u02ab\u02af\5p9\2\u02ac\u02ad"+ + "\7e\2\2\u02ad\u02ae\7F\2\2\u02ae\u02b0\5\u00a4S\2\u02af\u02ac\3\2\2\2"+ + "\u02af\u02b0\3\2\2\2\u02b0o\3\2\2\2\u02b1\u02b8\5r:\2\u02b2\u02b3\7\6"+ + "\2\2\u02b3\u02b4\7-\2\2\u02b4\u02b5\3\2\2\2\u02b5\u02b7\5\u008cG\2\u02b6"+ + "\u02b2\3\2\2\2\u02b7\u02ba\3\2\2\2\u02b8\u02b6\3\2\2\2\u02b8\u02b9\3\2"+ + "\2\2\u02b9q\3\2\2\2\u02ba\u02b8\3\2\2\2\u02bb\u02bd\t\7\2\2\u02bc\u02bb"+ + "\3\2\2\2\u02bd\u02c0\3\2\2\2\u02be\u02bc\3\2\2\2\u02be\u02bf\3\2\2\2\u02bf"+ + "\u02c1\3\2\2\2\u02c0\u02be\3\2\2\2\u02c1\u02c2\5t;\2\u02c2s\3\2\2\2\u02c3"+ + "\u02c8\5v<\2\u02c4\u02c5\7\65\2\2\u02c5\u02c7\5v<\2\u02c6\u02c4\3\2\2"+ + "\2\u02c7\u02ca\3\2\2\2\u02c8\u02c6\3\2\2\2\u02c8\u02c9\3\2\2\2\u02c9u"+ + "\3\2\2\2\u02ca\u02c8\3\2\2\2\u02cb\u02d3\5\u0080A\2\u02cc\u02d2\5x=\2"+ + "\u02cd\u02d2\5|?\2\u02ce\u02d2\5~@\2\u02cf\u02d2\5z>\2\u02d0\u02d2\5\u008e"+ + "H\2\u02d1\u02cc\3\2\2\2\u02d1\u02cd\3\2\2\2\u02d1\u02ce\3\2\2\2\u02d1"+ + "\u02cf\3\2\2\2\u02d1\u02d0\3\2\2\2\u02d2\u02d5\3\2\2\2\u02d3\u02d1\3\2"+ + "\2\2\u02d3\u02d4\3\2\2\2\u02d4w\3\2\2\2\u02d5\u02d3\3\2\2\2\u02d6\u02d7"+ + "\7\66\2\2\u02d7\u02d8\7\66\2\2\u02d8\u02d9\5*\26\2\u02d9\u02da\7\67\2"+ + "\2\u02da\u02db\7\67\2\2\u02dby\3\2\2\2\u02dc\u02dd\7\66\2\2\u02dd\u02de"+ + "\7\67\2\2\u02de{\3\2\2\2\u02df\u02e0\7\66\2\2\u02e0\u02e1\5*\26\2\u02e1"+ + "\u02e2\7\67\2\2\u02e2}\3\2\2\2\u02e3\u02ea\78\2\2\u02e4\u02eb\5\u00ae"+ + "X\2\u02e5\u02eb\5\u00acW\2\u02e6\u02eb\7s\2\2\u02e7\u02eb\5\u0084C\2\u02e8"+ + "\u02eb\5\u0082B\2\u02e9\u02eb\5\u0086D\2\u02ea\u02e4\3\2\2\2\u02ea\u02e5"+ + "\3\2\2\2\u02ea\u02e6\3\2\2\2\u02ea\u02e7\3\2\2\2\u02ea\u02e8\3\2\2\2\u02ea"+ + "\u02e9\3\2\2\2\u02eb\177\3\2\2\2\u02ec\u02f9\7k\2\2\u02ed\u02f9\7l\2\2"+ + "\u02ee\u02f9\5\u00acW\2\u02ef\u02f9\5\u0082B\2\u02f0\u02f9\5\u0084C\2"+ + "\u02f1\u02f9\5\u0086D\2\u02f2\u02f9\5\u009aN\2\u02f3\u02f9\5\u008cG\2"+ + "\u02f4\u02f9\5\u0088E\2\u02f5\u02f9\5\u008aF\2\u02f6\u02f9\5\u00a8U\2"+ + "\u02f7\u02f9\5\u0092J\2\u02f8\u02ec\3\2\2\2\u02f8\u02ed\3\2\2\2\u02f8"+ + "\u02ee\3\2\2\2\u02f8\u02ef\3\2\2\2\u02f8\u02f0\3\2\2\2\u02f8\u02f1\3\2"+ + "\2\2\u02f8\u02f2\3\2\2\2\u02f8\u02f3\3\2\2\2\u02f8\u02f4\3\2\2\2\u02f8"+ + "\u02f5\3\2\2\2\u02f8\u02f6\3\2\2\2\u02f8\u02f7\3\2\2\2\u02f9\u0081\3\2"+ + "\2\2\u02fa\u02fb\7!\2\2\u02fb\u02fc\5\32\16\2\u02fc\u0083\3\2\2\2\u02fd"+ + "\u02ff\7\35\2\2\u02fe\u0300\5*\26\2\u02ff\u02fe\3\2\2\2\u02ff\u0300\3"+ + "\2\2\2\u0300\u0301\3\2\2\2\u0301\u0302\7\36\2\2\u0302\u0085\3\2\2\2\u0303"+ + "\u0304\79\2\2\u0304\u0087\3\2\2\2\u0305\u0306\7\t\2\2\u0306\u0307\7\37"+ + "\2\2\u0307\u0308\5*\26\2\u0308\u0309\7 \2\2\u0309\u0089\3\2\2\2\u030a"+ + "\u030b\7\n\2\2\u030b\u030c\7\37\2\2\u030c\u030d\5*\26\2\u030d\u030e\7"+ + " \2\2\u030e\u008b\3\2\2\2\u030f\u0310\5\32\16\2\u0310\u0311\5\u008eH\2"+ + "\u0311\u008d\3\2\2\2\u0312\u0319\7\35\2\2\u0313\u0315\5\u0090I\2\u0314"+ + "\u0316\7\30\2\2\u0315\u0314\3\2\2\2\u0315\u0316\3\2\2\2\u0316\u0318\3"+ + "\2\2\2\u0317\u0313\3\2\2\2\u0318\u031b\3\2\2\2\u0319\u0317\3\2\2\2\u0319"+ + "\u031a\3\2\2\2\u031a\u031c\3\2\2\2\u031b\u0319\3\2\2\2\u031c\u031d\7\36"+ + "\2\2\u031d\u008f\3\2\2\2\u031e\u0321\5,\27\2\u031f\u0321\7j\2\2\u0320"+ + "\u031e\3\2\2\2\u0320\u031f\3\2\2\2\u0321\u0091\3\2\2\2\u0322\u0325\5\u0094"+ + "K\2\u0323\u0325\5\u0096L\2\u0324\u0322\3\2\2\2\u0324\u0323\3\2\2\2\u0325"+ + "\u0093\3\2\2\2\u0326\u0327\5\32\16\2\u0327\u0328\7:\2\2\u0328\u0329\7"+ + "l\2\2\u0329\u0095\3\2\2\2\u032a\u032b\7\34\2\2\u032b\u032d\7\35\2\2\u032c"+ + "\u032e\5&\24\2\u032d\u032c\3\2\2\2\u032d\u032e\3\2\2\2\u032e\u032f\3\2"+ + "\2\2\u032f\u0332\7\36\2\2\u0330\u0331\7F\2\2\u0331\u0333\5\u0098M\2\u0332"+ + "\u0330\3\2\2\2\u0332\u0333\3\2\2\2\u0333\u0334\3\2\2\2\u0334\u0336\7\37"+ + "\2\2\u0335\u0337\5*\26\2\u0336\u0335\3\2\2\2\u0336\u0337\3\2\2\2\u0337"+ + "\u0338\3\2\2\2\u0338\u0339\7 \2\2\u0339\u0097\3\2\2\2\u033a\u033b\7\35"+ + "\2\2\u033b\u0343\7\36\2\2\u033c\u0340\5\u009cO\2\u033d\u0341\7j\2\2\u033e"+ + "\u0341\7#\2\2\u033f\u0341\7\60\2\2\u0340\u033d\3\2\2\2\u0340\u033e\3\2"+ + "\2\2\u0340\u033f\3\2\2\2\u0340\u0341\3\2\2\2\u0341\u0343\3\2\2\2\u0342"+ + "\u033a\3\2\2\2\u0342\u033c\3\2\2\2\u0343\u0099\3\2\2\2\u0344\u034d\7\37"+ + "\2\2\u0345\u034a\5\u00a6T\2\u0346\u0347\7\30\2\2\u0347\u0349\5\u00a6T"+ + "\2\u0348\u0346\3\2\2\2\u0349\u034c\3\2\2\2\u034a\u0348\3\2\2\2\u034a\u034b"+ + "\3\2\2\2\u034b\u034e\3\2\2\2\u034c\u034a\3\2\2\2\u034d\u0345\3\2\2\2\u034d"+ + "\u034e\3\2\2\2\u034e\u034f\3\2\2\2\u034f\u0355\7 \2\2\u0350\u0351\7;\2"+ + "\2\u0351\u0352\5*\26\2\u0352\u0353\7<\2\2\u0353\u0355\3\2\2\2\u0354\u0344"+ + "\3\2\2\2\u0354\u0350\3\2\2\2\u0355\u009b\3\2\2\2\u0356\u035a\5\32\16\2"+ + "\u0357\u035a\7k\2\2\u0358\u035a\5\u009eP\2\u0359\u0356\3\2\2\2\u0359\u0357"+ + "\3\2\2\2\u0359\u0358\3\2\2\2\u035a\u009d\3\2\2\2\u035b\u035e\5\u00a0Q"+ + "\2\u035c\u035e\5\u00a2R\2\u035d\u035b\3\2\2\2\u035d\u035c\3\2\2\2\u035e"+ + "\u009f\3\2\2\2\u035f\u0360\7\34\2\2\u0360\u0361\7\35\2\2\u0361\u0362\7"+ + "#\2\2\u0362\u0363\7\36\2\2\u0363\u00a1\3\2\2\2\u0364\u0365\7\34\2\2\u0365"+ + "\u036e\7\35\2\2\u0366\u036b\5\u0098M\2\u0367\u0368\7\30\2\2\u0368\u036a"+ + "\5\u0098M\2\u0369\u0367\3\2\2\2\u036a\u036d\3\2\2\2\u036b\u0369\3\2\2"+ + "\2\u036b\u036c\3\2\2\2\u036c\u036f\3\2\2\2\u036d\u036b\3\2\2\2\u036e\u0366"+ + "\3\2\2\2\u036e\u036f\3\2\2\2\u036f\u0370\3\2\2\2\u0370\u0371\7\36\2\2"+ + "\u0371\u0372\7F\2\2\u0372\u0373\5\u0098M\2\u0373\u00a3\3\2\2\2\u0374\u0376"+ + "\5\u009cO\2\u0375\u0377\7j\2\2\u0376\u0375\3\2\2\2\u0376\u0377\3\2\2\2"+ + "\u0377\u00a5\3\2\2\2\u0378\u037b\5,\27\2\u0379\u037b\7s\2\2\u037a\u0378"+ + "\3\2\2\2\u037a\u0379\3\2\2\2\u037b\u037c\3\2\2\2\u037c\u037d\t\t\2\2\u037d"+ + "\u037e\5,\27\2\u037e\u00a7\3\2\2\2\u037f\u0381\7\66\2\2\u0380\u0382\5"+ + "*\26\2\u0381\u0380\3\2\2\2\u0381\u0382\3\2\2\2\u0382\u0383\3\2\2\2\u0383"+ + "\u0384\7\67\2\2\u0384\u00a9\3\2\2\2\u0385\u0386\5\u00acW\2\u0386\u00ab"+ + "\3\2\2\2\u0387\u0388\7i\2\2\u0388\u00ad\3\2\2\2\u0389\u038a\t\n\2\2\u038a"+ + "\u00af\3\2\2\2d\u00b8\u00bc\u00cc\u00d2\u00da\u00e1\u00eb\u0101\u0109"+ + "\u010e\u0111\u0115\u0120\u0129\u012c\u0133\u013a\u013c\u0143\u0148\u014c"+ + "\u0150\u0157\u015e\u0165\u016f\u0173\u017b\u017d\u0189\u018f\u0193\u0197"+ + "\u01a2\u01a8\u01b7\u01bd\u01c1\u01c5\u01cc\u01d3\u01d9\u01de\u01e0\u01e4"+ + "\u01eb\u01f2\u01fb\u0207\u0211\u021d\u0221\u022a\u0231\u0247\u024c\u0251"+ + "\u0255\u0261\u0269\u026d\u0274\u027b\u0281\u0288\u0290\u0297\u029d\u02a3"+ + "\u02a9\u02af\u02b8\u02be\u02c8\u02d1\u02d3\u02ea\u02f8\u02ff\u0315\u0319"+ + "\u0320\u0324\u032d\u0332\u0336\u0340\u0342\u034a\u034d\u0354\u0359\u035d"+ + "\u036b\u036e\u0376\u037a\u0381"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/src/main/java/org/rumbledb/parser/JsoniqVisitor.java b/src/main/java/org/rumbledb/parser/JsoniqVisitor.java index 4024f0f701..8808cf05c6 100644 --- a/src/main/java/org/rumbledb/parser/JsoniqVisitor.java +++ b/src/main/java/org/rumbledb/parser/JsoniqVisitor.java @@ -481,6 +481,24 @@ public interface JsoniqVisitor extends ParseTreeVisitor { * @return the visitor result */ T visitItemType(JsoniqParser.ItemTypeContext ctx); + /** + * Visit a parse tree produced by {@link JsoniqParser#functionTest}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunctionTest(JsoniqParser.FunctionTestContext ctx); + /** + * Visit a parse tree produced by {@link JsoniqParser#anyFunctionTest}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAnyFunctionTest(JsoniqParser.AnyFunctionTestContext ctx); + /** + * Visit a parse tree produced by {@link JsoniqParser#typedFunctionTest}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTypedFunctionTest(JsoniqParser.TypedFunctionTestContext ctx); /** * Visit a parse tree produced by {@link JsoniqParser#singleType}. * @param ctx the parse tree From bf054731686510c0af92ed07c05b8e26aad71da3 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sat, 13 Feb 2021 11:32:35 +0100 Subject: [PATCH 157/206] added all static type and native flwor tests to CI --- .gitlab-ci.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93cef44574..6fcaf18408 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,10 +2,18 @@ image: marioarduini/rumble-source:2020-11-23 build-rumble: stage: build + artifacts: + paths: + - targets/ script: - ant -buildfile build_antlr_parser.xml generate-parser -Dantlr.jar=lib/antlr-4.7-complete.jar - mvn clean compile assembly:single +javaapi-test: + stage: test + script: + - mvn -Dtest=JavaAPITest test + frontend-test: stage: test script: @@ -21,10 +29,15 @@ sparkruntime-test: script: - mvn -Dtest=SparkRuntimeTests test -javaapi-test: +nativeflworruntime-test: stage: test script: - - mvn -Dtest=JavaAPITest test + - mvn -Dtest=NativeFLWORRuntimeTests test + +statictyping-test: + stage: test + script: + - mvn -Dtest=StaticTypeTests test spotless-test: stage: test From b5c855c41dff83626c4875612779b1b69d65254d Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sat, 13 Feb 2021 11:33:12 +0100 Subject: [PATCH 158/206] spotless --- .../java/org/rumbledb/compiler/TranslationVisitor.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 02795e5ee7..7df1d1e39a 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -1171,14 +1171,14 @@ public ItemType processItemType(JsoniqParser.ItemTypeContext itemTypeContext) { return BuiltinTypesCatalogue.nullItem; } JsoniqParser.FunctionTestContext fnCtx = itemTypeContext.functionTest(); - if(fnCtx != null){ + if (fnCtx != null) { // we have a function item type JsoniqParser.TypedFunctionTestContext typedFnCtx = fnCtx.typedFunctionTest(); - if(typedFnCtx != null){ + if (typedFnCtx != null) { SequenceType rt = processSequenceType(typedFnCtx.rt); List st = typedFnCtx.st.stream() - .map(this::processSequenceType) - .collect(Collectors.toList()); + .map(this::processSequenceType) + .collect(Collectors.toList()); FunctionSignature signature = new FunctionSignature(st, rt); // TODO: move item type creation to ItemFactory return new FunctionItemType(signature); From b3f8b1b73b46536017784c42a8441ecdf57affe0 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sat, 13 Feb 2021 11:35:27 +0100 Subject: [PATCH 159/206] fix on CI --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6fcaf18408..33481971c4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ build-rumble: stage: build artifacts: paths: - - targets/ + - target/ script: - ant -buildfile build_antlr_parser.xml generate-parser -Dantlr.jar=lib/antlr-4.7-complete.jar - mvn clean compile assembly:single From b23be48f7a10d52213452d32438c8efc95c0ed32 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Sun, 14 Feb 2021 17:04:32 +0100 Subject: [PATCH 160/206] itemtype interface renaming and added itemtype factory --- .../java/org/rumbledb/compiler/InferTypeVisitor.java | 12 ++++++------ .../org/rumbledb/compiler/TranslationVisitor.java | 2 +- .../rumbledb/runtime/typing/InstanceOfIterator.java | 2 +- src/main/java/org/rumbledb/types/AtomicItemType.java | 8 ++++---- .../java/org/rumbledb/types/FunctionItemType.java | 10 +++++----- src/main/java/org/rumbledb/types/ItemItemType.java | 2 +- src/main/java/org/rumbledb/types/ItemType.java | 10 +++++----- .../java/org/rumbledb/types/ItemTypeFactory.java | 7 +++++++ src/main/java/org/rumbledb/types/SequenceType.java | 2 +- 9 files changed, 31 insertions(+), 24 deletions(-) create mode 100644 src/main/java/org/rumbledb/types/ItemTypeFactory.java diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 433e7a7bc2..dee47b13f9 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -126,7 +126,7 @@ public StaticContext visitCommaExpression(CommaExpression expression, StaticCont inferredType = childExpressionInferredType; } else { ItemType resultingItemType = inferredType.getItemType() - .findCommonSuperType(childExpressionInferredType.getItemType()); + .findLeastCommonSuperType(childExpressionInferredType.getItemType()); SequenceType.Arity resultingArity = ((inferredType.getArity() == SequenceType.Arity.OneOrZero || inferredType.getArity() == SequenceType.Arity.ZeroOrMore) @@ -271,7 +271,7 @@ public StaticContext visitInlineFunctionExpr(InlineFunctionExpression expression } List params = new ArrayList<>(expression.getParams().values()); FunctionSignature signature = new FunctionSignature(params, returnType); - expression.setInferredSequenceType(new SequenceType(new FunctionItemType(signature))); + expression.setInferredSequenceType(new SequenceType(ItemTypeFactory.createFunctionItemType(signature))); System.out.println("Visited inline function expression"); return argument; } @@ -298,7 +298,7 @@ public StaticContext visitNamedFunctionRef(NamedFunctionReferenceExpression expr FunctionSignature signature = getSignature(expression.getIdentifier(), expression.getStaticContext()); - expression.setInferredSequenceType(new SequenceType(new FunctionItemType(signature))); + expression.setInferredSequenceType(new SequenceType(ItemTypeFactory.createFunctionItemType(signature))); System.out.println("Visited named function expression"); return argument; } @@ -331,7 +331,7 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static if (expression.isPartialApplication()) { FunctionSignature partialSignature = new FunctionSignature(partialParams, signature.getReturnType()); - expression.setInferredSequenceType(new SequenceType(new FunctionItemType(partialSignature))); + expression.setInferredSequenceType(new SequenceType(ItemTypeFactory.createFunctionItemType(partialSignature))); } else { SequenceType returnType = signature.getReturnType(); if (returnType == null) { @@ -996,7 +996,7 @@ public void checkSwitchType(SequenceType type) { ); } ItemType itemType = type.getItemType(); - if (itemType.isFunctionItem()) { + if (itemType.isFunctionItemType()) { throw new UnexpectedStaticTypeException( "function item not allowed for the expressions of switch test condition and cases", ErrorCode.UnexpectedFunctionItem @@ -1354,7 +1354,7 @@ public StaticContext visitDynamicFunctionCallExpression( boolean isAnyFunction = false; if (!mainType.isEmptySequence()) { ItemType type = mainType.getItemType(); - if (type.isFunctionItem()) { + if (type.isFunctionItemType()) { if (type.equals(BuiltinTypesCatalogue.anyFunctionItem)) { isAnyFunction = true; } else { diff --git a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java index 7df1d1e39a..c28e75bbeb 100644 --- a/src/main/java/org/rumbledb/compiler/TranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/TranslationVisitor.java @@ -1181,7 +1181,7 @@ public ItemType processItemType(JsoniqParser.ItemTypeContext itemTypeContext) { .collect(Collectors.toList()); FunctionSignature signature = new FunctionSignature(st, rt); // TODO: move item type creation to ItemFactory - return new FunctionItemType(signature); + return ItemTypeFactory.createFunctionItemType(signature); } else { return BuiltinTypesCatalogue.anyFunctionItem; diff --git a/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java b/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java index 4855e63200..78605f1d4f 100644 --- a/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java @@ -183,7 +183,7 @@ public static boolean doesItemTypeMatchItem(ItemType itemType, Item itemToMatch) if (itemType.equals(BuiltinTypesCatalogue.base64BinaryItem)) { return itemToMatch.isBase64Binary(); } - if (itemType.isFunctionItem()) { + if (itemType.isFunctionItemType()) { return itemToMatch.isFunction(); } throw new OurBadException("Type unrecognized: " + itemType); diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 1314631ecd..620eed1a6e 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -81,17 +81,17 @@ public boolean equals(Object other) { } @Override - public boolean isSubtypeOfAtomicItem() { + public boolean isAtomicItemType() { return !(this.equals(arrayItem) || this.equals(objectItem)); } @Override - public boolean isObjectItem() { + public boolean isObjectItemType() { return this.equals(objectItem); } @Override - public boolean isArrayItem() { + public boolean isArrayItemType() { return this.equals(arrayItem); } @@ -141,7 +141,7 @@ public boolean isSubtypeOf(ItemType superType) { } @Override - public ItemType findCommonSuperType(ItemType other) { + public ItemType findLeastCommonSuperType(ItemType other) { if (other.isSubtypeOf(this)) { return this; } else if (this.isSubtypeOf(other)) { diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index 36862b1bbd..abdf8b8990 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -8,7 +8,7 @@ public class FunctionItemType implements ItemType { private FunctionSignature signature; static FunctionItemType anyFunctionItem = new FunctionItemType(true); - public FunctionItemType(FunctionSignature signature) { + FunctionItemType(FunctionSignature signature) { if (signature == null) { throw new OurBadException("a new function item type must have a signature"); } @@ -31,7 +31,7 @@ public boolean equals(Object other) { } @Override - public boolean isFunctionItem() { + public boolean isFunctionItemType() { return true; } @@ -47,18 +47,18 @@ public boolean isSubtypeOf(ItemType superType) { ) { return true; } - if (superType.isFunctionItem() && this.signature.isSubtypeOf(superType.getSignature())) { + if (superType.isFunctionItemType() && this.signature.isSubtypeOf(superType.getSignature())) { return true; } return false; } @Override - public ItemType findCommonSuperType(ItemType other) { + public ItemType findLeastCommonSuperType(ItemType other) { if (this.equals(other)) { return this; } - if (other.isFunctionItem()) { + if (other.isFunctionItemType()) { return anyFunctionItem; } return BuiltinTypesCatalogue.item; diff --git a/src/main/java/org/rumbledb/types/ItemItemType.java b/src/main/java/org/rumbledb/types/ItemItemType.java index 6f5f024c88..83a7636310 100644 --- a/src/main/java/org/rumbledb/types/ItemItemType.java +++ b/src/main/java/org/rumbledb/types/ItemItemType.java @@ -42,7 +42,7 @@ public boolean isSubtypeOf(ItemType superType) { } @Override - public ItemType findCommonSuperType(ItemType other) { + public ItemType findLeastCommonSuperType(ItemType other) { return item; } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 566f347fa7..b1e5d71ec2 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -40,28 +40,28 @@ public interface ItemType extends Serializable { /** * @return true it [this] is a subtype of an atomic item type. */ - public default boolean isSubtypeOfAtomicItem() { + public default boolean isAtomicItemType() { return false; } /** * @return true it [this] is an object item type. */ - public default boolean isObjectItem() { + public default boolean isObjectItemType() { return false; } /** * @return true it [this] is an array item type. */ - public default boolean isArrayItem() { + public default boolean isArrayItemType() { return false; } /** * @return true it [this] is a function item type. */ - public default boolean isFunctionItem() { + public default boolean isFunctionItemType() { return false; } @@ -111,7 +111,7 @@ public default FunctionSignature getSignature() { * @return the common supertype between [this] and [other], that would be the LCA in the item type tree of [this] * and [other] */ - public ItemType findCommonSuperType(ItemType other); + public ItemType findLeastCommonSuperType(ItemType other); /** * Check at static time if [this] could be casted to [other] item type, requires [this] to be an atomic type diff --git a/src/main/java/org/rumbledb/types/ItemTypeFactory.java b/src/main/java/org/rumbledb/types/ItemTypeFactory.java new file mode 100644 index 0000000000..c9ecfb4d6b --- /dev/null +++ b/src/main/java/org/rumbledb/types/ItemTypeFactory.java @@ -0,0 +1,7 @@ +package org.rumbledb.types; + +public class ItemTypeFactory { + public static FunctionItemType createFunctionItemType(FunctionSignature signature){ + return new FunctionItemType(signature); + } +} diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index f3de78132d..7d94610037 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -163,7 +163,7 @@ public SequenceType leastCommonSupertypeWith(SequenceType other) { return new SequenceType(this.itemType, resultingArity); } - ItemType itemSupertype = this.getItemType().findCommonSuperType(other.getItemType()); + ItemType itemSupertype = this.getItemType().findLeastCommonSuperType(other.getItemType()); Arity aritySuperType = Arity.ZeroOrMore; if (this.isAritySubtypeOf(other.getArity())) { aritySuperType = other.getArity(); From c908521545108b86e9f71e0c6c6f9cd5f981974d Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 15 Feb 2021 12:23:32 +0100 Subject: [PATCH 161/206] copied over jsound and ignored in tracking --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index d9829e3266..0623ce7d04 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ target/ *.iml /bin/ + +# for now ignore jsound package +src/main/java/jsound/ From c6364f99cf1995343fa101da00300164a19fc720 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 15 Feb 2021 12:29:36 +0100 Subject: [PATCH 162/206] added jsound package but not tracked --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index d9829e3266..23490e5cf2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ target/ *.iml /bin/ + +# for now ignore jsound package +src/main/java/jsound/ \ No newline at end of file From 6ef1d7ce009a53f45a5aa56612ba6e66581660bc Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 16 Feb 2021 11:49:10 +0100 Subject: [PATCH 163/206] integrated general and atomic facets in itemtype interface --- .../org/rumbledb/types/AtomicItemType.java | 150 +++++++++++++++--- .../java/org/rumbledb/types/FacetTypes.java | 31 ++++ .../java/org/rumbledb/types/ItemType.java | 138 ++++++++++++++++ .../org/rumbledb/types/TimezoneFacet.java | 7 + 4 files changed, 304 insertions(+), 22 deletions(-) create mode 100644 src/main/java/org/rumbledb/types/FacetTypes.java create mode 100644 src/main/java/org/rumbledb/types/TimezoneFacet.java diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 620eed1a6e..ba7ee6868d 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -2,74 +2,175 @@ import org.rumbledb.context.Name; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + + public class AtomicItemType implements ItemType { private static final long serialVersionUID = 1L; // TODO: extract array and object into its own types static final AtomicItemType atomicItem = new AtomicItemType( - new Name(Name.JS_NS, "js", "atomic") + new Name(Name.JS_NS, "js", "atomic"), + Collections.emptySet() ); static final AtomicItemType stringItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "string") + new Name(Name.XS_NS, "xs", "string"), + new HashSet<>(Arrays.asList(FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) ); static final AtomicItemType integerItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "integer") + new Name(Name.XS_NS, "xs", "integer"), + new HashSet<>(Arrays.asList( + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.TOTALDIGITS, + FacetTypes.FRACTIONDIGITS + )) ); static final AtomicItemType decimalItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "decimal") + new Name(Name.XS_NS, "xs", "decimal"), + new HashSet<>(Arrays.asList( + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.TOTALDIGITS, + FacetTypes.FRACTIONDIGITS + )) ); static final AtomicItemType doubleItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "double") + new Name(Name.XS_NS, "xs", "double"), + new HashSet<>(Arrays.asList( + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE + )) ); static final AtomicItemType floatItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "float") + new Name(Name.XS_NS, "xs", "float"), + new HashSet<>(Arrays.asList( + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE + )) ); static final AtomicItemType booleanItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "boolean") + new Name(Name.XS_NS, "xs", "boolean"), + Collections.emptySet() + ); + static final AtomicItemType nullItem = new AtomicItemType( + new Name(Name.JS_NS, "js", "null"), + Collections.emptySet() ); - static final AtomicItemType nullItem = new AtomicItemType(new Name(Name.JS_NS, "js", "null")); static final AtomicItemType durationItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "duration") + new Name(Name.XS_NS, "xs", "duration"), + new HashSet<>(Arrays.asList( + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE + )) ); static final AtomicItemType yearMonthDurationItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "yearMonthDuration") + new Name(Name.XS_NS, "xs", "yearMonthDuration"), + new HashSet<>(Arrays.asList( + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE + )) ); static final AtomicItemType dayTimeDurationItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "dayTimeDuration") + new Name(Name.XS_NS, "xs", "dayTimeDuration"), + new HashSet<>(Arrays.asList( + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE + )) ); static final AtomicItemType dateTimeItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "dateTime") + new Name(Name.XS_NS, "xs", "dateTime"), + new HashSet<>(Arrays.asList( + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.EXPLICITTIMEZONE + )) + ); + static final AtomicItemType dateItem = new AtomicItemType( + new Name(Name.XS_NS, "xs", "date"), + new HashSet<>(Arrays.asList( + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.EXPLICITTIMEZONE + )) + ); + static final AtomicItemType timeItem = new AtomicItemType( + new Name(Name.XS_NS, "xs", "time"), + new HashSet<>(Arrays.asList( + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.EXPLICITTIMEZONE + )) ); - static final AtomicItemType dateItem = new AtomicItemType(new Name(Name.XS_NS, "xs", "date")); - static final AtomicItemType timeItem = new AtomicItemType(new Name(Name.XS_NS, "xs", "time")); static final AtomicItemType hexBinaryItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "hexBinary") + new Name(Name.XS_NS, "xs", "hexBinary"), + new HashSet<>(Arrays.asList(FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) ); static final AtomicItemType anyURIItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "anyURI") + new Name(Name.XS_NS, "xs", "anyURI"), + new HashSet<>(Arrays.asList(FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) ); static final AtomicItemType base64BinaryItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "base64Binary") + new Name(Name.XS_NS, "xs", "base64Binary"), + new HashSet<>(Arrays.asList(FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) ); static final AtomicItemType JSONItem = new AtomicItemType( - new Name(Name.JS_NS, "xs", "json-item") + new Name(Name.JS_NS, "xs", "json-item"), + Collections.emptySet() ); static final AtomicItemType objectItem = new AtomicItemType( - new Name(Name.JS_NS, "js", "object") + new Name(Name.JS_NS, "js", "object"), + Collections.emptySet() ); static final AtomicItemType arrayItem = new AtomicItemType( - new Name(Name.JS_NS, "js", "array") + new Name(Name.JS_NS, "js", "array"), + Collections.emptySet() + ); + static final AtomicItemType intItem = new AtomicItemType( + Name.createVariableInDefaultTypeNamespace("int"), + new HashSet<>(Arrays.asList( + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.TOTALDIGITS, + FacetTypes.FRACTIONDIGITS + )) ); - static final AtomicItemType intItem = new AtomicItemType(Name.createVariableInDefaultTypeNamespace("int")); private Name name; + private Set allowedFacets; public AtomicItemType() { } - private AtomicItemType(Name name) { + private AtomicItemType(Name name, Set allowedFacets) { this.name = name; + this.allowedFacets = allowedFacets; } @Override @@ -235,6 +336,11 @@ public boolean canBePromotedTo(ItemType other) { return false; } + @Override + public Set getAllowedFacets() { + return this.allowedFacets; + } + @Override public String toString() { return this.name.toString(); diff --git a/src/main/java/org/rumbledb/types/FacetTypes.java b/src/main/java/org/rumbledb/types/FacetTypes.java new file mode 100644 index 0000000000..76aa5500f9 --- /dev/null +++ b/src/main/java/org/rumbledb/types/FacetTypes.java @@ -0,0 +1,31 @@ +package org.rumbledb.types; + +public enum FacetTypes { + LENGTH("length"), + MINLENGTH("minLength"), + MAXLENGTH("maxLength"), + MININCLUSIVE("minInclusive"), + MAXINCLUSIVE("maxInclusive"), + MINEXCLUSIVE("minExclusive"), + MAXEXCLUSIVE("maxExclusive"), + TOTALDIGITS("totalDigits"), + FRACTIONDIGITS("fractionDigits"), + EXPLICITTIMEZONE("explicitTimezone"), + + CONTENT("content"), + CLOSED("closed"), + + ENUMERATION("enumeration"), + METADATA("metadata"), + CONSTRAINTS("constraints"); + + private String facetName; + + FacetTypes(String facetName) { + this.facetName = facetName; + } + + public String getTypeName() { + return facetName; + } +} diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index b1e5d71ec2..c5ecd0dfcc 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -21,9 +21,13 @@ package org.rumbledb.types; +import org.rumbledb.api.Item; import org.rumbledb.context.Name; import java.io.Serializable; +import java.util.Collections; +import java.util.List; +import java.util.Set; public interface ItemType extends Serializable { @@ -37,6 +41,8 @@ public interface ItemType extends Serializable { */ public boolean equals(Object other); + // region kind + /** * @return true it [this] is a subtype of an atomic item type. */ @@ -73,6 +79,10 @@ public default boolean isNumeric() { return false; } + // endregion + + // region concrete-specific-function + /** * Tests for QName. * @@ -98,6 +108,10 @@ public default FunctionSignature getSignature() { throw new UnsupportedOperationException("getSignature operation is not supported for non-function item types"); } + // endregion + + // region hierarchy + /** * * @param superType another item type @@ -134,5 +148,129 @@ public default boolean canBePromotedTo(ItemType itemType) { return false; } + // endregion + + // region user-defined + + /** + * + * @return [true] if it is a user-defined type, false otherwise + */ + public default boolean isUserDefined(){ + return false; + } + + /** + * + * @return the base type for a user-defined type, throw an error for not user-defined types + */ + public default ItemType getBaseType(){ + throw new UnsupportedOperationException("getBaseType operation is supported only for user-defined types"); + } + + /** + * + * @return a set containing the allowed facets for restricting the type + */ + public Set getAllowedFacets(); + + /** + * + * @return the list of possible values for [this] item type or null if the enumeration facet is not set + */ + public default List getEnumerationFacet(){ + return null; + } + + /** + * + * @return the list of constraints in the implementation-defined language for [this] item type (note that this facet is cumulative) or an empty list if the constraints facet is not set + */ + public default List getConstraintsFacet(){ + return Collections.emptyList(); + } + + /** + * + * @return the minimum length facet value for [this] item type or null if the restriction is not set + */ + public default Integer getMinLengthFacet(){ + return null; + } + + /** + * + * @return the length facet value for [this] item type or null if the restriction is not set + */ + public default Integer getLengthFacet(){ + return null; + } + + /** + * + * @return the maximum length facet value for [this] item type or null if the restriction is not set + */ + public default Integer getMaxLengthFacet(){ + return null; + } + + /** + * + * @return an item representing the minimum possible value (excluded) for [this] item type or null if the restriction is not set + */ + public default Item getMinExclusiveFacet(){ + return null; + } + + /** + * + * @return an item representing the minimum possible value (included) for [this] item type or null if the restriction is not set + */ + public default Item getMinInclusiveFacet(){ + return null; + } + + /** + * + * @return an item representing the maximum possible value (excluded) for [this] item type or null if the restriction is not set + */ + public default Item getMaxExclusiveFacet(){ + return null; + } + + /** + * + * @return an item representing the maximum possible value (included) for [this] item type or null if the restriction is not set + */ + public default Item getMaxInclusiveFacet(){ + return null; + } + + /** + * + * @return the total digits facet value for [this] item type or null if the restriction is not set + */ + public default Integer getTotalDigitsFacet(){ + return null; + } + + /** + * + * @return the fraction digits facet value for [this] item type or null if the restriction is not set + */ + public default Integer getFractionDigitsFacet(){ + return null; + } + + /** + * + * @return the explicit timezone facet value for [this] item type or null if the restriction is not set + */ + public default TimezoneFacet getExplicitTimezoneFacet(){ + return null; + } + + // endregion + public String toString(); } diff --git a/src/main/java/org/rumbledb/types/TimezoneFacet.java b/src/main/java/org/rumbledb/types/TimezoneFacet.java new file mode 100644 index 0000000000..5d6e7f82fd --- /dev/null +++ b/src/main/java/org/rumbledb/types/TimezoneFacet.java @@ -0,0 +1,7 @@ +package org.rumbledb.types; + +public enum TimezoneFacet { + REQUIRED, + PROHIBITED, + OPTIONAL +} From 11c38f124773ecf302695bf4b6d8d22662b8b6e5 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 17 Feb 2021 12:19:15 +0100 Subject: [PATCH 164/206] added user defined atomic type concrete implementation and small rename --- .../rumbledb/compiler/InferTypeVisitor.java | 2 +- .../org/rumbledb/types/AtomicItemType.java | 2 +- .../org/rumbledb/types/FunctionItemType.java | 2 +- .../java/org/rumbledb/types/ItemItemType.java | 2 +- .../java/org/rumbledb/types/ItemType.java | 2 +- .../java/org/rumbledb/types/SequenceType.java | 2 +- .../types/UserDefinedAtomicItemType.java | 177 ++++++++++++++++++ 7 files changed, 183 insertions(+), 6 deletions(-) create mode 100644 src/main/java/org/rumbledb/types/UserDefinedAtomicItemType.java diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index dee47b13f9..9bbfd2aef8 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -126,7 +126,7 @@ public StaticContext visitCommaExpression(CommaExpression expression, StaticCont inferredType = childExpressionInferredType; } else { ItemType resultingItemType = inferredType.getItemType() - .findLeastCommonSuperType(childExpressionInferredType.getItemType()); + .findLeastCommonSuperTypeWith(childExpressionInferredType.getItemType()); SequenceType.Arity resultingArity = ((inferredType.getArity() == SequenceType.Arity.OneOrZero || inferredType.getArity() == SequenceType.Arity.ZeroOrMore) diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index ba7ee6868d..6362862f6e 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -242,7 +242,7 @@ public boolean isSubtypeOf(ItemType superType) { } @Override - public ItemType findLeastCommonSuperType(ItemType other) { + public ItemType findLeastCommonSuperTypeWith(ItemType other) { if (other.isSubtypeOf(this)) { return this; } else if (this.isSubtypeOf(other)) { diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index abdf8b8990..dbb1de405b 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -54,7 +54,7 @@ public boolean isSubtypeOf(ItemType superType) { } @Override - public ItemType findLeastCommonSuperType(ItemType other) { + public ItemType findLeastCommonSuperTypeWith(ItemType other) { if (this.equals(other)) { return this; } diff --git a/src/main/java/org/rumbledb/types/ItemItemType.java b/src/main/java/org/rumbledb/types/ItemItemType.java index 83a7636310..7c31db3efa 100644 --- a/src/main/java/org/rumbledb/types/ItemItemType.java +++ b/src/main/java/org/rumbledb/types/ItemItemType.java @@ -42,7 +42,7 @@ public boolean isSubtypeOf(ItemType superType) { } @Override - public ItemType findLeastCommonSuperType(ItemType other) { + public ItemType findLeastCommonSuperTypeWith(ItemType other) { return item; } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index c5ecd0dfcc..061cd9b013 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -125,7 +125,7 @@ public default FunctionSignature getSignature() { * @return the common supertype between [this] and [other], that would be the LCA in the item type tree of [this] * and [other] */ - public ItemType findLeastCommonSuperType(ItemType other); + public ItemType findLeastCommonSuperTypeWith(ItemType other); /** * Check at static time if [this] could be casted to [other] item type, requires [this] to be an atomic type diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index 7d94610037..29de1c765f 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -163,7 +163,7 @@ public SequenceType leastCommonSupertypeWith(SequenceType other) { return new SequenceType(this.itemType, resultingArity); } - ItemType itemSupertype = this.getItemType().findLeastCommonSuperType(other.getItemType()); + ItemType itemSupertype = this.getItemType().findLeastCommonSuperTypeWith(other.getItemType()); Arity aritySuperType = Arity.ZeroOrMore; if (this.isAritySubtypeOf(other.getArity())) { aritySuperType = other.getArity(); diff --git a/src/main/java/org/rumbledb/types/UserDefinedAtomicItemType.java b/src/main/java/org/rumbledb/types/UserDefinedAtomicItemType.java new file mode 100644 index 0000000000..e0c0230a63 --- /dev/null +++ b/src/main/java/org/rumbledb/types/UserDefinedAtomicItemType.java @@ -0,0 +1,177 @@ +package org.rumbledb.types; + +import org.apache.commons.collections.ListUtils; +import org.rumbledb.api.Item; +import org.rumbledb.context.Name; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Set; + +public class UserDefinedAtomicItemType implements ItemType { + + private final ItemType baseType; + private final Name name; + private final Item minInclusive, maxInclusive, minExclusive, maxExclusive; + private final Integer minLength, length, maxLength, totalDigits, fractionDigits; + private final List constraints; + private final List enumeration; + private final TimezoneFacet explicitTimezone; + + UserDefinedAtomicItemType(Name name, ItemType baseType, HashMap facets) { + // TODO : check in item factory that: name not already used or invalid, facets are correct and allowed according to baseType + this.name = name; + this.baseType = baseType; + + this.minInclusive = (Item) facets.get(FacetTypes.MININCLUSIVE); + this.maxInclusive = (Item) facets.get(FacetTypes.MAXINCLUSIVE); + this.minExclusive = (Item) facets.get(FacetTypes.MINEXCLUSIVE); + this.maxExclusive = (Item) facets.get(FacetTypes.MAXEXCLUSIVE); + + this.minLength = (Integer) facets.get(FacetTypes.MINLENGTH); + this.length = (Integer) facets.get(FacetTypes.LENGTH); + this.maxLength = (Integer) facets.get(FacetTypes.MAXLENGTH); + this.totalDigits = (Integer) facets.get(FacetTypes.TOTALDIGITS); + this.fractionDigits = (Integer) facets.get(FacetTypes.FRACTIONDIGITS); + + this.explicitTimezone = (TimezoneFacet) facets.get(FacetTypes.EXPLICITTIMEZONE); + + this.constraints = (List) facets.getOrDefault(FacetTypes.CONSTRAINTS, Collections.emptyList()); + this.enumeration = (List) facets.get(FacetTypes.ENUMERATION); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof ItemType)) { + return false; + } + return this.toString().equals(other.toString()); + } + + @Override + public boolean isAtomicItemType() { + return true; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Name getName() { + return this.name; + } + + @Override + public boolean isSubtypeOf(ItemType superType) { + return this.equals(superType) || superType.equals(this.baseType) || this.baseType.isSubtypeOf(superType); + } + + @Override + public ItemType findLeastCommonSuperTypeWith(ItemType other) { + if(this.isSubtypeOf(other)){ + return other; + } else if(other.isSubtypeOf(this)){ + return this; + } else { + return this.baseType.findLeastCommonSuperTypeWith(other.isUserDefined() ? other.getBaseType() : other); + } + } + + @Override + public boolean isStaticallyCastableAs(ItemType other) { + // TODO: what about further restrictions like string without num from int? + ItemType castFrom = this.baseType; + while(castFrom.isUserDefined()){ + castFrom = castFrom.getBaseType(); + } + ItemType castTo = other; + while (castTo.isUserDefined()){ + castTo = castTo.getBaseType(); + } + return castFrom.isStaticallyCastableAs(castTo); + } + + @Override + public boolean canBePromotedTo(ItemType other) { + // TODO : how about restriction types + if (other.equals(BuiltinTypesCatalogue.stringItem)) { + return this.isSubtypeOf(BuiltinTypesCatalogue.stringItem) || this.isSubtypeOf(BuiltinTypesCatalogue.anyURIItem); + } + if (other.equals(BuiltinTypesCatalogue.doubleItem)) { + return this.isNumeric(); + } + return false; + } + + @Override + public boolean isUserDefined() { + return true; + } + + @Override + public ItemType getBaseType() { + return this.baseType; + } + + @Override + public Set getAllowedFacets() { + throw new UnsupportedOperationException("only non-user-defined types specify allowed facets"); + } + + public List getEnumerationFacet(){ + return this.enumeration == null ? this.baseType.getEnumerationFacet() : this.enumeration; + } + + public List getConstraintsFacet(){ + return ListUtils.union(this.baseType.getConstraintsFacet(), this.constraints); + } + + public Integer getMinLengthFacet(){ + return this.minLength == null ? this.baseType.getMinLengthFacet() : this.minLength; + } + + public Integer getLengthFacet(){ + return this.length == null ? this.baseType.getLengthFacet() : this.length; + } + + public Integer getMaxLengthFacet(){ + return this.maxLength == null ? this.baseType.getMaxLengthFacet() : this.maxLength; + } + + public Item getMinExclusiveFacet(){ + return this.minExclusive == null ? this.baseType.getMinExclusiveFacet() : this.minExclusive; + } + + public Item getMinInclusiveFacet(){ + return this.minInclusive == null ? this.baseType.getMinInclusiveFacet() : this.minInclusive; + } + + public Item getMaxExclusiveFacet(){ + return this.maxExclusive == null ? this.baseType.getMaxExclusiveFacet() : this.maxExclusive; + } + + public Item getMaxInclusiveFacet(){ + return this.maxInclusive == null ? this.baseType.getMaxInclusiveFacet() : this.maxInclusive; + } + + public Integer getTotalDigitsFacet(){ + return this.totalDigits == null ? this.baseType.getTotalDigitsFacet() : this.totalDigits; + } + + public Integer getFractionDigitsFacet(){ + return this.fractionDigits == null ? this.baseType.getFractionDigitsFacet() : this.fractionDigits; + } + + public TimezoneFacet getExplicitTimezoneFacet(){ + return this.explicitTimezone == null ? this.baseType.getExplicitTimezoneFacet() : this.explicitTimezone; + } + + @Override + public String toString() { + // TODO : Consider added facets restriction and base type + return this.name.toString(); + } +} From 48b3ae6586c0cdd33bdbc70d5daa5d8ace2e1a1b Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 22 Feb 2021 09:07:37 +0100 Subject: [PATCH 165/206] cleaned interface about throwing exceptions and supported operations, added primitive, distinction between primitive and derived atomic types --- ...emType.java => DerivedAtomicItemType.java} | 64 +++++++++++++++-- .../org/rumbledb/types/FunctionItemType.java | 11 ++- .../java/org/rumbledb/types/ItemType.java | 70 +++++++++++-------- 3 files changed, 110 insertions(+), 35 deletions(-) rename src/main/java/org/rumbledb/types/{UserDefinedAtomicItemType.java => DerivedAtomicItemType.java} (64%) diff --git a/src/main/java/org/rumbledb/types/UserDefinedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java similarity index 64% rename from src/main/java/org/rumbledb/types/UserDefinedAtomicItemType.java rename to src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index e0c0230a63..3289b104ee 100644 --- a/src/main/java/org/rumbledb/types/UserDefinedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -9,9 +9,10 @@ import java.util.List; import java.util.Set; -public class UserDefinedAtomicItemType implements ItemType { +public class DerivedAtomicItemType implements ItemType { - private final ItemType baseType; + private final ItemType baseType, primitiveType; + private final boolean isUserDefined; private final Name name; private final Item minInclusive, maxInclusive, minExclusive, maxExclusive; private final Integer minLength, length, maxLength, totalDigits, fractionDigits; @@ -19,10 +20,17 @@ public class UserDefinedAtomicItemType implements ItemType { private final List enumeration; private final TimezoneFacet explicitTimezone; - UserDefinedAtomicItemType(Name name, ItemType baseType, HashMap facets) { + DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, HashMap facets){ + this(name, baseType, primitiveType, facets, true); + } + // TODO : turn builtin derived atomic types into this class + + private DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, HashMap facets, boolean isUserDefined) { // TODO : check in item factory that: name not already used or invalid, facets are correct and allowed according to baseType this.name = name; this.baseType = baseType; + this.primitiveType = primitiveType; + this.isUserDefined = isUserDefined; this.minInclusive = (Item) facets.get(FacetTypes.MININCLUSIVE); this.maxInclusive = (Item) facets.get(FacetTypes.MAXINCLUSIVE); @@ -108,7 +116,17 @@ public boolean canBePromotedTo(ItemType other) { @Override public boolean isUserDefined() { - return true; + return isUserDefined; + } + + @Override + public boolean isPrimitive() { + return false; + } + + @Override + public ItemType getPrimitiveType() { + return this.primitiveType; } @Override @@ -118,54 +136,90 @@ public ItemType getBaseType() { @Override public Set getAllowedFacets() { - throw new UnsupportedOperationException("only non-user-defined types specify allowed facets"); + return this.primitiveType.getAllowedFacets(); } public List getEnumerationFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.ENUMERATION)){ + throw new UnsupportedOperationException("this item type does not support the enumeration facet"); + } return this.enumeration == null ? this.baseType.getEnumerationFacet() : this.enumeration; } public List getConstraintsFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.CONSTRAINTS)){ + throw new UnsupportedOperationException("this item type does not support the constraints facet"); + } return ListUtils.union(this.baseType.getConstraintsFacet(), this.constraints); } public Integer getMinLengthFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.MINLENGTH)){ + throw new UnsupportedOperationException("this item type does not support the minimum length facet"); + } return this.minLength == null ? this.baseType.getMinLengthFacet() : this.minLength; } public Integer getLengthFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.LENGTH)){ + throw new UnsupportedOperationException("this item type does not support the length facet"); + } return this.length == null ? this.baseType.getLengthFacet() : this.length; } public Integer getMaxLengthFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.MAXLENGTH)){ + throw new UnsupportedOperationException("this item type does not support the maximum length facet"); + } return this.maxLength == null ? this.baseType.getMaxLengthFacet() : this.maxLength; } public Item getMinExclusiveFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.MINEXCLUSIVE)){ + throw new UnsupportedOperationException("this item type does not support the minimum exclusive facet"); + } return this.minExclusive == null ? this.baseType.getMinExclusiveFacet() : this.minExclusive; } public Item getMinInclusiveFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.MININCLUSIVE)){ + throw new UnsupportedOperationException("this item type does not support the minimum inclusive facet"); + } return this.minInclusive == null ? this.baseType.getMinInclusiveFacet() : this.minInclusive; } public Item getMaxExclusiveFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.MAXEXCLUSIVE)){ + throw new UnsupportedOperationException("this item type does not support the maximum exclusive facet"); + } return this.maxExclusive == null ? this.baseType.getMaxExclusiveFacet() : this.maxExclusive; } public Item getMaxInclusiveFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.MAXINCLUSIVE)){ + throw new UnsupportedOperationException("this item type does not support the maximum inclusive facet"); + } return this.maxInclusive == null ? this.baseType.getMaxInclusiveFacet() : this.maxInclusive; } public Integer getTotalDigitsFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.TOTALDIGITS)){ + throw new UnsupportedOperationException("this item type does not support the total digits facet"); + } return this.totalDigits == null ? this.baseType.getTotalDigitsFacet() : this.totalDigits; } public Integer getFractionDigitsFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.FRACTIONDIGITS)){ + throw new UnsupportedOperationException("this item type does not support the fraction digits facet"); + } return this.fractionDigits == null ? this.baseType.getFractionDigitsFacet() : this.fractionDigits; } public TimezoneFacet getExplicitTimezoneFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.EXPLICITTIMEZONE)){ + throw new UnsupportedOperationException("this item type does not support the explicit timezone facet"); + } return this.explicitTimezone == null ? this.baseType.getExplicitTimezoneFacet() : this.explicitTimezone; } diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index dbb1de405b..cccd2e9184 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -2,10 +2,12 @@ import org.rumbledb.exceptions.OurBadException; +import java.util.Set; + public class FunctionItemType implements ItemType { - private boolean isGeneric; - private FunctionSignature signature; + private final boolean isGeneric; + private final FunctionSignature signature; static FunctionItemType anyFunctionItem = new FunctionItemType(true); FunctionItemType(FunctionSignature signature) { @@ -64,6 +66,11 @@ public ItemType findLeastCommonSuperTypeWith(ItemType other) { return BuiltinTypesCatalogue.item; } + @Override + public Set getAllowedFacets() { + throw new UnsupportedOperationException("function item types does not support facets"); + } + @Override public String toString() { return this.isGeneric ? "function(*)" : this.signature.toString(); diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 061cd9b013..ffbeee6272 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -31,7 +31,7 @@ public interface ItemType extends Serializable { - // protected static final long serialVersionUID = 1L; + long serialVersionUID = 1L; /** * Tests for itemType equality. @@ -39,35 +39,35 @@ public interface ItemType extends Serializable { * @param other another item type. * @return true it is equal to other, false otherwise. */ - public boolean equals(Object other); + boolean equals(Object other); // region kind /** * @return true it [this] is a subtype of an atomic item type. */ - public default boolean isAtomicItemType() { + default boolean isAtomicItemType() { return false; } /** * @return true it [this] is an object item type. */ - public default boolean isObjectItemType() { + default boolean isObjectItemType() { return false; } /** * @return true it [this] is an array item type. */ - public default boolean isArrayItemType() { + default boolean isArrayItemType() { return false; } /** * @return true it [this] is a function item type. */ - public default boolean isFunctionItemType() { + default boolean isFunctionItemType() { return false; } @@ -75,7 +75,7 @@ public default boolean isFunctionItemType() { * * @return [true] if this is a numeric item type, false otherwise */ - public default boolean isNumeric() { + default boolean isNumeric() { return false; } @@ -88,7 +88,7 @@ public default boolean isNumeric() { * * @return true if [this] item type has a QName */ - public default boolean hasName() { + default boolean hasName() { return false; } @@ -96,7 +96,7 @@ public default boolean hasName() { * * @return the itemtype QName if available */ - public default Name getName() { + default Name getName() { throw new UnsupportedOperationException("getName operation is not supported for this itemType"); } @@ -104,7 +104,7 @@ public default Name getName() { * * @return the signature of the function item type if available */ - public default FunctionSignature getSignature() { + default FunctionSignature getSignature() { throw new UnsupportedOperationException("getSignature operation is not supported for non-function item types"); } @@ -117,7 +117,7 @@ public default FunctionSignature getSignature() { * @param superType another item type * @return true if [this] is a subtype of [superType], any type is considered a subtype of itself */ - public boolean isSubtypeOf(ItemType superType); + boolean isSubtypeOf(ItemType superType); /** * @@ -125,7 +125,7 @@ public default FunctionSignature getSignature() { * @return the common supertype between [this] and [other], that would be the LCA in the item type tree of [this] * and [other] */ - public ItemType findLeastCommonSuperTypeWith(ItemType other); + ItemType findLeastCommonSuperTypeWith(ItemType other); /** * Check at static time if [this] could be casted to [other] item type, requires [this] to be an atomic type @@ -133,7 +133,7 @@ public default FunctionSignature getSignature() { * @param other a strict subtype of atomic item type to which we are trying to cast * @return true if it is possible at static time to cast [this] to [other], false otherwise */ - public default boolean isStaticallyCastableAs(ItemType other) { + default boolean isStaticallyCastableAs(ItemType other) { throw new UnsupportedOperationException( "isStaticallyCastableAs operation is not supported for non-atomic item types" ); @@ -144,7 +144,7 @@ public default boolean isStaticallyCastableAs(ItemType other) { * @param itemType another item type * @return true if [this] can be promoted to [itemType] */ - public default boolean canBePromotedTo(ItemType itemType) { + default boolean canBePromotedTo(ItemType itemType) { return false; } @@ -156,15 +156,29 @@ public default boolean canBePromotedTo(ItemType itemType) { * * @return [true] if it is a user-defined type, false otherwise */ - public default boolean isUserDefined(){ + default boolean isUserDefined(){ return false; } + /** + * + * @return [true] if it is a primitive type + */ + default boolean isPrimitive() { return true; } + + /** + * + * @return the primitive type for a derived type, throw an error for primitive types + */ + default ItemType getPrimitiveType(){ + throw new UnsupportedOperationException("getPrimitiveType operation is supported only for non-primitive types"); + } + /** * * @return the base type for a user-defined type, throw an error for not user-defined types */ - public default ItemType getBaseType(){ + default ItemType getBaseType(){ throw new UnsupportedOperationException("getBaseType operation is supported only for user-defined types"); } @@ -178,7 +192,7 @@ public default ItemType getBaseType(){ * * @return the list of possible values for [this] item type or null if the enumeration facet is not set */ - public default List getEnumerationFacet(){ + default List getEnumerationFacet(){ return null; } @@ -186,7 +200,7 @@ public default List getEnumerationFacet(){ * * @return the list of constraints in the implementation-defined language for [this] item type (note that this facet is cumulative) or an empty list if the constraints facet is not set */ - public default List getConstraintsFacet(){ + default List getConstraintsFacet(){ return Collections.emptyList(); } @@ -194,7 +208,7 @@ public default List getConstraintsFacet(){ * * @return the minimum length facet value for [this] item type or null if the restriction is not set */ - public default Integer getMinLengthFacet(){ + default Integer getMinLengthFacet(){ return null; } @@ -202,7 +216,7 @@ public default Integer getMinLengthFacet(){ * * @return the length facet value for [this] item type or null if the restriction is not set */ - public default Integer getLengthFacet(){ + default Integer getLengthFacet(){ return null; } @@ -210,7 +224,7 @@ public default Integer getLengthFacet(){ * * @return the maximum length facet value for [this] item type or null if the restriction is not set */ - public default Integer getMaxLengthFacet(){ + default Integer getMaxLengthFacet(){ return null; } @@ -218,7 +232,7 @@ public default Integer getMaxLengthFacet(){ * * @return an item representing the minimum possible value (excluded) for [this] item type or null if the restriction is not set */ - public default Item getMinExclusiveFacet(){ + default Item getMinExclusiveFacet(){ return null; } @@ -226,7 +240,7 @@ public default Item getMinExclusiveFacet(){ * * @return an item representing the minimum possible value (included) for [this] item type or null if the restriction is not set */ - public default Item getMinInclusiveFacet(){ + default Item getMinInclusiveFacet(){ return null; } @@ -234,7 +248,7 @@ public default Item getMinInclusiveFacet(){ * * @return an item representing the maximum possible value (excluded) for [this] item type or null if the restriction is not set */ - public default Item getMaxExclusiveFacet(){ + default Item getMaxExclusiveFacet(){ return null; } @@ -242,7 +256,7 @@ public default Item getMaxExclusiveFacet(){ * * @return an item representing the maximum possible value (included) for [this] item type or null if the restriction is not set */ - public default Item getMaxInclusiveFacet(){ + default Item getMaxInclusiveFacet(){ return null; } @@ -250,7 +264,7 @@ public default Item getMaxInclusiveFacet(){ * * @return the total digits facet value for [this] item type or null if the restriction is not set */ - public default Integer getTotalDigitsFacet(){ + default Integer getTotalDigitsFacet(){ return null; } @@ -258,7 +272,7 @@ public default Integer getTotalDigitsFacet(){ * * @return the fraction digits facet value for [this] item type or null if the restriction is not set */ - public default Integer getFractionDigitsFacet(){ + default Integer getFractionDigitsFacet(){ return null; } @@ -266,7 +280,7 @@ public default Integer getFractionDigitsFacet(){ * * @return the explicit timezone facet value for [this] item type or null if the restriction is not set */ - public default TimezoneFacet getExplicitTimezoneFacet(){ + default TimezoneFacet getExplicitTimezoneFacet(){ return null; } From 9c533e735774918a0b883c4774058d8f7c6cab93 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 22 Feb 2021 09:27:01 +0100 Subject: [PATCH 166/206] added facets class to set derived item type facets --- .../rumbledb/types/DerivedAtomicItemType.java | 28 ++--- src/main/java/org/rumbledb/types/Facets.java | 113 ++++++++++++++++++ 2 files changed, 127 insertions(+), 14 deletions(-) create mode 100644 src/main/java/org/rumbledb/types/Facets.java diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index 3289b104ee..b2266f3120 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -20,33 +20,33 @@ public class DerivedAtomicItemType implements ItemType { private final List enumeration; private final TimezoneFacet explicitTimezone; - DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, HashMap facets){ + DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, Facets facets){ this(name, baseType, primitiveType, facets, true); } // TODO : turn builtin derived atomic types into this class - private DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, HashMap facets, boolean isUserDefined) { + private DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, Facets facets, boolean isUserDefined) { // TODO : check in item factory that: name not already used or invalid, facets are correct and allowed according to baseType this.name = name; this.baseType = baseType; this.primitiveType = primitiveType; this.isUserDefined = isUserDefined; - this.minInclusive = (Item) facets.get(FacetTypes.MININCLUSIVE); - this.maxInclusive = (Item) facets.get(FacetTypes.MAXINCLUSIVE); - this.minExclusive = (Item) facets.get(FacetTypes.MINEXCLUSIVE); - this.maxExclusive = (Item) facets.get(FacetTypes.MAXEXCLUSIVE); + this.minInclusive = facets.getMinInclusive(); + this.maxInclusive = facets.getMaxInclusive(); + this.minExclusive = facets.getMinExclusive(); + this.maxExclusive = facets.getMaxExclusive(); - this.minLength = (Integer) facets.get(FacetTypes.MINLENGTH); - this.length = (Integer) facets.get(FacetTypes.LENGTH); - this.maxLength = (Integer) facets.get(FacetTypes.MAXLENGTH); - this.totalDigits = (Integer) facets.get(FacetTypes.TOTALDIGITS); - this.fractionDigits = (Integer) facets.get(FacetTypes.FRACTIONDIGITS); + this.minLength = facets.getMinLength(); + this.length = facets.getLength(); + this.maxLength = facets.getMaxLength(); + this.totalDigits = facets.getTotalDigits(); + this.fractionDigits = facets.getFractionDigits(); - this.explicitTimezone = (TimezoneFacet) facets.get(FacetTypes.EXPLICITTIMEZONE); + this.explicitTimezone = facets.getExplicitTimezone(); - this.constraints = (List) facets.getOrDefault(FacetTypes.CONSTRAINTS, Collections.emptyList()); - this.enumeration = (List) facets.get(FacetTypes.ENUMERATION); + this.constraints = facets.getConstraints(); + this.enumeration = facets.getEnumeration(); } @Override diff --git a/src/main/java/org/rumbledb/types/Facets.java b/src/main/java/org/rumbledb/types/Facets.java new file mode 100644 index 0000000000..fae46676f0 --- /dev/null +++ b/src/main/java/org/rumbledb/types/Facets.java @@ -0,0 +1,113 @@ +package org.rumbledb.types; + +import org.rumbledb.api.Item; + +import java.util.Collections; +import java.util.List; + +/** + * Facets class represent a container with the ability to get and set facets and is intended to be a mutable proxy that will be passed to a DerivedAtomicType to indicate the specified facets + */ +public class Facets { + private Item minInclusive, maxInclusive, minExclusive, maxExclusive; + private Integer minLength, length, maxLength, totalDigits, fractionDigits; + private List constraints = Collections.emptyList(); + private List enumeration; + private TimezoneFacet explicitTimezone; + + public Item getMinInclusive() { + return this.minInclusive; + } + + public void setMinInclusive(Item minInclusive) { + this.minInclusive = minInclusive; + } + + public Item getMaxInclusive() { + return this.maxInclusive; + } + + public void setMaxInclusive(Item maxInclusive) { + this.maxInclusive = maxInclusive; + } + + public Item getMinExclusive() { + return this.minExclusive; + } + + public void setMinExclusive(Item minExclusive) { + this.minExclusive = minExclusive; + } + + public Item getMaxExclusive() { + return this.maxExclusive; + } + + public void setMaxExclusive(Item maxExclusive) { + this.maxExclusive = maxExclusive; + } + + public Integer getMinLength() { + return this.minLength; + } + + public void setMinLength(Integer minLength) { + this.minLength = minLength; + } + + public Integer getLength() { + return this.length; + } + + public void setLength(Integer length) { + this.length = length; + } + + public Integer getMaxLength() { + return this.maxLength; + } + + public void setMaxLength(Integer maxLength) { + this.maxLength = maxLength; + } + + public Integer getTotalDigits() { + return this.totalDigits; + } + + public void setTotalDigits(Integer totalDigits) { + this.totalDigits = totalDigits; + } + + public Integer getFractionDigits() { + return this.fractionDigits; + } + + public void setFractionDigits(Integer fractionDigits) { + this.fractionDigits = fractionDigits; + } + + public List getConstraints() { + return this.constraints; + } + + public void setConstraints(List constraints) { + this.constraints = constraints; + } + + public List getEnumeration() { + return this.enumeration; + } + + public void setEnumeration(List enumeration) { + this.enumeration = enumeration; + } + + public TimezoneFacet getExplicitTimezone() { + return this.explicitTimezone; + } + + public void setExplicitTimezone(TimezoneFacet explicitTimezone) { + this.explicitTimezone = explicitTimezone; + } +} From b209b7a52b94925971d9158ed58f95ad3b71be15 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 22 Feb 2021 09:36:04 +0100 Subject: [PATCH 167/206] added enum and constraints facets --- .../org/rumbledb/types/AtomicItemType.java | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 6362862f6e..3330cecbe8 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -19,11 +19,13 @@ public class AtomicItemType implements ItemType { ); static final AtomicItemType stringItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "string"), - new HashSet<>(Arrays.asList(FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) + new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) ); static final AtomicItemType integerItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "integer"), new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, FacetTypes.MININCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, @@ -35,6 +37,8 @@ public class AtomicItemType implements ItemType { static final AtomicItemType decimalItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "decimal"), new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, FacetTypes.MININCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, @@ -46,6 +50,8 @@ public class AtomicItemType implements ItemType { static final AtomicItemType doubleItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "double"), new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, FacetTypes.MININCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, @@ -55,6 +61,8 @@ public class AtomicItemType implements ItemType { static final AtomicItemType floatItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "float"), new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, FacetTypes.MININCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, @@ -63,7 +71,7 @@ public class AtomicItemType implements ItemType { ); static final AtomicItemType booleanItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "boolean"), - Collections.emptySet() + new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS)) ); static final AtomicItemType nullItem = new AtomicItemType( new Name(Name.JS_NS, "js", "null"), @@ -72,6 +80,8 @@ public class AtomicItemType implements ItemType { static final AtomicItemType durationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "duration"), new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, FacetTypes.MININCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, @@ -81,6 +91,8 @@ public class AtomicItemType implements ItemType { static final AtomicItemType yearMonthDurationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "yearMonthDuration"), new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, FacetTypes.MININCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, @@ -90,6 +102,8 @@ public class AtomicItemType implements ItemType { static final AtomicItemType dayTimeDurationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "dayTimeDuration"), new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, FacetTypes.MININCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, @@ -99,6 +113,8 @@ public class AtomicItemType implements ItemType { static final AtomicItemType dateTimeItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "dateTime"), new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, FacetTypes.MININCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, @@ -109,6 +125,8 @@ public class AtomicItemType implements ItemType { static final AtomicItemType dateItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "date"), new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, FacetTypes.MININCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, @@ -119,6 +137,8 @@ public class AtomicItemType implements ItemType { static final AtomicItemType timeItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "time"), new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, FacetTypes.MININCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, @@ -128,15 +148,15 @@ public class AtomicItemType implements ItemType { ); static final AtomicItemType hexBinaryItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "hexBinary"), - new HashSet<>(Arrays.asList(FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) + new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) ); static final AtomicItemType anyURIItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "anyURI"), - new HashSet<>(Arrays.asList(FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) + new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) ); static final AtomicItemType base64BinaryItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "base64Binary"), - new HashSet<>(Arrays.asList(FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) + new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) ); static final AtomicItemType JSONItem = new AtomicItemType( new Name(Name.JS_NS, "xs", "json-item"), @@ -153,6 +173,8 @@ public class AtomicItemType implements ItemType { static final AtomicItemType intItem = new AtomicItemType( Name.createVariableInDefaultTypeNamespace("int"), new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, FacetTypes.MININCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, From 6bbad35092b3cfdff2391e8dcb2f9ff8f0f8b65b Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 22 Feb 2021 14:40:38 +0100 Subject: [PATCH 168/206] integrated object item type --- .../rumbledb/types/DerivedAtomicItemType.java | 4 +- .../java/org/rumbledb/types/ItemType.java | 18 +++ .../org/rumbledb/types/ObjectItemType.java | 152 ++++++++++++++++++ 3 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/rumbledb/types/ObjectItemType.java diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index b2266f3120..27a38bcf88 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -74,7 +74,7 @@ public Name getName() { @Override public boolean isSubtypeOf(ItemType superType) { - return this.equals(superType) || superType.equals(this.baseType) || this.baseType.isSubtypeOf(superType); + return this.equals(superType) || this.baseType.isSubtypeOf(superType); } @Override @@ -84,7 +84,7 @@ public ItemType findLeastCommonSuperTypeWith(ItemType other) { } else if(other.isSubtypeOf(this)){ return this; } else { - return this.baseType.findLeastCommonSuperTypeWith(other.isUserDefined() ? other.getBaseType() : other); + return this.baseType.findLeastCommonSuperTypeWith(other.isPrimitive() ? other.getBaseType() : other); } } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index ffbeee6272..d3d0be7a18 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -21,12 +21,14 @@ package org.rumbledb.types; +import jsound.types.FieldDescriptor; import org.rumbledb.api.Item; import org.rumbledb.context.Name; import java.io.Serializable; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Set; public interface ItemType extends Serializable { @@ -284,6 +286,22 @@ default TimezoneFacet getExplicitTimezoneFacet(){ return null; } + /** + * + * @return content facet value for object item types (cumulative) + */ + default Map getContentFacet(){ + throw new UnsupportedOperationException("content facet is allowed only for object item types"); + } + + /** + * + * @return closed facet value for object item types + */ + default boolean getClosedFacet(){ + throw new UnsupportedOperationException("closed facet is allowed only for object item types"); + } + // endregion public String toString(); diff --git a/src/main/java/org/rumbledb/types/ObjectItemType.java b/src/main/java/org/rumbledb/types/ObjectItemType.java new file mode 100644 index 0000000000..8291991e6a --- /dev/null +++ b/src/main/java/org/rumbledb/types/ObjectItemType.java @@ -0,0 +1,152 @@ +package org.rumbledb.types; + +import jsound.types.FieldDescriptor; +import org.apache.commons.collections.ListUtils; +import org.apache.commons.collections.MapUtils; +import org.rumbledb.api.Item; +import org.rumbledb.context.Name; + +import java.util.*; + +public class ObjectItemType implements ItemType { + + final static ObjectItemType anyObjectItem = new ObjectItemType( + new Name(Name.JS_NS, "js", "object"), + false, + Collections.emptyMap(), + null, + Collections.emptyList(), + null + ); + + final static Set allowedFacets = new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.CONTENT, + FacetTypes.CLOSED + )); + + final private Name name; + final private Map content; + final private boolean isClosed; + final private List constraints; + final private List enumeration; + final private ItemType baseType; + + ObjectItemType(Name name, boolean isClosed, Map content, ItemType baseType, List constraints,List enumeration){ + this.name = name; + this.isClosed = isClosed; + this.content = content; + this.baseType = baseType; + this.constraints = constraints; + this.enumeration = enumeration; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof ItemType)) { + return false; + } + return this.toString().equals(other.toString()); + } + + @Override + public boolean isObjectItemType() { + return true; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Name getName() { + // TODO : what about anonymous types + return this.name; + } + + @Override + public boolean isSubtypeOf(ItemType superType) { + return this == anyObjectItem ? superType == anyObjectItem || superType == BuiltinTypesCatalogue.JSONItem || superType == BuiltinTypesCatalogue.item : + this.equals(superType) || this.baseType.isSubtypeOf(superType); + } + + @Override + public ItemType findLeastCommonSuperTypeWith(ItemType other) { + if(this.isSubtypeOf(other)){ + return other; + } else if(other.isSubtypeOf(this)){ + return this; + } else if(this == anyObjectItem) { + // if we reach here other not object item for sure + return other.isArrayItemType() ? BuiltinTypesCatalogue.JSONItem : BuiltinTypesCatalogue.item; + } else { + return this.getBaseType().findLeastCommonSuperTypeWith(other.isPrimitive() ? other : other.getBaseType()); + } + } + + @Override + public boolean isUserDefined() { + return !(this == anyObjectItem); + } + + @Override + public boolean isPrimitive() { + return this == anyObjectItem; + } + + @Override + public ItemType getPrimitiveType() { + return anyObjectItem; + } + + @Override + public ItemType getBaseType() { + return this.baseType; + } + + @Override + public Set getAllowedFacets() { + return allowedFacets; + } + + @Override + public List getEnumerationFacet() { + if(this.enumeration != null){ + return this.enumeration; + } else if(this.isPrimitive()){ + return null; + } else { + return baseType.getEnumerationFacet(); + } + } + + @Override + public List getConstraintsFacet() { + return this.isPrimitive() ? this.constraints : ListUtils.union(this.baseType.getConstraintsFacet(), this.constraints); + } + + @Override + public Map getContentFacet() { + if(this.isPrimitive()){ + return this.content; + } else { + // recursively get content facet, overriding new descriptors + Map map = new HashMap<>(this.baseType.getContentFacet()); + map.putAll(this.content); + return map; + } + } + + @Override + public boolean getClosedFacet() { + return this.isClosed; + } + + @Override + public String toString() { + // consider add content and various stuff + return this.name.toString(); + } +} From 3170ddc241ee914ed1dec85cfa487002b6dba061 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 22 Feb 2021 14:55:04 +0100 Subject: [PATCH 169/206] refactored item type to throw error on get facet by default --- .../org/rumbledb/types/AtomicItemType.java | 103 +++++++++++++++++- .../rumbledb/types/DerivedAtomicItemType.java | 36 ++++-- .../java/org/rumbledb/types/ItemType.java | 26 ++--- 3 files changed, 136 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 3330cecbe8..a5c67f761a 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -1,11 +1,10 @@ package org.rumbledb.types; +import org.apache.commons.collections.ListUtils; +import org.rumbledb.api.Item; import org.rumbledb.context.Name; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; +import java.util.*; public class AtomicItemType implements ItemType { @@ -363,6 +362,102 @@ public Set getAllowedFacets() { return this.allowedFacets; } + @Override + public List getEnumerationFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.ENUMERATION)){ + throw new UnsupportedOperationException(this.toString() + " item type does not support the enumeration facet"); + } + return null; + } + + @Override + public List getConstraintsFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.CONSTRAINTS)){ + throw new UnsupportedOperationException(this.toString() + " item type does not support the constraints facet"); + } + return Collections.emptyList(); + } + + @Override + public Integer getMinLengthFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.MINLENGTH)){ + throw new UnsupportedOperationException(this.toString() + " item type does not support the minimum length facet"); + } + return null; + } + + @Override + public Integer getLengthFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.LENGTH)){ + throw new UnsupportedOperationException(this.toString() + " item type does not support the length facet"); + } + return null; + } + + @Override + public Integer getMaxLengthFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.MAXLENGTH)){ + throw new UnsupportedOperationException(this.toString() + " item type does not support the maximum length facet"); + } + return null; + } + + @Override + public Item getMinExclusiveFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.MINEXCLUSIVE)){ + throw new UnsupportedOperationException(this.toString() + " item type does not support the minimum exclusive facet"); + } + return null; + } + + @Override + public Item getMinInclusiveFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.MININCLUSIVE)){ + throw new UnsupportedOperationException(this.toString() + " item type does not support the minimum inclusive facet"); + } + return null; + } + + @Override + public Item getMaxExclusiveFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.MAXEXCLUSIVE)){ + throw new UnsupportedOperationException(this.toString() + " item type does not support the maximum exclusive facet"); + } + return null; + } + + @Override + public Item getMaxInclusiveFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.MAXINCLUSIVE)){ + throw new UnsupportedOperationException(this.toString() + " item type does not support the maximum inclusive facet"); + } + return null; + } + + @Override + public Integer getTotalDigitsFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.TOTALDIGITS)){ + throw new UnsupportedOperationException(this.toString() + " item type does not support the total digits facet"); + } + return null; + } + + @Override + public Integer getFractionDigitsFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.FRACTIONDIGITS)){ + throw new UnsupportedOperationException(this.toString() + " item type does not support the fraction digits facet"); + } + return null; + } + + @Override + public TimezoneFacet getExplicitTimezoneFacet(){ + if(!this.getAllowedFacets().contains(FacetTypes.EXPLICITTIMEZONE)){ + throw new UnsupportedOperationException(this.toString() + " item type does not support the explicit timezone facet"); + } + return null; + } + @Override public String toString() { return this.name.toString(); diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index 27a38bcf88..58810e0405 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -139,86 +139,98 @@ public Set getAllowedFacets() { return this.primitiveType.getAllowedFacets(); } + @Override public List getEnumerationFacet(){ if(!this.getAllowedFacets().contains(FacetTypes.ENUMERATION)){ - throw new UnsupportedOperationException("this item type does not support the enumeration facet"); + throw new UnsupportedOperationException(this.toString() + " item type does not support the enumeration facet"); } return this.enumeration == null ? this.baseType.getEnumerationFacet() : this.enumeration; } + @Override public List getConstraintsFacet(){ if(!this.getAllowedFacets().contains(FacetTypes.CONSTRAINTS)){ - throw new UnsupportedOperationException("this item type does not support the constraints facet"); + throw new UnsupportedOperationException(this.toString() + " item type does not support the constraints facet"); } return ListUtils.union(this.baseType.getConstraintsFacet(), this.constraints); } + @Override public Integer getMinLengthFacet(){ if(!this.getAllowedFacets().contains(FacetTypes.MINLENGTH)){ - throw new UnsupportedOperationException("this item type does not support the minimum length facet"); + throw new UnsupportedOperationException(this.toString() + " item type does not support the minimum length facet"); } return this.minLength == null ? this.baseType.getMinLengthFacet() : this.minLength; } + @Override public Integer getLengthFacet(){ if(!this.getAllowedFacets().contains(FacetTypes.LENGTH)){ - throw new UnsupportedOperationException("this item type does not support the length facet"); + throw new UnsupportedOperationException(this.toString() + " item type does not support the length facet"); } return this.length == null ? this.baseType.getLengthFacet() : this.length; } + @Override public Integer getMaxLengthFacet(){ if(!this.getAllowedFacets().contains(FacetTypes.MAXLENGTH)){ - throw new UnsupportedOperationException("this item type does not support the maximum length facet"); + throw new UnsupportedOperationException(this.toString() + " item type does not support the maximum length facet"); } return this.maxLength == null ? this.baseType.getMaxLengthFacet() : this.maxLength; } + @Override public Item getMinExclusiveFacet(){ if(!this.getAllowedFacets().contains(FacetTypes.MINEXCLUSIVE)){ - throw new UnsupportedOperationException("this item type does not support the minimum exclusive facet"); + throw new UnsupportedOperationException(this.toString() + " item type does not support the minimum exclusive facet"); } return this.minExclusive == null ? this.baseType.getMinExclusiveFacet() : this.minExclusive; } + @Override public Item getMinInclusiveFacet(){ if(!this.getAllowedFacets().contains(FacetTypes.MININCLUSIVE)){ - throw new UnsupportedOperationException("this item type does not support the minimum inclusive facet"); + throw new UnsupportedOperationException(this.toString() + " item type does not support the minimum inclusive facet"); } return this.minInclusive == null ? this.baseType.getMinInclusiveFacet() : this.minInclusive; } + @Override public Item getMaxExclusiveFacet(){ if(!this.getAllowedFacets().contains(FacetTypes.MAXEXCLUSIVE)){ - throw new UnsupportedOperationException("this item type does not support the maximum exclusive facet"); + throw new UnsupportedOperationException(this.toString() + " item type does not support the maximum exclusive facet"); } return this.maxExclusive == null ? this.baseType.getMaxExclusiveFacet() : this.maxExclusive; } + @Override public Item getMaxInclusiveFacet(){ if(!this.getAllowedFacets().contains(FacetTypes.MAXINCLUSIVE)){ - throw new UnsupportedOperationException("this item type does not support the maximum inclusive facet"); + throw new UnsupportedOperationException(this.toString() + " item type does not support the maximum inclusive facet"); } return this.maxInclusive == null ? this.baseType.getMaxInclusiveFacet() : this.maxInclusive; } + @Override public Integer getTotalDigitsFacet(){ if(!this.getAllowedFacets().contains(FacetTypes.TOTALDIGITS)){ - throw new UnsupportedOperationException("this item type does not support the total digits facet"); + throw new UnsupportedOperationException(this.toString() + " item type does not support the total digits facet"); } return this.totalDigits == null ? this.baseType.getTotalDigitsFacet() : this.totalDigits; } + @Override public Integer getFractionDigitsFacet(){ if(!this.getAllowedFacets().contains(FacetTypes.FRACTIONDIGITS)){ - throw new UnsupportedOperationException("this item type does not support the fraction digits facet"); + throw new UnsupportedOperationException(this.toString() + " item type does not support the fraction digits facet"); } return this.fractionDigits == null ? this.baseType.getFractionDigitsFacet() : this.fractionDigits; } + @Override public TimezoneFacet getExplicitTimezoneFacet(){ if(!this.getAllowedFacets().contains(FacetTypes.EXPLICITTIMEZONE)){ - throw new UnsupportedOperationException("this item type does not support the explicit timezone facet"); + throw new UnsupportedOperationException(this.toString() + " item type does not support the explicit timezone facet"); } return this.explicitTimezone == null ? this.baseType.getExplicitTimezoneFacet() : this.explicitTimezone; } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index d3d0be7a18..0ae6e82621 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -195,7 +195,7 @@ default ItemType getBaseType(){ * @return the list of possible values for [this] item type or null if the enumeration facet is not set */ default List getEnumerationFacet(){ - return null; + throw new UnsupportedOperationException("enumeration facet is allowed only for atomic, object and array item types"); } /** @@ -203,7 +203,7 @@ default List getEnumerationFacet(){ * @return the list of constraints in the implementation-defined language for [this] item type (note that this facet is cumulative) or an empty list if the constraints facet is not set */ default List getConstraintsFacet(){ - return Collections.emptyList(); + throw new UnsupportedOperationException("constraints facet is allowed only for atomic, object and array item types"); } /** @@ -211,7 +211,7 @@ default List getConstraintsFacet(){ * @return the minimum length facet value for [this] item type or null if the restriction is not set */ default Integer getMinLengthFacet(){ - return null; + throw new UnsupportedOperationException("minimum length facet is not allowed for " + this.toString() + " item type"); } /** @@ -219,7 +219,7 @@ default Integer getMinLengthFacet(){ * @return the length facet value for [this] item type or null if the restriction is not set */ default Integer getLengthFacet(){ - return null; + throw new UnsupportedOperationException("length facet is not allowed for " + this.toString() + " item type"); } /** @@ -227,7 +227,7 @@ default Integer getLengthFacet(){ * @return the maximum length facet value for [this] item type or null if the restriction is not set */ default Integer getMaxLengthFacet(){ - return null; + throw new UnsupportedOperationException("maximum length facet is not allowed for " + this.toString() + " item type"); } /** @@ -235,7 +235,7 @@ default Integer getMaxLengthFacet(){ * @return an item representing the minimum possible value (excluded) for [this] item type or null if the restriction is not set */ default Item getMinExclusiveFacet(){ - return null; + throw new UnsupportedOperationException("minimum exclusive facet is not allowed for " + this.toString() + " item types"); } /** @@ -243,7 +243,7 @@ default Item getMinExclusiveFacet(){ * @return an item representing the minimum possible value (included) for [this] item type or null if the restriction is not set */ default Item getMinInclusiveFacet(){ - return null; + throw new UnsupportedOperationException("minimum inclusive facet is not allowed for " + this.toString() + " item types"); } /** @@ -251,7 +251,7 @@ default Item getMinInclusiveFacet(){ * @return an item representing the maximum possible value (excluded) for [this] item type or null if the restriction is not set */ default Item getMaxExclusiveFacet(){ - return null; + throw new UnsupportedOperationException("maximum exclusive facet is not allowed for " + this.toString() + " item types"); } /** @@ -259,7 +259,7 @@ default Item getMaxExclusiveFacet(){ * @return an item representing the maximum possible value (included) for [this] item type or null if the restriction is not set */ default Item getMaxInclusiveFacet(){ - return null; + throw new UnsupportedOperationException("maximum inclusive facet is not allowed for " + this.toString() + " item types"); } /** @@ -267,7 +267,7 @@ default Item getMaxInclusiveFacet(){ * @return the total digits facet value for [this] item type or null if the restriction is not set */ default Integer getTotalDigitsFacet(){ - return null; + throw new UnsupportedOperationException("total digits facet is not allowed for " + this.toString() + " item types"); } /** @@ -275,7 +275,7 @@ default Integer getTotalDigitsFacet(){ * @return the fraction digits facet value for [this] item type or null if the restriction is not set */ default Integer getFractionDigitsFacet(){ - return null; + throw new UnsupportedOperationException("fraction digits facet is not allowed for " + this.toString() + " item types"); } /** @@ -283,7 +283,7 @@ default Integer getFractionDigitsFacet(){ * @return the explicit timezone facet value for [this] item type or null if the restriction is not set */ default TimezoneFacet getExplicitTimezoneFacet(){ - return null; + throw new UnsupportedOperationException("explicit timezone facet is not allowed for " + this.toString() + " item types"); } /** @@ -299,7 +299,7 @@ default Map getContentFacet(){ * @return closed facet value for object item types */ default boolean getClosedFacet(){ - throw new UnsupportedOperationException("closed facet is allowed only for object item types"); + throw new UnsupportedOperationException("closed facet is not allowed only for object item types"); } // endregion From 36847d5d57aa3730af466d8b96e518ba3d60db78 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 22 Feb 2021 15:30:41 +0100 Subject: [PATCH 170/206] added array item type --- .../org/rumbledb/types/ArrayItemType.java | 148 ++++++++++++++++++ .../org/rumbledb/types/AtomicItemType.java | 18 +-- .../rumbledb/types/BuiltinTypesCatalogue.java | 4 +- .../java/org/rumbledb/types/ItemType.java | 15 +- .../org/rumbledb/types/ObjectItemType.java | 17 +- 5 files changed, 171 insertions(+), 31 deletions(-) create mode 100644 src/main/java/org/rumbledb/types/ArrayItemType.java diff --git a/src/main/java/org/rumbledb/types/ArrayItemType.java b/src/main/java/org/rumbledb/types/ArrayItemType.java new file mode 100644 index 0000000000..cf8f917e01 --- /dev/null +++ b/src/main/java/org/rumbledb/types/ArrayItemType.java @@ -0,0 +1,148 @@ +package org.rumbledb.types; + +import jsound.types.ArrayContentDescriptor; +import jsound.types.FieldDescriptor; +import org.apache.commons.collections.ListUtils; +import org.rumbledb.api.Item; +import org.rumbledb.context.Name; + +import java.util.*; + +public class ArrayItemType implements ItemType { + + final static ArrayItemType anyArrayItem = new ArrayItemType( + new Name(Name.JS_NS, "js", "array"), + null, + null, + null, + null, + Collections.emptyList(), + null + ); + + final static Set allowedFacets = new HashSet<>(Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.CONTENT, + FacetTypes.MINLENGTH, + FacetTypes.MAXLENGTH + )); + + final private Name name; + final private ArrayContentDescriptor content; + final private List constraints; + final private List enumeration; + final private ItemType baseType; + final private Integer minLength, maxLength; + + ArrayItemType(Name name, ItemType baseType, ArrayContentDescriptor content, Integer minLength, Integer maxLength, List constraints, List enumeration){ + this.name = name; + this.baseType = baseType; + this.content = content; + this.minLength = minLength; + this.maxLength = maxLength; + this.constraints = constraints; + this.enumeration = enumeration; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof ItemType)) { + return false; + } + return this.toString().equals(other.toString()); + } + + @Override + public boolean isArrayItemType() { + return true; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Name getName() { + // TODO : what about anonymous types + return this.name; + } + + @Override + public boolean isSubtypeOf(ItemType superType) { + return this == anyArrayItem ? superType == anyArrayItem || superType == BuiltinTypesCatalogue.JSONItem || superType == BuiltinTypesCatalogue.item : + this.equals(superType) || this.baseType.isSubtypeOf(superType); + } + + @Override + public ItemType findLeastCommonSuperTypeWith(ItemType other) { + if(this.isSubtypeOf(other)){ + return other; + } else if(other.isSubtypeOf(this)){ + return this; + } else if(this == anyArrayItem) { + // if we reach here other not object item for sure + return other.isObjectItemType() ? BuiltinTypesCatalogue.JSONItem : BuiltinTypesCatalogue.item; + } else { + return this.getBaseType().findLeastCommonSuperTypeWith(other.isPrimitive() ? other : other.getBaseType()); + } + } + + @Override + public boolean isUserDefined() { + return !(this == anyArrayItem); + } + + @Override + public boolean isPrimitive() { + return this == anyArrayItem; + } + + @Override + public ItemType getPrimitiveType() { + return anyArrayItem; + } + + @Override + public ItemType getBaseType() { + return this.baseType; + } + + @Override + public Set getAllowedFacets() { + return allowedFacets; + } + + @Override + public List getEnumerationFacet() { + return this.enumeration != null || this.isPrimitive() ? this.enumeration : this.baseType.getEnumerationFacet(); + } + + @Override + public List getConstraintsFacet() { + return this.isPrimitive() ? this.constraints : ListUtils.union(this.baseType.getConstraintsFacet(), this.constraints); + } + + @Override + public Integer getMinLengthFacet() { + return this.minLength != null || this.isPrimitive() ? this.minLength : this.baseType.getMinLengthFacet(); + } + + @Override + public Integer getMaxLengthFacet() { + return this.maxLength != null || this.isPrimitive() ? this.maxLength : this.baseType.getMaxLengthFacet(); + } + + @Override + public ArrayContentDescriptor getArrayContentFacet() { + return this.content != null || this.isPrimitive() ? this.content : this.baseType.getArrayContentFacet(); + } + + @Override + public String toString() { + // consider add content and various stuff + return this.name.toString(); + } + +} diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index a5c67f761a..9c8695d9aa 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -161,14 +161,6 @@ public class AtomicItemType implements ItemType { new Name(Name.JS_NS, "xs", "json-item"), Collections.emptySet() ); - static final AtomicItemType objectItem = new AtomicItemType( - new Name(Name.JS_NS, "js", "object"), - Collections.emptySet() - ); - static final AtomicItemType arrayItem = new AtomicItemType( - new Name(Name.JS_NS, "js", "array"), - Collections.emptySet() - ); static final AtomicItemType intItem = new AtomicItemType( Name.createVariableInDefaultTypeNamespace("int"), new HashSet<>(Arrays.asList( @@ -204,17 +196,17 @@ public boolean equals(Object other) { @Override public boolean isAtomicItemType() { - return !(this.equals(arrayItem) || this.equals(objectItem)); + return !(this.equals(JSONItem)); } @Override public boolean isObjectItemType() { - return this.equals(objectItem); + return false; } @Override public boolean isArrayItemType() { - return this.equals(arrayItem); + return false; } @Override @@ -232,9 +224,7 @@ public boolean isSubtypeOf(ItemType superType) { if (superType.equals(BuiltinTypesCatalogue.item)) { return true; } else if (superType.equals(JSONItem)) { - return this.equals(objectItem) - || this.equals(arrayItem) - || this.equals(JSONItem); + return this.equals(JSONItem); } else if (superType.equals(atomicItem)) { return this.equals(stringItem) || this.equals(integerItem) diff --git a/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java b/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java index 9a4ddac519..1f2628eaf0 100644 --- a/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java +++ b/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java @@ -26,8 +26,8 @@ public class BuiltinTypesCatalogue { public static final ItemType anyURIItem = AtomicItemType.anyURIItem; public static final ItemType base64BinaryItem = AtomicItemType.base64BinaryItem; public static final ItemType JSONItem = AtomicItemType.JSONItem; - public static final ItemType objectItem = AtomicItemType.objectItem; - public static final ItemType arrayItem = AtomicItemType.arrayItem; + public static final ItemType objectItem = ObjectItemType.anyObjectItem; + public static final ItemType arrayItem = ArrayItemType.anyArrayItem; public static final ItemType intItem = AtomicItemType.intItem; public static final ItemType anyFunctionItem = FunctionItemType.anyFunctionItem; diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 0ae6e82621..e4a6a0e316 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -21,6 +21,7 @@ package org.rumbledb.types; +import jsound.types.ArrayContentDescriptor; import jsound.types.FieldDescriptor; import org.rumbledb.api.Item; import org.rumbledb.context.Name; @@ -288,10 +289,10 @@ default TimezoneFacet getExplicitTimezoneFacet(){ /** * - * @return content facet value for object item types (cumulative) + * @return content facet value for object item types (cumulative facet) */ - default Map getContentFacet(){ - throw new UnsupportedOperationException("content facet is allowed only for object item types"); + default Map getObjectContentFacet(){ + throw new UnsupportedOperationException("object content facet is allowed only for object item types"); } /** @@ -302,6 +303,14 @@ default boolean getClosedFacet(){ throw new UnsupportedOperationException("closed facet is not allowed only for object item types"); } + /** + * + * @return content facet value for array item types + */ + default ArrayContentDescriptor getArrayContentFacet(){ + throw new UnsupportedOperationException("array content facet is allowed only for array item types"); + } + // endregion public String toString(); diff --git a/src/main/java/org/rumbledb/types/ObjectItemType.java b/src/main/java/org/rumbledb/types/ObjectItemType.java index 8291991e6a..8df4720fe1 100644 --- a/src/main/java/org/rumbledb/types/ObjectItemType.java +++ b/src/main/java/org/rumbledb/types/ObjectItemType.java @@ -2,7 +2,6 @@ import jsound.types.FieldDescriptor; import org.apache.commons.collections.ListUtils; -import org.apache.commons.collections.MapUtils; import org.rumbledb.api.Item; import org.rumbledb.context.Name; @@ -12,9 +11,9 @@ public class ObjectItemType implements ItemType { final static ObjectItemType anyObjectItem = new ObjectItemType( new Name(Name.JS_NS, "js", "object"), + null, false, Collections.emptyMap(), - null, Collections.emptyList(), null ); @@ -33,7 +32,7 @@ public class ObjectItemType implements ItemType { final private List enumeration; final private ItemType baseType; - ObjectItemType(Name name, boolean isClosed, Map content, ItemType baseType, List constraints,List enumeration){ + ObjectItemType(Name name, ItemType baseType, boolean isClosed, Map content, List constraints,List enumeration){ this.name = name; this.isClosed = isClosed; this.content = content; @@ -113,13 +112,7 @@ public Set getAllowedFacets() { @Override public List getEnumerationFacet() { - if(this.enumeration != null){ - return this.enumeration; - } else if(this.isPrimitive()){ - return null; - } else { - return baseType.getEnumerationFacet(); - } + return this.enumeration != null || this.isPrimitive() ? this.enumeration : this.baseType.getEnumerationFacet(); } @Override @@ -128,12 +121,12 @@ public List getConstraintsFacet() { } @Override - public Map getContentFacet() { + public Map getObjectContentFacet() { if(this.isPrimitive()){ return this.content; } else { // recursively get content facet, overriding new descriptors - Map map = new HashMap<>(this.baseType.getContentFacet()); + Map map = new HashMap<>(this.baseType.getObjectContentFacet()); map.putAll(this.content); return map; } From 88bb8068b152cfe44428669d6aa995150c989974 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 22 Feb 2021 15:34:39 +0100 Subject: [PATCH 171/206] removed constraints facet from array since it is not allowed --- src/main/java/org/rumbledb/types/ArrayItemType.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/org/rumbledb/types/ArrayItemType.java b/src/main/java/org/rumbledb/types/ArrayItemType.java index cf8f917e01..cd58027132 100644 --- a/src/main/java/org/rumbledb/types/ArrayItemType.java +++ b/src/main/java/org/rumbledb/types/ArrayItemType.java @@ -16,13 +16,11 @@ public class ArrayItemType implements ItemType { null, null, null, - Collections.emptyList(), null ); final static Set allowedFacets = new HashSet<>(Arrays.asList( FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, FacetTypes.CONTENT, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH @@ -30,18 +28,16 @@ public class ArrayItemType implements ItemType { final private Name name; final private ArrayContentDescriptor content; - final private List constraints; final private List enumeration; final private ItemType baseType; final private Integer minLength, maxLength; - ArrayItemType(Name name, ItemType baseType, ArrayContentDescriptor content, Integer minLength, Integer maxLength, List constraints, List enumeration){ + ArrayItemType(Name name, ItemType baseType, ArrayContentDescriptor content, Integer minLength, Integer maxLength, List enumeration){ this.name = name; this.baseType = baseType; this.content = content; this.minLength = minLength; this.maxLength = maxLength; - this.constraints = constraints; this.enumeration = enumeration; } @@ -119,11 +115,6 @@ public List getEnumerationFacet() { return this.enumeration != null || this.isPrimitive() ? this.enumeration : this.baseType.getEnumerationFacet(); } - @Override - public List getConstraintsFacet() { - return this.isPrimitive() ? this.constraints : ListUtils.union(this.baseType.getConstraintsFacet(), this.constraints); - } - @Override public Integer getMinLengthFacet() { return this.minLength != null || this.isPrimitive() ? this.minLength : this.baseType.getMinLengthFacet(); From 0acb06464cda166deea784b8891887c4bbe73e87 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 22 Feb 2021 17:15:25 +0100 Subject: [PATCH 172/206] added to dataframe function to atomic types and generic item --- .../org/rumbledb/types/AtomicItemType.java | 68 +++++++++++++------ .../rumbledb/types/DerivedAtomicItemType.java | 18 +++-- .../java/org/rumbledb/types/ItemItemType.java | 14 ++++ .../java/org/rumbledb/types/ItemType.java | 5 ++ 4 files changed, 80 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 9c8695d9aa..aa0813120c 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -1,6 +1,8 @@ package org.rumbledb.types; import org.apache.commons.collections.ListUtils; +import org.apache.spark.sql.types.DataType; +import org.apache.spark.sql.types.DataTypes; import org.rumbledb.api.Item; import org.rumbledb.context.Name; @@ -14,11 +16,13 @@ public class AtomicItemType implements ItemType { // TODO: extract array and object into its own types static final AtomicItemType atomicItem = new AtomicItemType( new Name(Name.JS_NS, "js", "atomic"), - Collections.emptySet() + Collections.emptySet(), + DataTypes.BinaryType ); static final AtomicItemType stringItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "string"), - new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) + new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)), + DataTypes.StringType ); static final AtomicItemType integerItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "integer"), @@ -31,7 +35,8 @@ public class AtomicItemType implements ItemType { FacetTypes.MAXINCLUSIVE, FacetTypes.TOTALDIGITS, FacetTypes.FRACTIONDIGITS - )) + )), + DataTypes.LongType // TODO : how to support arbitrary-sized integer ); static final AtomicItemType decimalItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "decimal"), @@ -44,7 +49,8 @@ public class AtomicItemType implements ItemType { FacetTypes.MAXINCLUSIVE, FacetTypes.TOTALDIGITS, FacetTypes.FRACTIONDIGITS - )) + )), + DataTypes.createDecimalType() ); static final AtomicItemType doubleItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "double"), @@ -55,7 +61,8 @@ public class AtomicItemType implements ItemType { FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, FacetTypes.MAXINCLUSIVE - )) + )), + DataTypes.DoubleType ); static final AtomicItemType floatItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "float"), @@ -66,15 +73,18 @@ public class AtomicItemType implements ItemType { FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, FacetTypes.MAXINCLUSIVE - )) + )), + DataTypes.FloatType ); static final AtomicItemType booleanItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "boolean"), - new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS)) + new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS)), + DataTypes.BooleanType ); static final AtomicItemType nullItem = new AtomicItemType( new Name(Name.JS_NS, "js", "null"), - Collections.emptySet() + Collections.emptySet(), + DataTypes.NullType // TODO : see appropriate type ); static final AtomicItemType durationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "duration"), @@ -85,7 +95,8 @@ public class AtomicItemType implements ItemType { FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, FacetTypes.MAXINCLUSIVE - )) + )), + DataTypes.BinaryType // TODO : appropriate datatype ); static final AtomicItemType yearMonthDurationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "yearMonthDuration"), @@ -96,7 +107,8 @@ public class AtomicItemType implements ItemType { FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, FacetTypes.MAXINCLUSIVE - )) + )), + DataTypes.BinaryType // TODO : appropriate datatype ); static final AtomicItemType dayTimeDurationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "dayTimeDuration"), @@ -107,7 +119,8 @@ public class AtomicItemType implements ItemType { FacetTypes.MAXINCLUSIVE, FacetTypes.MINEXCLUSIVE, FacetTypes.MAXINCLUSIVE - )) + )), + DataTypes.BinaryType // TODO : appropriate datatype ); static final AtomicItemType dateTimeItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "dateTime"), @@ -119,7 +132,8 @@ public class AtomicItemType implements ItemType { FacetTypes.MINEXCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.EXPLICITTIMEZONE - )) + )), + DataTypes.DateType ); static final AtomicItemType dateItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "date"), @@ -131,7 +145,8 @@ public class AtomicItemType implements ItemType { FacetTypes.MINEXCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.EXPLICITTIMEZONE - )) + )), + DataTypes.TimestampType ); static final AtomicItemType timeItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "time"), @@ -143,23 +158,28 @@ public class AtomicItemType implements ItemType { FacetTypes.MINEXCLUSIVE, FacetTypes.MAXINCLUSIVE, FacetTypes.EXPLICITTIMEZONE - )) + )), + DataTypes.TimestampType ); static final AtomicItemType hexBinaryItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "hexBinary"), - new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) + new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)), + DataTypes.BinaryType ); static final AtomicItemType anyURIItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "anyURI"), - new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) + new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)), + DataTypes.StringType ); static final AtomicItemType base64BinaryItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "base64Binary"), - new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)) + new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)), + DataTypes.BinaryType ); static final AtomicItemType JSONItem = new AtomicItemType( new Name(Name.JS_NS, "xs", "json-item"), - Collections.emptySet() + Collections.emptySet(), + DataTypes.BinaryType // TODO : consider how to deal with it ); static final AtomicItemType intItem = new AtomicItemType( Name.createVariableInDefaultTypeNamespace("int"), @@ -172,18 +192,21 @@ public class AtomicItemType implements ItemType { FacetTypes.MAXINCLUSIVE, FacetTypes.TOTALDIGITS, FacetTypes.FRACTIONDIGITS - )) + )), + DataTypes.IntegerType ); private Name name; private Set allowedFacets; + private DataType dataFrameType; public AtomicItemType() { } - private AtomicItemType(Name name, Set allowedFacets) { + private AtomicItemType(Name name, Set allowedFacets, DataType dataFrameType) { this.name = name; this.allowedFacets = allowedFacets; + this.dataFrameType = dataFrameType; } @Override @@ -452,4 +475,9 @@ public TimezoneFacet getExplicitTimezoneFacet(){ public String toString() { return this.name.toString(); } + + @Override + public DataType toDataFrameType() { + return this.dataFrameType; + } } diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index 58810e0405..064c51f0c0 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -1,11 +1,11 @@ package org.rumbledb.types; import org.apache.commons.collections.ListUtils; +import org.apache.spark.sql.types.DataType; +import org.apache.spark.sql.types.DataTypes; import org.rumbledb.api.Item; import org.rumbledb.context.Name; -import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Set; @@ -19,13 +19,14 @@ public class DerivedAtomicItemType implements ItemType { private final List constraints; private final List enumeration; private final TimezoneFacet explicitTimezone; + private final DataType dataFrameType; - DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, Facets facets){ - this(name, baseType, primitiveType, facets, true); + DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, Facets facets, DataType dataFrameType){ + this(name, baseType, primitiveType, facets, true, dataFrameType); } // TODO : turn builtin derived atomic types into this class - private DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, Facets facets, boolean isUserDefined) { + private DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, Facets facets, boolean isUserDefined, DataType dataFrameType) { // TODO : check in item factory that: name not already used or invalid, facets are correct and allowed according to baseType this.name = name; this.baseType = baseType; @@ -47,6 +48,8 @@ private DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveTy this.constraints = facets.getConstraints(); this.enumeration = facets.getEnumeration(); + + this.dataFrameType = dataFrameType; } @Override @@ -240,4 +243,9 @@ public String toString() { // TODO : Consider added facets restriction and base type return this.name.toString(); } + + @Override + public DataType toDataFrameType() { + return this.dataFrameType != null ? this.dataFrameType : this.baseType.toDataFrameType(); + } } diff --git a/src/main/java/org/rumbledb/types/ItemItemType.java b/src/main/java/org/rumbledb/types/ItemItemType.java index 7c31db3efa..6d2f6deb51 100644 --- a/src/main/java/org/rumbledb/types/ItemItemType.java +++ b/src/main/java/org/rumbledb/types/ItemItemType.java @@ -1,7 +1,11 @@ package org.rumbledb.types; +import org.apache.spark.sql.types.DataType; +import org.apache.spark.sql.types.DataTypes; import org.rumbledb.context.Name; +import java.util.Set; + /** * Class representing the generic 'item' item type */ @@ -46,8 +50,18 @@ public ItemType findLeastCommonSuperTypeWith(ItemType other) { return item; } + @Override + public Set getAllowedFacets() { + throw new UnsupportedOperationException("item type does not support facets"); + } + @Override public String toString() { return this.name.toString(); } + + @Override + public DataType toDataFrameType() { + return DataTypes.BinaryType; + } } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index e4a6a0e316..349dcecafd 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -23,6 +23,7 @@ import jsound.types.ArrayContentDescriptor; import jsound.types.FieldDescriptor; +import org.apache.spark.sql.types.DataType; import org.rumbledb.api.Item; import org.rumbledb.context.Name; @@ -314,4 +315,8 @@ default ArrayContentDescriptor getArrayContentFacet(){ // endregion public String toString(); + + default DataType toDataFrameType(){ + throw new UnsupportedOperationException("toDataFrameType method is not supported for " + this.toString() + " item types"); + } } From 275c2445102e64c1fb11e0da3ef19be433dc5139 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 23 Feb 2021 10:20:46 +0100 Subject: [PATCH 173/206] added json item type, extended base type to all and added type tree depth for fast and efficient finding of least common ancestor --- .../org/rumbledb/types/ArrayItemType.java | 17 ++--- .../org/rumbledb/types/AtomicItemType.java | 68 +++++------------ .../rumbledb/types/BuiltinTypesCatalogue.java | 2 +- .../rumbledb/types/DerivedAtomicItemType.java | 12 +-- .../org/rumbledb/types/FunctionItemType.java | 10 +++ .../java/org/rumbledb/types/ItemItemType.java | 16 ++-- .../java/org/rumbledb/types/ItemType.java | 35 ++++++--- .../java/org/rumbledb/types/JsonItemType.java | 76 +++++++++++++++++++ .../org/rumbledb/types/ObjectItemType.java | 17 ++--- 9 files changed, 159 insertions(+), 94 deletions(-) create mode 100644 src/main/java/org/rumbledb/types/JsonItemType.java diff --git a/src/main/java/org/rumbledb/types/ArrayItemType.java b/src/main/java/org/rumbledb/types/ArrayItemType.java index cd58027132..cc2aa57fe1 100644 --- a/src/main/java/org/rumbledb/types/ArrayItemType.java +++ b/src/main/java/org/rumbledb/types/ArrayItemType.java @@ -12,7 +12,7 @@ public class ArrayItemType implements ItemType { final static ArrayItemType anyArrayItem = new ArrayItemType( new Name(Name.JS_NS, "js", "array"), - null, + BuiltinTypesCatalogue.JSONItem, null, null, null, @@ -30,11 +30,13 @@ public class ArrayItemType implements ItemType { final private ArrayContentDescriptor content; final private List enumeration; final private ItemType baseType; + final private int typeTreeDepth; final private Integer minLength, maxLength; ArrayItemType(Name name, ItemType baseType, ArrayContentDescriptor content, Integer minLength, Integer maxLength, List enumeration){ this.name = name; this.baseType = baseType; + this.typeTreeDepth = baseType.getTypeTreeDepth() + 1; this.content = content; this.minLength = minLength; this.maxLength = maxLength; @@ -72,17 +74,8 @@ public boolean isSubtypeOf(ItemType superType) { } @Override - public ItemType findLeastCommonSuperTypeWith(ItemType other) { - if(this.isSubtypeOf(other)){ - return other; - } else if(other.isSubtypeOf(this)){ - return this; - } else if(this == anyArrayItem) { - // if we reach here other not object item for sure - return other.isObjectItemType() ? BuiltinTypesCatalogue.JSONItem : BuiltinTypesCatalogue.item; - } else { - return this.getBaseType().findLeastCommonSuperTypeWith(other.isPrimitive() ? other : other.getBaseType()); - } + public int getTypeTreeDepth() { + return this.typeTreeDepth; } @Override diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index aa0813120c..1013a7a563 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -176,11 +176,6 @@ public class AtomicItemType implements ItemType { new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)), DataTypes.BinaryType ); - static final AtomicItemType JSONItem = new AtomicItemType( - new Name(Name.JS_NS, "xs", "json-item"), - Collections.emptySet(), - DataTypes.BinaryType // TODO : consider how to deal with it - ); static final AtomicItemType intItem = new AtomicItemType( Name.createVariableInDefaultTypeNamespace("int"), new HashSet<>(Arrays.asList( @@ -219,17 +214,7 @@ public boolean equals(Object other) { @Override public boolean isAtomicItemType() { - return !(this.equals(JSONItem)); - } - - @Override - public boolean isObjectItemType() { - return false; - } - - @Override - public boolean isArrayItemType() { - return false; + return true; } @Override @@ -244,27 +229,8 @@ public Name getName() { @Override public boolean isSubtypeOf(ItemType superType) { - if (superType.equals(BuiltinTypesCatalogue.item)) { + if (superType == BuiltinTypesCatalogue.item || superType == atomicItem) { return true; - } else if (superType.equals(JSONItem)) { - return this.equals(JSONItem); - } else if (superType.equals(atomicItem)) { - return this.equals(stringItem) - || this.equals(integerItem) - || this.equals(decimalItem) - || this.equals(doubleItem) - || this.equals(booleanItem) - || this.equals(nullItem) - || this.equals(anyURIItem) - || this.equals(hexBinaryItem) - || this.equals(base64BinaryItem) - || this.equals(dateTimeItem) - || this.equals(dateItem) - || this.equals(timeItem) - || this.equals(durationItem) - || this.equals(yearMonthDurationItem) - || this.equals(dayTimeDurationItem) - || this.equals(atomicItem); } else if (superType.equals(durationItem)) { return this.equals(yearMonthDurationItem) || this.equals(dayTimeDurationItem) @@ -276,19 +242,27 @@ public boolean isSubtypeOf(ItemType superType) { } @Override - public ItemType findLeastCommonSuperTypeWith(ItemType other) { - if (other.isSubtypeOf(this)) { - return this; - } else if (this.isSubtypeOf(other)) { - return other; - } else if (this.isSubtypeOf(durationItem) && other.isSubtypeOf(durationItem)) { - return durationItem; - } else if (this.isSubtypeOf(atomicItem) && other.isSubtypeOf(atomicItem)) { - return atomicItem; - } else if (this.isSubtypeOf(JSONItem) && other.isSubtypeOf(JSONItem)) { - return JSONItem; + public int getTypeTreeDepth() { + if(this == atomicItem){ + return 1; + } else if (this == yearMonthDurationItem || this == dayTimeDurationItem || this == integerItem || this == intItem){ + // TODO : check once you remove derived like integer and int + return 3; } else { + return 2; + } + } + + @Override + public ItemType getBaseType() { + if(this == atomicItem){ return BuiltinTypesCatalogue.item; + } else if(this == yearMonthDurationItem || this == dayTimeDurationItem){ + return durationItem; + } else if(this == integerItem || this == intItem){ + return decimalItem; + } else { + return atomicItem; } } diff --git a/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java b/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java index 1f2628eaf0..7d42e1d955 100644 --- a/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java +++ b/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java @@ -25,7 +25,7 @@ public class BuiltinTypesCatalogue { public static final ItemType hexBinaryItem = AtomicItemType.hexBinaryItem; public static final ItemType anyURIItem = AtomicItemType.anyURIItem; public static final ItemType base64BinaryItem = AtomicItemType.base64BinaryItem; - public static final ItemType JSONItem = AtomicItemType.JSONItem; + public static final ItemType JSONItem = JsonItemType.jsonItem; public static final ItemType objectItem = ObjectItemType.anyObjectItem; public static final ItemType arrayItem = ArrayItemType.anyArrayItem; public static final ItemType intItem = AtomicItemType.intItem; diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index 064c51f0c0..5cd38cd950 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -12,6 +12,7 @@ public class DerivedAtomicItemType implements ItemType { private final ItemType baseType, primitiveType; + private final int typeTreeDepth; private final boolean isUserDefined; private final Name name; private final Item minInclusive, maxInclusive, minExclusive, maxExclusive; @@ -32,6 +33,7 @@ private DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveTy this.baseType = baseType; this.primitiveType = primitiveType; this.isUserDefined = isUserDefined; + this.typeTreeDepth = baseType.getTypeTreeDepth() + 1; this.minInclusive = facets.getMinInclusive(); this.maxInclusive = facets.getMaxInclusive(); @@ -81,14 +83,8 @@ public boolean isSubtypeOf(ItemType superType) { } @Override - public ItemType findLeastCommonSuperTypeWith(ItemType other) { - if(this.isSubtypeOf(other)){ - return other; - } else if(other.isSubtypeOf(this)){ - return this; - } else { - return this.baseType.findLeastCommonSuperTypeWith(other.isPrimitive() ? other.getBaseType() : other); - } + public int getTypeTreeDepth() { + return this.typeTreeDepth; } @Override diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index cccd2e9184..160582dba0 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -66,6 +66,16 @@ public ItemType findLeastCommonSuperTypeWith(ItemType other) { return BuiltinTypesCatalogue.item; } + @Override + public int getTypeTreeDepth() { + return this == anyFunctionItem ? 1 : 2; + } + + @Override + public ItemType getBaseType() { + return this == anyFunctionItem ? BuiltinTypesCatalogue.item : anyFunctionItem; + } + @Override public Set getAllowedFacets() { throw new UnsupportedOperationException("function item types does not support facets"); diff --git a/src/main/java/org/rumbledb/types/ItemItemType.java b/src/main/java/org/rumbledb/types/ItemItemType.java index 6d2f6deb51..99d724004c 100644 --- a/src/main/java/org/rumbledb/types/ItemItemType.java +++ b/src/main/java/org/rumbledb/types/ItemItemType.java @@ -14,11 +14,7 @@ public class ItemItemType implements ItemType { private static final long serialVersionUID = 1L; static final ItemType item = new ItemItemType(Name.createVariableInDefaultTypeNamespace("item")); - private Name name; - - public ItemItemType() { - - } + private final Name name; private ItemItemType(Name name) { this.name = name; @@ -50,6 +46,16 @@ public ItemType findLeastCommonSuperTypeWith(ItemType other) { return item; } + @Override + public int getTypeTreeDepth() { + return 0; + } + + @Override + public ItemType getBaseType() { + return null; + } + @Override public Set getAllowedFacets() { throw new UnsupportedOperationException("item type does not support facets"); diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 349dcecafd..d22eaab24e 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -129,7 +129,32 @@ default FunctionSignature getSignature() { * @return the common supertype between [this] and [other], that would be the LCA in the item type tree of [this] * and [other] */ - ItemType findLeastCommonSuperTypeWith(ItemType other); + default ItemType findLeastCommonSuperTypeWith(ItemType other){ + ItemType current = this; + while (other.getTypeTreeDepth() > current.getTypeTreeDepth()){ + other = other.getBaseType(); + } + while (other.getTypeTreeDepth() < current.getTypeTreeDepth()){ + current = current.getBaseType(); + } + while(!current.equals(other)){ + current = current.getBaseType(); + other = other.getBaseType(); + } + return current; + } + + /** + * + * @return an int representing the depth of the item type in the type tree ('item' is the root with depth 0) + */ + int getTypeTreeDepth(); + + /** + * + * @return the base type for a type, return null for the topmost item type + */ + ItemType getBaseType(); /** * Check at static time if [this] could be casted to [other] item type, requires [this] to be an atomic type @@ -178,14 +203,6 @@ default ItemType getPrimitiveType(){ throw new UnsupportedOperationException("getPrimitiveType operation is supported only for non-primitive types"); } - /** - * - * @return the base type for a user-defined type, throw an error for not user-defined types - */ - default ItemType getBaseType(){ - throw new UnsupportedOperationException("getBaseType operation is supported only for user-defined types"); - } - /** * * @return a set containing the allowed facets for restricting the type diff --git a/src/main/java/org/rumbledb/types/JsonItemType.java b/src/main/java/org/rumbledb/types/JsonItemType.java new file mode 100644 index 0000000000..5d221a4a83 --- /dev/null +++ b/src/main/java/org/rumbledb/types/JsonItemType.java @@ -0,0 +1,76 @@ +package org.rumbledb.types; + +import org.apache.spark.sql.types.DataType; +import org.apache.spark.sql.types.DataTypes; +import org.rumbledb.context.Name; + +import java.util.Set; + +/** + * Class representing the generic 'item' item type + */ +public class JsonItemType implements ItemType { + + private static final long serialVersionUID = 1L; + + // TODO : check if wrong prefix + static final ItemType jsonItem = new JsonItemType(new Name(Name.JS_NS, "xs", "json-item")); + private final Name name; + private JsonItemType(Name name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + // no need to check the class because ItemItemType is a singleton and it is only equal to its only instance + return o == jsonItem; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Name getName() { + return this.name; + } + + @Override + public boolean isSubtypeOf(ItemType superType) { + return superType == BuiltinTypesCatalogue.item || superType == jsonItem; + } + + @Override + public ItemType findLeastCommonSuperTypeWith(ItemType other) { + while (other.getTypeTreeDepth() > 1){ + other = other.getBaseType(); + } + return other == jsonItem ? jsonItem : BuiltinTypesCatalogue.item; + } + + @Override + public int getTypeTreeDepth() { + return 1; + } + + @Override + public ItemType getBaseType() { + return BuiltinTypesCatalogue.item; + } + + @Override + public Set getAllowedFacets() { + throw new UnsupportedOperationException("item type does not support facets"); + } + + @Override + public String toString() { + return this.name.toString(); + } + + @Override + public DataType toDataFrameType() { + return DataTypes.BinaryType; + } +} diff --git a/src/main/java/org/rumbledb/types/ObjectItemType.java b/src/main/java/org/rumbledb/types/ObjectItemType.java index 8df4720fe1..1ea052ba38 100644 --- a/src/main/java/org/rumbledb/types/ObjectItemType.java +++ b/src/main/java/org/rumbledb/types/ObjectItemType.java @@ -11,7 +11,7 @@ public class ObjectItemType implements ItemType { final static ObjectItemType anyObjectItem = new ObjectItemType( new Name(Name.JS_NS, "js", "object"), - null, + BuiltinTypesCatalogue.JSONItem, false, Collections.emptyMap(), Collections.emptyList(), @@ -31,12 +31,14 @@ public class ObjectItemType implements ItemType { final private List constraints; final private List enumeration; final private ItemType baseType; + final private int typeTreeDepth; ObjectItemType(Name name, ItemType baseType, boolean isClosed, Map content, List constraints,List enumeration){ this.name = name; this.isClosed = isClosed; this.content = content; this.baseType = baseType; + this.typeTreeDepth = baseType.getTypeTreeDepth() + 1; this.constraints = constraints; this.enumeration = enumeration; } @@ -72,17 +74,8 @@ public boolean isSubtypeOf(ItemType superType) { } @Override - public ItemType findLeastCommonSuperTypeWith(ItemType other) { - if(this.isSubtypeOf(other)){ - return other; - } else if(other.isSubtypeOf(this)){ - return this; - } else if(this == anyObjectItem) { - // if we reach here other not object item for sure - return other.isArrayItemType() ? BuiltinTypesCatalogue.JSONItem : BuiltinTypesCatalogue.item; - } else { - return this.getBaseType().findLeastCommonSuperTypeWith(other.isPrimitive() ? other : other.getBaseType()); - } + public int getTypeTreeDepth() { + return this.typeTreeDepth; } @Override From d8206a934dc548839b878209408f9185b94cdd20 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 23 Feb 2021 11:01:20 +0100 Subject: [PATCH 174/206] added union item type --- .../java/org/rumbledb/types/ItemType.java | 20 ++++ .../org/rumbledb/types/UnionItemType.java | 105 ++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 src/main/java/org/rumbledb/types/UnionItemType.java diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index d22eaab24e..be505b2231 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -23,6 +23,7 @@ import jsound.types.ArrayContentDescriptor; import jsound.types.FieldDescriptor; +import jsound.types.UnionContentDescriptor; import org.apache.spark.sql.types.DataType; import org.rumbledb.api.Item; import org.rumbledb.context.Name; @@ -68,6 +69,17 @@ default boolean isArrayItemType() { return false; } + /** + * @return test if [this] is a subptype of a json item type + */ + default boolean isJsonItemType() { + return this == BuiltinTypesCatalogue.JSONItem || isObjectItemType() || isArrayItemType(); + } + + default boolean isUnionType() { + return false; + } + /** * @return true it [this] is a function item type. */ @@ -329,6 +341,14 @@ default ArrayContentDescriptor getArrayContentFacet(){ throw new UnsupportedOperationException("array content facet is allowed only for array item types"); } + /** + * + * @return content facet value for union item types + */ + default UnionContentDescriptor getUnionContentFacet(){ + throw new UnsupportedOperationException("union content facet is allowed only for union item types"); + } + // endregion public String toString(); diff --git a/src/main/java/org/rumbledb/types/UnionItemType.java b/src/main/java/org/rumbledb/types/UnionItemType.java new file mode 100644 index 0000000000..6f00a546c4 --- /dev/null +++ b/src/main/java/org/rumbledb/types/UnionItemType.java @@ -0,0 +1,105 @@ +package org.rumbledb.types; + +import jsound.types.ArrayContentDescriptor; +import jsound.types.UnionContentDescriptor; +import org.apache.spark.sql.types.DataType; +import org.apache.spark.sql.types.DataTypes; +import org.rumbledb.context.Name; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public class UnionItemType implements ItemType { + + private static Set allowedFacets = new HashSet<>(Arrays.asList(FacetTypes.CONTENT)); + + private final Name name; + private final ItemType baseType; + private final int typeTreeDepth; + private final UnionContentDescriptor content; + + UnionItemType(Name name, ItemType baseType, UnionContentDescriptor content){ + this.name = name; + this.baseType = baseType; + this.typeTreeDepth = baseType.getTypeTreeDepth() + 1; + this.content = content; + } + + UnionItemType(Name name, UnionContentDescriptor content){ + this.name = name; + // TODO : check union always restriction on item + this.baseType = BuiltinTypesCatalogue.item; + this.typeTreeDepth = 1; + this.content = content; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof ItemType)) { + return false; + } + return this.toString().equals(other.toString()); + } + + @Override + public boolean isUnionType() { + return true; + } + + @Override + public boolean hasName() { + return true; + } + + @Override + public Name getName() { + return this.name; + } + + @Override + public boolean isSubtypeOf(ItemType superType) { + return this.equals(superType) || this.baseType.isSubtypeOf(superType); + } + + @Override + public int getTypeTreeDepth() { + return this.typeTreeDepth; + } + + @Override + public boolean isUserDefined() { + return true; + } + + @Override + public boolean isPrimitive() { + return false; + } + + @Override + public ItemType getPrimitiveType() { + return BuiltinTypesCatalogue.item; + } + + @Override + public Set getAllowedFacets() { + return allowedFacets; + } + + @Override + public UnionContentDescriptor getUnionContentFacet() { + return content; + } + + @Override + public String toString() { + // TODO : consider providing more info + return this.name.toString(); + } + + @Override + public DataType toDataFrameType() { + return DataTypes.BinaryType; + } +} From 258866b4f8f77cb9d2af1bc76a8656c4d02b06b9 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 23 Feb 2021 12:17:06 +0100 Subject: [PATCH 175/206] fixed missing method in union type --- src/main/java/org/rumbledb/types/UnionItemType.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/rumbledb/types/UnionItemType.java b/src/main/java/org/rumbledb/types/UnionItemType.java index 6f00a546c4..fed397e6ec 100644 --- a/src/main/java/org/rumbledb/types/UnionItemType.java +++ b/src/main/java/org/rumbledb/types/UnionItemType.java @@ -67,6 +67,11 @@ public int getTypeTreeDepth() { return this.typeTreeDepth; } + @Override + public ItemType getBaseType() { + return this.baseType; + } + @Override public boolean isUserDefined() { return true; From 738f3aa2cf097cf17092056d68ce5b7aed6d77e7 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 1 Mar 2021 15:00:58 +0100 Subject: [PATCH 176/206] corrected json item namespace --- src/main/java/org/rumbledb/types/JsonItemType.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/rumbledb/types/JsonItemType.java b/src/main/java/org/rumbledb/types/JsonItemType.java index 5d221a4a83..1eea489586 100644 --- a/src/main/java/org/rumbledb/types/JsonItemType.java +++ b/src/main/java/org/rumbledb/types/JsonItemType.java @@ -13,8 +13,7 @@ public class JsonItemType implements ItemType { private static final long serialVersionUID = 1L; - // TODO : check if wrong prefix - static final ItemType jsonItem = new JsonItemType(new Name(Name.JS_NS, "xs", "json-item")); + static final ItemType jsonItem = new JsonItemType(new Name(Name.JS_NS, "js", "json-item")); private final Name name; private JsonItemType(Name name) { this.name = name; From e69a0828ac5ff85d1ac9e6c4c4fa0d11b47aca3d Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 1 Mar 2021 15:38:22 +0100 Subject: [PATCH 177/206] compiled again by integrating what is needed so far from JSound --- .../types/ArrayContentDescriptor.java | 19 ++++++ .../org/rumbledb/types/ArrayItemType.java | 3 - .../rumbledb/types/DerivedAtomicItemType.java | 2 +- .../java/org/rumbledb/types/FacetTypes.java | 2 +- .../org/rumbledb/types/FieldDescriptor.java | 63 +++++++++++++++++++ .../java/org/rumbledb/types/ItemItemType.java | 4 +- .../java/org/rumbledb/types/ItemType.java | 4 -- .../org/rumbledb/types/ObjectItemType.java | 1 - .../org/rumbledb/types/TypeOrReference.java | 43 +++++++++++++ .../types/UnionContentDescriptor.java | 23 +++++++ .../org/rumbledb/types/UnionItemType.java | 4 +- 11 files changed, 154 insertions(+), 14 deletions(-) create mode 100644 src/main/java/org/rumbledb/types/ArrayContentDescriptor.java create mode 100644 src/main/java/org/rumbledb/types/FieldDescriptor.java create mode 100644 src/main/java/org/rumbledb/types/TypeOrReference.java create mode 100644 src/main/java/org/rumbledb/types/UnionContentDescriptor.java diff --git a/src/main/java/org/rumbledb/types/ArrayContentDescriptor.java b/src/main/java/org/rumbledb/types/ArrayContentDescriptor.java new file mode 100644 index 0000000000..935b1fd70c --- /dev/null +++ b/src/main/java/org/rumbledb/types/ArrayContentDescriptor.java @@ -0,0 +1,19 @@ +package org.rumbledb.types; + +import java.util.Map; + +public class ArrayContentDescriptor { + private final TypeOrReference type; + + public ArrayContentDescriptor(TypeOrReference type) { + this.type = type; + } + + public TypeOrReference getType() { + return this.type; + } + + public void resolveTypeDescriptors(Map populatedSchema) { + this.type.resolve(populatedSchema); + } +} diff --git a/src/main/java/org/rumbledb/types/ArrayItemType.java b/src/main/java/org/rumbledb/types/ArrayItemType.java index cc2aa57fe1..5bd5a13563 100644 --- a/src/main/java/org/rumbledb/types/ArrayItemType.java +++ b/src/main/java/org/rumbledb/types/ArrayItemType.java @@ -1,8 +1,5 @@ package org.rumbledb.types; -import jsound.types.ArrayContentDescriptor; -import jsound.types.FieldDescriptor; -import org.apache.commons.collections.ListUtils; import org.rumbledb.api.Item; import org.rumbledb.context.Name; diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index 5cd38cd950..a97ba9767f 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -115,7 +115,7 @@ public boolean canBePromotedTo(ItemType other) { @Override public boolean isUserDefined() { - return isUserDefined; + return this.isUserDefined; } @Override diff --git a/src/main/java/org/rumbledb/types/FacetTypes.java b/src/main/java/org/rumbledb/types/FacetTypes.java index 76aa5500f9..843b7e9dd5 100644 --- a/src/main/java/org/rumbledb/types/FacetTypes.java +++ b/src/main/java/org/rumbledb/types/FacetTypes.java @@ -26,6 +26,6 @@ public enum FacetTypes { } public String getTypeName() { - return facetName; + return this.facetName; } } diff --git a/src/main/java/org/rumbledb/types/FieldDescriptor.java b/src/main/java/org/rumbledb/types/FieldDescriptor.java new file mode 100644 index 0000000000..b8e4d796b0 --- /dev/null +++ b/src/main/java/org/rumbledb/types/FieldDescriptor.java @@ -0,0 +1,63 @@ +package org.rumbledb.types; + +import java.util.Map; +import org.rumbledb.api.Item; + +public class FieldDescriptor { + public String name; + private TypeOrReference type; + private boolean required = false; + private Item defaultValue = null; + private boolean unique = false; + private boolean requiredIsSet = false; + public boolean defaultIsChecked = false; + + public void setName(String name) { + this.name = name; + } + + public void setType(TypeOrReference type) { + this.type = type; + } + + public void setRequired(Boolean required) { + this.requiredIsSet = true; + this.required = required; + } + + public void setDefaultValue(Item defaultValue) { + this.defaultValue = defaultValue; + } + + public void setUnique(Boolean unique) { + this.unique = unique; + } + + public String getName() { + return this.name; + } + + public TypeOrReference getTypeOrReference() { + return this.type; + } + + public boolean isRequired() { + return this.required; + } + + public Boolean isUnique() { + return this.unique; + } + + public Item getDefaultValue() { + return this.defaultValue; + } + + public boolean requiredIsSet() { + return this.requiredIsSet; + } + + public void resolveTypeDescriptors(Map populatedSchema) { + this.type.resolve(populatedSchema); + } +} diff --git a/src/main/java/org/rumbledb/types/ItemItemType.java b/src/main/java/org/rumbledb/types/ItemItemType.java index 99d724004c..bdca71e088 100644 --- a/src/main/java/org/rumbledb/types/ItemItemType.java +++ b/src/main/java/org/rumbledb/types/ItemItemType.java @@ -14,7 +14,9 @@ public class ItemItemType implements ItemType { private static final long serialVersionUID = 1L; static final ItemType item = new ItemItemType(Name.createVariableInDefaultTypeNamespace("item")); - private final Name name; + private Name name; + + public ItemItemType(){} private ItemItemType(Name name) { this.name = name; diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index be505b2231..ddb3aefee1 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -21,15 +21,11 @@ package org.rumbledb.types; -import jsound.types.ArrayContentDescriptor; -import jsound.types.FieldDescriptor; -import jsound.types.UnionContentDescriptor; import org.apache.spark.sql.types.DataType; import org.rumbledb.api.Item; import org.rumbledb.context.Name; import java.io.Serializable; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; diff --git a/src/main/java/org/rumbledb/types/ObjectItemType.java b/src/main/java/org/rumbledb/types/ObjectItemType.java index 1ea052ba38..0560121113 100644 --- a/src/main/java/org/rumbledb/types/ObjectItemType.java +++ b/src/main/java/org/rumbledb/types/ObjectItemType.java @@ -1,6 +1,5 @@ package org.rumbledb.types; -import jsound.types.FieldDescriptor; import org.apache.commons.collections.ListUtils; import org.rumbledb.api.Item; import org.rumbledb.context.Name; diff --git a/src/main/java/org/rumbledb/types/TypeOrReference.java b/src/main/java/org/rumbledb/types/TypeOrReference.java new file mode 100644 index 0000000000..58ced1d752 --- /dev/null +++ b/src/main/java/org/rumbledb/types/TypeOrReference.java @@ -0,0 +1,43 @@ +package org.rumbledb.types; + +import org.rumbledb.exceptions.RumbleException; + +import java.util.Map; + +public class TypeOrReference { + + private ItemType type; + private String stringType; + + public TypeOrReference(ItemType type) { + this.type = type; + } + + public TypeOrReference(String stringType) { + this.stringType = stringType; + } + + public void resolve(Map populatedSchema) { + if (this.type != null) { + return; + } + this.type = populatedSchema.get(this.stringType); + if (this.type == null) + throw new RumbleException("Type " + this.stringType + " could not be resolved."); + } + + public ItemType getTypeDescriptor() { + if (this.type == null) { + throw new RumbleException("Type " + this.stringType + " was not resolved."); + } + return this.type; + } + + public String getStringType() { + return this.stringType; + } + + public ItemType getType() { + return this.type; + } +} diff --git a/src/main/java/org/rumbledb/types/UnionContentDescriptor.java b/src/main/java/org/rumbledb/types/UnionContentDescriptor.java new file mode 100644 index 0000000000..818eec0886 --- /dev/null +++ b/src/main/java/org/rumbledb/types/UnionContentDescriptor.java @@ -0,0 +1,23 @@ +package org.rumbledb.types; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class UnionContentDescriptor { + private final List types; + + public UnionContentDescriptor() { + this.types = new ArrayList<>(); + } + + public List getTypes() { + return this.types; + } + + public void resolveTypeDescriptors(Map populatedSchema) { + for (TypeOrReference type : this.types) { + type.resolve(populatedSchema); + } + } +} diff --git a/src/main/java/org/rumbledb/types/UnionItemType.java b/src/main/java/org/rumbledb/types/UnionItemType.java index fed397e6ec..823cf1dabb 100644 --- a/src/main/java/org/rumbledb/types/UnionItemType.java +++ b/src/main/java/org/rumbledb/types/UnionItemType.java @@ -1,7 +1,5 @@ package org.rumbledb.types; -import jsound.types.ArrayContentDescriptor; -import jsound.types.UnionContentDescriptor; import org.apache.spark.sql.types.DataType; import org.apache.spark.sql.types.DataTypes; import org.rumbledb.context.Name; @@ -94,7 +92,7 @@ public Set getAllowedFacets() { @Override public UnionContentDescriptor getUnionContentFacet() { - return content; + return this.content; } @Override From 431294a57619b617c863f7e9d7ca45e165578307 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 1 Mar 2021 15:57:47 +0100 Subject: [PATCH 178/206] fixed isSubtypeOf relation to account for union types --- .../org/rumbledb/types/ArrayItemType.java | 6 ----- .../org/rumbledb/types/AtomicItemType.java | 14 ----------- .../rumbledb/types/DerivedAtomicItemType.java | 5 ---- .../java/org/rumbledb/types/ItemType.java | 25 +++++++++++++++++-- .../org/rumbledb/types/ObjectItemType.java | 6 ----- .../org/rumbledb/types/UnionItemType.java | 6 ----- 6 files changed, 23 insertions(+), 39 deletions(-) diff --git a/src/main/java/org/rumbledb/types/ArrayItemType.java b/src/main/java/org/rumbledb/types/ArrayItemType.java index 5bd5a13563..76ea5def0c 100644 --- a/src/main/java/org/rumbledb/types/ArrayItemType.java +++ b/src/main/java/org/rumbledb/types/ArrayItemType.java @@ -64,12 +64,6 @@ public Name getName() { return this.name; } - @Override - public boolean isSubtypeOf(ItemType superType) { - return this == anyArrayItem ? superType == anyArrayItem || superType == BuiltinTypesCatalogue.JSONItem || superType == BuiltinTypesCatalogue.item : - this.equals(superType) || this.baseType.isSubtypeOf(superType); - } - @Override public int getTypeTreeDepth() { return this.typeTreeDepth; diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 1013a7a563..b0491d6b05 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -227,20 +227,6 @@ public Name getName() { return this.name; } - @Override - public boolean isSubtypeOf(ItemType superType) { - if (superType == BuiltinTypesCatalogue.item || superType == atomicItem) { - return true; - } else if (superType.equals(durationItem)) { - return this.equals(yearMonthDurationItem) - || this.equals(dayTimeDurationItem) - || this.equals(durationItem); - } else if (superType.equals(decimalItem)) { - return this.equals(integerItem) || this.equals(decimalItem) || this.equals(intItem); - } - return this.equals(superType); - } - @Override public int getTypeTreeDepth() { if(this == atomicItem){ diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index a97ba9767f..9dc6f5557b 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -77,11 +77,6 @@ public Name getName() { return this.name; } - @Override - public boolean isSubtypeOf(ItemType superType) { - return this.equals(superType) || this.baseType.isSubtypeOf(superType); - } - @Override public int getTypeTreeDepth() { return this.typeTreeDepth; diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index ddb3aefee1..79e6eabe8f 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -129,13 +129,34 @@ default FunctionSignature getSignature() { * @param superType another item type * @return true if [this] is a subtype of [superType], any type is considered a subtype of itself */ - boolean isSubtypeOf(ItemType superType); + default boolean isSubtypeOf(ItemType superType){ + // the default methods works fine for all non-function types + // we exploit the fact that the type system is a tree (except for union types, that needs special checks) + + // special check for unions + if(superType.isUnionType()){ + // TODO : to simplify inner classes + for(TypeOrReference typeOrReference : superType.getUnionContentFacet().getTypes()){ + if(this.isSubtypeOf(typeOrReference.getType())){ + return true; + } + } + } + + // get up the type tree and check for equality + ItemType current = this; + while(current.getTypeTreeDepth() > superType.getTypeTreeDepth()){ + current = current.getBaseType(); + } + + return current.equals(superType); + } /** * * @param other another item type * @return the common supertype between [this] and [other], that would be the LCA in the item type tree of [this] - * and [other] + * and [other] (does not take into account union types as common ancestor, but only the type tree) */ default ItemType findLeastCommonSuperTypeWith(ItemType other){ ItemType current = this; diff --git a/src/main/java/org/rumbledb/types/ObjectItemType.java b/src/main/java/org/rumbledb/types/ObjectItemType.java index 0560121113..8988559c09 100644 --- a/src/main/java/org/rumbledb/types/ObjectItemType.java +++ b/src/main/java/org/rumbledb/types/ObjectItemType.java @@ -66,12 +66,6 @@ public Name getName() { return this.name; } - @Override - public boolean isSubtypeOf(ItemType superType) { - return this == anyObjectItem ? superType == anyObjectItem || superType == BuiltinTypesCatalogue.JSONItem || superType == BuiltinTypesCatalogue.item : - this.equals(superType) || this.baseType.isSubtypeOf(superType); - } - @Override public int getTypeTreeDepth() { return this.typeTreeDepth; diff --git a/src/main/java/org/rumbledb/types/UnionItemType.java b/src/main/java/org/rumbledb/types/UnionItemType.java index 823cf1dabb..c9904deedd 100644 --- a/src/main/java/org/rumbledb/types/UnionItemType.java +++ b/src/main/java/org/rumbledb/types/UnionItemType.java @@ -26,7 +26,6 @@ public class UnionItemType implements ItemType { UnionItemType(Name name, UnionContentDescriptor content){ this.name = name; - // TODO : check union always restriction on item this.baseType = BuiltinTypesCatalogue.item; this.typeTreeDepth = 1; this.content = content; @@ -55,11 +54,6 @@ public Name getName() { return this.name; } - @Override - public boolean isSubtypeOf(ItemType superType) { - return this.equals(superType) || this.baseType.isSubtypeOf(superType); - } - @Override public int getTypeTreeDepth() { return this.typeTreeDepth; From f7c3c3a5f875291652cc41db5a126fa45dab49df Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 1 Mar 2021 16:55:08 +0100 Subject: [PATCH 179/206] corrected derived types like daytime/yearmonth durations type and restrictions on decimals --- .../org/rumbledb/types/AtomicItemType.java | 50 ++++--------------- .../rumbledb/types/BuiltinTypesCatalogue.java | 10 ++-- .../rumbledb/types/DerivedAtomicItemType.java | 44 ++++++++++++++++ src/main/java/org/rumbledb/types/Facets.java | 26 ++++++++++ 4 files changed, 88 insertions(+), 42 deletions(-) diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index b0491d6b05..6671913380 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -1,6 +1,5 @@ package org.rumbledb.types; -import org.apache.commons.collections.ListUtils; import org.apache.spark.sql.types.DataType; import org.apache.spark.sql.types.DataTypes; import org.rumbledb.api.Item; @@ -8,12 +7,13 @@ import java.util.*; - +/** + * This class describes all the primitive built-in atomic types in the JSONiq data model and the derived DayTimeDuration and YearMonthDuration item types that are derived, but whose derivation cannot be expressed through JSound facets + */ public class AtomicItemType implements ItemType { private static final long serialVersionUID = 1L; - // TODO: extract array and object into its own types static final AtomicItemType atomicItem = new AtomicItemType( new Name(Name.JS_NS, "js", "atomic"), Collections.emptySet(), @@ -24,20 +24,7 @@ public class AtomicItemType implements ItemType { new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)), DataTypes.StringType ); - static final AtomicItemType integerItem = new AtomicItemType( - new Name(Name.XS_NS, "xs", "integer"), - new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, - FacetTypes.MININCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.MINEXCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.TOTALDIGITS, - FacetTypes.FRACTIONDIGITS - )), - DataTypes.LongType // TODO : how to support arbitrary-sized integer - ); + static final AtomicItemType decimalItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "decimal"), new HashSet<>(Arrays.asList( @@ -176,20 +163,6 @@ public class AtomicItemType implements ItemType { new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)), DataTypes.BinaryType ); - static final AtomicItemType intItem = new AtomicItemType( - Name.createVariableInDefaultTypeNamespace("int"), - new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, - FacetTypes.MININCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.MINEXCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.TOTALDIGITS, - FacetTypes.FRACTIONDIGITS - )), - DataTypes.IntegerType - ); private Name name; private Set allowedFacets; @@ -231,7 +204,7 @@ public Name getName() { public int getTypeTreeDepth() { if(this == atomicItem){ return 1; - } else if (this == yearMonthDurationItem || this == dayTimeDurationItem || this == integerItem || this == intItem){ + } else if (this == yearMonthDurationItem || this == dayTimeDurationItem){ // TODO : check once you remove derived like integer and int return 3; } else { @@ -245,13 +218,16 @@ public ItemType getBaseType() { return BuiltinTypesCatalogue.item; } else if(this == yearMonthDurationItem || this == dayTimeDurationItem){ return durationItem; - } else if(this == integerItem || this == intItem){ - return decimalItem; } else { return atomicItem; } } + @Override + public boolean isPrimitive() { + return !(this == dayTimeDurationItem || this == yearMonthDurationItem); + } + @Override public boolean isStaticallyCastableAs(ItemType other) { // anything can be casted to itself @@ -312,11 +288,7 @@ public boolean isStaticallyCastableAs(ItemType other) { @Override public boolean isNumeric() { - return this.equals(intItem) - || this.equals(integerItem) - || this.equals(decimalItem) - || this.equals(doubleItem) - || this.equals(floatItem); + return this == decimalItem || this == floatItem || this == doubleItem; } @Override diff --git a/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java b/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java index 7d42e1d955..e2db12271c 100644 --- a/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java +++ b/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java @@ -10,7 +10,7 @@ public class BuiltinTypesCatalogue { public static final ItemType item = ItemItemType.item; public static final ItemType atomicItem = AtomicItemType.atomicItem; public static final ItemType stringItem = AtomicItemType.stringItem; - public static final ItemType integerItem = AtomicItemType.integerItem; + public static final ItemType integerItem = DerivedAtomicItemType.integerItem; public static final ItemType decimalItem = AtomicItemType.decimalItem; public static final ItemType doubleItem = AtomicItemType.doubleItem; public static final ItemType floatItem = AtomicItemType.floatItem; @@ -28,7 +28,9 @@ public class BuiltinTypesCatalogue { public static final ItemType JSONItem = JsonItemType.jsonItem; public static final ItemType objectItem = ObjectItemType.anyObjectItem; public static final ItemType arrayItem = ArrayItemType.anyArrayItem; - public static final ItemType intItem = AtomicItemType.intItem; + public static final ItemType longItem = DerivedAtomicItemType.longItem; + public static final ItemType intItem = DerivedAtomicItemType.intItem; + public static final ItemType shortItem = DerivedAtomicItemType.shortItem; public static final ItemType anyFunctionItem = FunctionItemType.anyFunctionItem; public static boolean typeExists(Name name) { @@ -68,7 +70,9 @@ public static boolean typeExists(Name name) { hexBinaryItem, anyURIItem, base64BinaryItem, - item + item, + longItem, + shortItem ); public static ItemType getItemTypeByName(Name name) { diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index 9dc6f5557b..4dc2443bbf 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -5,12 +5,51 @@ import org.apache.spark.sql.types.DataTypes; import org.rumbledb.api.Item; import org.rumbledb.context.Name; +import org.rumbledb.items.IntItem; +import org.rumbledb.items.IntegerItem; +import java.math.BigInteger; import java.util.List; import java.util.Set; public class DerivedAtomicItemType implements ItemType { + static final DerivedAtomicItemType integerItem = new DerivedAtomicItemType( + new Name(Name.XS_NS, "xs", "integer"), + BuiltinTypesCatalogue.decimalItem, + BuiltinTypesCatalogue.decimalItem, + Facets.getIntegerFacets(), + false, + DataTypes.createDecimalType() // TODO : how to support arbitrary-sized integer + ); + + static final DerivedAtomicItemType longItem = new DerivedAtomicItemType( + new Name(Name.XS_NS, "xs", "long"), + integerItem, + BuiltinTypesCatalogue.decimalItem, + Facets.createMinMaxFacets(new IntegerItem(new BigInteger("-9223372036854775808")), new IntegerItem(new BigInteger("9223372036854775807")), true), + false, + DataTypes.LongType // TODO : how to support arbitrary-sized integer + ); + + static final DerivedAtomicItemType intItem = new DerivedAtomicItemType( + Name.createVariableInDefaultTypeNamespace("int"), + longItem, + BuiltinTypesCatalogue.decimalItem, + Facets.createMinMaxFacets(new IntItem(-2147483648), new IntItem(2147483647), true), + false, + DataTypes.IntegerType // TODO : how to support arbitrary-sized integer + ); + + static final DerivedAtomicItemType shortItem = new DerivedAtomicItemType( + new Name(Name.XS_NS, "xs", "short"), + intItem, + BuiltinTypesCatalogue.decimalItem, + Facets.createMinMaxFacets(new IntItem(-32768), new IntItem(32767), true), + false, + DataTypes.ShortType // TODO : how to support arbitrary-sized integer + ); + private final ItemType baseType, primitiveType; private final int typeTreeDepth; private final boolean isUserDefined; @@ -67,6 +106,11 @@ public boolean isAtomicItemType() { return true; } + @Override + public boolean isNumeric() { + return this.primitiveType.isNumeric(); + } + @Override public boolean hasName() { return true; diff --git a/src/main/java/org/rumbledb/types/Facets.java b/src/main/java/org/rumbledb/types/Facets.java index fae46676f0..f22b5b82fc 100644 --- a/src/main/java/org/rumbledb/types/Facets.java +++ b/src/main/java/org/rumbledb/types/Facets.java @@ -9,12 +9,38 @@ * Facets class represent a container with the ability to get and set facets and is intended to be a mutable proxy that will be passed to a DerivedAtomicType to indicate the specified facets */ public class Facets { + + /** + * @return Facets for the integer derived type + */ + public static Facets getIntegerFacets() { + Facets facets = new Facets(); + facets.setFractionDigits(0); + return facets; + } + + public static Facets createMinMaxFacets(Item min, Item max, boolean isInclusive){ + Facets facets = new Facets(); + if(isInclusive){ + facets.setMinInclusive(min); + facets.setMaxInclusive(max); + } else { + facets.setMinExclusive(min); + facets.setMaxExclusive(max); + } + return facets; + } + private Item minInclusive, maxInclusive, minExclusive, maxExclusive; private Integer minLength, length, maxLength, totalDigits, fractionDigits; private List constraints = Collections.emptyList(); private List enumeration; private TimezoneFacet explicitTimezone; + public Facets(){ + + } + public Item getMinInclusive() { return this.minInclusive; } From 8941f6081414b8c168ea81154b2a69ec033de078 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Mon, 1 Mar 2021 16:55:58 +0100 Subject: [PATCH 180/206] spotless --- .../rumbledb/compiler/InferTypeVisitor.java | 4 +- .../org/rumbledb/types/ArrayItemType.java | 23 +- .../org/rumbledb/types/AtomicItemType.java | 315 +++++++++++------- .../rumbledb/types/DerivedAtomicItemType.java | 119 ++++--- src/main/java/org/rumbledb/types/Facets.java | 9 +- .../java/org/rumbledb/types/ItemItemType.java | 3 +- .../java/org/rumbledb/types/ItemType.java | 123 ++++--- .../org/rumbledb/types/ItemTypeFactory.java | 2 +- .../java/org/rumbledb/types/JsonItemType.java | 3 +- .../org/rumbledb/types/ObjectItemType.java | 29 +- .../org/rumbledb/types/UnionItemType.java | 4 +- 11 files changed, 399 insertions(+), 235 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 9bbfd2aef8..5763ac89eb 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -331,7 +331,9 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static if (expression.isPartialApplication()) { FunctionSignature partialSignature = new FunctionSignature(partialParams, signature.getReturnType()); - expression.setInferredSequenceType(new SequenceType(ItemTypeFactory.createFunctionItemType(partialSignature))); + expression.setInferredSequenceType( + new SequenceType(ItemTypeFactory.createFunctionItemType(partialSignature)) + ); } else { SequenceType returnType = signature.getReturnType(); if (returnType == null) { diff --git a/src/main/java/org/rumbledb/types/ArrayItemType.java b/src/main/java/org/rumbledb/types/ArrayItemType.java index 76ea5def0c..5bb756190b 100644 --- a/src/main/java/org/rumbledb/types/ArrayItemType.java +++ b/src/main/java/org/rumbledb/types/ArrayItemType.java @@ -16,12 +16,14 @@ public class ArrayItemType implements ItemType { null ); - final static Set allowedFacets = new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONTENT, - FacetTypes.MINLENGTH, - FacetTypes.MAXLENGTH - )); + final static Set allowedFacets = new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONTENT, + FacetTypes.MINLENGTH, + FacetTypes.MAXLENGTH + ) + ); final private Name name; final private ArrayContentDescriptor content; @@ -30,7 +32,14 @@ public class ArrayItemType implements ItemType { final private int typeTreeDepth; final private Integer minLength, maxLength; - ArrayItemType(Name name, ItemType baseType, ArrayContentDescriptor content, Integer minLength, Integer maxLength, List enumeration){ + ArrayItemType( + Name name, + ItemType baseType, + ArrayContentDescriptor content, + Integer minLength, + Integer maxLength, + List enumeration + ) { this.name = name; this.baseType = baseType; this.typeTreeDepth = baseType.getTypeTreeDepth() + 1; diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 6671913380..913aff870c 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -8,7 +8,8 @@ import java.util.*; /** - * This class describes all the primitive built-in atomic types in the JSONiq data model and the derived DayTimeDuration and YearMonthDuration item types that are derived, but whose derivation cannot be expressed through JSound facets + * This class describes all the primitive built-in atomic types in the JSONiq data model and the derived DayTimeDuration + * and YearMonthDuration item types that are derived, but whose derivation cannot be expressed through JSound facets */ public class AtomicItemType implements ItemType { @@ -21,46 +22,60 @@ public class AtomicItemType implements ItemType { ); static final AtomicItemType stringItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "string"), - new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.LENGTH, + FacetTypes.MINLENGTH, + FacetTypes.MAXLENGTH + ) + ), DataTypes.StringType ); static final AtomicItemType decimalItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "decimal"), - new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, - FacetTypes.MININCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.MINEXCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.TOTALDIGITS, - FacetTypes.FRACTIONDIGITS - )), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.TOTALDIGITS, + FacetTypes.FRACTIONDIGITS + ) + ), DataTypes.createDecimalType() ); static final AtomicItemType doubleItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "double"), - new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, - FacetTypes.MININCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.MINEXCLUSIVE, - FacetTypes.MAXINCLUSIVE - )), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE + ) + ), DataTypes.DoubleType ); static final AtomicItemType floatItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "float"), - new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, - FacetTypes.MININCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.MINEXCLUSIVE, - FacetTypes.MAXINCLUSIVE - )), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE + ) + ), DataTypes.FloatType ); static final AtomicItemType booleanItem = new AtomicItemType( @@ -75,92 +90,128 @@ public class AtomicItemType implements ItemType { ); static final AtomicItemType durationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "duration"), - new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, - FacetTypes.MININCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.MINEXCLUSIVE, - FacetTypes.MAXINCLUSIVE - )), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE + ) + ), DataTypes.BinaryType // TODO : appropriate datatype ); static final AtomicItemType yearMonthDurationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "yearMonthDuration"), - new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, - FacetTypes.MININCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.MINEXCLUSIVE, - FacetTypes.MAXINCLUSIVE - )), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE + ) + ), DataTypes.BinaryType // TODO : appropriate datatype ); static final AtomicItemType dayTimeDurationItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "dayTimeDuration"), - new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, - FacetTypes.MININCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.MINEXCLUSIVE, - FacetTypes.MAXINCLUSIVE - )), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE + ) + ), DataTypes.BinaryType // TODO : appropriate datatype ); static final AtomicItemType dateTimeItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "dateTime"), - new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, - FacetTypes.MININCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.MINEXCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.EXPLICITTIMEZONE - )), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.EXPLICITTIMEZONE + ) + ), DataTypes.DateType ); static final AtomicItemType dateItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "date"), - new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, - FacetTypes.MININCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.MINEXCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.EXPLICITTIMEZONE - )), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.EXPLICITTIMEZONE + ) + ), DataTypes.TimestampType ); static final AtomicItemType timeItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "time"), - new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, - FacetTypes.MININCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.MINEXCLUSIVE, - FacetTypes.MAXINCLUSIVE, - FacetTypes.EXPLICITTIMEZONE - )), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.MININCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.MINEXCLUSIVE, + FacetTypes.MAXINCLUSIVE, + FacetTypes.EXPLICITTIMEZONE + ) + ), DataTypes.TimestampType ); static final AtomicItemType hexBinaryItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "hexBinary"), - new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.LENGTH, + FacetTypes.MINLENGTH, + FacetTypes.MAXLENGTH + ) + ), DataTypes.BinaryType ); static final AtomicItemType anyURIItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "anyURI"), - new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.LENGTH, + FacetTypes.MINLENGTH, + FacetTypes.MAXLENGTH + ) + ), DataTypes.StringType ); static final AtomicItemType base64BinaryItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "base64Binary"), - new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS, FacetTypes.LENGTH, FacetTypes.MINLENGTH, FacetTypes.MAXLENGTH)), + new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.LENGTH, + FacetTypes.MINLENGTH, + FacetTypes.MAXLENGTH + ) + ), DataTypes.BinaryType ); @@ -202,9 +253,9 @@ public Name getName() { @Override public int getTypeTreeDepth() { - if(this == atomicItem){ + if (this == atomicItem) { return 1; - } else if (this == yearMonthDurationItem || this == dayTimeDurationItem){ + } else if (this == yearMonthDurationItem || this == dayTimeDurationItem) { // TODO : check once you remove derived like integer and int return 3; } else { @@ -214,9 +265,9 @@ public int getTypeTreeDepth() { @Override public ItemType getBaseType() { - if(this == atomicItem){ + if (this == atomicItem) { return BuiltinTypesCatalogue.item; - } else if(this == yearMonthDurationItem || this == dayTimeDurationItem){ + } else if (this == yearMonthDurationItem || this == dayTimeDurationItem) { return durationItem; } else { return atomicItem; @@ -308,97 +359,119 @@ public Set getAllowedFacets() { } @Override - public List getEnumerationFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.ENUMERATION)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the enumeration facet"); + public List getEnumerationFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.ENUMERATION)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the enumeration facet" + ); } return null; } @Override - public List getConstraintsFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.CONSTRAINTS)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the constraints facet"); + public List getConstraintsFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.CONSTRAINTS)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the constraints facet" + ); } return Collections.emptyList(); } @Override - public Integer getMinLengthFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.MINLENGTH)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the minimum length facet"); + public Integer getMinLengthFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.MINLENGTH)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the minimum length facet" + ); } return null; } @Override - public Integer getLengthFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.LENGTH)){ + public Integer getLengthFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.LENGTH)) { throw new UnsupportedOperationException(this.toString() + " item type does not support the length facet"); } return null; } @Override - public Integer getMaxLengthFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.MAXLENGTH)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the maximum length facet"); + public Integer getMaxLengthFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.MAXLENGTH)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the maximum length facet" + ); } return null; } @Override - public Item getMinExclusiveFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.MINEXCLUSIVE)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the minimum exclusive facet"); + public Item getMinExclusiveFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.MINEXCLUSIVE)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the minimum exclusive facet" + ); } return null; } @Override - public Item getMinInclusiveFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.MININCLUSIVE)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the minimum inclusive facet"); + public Item getMinInclusiveFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.MININCLUSIVE)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the minimum inclusive facet" + ); } return null; } @Override - public Item getMaxExclusiveFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.MAXEXCLUSIVE)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the maximum exclusive facet"); + public Item getMaxExclusiveFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.MAXEXCLUSIVE)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the maximum exclusive facet" + ); } return null; } @Override - public Item getMaxInclusiveFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.MAXINCLUSIVE)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the maximum inclusive facet"); + public Item getMaxInclusiveFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.MAXINCLUSIVE)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the maximum inclusive facet" + ); } return null; } @Override - public Integer getTotalDigitsFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.TOTALDIGITS)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the total digits facet"); + public Integer getTotalDigitsFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.TOTALDIGITS)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the total digits facet" + ); } return null; } @Override - public Integer getFractionDigitsFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.FRACTIONDIGITS)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the fraction digits facet"); + public Integer getFractionDigitsFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.FRACTIONDIGITS)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the fraction digits facet" + ); } return null; } @Override - public TimezoneFacet getExplicitTimezoneFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.EXPLICITTIMEZONE)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the explicit timezone facet"); + public TimezoneFacet getExplicitTimezoneFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.EXPLICITTIMEZONE)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the explicit timezone facet" + ); } return null; } diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index 4dc2443bbf..e2d14fb92d 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -27,7 +27,11 @@ public class DerivedAtomicItemType implements ItemType { new Name(Name.XS_NS, "xs", "long"), integerItem, BuiltinTypesCatalogue.decimalItem, - Facets.createMinMaxFacets(new IntegerItem(new BigInteger("-9223372036854775808")), new IntegerItem(new BigInteger("9223372036854775807")), true), + Facets.createMinMaxFacets( + new IntegerItem(new BigInteger("-9223372036854775808")), + new IntegerItem(new BigInteger("9223372036854775807")), + true + ), false, DataTypes.LongType // TODO : how to support arbitrary-sized integer ); @@ -61,13 +65,21 @@ public class DerivedAtomicItemType implements ItemType { private final TimezoneFacet explicitTimezone; private final DataType dataFrameType; - DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, Facets facets, DataType dataFrameType){ + DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, Facets facets, DataType dataFrameType) { this(name, baseType, primitiveType, facets, true, dataFrameType); } // TODO : turn builtin derived atomic types into this class - private DerivedAtomicItemType(Name name, ItemType baseType, ItemType primitiveType, Facets facets, boolean isUserDefined, DataType dataFrameType) { - // TODO : check in item factory that: name not already used or invalid, facets are correct and allowed according to baseType + private DerivedAtomicItemType( + Name name, + ItemType baseType, + ItemType primitiveType, + Facets facets, + boolean isUserDefined, + DataType dataFrameType + ) { + // TODO : check in item factory that: name not already used or invalid, facets are correct and allowed according + // to baseType this.name = name; this.baseType = baseType; this.primitiveType = primitiveType; @@ -130,11 +142,11 @@ public int getTypeTreeDepth() { public boolean isStaticallyCastableAs(ItemType other) { // TODO: what about further restrictions like string without num from int? ItemType castFrom = this.baseType; - while(castFrom.isUserDefined()){ + while (castFrom.isUserDefined()) { castFrom = castFrom.getBaseType(); } ItemType castTo = other; - while (castTo.isUserDefined()){ + while (castTo.isUserDefined()) { castTo = castTo.getBaseType(); } return castFrom.isStaticallyCastableAs(castTo); @@ -144,7 +156,8 @@ public boolean isStaticallyCastableAs(ItemType other) { public boolean canBePromotedTo(ItemType other) { // TODO : how about restriction types if (other.equals(BuiltinTypesCatalogue.stringItem)) { - return this.isSubtypeOf(BuiltinTypesCatalogue.stringItem) || this.isSubtypeOf(BuiltinTypesCatalogue.anyURIItem); + return this.isSubtypeOf(BuiltinTypesCatalogue.stringItem) + || this.isSubtypeOf(BuiltinTypesCatalogue.anyURIItem); } if (other.equals(BuiltinTypesCatalogue.doubleItem)) { return this.isNumeric(); @@ -178,97 +191,119 @@ public Set getAllowedFacets() { } @Override - public List getEnumerationFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.ENUMERATION)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the enumeration facet"); + public List getEnumerationFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.ENUMERATION)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the enumeration facet" + ); } return this.enumeration == null ? this.baseType.getEnumerationFacet() : this.enumeration; } @Override - public List getConstraintsFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.CONSTRAINTS)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the constraints facet"); + public List getConstraintsFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.CONSTRAINTS)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the constraints facet" + ); } return ListUtils.union(this.baseType.getConstraintsFacet(), this.constraints); } @Override - public Integer getMinLengthFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.MINLENGTH)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the minimum length facet"); + public Integer getMinLengthFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.MINLENGTH)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the minimum length facet" + ); } return this.minLength == null ? this.baseType.getMinLengthFacet() : this.minLength; } @Override - public Integer getLengthFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.LENGTH)){ + public Integer getLengthFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.LENGTH)) { throw new UnsupportedOperationException(this.toString() + " item type does not support the length facet"); } return this.length == null ? this.baseType.getLengthFacet() : this.length; } @Override - public Integer getMaxLengthFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.MAXLENGTH)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the maximum length facet"); + public Integer getMaxLengthFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.MAXLENGTH)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the maximum length facet" + ); } return this.maxLength == null ? this.baseType.getMaxLengthFacet() : this.maxLength; } @Override - public Item getMinExclusiveFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.MINEXCLUSIVE)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the minimum exclusive facet"); + public Item getMinExclusiveFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.MINEXCLUSIVE)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the minimum exclusive facet" + ); } return this.minExclusive == null ? this.baseType.getMinExclusiveFacet() : this.minExclusive; } @Override - public Item getMinInclusiveFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.MININCLUSIVE)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the minimum inclusive facet"); + public Item getMinInclusiveFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.MININCLUSIVE)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the minimum inclusive facet" + ); } return this.minInclusive == null ? this.baseType.getMinInclusiveFacet() : this.minInclusive; } @Override - public Item getMaxExclusiveFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.MAXEXCLUSIVE)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the maximum exclusive facet"); + public Item getMaxExclusiveFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.MAXEXCLUSIVE)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the maximum exclusive facet" + ); } return this.maxExclusive == null ? this.baseType.getMaxExclusiveFacet() : this.maxExclusive; } @Override - public Item getMaxInclusiveFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.MAXINCLUSIVE)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the maximum inclusive facet"); + public Item getMaxInclusiveFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.MAXINCLUSIVE)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the maximum inclusive facet" + ); } return this.maxInclusive == null ? this.baseType.getMaxInclusiveFacet() : this.maxInclusive; } @Override - public Integer getTotalDigitsFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.TOTALDIGITS)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the total digits facet"); + public Integer getTotalDigitsFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.TOTALDIGITS)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the total digits facet" + ); } return this.totalDigits == null ? this.baseType.getTotalDigitsFacet() : this.totalDigits; } @Override - public Integer getFractionDigitsFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.FRACTIONDIGITS)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the fraction digits facet"); + public Integer getFractionDigitsFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.FRACTIONDIGITS)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the fraction digits facet" + ); } return this.fractionDigits == null ? this.baseType.getFractionDigitsFacet() : this.fractionDigits; } @Override - public TimezoneFacet getExplicitTimezoneFacet(){ - if(!this.getAllowedFacets().contains(FacetTypes.EXPLICITTIMEZONE)){ - throw new UnsupportedOperationException(this.toString() + " item type does not support the explicit timezone facet"); + public TimezoneFacet getExplicitTimezoneFacet() { + if (!this.getAllowedFacets().contains(FacetTypes.EXPLICITTIMEZONE)) { + throw new UnsupportedOperationException( + this.toString() + " item type does not support the explicit timezone facet" + ); } return this.explicitTimezone == null ? this.baseType.getExplicitTimezoneFacet() : this.explicitTimezone; } diff --git a/src/main/java/org/rumbledb/types/Facets.java b/src/main/java/org/rumbledb/types/Facets.java index f22b5b82fc..964e092e2c 100644 --- a/src/main/java/org/rumbledb/types/Facets.java +++ b/src/main/java/org/rumbledb/types/Facets.java @@ -6,7 +6,8 @@ import java.util.List; /** - * Facets class represent a container with the ability to get and set facets and is intended to be a mutable proxy that will be passed to a DerivedAtomicType to indicate the specified facets + * Facets class represent a container with the ability to get and set facets and is intended to be a mutable proxy that + * will be passed to a DerivedAtomicType to indicate the specified facets */ public class Facets { @@ -19,9 +20,9 @@ public static Facets getIntegerFacets() { return facets; } - public static Facets createMinMaxFacets(Item min, Item max, boolean isInclusive){ + public static Facets createMinMaxFacets(Item min, Item max, boolean isInclusive) { Facets facets = new Facets(); - if(isInclusive){ + if (isInclusive) { facets.setMinInclusive(min); facets.setMaxInclusive(max); } else { @@ -37,7 +38,7 @@ public static Facets createMinMaxFacets(Item min, Item max, boolean isInclusive) private List enumeration; private TimezoneFacet explicitTimezone; - public Facets(){ + public Facets() { } diff --git a/src/main/java/org/rumbledb/types/ItemItemType.java b/src/main/java/org/rumbledb/types/ItemItemType.java index bdca71e088..9fe4502706 100644 --- a/src/main/java/org/rumbledb/types/ItemItemType.java +++ b/src/main/java/org/rumbledb/types/ItemItemType.java @@ -16,7 +16,8 @@ public class ItemItemType implements ItemType { static final ItemType item = new ItemItemType(Name.createVariableInDefaultTypeNamespace("item")); private Name name; - public ItemItemType(){} + public ItemItemType() { + } private ItemItemType(Name name) { this.name = name; diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 79e6eabe8f..99d019f24c 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -129,15 +129,15 @@ default FunctionSignature getSignature() { * @param superType another item type * @return true if [this] is a subtype of [superType], any type is considered a subtype of itself */ - default boolean isSubtypeOf(ItemType superType){ + default boolean isSubtypeOf(ItemType superType) { // the default methods works fine for all non-function types // we exploit the fact that the type system is a tree (except for union types, that needs special checks) // special check for unions - if(superType.isUnionType()){ + if (superType.isUnionType()) { // TODO : to simplify inner classes - for(TypeOrReference typeOrReference : superType.getUnionContentFacet().getTypes()){ - if(this.isSubtypeOf(typeOrReference.getType())){ + for (TypeOrReference typeOrReference : superType.getUnionContentFacet().getTypes()) { + if (this.isSubtypeOf(typeOrReference.getType())) { return true; } } @@ -145,7 +145,7 @@ default boolean isSubtypeOf(ItemType superType){ // get up the type tree and check for equality ItemType current = this; - while(current.getTypeTreeDepth() > superType.getTypeTreeDepth()){ + while (current.getTypeTreeDepth() > superType.getTypeTreeDepth()) { current = current.getBaseType(); } @@ -158,15 +158,15 @@ default boolean isSubtypeOf(ItemType superType){ * @return the common supertype between [this] and [other], that would be the LCA in the item type tree of [this] * and [other] (does not take into account union types as common ancestor, but only the type tree) */ - default ItemType findLeastCommonSuperTypeWith(ItemType other){ + default ItemType findLeastCommonSuperTypeWith(ItemType other) { ItemType current = this; - while (other.getTypeTreeDepth() > current.getTypeTreeDepth()){ + while (other.getTypeTreeDepth() > current.getTypeTreeDepth()) { other = other.getBaseType(); } - while (other.getTypeTreeDepth() < current.getTypeTreeDepth()){ + while (other.getTypeTreeDepth() < current.getTypeTreeDepth()) { current = current.getBaseType(); } - while(!current.equals(other)){ + while (!current.equals(other)) { current = current.getBaseType(); other = other.getBaseType(); } @@ -214,7 +214,7 @@ default boolean canBePromotedTo(ItemType itemType) { * * @return [true] if it is a user-defined type, false otherwise */ - default boolean isUserDefined(){ + default boolean isUserDefined() { return false; } @@ -222,13 +222,15 @@ default boolean isUserDefined(){ * * @return [true] if it is a primitive type */ - default boolean isPrimitive() { return true; } + default boolean isPrimitive() { + return true; + } /** * * @return the primitive type for a derived type, throw an error for primitive types */ - default ItemType getPrimitiveType(){ + default ItemType getPrimitiveType() { throw new UnsupportedOperationException("getPrimitiveType operation is supported only for non-primitive types"); } @@ -242,31 +244,38 @@ default ItemType getPrimitiveType(){ * * @return the list of possible values for [this] item type or null if the enumeration facet is not set */ - default List getEnumerationFacet(){ - throw new UnsupportedOperationException("enumeration facet is allowed only for atomic, object and array item types"); + default List getEnumerationFacet() { + throw new UnsupportedOperationException( + "enumeration facet is allowed only for atomic, object and array item types" + ); } /** * - * @return the list of constraints in the implementation-defined language for [this] item type (note that this facet is cumulative) or an empty list if the constraints facet is not set + * @return the list of constraints in the implementation-defined language for [this] item type (note that this facet + * is cumulative) or an empty list if the constraints facet is not set */ - default List getConstraintsFacet(){ - throw new UnsupportedOperationException("constraints facet is allowed only for atomic, object and array item types"); + default List getConstraintsFacet() { + throw new UnsupportedOperationException( + "constraints facet is allowed only for atomic, object and array item types" + ); } /** * * @return the minimum length facet value for [this] item type or null if the restriction is not set */ - default Integer getMinLengthFacet(){ - throw new UnsupportedOperationException("minimum length facet is not allowed for " + this.toString() + " item type"); + default Integer getMinLengthFacet() { + throw new UnsupportedOperationException( + "minimum length facet is not allowed for " + this.toString() + " item type" + ); } /** * * @return the length facet value for [this] item type or null if the restriction is not set */ - default Integer getLengthFacet(){ + default Integer getLengthFacet() { throw new UnsupportedOperationException("length facet is not allowed for " + this.toString() + " item type"); } @@ -274,71 +283,91 @@ default Integer getLengthFacet(){ * * @return the maximum length facet value for [this] item type or null if the restriction is not set */ - default Integer getMaxLengthFacet(){ - throw new UnsupportedOperationException("maximum length facet is not allowed for " + this.toString() + " item type"); + default Integer getMaxLengthFacet() { + throw new UnsupportedOperationException( + "maximum length facet is not allowed for " + this.toString() + " item type" + ); } /** * - * @return an item representing the minimum possible value (excluded) for [this] item type or null if the restriction is not set + * @return an item representing the minimum possible value (excluded) for [this] item type or null if the + * restriction is not set */ - default Item getMinExclusiveFacet(){ - throw new UnsupportedOperationException("minimum exclusive facet is not allowed for " + this.toString() + " item types"); + default Item getMinExclusiveFacet() { + throw new UnsupportedOperationException( + "minimum exclusive facet is not allowed for " + this.toString() + " item types" + ); } /** * - * @return an item representing the minimum possible value (included) for [this] item type or null if the restriction is not set + * @return an item representing the minimum possible value (included) for [this] item type or null if the + * restriction is not set */ - default Item getMinInclusiveFacet(){ - throw new UnsupportedOperationException("minimum inclusive facet is not allowed for " + this.toString() + " item types"); + default Item getMinInclusiveFacet() { + throw new UnsupportedOperationException( + "minimum inclusive facet is not allowed for " + this.toString() + " item types" + ); } /** * - * @return an item representing the maximum possible value (excluded) for [this] item type or null if the restriction is not set + * @return an item representing the maximum possible value (excluded) for [this] item type or null if the + * restriction is not set */ - default Item getMaxExclusiveFacet(){ - throw new UnsupportedOperationException("maximum exclusive facet is not allowed for " + this.toString() + " item types"); + default Item getMaxExclusiveFacet() { + throw new UnsupportedOperationException( + "maximum exclusive facet is not allowed for " + this.toString() + " item types" + ); } /** * - * @return an item representing the maximum possible value (included) for [this] item type or null if the restriction is not set + * @return an item representing the maximum possible value (included) for [this] item type or null if the + * restriction is not set */ - default Item getMaxInclusiveFacet(){ - throw new UnsupportedOperationException("maximum inclusive facet is not allowed for " + this.toString() + " item types"); + default Item getMaxInclusiveFacet() { + throw new UnsupportedOperationException( + "maximum inclusive facet is not allowed for " + this.toString() + " item types" + ); } /** * * @return the total digits facet value for [this] item type or null if the restriction is not set */ - default Integer getTotalDigitsFacet(){ - throw new UnsupportedOperationException("total digits facet is not allowed for " + this.toString() + " item types"); + default Integer getTotalDigitsFacet() { + throw new UnsupportedOperationException( + "total digits facet is not allowed for " + this.toString() + " item types" + ); } /** * * @return the fraction digits facet value for [this] item type or null if the restriction is not set */ - default Integer getFractionDigitsFacet(){ - throw new UnsupportedOperationException("fraction digits facet is not allowed for " + this.toString() + " item types"); + default Integer getFractionDigitsFacet() { + throw new UnsupportedOperationException( + "fraction digits facet is not allowed for " + this.toString() + " item types" + ); } /** * * @return the explicit timezone facet value for [this] item type or null if the restriction is not set */ - default TimezoneFacet getExplicitTimezoneFacet(){ - throw new UnsupportedOperationException("explicit timezone facet is not allowed for " + this.toString() + " item types"); + default TimezoneFacet getExplicitTimezoneFacet() { + throw new UnsupportedOperationException( + "explicit timezone facet is not allowed for " + this.toString() + " item types" + ); } /** * * @return content facet value for object item types (cumulative facet) */ - default Map getObjectContentFacet(){ + default Map getObjectContentFacet() { throw new UnsupportedOperationException("object content facet is allowed only for object item types"); } @@ -346,7 +375,7 @@ default Map getObjectContentFacet(){ * * @return closed facet value for object item types */ - default boolean getClosedFacet(){ + default boolean getClosedFacet() { throw new UnsupportedOperationException("closed facet is not allowed only for object item types"); } @@ -354,7 +383,7 @@ default boolean getClosedFacet(){ * * @return content facet value for array item types */ - default ArrayContentDescriptor getArrayContentFacet(){ + default ArrayContentDescriptor getArrayContentFacet() { throw new UnsupportedOperationException("array content facet is allowed only for array item types"); } @@ -362,7 +391,7 @@ default ArrayContentDescriptor getArrayContentFacet(){ * * @return content facet value for union item types */ - default UnionContentDescriptor getUnionContentFacet(){ + default UnionContentDescriptor getUnionContentFacet() { throw new UnsupportedOperationException("union content facet is allowed only for union item types"); } @@ -370,7 +399,9 @@ default UnionContentDescriptor getUnionContentFacet(){ public String toString(); - default DataType toDataFrameType(){ - throw new UnsupportedOperationException("toDataFrameType method is not supported for " + this.toString() + " item types"); + default DataType toDataFrameType() { + throw new UnsupportedOperationException( + "toDataFrameType method is not supported for " + this.toString() + " item types" + ); } } diff --git a/src/main/java/org/rumbledb/types/ItemTypeFactory.java b/src/main/java/org/rumbledb/types/ItemTypeFactory.java index c9ecfb4d6b..7a1a8fb80c 100644 --- a/src/main/java/org/rumbledb/types/ItemTypeFactory.java +++ b/src/main/java/org/rumbledb/types/ItemTypeFactory.java @@ -1,7 +1,7 @@ package org.rumbledb.types; public class ItemTypeFactory { - public static FunctionItemType createFunctionItemType(FunctionSignature signature){ + public static FunctionItemType createFunctionItemType(FunctionSignature signature) { return new FunctionItemType(signature); } } diff --git a/src/main/java/org/rumbledb/types/JsonItemType.java b/src/main/java/org/rumbledb/types/JsonItemType.java index 1eea489586..77cc7c926d 100644 --- a/src/main/java/org/rumbledb/types/JsonItemType.java +++ b/src/main/java/org/rumbledb/types/JsonItemType.java @@ -15,6 +15,7 @@ public class JsonItemType implements ItemType { static final ItemType jsonItem = new JsonItemType(new Name(Name.JS_NS, "js", "json-item")); private final Name name; + private JsonItemType(Name name) { this.name = name; } @@ -42,7 +43,7 @@ public boolean isSubtypeOf(ItemType superType) { @Override public ItemType findLeastCommonSuperTypeWith(ItemType other) { - while (other.getTypeTreeDepth() > 1){ + while (other.getTypeTreeDepth() > 1) { other = other.getBaseType(); } return other == jsonItem ? jsonItem : BuiltinTypesCatalogue.item; diff --git a/src/main/java/org/rumbledb/types/ObjectItemType.java b/src/main/java/org/rumbledb/types/ObjectItemType.java index 8988559c09..23f735c57f 100644 --- a/src/main/java/org/rumbledb/types/ObjectItemType.java +++ b/src/main/java/org/rumbledb/types/ObjectItemType.java @@ -17,12 +17,14 @@ public class ObjectItemType implements ItemType { null ); - final static Set allowedFacets = new HashSet<>(Arrays.asList( - FacetTypes.ENUMERATION, - FacetTypes.CONSTRAINTS, - FacetTypes.CONTENT, - FacetTypes.CLOSED - )); + final static Set allowedFacets = new HashSet<>( + Arrays.asList( + FacetTypes.ENUMERATION, + FacetTypes.CONSTRAINTS, + FacetTypes.CONTENT, + FacetTypes.CLOSED + ) + ); final private Name name; final private Map content; @@ -32,7 +34,14 @@ public class ObjectItemType implements ItemType { final private ItemType baseType; final private int typeTreeDepth; - ObjectItemType(Name name, ItemType baseType, boolean isClosed, Map content, List constraints,List enumeration){ + ObjectItemType( + Name name, + ItemType baseType, + boolean isClosed, + Map content, + List constraints, + List enumeration + ) { this.name = name; this.isClosed = isClosed; this.content = content; @@ -103,12 +112,14 @@ public List getEnumerationFacet() { @Override public List getConstraintsFacet() { - return this.isPrimitive() ? this.constraints : ListUtils.union(this.baseType.getConstraintsFacet(), this.constraints); + return this.isPrimitive() + ? this.constraints + : ListUtils.union(this.baseType.getConstraintsFacet(), this.constraints); } @Override public Map getObjectContentFacet() { - if(this.isPrimitive()){ + if (this.isPrimitive()) { return this.content; } else { // recursively get content facet, overriding new descriptors diff --git a/src/main/java/org/rumbledb/types/UnionItemType.java b/src/main/java/org/rumbledb/types/UnionItemType.java index c9904deedd..7e55276b2f 100644 --- a/src/main/java/org/rumbledb/types/UnionItemType.java +++ b/src/main/java/org/rumbledb/types/UnionItemType.java @@ -17,14 +17,14 @@ public class UnionItemType implements ItemType { private final int typeTreeDepth; private final UnionContentDescriptor content; - UnionItemType(Name name, ItemType baseType, UnionContentDescriptor content){ + UnionItemType(Name name, ItemType baseType, UnionContentDescriptor content) { this.name = name; this.baseType = baseType; this.typeTreeDepth = baseType.getTypeTreeDepth() + 1; this.content = content; } - UnionItemType(Name name, UnionContentDescriptor content){ + UnionItemType(Name name, UnionContentDescriptor content) { this.name = name; this.baseType = BuiltinTypesCatalogue.item; this.typeTreeDepth = 1; From 99060c402f8a7cd2bfc25f0db63208b8e07cc6a8 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 2 Mar 2021 10:19:58 +0100 Subject: [PATCH 181/206] corrected tricky bug on spark runtime tests --- .../org/rumbledb/types/ArrayItemType.java | 4 ++-- .../org/rumbledb/types/AtomicItemType.java | 12 +++++------ .../rumbledb/types/DerivedAtomicItemType.java | 20 ++++++------------- .../org/rumbledb/types/FunctionItemType.java | 4 ++-- .../java/org/rumbledb/types/ItemItemType.java | 8 +++++--- .../java/org/rumbledb/types/ItemType.java | 2 +- .../java/org/rumbledb/types/JsonItemType.java | 10 ++++++---- .../org/rumbledb/types/ObjectItemType.java | 4 ++-- 8 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/rumbledb/types/ArrayItemType.java b/src/main/java/org/rumbledb/types/ArrayItemType.java index 5bb756190b..d7b61332a6 100644 --- a/src/main/java/org/rumbledb/types/ArrayItemType.java +++ b/src/main/java/org/rumbledb/types/ArrayItemType.java @@ -80,12 +80,12 @@ public int getTypeTreeDepth() { @Override public boolean isUserDefined() { - return !(this == anyArrayItem); + return !(this.equals(anyArrayItem)); } @Override public boolean isPrimitive() { - return this == anyArrayItem; + return this.equals(anyArrayItem); } @Override diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index 913aff870c..c79b2231f9 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -253,9 +253,9 @@ public Name getName() { @Override public int getTypeTreeDepth() { - if (this == atomicItem) { + if (this.equals(atomicItem)) { return 1; - } else if (this == yearMonthDurationItem || this == dayTimeDurationItem) { + } else if (this.equals(yearMonthDurationItem) || this.equals(dayTimeDurationItem)) { // TODO : check once you remove derived like integer and int return 3; } else { @@ -265,9 +265,9 @@ public int getTypeTreeDepth() { @Override public ItemType getBaseType() { - if (this == atomicItem) { + if (this.equals(atomicItem)) { return BuiltinTypesCatalogue.item; - } else if (this == yearMonthDurationItem || this == dayTimeDurationItem) { + } else if (this.equals(yearMonthDurationItem) || this.equals(dayTimeDurationItem)) { return durationItem; } else { return atomicItem; @@ -276,7 +276,7 @@ public ItemType getBaseType() { @Override public boolean isPrimitive() { - return !(this == dayTimeDurationItem || this == yearMonthDurationItem); + return !(this.equals(dayTimeDurationItem) || this.equals(yearMonthDurationItem)); } @Override @@ -339,7 +339,7 @@ public boolean isStaticallyCastableAs(ItemType other) { @Override public boolean isNumeric() { - return this == decimalItem || this == floatItem || this == doubleItem; + return this.equals(decimalItem) || this.equals(floatItem) || this.equals(doubleItem); } @Override diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index e2d14fb92d..4509276204 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -16,8 +16,8 @@ public class DerivedAtomicItemType implements ItemType { static final DerivedAtomicItemType integerItem = new DerivedAtomicItemType( new Name(Name.XS_NS, "xs", "integer"), - BuiltinTypesCatalogue.decimalItem, - BuiltinTypesCatalogue.decimalItem, + AtomicItemType.decimalItem, + AtomicItemType.decimalItem, Facets.getIntegerFacets(), false, DataTypes.createDecimalType() // TODO : how to support arbitrary-sized integer @@ -26,7 +26,7 @@ public class DerivedAtomicItemType implements ItemType { static final DerivedAtomicItemType longItem = new DerivedAtomicItemType( new Name(Name.XS_NS, "xs", "long"), integerItem, - BuiltinTypesCatalogue.decimalItem, + AtomicItemType.decimalItem, Facets.createMinMaxFacets( new IntegerItem(new BigInteger("-9223372036854775808")), new IntegerItem(new BigInteger("9223372036854775807")), @@ -39,7 +39,7 @@ public class DerivedAtomicItemType implements ItemType { static final DerivedAtomicItemType intItem = new DerivedAtomicItemType( Name.createVariableInDefaultTypeNamespace("int"), longItem, - BuiltinTypesCatalogue.decimalItem, + AtomicItemType.decimalItem, Facets.createMinMaxFacets(new IntItem(-2147483648), new IntItem(2147483647), true), false, DataTypes.IntegerType // TODO : how to support arbitrary-sized integer @@ -48,7 +48,7 @@ public class DerivedAtomicItemType implements ItemType { static final DerivedAtomicItemType shortItem = new DerivedAtomicItemType( new Name(Name.XS_NS, "xs", "short"), intItem, - BuiltinTypesCatalogue.decimalItem, + AtomicItemType.decimalItem, Facets.createMinMaxFacets(new IntItem(-32768), new IntItem(32767), true), false, DataTypes.ShortType // TODO : how to support arbitrary-sized integer @@ -141,15 +141,7 @@ public int getTypeTreeDepth() { @Override public boolean isStaticallyCastableAs(ItemType other) { // TODO: what about further restrictions like string without num from int? - ItemType castFrom = this.baseType; - while (castFrom.isUserDefined()) { - castFrom = castFrom.getBaseType(); - } - ItemType castTo = other; - while (castTo.isUserDefined()) { - castTo = castTo.getBaseType(); - } - return castFrom.isStaticallyCastableAs(castTo); + return this.primitiveType.isStaticallyCastableAs(other.isPrimitive() ? other : other.getPrimitiveType()); } @Override diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index 160582dba0..4d7bb6c494 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -68,12 +68,12 @@ public ItemType findLeastCommonSuperTypeWith(ItemType other) { @Override public int getTypeTreeDepth() { - return this == anyFunctionItem ? 1 : 2; + return this.equals(anyFunctionItem) ? 1 : 2; } @Override public ItemType getBaseType() { - return this == anyFunctionItem ? BuiltinTypesCatalogue.item : anyFunctionItem; + return this.equals(anyFunctionItem) ? BuiltinTypesCatalogue.item : anyFunctionItem; } @Override diff --git a/src/main/java/org/rumbledb/types/ItemItemType.java b/src/main/java/org/rumbledb/types/ItemItemType.java index 9fe4502706..431e408c27 100644 --- a/src/main/java/org/rumbledb/types/ItemItemType.java +++ b/src/main/java/org/rumbledb/types/ItemItemType.java @@ -25,8 +25,10 @@ private ItemItemType(Name name) { @Override public boolean equals(Object o) { - // no need to check the class because ItemItemType is a singleton and it is only equal to its only instance - return o == item; + if (!(o instanceof ItemType)) { + return false; + } + return this.toString().equals(o.toString()); } @Override @@ -41,7 +43,7 @@ public Name getName() { @Override public boolean isSubtypeOf(ItemType superType) { - return superType == item; + return superType.equals(item); } @Override diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 99d019f24c..c575e9c9e8 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -69,7 +69,7 @@ default boolean isArrayItemType() { * @return test if [this] is a subptype of a json item type */ default boolean isJsonItemType() { - return this == BuiltinTypesCatalogue.JSONItem || isObjectItemType() || isArrayItemType(); + return this.equals(BuiltinTypesCatalogue.JSONItem) || isObjectItemType() || isArrayItemType(); } default boolean isUnionType() { diff --git a/src/main/java/org/rumbledb/types/JsonItemType.java b/src/main/java/org/rumbledb/types/JsonItemType.java index 77cc7c926d..7fa0e42c8c 100644 --- a/src/main/java/org/rumbledb/types/JsonItemType.java +++ b/src/main/java/org/rumbledb/types/JsonItemType.java @@ -22,8 +22,10 @@ private JsonItemType(Name name) { @Override public boolean equals(Object o) { - // no need to check the class because ItemItemType is a singleton and it is only equal to its only instance - return o == jsonItem; + if (!(o instanceof ItemType)) { + return false; + } + return this.toString().equals(o.toString()); } @Override @@ -38,7 +40,7 @@ public Name getName() { @Override public boolean isSubtypeOf(ItemType superType) { - return superType == BuiltinTypesCatalogue.item || superType == jsonItem; + return superType.equals(BuiltinTypesCatalogue.item) || superType.equals(jsonItem); } @Override @@ -46,7 +48,7 @@ public ItemType findLeastCommonSuperTypeWith(ItemType other) { while (other.getTypeTreeDepth() > 1) { other = other.getBaseType(); } - return other == jsonItem ? jsonItem : BuiltinTypesCatalogue.item; + return other.equals(jsonItem) ? jsonItem : BuiltinTypesCatalogue.item; } @Override diff --git a/src/main/java/org/rumbledb/types/ObjectItemType.java b/src/main/java/org/rumbledb/types/ObjectItemType.java index 23f735c57f..05690dbcfd 100644 --- a/src/main/java/org/rumbledb/types/ObjectItemType.java +++ b/src/main/java/org/rumbledb/types/ObjectItemType.java @@ -82,12 +82,12 @@ public int getTypeTreeDepth() { @Override public boolean isUserDefined() { - return !(this == anyObjectItem); + return !(this.equals(anyObjectItem)); } @Override public boolean isPrimitive() { - return this == anyObjectItem; + return this.equals(anyObjectItem); } @Override From 583b5b7b6882117f53c177cb3f6e8335e02d7dd5 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 2 Mar 2021 10:28:35 +0100 Subject: [PATCH 182/206] spotless --- src/main/java/org/rumbledb/types/DerivedAtomicItemType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index 4509276204..2657196af0 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -141,7 +141,7 @@ public int getTypeTreeDepth() { @Override public boolean isStaticallyCastableAs(ItemType other) { // TODO: what about further restrictions like string without num from int? - return this.primitiveType.isStaticallyCastableAs(other.isPrimitive() ? other : other.getPrimitiveType()); + return this.primitiveType.isStaticallyCastableAs(other.isPrimitive() ? other : other.getPrimitiveType()); } @Override From ecc602cf8b5b902779af8ebabb04415edb7c9043 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 3 Mar 2021 11:04:49 +0100 Subject: [PATCH 183/206] removed TypeOrReference class in favor of directly using ItemType --- .../types/ArrayContentDescriptor.java | 12 ++---- .../org/rumbledb/types/FieldDescriptor.java | 11 ++--- .../java/org/rumbledb/types/ItemType.java | 5 +-- .../org/rumbledb/types/TypeOrReference.java | 43 ------------------- .../types/UnionContentDescriptor.java | 11 +---- 5 files changed, 10 insertions(+), 72 deletions(-) delete mode 100644 src/main/java/org/rumbledb/types/TypeOrReference.java diff --git a/src/main/java/org/rumbledb/types/ArrayContentDescriptor.java b/src/main/java/org/rumbledb/types/ArrayContentDescriptor.java index 935b1fd70c..861bbea333 100644 --- a/src/main/java/org/rumbledb/types/ArrayContentDescriptor.java +++ b/src/main/java/org/rumbledb/types/ArrayContentDescriptor.java @@ -1,19 +1,13 @@ package org.rumbledb.types; -import java.util.Map; - public class ArrayContentDescriptor { - private final TypeOrReference type; + private final ItemType type; - public ArrayContentDescriptor(TypeOrReference type) { + public ArrayContentDescriptor(ItemType type) { this.type = type; } - public TypeOrReference getType() { + public ItemType getType() { return this.type; } - - public void resolveTypeDescriptors(Map populatedSchema) { - this.type.resolve(populatedSchema); - } } diff --git a/src/main/java/org/rumbledb/types/FieldDescriptor.java b/src/main/java/org/rumbledb/types/FieldDescriptor.java index b8e4d796b0..22ffa639d7 100644 --- a/src/main/java/org/rumbledb/types/FieldDescriptor.java +++ b/src/main/java/org/rumbledb/types/FieldDescriptor.java @@ -5,18 +5,17 @@ public class FieldDescriptor { public String name; - private TypeOrReference type; + private ItemType type; private boolean required = false; private Item defaultValue = null; private boolean unique = false; private boolean requiredIsSet = false; - public boolean defaultIsChecked = false; public void setName(String name) { this.name = name; } - public void setType(TypeOrReference type) { + public void setType(ItemType type) { this.type = type; } @@ -37,7 +36,7 @@ public String getName() { return this.name; } - public TypeOrReference getTypeOrReference() { + public ItemType getType() { return this.type; } @@ -56,8 +55,4 @@ public Item getDefaultValue() { public boolean requiredIsSet() { return this.requiredIsSet; } - - public void resolveTypeDescriptors(Map populatedSchema) { - this.type.resolve(populatedSchema); - } } diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index c575e9c9e8..711d6927be 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -135,9 +135,8 @@ default boolean isSubtypeOf(ItemType superType) { // special check for unions if (superType.isUnionType()) { - // TODO : to simplify inner classes - for (TypeOrReference typeOrReference : superType.getUnionContentFacet().getTypes()) { - if (this.isSubtypeOf(typeOrReference.getType())) { + for (ItemType unionItemType : superType.getUnionContentFacet().getTypes()) { + if (this.isSubtypeOf(unionItemType)) { return true; } } diff --git a/src/main/java/org/rumbledb/types/TypeOrReference.java b/src/main/java/org/rumbledb/types/TypeOrReference.java deleted file mode 100644 index 58ced1d752..0000000000 --- a/src/main/java/org/rumbledb/types/TypeOrReference.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.rumbledb.types; - -import org.rumbledb.exceptions.RumbleException; - -import java.util.Map; - -public class TypeOrReference { - - private ItemType type; - private String stringType; - - public TypeOrReference(ItemType type) { - this.type = type; - } - - public TypeOrReference(String stringType) { - this.stringType = stringType; - } - - public void resolve(Map populatedSchema) { - if (this.type != null) { - return; - } - this.type = populatedSchema.get(this.stringType); - if (this.type == null) - throw new RumbleException("Type " + this.stringType + " could not be resolved."); - } - - public ItemType getTypeDescriptor() { - if (this.type == null) { - throw new RumbleException("Type " + this.stringType + " was not resolved."); - } - return this.type; - } - - public String getStringType() { - return this.stringType; - } - - public ItemType getType() { - return this.type; - } -} diff --git a/src/main/java/org/rumbledb/types/UnionContentDescriptor.java b/src/main/java/org/rumbledb/types/UnionContentDescriptor.java index 818eec0886..cb343f92bb 100644 --- a/src/main/java/org/rumbledb/types/UnionContentDescriptor.java +++ b/src/main/java/org/rumbledb/types/UnionContentDescriptor.java @@ -2,22 +2,15 @@ import java.util.ArrayList; import java.util.List; -import java.util.Map; public class UnionContentDescriptor { - private final List types; + private final List types; public UnionContentDescriptor() { this.types = new ArrayList<>(); } - public List getTypes() { + public List getTypes() { return this.types; } - - public void resolveTypeDescriptors(Map populatedSchema) { - for (TypeOrReference type : this.types) { - type.resolve(populatedSchema); - } - } } From 2fc1c2d182c73e796fcc32f9c4f98bb33faffe7d Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 3 Mar 2021 13:52:27 +0100 Subject: [PATCH 184/206] added parquet support and tested object type creation --- .../rumbledb/compiler/InferTypeVisitor.java | 57 ++++++++++- .../org/rumbledb/types/ArrayItemType.java | 32 ++++++- .../org/rumbledb/types/AtomicItemType.java | 2 +- .../rumbledb/types/DerivedAtomicItemType.java | 85 ++++++++++++++++- .../org/rumbledb/types/FunctionItemType.java | 5 + .../java/org/rumbledb/types/ItemItemType.java | 2 +- .../java/org/rumbledb/types/ItemType.java | 13 ++- .../org/rumbledb/types/ItemTypeFactory.java | 49 ++++++++++ .../java/org/rumbledb/types/JsonItemType.java | 2 +- .../org/rumbledb/types/ObjectItemType.java | 95 +++++++++++++++++-- .../org/rumbledb/types/UnionItemType.java | 25 ++++- 11 files changed, 346 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 5763ac89eb..0137bb3bcb 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -1,8 +1,11 @@ package org.rumbledb.compiler; +import org.apache.spark.sql.AnalysisException; +import org.apache.spark.sql.types.StructType; import org.rumbledb.config.RumbleRuntimeConfiguration; import org.rumbledb.context.*; import org.rumbledb.errorcodes.ErrorCode; +import org.rumbledb.exceptions.CannotRetrieveResourceException; import org.rumbledb.exceptions.IsStaticallyUnexpectedType; import org.rumbledb.exceptions.OurBadException; import org.rumbledb.exceptions.UnexpectedStaticTypeException; @@ -26,9 +29,12 @@ import org.rumbledb.expressions.postfix.*; import org.rumbledb.expressions.primary.*; import org.rumbledb.expressions.typing.*; +import org.rumbledb.runtime.functions.input.FileSystemUtil; import org.rumbledb.types.*; import org.rumbledb.types.BuiltinTypesCatalogue; +import sparksoniq.spark.SparkSessionManager; +import java.net.URI; import java.util.*; import java.util.stream.Collectors; @@ -303,6 +309,44 @@ public StaticContext visitNamedFunctionRef(NamedFunctionReferenceExpression expr return argument; } + /** + * For specific input functions we read the schema and annotate static type precisely + * @param expression function call expression to be annotated + * @return true if we perform the annotation or false if it is not one of this specific cases + */ + private boolean tryAnnotateSpecificFunctions(FunctionCallExpression expression, StaticContext staticContext){ + List functionNameToAnnotate = Arrays.asList( + Name.createVariableInDefaultFunctionNamespace("avro-file"), + Name.createVariableInDefaultFunctionNamespace("parquet-file") + ); + Name functionName = expression.getFunctionName(); + List args = expression.getArguments(); + + if(functionNameToAnnotate.contains(functionName) && args.size() > 0 && args.get(0) instanceof StringLiteralExpression){ + String path = ((StringLiteralExpression) args.get(0)).getValue(); + URI uri = FileSystemUtil.resolveURI(staticContext.getStaticBaseURI(), path, expression.getMetadata()); + if (!FileSystemUtil.exists(uri, this.rumbleRuntimeConfiguration, expression.getMetadata())) { + throw new CannotRetrieveResourceException("File " + uri + " not found.", expression.getMetadata()); + } + try { + StructType s = SparkSessionManager.getInstance() + .getOrCreateSession() + .read() + .parquet(uri.toString()) + .schema(); + ItemType schemaItemType = ItemTypeFactory.createItemTypeFromSparkStructType(null, s); + System.out.println(schemaItemType.toString()); + } catch (Exception e) { + if (e instanceof AnalysisException) { + throw new CannotRetrieveResourceException("File " + uri + " not found.", expression.getMetadata()); + } + throw e; + } + } + + return false; + } + @Override public StaticContext visitFunctionCall(FunctionCallExpression expression, StaticContext argument) { visitDescendants(expression, argument); @@ -314,6 +358,7 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static List partialParams = new ArrayList<>(); int paramsLength = parameterExpressions.size(); + // check arguments are of correct type for (int i = 0; i < paramsLength; ++i) { if (parameterExpressions.get(i) != null) { SequenceType actualType = parameterExpressions.get(i).getInferredSequenceType(); @@ -335,11 +380,15 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static new SequenceType(ItemTypeFactory.createFunctionItemType(partialSignature)) ); } else { - SequenceType returnType = signature.getReturnType(); - if (returnType == null) { - returnType = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; + // try annotate specific functions + if(!tryAnnotateSpecificFunctions(expression, argument)){ + // we did not annotate a specific function, therefore we use default return type + SequenceType returnType = signature.getReturnType(); + if (returnType == null) { + returnType = SequenceType.MOST_GENERAL_SEQUENCE_TYPE; + } + expression.setInferredSequenceType(returnType); } - expression.setInferredSequenceType(returnType); } System.out.println("Visited static function call, set type to " + expression.getInferredSequenceType()); diff --git a/src/main/java/org/rumbledb/types/ArrayItemType.java b/src/main/java/org/rumbledb/types/ArrayItemType.java index d7b61332a6..258ea18fd5 100644 --- a/src/main/java/org/rumbledb/types/ArrayItemType.java +++ b/src/main/java/org/rumbledb/types/ArrayItemType.java @@ -54,7 +54,7 @@ public boolean equals(Object other) { if (!(other instanceof ItemType)) { return false; } - return this.toString().equals(other.toString()); + return this.getIdentifierString().equals(((ItemType) other).getIdentifierString()); } @Override @@ -64,12 +64,11 @@ public boolean isArrayItemType() { @Override public boolean hasName() { - return true; + return this.name != null; } @Override public Name getName() { - // TODO : what about anonymous types return this.name; } @@ -123,6 +122,33 @@ public ArrayContentDescriptor getArrayContentFacet() { return this.content != null || this.isPrimitive() ? this.content : this.baseType.getArrayContentFacet(); } + @Override + public String getIdentifierString() { + if(this.hasName()){ + return this.name.toString(); + } + StringBuilder sb = new StringBuilder(); + sb.append("#anonymous-array-base{"); + sb.append(this.baseType.getIdentifierString()); + sb.append("}"); + if(this.content != null){ + sb.append("-content{"); + sb.append(this.content.getType().getIdentifierString()); + sb.append("}"); + } + if(this.enumeration != null){ + sb.append("-enum{"); + String comma = ""; + for(Item item : this.enumeration){ + sb.append(comma); + sb.append(item.serialize()); + comma = ","; + } + sb.append("}"); + } + return sb.toString(); + } + @Override public String toString() { // consider add content and various stuff diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index c79b2231f9..e61542a740 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -233,7 +233,7 @@ public boolean equals(Object other) { if (!(other instanceof ItemType)) { return false; } - return this.toString().equals(other.toString()); + return this.getIdentifierString().equals(((ItemType) other).getIdentifierString()); } @Override diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index 2657196af0..126a872219 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -110,7 +110,7 @@ public boolean equals(Object other) { if (!(other instanceof ItemType)) { return false; } - return this.toString().equals(other.toString()); + return this.getIdentifierString().equals(((ItemType) other).getIdentifierString()); } @Override @@ -125,7 +125,7 @@ public boolean isNumeric() { @Override public boolean hasName() { - return true; + return this.name != null; } @Override @@ -300,6 +300,87 @@ public TimezoneFacet getExplicitTimezoneFacet() { return this.explicitTimezone == null ? this.baseType.getExplicitTimezoneFacet() : this.explicitTimezone; } + @Override + public String getIdentifierString() { + if(this.hasName()){ + return this.name.toString(); + } + StringBuilder sb = new StringBuilder(); + sb.append("#anonymous-atomic-base{"); + sb.append(this.baseType.getIdentifierString()); + sb.append("}"); + + if(this.minLength != null){ + sb.append("-ml:"); + sb.append(this.minLength); + } + if(this.length != null){ + sb.append("-l:"); + sb.append(this.length); + } + if(this.maxLength != null){ + sb.append("-Ml:"); + sb.append(this.maxLength); + } + + if(this.totalDigits != null){ + sb.append("-td:"); + sb.append(this.totalDigits); + } + if(this.fractionDigits != null){ + sb.append("-fd:"); + sb.append(this.fractionDigits); + } + + if(this.minInclusive != null){ + sb.append("-mi:"); + sb.append(this.minInclusive.serialize()); + } + if(this.minExclusive != null){ + sb.append("-me:"); + sb.append(this.minExclusive.serialize()); + } + if(this.maxInclusive != null){ + sb.append("-Mi:"); + sb.append(this.maxInclusive.serialize()); + } + if(this.maxExclusive != null){ + sb.append("-Me:"); + sb.append(this.maxExclusive.serialize()); + } + + if(this.explicitTimezone != null){ + sb.append("-et:"); + sb.append(this.explicitTimezone.name()); + } + + + if(this.enumeration != null){ + sb.append("-enum{"); + String comma = ""; + for(Item item : this.enumeration){ + sb.append(comma); + sb.append(item.serialize()); + comma = ","; + } + sb.append("}"); + } + + if(this.constraints.size() > 0){ + sb.append("-const{"); + String comma = ""; + for(String c : this.constraints){ + sb.append(comma); + sb.append("\""); + sb.append(c); + sb.append("\""); + comma = ","; + } + sb.append("}"); + } + return sb.toString(); + } + @Override public String toString() { // TODO : Consider added facets restriction and base type diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index 4d7bb6c494..06b105388a 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -81,6 +81,11 @@ public Set getAllowedFacets() { throw new UnsupportedOperationException("function item types does not support facets"); } + @Override + public String getIdentifierString() { + return this.toString(); + } + @Override public String toString() { return this.isGeneric ? "function(*)" : this.signature.toString(); diff --git a/src/main/java/org/rumbledb/types/ItemItemType.java b/src/main/java/org/rumbledb/types/ItemItemType.java index 431e408c27..bf0bc65a7a 100644 --- a/src/main/java/org/rumbledb/types/ItemItemType.java +++ b/src/main/java/org/rumbledb/types/ItemItemType.java @@ -28,7 +28,7 @@ public boolean equals(Object o) { if (!(o instanceof ItemType)) { return false; } - return this.toString().equals(o.toString()); + return this.getIdentifierString().equals(((ItemType) o).getIdentifierString()); } @Override diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 711d6927be..4ff328fec0 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -396,7 +396,18 @@ default UnionContentDescriptor getUnionContentFacet() { // endregion - public String toString(); + /** + * + * @return a String that uniquely identify an item type + */ + default String getIdentifierString(){ + if(this.hasName()){ + return this.getName().toString(); + } + throw new UnsupportedOperationException("default implementation of uniqueString always requires a Name"); + } + + String toString(); default DataType toDataFrameType() { throw new UnsupportedOperationException( diff --git a/src/main/java/org/rumbledb/types/ItemTypeFactory.java b/src/main/java/org/rumbledb/types/ItemTypeFactory.java index 7a1a8fb80c..168aba46f7 100644 --- a/src/main/java/org/rumbledb/types/ItemTypeFactory.java +++ b/src/main/java/org/rumbledb/types/ItemTypeFactory.java @@ -1,7 +1,56 @@ package org.rumbledb.types; +import org.apache.spark.sql.types.ArrayType; +import org.apache.spark.sql.types.DataType; +import org.apache.spark.sql.types.StructField; +import org.apache.spark.sql.types.StructType; +import org.rumbledb.context.Name; +import org.rumbledb.items.parsing.ItemParser; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + public class ItemTypeFactory { + /** + * @param signature of the wanted function item type + * @return a function item type with the given signature + */ public static FunctionItemType createFunctionItemType(FunctionSignature signature) { return new FunctionItemType(signature); } + + /** + * Create an object item type from a spark struct type (count as restriction on generic object type) + * @param name of the new type (if null it is an anonymous type) + * @param structType descriptor of the object + * @return an object item type representing the type in Rumble + */ + public static ObjectItemType createItemTypeFromSparkStructType(String name, StructType structType){ + // TODO : should parquet/avro object be closed? + // TODO : handle type registration + // TODO : identical anonymous types should be equivalent? + Name objectName = name != null && !name.equals("") ? Name.createVariableInDefaultTypeNamespace(name) : null; + Map content = new HashMap<>(); + for (StructField field : structType.fields()){ + DataType filedType = field.dataType(); + ItemType mappedItemType; + if (filedType instanceof StructType) { + mappedItemType = createItemTypeFromSparkStructType(null, (StructType) filedType); + } else if (filedType instanceof ArrayType) { + // TODO : add proper function + mappedItemType = BuiltinTypesCatalogue.arrayItem; + } else { + mappedItemType = ItemParser.convertDataTypeToItemType(filedType); + } + FieldDescriptor fieldDescriptor = new FieldDescriptor(); + fieldDescriptor.setName(field.name()); + fieldDescriptor.setType(mappedItemType); + fieldDescriptor.setRequired(!field.nullable()); + // TODO : how to deal with duplicate keys? + content.put(field.name(), fieldDescriptor); + } + + return new ObjectItemType(objectName, BuiltinTypesCatalogue.objectItem, false, content, null, null); + } } diff --git a/src/main/java/org/rumbledb/types/JsonItemType.java b/src/main/java/org/rumbledb/types/JsonItemType.java index 7fa0e42c8c..d8933ddbb4 100644 --- a/src/main/java/org/rumbledb/types/JsonItemType.java +++ b/src/main/java/org/rumbledb/types/JsonItemType.java @@ -25,7 +25,7 @@ public boolean equals(Object o) { if (!(o instanceof ItemType)) { return false; } - return this.toString().equals(o.toString()); + return this.getIdentifierString().equals(((ItemType) o).getIdentifierString()); } @Override diff --git a/src/main/java/org/rumbledb/types/ObjectItemType.java b/src/main/java/org/rumbledb/types/ObjectItemType.java index 05690dbcfd..81bc0c7c0e 100644 --- a/src/main/java/org/rumbledb/types/ObjectItemType.java +++ b/src/main/java/org/rumbledb/types/ObjectItemType.java @@ -44,10 +44,10 @@ public class ObjectItemType implements ItemType { ) { this.name = name; this.isClosed = isClosed; - this.content = content; + this.content = content == null ? Collections.emptyMap() : content; this.baseType = baseType; this.typeTreeDepth = baseType.getTypeTreeDepth() + 1; - this.constraints = constraints; + this.constraints = constraints == null ? Collections.emptyList() : constraints; this.enumeration = enumeration; } @@ -56,7 +56,7 @@ public boolean equals(Object other) { if (!(other instanceof ItemType)) { return false; } - return this.toString().equals(other.toString()); + return this.getIdentifierString().equals(((ItemType) other).getIdentifierString()); } @Override @@ -66,12 +66,11 @@ public boolean isObjectItemType() { @Override public boolean hasName() { - return true; + return this.name != null; } @Override public Name getName() { - // TODO : what about anonymous types return this.name; } @@ -134,9 +133,91 @@ public boolean getClosedFacet() { return this.isClosed; } + @Override + public String getIdentifierString() { + if(this.hasName()){ + return this.name.toString(); + } + StringBuilder sb = new StringBuilder(); + sb.append("#anonymous-object-base{"); + sb.append(this.baseType.getIdentifierString()); + sb.append("}"); + sb.append(this.isClosed ? "-c" : "-nc"); + if(this.content != null){ + sb.append("-content{"); + String comma = ""; + for(FieldDescriptor fd : this.content.values()){ + sb.append(comma); + sb.append(fd.getName()); + sb.append(fd.isRequired() ? "(r):" : "(nr):"); + sb.append(fd.getType().getIdentifierString()); + Item dv = fd.getDefaultValue(); + if(dv != null){ + sb.append("(def:"); + sb.append(dv.serialize()); + sb.append(")"); + } else { + sb.append("(nd)"); + } + comma = ","; + } + sb.append("}"); + } + if(this.enumeration != null){ + sb.append("-enum{"); + String comma = ""; + for(Item item : this.enumeration){ + sb.append(comma); + sb.append(item.serialize()); + comma = ","; + } + sb.append("}"); + } + if(this.constraints.size() > 0){ + sb.append("-const{"); + String comma = ""; + for(String c : this.constraints){ + sb.append(comma); + sb.append("\""); + sb.append(c); + sb.append("\""); + comma = ","; + } + sb.append("}"); + } + return sb.toString(); + } + @Override public String toString() { - // consider add content and various stuff - return this.name.toString(); + if((new Name(Name.JS_NS, "js", "object")).equals(this.name)){ + // generic object + return this.name.toString(); + } else { + StringBuilder sb = new StringBuilder(); + sb.append(this.name == null ? "#anonymous" : this.name.toString()); + sb.append(" (object item)\n"); + + sb.append("base type : "); + sb.append(this.baseType.getIdentifierString()); + sb.append("\n"); + + List fields = new ArrayList<>(this.getObjectContentFacet().values()); + if(fields.size() > 0){ + sb.append("content facet:\n"); + String comma = ""; + for(FieldDescriptor field : fields){ + sb.append(" "); + sb.append(field.getName()); + if(field.isRequired()){ + sb.append(" (required)"); + } + sb.append(" : "); + sb.append(field.getType().getIdentifierString()); + sb.append("\n"); + } + } + return sb.toString(); + } } } diff --git a/src/main/java/org/rumbledb/types/UnionItemType.java b/src/main/java/org/rumbledb/types/UnionItemType.java index 7e55276b2f..f45651c45e 100644 --- a/src/main/java/org/rumbledb/types/UnionItemType.java +++ b/src/main/java/org/rumbledb/types/UnionItemType.java @@ -2,6 +2,7 @@ import org.apache.spark.sql.types.DataType; import org.apache.spark.sql.types.DataTypes; +import org.rumbledb.api.Item; import org.rumbledb.context.Name; import java.util.Arrays; @@ -36,7 +37,7 @@ public boolean equals(Object other) { if (!(other instanceof ItemType)) { return false; } - return this.toString().equals(other.toString()); + return this.getIdentifierString().equals(((ItemType) other).getIdentifierString()); } @Override @@ -89,6 +90,28 @@ public UnionContentDescriptor getUnionContentFacet() { return this.content; } + @Override + public String getIdentifierString() { + if(this.hasName()){ + return this.name.toString(); + } + StringBuilder sb = new StringBuilder(); + sb.append("#anonymous-union-base{"); + sb.append(this.baseType.getIdentifierString()); + sb.append("}"); + if(this.content != null){ + sb.append("-content{"); + String comma = ""; + for(ItemType it : this.content.getTypes()){ + sb.append(comma); + sb.append(it.getIdentifierString()); + comma = ","; + } + sb.append("}"); + } + return sb.toString(); + } + @Override public String toString() { // TODO : consider providing more info From 4ce639cd4aafe6e6b17d80ac4fd3206950862704 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Wed, 3 Mar 2021 16:58:42 +0100 Subject: [PATCH 185/206] added object lookup complete inference --- .../rumbledb/compiler/InferTypeVisitor.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 0137bb3bcb..e6e4989431 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -316,7 +316,7 @@ public StaticContext visitNamedFunctionRef(NamedFunctionReferenceExpression expr */ private boolean tryAnnotateSpecificFunctions(FunctionCallExpression expression, StaticContext staticContext){ List functionNameToAnnotate = Arrays.asList( - Name.createVariableInDefaultFunctionNamespace("avro-file"), + //Name.createVariableInDefaultFunctionNamespace("avro-file"), Name.createVariableInDefaultFunctionNamespace("parquet-file") ); Name functionName = expression.getFunctionName(); @@ -336,6 +336,9 @@ private boolean tryAnnotateSpecificFunctions(FunctionCallExpression expression, .schema(); ItemType schemaItemType = ItemTypeFactory.createItemTypeFromSparkStructType(null, s); System.out.println(schemaItemType.toString()); + // TODO : check if arity is correct + expression.setInferredSequenceType(new SequenceType(schemaItemType, SequenceType.Arity.ZeroOrMore)); + return true; } catch (Exception e) { if (e instanceof AnalysisException) { throw new CannotRetrieveResourceException("File " + uri + " not found.", expression.getMetadata()); @@ -1308,7 +1311,30 @@ public StaticContext visitObjectLookupExpression(ObjectLookupExpression expressi SequenceType.Arity inferredArity = mainType.isAritySubtypeOf(SequenceType.Arity.OneOrZero) ? SequenceType.Arity.OneOrZero : SequenceType.Arity.ZeroOrMore; - expression.setInferredSequenceType(new SequenceType(BuiltinTypesCatalogue.item, inferredArity)); + + ItemType inferredType = BuiltinTypesCatalogue.item; + // if we have a specific object type and a string literal as key try perform better inference + if(mainType.getItemType().isObjectItemType() && (expression.getLookupExpression() instanceof StringLiteralExpression)){ + String key = ((StringLiteralExpression) expression.getLookupExpression()).getValue(); + boolean isObjectClosed = mainType.getItemType().getClosedFacet(); + Map objectSchema = mainType.getItemType().getObjectContentFacet(); + if(objectSchema.containsKey(key)){ + FieldDescriptor field = objectSchema.get(key); + inferredType = field.getType(); + if(field.isRequired()){ + // if the field is required then any object will have it, so no need to include '0' arity if not present + inferredArity = mainType.getArity(); + } + } else if(isObjectClosed){ + // if object is closed and key is not found then for sure we will return the empty sequence + throw new UnexpectedStaticTypeException( + "Inferred type is empty sequence and this is not a CommaExpression", + ErrorCode.StaticallyInferredEmptySequenceNotFromCommaExpression + ); + } + } + + expression.setInferredSequenceType(new SequenceType(inferredType, inferredArity)); System.out.println("visiting ObjectLookup expression, type set to: " + expression.getInferredSequenceType()); return argument; } From 3b2ff08f11a117cc1cdf1a195a880dafdca42f31 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Fri, 26 Mar 2021 18:51:19 +0100 Subject: [PATCH 186/206] fix on constant integers in order by --- .../runtime/flwor/clauses/OrderByClauseSparkIterator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index 0add3e6cf9..18b98bfafa 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -531,11 +531,13 @@ public static Dataset tryNativeQuery( orderSql.append(orderSeparator); orderSeparator = ", "; // special check to avoid ordering by an integer constant in an ordering clause + // second check to assure it is a literal // because of meaning mismatch between sparksql (where it is supposed to order by the i-th col) // and jsoniq (order by a costant, so no actual ordering is performed) if ( - nativeQuery.getResultingType() == BuiltinTypesCatalogue.integerItem - || nativeQuery.getResultingType() == BuiltinTypesCatalogue.intItem + (nativeQuery.getResultingType() == BuiltinTypesCatalogue.integerItem + || nativeQuery.getResultingType() == BuiltinTypesCatalogue.intItem) + && nativeQuery.getResultingQuery().matches("\\s*-?\\s*\\d+\\s*") ) { orderSql.append('"'); orderSql.append(nativeQuery.getResultingQuery()); From c2ba2e3f13c5e93e8307396ac4c1faf6872fb702 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Fri, 26 Mar 2021 18:52:26 +0100 Subject: [PATCH 187/206] set object item type generated from spark struct type as closed --- src/main/java/org/rumbledb/types/ItemTypeFactory.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/rumbledb/types/ItemTypeFactory.java b/src/main/java/org/rumbledb/types/ItemTypeFactory.java index 168aba46f7..01e6684897 100644 --- a/src/main/java/org/rumbledb/types/ItemTypeFactory.java +++ b/src/main/java/org/rumbledb/types/ItemTypeFactory.java @@ -27,7 +27,6 @@ public static FunctionItemType createFunctionItemType(FunctionSignature signatur * @return an object item type representing the type in Rumble */ public static ObjectItemType createItemTypeFromSparkStructType(String name, StructType structType){ - // TODO : should parquet/avro object be closed? // TODO : handle type registration // TODO : identical anonymous types should be equivalent? Name objectName = name != null && !name.equals("") ? Name.createVariableInDefaultTypeNamespace(name) : null; @@ -51,6 +50,6 @@ public static ObjectItemType createItemTypeFromSparkStructType(String name, Stru content.put(field.name(), fieldDescriptor); } - return new ObjectItemType(objectName, BuiltinTypesCatalogue.objectItem, false, content, null, null); + return new ObjectItemType(objectName, BuiltinTypesCatalogue.objectItem, true, content, null, null); } } From 17324fb1978516aedf623fc4d628c29b3f973fb1 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 30 Mar 2021 14:33:33 +0200 Subject: [PATCH 188/206] spotless --- .../rumbledb/compiler/InferTypeVisitor.java | 37 ++++++++++++------- .../clauses/OrderByClauseSparkIterator.java | 2 +- .../org/rumbledb/types/ArrayItemType.java | 8 ++-- .../rumbledb/types/DerivedAtomicItemType.java | 30 +++++++-------- .../org/rumbledb/types/FieldDescriptor.java | 1 - .../java/org/rumbledb/types/ItemType.java | 4 +- .../org/rumbledb/types/ItemTypeFactory.java | 6 +-- .../org/rumbledb/types/ObjectItemType.java | 26 ++++++------- .../org/rumbledb/types/UnionItemType.java | 7 ++-- 9 files changed, 64 insertions(+), 57 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index e6e4989431..f28768a0d7 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -311,18 +311,23 @@ public StaticContext visitNamedFunctionRef(NamedFunctionReferenceExpression expr /** * For specific input functions we read the schema and annotate static type precisely + * * @param expression function call expression to be annotated * @return true if we perform the annotation or false if it is not one of this specific cases */ - private boolean tryAnnotateSpecificFunctions(FunctionCallExpression expression, StaticContext staticContext){ + private boolean tryAnnotateSpecificFunctions(FunctionCallExpression expression, StaticContext staticContext) { List functionNameToAnnotate = Arrays.asList( - //Name.createVariableInDefaultFunctionNamespace("avro-file"), - Name.createVariableInDefaultFunctionNamespace("parquet-file") + // Name.createVariableInDefaultFunctionNamespace("avro-file"), + Name.createVariableInDefaultFunctionNamespace("parquet-file") ); Name functionName = expression.getFunctionName(); List args = expression.getArguments(); - if(functionNameToAnnotate.contains(functionName) && args.size() > 0 && args.get(0) instanceof StringLiteralExpression){ + if ( + functionNameToAnnotate.contains(functionName) + && args.size() > 0 + && args.get(0) instanceof StringLiteralExpression + ) { String path = ((StringLiteralExpression) args.get(0)).getValue(); URI uri = FileSystemUtil.resolveURI(staticContext.getStaticBaseURI(), path, expression.getMetadata()); if (!FileSystemUtil.exists(uri, this.rumbleRuntimeConfiguration, expression.getMetadata())) { @@ -330,10 +335,10 @@ private boolean tryAnnotateSpecificFunctions(FunctionCallExpression expression, } try { StructType s = SparkSessionManager.getInstance() - .getOrCreateSession() - .read() - .parquet(uri.toString()) - .schema(); + .getOrCreateSession() + .read() + .parquet(uri.toString()) + .schema(); ItemType schemaItemType = ItemTypeFactory.createItemTypeFromSparkStructType(null, s); System.out.println(schemaItemType.toString()); // TODO : check if arity is correct @@ -384,7 +389,7 @@ public StaticContext visitFunctionCall(FunctionCallExpression expression, Static ); } else { // try annotate specific functions - if(!tryAnnotateSpecificFunctions(expression, argument)){ + if (!tryAnnotateSpecificFunctions(expression, argument)) { // we did not annotate a specific function, therefore we use default return type SequenceType returnType = signature.getReturnType(); if (returnType == null) { @@ -1314,18 +1319,22 @@ public StaticContext visitObjectLookupExpression(ObjectLookupExpression expressi ItemType inferredType = BuiltinTypesCatalogue.item; // if we have a specific object type and a string literal as key try perform better inference - if(mainType.getItemType().isObjectItemType() && (expression.getLookupExpression() instanceof StringLiteralExpression)){ + if ( + mainType.getItemType().isObjectItemType() + && (expression.getLookupExpression() instanceof StringLiteralExpression) + ) { String key = ((StringLiteralExpression) expression.getLookupExpression()).getValue(); boolean isObjectClosed = mainType.getItemType().getClosedFacet(); Map objectSchema = mainType.getItemType().getObjectContentFacet(); - if(objectSchema.containsKey(key)){ + if (objectSchema.containsKey(key)) { FieldDescriptor field = objectSchema.get(key); inferredType = field.getType(); - if(field.isRequired()){ - // if the field is required then any object will have it, so no need to include '0' arity if not present + if (field.isRequired()) { + // if the field is required then any object will have it, so no need to include '0' arity if not + // present inferredArity = mainType.getArity(); } - } else if(isObjectClosed){ + } else if (isObjectClosed) { // if object is closed and key is not found then for sure we will return the empty sequence throw new UnexpectedStaticTypeException( "Inferred type is empty sequence and this is not a CommaExpression", diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java index 18b98bfafa..e0a4e9792b 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/OrderByClauseSparkIterator.java @@ -535,7 +535,7 @@ public static Dataset tryNativeQuery( // because of meaning mismatch between sparksql (where it is supposed to order by the i-th col) // and jsoniq (order by a costant, so no actual ordering is performed) if ( - (nativeQuery.getResultingType() == BuiltinTypesCatalogue.integerItem + (nativeQuery.getResultingType() == BuiltinTypesCatalogue.integerItem || nativeQuery.getResultingType() == BuiltinTypesCatalogue.intItem) && nativeQuery.getResultingQuery().matches("\\s*-?\\s*\\d+\\s*") ) { diff --git a/src/main/java/org/rumbledb/types/ArrayItemType.java b/src/main/java/org/rumbledb/types/ArrayItemType.java index 258ea18fd5..62ed6fec8d 100644 --- a/src/main/java/org/rumbledb/types/ArrayItemType.java +++ b/src/main/java/org/rumbledb/types/ArrayItemType.java @@ -124,22 +124,22 @@ public ArrayContentDescriptor getArrayContentFacet() { @Override public String getIdentifierString() { - if(this.hasName()){ + if (this.hasName()) { return this.name.toString(); } StringBuilder sb = new StringBuilder(); sb.append("#anonymous-array-base{"); sb.append(this.baseType.getIdentifierString()); sb.append("}"); - if(this.content != null){ + if (this.content != null) { sb.append("-content{"); sb.append(this.content.getType().getIdentifierString()); sb.append("}"); } - if(this.enumeration != null){ + if (this.enumeration != null) { sb.append("-enum{"); String comma = ""; - for(Item item : this.enumeration){ + for (Item item : this.enumeration) { sb.append(comma); sb.append(item.serialize()); comma = ","; diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index 126a872219..c0c3b9549e 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -302,7 +302,7 @@ public TimezoneFacet getExplicitTimezoneFacet() { @Override public String getIdentifierString() { - if(this.hasName()){ + if (this.hasName()) { return this.name.toString(); } StringBuilder sb = new StringBuilder(); @@ -310,55 +310,55 @@ public String getIdentifierString() { sb.append(this.baseType.getIdentifierString()); sb.append("}"); - if(this.minLength != null){ + if (this.minLength != null) { sb.append("-ml:"); sb.append(this.minLength); } - if(this.length != null){ + if (this.length != null) { sb.append("-l:"); sb.append(this.length); } - if(this.maxLength != null){ + if (this.maxLength != null) { sb.append("-Ml:"); sb.append(this.maxLength); } - if(this.totalDigits != null){ + if (this.totalDigits != null) { sb.append("-td:"); sb.append(this.totalDigits); } - if(this.fractionDigits != null){ + if (this.fractionDigits != null) { sb.append("-fd:"); sb.append(this.fractionDigits); } - if(this.minInclusive != null){ + if (this.minInclusive != null) { sb.append("-mi:"); sb.append(this.minInclusive.serialize()); } - if(this.minExclusive != null){ + if (this.minExclusive != null) { sb.append("-me:"); sb.append(this.minExclusive.serialize()); } - if(this.maxInclusive != null){ + if (this.maxInclusive != null) { sb.append("-Mi:"); sb.append(this.maxInclusive.serialize()); } - if(this.maxExclusive != null){ + if (this.maxExclusive != null) { sb.append("-Me:"); sb.append(this.maxExclusive.serialize()); } - if(this.explicitTimezone != null){ + if (this.explicitTimezone != null) { sb.append("-et:"); sb.append(this.explicitTimezone.name()); } - if(this.enumeration != null){ + if (this.enumeration != null) { sb.append("-enum{"); String comma = ""; - for(Item item : this.enumeration){ + for (Item item : this.enumeration) { sb.append(comma); sb.append(item.serialize()); comma = ","; @@ -366,10 +366,10 @@ public String getIdentifierString() { sb.append("}"); } - if(this.constraints.size() > 0){ + if (this.constraints.size() > 0) { sb.append("-const{"); String comma = ""; - for(String c : this.constraints){ + for (String c : this.constraints) { sb.append(comma); sb.append("\""); sb.append(c); diff --git a/src/main/java/org/rumbledb/types/FieldDescriptor.java b/src/main/java/org/rumbledb/types/FieldDescriptor.java index 22ffa639d7..dda669652c 100644 --- a/src/main/java/org/rumbledb/types/FieldDescriptor.java +++ b/src/main/java/org/rumbledb/types/FieldDescriptor.java @@ -1,6 +1,5 @@ package org.rumbledb.types; -import java.util.Map; import org.rumbledb.api.Item; public class FieldDescriptor { diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 4ff328fec0..60ddfa12fa 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -400,8 +400,8 @@ default UnionContentDescriptor getUnionContentFacet() { * * @return a String that uniquely identify an item type */ - default String getIdentifierString(){ - if(this.hasName()){ + default String getIdentifierString() { + if (this.hasName()) { return this.getName().toString(); } throw new UnsupportedOperationException("default implementation of uniqueString always requires a Name"); diff --git a/src/main/java/org/rumbledb/types/ItemTypeFactory.java b/src/main/java/org/rumbledb/types/ItemTypeFactory.java index 01e6684897..d543ee20af 100644 --- a/src/main/java/org/rumbledb/types/ItemTypeFactory.java +++ b/src/main/java/org/rumbledb/types/ItemTypeFactory.java @@ -7,7 +7,6 @@ import org.rumbledb.context.Name; import org.rumbledb.items.parsing.ItemParser; -import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -22,16 +21,17 @@ public static FunctionItemType createFunctionItemType(FunctionSignature signatur /** * Create an object item type from a spark struct type (count as restriction on generic object type) + * * @param name of the new type (if null it is an anonymous type) * @param structType descriptor of the object * @return an object item type representing the type in Rumble */ - public static ObjectItemType createItemTypeFromSparkStructType(String name, StructType structType){ + public static ObjectItemType createItemTypeFromSparkStructType(String name, StructType structType) { // TODO : handle type registration // TODO : identical anonymous types should be equivalent? Name objectName = name != null && !name.equals("") ? Name.createVariableInDefaultTypeNamespace(name) : null; Map content = new HashMap<>(); - for (StructField field : structType.fields()){ + for (StructField field : structType.fields()) { DataType filedType = field.dataType(); ItemType mappedItemType; if (filedType instanceof StructType) { diff --git a/src/main/java/org/rumbledb/types/ObjectItemType.java b/src/main/java/org/rumbledb/types/ObjectItemType.java index 81bc0c7c0e..3c53eb582e 100644 --- a/src/main/java/org/rumbledb/types/ObjectItemType.java +++ b/src/main/java/org/rumbledb/types/ObjectItemType.java @@ -135,7 +135,7 @@ public boolean getClosedFacet() { @Override public String getIdentifierString() { - if(this.hasName()){ + if (this.hasName()) { return this.name.toString(); } StringBuilder sb = new StringBuilder(); @@ -143,16 +143,16 @@ public String getIdentifierString() { sb.append(this.baseType.getIdentifierString()); sb.append("}"); sb.append(this.isClosed ? "-c" : "-nc"); - if(this.content != null){ + if (this.content != null) { sb.append("-content{"); String comma = ""; - for(FieldDescriptor fd : this.content.values()){ + for (FieldDescriptor fd : this.content.values()) { sb.append(comma); sb.append(fd.getName()); sb.append(fd.isRequired() ? "(r):" : "(nr):"); sb.append(fd.getType().getIdentifierString()); Item dv = fd.getDefaultValue(); - if(dv != null){ + if (dv != null) { sb.append("(def:"); sb.append(dv.serialize()); sb.append(")"); @@ -163,20 +163,20 @@ public String getIdentifierString() { } sb.append("}"); } - if(this.enumeration != null){ + if (this.enumeration != null) { sb.append("-enum{"); String comma = ""; - for(Item item : this.enumeration){ + for (Item item : this.enumeration) { sb.append(comma); sb.append(item.serialize()); comma = ","; } sb.append("}"); } - if(this.constraints.size() > 0){ + if (this.constraints.size() > 0) { sb.append("-const{"); String comma = ""; - for(String c : this.constraints){ + for (String c : this.constraints) { sb.append(comma); sb.append("\""); sb.append(c); @@ -190,7 +190,7 @@ public String getIdentifierString() { @Override public String toString() { - if((new Name(Name.JS_NS, "js", "object")).equals(this.name)){ + if ((new Name(Name.JS_NS, "js", "object")).equals(this.name)) { // generic object return this.name.toString(); } else { @@ -203,13 +203,13 @@ public String toString() { sb.append("\n"); List fields = new ArrayList<>(this.getObjectContentFacet().values()); - if(fields.size() > 0){ - sb.append("content facet:\n"); + if (fields.size() > 0) { + sb.append("content facet:\n"); String comma = ""; - for(FieldDescriptor field : fields){ + for (FieldDescriptor field : fields) { sb.append(" "); sb.append(field.getName()); - if(field.isRequired()){ + if (field.isRequired()) { sb.append(" (required)"); } sb.append(" : "); diff --git a/src/main/java/org/rumbledb/types/UnionItemType.java b/src/main/java/org/rumbledb/types/UnionItemType.java index f45651c45e..5c4194bf70 100644 --- a/src/main/java/org/rumbledb/types/UnionItemType.java +++ b/src/main/java/org/rumbledb/types/UnionItemType.java @@ -2,7 +2,6 @@ import org.apache.spark.sql.types.DataType; import org.apache.spark.sql.types.DataTypes; -import org.rumbledb.api.Item; import org.rumbledb.context.Name; import java.util.Arrays; @@ -92,17 +91,17 @@ public UnionContentDescriptor getUnionContentFacet() { @Override public String getIdentifierString() { - if(this.hasName()){ + if (this.hasName()) { return this.name.toString(); } StringBuilder sb = new StringBuilder(); sb.append("#anonymous-union-base{"); sb.append(this.baseType.getIdentifierString()); sb.append("}"); - if(this.content != null){ + if (this.content != null) { sb.append("-content{"); String comma = ""; - for(ItemType it : this.content.getTypes()){ + for (ItemType it : this.content.getTypes()) { sb.append(comma); sb.append(it.getIdentifierString()); comma = ","; From 986cd4b123d1ea0c06b397bba06080530d8856d7 Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 30 Mar 2021 22:14:54 +0200 Subject: [PATCH 189/206] solved conflicts and passing all tests --- .../org/rumbledb/context/BuiltinFunctionCatalogue.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/rumbledb/context/BuiltinFunctionCatalogue.java b/src/main/java/org/rumbledb/context/BuiltinFunctionCatalogue.java index 65f8c92d84..11a5ebf376 100644 --- a/src/main/java/org/rumbledb/context/BuiltinFunctionCatalogue.java +++ b/src/main/java/org/rumbledb/context/BuiltinFunctionCatalogue.java @@ -857,8 +857,8 @@ private static BuiltinFunction createBuiltinFunction( "math", "round" ), - "numeric?", - "numeric?", + "double?", + "double?", RoundFunctionIterator.class, BuiltinFunction.BuiltinFunctionExecutionMode.LOCAL ); @@ -868,9 +868,9 @@ private static BuiltinFunction createBuiltinFunction( "math", "round" ), - "numeric?", + "double?", "integer", - "numeric?", + "double?", RoundFunctionIterator.class, BuiltinFunction.BuiltinFunctionExecutionMode.LOCAL ); From 048b44ae21258606f0dd895b37bc591a94696f4e Mon Sep 17 00:00:00 2001 From: Mario Arduini Date: Tue, 30 Mar 2021 22:39:47 +0200 Subject: [PATCH 190/206] spotless --- src/main/java/org/rumbledb/compiler/InferTypeVisitor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java index 5c8266b0bc..bb68c301ba 100644 --- a/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java +++ b/src/main/java/org/rumbledb/compiler/InferTypeVisitor.java @@ -39,7 +39,6 @@ import java.net.URI; import org.rumbledb.types.*; -import org.rumbledb.types.AtomicItemType; import java.util.*; import java.util.stream.Collectors; From 05a6b511e1f79098344455fb8aae592113123d24 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 8 Apr 2021 16:36:24 +0200 Subject: [PATCH 191/206] Fix imports. --- .../java/org/rumbledb/runtime/RuntimeIterator.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java index 3fa21e477e..799fb05a41 100644 --- a/src/main/java/org/rumbledb/runtime/RuntimeIterator.java +++ b/src/main/java/org/rumbledb/runtime/RuntimeIterator.java @@ -40,12 +40,18 @@ import org.rumbledb.context.DynamicContext; import org.rumbledb.context.Name; import org.rumbledb.context.StaticContext; -import org.rumbledb.exceptions.*; +import org.rumbledb.exceptions.ExceptionMetadata; +import org.rumbledb.exceptions.InvalidArgumentTypeException; +import org.rumbledb.exceptions.IteratorFlowException; +import org.rumbledb.exceptions.MoreThanOneItemException; +import org.rumbledb.exceptions.NoItemException; +import org.rumbledb.exceptions.OurBadException; +import org.rumbledb.exceptions.RumbleException; import org.rumbledb.expressions.ExecutionMode; -import org.rumbledb.runtime.flwor.NativeClauseContext; -import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.expressions.comparison.ComparisonExpression.ComparisonOperator; +import org.rumbledb.runtime.flwor.NativeClauseContext; import org.rumbledb.runtime.misc.ComparisonIterator; +import org.rumbledb.types.BuiltinTypesCatalogue; import com.esotericsoftware.kryo.Kryo; import com.esotericsoftware.kryo.KryoSerializable; From c6cfe1c8e356676c24eb8d053cf301abf0a264e1 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 8 Apr 2021 16:36:55 +0200 Subject: [PATCH 192/206] Fix imports. --- .../java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java index 23e0a03c11..43109e3ae6 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java +++ b/src/main/java/org/rumbledb/runtime/flwor/FlworDataFrameUtils.java @@ -43,15 +43,11 @@ import org.apache.spark.sql.RowFactory; import org.apache.spark.sql.expressions.UserDefinedFunction; import org.apache.spark.sql.expressions.Window; -<<<<<<< HEAD -import org.apache.spark.sql.types.*; -======= import org.apache.spark.sql.types.ArrayType; import org.apache.spark.sql.types.DataType; import org.apache.spark.sql.types.DataTypes; import org.apache.spark.sql.types.StructField; import org.apache.spark.sql.types.StructType; ->>>>>>> dea920b2842c10684ade1a2e6ebc1232916dd5b1 import org.rumbledb.api.Item; import org.rumbledb.config.RumbleRuntimeConfiguration; import org.rumbledb.context.DynamicContext; From 9d3c0c236e5fecdd2582f65e0109edc66e6a35d8 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 8 Apr 2021 16:37:53 +0200 Subject: [PATCH 193/206] Fix diff. --- src/test/java/iq/StaticTypeTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/iq/StaticTypeTests.java b/src/test/java/iq/StaticTypeTests.java index c90b2161d1..10342d6d78 100644 --- a/src/test/java/iq/StaticTypeTests.java +++ b/src/test/java/iq/StaticTypeTests.java @@ -1,6 +1,7 @@ package iq; import org.rumbledb.config.RumbleRuntimeConfiguration; + import iq.base.AnnotationsTestsBase; import scala.util.Properties; From 89591c5126055b5d953f688f19bb42234c682a94 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Thu, 8 Apr 2021 16:38:35 +0200 Subject: [PATCH 194/206] Take over from master. --- .../org/rumbledb/context/BuiltinFunctionCatalogue.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/rumbledb/context/BuiltinFunctionCatalogue.java b/src/main/java/org/rumbledb/context/BuiltinFunctionCatalogue.java index 50673d95d4..ebfa8dfb33 100644 --- a/src/main/java/org/rumbledb/context/BuiltinFunctionCatalogue.java +++ b/src/main/java/org/rumbledb/context/BuiltinFunctionCatalogue.java @@ -857,8 +857,8 @@ private static BuiltinFunction createBuiltinFunction( "math", "round" ), - "double?", - "double?", + "numeric?", + "numeric?", RoundFunctionIterator.class, BuiltinFunction.BuiltinFunctionExecutionMode.LOCAL ); @@ -868,9 +868,9 @@ private static BuiltinFunction createBuiltinFunction( "math", "round" ), - "double?", + "numeric?", "integer", - "double?", + "numeric?", RoundFunctionIterator.class, BuiltinFunction.BuiltinFunctionExecutionMode.LOCAL ); From d8f6375e62555d662330c9936ae33b9842f11182 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Fri, 9 Apr 2021 11:04:47 +0200 Subject: [PATCH 195/206] Revert catalogue. --- .../rumbledb/types/BuiltinTypesCatalogue.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java b/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java index 22a8c1ffea..e2db12271c 100644 --- a/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java +++ b/src/main/java/org/rumbledb/types/BuiltinTypesCatalogue.java @@ -7,10 +7,10 @@ import java.util.List; public class BuiltinTypesCatalogue { - public static final ItemType item = AtomicItemType.item; + public static final ItemType item = ItemItemType.item; public static final ItemType atomicItem = AtomicItemType.atomicItem; public static final ItemType stringItem = AtomicItemType.stringItem; - public static final ItemType integerItem = AtomicItemType.integerItem; + public static final ItemType integerItem = DerivedAtomicItemType.integerItem; public static final ItemType decimalItem = AtomicItemType.decimalItem; public static final ItemType doubleItem = AtomicItemType.doubleItem; public static final ItemType floatItem = AtomicItemType.floatItem; @@ -25,11 +25,13 @@ public class BuiltinTypesCatalogue { public static final ItemType hexBinaryItem = AtomicItemType.hexBinaryItem; public static final ItemType anyURIItem = AtomicItemType.anyURIItem; public static final ItemType base64BinaryItem = AtomicItemType.base64BinaryItem; - public static final ItemType intItem = AtomicItemType.intItem; - public static final ItemType arrayItem = AtomicItemType.arrayItem; - public static final ItemType objectItem = AtomicItemType.objectItem; - public static final ItemType anyFunctionItem = AtomicItemType.functionItem; - public static final ItemType JSONItem = AtomicItemType.JSONItem; + public static final ItemType JSONItem = JsonItemType.jsonItem; + public static final ItemType objectItem = ObjectItemType.anyObjectItem; + public static final ItemType arrayItem = ArrayItemType.anyArrayItem; + public static final ItemType longItem = DerivedAtomicItemType.longItem; + public static final ItemType intItem = DerivedAtomicItemType.intItem; + public static final ItemType shortItem = DerivedAtomicItemType.shortItem; + public static final ItemType anyFunctionItem = FunctionItemType.anyFunctionItem; public static boolean typeExists(Name name) { for (ItemType builtInItemType : builtInItemTypes) { @@ -47,6 +49,7 @@ public static boolean typeExists(Name name) { } private static final List builtInItemTypes = Arrays.asList( + objectItem, atomicItem, stringItem, integerItem, @@ -55,7 +58,9 @@ public static boolean typeExists(Name name) { doubleItem, floatItem, booleanItem, + arrayItem, nullItem, + JSONItem, durationItem, yearMonthDurationItem, dayTimeDurationItem, @@ -65,7 +70,9 @@ public static boolean typeExists(Name name) { hexBinaryItem, anyURIItem, base64BinaryItem, - item + item, + longItem, + shortItem ); public static ItemType getItemTypeByName(Name name) { From bbdb916491d6a81987b117b343887a265010599a Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Mon, 12 Apr 2021 13:26:10 +0200 Subject: [PATCH 196/206] Fix. --- src/main/java/org/rumbledb/types/ItemType.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/main/java/org/rumbledb/types/ItemType.java b/src/main/java/org/rumbledb/types/ItemType.java index 3781563b0f..2f14aa9981 100644 --- a/src/main/java/org/rumbledb/types/ItemType.java +++ b/src/main/java/org/rumbledb/types/ItemType.java @@ -415,20 +415,4 @@ default DataType toDataFrameType() { "toDataFrameType method is not supported for " + this.toString() + " item types" ); } - - public boolean isFunctionItemType() { - return false; - } - - public int getTypeTreeDepth() { - throw new UnsupportedOperationException("getTypeTreeDepth not implemented."); - } - - public ItemType getBaseType() { - throw new UnsupportedOperationException("getBaseType not implemented."); - } - - public String getIdentifierString() { - throw new UnsupportedOperationException("getIdentifierString not implemented."); - } } From a1e5ff439b97a8f7887dd53ed753576623047f7e Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Mon, 12 Apr 2021 13:26:58 +0200 Subject: [PATCH 197/206] Restore file. --- src/main/java/org/rumbledb/types/SequenceType.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/rumbledb/types/SequenceType.java b/src/main/java/org/rumbledb/types/SequenceType.java index 29de1c765f..04d7468b4a 100644 --- a/src/main/java/org/rumbledb/types/SequenceType.java +++ b/src/main/java/org/rumbledb/types/SequenceType.java @@ -311,6 +311,12 @@ public String toString() { sequenceTypes.put("float", new SequenceType(BuiltinTypesCatalogue.floatItem, SequenceType.Arity.One)); sequenceTypes.put("float?", new SequenceType(BuiltinTypesCatalogue.floatItem, SequenceType.Arity.OneOrZero)); + sequenceTypes.put("numeric", new SequenceType(BuiltinTypesCatalogue.numericItem, SequenceType.Arity.One)); + sequenceTypes.put( + "numeric?", + new SequenceType(BuiltinTypesCatalogue.numericItem, SequenceType.Arity.OneOrZero) + ); + sequenceTypes.put("boolean", new SequenceType(BuiltinTypesCatalogue.booleanItem, SequenceType.Arity.One)); sequenceTypes.put( "boolean?", From 87948c4278635ec2023deb10c1b806f4feb11860 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Mon, 12 Apr 2021 13:27:46 +0200 Subject: [PATCH 198/206] Restore. --- src/test/java/iq/FrontendTests.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/java/iq/FrontendTests.java b/src/test/java/iq/FrontendTests.java index b4fa269ec0..2f334ac621 100644 --- a/src/test/java/iq/FrontendTests.java +++ b/src/test/java/iq/FrontendTests.java @@ -21,6 +21,7 @@ package iq; +import iq.base.AnnotationsTestsBase; import org.junit.Assert; import org.junit.Test; import org.rumbledb.compiler.VisitorHelpers; @@ -31,9 +32,6 @@ import org.rumbledb.expressions.primary.VariableReferenceExpression; import org.rumbledb.runtime.functions.input.FileSystemUtil; import org.rumbledb.types.BuiltinTypesCatalogue; - -import iq.base.AnnotationsTestsBase; - import java.io.File; import java.net.URI; import java.util.Arrays; From 3e0eb053c434526306c5c37017bc76db72155b50 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Mon, 12 Apr 2021 13:28:06 +0200 Subject: [PATCH 199/206] Restore. --- .../java/org/rumbledb/compiler/XQueryTranslationVisitor.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/rumbledb/compiler/XQueryTranslationVisitor.java b/src/main/java/org/rumbledb/compiler/XQueryTranslationVisitor.java index 99f485aa76..367f036853 100644 --- a/src/main/java/org/rumbledb/compiler/XQueryTranslationVisitor.java +++ b/src/main/java/org/rumbledb/compiler/XQueryTranslationVisitor.java @@ -33,7 +33,6 @@ import org.rumbledb.expressions.typing.TreatExpression; import org.rumbledb.parser.XQueryParser; import org.rumbledb.runtime.functions.input.FileSystemUtil; -import org.rumbledb.types.AtomicItemType; import org.rumbledb.types.BuiltinTypesCatalogue; import org.rumbledb.types.ItemType; import org.rumbledb.types.SequenceType; @@ -745,7 +744,9 @@ private ItemType processItemType(XQueryParser.ItemTypeContext ctx) { else return BuiltinTypesCatalogue.arrayItem; } else if (child instanceof XQueryParser.AtomicOrUnionTypeContext) { - return BuiltinTypesCatalogue.getItemTypeByName(parseName(ctx.atomicOrUnionType().eqName().qName(), false, true)); + return BuiltinTypesCatalogue.getItemTypeByName( + parseName(ctx.atomicOrUnionType().eqName().qName(), false, true) + ); } else if (child instanceof XQueryParser.ParenthesizedItemTestContext) { return processItemType(((XQueryParser.ParenthesizedItemTestContext) child).itemType()); } else { From 874161b212517bd2d0800c537f0f804dbc3523b4 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Mon, 12 Apr 2021 13:32:47 +0200 Subject: [PATCH 200/206] Restore. --- src/main/java/org/rumbledb/types/ObjectItemType.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/types/ObjectItemType.java b/src/main/java/org/rumbledb/types/ObjectItemType.java index 3c53eb582e..13b609f898 100644 --- a/src/main/java/org/rumbledb/types/ObjectItemType.java +++ b/src/main/java/org/rumbledb/types/ObjectItemType.java @@ -8,6 +8,8 @@ public class ObjectItemType implements ItemType { + private static final long serialVersionUID = 1L; + final static ObjectItemType anyObjectItem = new ObjectItemType( new Name(Name.JS_NS, "js", "object"), BuiltinTypesCatalogue.JSONItem, @@ -109,6 +111,7 @@ public List getEnumerationFacet() { return this.enumeration != null || this.isPrimitive() ? this.enumeration : this.baseType.getEnumerationFacet(); } + @SuppressWarnings("unchecked") @Override public List getConstraintsFacet() { return this.isPrimitive() @@ -205,7 +208,7 @@ public String toString() { List fields = new ArrayList<>(this.getObjectContentFacet().values()); if (fields.size() > 0) { sb.append("content facet:\n"); - String comma = ""; + // String comma = ""; for (FieldDescriptor field : fields) { sb.append(" "); sb.append(field.getName()); From ceda4749aec66e3b802d469d9675b3086553e170 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Mon, 12 Apr 2021 13:34:00 +0200 Subject: [PATCH 201/206] Restore. --- src/main/java/org/rumbledb/types/DerivedAtomicItemType.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java index c0c3b9549e..38faed5fb2 100644 --- a/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java +++ b/src/main/java/org/rumbledb/types/DerivedAtomicItemType.java @@ -14,6 +14,8 @@ public class DerivedAtomicItemType implements ItemType { + private static final long serialVersionUID = 1L; + static final DerivedAtomicItemType integerItem = new DerivedAtomicItemType( new Name(Name.XS_NS, "xs", "integer"), AtomicItemType.decimalItem, @@ -192,6 +194,7 @@ public List getEnumerationFacet() { return this.enumeration == null ? this.baseType.getEnumerationFacet() : this.enumeration; } + @SuppressWarnings("unchecked") @Override public List getConstraintsFacet() { if (!this.getAllowedFacets().contains(FacetTypes.CONSTRAINTS)) { From 3e259cd5851c54bd111f62f64829679ff19d4f6b Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Mon, 12 Apr 2021 13:34:11 +0200 Subject: [PATCH 202/206] Fix. --- src/main/java/org/rumbledb/types/FunctionItemType.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index 526b46d50b..b41c42cfac 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -81,14 +81,11 @@ public ItemType getBaseType() { } @Override -<<<<<<< HEAD public Set getAllowedFacets() { throw new UnsupportedOperationException("function item types does not support facets"); } @Override -======= ->>>>>>> ad48168f27446dca37ad4a33ebb3cb1a7cb5df7e public String getIdentifierString() { return this.toString(); } From e0d68edd117d12fbbab71d0a961b620a610905d6 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Mon, 12 Apr 2021 13:35:05 +0200 Subject: [PATCH 203/206] Fix. --- .../org/rumbledb/types/AtomicItemType.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/types/AtomicItemType.java b/src/main/java/org/rumbledb/types/AtomicItemType.java index e61542a740..d83c0de089 100644 --- a/src/main/java/org/rumbledb/types/AtomicItemType.java +++ b/src/main/java/org/rumbledb/types/AtomicItemType.java @@ -20,6 +20,11 @@ public class AtomicItemType implements ItemType { Collections.emptySet(), DataTypes.BinaryType ); + static final AtomicItemType numericItem = new AtomicItemType( + new Name(Name.JS_NS, "js", "numeric"), + Collections.emptySet(), + DataTypes.BinaryType + ); static final AtomicItemType stringItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "string"), new HashSet<>( @@ -78,6 +83,7 @@ public class AtomicItemType implements ItemType { ), DataTypes.FloatType ); + static final AtomicItemType booleanItem = new AtomicItemType( new Name(Name.XS_NS, "xs", "boolean"), new HashSet<>(Arrays.asList(FacetTypes.ENUMERATION, FacetTypes.CONSTRAINTS)), @@ -255,6 +261,10 @@ public Name getName() { public int getTypeTreeDepth() { if (this.equals(atomicItem)) { return 1; + } else if (this.equals(numericItem)) { + return 2; + } else if (this.isNumeric()) { + return 3; } else if (this.equals(yearMonthDurationItem) || this.equals(dayTimeDurationItem)) { // TODO : check once you remove derived like integer and int return 3; @@ -267,6 +277,10 @@ public int getTypeTreeDepth() { public ItemType getBaseType() { if (this.equals(atomicItem)) { return BuiltinTypesCatalogue.item; + } else if (this.equals(numericItem)) { + return atomicItem; + } else if (this.isNumeric()) { + return numericItem; } else if (this.equals(yearMonthDurationItem) || this.equals(dayTimeDurationItem)) { return durationItem; } else { @@ -339,7 +353,10 @@ public boolean isStaticallyCastableAs(ItemType other) { @Override public boolean isNumeric() { - return this.equals(decimalItem) || this.equals(floatItem) || this.equals(doubleItem); + return this.equals(decimalItem) + || this.equals(floatItem) + || this.equals(doubleItem) + || this.equals(numericItem); } @Override From 1553bc5debe695aab0f52a1d48e4d0eaaf58ed78 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Mon, 12 Apr 2021 13:36:09 +0200 Subject: [PATCH 204/206] Fix warnings. --- src/main/java/org/rumbledb/types/ArrayItemType.java | 2 ++ src/main/java/org/rumbledb/types/FunctionItemType.java | 1 - src/main/java/org/rumbledb/types/UnionItemType.java | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rumbledb/types/ArrayItemType.java b/src/main/java/org/rumbledb/types/ArrayItemType.java index 62ed6fec8d..69a1963211 100644 --- a/src/main/java/org/rumbledb/types/ArrayItemType.java +++ b/src/main/java/org/rumbledb/types/ArrayItemType.java @@ -7,6 +7,8 @@ public class ArrayItemType implements ItemType { + private static final long serialVersionUID = 1L; + final static ArrayItemType anyArrayItem = new ArrayItemType( new Name(Name.JS_NS, "js", "array"), BuiltinTypesCatalogue.JSONItem, diff --git a/src/main/java/org/rumbledb/types/FunctionItemType.java b/src/main/java/org/rumbledb/types/FunctionItemType.java index b41c42cfac..6c3f406794 100644 --- a/src/main/java/org/rumbledb/types/FunctionItemType.java +++ b/src/main/java/org/rumbledb/types/FunctionItemType.java @@ -8,7 +8,6 @@ public class FunctionItemType implements ItemType { private static final long serialVersionUID = 1L; - @SuppressWarnings("unused") private final boolean isGeneric; private final FunctionSignature signature; diff --git a/src/main/java/org/rumbledb/types/UnionItemType.java b/src/main/java/org/rumbledb/types/UnionItemType.java index 5c4194bf70..d585c44e28 100644 --- a/src/main/java/org/rumbledb/types/UnionItemType.java +++ b/src/main/java/org/rumbledb/types/UnionItemType.java @@ -10,6 +10,8 @@ public class UnionItemType implements ItemType { + private static final long serialVersionUID = 1L; + private static Set allowedFacets = new HashSet<>(Arrays.asList(FacetTypes.CONTENT)); private final Name name; From ca7c59f82d22123e706190ae540b0f3852c69277 Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Tue, 13 Apr 2021 15:02:46 +0200 Subject: [PATCH 205/206] Take over. --- .../runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java | 1 + .../java/org/rumbledb/runtime/typing/CastableIterator.java | 1 - .../java/org/rumbledb/runtime/typing/InstanceOfIterator.java | 5 ++++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java b/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java index fd8ef0d3a5..8c79008159 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java +++ b/src/main/java/org/rumbledb/runtime/flwor/udfs/OrderClauseCreateColumnsUDF.java @@ -34,6 +34,7 @@ import org.rumbledb.runtime.RuntimeIterator; import org.rumbledb.runtime.flwor.expression.OrderByClauseAnnotatedChildIterator; import org.rumbledb.types.BuiltinTypesCatalogue; + import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java b/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java index 184e95707c..0814eaad6d 100644 --- a/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/CastableIterator.java @@ -58,7 +58,6 @@ public Item materializeFirstItemOrNull( ); } - static void checkInvalidCastable(Item item, ExceptionMetadata metadata, ItemType type) { if (type.equals(BuiltinTypesCatalogue.atomicItem)) { throw new CastableException("\"atomic\": invalid type for \"cast\" or \"castable\" expression", metadata); diff --git a/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java b/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java index 78605f1d4f..fc55a9db2f 100644 --- a/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java +++ b/src/main/java/org/rumbledb/runtime/typing/InstanceOfIterator.java @@ -144,6 +144,9 @@ public static boolean doesItemTypeMatchItem(ItemType itemType, Item itemToMatch) if (itemType.equals(BuiltinTypesCatalogue.floatItem)) { return itemToMatch.isFloat(); } + if (itemType.equals(BuiltinTypesCatalogue.numericItem)) { + return itemToMatch.isNumeric(); + } if (itemType.equals(BuiltinTypesCatalogue.booleanItem)) { return itemToMatch.isBoolean(); } @@ -183,7 +186,7 @@ public static boolean doesItemTypeMatchItem(ItemType itemType, Item itemToMatch) if (itemType.equals(BuiltinTypesCatalogue.base64BinaryItem)) { return itemToMatch.isBase64Binary(); } - if (itemType.isFunctionItemType()) { + if (itemType.equals(BuiltinTypesCatalogue.anyFunctionItem)) { return itemToMatch.isFunction(); } throw new OurBadException("Type unrecognized: " + itemType); From 0c9ca798cdc0afd9ad090aecf1a616f5a4495a3a Mon Sep 17 00:00:00 2001 From: Ghislain Fourny Date: Tue, 13 Apr 2021 15:03:29 +0200 Subject: [PATCH 206/206] Fix. --- .../runtime/flwor/clauses/ForClauseSparkIterator.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java index 9660b815f6..cfd1c6a501 100644 --- a/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java +++ b/src/main/java/org/rumbledb/runtime/flwor/clauses/ForClauseSparkIterator.java @@ -1234,15 +1234,10 @@ public static Dataset tryNativeQuery( if (nativeQuery == NativeClauseContext.NoNativeQuery) { return null; } -<<<<<<< HEAD - System.out.println("native query returned " + nativeQuery.getResultingQuery()); - System.out.println("lateral view part is " + nativeQuery.getLateralViewPart()); -======= System.out.println( "[INFO] Rumble was able to optimize a for clause to a native SQL query: " + nativeQuery.getResultingQuery() ); System.out.println("[INFO] (the lateral view part is " + nativeQuery.getLateralViewPart() + ")"); ->>>>>>> 96333dd468abad903856f85c915c8c6e4e94942d String selectSQL = FlworDataFrameUtils.getSQLProjection(allColumns, true); dataFrame.createOrReplaceTempView("input");