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 extends T> visitor) {
+ if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor extends T>)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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> 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 extends T> visitor) {
- if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor extends T>)visitor).visitStaticallyIsExpr(this);
+ if ( visitor instanceof JsoniqVisitor ) return ((JsoniqVisitor extends T>)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