From b530d7ce3ce43349ce16eb477a31748755744ab5 Mon Sep 17 00:00:00 2001 From: Zahid Hossain <60911932+zhossain-info@users.noreply.github.com> Date: Mon, 19 Feb 2024 22:00:49 +0600 Subject: [PATCH 01/12] Add data type interfaces for script and schema --- .../com/relogiclabs/jschema/type/EArray.java | 17 +++++++++ .../relogiclabs/jschema/type/EBoolean.java | 15 ++++++++ .../com/relogiclabs/jschema/type/EDouble.java | 15 ++++++++ .../relogiclabs/jschema/type/EInteger.java | 15 ++++++++ .../com/relogiclabs/jschema/type/ENull.java | 21 +++++++++++ .../com/relogiclabs/jschema/type/ENumber.java | 10 ++++++ .../com/relogiclabs/jschema/type/EObject.java | 14 ++++++++ .../com/relogiclabs/jschema/type/EString.java | 14 ++++++++ .../com/relogiclabs/jschema/type/EType.java | 36 +++++++++++++++++++ .../relogiclabs/jschema/type/EUndefined.java | 21 +++++++++++ .../com/relogiclabs/jschema/type/EValue.java | 28 +++++++++++++++ 11 files changed, 206 insertions(+) create mode 100644 src/main/java/com/relogiclabs/jschema/type/EArray.java create mode 100644 src/main/java/com/relogiclabs/jschema/type/EBoolean.java create mode 100644 src/main/java/com/relogiclabs/jschema/type/EDouble.java create mode 100644 src/main/java/com/relogiclabs/jschema/type/EInteger.java create mode 100644 src/main/java/com/relogiclabs/jschema/type/ENull.java create mode 100644 src/main/java/com/relogiclabs/jschema/type/ENumber.java create mode 100644 src/main/java/com/relogiclabs/jschema/type/EObject.java create mode 100644 src/main/java/com/relogiclabs/jschema/type/EString.java create mode 100644 src/main/java/com/relogiclabs/jschema/type/EType.java create mode 100644 src/main/java/com/relogiclabs/jschema/type/EUndefined.java create mode 100644 src/main/java/com/relogiclabs/jschema/type/EValue.java diff --git a/src/main/java/com/relogiclabs/jschema/type/EArray.java b/src/main/java/com/relogiclabs/jschema/type/EArray.java new file mode 100644 index 0000000..12d33e8 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/type/EArray.java @@ -0,0 +1,17 @@ +package com.relogiclabs.jschema.type; + +import java.util.List; + +public interface EArray extends EValue { + EValue get(int index); + List elements(); + + default int size() { + return elements().size(); + } + + @Override + default EType getType() { + return EType.ARRAY; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/type/EBoolean.java b/src/main/java/com/relogiclabs/jschema/type/EBoolean.java new file mode 100644 index 0000000..4e831e8 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/type/EBoolean.java @@ -0,0 +1,15 @@ +package com.relogiclabs.jschema.type; + +public interface EBoolean extends EValue { + boolean getValue(); + + @Override + default boolean toBoolean() { + return getValue(); + } + + @Override + default EType getType() { + return EType.BOOLEAN; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/type/EDouble.java b/src/main/java/com/relogiclabs/jschema/type/EDouble.java new file mode 100644 index 0000000..7503632 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/type/EDouble.java @@ -0,0 +1,15 @@ +package com.relogiclabs.jschema.type; + +public interface EDouble extends ENumber { + double getValue(); + + @Override + default double toDouble() { + return getValue(); + } + + @Override + default EType getType() { + return EType.DOUBLE; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/type/EInteger.java b/src/main/java/com/relogiclabs/jschema/type/EInteger.java new file mode 100644 index 0000000..09b7fef --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/type/EInteger.java @@ -0,0 +1,15 @@ +package com.relogiclabs.jschema.type; + +public interface EInteger extends ENumber { + long getValue(); + + @Override + default double toDouble() { + return getValue(); + } + + @Override + default EType getType() { + return EType.INTEGER; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/type/ENull.java b/src/main/java/com/relogiclabs/jschema/type/ENull.java new file mode 100644 index 0000000..926ce3d --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/type/ENull.java @@ -0,0 +1,21 @@ +package com.relogiclabs.jschema.type; + +public interface ENull extends EValue { + String STRING = "null"; + ENull NULL = new ENull() { + @Override + public String toString() { + return STRING; + } + }; + + @Override + default EType getType() { + return EType.NULL; + } + + @Override + default boolean toBoolean() { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/type/ENumber.java b/src/main/java/com/relogiclabs/jschema/type/ENumber.java new file mode 100644 index 0000000..371e15f --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/type/ENumber.java @@ -0,0 +1,10 @@ +package com.relogiclabs.jschema.type; + +public interface ENumber extends EValue { + double toDouble(); + + @Override + default EType getType() { + return EType.NUMBER; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/type/EObject.java b/src/main/java/com/relogiclabs/jschema/type/EObject.java new file mode 100644 index 0000000..a013a56 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/type/EObject.java @@ -0,0 +1,14 @@ +package com.relogiclabs.jschema.type; + +import java.util.Set; + +public interface EObject extends EValue { + EValue get(String key); + int size(); + Set keySet(); + + @Override + default EType getType() { + return EType.OBJECT; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/type/EString.java b/src/main/java/com/relogiclabs/jschema/type/EString.java new file mode 100644 index 0000000..83e96bf --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/type/EString.java @@ -0,0 +1,14 @@ +package com.relogiclabs.jschema.type; + +public interface EString extends EValue { + String getValue(); + + default int length() { + return getValue().length(); + } + + @Override + default EType getType() { + return EType.STRING; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/type/EType.java b/src/main/java/com/relogiclabs/jschema/type/EType.java new file mode 100644 index 0000000..63669d1 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/type/EType.java @@ -0,0 +1,36 @@ +package com.relogiclabs.jschema.type; + +import lombok.Getter; + +@Getter +public enum EType { + NUMBER("#number"), + INTEGER("#integer"), + FLOAT("#float"), + DOUBLE("#double"), + STRING("#string"), + ARRAY("#array"), + RANGE("#range"), + OBJECT("#object"), + BOOLEAN("#boolean"), + DATETIME("#datetime"), + DATE("#date"), + TIME("#time"), + PRIMITIVE("#primitive"), + COMPOSITE("#composite"), + ANY("#any"), + NULL("#null"), + UNDEFINED("#undefined"), + VOID("#void"); + + private final String name; + + EType(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/type/EUndefined.java b/src/main/java/com/relogiclabs/jschema/type/EUndefined.java new file mode 100644 index 0000000..2168524 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/type/EUndefined.java @@ -0,0 +1,21 @@ +package com.relogiclabs.jschema.type; + +public interface EUndefined extends EValue { + String STRING = "undefined"; + EUndefined UNDEFINED = new EUndefined() { + @Override + public String toString() { + return STRING; + } + }; + + @Override + default EType getType() { + return EType.UNDEFINED; + } + + @Override + default boolean toBoolean() { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/type/EValue.java b/src/main/java/com/relogiclabs/jschema/type/EValue.java new file mode 100644 index 0000000..58dbf45 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/type/EValue.java @@ -0,0 +1,28 @@ +package com.relogiclabs.jschema.type; + +public interface EValue { + EValue VOID = new EValue() { + @Override + public EType getType() { + return EType.VOID; + } + + @Override + public boolean toBoolean() { + return false; + } + + @Override + public String toString() { + return EType.VOID.toString(); + } + }; + + default EType getType() { + return EType.ANY; + } + + default boolean toBoolean() { + return true; + } +} \ No newline at end of file From 333a9a0d3926b27cca88626b4bca37bbfcfb12a3 Mon Sep 17 00:00:00 2001 From: Zahid Hossain <60911932+zhossain-info@users.noreply.github.com> Date: Mon, 19 Feb 2024 22:26:55 +0600 Subject: [PATCH 02/12] Add and refactor exceptions for different errors --- .../ClassInstantiationException.java | 6 ++--- .../exception/CommonException.java | 24 +++++++++++++++++-- .../exception/DateTimeLexerException.java | 4 ++-- .../DefinitionNotFoundException.java | 6 ++--- .../DuplicateDefinitionException.java | 6 ++--- .../exception/DuplicateImportException.java | 9 +++++++ .../exception/DuplicatePragmaException.java | 6 ++--- .../DuplicatePropertyKeyException.java | 6 ++--- .../exception/FunctionNotFoundException.java | 6 ++--- .../exception/InvalidDataTypeException.java | 6 ++--- .../exception/InvalidDateTimeException.java | 4 ++-- .../exception/InvalidFunctionException.java | 6 ++--- .../exception/InvalidImportException.java | 9 +++++++ .../InvalidPragmaValueException.java | 6 ++--- .../exception/JsonLexerException.java | 4 ++-- .../exception/JsonParserException.java | 2 +- .../exception/JsonSchemaException.java | 16 ++++++------- .../exception/MisplacedOptionalException.java | 4 ++-- .../exception/NoValueReceivedException.java | 4 ++-- .../exception/NotFoundClassException.java | 6 ++--- .../exception/PragmaNotFoundException.java | 6 ++--- .../exception/ReceiverNotFoundException.java | 4 ++-- .../exception/SchemaLexerException.java | 4 ++-- .../exception/SchemaParserException.java | 2 +- .../exception/ScriptArgumentException.java | 7 ++++++ .../exception/ScriptCommonException.java | 21 ++++++++++++++++ .../exception/ScriptFunctionException.java | 7 ++++++ .../exception/ScriptInitiatedException.java | 13 ++++++++++ .../exception/ScriptInvocationException.java | 20 ++++++++++++++++ .../exception/ScriptOperationException.java | 9 +++++++ .../exception/ScriptRuntimeException.java | 22 +++++++++++++++++ .../exception/ScriptTemplateException.java | 24 +++++++++++++++++++ .../exception/ScriptVariableException.java | 7 ++++++ .../exception/SystemOperationException.java | 9 +++++++ .../exception/TargetInvocationException.java | 4 ++-- 35 files changed, 238 insertions(+), 61 deletions(-) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/ClassInstantiationException.java (63%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/CommonException.java (56%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/DateTimeLexerException.java (79%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/DefinitionNotFoundException.java (60%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/DuplicateDefinitionException.java (60%) create mode 100644 src/main/java/com/relogiclabs/jschema/exception/DuplicateImportException.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/DuplicatePragmaException.java (59%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/DuplicatePropertyKeyException.java (60%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/FunctionNotFoundException.java (59%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/InvalidDataTypeException.java (59%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/InvalidDateTimeException.java (77%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/InvalidFunctionException.java (70%) create mode 100644 src/main/java/com/relogiclabs/jschema/exception/InvalidImportException.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/InvalidPragmaValueException.java (60%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/JsonLexerException.java (78%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/JsonParserException.java (79%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/JsonSchemaException.java (62%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/MisplacedOptionalException.java (60%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/NoValueReceivedException.java (59%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/NotFoundClassException.java (58%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/PragmaNotFoundException.java (58%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/ReceiverNotFoundException.java (60%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/SchemaLexerException.java (78%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/SchemaParserException.java (79%) create mode 100644 src/main/java/com/relogiclabs/jschema/exception/ScriptArgumentException.java create mode 100644 src/main/java/com/relogiclabs/jschema/exception/ScriptCommonException.java create mode 100644 src/main/java/com/relogiclabs/jschema/exception/ScriptFunctionException.java create mode 100644 src/main/java/com/relogiclabs/jschema/exception/ScriptInitiatedException.java create mode 100644 src/main/java/com/relogiclabs/jschema/exception/ScriptInvocationException.java create mode 100644 src/main/java/com/relogiclabs/jschema/exception/ScriptOperationException.java create mode 100644 src/main/java/com/relogiclabs/jschema/exception/ScriptRuntimeException.java create mode 100644 src/main/java/com/relogiclabs/jschema/exception/ScriptTemplateException.java create mode 100644 src/main/java/com/relogiclabs/jschema/exception/ScriptVariableException.java create mode 100644 src/main/java/com/relogiclabs/jschema/exception/SystemOperationException.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/exception/TargetInvocationException.java (79%) diff --git a/src/main/java/com/relogiclabs/json/schema/exception/ClassInstantiationException.java b/src/main/java/com/relogiclabs/jschema/exception/ClassInstantiationException.java similarity index 63% rename from src/main/java/com/relogiclabs/json/schema/exception/ClassInstantiationException.java rename to src/main/java/com/relogiclabs/jschema/exception/ClassInstantiationException.java index ea3c883..b1fdc8f 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/ClassInstantiationException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/ClassInstantiationException.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class ClassInstantiationException extends CommonException { public ClassInstantiationException(ErrorDetail detail, Throwable cause) { super(detail, cause); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/CommonException.java b/src/main/java/com/relogiclabs/jschema/exception/CommonException.java similarity index 56% rename from src/main/java/com/relogiclabs/json/schema/exception/CommonException.java rename to src/main/java/com/relogiclabs/jschema/exception/CommonException.java index 44e9b01..b558a6f 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/CommonException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/CommonException.java @@ -1,18 +1,22 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; import lombok.Getter; import java.util.HashMap; import java.util.Map; +import static java.util.Arrays.copyOfRange; + public class CommonException extends RuntimeException { + private static final String FAIL_METHOD_PREFIX = "fail"; @Getter private final String code; private Map attributes; public CommonException(String code, String message, Throwable cause) { super(message, cause); this.code = code; + formatStackTrace(); } public CommonException(String code, String message) { @@ -36,4 +40,20 @@ public void setAttribute(String name, String value) { if(attributes == null) attributes = new HashMap<>(5); attributes.put(name, value); } + + @Override + public synchronized Throwable fillInStackTrace() { + var result = super.fillInStackTrace(); + formatStackTrace(); + return result; + } + + private void formatStackTrace() { + StackTraceElement[] stackTrace = getStackTrace(); + int offset = 0; + for(var e : stackTrace) + if(e.getMethodName().startsWith(FAIL_METHOD_PREFIX)) offset++; + else break; + setStackTrace(copyOfRange(stackTrace, offset, stackTrace.length)); + } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/DateTimeLexerException.java b/src/main/java/com/relogiclabs/jschema/exception/DateTimeLexerException.java similarity index 79% rename from src/main/java/com/relogiclabs/json/schema/exception/DateTimeLexerException.java rename to src/main/java/com/relogiclabs/jschema/exception/DateTimeLexerException.java index 02bc319..9cab4a1 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/DateTimeLexerException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/DateTimeLexerException.java @@ -1,7 +1,7 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; public class DateTimeLexerException extends CommonException { public DateTimeLexerException(String code, String message, Throwable cause) { super(code, message, cause); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/DefinitionNotFoundException.java b/src/main/java/com/relogiclabs/jschema/exception/DefinitionNotFoundException.java similarity index 60% rename from src/main/java/com/relogiclabs/json/schema/exception/DefinitionNotFoundException.java rename to src/main/java/com/relogiclabs/jschema/exception/DefinitionNotFoundException.java index 5ce6464..c5e729f 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/DefinitionNotFoundException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/DefinitionNotFoundException.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class DefinitionNotFoundException extends CommonException { public DefinitionNotFoundException(ErrorDetail detail) { super(detail); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/DuplicateDefinitionException.java b/src/main/java/com/relogiclabs/jschema/exception/DuplicateDefinitionException.java similarity index 60% rename from src/main/java/com/relogiclabs/json/schema/exception/DuplicateDefinitionException.java rename to src/main/java/com/relogiclabs/jschema/exception/DuplicateDefinitionException.java index 2d313ec..24dd131 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/DuplicateDefinitionException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/DuplicateDefinitionException.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class DuplicateDefinitionException extends CommonException { public DuplicateDefinitionException(ErrorDetail detail) { super(detail); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/exception/DuplicateImportException.java b/src/main/java/com/relogiclabs/jschema/exception/DuplicateImportException.java new file mode 100644 index 0000000..8a6968b --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/exception/DuplicateImportException.java @@ -0,0 +1,9 @@ +package com.relogiclabs.jschema.exception; + +import com.relogiclabs.jschema.message.ErrorDetail; + +public class DuplicateImportException extends CommonException { + public DuplicateImportException(ErrorDetail detail) { + super(detail); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/DuplicatePragmaException.java b/src/main/java/com/relogiclabs/jschema/exception/DuplicatePragmaException.java similarity index 59% rename from src/main/java/com/relogiclabs/json/schema/exception/DuplicatePragmaException.java rename to src/main/java/com/relogiclabs/jschema/exception/DuplicatePragmaException.java index 785bca5..bdd9f6b 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/DuplicatePragmaException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/DuplicatePragmaException.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class DuplicatePragmaException extends CommonException { public DuplicatePragmaException(ErrorDetail detail) { super(detail); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/DuplicatePropertyKeyException.java b/src/main/java/com/relogiclabs/jschema/exception/DuplicatePropertyKeyException.java similarity index 60% rename from src/main/java/com/relogiclabs/json/schema/exception/DuplicatePropertyKeyException.java rename to src/main/java/com/relogiclabs/jschema/exception/DuplicatePropertyKeyException.java index 6c3d898..c1f9817 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/DuplicatePropertyKeyException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/DuplicatePropertyKeyException.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class DuplicatePropertyKeyException extends CommonException { public DuplicatePropertyKeyException(ErrorDetail detail) { super(detail); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/FunctionNotFoundException.java b/src/main/java/com/relogiclabs/jschema/exception/FunctionNotFoundException.java similarity index 59% rename from src/main/java/com/relogiclabs/json/schema/exception/FunctionNotFoundException.java rename to src/main/java/com/relogiclabs/jschema/exception/FunctionNotFoundException.java index fafb512..2dc29d6 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/FunctionNotFoundException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/FunctionNotFoundException.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class FunctionNotFoundException extends CommonException { public FunctionNotFoundException(ErrorDetail detail) { super(detail); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/InvalidDataTypeException.java b/src/main/java/com/relogiclabs/jschema/exception/InvalidDataTypeException.java similarity index 59% rename from src/main/java/com/relogiclabs/json/schema/exception/InvalidDataTypeException.java rename to src/main/java/com/relogiclabs/jschema/exception/InvalidDataTypeException.java index d23e979..e59fd94 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/InvalidDataTypeException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/InvalidDataTypeException.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class InvalidDataTypeException extends CommonException { public InvalidDataTypeException(ErrorDetail detail) { super(detail); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/InvalidDateTimeException.java b/src/main/java/com/relogiclabs/jschema/exception/InvalidDateTimeException.java similarity index 77% rename from src/main/java/com/relogiclabs/json/schema/exception/InvalidDateTimeException.java rename to src/main/java/com/relogiclabs/jschema/exception/InvalidDateTimeException.java index a981d15..183b85c 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/InvalidDateTimeException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/InvalidDateTimeException.java @@ -1,7 +1,7 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; public class InvalidDateTimeException extends CommonException { public InvalidDateTimeException(String code, String message) { super(code, message); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/InvalidFunctionException.java b/src/main/java/com/relogiclabs/jschema/exception/InvalidFunctionException.java similarity index 70% rename from src/main/java/com/relogiclabs/json/schema/exception/InvalidFunctionException.java rename to src/main/java/com/relogiclabs/jschema/exception/InvalidFunctionException.java index 7005ffc..236d916 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/InvalidFunctionException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/InvalidFunctionException.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class InvalidFunctionException extends CommonException { public InvalidFunctionException(String code, String message) { @@ -10,4 +10,4 @@ public InvalidFunctionException(String code, String message) { public InvalidFunctionException(ErrorDetail detail) { super(detail); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/exception/InvalidImportException.java b/src/main/java/com/relogiclabs/jschema/exception/InvalidImportException.java new file mode 100644 index 0000000..0146262 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/exception/InvalidImportException.java @@ -0,0 +1,9 @@ +package com.relogiclabs.jschema.exception; + +import com.relogiclabs.jschema.message.ErrorDetail; + +public class InvalidImportException extends CommonException { + public InvalidImportException(ErrorDetail detail) { + super(detail); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/InvalidPragmaValueException.java b/src/main/java/com/relogiclabs/jschema/exception/InvalidPragmaValueException.java similarity index 60% rename from src/main/java/com/relogiclabs/json/schema/exception/InvalidPragmaValueException.java rename to src/main/java/com/relogiclabs/jschema/exception/InvalidPragmaValueException.java index c8d7630..d7985c3 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/InvalidPragmaValueException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/InvalidPragmaValueException.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class InvalidPragmaValueException extends CommonException { public InvalidPragmaValueException(ErrorDetail detail) { super(detail); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/JsonLexerException.java b/src/main/java/com/relogiclabs/jschema/exception/JsonLexerException.java similarity index 78% rename from src/main/java/com/relogiclabs/json/schema/exception/JsonLexerException.java rename to src/main/java/com/relogiclabs/jschema/exception/JsonLexerException.java index c0a03e0..4e037d8 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/JsonLexerException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/JsonLexerException.java @@ -1,7 +1,7 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; public class JsonLexerException extends CommonException { public JsonLexerException(String code, String message, Throwable cause) { super(code, message, cause); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/JsonParserException.java b/src/main/java/com/relogiclabs/jschema/exception/JsonParserException.java similarity index 79% rename from src/main/java/com/relogiclabs/json/schema/exception/JsonParserException.java rename to src/main/java/com/relogiclabs/jschema/exception/JsonParserException.java index bf47720..c184a91 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/JsonParserException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/JsonParserException.java @@ -1,4 +1,4 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; public class JsonParserException extends CommonException { public JsonParserException(String code, String message, Throwable cause) { diff --git a/src/main/java/com/relogiclabs/json/schema/exception/JsonSchemaException.java b/src/main/java/com/relogiclabs/jschema/exception/JsonSchemaException.java similarity index 62% rename from src/main/java/com/relogiclabs/json/schema/exception/JsonSchemaException.java rename to src/main/java/com/relogiclabs/jschema/exception/JsonSchemaException.java index d41a654..65390b3 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/JsonSchemaException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/JsonSchemaException.java @@ -1,15 +1,15 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ActualDetail; -import com.relogiclabs.json.schema.message.ErrorDetail; -import com.relogiclabs.json.schema.message.ExpectedDetail; -import com.relogiclabs.json.schema.tree.Context; +import com.relogiclabs.jschema.message.ActualDetail; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ExpectedDetail; +import com.relogiclabs.jschema.tree.Context; import lombok.Getter; -import static com.relogiclabs.json.schema.internal.util.MiscellaneousHelper.nonNull; +import static com.relogiclabs.jschema.internal.util.MiscellaneousHelper.nonNullFrom; @Getter -public class JsonSchemaException extends CommonException { +public class JsonSchemaException extends ScriptRuntimeException { private final ErrorDetail error; private final ExpectedDetail expected; private final ActualDetail actual; @@ -27,7 +27,7 @@ public JsonSchemaException(ErrorDetail error, ExpectedDetail expected, } private static String format(ErrorDetail error, ExpectedDetail expected, ActualDetail actual) { - Context context = nonNull(expected.getContext(), actual.getContext()); + Context context = nonNullFrom(expected.getContext(), actual.getContext()); return context.getRuntime().getMessageFormatter().format(error, expected, actual); } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/MisplacedOptionalException.java b/src/main/java/com/relogiclabs/jschema/exception/MisplacedOptionalException.java similarity index 60% rename from src/main/java/com/relogiclabs/json/schema/exception/MisplacedOptionalException.java rename to src/main/java/com/relogiclabs/jschema/exception/MisplacedOptionalException.java index cd1b34e..5e2e98c 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/MisplacedOptionalException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/MisplacedOptionalException.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class MisplacedOptionalException extends CommonException { public MisplacedOptionalException(ErrorDetail detail) { diff --git a/src/main/java/com/relogiclabs/json/schema/exception/NoValueReceivedException.java b/src/main/java/com/relogiclabs/jschema/exception/NoValueReceivedException.java similarity index 59% rename from src/main/java/com/relogiclabs/json/schema/exception/NoValueReceivedException.java rename to src/main/java/com/relogiclabs/jschema/exception/NoValueReceivedException.java index 471a2f5..504b054 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/NoValueReceivedException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/NoValueReceivedException.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class NoValueReceivedException extends CommonException { public NoValueReceivedException(ErrorDetail detail) { diff --git a/src/main/java/com/relogiclabs/json/schema/exception/NotFoundClassException.java b/src/main/java/com/relogiclabs/jschema/exception/NotFoundClassException.java similarity index 58% rename from src/main/java/com/relogiclabs/json/schema/exception/NotFoundClassException.java rename to src/main/java/com/relogiclabs/jschema/exception/NotFoundClassException.java index 2e218b7..a61f1fc 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/NotFoundClassException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/NotFoundClassException.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class NotFoundClassException extends CommonException { public NotFoundClassException(ErrorDetail detail) { super(detail); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/PragmaNotFoundException.java b/src/main/java/com/relogiclabs/jschema/exception/PragmaNotFoundException.java similarity index 58% rename from src/main/java/com/relogiclabs/json/schema/exception/PragmaNotFoundException.java rename to src/main/java/com/relogiclabs/jschema/exception/PragmaNotFoundException.java index 0376869..533ce21 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/PragmaNotFoundException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/PragmaNotFoundException.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class PragmaNotFoundException extends CommonException { public PragmaNotFoundException(ErrorDetail detail) { super(detail); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/ReceiverNotFoundException.java b/src/main/java/com/relogiclabs/jschema/exception/ReceiverNotFoundException.java similarity index 60% rename from src/main/java/com/relogiclabs/json/schema/exception/ReceiverNotFoundException.java rename to src/main/java/com/relogiclabs/jschema/exception/ReceiverNotFoundException.java index 3f15c08..950d6ea 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/ReceiverNotFoundException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/ReceiverNotFoundException.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; -import com.relogiclabs.json.schema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ErrorDetail; public class ReceiverNotFoundException extends CommonException { public ReceiverNotFoundException(ErrorDetail detail) { diff --git a/src/main/java/com/relogiclabs/json/schema/exception/SchemaLexerException.java b/src/main/java/com/relogiclabs/jschema/exception/SchemaLexerException.java similarity index 78% rename from src/main/java/com/relogiclabs/json/schema/exception/SchemaLexerException.java rename to src/main/java/com/relogiclabs/jschema/exception/SchemaLexerException.java index ecb5815..27744f0 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/SchemaLexerException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/SchemaLexerException.java @@ -1,7 +1,7 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; public class SchemaLexerException extends CommonException { public SchemaLexerException(String code, String message, Throwable cause) { super(code, message, cause); } -} +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/SchemaParserException.java b/src/main/java/com/relogiclabs/jschema/exception/SchemaParserException.java similarity index 79% rename from src/main/java/com/relogiclabs/json/schema/exception/SchemaParserException.java rename to src/main/java/com/relogiclabs/jschema/exception/SchemaParserException.java index 33bf8e1..5f958ab 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/SchemaParserException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/SchemaParserException.java @@ -1,4 +1,4 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; public class SchemaParserException extends CommonException { public SchemaParserException(String code, String message, Throwable cause) { diff --git a/src/main/java/com/relogiclabs/jschema/exception/ScriptArgumentException.java b/src/main/java/com/relogiclabs/jschema/exception/ScriptArgumentException.java new file mode 100644 index 0000000..2133cb3 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/exception/ScriptArgumentException.java @@ -0,0 +1,7 @@ +package com.relogiclabs.jschema.exception; + +public class ScriptArgumentException extends ScriptTemplateException { + public ScriptArgumentException(String code, String template) { + super(code, template); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/exception/ScriptCommonException.java b/src/main/java/com/relogiclabs/jschema/exception/ScriptCommonException.java new file mode 100644 index 0000000..4eeb258 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/exception/ScriptCommonException.java @@ -0,0 +1,21 @@ +package com.relogiclabs.jschema.exception; + +import com.relogiclabs.jschema.message.ErrorDetail; + +public class ScriptCommonException extends CommonException { + public ScriptCommonException(String code, String message, Throwable cause) { + super(code, message, cause); + } + + public ScriptCommonException(String code, String message) { + super(code, message); + } + + public ScriptCommonException(ErrorDetail detail, Throwable cause) { + super(detail, cause); + } + + public ScriptCommonException(ErrorDetail detail) { + super(detail); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/exception/ScriptFunctionException.java b/src/main/java/com/relogiclabs/jschema/exception/ScriptFunctionException.java new file mode 100644 index 0000000..b73a78f --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/exception/ScriptFunctionException.java @@ -0,0 +1,7 @@ +package com.relogiclabs.jschema.exception; + +public class ScriptFunctionException extends ScriptCommonException { + public ScriptFunctionException(String code, String message) { + super(code, message); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/exception/ScriptInitiatedException.java b/src/main/java/com/relogiclabs/jschema/exception/ScriptInitiatedException.java new file mode 100644 index 0000000..cf23e9b --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/exception/ScriptInitiatedException.java @@ -0,0 +1,13 @@ +package com.relogiclabs.jschema.exception; + +import com.relogiclabs.jschema.message.ErrorDetail; + +public class ScriptInitiatedException extends ScriptRuntimeException { + public ScriptInitiatedException(String code, String message) { + super(code, message); + } + + public ScriptInitiatedException(ErrorDetail detail) { + super(detail); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/exception/ScriptInvocationException.java b/src/main/java/com/relogiclabs/jschema/exception/ScriptInvocationException.java new file mode 100644 index 0000000..d79e1cf --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/exception/ScriptInvocationException.java @@ -0,0 +1,20 @@ +package com.relogiclabs.jschema.exception; + +import org.antlr.v4.runtime.Token; + +public class ScriptInvocationException extends ScriptTemplateException { + private final Token token; + + public ScriptInvocationException(String code, String template, Token token) { + super(code, template); + this.token = token; + } + + public ScriptInvocationException(String code, String template) { + this(code, template, null); + } + + public Token getToken(Token defaultToken) { + return token != null ? token : defaultToken; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/exception/ScriptOperationException.java b/src/main/java/com/relogiclabs/jschema/exception/ScriptOperationException.java new file mode 100644 index 0000000..359224f --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/exception/ScriptOperationException.java @@ -0,0 +1,9 @@ +package com.relogiclabs.jschema.exception; + +import com.relogiclabs.jschema.message.ErrorDetail; + +public class ScriptOperationException extends ScriptRuntimeException { + public ScriptOperationException(ErrorDetail detail, Throwable cause) { + super(detail, cause); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/exception/ScriptRuntimeException.java b/src/main/java/com/relogiclabs/jschema/exception/ScriptRuntimeException.java new file mode 100644 index 0000000..722cff1 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/exception/ScriptRuntimeException.java @@ -0,0 +1,22 @@ +package com.relogiclabs.jschema.exception; + +import com.relogiclabs.jschema.message.ErrorDetail; + +public class ScriptRuntimeException extends ScriptCommonException { + + public ScriptRuntimeException(String code, String message) { + super(code, message); + } + + public ScriptRuntimeException(String code, String message, Throwable cause) { + super(code, message, cause); + } + + public ScriptRuntimeException(ErrorDetail detail) { + super(detail); + } + + public ScriptRuntimeException(ErrorDetail detail, Throwable cause) { + super(detail, cause); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/exception/ScriptTemplateException.java b/src/main/java/com/relogiclabs/jschema/exception/ScriptTemplateException.java new file mode 100644 index 0000000..f712317 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/exception/ScriptTemplateException.java @@ -0,0 +1,24 @@ +package com.relogiclabs.jschema.exception; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ScriptTemplateException extends ScriptCommonException { + private static final Pattern TEMPLATE_PATTERN = Pattern.compile(" '?%s'?"); + private final String template; + + public ScriptTemplateException(String code, String template) { + super(code, toMessage(template)); + this.template = template; + } + + public String getMessage(Object... args) { + return template.formatted(args); + } + + private static String toMessage(String template) { + Matcher matcher = TEMPLATE_PATTERN.matcher(template); + if(matcher.find()) return matcher.replaceAll(""); + return template; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/exception/ScriptVariableException.java b/src/main/java/com/relogiclabs/jschema/exception/ScriptVariableException.java new file mode 100644 index 0000000..ee22f15 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/exception/ScriptVariableException.java @@ -0,0 +1,7 @@ +package com.relogiclabs.jschema.exception; + +public class ScriptVariableException extends ScriptCommonException { + public ScriptVariableException(String code, String message) { + super(code, message); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/exception/SystemOperationException.java b/src/main/java/com/relogiclabs/jschema/exception/SystemOperationException.java new file mode 100644 index 0000000..8ae35d7 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/exception/SystemOperationException.java @@ -0,0 +1,9 @@ +package com.relogiclabs.jschema.exception; + +import com.relogiclabs.jschema.message.ErrorDetail; + +public class SystemOperationException extends ScriptRuntimeException { + public SystemOperationException(ErrorDetail detail, Throwable cause) { + super(detail, cause); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/exception/TargetInvocationException.java b/src/main/java/com/relogiclabs/jschema/exception/TargetInvocationException.java similarity index 79% rename from src/main/java/com/relogiclabs/json/schema/exception/TargetInvocationException.java rename to src/main/java/com/relogiclabs/jschema/exception/TargetInvocationException.java index f67fdcc..6dba481 100644 --- a/src/main/java/com/relogiclabs/json/schema/exception/TargetInvocationException.java +++ b/src/main/java/com/relogiclabs/jschema/exception/TargetInvocationException.java @@ -1,7 +1,7 @@ -package com.relogiclabs.json.schema.exception; +package com.relogiclabs.jschema.exception; public class TargetInvocationException extends CommonException { public TargetInvocationException(String code, String message, Throwable cause) { super(code, message, cause); } -} +} \ No newline at end of file From 9ed9dc0535d875993020e4dbcbe0a2cd34c35c58 Mon Sep 17 00:00:00 2001 From: Zahid Hossain <60911932+zhossain-info@users.noreply.github.com> Date: Mon, 19 Feb 2024 22:47:14 +0600 Subject: [PATCH 03/12] Add and refactor node builders --- .../internal/builder/JAliasBuilder.java | 6 +-- .../internal/builder/JArrayBuilder.java | 8 ++-- .../internal/builder/JBooleanBuilder.java | 10 +++++ .../internal/builder/JDataTypeBuilder.java | 10 ++--- .../internal/builder/JDefinitionBuilder.java | 20 +++++++++ .../internal/builder/JDoubleBuilder.java | 10 +++++ .../internal/builder/JFloatBuilder.java | 10 +++++ .../internal/builder/JFunctionBuilder.java | 8 ++-- .../internal/builder/JImportBuilder.java | 17 ++++++++ .../internal/builder/JIntegerBuilder.java | 10 +++++ .../internal/builder/JNodeBuilder.java | 6 +-- .../internal/builder/JNullBuilder.java | 10 +++++ .../internal/builder/JObjectBuilder.java | 12 +++--- .../internal/builder/JPragmaBuilder.java | 38 +++++++++++++++++ .../internal/builder/JPrimitiveBuilder.java | 2 +- .../internal/builder/JPropertyBuilder.java | 8 ++-- .../internal/builder/JReceiverBuilder.java | 6 +-- .../internal/builder/JRootBuilder.java | 32 +++++++++++++++ .../internal/builder/JScriptBuilder.java | 20 +++++++++ .../internal/builder/JStringBuilder.java | 10 +++++ .../internal/builder/JTitleBuilder.java | 6 +-- .../internal/builder/JUndefinedBuilder.java | 10 +++++ .../internal/builder/JValidatorBuilder.java | 14 +++---- .../internal/builder/JVersionBuilder.java | 6 +-- .../internal/builder/JBooleanBuilder.java | 10 ----- .../internal/builder/JDefinitionBuilder.java | 20 --------- .../internal/builder/JDoubleBuilder.java | 10 ----- .../internal/builder/JFloatBuilder.java | 10 ----- .../internal/builder/JIncludeBuilder.java | 17 -------- .../internal/builder/JIntegerBuilder.java | 10 ----- .../schema/internal/builder/JNullBuilder.java | 10 ----- .../internal/builder/JPragmaBuilder.java | 41 ------------------- .../schema/internal/builder/JRootBuilder.java | 30 -------------- .../internal/builder/JStringBuilder.java | 10 ----- .../internal/builder/JUndefinedBuilder.java | 10 ----- 35 files changed, 243 insertions(+), 224 deletions(-) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/builder/JAliasBuilder.java (58%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/builder/JArrayBuilder.java (55%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/builder/JBooleanBuilder.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/builder/JDataTypeBuilder.java (52%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/builder/JDefinitionBuilder.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/builder/JDoubleBuilder.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/builder/JFloatBuilder.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/builder/JFunctionBuilder.java (59%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/builder/JImportBuilder.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/builder/JIntegerBuilder.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/builder/JNodeBuilder.java (79%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/builder/JNullBuilder.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/builder/JObjectBuilder.java (55%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/builder/JPragmaBuilder.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/builder/JPrimitiveBuilder.java (81%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/builder/JPropertyBuilder.java (54%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/builder/JReceiverBuilder.java (57%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/builder/JRootBuilder.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/builder/JScriptBuilder.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/builder/JStringBuilder.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/builder/JTitleBuilder.java (58%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/builder/JUndefinedBuilder.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/builder/JValidatorBuilder.java (52%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/builder/JVersionBuilder.java (58%) delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/builder/JBooleanBuilder.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/builder/JDefinitionBuilder.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/builder/JDoubleBuilder.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/builder/JFloatBuilder.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/builder/JIncludeBuilder.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/builder/JIntegerBuilder.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/builder/JNullBuilder.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/builder/JPragmaBuilder.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/builder/JRootBuilder.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/builder/JStringBuilder.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/builder/JUndefinedBuilder.java diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JAliasBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JAliasBuilder.java similarity index 58% rename from src/main/java/com/relogiclabs/json/schema/internal/builder/JAliasBuilder.java rename to src/main/java/com/relogiclabs/jschema/internal/builder/JAliasBuilder.java index 38893e9..a9140b1 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JAliasBuilder.java +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JAliasBuilder.java @@ -1,13 +1,13 @@ -package com.relogiclabs.json.schema.internal.builder; +package com.relogiclabs.jschema.internal.builder; -import com.relogiclabs.json.schema.type.JAlias; +import com.relogiclabs.jschema.node.JAlias; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @Accessors(fluent = true) -public class JAliasBuilder extends JNodeBuilder { +public final class JAliasBuilder extends JNodeBuilder { private String name; @Override diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JArrayBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JArrayBuilder.java similarity index 55% rename from src/main/java/com/relogiclabs/json/schema/internal/builder/JArrayBuilder.java rename to src/main/java/com/relogiclabs/jschema/internal/builder/JArrayBuilder.java index 1672dac..cae50c9 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JArrayBuilder.java +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JArrayBuilder.java @@ -1,7 +1,7 @@ -package com.relogiclabs.json.schema.internal.builder; +package com.relogiclabs.jschema.internal.builder; -import com.relogiclabs.json.schema.type.JArray; -import com.relogiclabs.json.schema.type.JNode; +import com.relogiclabs.jschema.node.JArray; +import com.relogiclabs.jschema.node.JNode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @@ -10,7 +10,7 @@ @Getter @Setter @Accessors(fluent = true) -public class JArrayBuilder extends JNodeBuilder { +public final class JArrayBuilder extends JNodeBuilder { private List elements; @Override diff --git a/src/main/java/com/relogiclabs/jschema/internal/builder/JBooleanBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JBooleanBuilder.java new file mode 100644 index 0000000..2b7b8ce --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JBooleanBuilder.java @@ -0,0 +1,10 @@ +package com.relogiclabs.jschema.internal.builder; + +import com.relogiclabs.jschema.node.JBoolean; + +public final class JBooleanBuilder extends JPrimitiveBuilder { + @Override + public JBoolean build() { + return JBoolean.from(this); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JDataTypeBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JDataTypeBuilder.java similarity index 52% rename from src/main/java/com/relogiclabs/json/schema/internal/builder/JDataTypeBuilder.java rename to src/main/java/com/relogiclabs/jschema/internal/builder/JDataTypeBuilder.java index d1965a4..6d5bf1e 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JDataTypeBuilder.java +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JDataTypeBuilder.java @@ -1,15 +1,15 @@ -package com.relogiclabs.json.schema.internal.builder; +package com.relogiclabs.jschema.internal.builder; -import com.relogiclabs.json.schema.type.JAlias; -import com.relogiclabs.json.schema.type.JDataType; -import com.relogiclabs.json.schema.type.JsonType; +import com.relogiclabs.jschema.node.JAlias; +import com.relogiclabs.jschema.node.JDataType; +import com.relogiclabs.jschema.node.JsonType; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @Accessors(fluent = true) -public class JDataTypeBuilder extends JNodeBuilder { +public final class JDataTypeBuilder extends JNodeBuilder { private JsonType jsonType; private Boolean nested; private JAlias alias; diff --git a/src/main/java/com/relogiclabs/jschema/internal/builder/JDefinitionBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JDefinitionBuilder.java new file mode 100644 index 0000000..f2135bb --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JDefinitionBuilder.java @@ -0,0 +1,20 @@ +package com.relogiclabs.jschema.internal.builder; + +import com.relogiclabs.jschema.node.JAlias; +import com.relogiclabs.jschema.node.JDefinition; +import com.relogiclabs.jschema.node.JValidator; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +@Getter @Setter +@Accessors(fluent = true) +public final class JDefinitionBuilder extends JNodeBuilder { + private JAlias alias; + private JValidator validator; + + @Override + public JDefinition build() { + return JDefinition.from(this); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/builder/JDoubleBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JDoubleBuilder.java new file mode 100644 index 0000000..f842365 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JDoubleBuilder.java @@ -0,0 +1,10 @@ +package com.relogiclabs.jschema.internal.builder; + +import com.relogiclabs.jschema.node.JDouble; + +public final class JDoubleBuilder extends JPrimitiveBuilder { + @Override + public JDouble build() { + return JDouble.from(this); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/builder/JFloatBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JFloatBuilder.java new file mode 100644 index 0000000..f8ac4b4 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JFloatBuilder.java @@ -0,0 +1,10 @@ +package com.relogiclabs.jschema.internal.builder; + +import com.relogiclabs.jschema.node.JFloat; + +public final class JFloatBuilder extends JPrimitiveBuilder { + @Override + public JFloat build() { + return JFloat.from(this); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JFunctionBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JFunctionBuilder.java similarity index 59% rename from src/main/java/com/relogiclabs/json/schema/internal/builder/JFunctionBuilder.java rename to src/main/java/com/relogiclabs/jschema/internal/builder/JFunctionBuilder.java index 163637a..b057127 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JFunctionBuilder.java +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JFunctionBuilder.java @@ -1,7 +1,7 @@ -package com.relogiclabs.json.schema.internal.builder; +package com.relogiclabs.jschema.internal.builder; -import com.relogiclabs.json.schema.type.JFunction; -import com.relogiclabs.json.schema.type.JNode; +import com.relogiclabs.jschema.node.JFunction; +import com.relogiclabs.jschema.node.JNode; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @@ -10,7 +10,7 @@ @Getter @Setter @Accessors(fluent = true) -public class JFunctionBuilder extends JNodeBuilder { +public final class JFunctionBuilder extends JNodeBuilder { private String name; private Boolean nested; private List arguments; diff --git a/src/main/java/com/relogiclabs/jschema/internal/builder/JImportBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JImportBuilder.java new file mode 100644 index 0000000..5f20fe0 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JImportBuilder.java @@ -0,0 +1,17 @@ +package com.relogiclabs.jschema.internal.builder; + +import com.relogiclabs.jschema.node.JImport; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +@Getter @Setter +@Accessors(fluent = true) +public final class JImportBuilder extends JNodeBuilder { + private String className; + + @Override + public JImport build() { + return JImport.from(this); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/builder/JIntegerBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JIntegerBuilder.java new file mode 100644 index 0000000..a980add --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JIntegerBuilder.java @@ -0,0 +1,10 @@ +package com.relogiclabs.jschema.internal.builder; + +import com.relogiclabs.jschema.node.JInteger; + +public final class JIntegerBuilder extends JPrimitiveBuilder { + @Override + public JInteger build() { + return JInteger.from(this); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JNodeBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JNodeBuilder.java similarity index 79% rename from src/main/java/com/relogiclabs/json/schema/internal/builder/JNodeBuilder.java rename to src/main/java/com/relogiclabs/jschema/internal/builder/JNodeBuilder.java index c0502ce..19a93f6 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JNodeBuilder.java +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JNodeBuilder.java @@ -1,7 +1,7 @@ -package com.relogiclabs.json.schema.internal.builder; +package com.relogiclabs.jschema.internal.builder; -import com.relogiclabs.json.schema.tree.Context; -import com.relogiclabs.json.schema.type.JNode; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.tree.Context; import lombok.Getter; import lombok.experimental.Accessors; diff --git a/src/main/java/com/relogiclabs/jschema/internal/builder/JNullBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JNullBuilder.java new file mode 100644 index 0000000..969cf9b --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JNullBuilder.java @@ -0,0 +1,10 @@ +package com.relogiclabs.jschema.internal.builder; + +import com.relogiclabs.jschema.node.JNull; + +public final class JNullBuilder extends JNodeBuilder { + @Override + public JNull build() { + return JNull.from(this); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JObjectBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JObjectBuilder.java similarity index 55% rename from src/main/java/com/relogiclabs/json/schema/internal/builder/JObjectBuilder.java rename to src/main/java/com/relogiclabs/jschema/internal/builder/JObjectBuilder.java index d1dd2dd..66021c5 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JObjectBuilder.java +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JObjectBuilder.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.internal.builder; +package com.relogiclabs.jschema.internal.builder; -import com.relogiclabs.json.schema.collection.IndexMap; -import com.relogiclabs.json.schema.internal.collection.IndexHashMap; -import com.relogiclabs.json.schema.type.JObject; -import com.relogiclabs.json.schema.type.JProperty; +import com.relogiclabs.jschema.collection.IndexMap; +import com.relogiclabs.jschema.internal.collection.IndexHashMap; +import com.relogiclabs.jschema.node.JObject; +import com.relogiclabs.jschema.node.JProperty; import lombok.Getter; import lombok.experimental.Accessors; @@ -11,7 +11,7 @@ @Getter @Accessors(fluent = true) -public class JObjectBuilder extends JNodeBuilder { +public final class JObjectBuilder extends JNodeBuilder { private IndexMap properties; public JObjectBuilder properties(List properties) { diff --git a/src/main/java/com/relogiclabs/jschema/internal/builder/JPragmaBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JPragmaBuilder.java new file mode 100644 index 0000000..39454ff --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JPragmaBuilder.java @@ -0,0 +1,38 @@ +package com.relogiclabs.jschema.internal.builder; + +import com.relogiclabs.jschema.exception.InvalidPragmaValueException; +import com.relogiclabs.jschema.exception.PragmaNotFoundException; +import com.relogiclabs.jschema.internal.tree.PragmaDescriptor; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JPragma; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.PRAG01; +import static com.relogiclabs.jschema.message.ErrorCode.PRAG02; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; + +@Getter @Setter +@Accessors(fluent = true) +public final class JPragmaBuilder extends JNodeBuilder { + private String name; + private JNode value; + + private void checkPragma() { + var descriptor = PragmaDescriptor.from(name); + if (descriptor == null) + throw new PragmaNotFoundException(formatForSchema(PRAG01, concat("Invalid pragma '", + name, "' with value ", value.getOutline(), " found"), context())); + if (!descriptor.matchType(value.getClass())) + throw new InvalidPragmaValueException(formatForSchema(PRAG02, concat("Invalid value ", + value.getOutline(), " for pragma '", name, "' found"), value)); + } + + @Override + public JPragma build() { + checkPragma(); + return JPragma.from(this); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JPrimitiveBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JPrimitiveBuilder.java similarity index 81% rename from src/main/java/com/relogiclabs/json/schema/internal/builder/JPrimitiveBuilder.java rename to src/main/java/com/relogiclabs/jschema/internal/builder/JPrimitiveBuilder.java index ce2f40e..d049b8b 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JPrimitiveBuilder.java +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JPrimitiveBuilder.java @@ -1,4 +1,4 @@ -package com.relogiclabs.json.schema.internal.builder; +package com.relogiclabs.jschema.internal.builder; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JPropertyBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JPropertyBuilder.java similarity index 54% rename from src/main/java/com/relogiclabs/json/schema/internal/builder/JPropertyBuilder.java rename to src/main/java/com/relogiclabs/jschema/internal/builder/JPropertyBuilder.java index 5a357db..d0c01ed 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JPropertyBuilder.java +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JPropertyBuilder.java @@ -1,14 +1,14 @@ -package com.relogiclabs.json.schema.internal.builder; +package com.relogiclabs.jschema.internal.builder; -import com.relogiclabs.json.schema.type.JNode; -import com.relogiclabs.json.schema.type.JProperty; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JProperty; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @Accessors(fluent = true) -public class JPropertyBuilder extends JNodeBuilder { +public final class JPropertyBuilder extends JNodeBuilder { private String key; private JNode value; diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JReceiverBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JReceiverBuilder.java similarity index 57% rename from src/main/java/com/relogiclabs/json/schema/internal/builder/JReceiverBuilder.java rename to src/main/java/com/relogiclabs/jschema/internal/builder/JReceiverBuilder.java index 6bf3039..014fea3 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JReceiverBuilder.java +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JReceiverBuilder.java @@ -1,13 +1,13 @@ -package com.relogiclabs.json.schema.internal.builder; +package com.relogiclabs.jschema.internal.builder; -import com.relogiclabs.json.schema.type.JReceiver; +import com.relogiclabs.jschema.node.JReceiver; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @Accessors(fluent = true) -public class JReceiverBuilder extends JNodeBuilder { +public final class JReceiverBuilder extends JNodeBuilder { private String name; @Override diff --git a/src/main/java/com/relogiclabs/jschema/internal/builder/JRootBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JRootBuilder.java new file mode 100644 index 0000000..1bedf09 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JRootBuilder.java @@ -0,0 +1,32 @@ +package com.relogiclabs.jschema.internal.builder; + +import com.relogiclabs.jschema.node.JDefinition; +import com.relogiclabs.jschema.node.JImport; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JPragma; +import com.relogiclabs.jschema.node.JRoot; +import com.relogiclabs.jschema.node.JScript; +import com.relogiclabs.jschema.node.JTitle; +import com.relogiclabs.jschema.node.JVersion; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +import java.util.List; + +@Getter @Setter +@Accessors(fluent = true) +public final class JRootBuilder extends JNodeBuilder { + private JTitle title; + private JVersion version; + private List imports; + private List pragmas; + private List definitions; + private List scripts; + private JNode value; + + @Override + public JRoot build() { + return JRoot.from(this); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/builder/JScriptBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JScriptBuilder.java new file mode 100644 index 0000000..0007303 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JScriptBuilder.java @@ -0,0 +1,20 @@ +package com.relogiclabs.jschema.internal.builder; + +import com.relogiclabs.jschema.internal.engine.Evaluator; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JScript; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +@Getter @Setter +@Accessors(fluent = true) +public final class JScriptBuilder extends JNodeBuilder { + private Evaluator evaluator; + private String source; + + @Override + public JNode build() { + return JScript.from(this); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/builder/JStringBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JStringBuilder.java new file mode 100644 index 0000000..63b5980 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JStringBuilder.java @@ -0,0 +1,10 @@ +package com.relogiclabs.jschema.internal.builder; + +import com.relogiclabs.jschema.node.JString; + +public final class JStringBuilder extends JPrimitiveBuilder { + @Override + public JString build() { + return JString.from(this); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JTitleBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JTitleBuilder.java similarity index 58% rename from src/main/java/com/relogiclabs/json/schema/internal/builder/JTitleBuilder.java rename to src/main/java/com/relogiclabs/jschema/internal/builder/JTitleBuilder.java index e588768..e3696ff 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JTitleBuilder.java +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JTitleBuilder.java @@ -1,13 +1,13 @@ -package com.relogiclabs.json.schema.internal.builder; +package com.relogiclabs.jschema.internal.builder; -import com.relogiclabs.json.schema.type.JTitle; +import com.relogiclabs.jschema.node.JTitle; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @Accessors(fluent = true) -public class JTitleBuilder extends JNodeBuilder { +public final class JTitleBuilder extends JNodeBuilder { private String title; @Override diff --git a/src/main/java/com/relogiclabs/jschema/internal/builder/JUndefinedBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JUndefinedBuilder.java new file mode 100644 index 0000000..6272aef --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JUndefinedBuilder.java @@ -0,0 +1,10 @@ +package com.relogiclabs.jschema.internal.builder; + +import com.relogiclabs.jschema.node.JUndefined; + +public final class JUndefinedBuilder extends JNodeBuilder { + @Override + public JUndefined build() { + return JUndefined.from(this); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JValidatorBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JValidatorBuilder.java similarity index 52% rename from src/main/java/com/relogiclabs/json/schema/internal/builder/JValidatorBuilder.java rename to src/main/java/com/relogiclabs/jschema/internal/builder/JValidatorBuilder.java index 5bf405a..668df11 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JValidatorBuilder.java +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JValidatorBuilder.java @@ -1,10 +1,10 @@ -package com.relogiclabs.json.schema.internal.builder; +package com.relogiclabs.jschema.internal.builder; -import com.relogiclabs.json.schema.type.JDataType; -import com.relogiclabs.json.schema.type.JFunction; -import com.relogiclabs.json.schema.type.JNode; -import com.relogiclabs.json.schema.type.JReceiver; -import com.relogiclabs.json.schema.type.JValidator; +import com.relogiclabs.jschema.node.JDataType; +import com.relogiclabs.jschema.node.JFunction; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JReceiver; +import com.relogiclabs.jschema.node.JValidator; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @@ -13,7 +13,7 @@ @Getter @Setter @Accessors(fluent = true) -public class JValidatorBuilder extends JNodeBuilder { +public final class JValidatorBuilder extends JNodeBuilder { private JNode value; private List functions; private List dataTypes; diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JVersionBuilder.java b/src/main/java/com/relogiclabs/jschema/internal/builder/JVersionBuilder.java similarity index 58% rename from src/main/java/com/relogiclabs/json/schema/internal/builder/JVersionBuilder.java rename to src/main/java/com/relogiclabs/jschema/internal/builder/JVersionBuilder.java index 2c4cb0a..20ba396 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JVersionBuilder.java +++ b/src/main/java/com/relogiclabs/jschema/internal/builder/JVersionBuilder.java @@ -1,13 +1,13 @@ -package com.relogiclabs.json.schema.internal.builder; +package com.relogiclabs.jschema.internal.builder; -import com.relogiclabs.json.schema.type.JVersion; +import com.relogiclabs.jschema.node.JVersion; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @Getter @Setter @Accessors(fluent = true) -public class JVersionBuilder extends JNodeBuilder { +public final class JVersionBuilder extends JNodeBuilder { private String version; @Override diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JBooleanBuilder.java b/src/main/java/com/relogiclabs/json/schema/internal/builder/JBooleanBuilder.java deleted file mode 100644 index 4d19dad..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JBooleanBuilder.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.relogiclabs.json.schema.internal.builder; - -import com.relogiclabs.json.schema.type.JBoolean; - -public class JBooleanBuilder extends JPrimitiveBuilder { - @Override - public JBoolean build() { - return JBoolean.from(this); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JDefinitionBuilder.java b/src/main/java/com/relogiclabs/json/schema/internal/builder/JDefinitionBuilder.java deleted file mode 100644 index 8d2b251..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JDefinitionBuilder.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.relogiclabs.json.schema.internal.builder; - -import com.relogiclabs.json.schema.type.JAlias; -import com.relogiclabs.json.schema.type.JDefinition; -import com.relogiclabs.json.schema.type.JValidator; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.Accessors; - -@Getter @Setter -@Accessors(fluent = true) -public class JDefinitionBuilder extends JNodeBuilder { - private JAlias alias; - private JValidator validator; - - @Override - public JDefinition build() { - return JDefinition.from(this); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JDoubleBuilder.java b/src/main/java/com/relogiclabs/json/schema/internal/builder/JDoubleBuilder.java deleted file mode 100644 index 6103218..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JDoubleBuilder.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.relogiclabs.json.schema.internal.builder; - -import com.relogiclabs.json.schema.type.JDouble; - -public class JDoubleBuilder extends JPrimitiveBuilder { - @Override - public JDouble build() { - return JDouble.from(this); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JFloatBuilder.java b/src/main/java/com/relogiclabs/json/schema/internal/builder/JFloatBuilder.java deleted file mode 100644 index bf8274d..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JFloatBuilder.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.relogiclabs.json.schema.internal.builder; - -import com.relogiclabs.json.schema.type.JFloat; - -public class JFloatBuilder extends JPrimitiveBuilder { - @Override - public JFloat build() { - return JFloat.from(this); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JIncludeBuilder.java b/src/main/java/com/relogiclabs/json/schema/internal/builder/JIncludeBuilder.java deleted file mode 100644 index a203f27..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JIncludeBuilder.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.relogiclabs.json.schema.internal.builder; - -import com.relogiclabs.json.schema.type.JInclude; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.Accessors; - -@Getter @Setter -@Accessors(fluent = true) -public class JIncludeBuilder extends JNodeBuilder { - private String className; - - @Override - public JInclude build() { - return JInclude.from(this); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JIntegerBuilder.java b/src/main/java/com/relogiclabs/json/schema/internal/builder/JIntegerBuilder.java deleted file mode 100644 index dcba156..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JIntegerBuilder.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.relogiclabs.json.schema.internal.builder; - -import com.relogiclabs.json.schema.type.JInteger; - -public class JIntegerBuilder extends JPrimitiveBuilder { - @Override - public JInteger build() { - return JInteger.from(this); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JNullBuilder.java b/src/main/java/com/relogiclabs/json/schema/internal/builder/JNullBuilder.java deleted file mode 100644 index 569efd6..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JNullBuilder.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.relogiclabs.json.schema.internal.builder; - -import com.relogiclabs.json.schema.type.JNull; - -public class JNullBuilder extends JNodeBuilder { - @Override - public JNull build() { - return JNull.from(this); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JPragmaBuilder.java b/src/main/java/com/relogiclabs/json/schema/internal/builder/JPragmaBuilder.java deleted file mode 100644 index 93a5dee..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JPragmaBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.relogiclabs.json.schema.internal.builder; - -import com.relogiclabs.json.schema.exception.InvalidPragmaValueException; -import com.relogiclabs.json.schema.exception.PragmaNotFoundException; -import com.relogiclabs.json.schema.internal.tree.PragmaDescriptor; -import com.relogiclabs.json.schema.type.JNode; -import com.relogiclabs.json.schema.type.JPragma; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.Accessors; - -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static com.relogiclabs.json.schema.internal.util.StringHelper.quote; -import static com.relogiclabs.json.schema.message.ErrorCode.PRAG01; -import static com.relogiclabs.json.schema.message.ErrorCode.PRAG02; -import static com.relogiclabs.json.schema.message.MessageFormatter.formatForSchema; - -@Getter @Setter -@Accessors(fluent = true) -public class JPragmaBuilder extends JNodeBuilder { - private String name; - private JNode value; - - private void checkPragma() { - var descriptor = PragmaDescriptor.from(name); - if (descriptor == null) - throw new PragmaNotFoundException(formatForSchema(PRAG01, - concat("Invalid pragma ", quote(name), " with value ", - value.getOutline(), " found"), context())); - if (!descriptor.matchType(value.getClass())) - throw new InvalidPragmaValueException(formatForSchema(PRAG02, - concat("Invalid value ", value.getOutline(), - " for pragma ", quote(name), " found"), value)); - } - - @Override - public JPragma build() { - checkPragma(); - return JPragma.from(this); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JRootBuilder.java b/src/main/java/com/relogiclabs/json/schema/internal/builder/JRootBuilder.java deleted file mode 100644 index 75863c0..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JRootBuilder.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.relogiclabs.json.schema.internal.builder; - -import com.relogiclabs.json.schema.type.JDefinition; -import com.relogiclabs.json.schema.type.JInclude; -import com.relogiclabs.json.schema.type.JNode; -import com.relogiclabs.json.schema.type.JPragma; -import com.relogiclabs.json.schema.type.JRoot; -import com.relogiclabs.json.schema.type.JTitle; -import com.relogiclabs.json.schema.type.JVersion; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.Accessors; - -import java.util.List; - -@Getter @Setter -@Accessors(fluent = true) -public class JRootBuilder extends JNodeBuilder { - private JTitle title; - private JVersion version; - private List includes; - private List pragmas; - private List definitions; - private JNode value; - - @Override - public JRoot build() { - return JRoot.from(this); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JStringBuilder.java b/src/main/java/com/relogiclabs/json/schema/internal/builder/JStringBuilder.java deleted file mode 100644 index 154e4c3..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JStringBuilder.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.relogiclabs.json.schema.internal.builder; - -import com.relogiclabs.json.schema.type.JString; - -public class JStringBuilder extends JPrimitiveBuilder { - @Override - public JString build() { - return JString.from(this); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/builder/JUndefinedBuilder.java b/src/main/java/com/relogiclabs/json/schema/internal/builder/JUndefinedBuilder.java deleted file mode 100644 index df9ae89..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/builder/JUndefinedBuilder.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.relogiclabs.json.schema.internal.builder; - -import com.relogiclabs.json.schema.type.JUndefined; - -public class JUndefinedBuilder extends JNodeBuilder { - @Override - public JUndefined build() { - return JUndefined.from(this); - } -} \ No newline at end of file From 2fefce4d056bb143e38d4ed5ebbc6dcf86e9f66d Mon Sep 17 00:00:00 2001 From: Zahid Hossain <60911932+zhossain-info@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:23:46 +0600 Subject: [PATCH 04/12] Update schema and script grammars --- .../internal/grammar/DateTimeLexer.g4 | 0 .../internal/grammar/JsonLexer.g4 | 2 +- .../internal/grammar/JsonParser.g4 | 24 +- .../jschema/internal/grammar/SchemaLexer.g4 | 148 ++++++++++++ .../jschema/internal/grammar/SchemaParser.g4 | 222 ++++++++++++++++++ 5 files changed, 383 insertions(+), 13 deletions(-) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/grammar/DateTimeLexer.g4 (100%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/grammar/JsonLexer.g4 (94%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/grammar/JsonParser.g4 (56%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaLexer.g4 create mode 100644 src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaParser.g4 diff --git a/src/main/java/com/relogiclabs/json/schema/internal/grammar/DateTimeLexer.g4 b/src/main/java/com/relogiclabs/jschema/internal/grammar/DateTimeLexer.g4 similarity index 100% rename from src/main/java/com/relogiclabs/json/schema/internal/grammar/DateTimeLexer.g4 rename to src/main/java/com/relogiclabs/jschema/internal/grammar/DateTimeLexer.g4 diff --git a/src/main/java/com/relogiclabs/json/schema/internal/grammar/JsonLexer.g4 b/src/main/java/com/relogiclabs/jschema/internal/grammar/JsonLexer.g4 similarity index 94% rename from src/main/java/com/relogiclabs/json/schema/internal/grammar/JsonLexer.g4 rename to src/main/java/com/relogiclabs/jschema/internal/grammar/JsonLexer.g4 index 4780b10..4d9964e 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/grammar/JsonLexer.g4 +++ b/src/main/java/com/relogiclabs/jschema/internal/grammar/JsonLexer.g4 @@ -24,4 +24,4 @@ fragment INTDIGIT : '0' | [1-9] DIGIT*; fragment EXPONENT : [eE] [+\-]? DIGIT+; fragment DIGIT : [0-9]; -WHITE_SPACE : [\n\r\t ]+ -> skip; +WHITE_SPACE : [\n\r\t ]+ -> skip; \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/grammar/JsonParser.g4 b/src/main/java/com/relogiclabs/jschema/internal/grammar/JsonParser.g4 similarity index 56% rename from src/main/java/com/relogiclabs/json/schema/internal/grammar/JsonParser.g4 rename to src/main/java/com/relogiclabs/jschema/internal/grammar/JsonParser.g4 index 562f31f..ab9f240 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/grammar/JsonParser.g4 +++ b/src/main/java/com/relogiclabs/jschema/internal/grammar/JsonParser.g4 @@ -3,28 +3,28 @@ parser grammar JsonParser; options { tokenVocab = JsonLexer; } json - : value EOF + : valueNode EOF ; -value - : primitive - | object - | array +valueNode + : primitiveNode + | objectNode + | arrayNode ; -object - : LBRACE (property (COMMA property)*)? RBRACE +objectNode + : LBRACE ( propertyNode ( COMMA propertyNode )* )? RBRACE ; -property - : STRING COLON value +propertyNode + : STRING COLON valueNode ; -array - : LBRACKET (value (COMMA value)*)? RBRACKET +arrayNode + : LBRACKET ( valueNode ( COMMA valueNode )* )? RBRACKET ; -primitive +primitiveNode : TRUE # PrimitiveTrue | FALSE # PrimitiveFalse | STRING # PrimitiveString diff --git a/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaLexer.g4 b/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaLexer.g4 new file mode 100644 index 0000000..2d8bca0 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaLexer.g4 @@ -0,0 +1,148 @@ +lexer grammar SchemaLexer; + +// Sections +TITLE : '%title'; +VERSION : '%version'; +IMPORT : '%import'; +PRAGMA : '%pragma'; +DEFINE : '%define'; +SCHEMA : '%schema'; +SCRIPT : '%script' -> pushMode(DIRECTIVE_SCRIPT1); + +// Keywords +TRUE : 'true'; +FALSE : 'false'; +NULL : 'null'; + +// Symbols +COLON : ':'; +COMMA : ','; +STAR : '*'; +LBRACE : '{'; +RBRACE : '}'; +LBRACKET : '['; +RBRACKET : ']'; +LPAREN : '('; +RPAREN : ')'; +OPTIONAL : '?'; +UNDEFINED : '!'; + +// Identifiers +FULL_IDENTIFIER : IDENTIFIER ( '.' IDENTIFIER )*; +ALIAS : '$' IDENTIFIER; +DATATYPE : '#' ALPHA+; +FUNCTION : '@' IDENTIFIER; +RECEIVER : '&' IDENTIFIER; + +fragment IDENTIFIER : ALPHA ALPHANUMERIC*; +fragment ALPHA : [A-Za-z_]; +fragment ALPHANUMERIC : [A-Za-z0-9_]; + +// String +STRING : '"' ( ESCAPE | SAFE_CODEPOINT )* '"'; +fragment ESCAPE : '\\' ( ["\\/bfnrt] | UNICODE ); +fragment UNICODE : 'u' HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT; +fragment HEXDIGIT : [0-9a-fA-F]; +fragment SAFE_CODEPOINT : ~["\\\u0000-\u001F]; + +// Numbers +INTEGER : '-'? INTDIGIT; +FLOAT : INTEGER FRACTION; +DOUBLE : INTEGER FRACTION? EXPONENT; + +fragment FRACTION : '.' DIGIT+; +fragment INTDIGIT : '0' | [1-9] DIGIT*; +fragment EXPONENT : [eE] [+\-]? DIGIT+; +fragment DIGIT : [0-9]; + +// Hidden Tokens +WHITE_SPACE : [\n\r\t ]+ -> channel(HIDDEN); +BLOCK_COMMENT : '/*' .*? '*/' -> channel(HIDDEN); +LINE_COMMENT : '//' ~('\r' | '\n')* -> channel(HIDDEN); + +//---------------DIRECTIVE_SCRIPT1--------------- +mode DIRECTIVE_SCRIPT1; + +// Keywords +G_VAR : 'var'; +G_IF : 'if'; +G_ELSE : 'else'; +G_WHILE : 'while'; +G_FOR : 'for'; +G_FOREACH : 'foreach'; +G_IN : 'in'; +G_BREAK : 'break'; +G_CONSTRAINT : 'constraint'; +G_TARGET : 'target'; +G_CALLER : 'caller'; +G_SUBROUTINE : 'subroutine'; +G_TRYOF : 'tryof'; +G_THROW : 'throw'; +G_FUNCTION : 'function'; +G_RETURN : 'return'; +G_FUTURE : 'future'; +G_TRUE : 'true'; +G_FALSE : 'false'; +G_NULL : 'null'; +G_UNDEFINED : 'undefined'; + +// Reserved Keywords +G_THIS : 'this'; +G_NEW : 'new'; +G_CONTINUE : 'continue'; +G_DO : 'do'; +G_CONST : 'const'; +G_SWITCH : 'switch'; +G_CASE : 'case'; +G_IMPORT : 'import'; +G_CLASS : 'class'; +G_SUPER : 'super'; +G_DEFAULT : 'default'; + +// Literals +G_INTEGER : INTEGER; +G_DOUBLE : INTEGER FRACTION? EXPONENT?; +G_STRING : STRING; +G_IDENTIFIER : IDENTIFIER; + +// Separator Symbols +G_LBRACE : '{'; +G_RBRACE : '}'; +G_LBRACKET : '['; +G_RBRACKET : ']'; +G_LPAREN : '('; +G_RPAREN : ')'; +G_SEMI : ';'; +G_COMMA : ','; +G_DOT : '.'; +G_COLON : ':'; +G_RANGE : '..'; +G_ELLIPSIS : '...'; + +// Operator Symbols +G_ASSIGN : '='; +G_INC : '++'; +G_DEC : '--'; +G_PLUS : '+'; +G_MINUS : '-'; +G_MUL : '*'; +G_DIV : '/'; +G_GT : '>'; +G_LT : '<'; +G_LE : '<='; +G_GE : '>='; +G_EQ : '=='; +G_NE : '!='; +G_NOT : '!'; +G_AND : '&&'; +G_OR : '||'; + +// Next Sections +DEFINE1 : '%define' -> type(DEFINE), popMode; +SCHEMA1 : '%schema' -> type(SCHEMA), popMode; +SCRIPT1 : '%script' -> type(SCRIPT), popMode; + +// Hidden Tokens +WHITE_SPACE1 : WHITE_SPACE -> channel(HIDDEN); +BLOCK_COMMENT1 : BLOCK_COMMENT -> channel(HIDDEN); +LINE_COMMENT1 : LINE_COMMENT -> channel(HIDDEN); \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaParser.g4 b/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaParser.g4 new file mode 100644 index 0000000..0fb1546 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaParser.g4 @@ -0,0 +1,222 @@ +parser grammar SchemaParser; + +options { tokenVocab = SchemaLexer; } + +//---------------Schema Rules--------------- +schema + : titleNode? versionNode? ( importNode | pragmaNode )* + ( defineNode | scriptNode )* + schemaMain + ( defineNode | scriptNode )* EOF #CompleteSchema + | validatorNode EOF #ShortSchema + ; + +schemaMain + : SCHEMA COLON validatorNode + ; + +titleNode + : TITLE COLON STRING + ; + +versionNode + : VERSION COLON STRING + ; + +importNode + : IMPORT COLON FULL_IDENTIFIER ( COMMA FULL_IDENTIFIER )? + ; + +pragmaNode + : PRAGMA FULL_IDENTIFIER COLON primitiveNode + ; + +defineNode + : DEFINE aliasNode COLON validatorMain + ; + +aliasNode + : ALIAS + ; + +validatorMain + : valueNode functionNode* datatypeNode* receiverNode* OPTIONAL? + | functionNode+ datatypeNode* receiverNode* OPTIONAL? + | datatypeNode+ receiverNode* OPTIONAL? + ; + +validatorNode + : validatorMain + | aliasNode + ; + +valueNode + : primitiveNode + | objectNode + | arrayNode + ; + +receiverNode + : RECEIVER + ; + +objectNode + : LBRACE ( propertyNode ( COMMA propertyNode )* )? RBRACE + ; + +propertyNode + : STRING COLON validatorNode + ; + +arrayNode + : LBRACKET ( validatorNode ( COMMA validatorNode )* )? RBRACKET + ; + +datatypeNode + : DATATYPE STAR? (LPAREN aliasNode RPAREN)? + ; + +functionNode + : FUNCTION STAR? ( LPAREN ( argumentNode ( COMMA argumentNode )* )? RPAREN )? + ; + +argumentNode + : valueNode + | receiverNode + ; + +primitiveNode + : TRUE # PrimitiveTrue + | FALSE # PrimitiveFalse + | STRING # PrimitiveString + | INTEGER # PrimitiveInteger + | FLOAT # PrimitiveFloat + | DOUBLE # PrimitiveDouble + | NULL # PrimitiveNull + | UNDEFINED # PrimitiveUndefined + ; + + +//---------------Script Rules--------------- +scriptNode + : SCRIPT G_COLON G_LBRACE globalStatement+ G_RBRACE + ; + +globalStatement + : functionDeclaration + | varStatement + ; + +statement + : varStatement + | expressionStatement + | ifStatement + | whileStatement + | forStatement + | foreachStatement + | returnStatement + | breakStatement + | blockStatement + ; + +functionDeclaration + : ( G_CONSTRAINT G_FUNCTION? | G_FUTURE G_CONSTRAINT? G_FUNCTION? | G_SUBROUTINE G_FUNCTION? ) + name=G_IDENTIFIER G_LPAREN + ( G_IDENTIFIER ( G_COMMA G_IDENTIFIER )* G_ELLIPSIS? )? + G_RPAREN blockStatement + ; + +varStatement + : G_VAR varInitialization ( G_COMMA varInitialization )* G_SEMI + ; + +varInitialization + : G_IDENTIFIER ( G_ASSIGN expression )? + ; + +expressionStatement + : expression G_SEMI + ; + +ifStatement + : G_IF G_LPAREN expression G_RPAREN statement ( G_ELSE statement )? + ; + +whileStatement + : G_WHILE G_LPAREN expression G_RPAREN statement + ; + +forStatement + : G_FOR G_LPAREN ( varStatement | initialization=expressionList G_SEMI )? + condition=expression? G_SEMI updation=expressionList? + G_RPAREN statement + ; + +expressionList + : expression ( G_COMMA expression )* + ; + +foreachStatement + : G_FOREACH G_LPAREN G_VAR G_IDENTIFIER G_IN expression G_RPAREN statement + ; + +returnStatement + : G_RETURN expression G_SEMI + ; + +breakStatement + : G_BREAK G_SEMI + ; + +blockStatement + : G_LBRACE statement* G_RBRACE + ; + +expression + : refExpression #AllRefExpression + | G_MINUS expression #UnaryMinusExpression + | G_NOT expression #LogicalNotExpression + | refExpression G_INC #PostIncrementExpression + | refExpression G_DEC #PostDecrementExpression + | G_INC refExpression #PreIncrementExpression + | G_DEC refExpression #PreDecrementExpression + | expression ( G_MUL | G_DIV ) expression #MultiplicativeExpression + | expression ( G_PLUS | G_MINUS ) expression #AdditiveExpression + | expression G_RANGE expression? #RangeBothExpression + | G_RANGE expression #RangeEndExpression + | expression ( G_GE | G_LE | G_GT | G_LT ) expression #RelationalExpression + | expression ( G_EQ | G_NE ) expression #EqualityExpression + | expression G_AND expression #LogicalAndExpression + | expression G_OR expression #LogicalOrExpression + | refExpression G_ASSIGN expression #AssignmentExpression + | literal #LiteralExpression + | G_LPAREN expression G_RPAREN #ParenthesizedExpression + | G_TRYOF G_LPAREN expression G_RPAREN #TryofExpression + | G_THROW G_LPAREN expression ( G_COMMA expression )? G_RPAREN #ThrowExpression + ; + +refExpression + : refExpression G_DOT G_IDENTIFIER #DotExpression + | refExpression G_LBRACKET expression G_RBRACKET #IndexExpression + | G_IDENTIFIER G_LPAREN ( expression ( G_COMMA expression )* )? G_RPAREN #InvokeExpression + | G_TARGET #TargetExpression + | G_CALLER #CallerExpression + | G_IDENTIFIER #IdentifierExpression + ; + +literal + : G_TRUE #TrueLiteral + | G_FALSE #FalseLiteral + | G_INTEGER #IntegerLiteral + | G_DOUBLE #DoubleLiteral + | G_STRING #StringLiteral + | G_LBRACKET ( expression ( G_COMMA expression )* )? G_RBRACKET #ArrayLiteral + | G_LBRACE + ( keys+=( G_IDENTIFIER | G_STRING ) + G_COLON values+=expression + ( G_COMMA keys+=( G_IDENTIFIER | G_STRING ) + G_COLON values+=expression )* )? + G_RBRACE #ObjectLiteral + | G_NULL #NullLiteral + | G_UNDEFINED #UndefinedLiteral + ; \ No newline at end of file From ee310f7604605b65320a0fa6ffc6b202b8a91fd8 Mon Sep 17 00:00:00 2001 From: Zahid Hossain <60911932+zhossain-info@users.noreply.github.com> Date: Tue, 20 Feb 2024 16:17:58 +0600 Subject: [PATCH 05/12] Update Antlr generated files for schema and script --- .../internal/antlr/DateTimeLexer.interp | 110 + .../jschema/internal/antlr/DateTimeLexer.java | 245 + .../internal/antlr/DateTimeLexer.tokens | 0 .../jschema/internal/antlr/JsonLexer.interp | 66 + .../jschema/internal/antlr/JsonLexer.java | 210 + .../internal/antlr/JsonLexer.tokens | 0 .../jschema/internal/antlr/JsonParser.interp | 45 + .../jschema/internal/antlr/JsonParser.java | 618 +++ .../internal/antlr/JsonParser.tokens | 0 .../internal/antlr/JsonParserBaseVisitor.java | 98 + .../internal/antlr/JsonParserVisitor.java | 91 + .../jschema/internal/antlr/SchemaLexer.interp | 332 ++ .../jschema/internal/antlr/SchemaLexer.java | 640 +++ .../jschema/internal/antlr/SchemaLexer.tokens | 152 + .../internal/antlr/SchemaParser.interp | 248 + .../jschema/internal/antlr/SchemaParser.java | 4398 +++++++++++++++++ .../internal/antlr/SchemaParser.tokens | 152 + .../antlr/SchemaParserBaseVisitor.java | 553 +++ .../internal/antlr/SchemaParserVisitor.java | 519 ++ 19 files changed, 8477 insertions(+) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/DateTimeLexer.interp create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/DateTimeLexer.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/antlr/DateTimeLexer.tokens (100%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/JsonLexer.interp create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/JsonLexer.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/antlr/JsonLexer.tokens (100%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParser.interp create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParser.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/antlr/JsonParser.tokens (100%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParserBaseVisitor.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParserVisitor.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.interp create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.tokens create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.interp create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.tokens create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParserBaseVisitor.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParserVisitor.java diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/DateTimeLexer.interp b/src/main/java/com/relogiclabs/jschema/internal/antlr/DateTimeLexer.interp new file mode 100644 index 0000000..5e85dd7 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/DateTimeLexer.interp @@ -0,0 +1,110 @@ +token literal names: +null +'G' +'YYYY' +'YY' +'MMMM' +'MMM' +'MM' +'M' +'DDDD' +'DDD' +'DD' +'D' +'t' +'hh' +'h' +'mm' +'m' +'ss' +'s' +'ffffff' +'fffff' +'ffff' +'fff' +'ff' +'f' +'F' +'ZZZ' +'ZZ' +'Z' +null +null +null + +token symbolic names: +null +ERA +YEAR_NUMBER4 +YEAR_NUMBER2 +MONTH_NAME +MONTH_SHORT_NAME +MONTH_NUMBER2 +MONTH_NUMBER +WEEKDAY_NAME +WEEKDAY_SHORT_NAME +DAY_NUMBER2 +DAY_NUMBER +CLOCK_AM_PM +HOUR_NUMBER2 +HOUR_NUMBER +MINUTE_NUMBER2 +MINUTE_NUMBER +SECOND_NUMBER2 +SECOND_NUMBER +FRACTION_NUMBER6 +FRACTION_NUMBER5 +FRACTION_NUMBER4 +FRACTION_NUMBER3 +FRACTION_NUMBER2 +FRACTION_NUMBER1 +FRACTION_NUMBER +UTC_OFFSET_TIME2 +UTC_OFFSET_TIME1 +UTC_OFFSET_HOUR +SYMBOL +WHITESPACE +TEXT + +rule names: +ERA +YEAR_NUMBER4 +YEAR_NUMBER2 +MONTH_NAME +MONTH_SHORT_NAME +MONTH_NUMBER2 +MONTH_NUMBER +WEEKDAY_NAME +WEEKDAY_SHORT_NAME +DAY_NUMBER2 +DAY_NUMBER +CLOCK_AM_PM +HOUR_NUMBER2 +HOUR_NUMBER +MINUTE_NUMBER2 +MINUTE_NUMBER +SECOND_NUMBER2 +SECOND_NUMBER +FRACTION_NUMBER6 +FRACTION_NUMBER5 +FRACTION_NUMBER4 +FRACTION_NUMBER3 +FRACTION_NUMBER2 +FRACTION_NUMBER1 +FRACTION_NUMBER +UTC_OFFSET_TIME2 +UTC_OFFSET_TIME1 +UTC_OFFSET_HOUR +SYMBOL +WHITESPACE +TEXT + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 31, 177, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 4, 28, 158, 8, 28, 11, 28, 12, 28, 159, 1, 29, 4, 29, 163, 8, 29, 11, 29, 12, 29, 164, 1, 30, 1, 30, 1, 30, 1, 30, 5, 30, 171, 8, 30, 10, 30, 12, 30, 174, 9, 30, 1, 30, 1, 30, 0, 0, 31, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 1, 0, 3, 4, 0, 33, 47, 58, 64, 91, 96, 123, 126, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 39, 39, 180, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 1, 63, 1, 0, 0, 0, 3, 65, 1, 0, 0, 0, 5, 70, 1, 0, 0, 0, 7, 73, 1, 0, 0, 0, 9, 78, 1, 0, 0, 0, 11, 82, 1, 0, 0, 0, 13, 85, 1, 0, 0, 0, 15, 87, 1, 0, 0, 0, 17, 92, 1, 0, 0, 0, 19, 96, 1, 0, 0, 0, 21, 99, 1, 0, 0, 0, 23, 101, 1, 0, 0, 0, 25, 103, 1, 0, 0, 0, 27, 106, 1, 0, 0, 0, 29, 108, 1, 0, 0, 0, 31, 111, 1, 0, 0, 0, 33, 113, 1, 0, 0, 0, 35, 116, 1, 0, 0, 0, 37, 118, 1, 0, 0, 0, 39, 125, 1, 0, 0, 0, 41, 131, 1, 0, 0, 0, 43, 136, 1, 0, 0, 0, 45, 140, 1, 0, 0, 0, 47, 143, 1, 0, 0, 0, 49, 145, 1, 0, 0, 0, 51, 147, 1, 0, 0, 0, 53, 151, 1, 0, 0, 0, 55, 154, 1, 0, 0, 0, 57, 157, 1, 0, 0, 0, 59, 162, 1, 0, 0, 0, 61, 166, 1, 0, 0, 0, 63, 64, 5, 71, 0, 0, 64, 2, 1, 0, 0, 0, 65, 66, 5, 89, 0, 0, 66, 67, 5, 89, 0, 0, 67, 68, 5, 89, 0, 0, 68, 69, 5, 89, 0, 0, 69, 4, 1, 0, 0, 0, 70, 71, 5, 89, 0, 0, 71, 72, 5, 89, 0, 0, 72, 6, 1, 0, 0, 0, 73, 74, 5, 77, 0, 0, 74, 75, 5, 77, 0, 0, 75, 76, 5, 77, 0, 0, 76, 77, 5, 77, 0, 0, 77, 8, 1, 0, 0, 0, 78, 79, 5, 77, 0, 0, 79, 80, 5, 77, 0, 0, 80, 81, 5, 77, 0, 0, 81, 10, 1, 0, 0, 0, 82, 83, 5, 77, 0, 0, 83, 84, 5, 77, 0, 0, 84, 12, 1, 0, 0, 0, 85, 86, 5, 77, 0, 0, 86, 14, 1, 0, 0, 0, 87, 88, 5, 68, 0, 0, 88, 89, 5, 68, 0, 0, 89, 90, 5, 68, 0, 0, 90, 91, 5, 68, 0, 0, 91, 16, 1, 0, 0, 0, 92, 93, 5, 68, 0, 0, 93, 94, 5, 68, 0, 0, 94, 95, 5, 68, 0, 0, 95, 18, 1, 0, 0, 0, 96, 97, 5, 68, 0, 0, 97, 98, 5, 68, 0, 0, 98, 20, 1, 0, 0, 0, 99, 100, 5, 68, 0, 0, 100, 22, 1, 0, 0, 0, 101, 102, 5, 116, 0, 0, 102, 24, 1, 0, 0, 0, 103, 104, 5, 104, 0, 0, 104, 105, 5, 104, 0, 0, 105, 26, 1, 0, 0, 0, 106, 107, 5, 104, 0, 0, 107, 28, 1, 0, 0, 0, 108, 109, 5, 109, 0, 0, 109, 110, 5, 109, 0, 0, 110, 30, 1, 0, 0, 0, 111, 112, 5, 109, 0, 0, 112, 32, 1, 0, 0, 0, 113, 114, 5, 115, 0, 0, 114, 115, 5, 115, 0, 0, 115, 34, 1, 0, 0, 0, 116, 117, 5, 115, 0, 0, 117, 36, 1, 0, 0, 0, 118, 119, 5, 102, 0, 0, 119, 120, 5, 102, 0, 0, 120, 121, 5, 102, 0, 0, 121, 122, 5, 102, 0, 0, 122, 123, 5, 102, 0, 0, 123, 124, 5, 102, 0, 0, 124, 38, 1, 0, 0, 0, 125, 126, 5, 102, 0, 0, 126, 127, 5, 102, 0, 0, 127, 128, 5, 102, 0, 0, 128, 129, 5, 102, 0, 0, 129, 130, 5, 102, 0, 0, 130, 40, 1, 0, 0, 0, 131, 132, 5, 102, 0, 0, 132, 133, 5, 102, 0, 0, 133, 134, 5, 102, 0, 0, 134, 135, 5, 102, 0, 0, 135, 42, 1, 0, 0, 0, 136, 137, 5, 102, 0, 0, 137, 138, 5, 102, 0, 0, 138, 139, 5, 102, 0, 0, 139, 44, 1, 0, 0, 0, 140, 141, 5, 102, 0, 0, 141, 142, 5, 102, 0, 0, 142, 46, 1, 0, 0, 0, 143, 144, 5, 102, 0, 0, 144, 48, 1, 0, 0, 0, 145, 146, 5, 70, 0, 0, 146, 50, 1, 0, 0, 0, 147, 148, 5, 90, 0, 0, 148, 149, 5, 90, 0, 0, 149, 150, 5, 90, 0, 0, 150, 52, 1, 0, 0, 0, 151, 152, 5, 90, 0, 0, 152, 153, 5, 90, 0, 0, 153, 54, 1, 0, 0, 0, 154, 155, 5, 90, 0, 0, 155, 56, 1, 0, 0, 0, 156, 158, 7, 0, 0, 0, 157, 156, 1, 0, 0, 0, 158, 159, 1, 0, 0, 0, 159, 157, 1, 0, 0, 0, 159, 160, 1, 0, 0, 0, 160, 58, 1, 0, 0, 0, 161, 163, 7, 1, 0, 0, 162, 161, 1, 0, 0, 0, 163, 164, 1, 0, 0, 0, 164, 162, 1, 0, 0, 0, 164, 165, 1, 0, 0, 0, 165, 60, 1, 0, 0, 0, 166, 172, 5, 39, 0, 0, 167, 171, 8, 2, 0, 0, 168, 169, 5, 39, 0, 0, 169, 171, 5, 39, 0, 0, 170, 167, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 171, 174, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, 173, 175, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 175, 176, 5, 39, 0, 0, 176, 62, 1, 0, 0, 0, 5, 0, 159, 164, 170, 172, 0] \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/DateTimeLexer.java b/src/main/java/com/relogiclabs/jschema/internal/antlr/DateTimeLexer.java new file mode 100644 index 0000000..0223da1 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/DateTimeLexer.java @@ -0,0 +1,245 @@ +package com.relogiclabs.jschema.internal.antlr; + +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.RuntimeMetaData; +import org.antlr.v4.runtime.Vocabulary; +import org.antlr.v4.runtime.VocabularyImpl; +import org.antlr.v4.runtime.atn.ATN; +import org.antlr.v4.runtime.atn.ATNDeserializer; +import org.antlr.v4.runtime.atn.LexerATNSimulator; +import org.antlr.v4.runtime.atn.PredictionContextCache; +import org.antlr.v4.runtime.dfa.DFA; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) +public class DateTimeLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + ERA=1, YEAR_NUMBER4=2, YEAR_NUMBER2=3, MONTH_NAME=4, MONTH_SHORT_NAME=5, + MONTH_NUMBER2=6, MONTH_NUMBER=7, WEEKDAY_NAME=8, WEEKDAY_SHORT_NAME=9, + DAY_NUMBER2=10, DAY_NUMBER=11, CLOCK_AM_PM=12, HOUR_NUMBER2=13, HOUR_NUMBER=14, + MINUTE_NUMBER2=15, MINUTE_NUMBER=16, SECOND_NUMBER2=17, SECOND_NUMBER=18, + FRACTION_NUMBER6=19, FRACTION_NUMBER5=20, FRACTION_NUMBER4=21, FRACTION_NUMBER3=22, + FRACTION_NUMBER2=23, FRACTION_NUMBER1=24, FRACTION_NUMBER=25, UTC_OFFSET_TIME2=26, + UTC_OFFSET_TIME1=27, UTC_OFFSET_HOUR=28, SYMBOL=29, WHITESPACE=30, TEXT=31; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + private static String[] makeRuleNames() { + return new String[] { + "ERA", "YEAR_NUMBER4", "YEAR_NUMBER2", "MONTH_NAME", "MONTH_SHORT_NAME", + "MONTH_NUMBER2", "MONTH_NUMBER", "WEEKDAY_NAME", "WEEKDAY_SHORT_NAME", + "DAY_NUMBER2", "DAY_NUMBER", "CLOCK_AM_PM", "HOUR_NUMBER2", "HOUR_NUMBER", + "MINUTE_NUMBER2", "MINUTE_NUMBER", "SECOND_NUMBER2", "SECOND_NUMBER", + "FRACTION_NUMBER6", "FRACTION_NUMBER5", "FRACTION_NUMBER4", "FRACTION_NUMBER3", + "FRACTION_NUMBER2", "FRACTION_NUMBER1", "FRACTION_NUMBER", "UTC_OFFSET_TIME2", + "UTC_OFFSET_TIME1", "UTC_OFFSET_HOUR", "SYMBOL", "WHITESPACE", "TEXT" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'G'", "'YYYY'", "'YY'", "'MMMM'", "'MMM'", "'MM'", "'M'", "'DDDD'", + "'DDD'", "'DD'", "'D'", "'t'", "'hh'", "'h'", "'mm'", "'m'", "'ss'", + "'s'", "'ffffff'", "'fffff'", "'ffff'", "'fff'", "'ff'", "'f'", "'F'", + "'ZZZ'", "'ZZ'", "'Z'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "ERA", "YEAR_NUMBER4", "YEAR_NUMBER2", "MONTH_NAME", "MONTH_SHORT_NAME", + "MONTH_NUMBER2", "MONTH_NUMBER", "WEEKDAY_NAME", "WEEKDAY_SHORT_NAME", + "DAY_NUMBER2", "DAY_NUMBER", "CLOCK_AM_PM", "HOUR_NUMBER2", "HOUR_NUMBER", + "MINUTE_NUMBER2", "MINUTE_NUMBER", "SECOND_NUMBER2", "SECOND_NUMBER", + "FRACTION_NUMBER6", "FRACTION_NUMBER5", "FRACTION_NUMBER4", "FRACTION_NUMBER3", + "FRACTION_NUMBER2", "FRACTION_NUMBER1", "FRACTION_NUMBER", "UTC_OFFSET_TIME2", + "UTC_OFFSET_TIME1", "UTC_OFFSET_HOUR", "SYMBOL", "WHITESPACE", "TEXT" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public DateTimeLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "DateTimeLexer.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\u0004\u0000\u001f\u00b1\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002"+ + "\u0001\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002"+ + "\u0004\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002"+ + "\u0007\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002"+ + "\u000b\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e"+ + "\u0002\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011"+ + "\u0002\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014"+ + "\u0002\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017"+ + "\u0002\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a"+ + "\u0002\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d"+ + "\u0002\u001e\u0007\u001e\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0002"+ + "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0004"+ + "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005"+ + "\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\b\u0001\b\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0001"+ + "\n\u0001\n\u0001\u000b\u0001\u000b\u0001\f\u0001\f\u0001\f\u0001\r\u0001"+ + "\r\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u0010"+ + "\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012"+ + "\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0013"+ + "\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0014"+ + "\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015"+ + "\u0001\u0015\u0001\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0017"+ + "\u0001\u0017\u0001\u0018\u0001\u0018\u0001\u0019\u0001\u0019\u0001\u0019"+ + "\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b"+ + "\u0001\u001c\u0004\u001c\u009e\b\u001c\u000b\u001c\f\u001c\u009f\u0001"+ + "\u001d\u0004\u001d\u00a3\b\u001d\u000b\u001d\f\u001d\u00a4\u0001\u001e"+ + "\u0001\u001e\u0001\u001e\u0001\u001e\u0005\u001e\u00ab\b\u001e\n\u001e"+ + "\f\u001e\u00ae\t\u001e\u0001\u001e\u0001\u001e\u0000\u0000\u001f\u0001"+ + "\u0001\u0003\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b\u0006\r\u0007"+ + "\u000f\b\u0011\t\u0013\n\u0015\u000b\u0017\f\u0019\r\u001b\u000e\u001d"+ + "\u000f\u001f\u0010!\u0011#\u0012%\u0013\'\u0014)\u0015+\u0016-\u0017/"+ + "\u00181\u00193\u001a5\u001b7\u001c9\u001d;\u001e=\u001f\u0001\u0000\u0003"+ + "\u0004\u0000!/:@[`{~\u0003\u0000\t\n\r\r \u0001\u0000\'\'\u00b4\u0000"+ + "\u0001\u0001\u0000\u0000\u0000\u0000\u0003\u0001\u0000\u0000\u0000\u0000"+ + "\u0005\u0001\u0000\u0000\u0000\u0000\u0007\u0001\u0000\u0000\u0000\u0000"+ + "\t\u0001\u0000\u0000\u0000\u0000\u000b\u0001\u0000\u0000\u0000\u0000\r"+ + "\u0001\u0000\u0000\u0000\u0000\u000f\u0001\u0000\u0000\u0000\u0000\u0011"+ + "\u0001\u0000\u0000\u0000\u0000\u0013\u0001\u0000\u0000\u0000\u0000\u0015"+ + "\u0001\u0000\u0000\u0000\u0000\u0017\u0001\u0000\u0000\u0000\u0000\u0019"+ + "\u0001\u0000\u0000\u0000\u0000\u001b\u0001\u0000\u0000\u0000\u0000\u001d"+ + "\u0001\u0000\u0000\u0000\u0000\u001f\u0001\u0000\u0000\u0000\u0000!\u0001"+ + "\u0000\u0000\u0000\u0000#\u0001\u0000\u0000\u0000\u0000%\u0001\u0000\u0000"+ + "\u0000\u0000\'\u0001\u0000\u0000\u0000\u0000)\u0001\u0000\u0000\u0000"+ + "\u0000+\u0001\u0000\u0000\u0000\u0000-\u0001\u0000\u0000\u0000\u0000/"+ + "\u0001\u0000\u0000\u0000\u00001\u0001\u0000\u0000\u0000\u00003\u0001\u0000"+ + "\u0000\u0000\u00005\u0001\u0000\u0000\u0000\u00007\u0001\u0000\u0000\u0000"+ + "\u00009\u0001\u0000\u0000\u0000\u0000;\u0001\u0000\u0000\u0000\u0000="+ + "\u0001\u0000\u0000\u0000\u0001?\u0001\u0000\u0000\u0000\u0003A\u0001\u0000"+ + "\u0000\u0000\u0005F\u0001\u0000\u0000\u0000\u0007I\u0001\u0000\u0000\u0000"+ + "\tN\u0001\u0000\u0000\u0000\u000bR\u0001\u0000\u0000\u0000\rU\u0001\u0000"+ + "\u0000\u0000\u000fW\u0001\u0000\u0000\u0000\u0011\\\u0001\u0000\u0000"+ + "\u0000\u0013`\u0001\u0000\u0000\u0000\u0015c\u0001\u0000\u0000\u0000\u0017"+ + "e\u0001\u0000\u0000\u0000\u0019g\u0001\u0000\u0000\u0000\u001bj\u0001"+ + "\u0000\u0000\u0000\u001dl\u0001\u0000\u0000\u0000\u001fo\u0001\u0000\u0000"+ + "\u0000!q\u0001\u0000\u0000\u0000#t\u0001\u0000\u0000\u0000%v\u0001\u0000"+ + "\u0000\u0000\'}\u0001\u0000\u0000\u0000)\u0083\u0001\u0000\u0000\u0000"+ + "+\u0088\u0001\u0000\u0000\u0000-\u008c\u0001\u0000\u0000\u0000/\u008f"+ + "\u0001\u0000\u0000\u00001\u0091\u0001\u0000\u0000\u00003\u0093\u0001\u0000"+ + "\u0000\u00005\u0097\u0001\u0000\u0000\u00007\u009a\u0001\u0000\u0000\u0000"+ + "9\u009d\u0001\u0000\u0000\u0000;\u00a2\u0001\u0000\u0000\u0000=\u00a6"+ + "\u0001\u0000\u0000\u0000?@\u0005G\u0000\u0000@\u0002\u0001\u0000\u0000"+ + "\u0000AB\u0005Y\u0000\u0000BC\u0005Y\u0000\u0000CD\u0005Y\u0000\u0000"+ + "DE\u0005Y\u0000\u0000E\u0004\u0001\u0000\u0000\u0000FG\u0005Y\u0000\u0000"+ + "GH\u0005Y\u0000\u0000H\u0006\u0001\u0000\u0000\u0000IJ\u0005M\u0000\u0000"+ + "JK\u0005M\u0000\u0000KL\u0005M\u0000\u0000LM\u0005M\u0000\u0000M\b\u0001"+ + "\u0000\u0000\u0000NO\u0005M\u0000\u0000OP\u0005M\u0000\u0000PQ\u0005M"+ + "\u0000\u0000Q\n\u0001\u0000\u0000\u0000RS\u0005M\u0000\u0000ST\u0005M"+ + "\u0000\u0000T\f\u0001\u0000\u0000\u0000UV\u0005M\u0000\u0000V\u000e\u0001"+ + "\u0000\u0000\u0000WX\u0005D\u0000\u0000XY\u0005D\u0000\u0000YZ\u0005D"+ + "\u0000\u0000Z[\u0005D\u0000\u0000[\u0010\u0001\u0000\u0000\u0000\\]\u0005"+ + "D\u0000\u0000]^\u0005D\u0000\u0000^_\u0005D\u0000\u0000_\u0012\u0001\u0000"+ + "\u0000\u0000`a\u0005D\u0000\u0000ab\u0005D\u0000\u0000b\u0014\u0001\u0000"+ + "\u0000\u0000cd\u0005D\u0000\u0000d\u0016\u0001\u0000\u0000\u0000ef\u0005"+ + "t\u0000\u0000f\u0018\u0001\u0000\u0000\u0000gh\u0005h\u0000\u0000hi\u0005"+ + "h\u0000\u0000i\u001a\u0001\u0000\u0000\u0000jk\u0005h\u0000\u0000k\u001c"+ + "\u0001\u0000\u0000\u0000lm\u0005m\u0000\u0000mn\u0005m\u0000\u0000n\u001e"+ + "\u0001\u0000\u0000\u0000op\u0005m\u0000\u0000p \u0001\u0000\u0000\u0000"+ + "qr\u0005s\u0000\u0000rs\u0005s\u0000\u0000s\"\u0001\u0000\u0000\u0000"+ + "tu\u0005s\u0000\u0000u$\u0001\u0000\u0000\u0000vw\u0005f\u0000\u0000w"+ + "x\u0005f\u0000\u0000xy\u0005f\u0000\u0000yz\u0005f\u0000\u0000z{\u0005"+ + "f\u0000\u0000{|\u0005f\u0000\u0000|&\u0001\u0000\u0000\u0000}~\u0005f"+ + "\u0000\u0000~\u007f\u0005f\u0000\u0000\u007f\u0080\u0005f\u0000\u0000"+ + "\u0080\u0081\u0005f\u0000\u0000\u0081\u0082\u0005f\u0000\u0000\u0082("+ + "\u0001\u0000\u0000\u0000\u0083\u0084\u0005f\u0000\u0000\u0084\u0085\u0005"+ + "f\u0000\u0000\u0085\u0086\u0005f\u0000\u0000\u0086\u0087\u0005f\u0000"+ + "\u0000\u0087*\u0001\u0000\u0000\u0000\u0088\u0089\u0005f\u0000\u0000\u0089"+ + "\u008a\u0005f\u0000\u0000\u008a\u008b\u0005f\u0000\u0000\u008b,\u0001"+ + "\u0000\u0000\u0000\u008c\u008d\u0005f\u0000\u0000\u008d\u008e\u0005f\u0000"+ + "\u0000\u008e.\u0001\u0000\u0000\u0000\u008f\u0090\u0005f\u0000\u0000\u0090"+ + "0\u0001\u0000\u0000\u0000\u0091\u0092\u0005F\u0000\u0000\u00922\u0001"+ + "\u0000\u0000\u0000\u0093\u0094\u0005Z\u0000\u0000\u0094\u0095\u0005Z\u0000"+ + "\u0000\u0095\u0096\u0005Z\u0000\u0000\u00964\u0001\u0000\u0000\u0000\u0097"+ + "\u0098\u0005Z\u0000\u0000\u0098\u0099\u0005Z\u0000\u0000\u00996\u0001"+ + "\u0000\u0000\u0000\u009a\u009b\u0005Z\u0000\u0000\u009b8\u0001\u0000\u0000"+ + "\u0000\u009c\u009e\u0007\u0000\u0000\u0000\u009d\u009c\u0001\u0000\u0000"+ + "\u0000\u009e\u009f\u0001\u0000\u0000\u0000\u009f\u009d\u0001\u0000\u0000"+ + "\u0000\u009f\u00a0\u0001\u0000\u0000\u0000\u00a0:\u0001\u0000\u0000\u0000"+ + "\u00a1\u00a3\u0007\u0001\u0000\u0000\u00a2\u00a1\u0001\u0000\u0000\u0000"+ + "\u00a3\u00a4\u0001\u0000\u0000\u0000\u00a4\u00a2\u0001\u0000\u0000\u0000"+ + "\u00a4\u00a5\u0001\u0000\u0000\u0000\u00a5<\u0001\u0000\u0000\u0000\u00a6"+ + "\u00ac\u0005\'\u0000\u0000\u00a7\u00ab\b\u0002\u0000\u0000\u00a8\u00a9"+ + "\u0005\'\u0000\u0000\u00a9\u00ab\u0005\'\u0000\u0000\u00aa\u00a7\u0001"+ + "\u0000\u0000\u0000\u00aa\u00a8\u0001\u0000\u0000\u0000\u00ab\u00ae\u0001"+ + "\u0000\u0000\u0000\u00ac\u00aa\u0001\u0000\u0000\u0000\u00ac\u00ad\u0001"+ + "\u0000\u0000\u0000\u00ad\u00af\u0001\u0000\u0000\u0000\u00ae\u00ac\u0001"+ + "\u0000\u0000\u0000\u00af\u00b0\u0005\'\u0000\u0000\u00b0>\u0001\u0000"+ + "\u0000\u0000\u0005\u0000\u009f\u00a4\u00aa\u00ac\u0000"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/DateTimeLexer.tokens b/src/main/java/com/relogiclabs/jschema/internal/antlr/DateTimeLexer.tokens similarity index 100% rename from src/main/java/com/relogiclabs/json/schema/internal/antlr/DateTimeLexer.tokens rename to src/main/java/com/relogiclabs/jschema/internal/antlr/DateTimeLexer.tokens diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonLexer.interp b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonLexer.interp new file mode 100644 index 0000000..0cf649b --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonLexer.interp @@ -0,0 +1,66 @@ +token literal names: +null +'true' +'false' +'null' +'[' +']' +'{' +'}' +',' +':' +null +null +null +null +null + +token symbolic names: +null +TRUE +FALSE +NULL +LBRACKET +RBRACKET +LBRACE +RBRACE +COMMA +COLON +STRING +INTEGER +FLOAT +DOUBLE +WHITE_SPACE + +rule names: +TRUE +FALSE +NULL +LBRACKET +RBRACKET +LBRACE +RBRACE +COMMA +COLON +STRING +ESCAPE +UNICODE +HEXDIGIT +SAFECODEPOINT +INTEGER +FLOAT +DOUBLE +INTDIGIT +EXPONENT +DIGIT +WHITE_SPACE + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 14, 147, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 5, 9, 75, 8, 9, 10, 9, 12, 9, 78, 9, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 3, 10, 85, 8, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 3, 14, 98, 8, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 4, 15, 105, 8, 15, 11, 15, 12, 15, 106, 1, 16, 1, 16, 1, 16, 4, 16, 112, 8, 16, 11, 16, 12, 16, 113, 3, 16, 116, 8, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 5, 17, 123, 8, 17, 10, 17, 12, 17, 126, 9, 17, 3, 17, 128, 8, 17, 1, 18, 1, 18, 3, 18, 132, 8, 18, 1, 18, 4, 18, 135, 8, 18, 11, 18, 12, 18, 136, 1, 19, 1, 19, 1, 20, 4, 20, 142, 8, 20, 11, 20, 12, 20, 143, 1, 20, 1, 20, 0, 0, 21, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 0, 23, 0, 25, 0, 27, 0, 29, 11, 31, 12, 33, 13, 35, 0, 37, 0, 39, 0, 41, 14, 1, 0, 8, 8, 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 0, 31, 34, 34, 92, 92, 1, 0, 49, 57, 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 1, 0, 48, 57, 3, 0, 9, 10, 13, 13, 32, 32, 151, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 1, 43, 1, 0, 0, 0, 3, 48, 1, 0, 0, 0, 5, 54, 1, 0, 0, 0, 7, 59, 1, 0, 0, 0, 9, 61, 1, 0, 0, 0, 11, 63, 1, 0, 0, 0, 13, 65, 1, 0, 0, 0, 15, 67, 1, 0, 0, 0, 17, 69, 1, 0, 0, 0, 19, 71, 1, 0, 0, 0, 21, 81, 1, 0, 0, 0, 23, 86, 1, 0, 0, 0, 25, 92, 1, 0, 0, 0, 27, 94, 1, 0, 0, 0, 29, 97, 1, 0, 0, 0, 31, 101, 1, 0, 0, 0, 33, 108, 1, 0, 0, 0, 35, 127, 1, 0, 0, 0, 37, 129, 1, 0, 0, 0, 39, 138, 1, 0, 0, 0, 41, 141, 1, 0, 0, 0, 43, 44, 5, 116, 0, 0, 44, 45, 5, 114, 0, 0, 45, 46, 5, 117, 0, 0, 46, 47, 5, 101, 0, 0, 47, 2, 1, 0, 0, 0, 48, 49, 5, 102, 0, 0, 49, 50, 5, 97, 0, 0, 50, 51, 5, 108, 0, 0, 51, 52, 5, 115, 0, 0, 52, 53, 5, 101, 0, 0, 53, 4, 1, 0, 0, 0, 54, 55, 5, 110, 0, 0, 55, 56, 5, 117, 0, 0, 56, 57, 5, 108, 0, 0, 57, 58, 5, 108, 0, 0, 58, 6, 1, 0, 0, 0, 59, 60, 5, 91, 0, 0, 60, 8, 1, 0, 0, 0, 61, 62, 5, 93, 0, 0, 62, 10, 1, 0, 0, 0, 63, 64, 5, 123, 0, 0, 64, 12, 1, 0, 0, 0, 65, 66, 5, 125, 0, 0, 66, 14, 1, 0, 0, 0, 67, 68, 5, 44, 0, 0, 68, 16, 1, 0, 0, 0, 69, 70, 5, 58, 0, 0, 70, 18, 1, 0, 0, 0, 71, 76, 5, 34, 0, 0, 72, 75, 3, 21, 10, 0, 73, 75, 3, 27, 13, 0, 74, 72, 1, 0, 0, 0, 74, 73, 1, 0, 0, 0, 75, 78, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 79, 1, 0, 0, 0, 78, 76, 1, 0, 0, 0, 79, 80, 5, 34, 0, 0, 80, 20, 1, 0, 0, 0, 81, 84, 5, 92, 0, 0, 82, 85, 7, 0, 0, 0, 83, 85, 3, 23, 11, 0, 84, 82, 1, 0, 0, 0, 84, 83, 1, 0, 0, 0, 85, 22, 1, 0, 0, 0, 86, 87, 5, 117, 0, 0, 87, 88, 3, 25, 12, 0, 88, 89, 3, 25, 12, 0, 89, 90, 3, 25, 12, 0, 90, 91, 3, 25, 12, 0, 91, 24, 1, 0, 0, 0, 92, 93, 7, 1, 0, 0, 93, 26, 1, 0, 0, 0, 94, 95, 8, 2, 0, 0, 95, 28, 1, 0, 0, 0, 96, 98, 5, 45, 0, 0, 97, 96, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 99, 1, 0, 0, 0, 99, 100, 3, 35, 17, 0, 100, 30, 1, 0, 0, 0, 101, 102, 3, 29, 14, 0, 102, 104, 5, 46, 0, 0, 103, 105, 3, 39, 19, 0, 104, 103, 1, 0, 0, 0, 105, 106, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 106, 107, 1, 0, 0, 0, 107, 32, 1, 0, 0, 0, 108, 115, 3, 29, 14, 0, 109, 111, 5, 46, 0, 0, 110, 112, 3, 39, 19, 0, 111, 110, 1, 0, 0, 0, 112, 113, 1, 0, 0, 0, 113, 111, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 116, 1, 0, 0, 0, 115, 109, 1, 0, 0, 0, 115, 116, 1, 0, 0, 0, 116, 117, 1, 0, 0, 0, 117, 118, 3, 37, 18, 0, 118, 34, 1, 0, 0, 0, 119, 128, 5, 48, 0, 0, 120, 124, 7, 3, 0, 0, 121, 123, 3, 39, 19, 0, 122, 121, 1, 0, 0, 0, 123, 126, 1, 0, 0, 0, 124, 122, 1, 0, 0, 0, 124, 125, 1, 0, 0, 0, 125, 128, 1, 0, 0, 0, 126, 124, 1, 0, 0, 0, 127, 119, 1, 0, 0, 0, 127, 120, 1, 0, 0, 0, 128, 36, 1, 0, 0, 0, 129, 131, 7, 4, 0, 0, 130, 132, 7, 5, 0, 0, 131, 130, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 134, 1, 0, 0, 0, 133, 135, 3, 39, 19, 0, 134, 133, 1, 0, 0, 0, 135, 136, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 136, 137, 1, 0, 0, 0, 137, 38, 1, 0, 0, 0, 138, 139, 7, 6, 0, 0, 139, 40, 1, 0, 0, 0, 140, 142, 7, 7, 0, 0, 141, 140, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 141, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 144, 145, 1, 0, 0, 0, 145, 146, 6, 20, 0, 0, 146, 42, 1, 0, 0, 0, 13, 0, 74, 76, 84, 97, 106, 113, 115, 124, 127, 131, 136, 143, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonLexer.java b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonLexer.java new file mode 100644 index 0000000..ff0b491 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonLexer.java @@ -0,0 +1,210 @@ +package com.relogiclabs.jschema.internal.antlr; + +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.RuntimeMetaData; +import org.antlr.v4.runtime.Vocabulary; +import org.antlr.v4.runtime.VocabularyImpl; +import org.antlr.v4.runtime.atn.ATN; +import org.antlr.v4.runtime.atn.ATNDeserializer; +import org.antlr.v4.runtime.atn.LexerATNSimulator; +import org.antlr.v4.runtime.atn.PredictionContextCache; +import org.antlr.v4.runtime.dfa.DFA; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) +public class JsonLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + TRUE=1, FALSE=2, NULL=3, LBRACKET=4, RBRACKET=5, LBRACE=6, RBRACE=7, COMMA=8, + COLON=9, STRING=10, INTEGER=11, FLOAT=12, DOUBLE=13, WHITE_SPACE=14; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + private static String[] makeRuleNames() { + return new String[] { + "TRUE", "FALSE", "NULL", "LBRACKET", "RBRACKET", "LBRACE", "RBRACE", + "COMMA", "COLON", "STRING", "ESCAPE", "UNICODE", "HEXDIGIT", "SAFECODEPOINT", + "INTEGER", "FLOAT", "DOUBLE", "INTDIGIT", "EXPONENT", "DIGIT", "WHITE_SPACE" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'true'", "'false'", "'null'", "'['", "']'", "'{'", "'}'", "','", + "':'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "TRUE", "FALSE", "NULL", "LBRACKET", "RBRACKET", "LBRACE", "RBRACE", + "COMMA", "COLON", "STRING", "INTEGER", "FLOAT", "DOUBLE", "WHITE_SPACE" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public JsonLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "JsonLexer.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\u0004\u0000\u000e\u0093\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002"+ + "\u0001\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002"+ + "\u0004\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002"+ + "\u0007\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002"+ + "\u000b\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e"+ + "\u0002\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011"+ + "\u0002\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014"+ + "\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002"+ + "\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+ + "\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006"+ + "\u0001\u0007\u0001\u0007\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0005"+ + "\tK\b\t\n\t\f\tN\t\t\u0001\t\u0001\t\u0001\n\u0001\n\u0001\n\u0003\nU"+ + "\b\n\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001"+ + "\u000b\u0001\f\u0001\f\u0001\r\u0001\r\u0001\u000e\u0003\u000eb\b\u000e"+ + "\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u000f\u0004\u000f"+ + "i\b\u000f\u000b\u000f\f\u000fj\u0001\u0010\u0001\u0010\u0001\u0010\u0004"+ + "\u0010p\b\u0010\u000b\u0010\f\u0010q\u0003\u0010t\b\u0010\u0001\u0010"+ + "\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0011\u0005\u0011{\b\u0011"+ + "\n\u0011\f\u0011~\t\u0011\u0003\u0011\u0080\b\u0011\u0001\u0012\u0001"+ + "\u0012\u0003\u0012\u0084\b\u0012\u0001\u0012\u0004\u0012\u0087\b\u0012"+ + "\u000b\u0012\f\u0012\u0088\u0001\u0013\u0001\u0013\u0001\u0014\u0004\u0014"+ + "\u008e\b\u0014\u000b\u0014\f\u0014\u008f\u0001\u0014\u0001\u0014\u0000"+ + "\u0000\u0015\u0001\u0001\u0003\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b"+ + "\u0006\r\u0007\u000f\b\u0011\t\u0013\n\u0015\u0000\u0017\u0000\u0019\u0000"+ + "\u001b\u0000\u001d\u000b\u001f\f!\r#\u0000%\u0000\'\u0000)\u000e\u0001"+ + "\u0000\b\b\u0000\"\"//\\\\bbffnnrrtt\u0003\u000009AFaf\u0003\u0000\u0000"+ + "\u001f\"\"\\\\\u0001\u000019\u0002\u0000EEee\u0002\u0000++--\u0001\u0000"+ + "09\u0003\u0000\t\n\r\r \u0097\u0000\u0001\u0001\u0000\u0000\u0000\u0000"+ + "\u0003\u0001\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0000"+ + "\u0007\u0001\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0000\u000b"+ + "\u0001\u0000\u0000\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000\u000f\u0001"+ + "\u0000\u0000\u0000\u0000\u0011\u0001\u0000\u0000\u0000\u0000\u0013\u0001"+ + "\u0000\u0000\u0000\u0000\u001d\u0001\u0000\u0000\u0000\u0000\u001f\u0001"+ + "\u0000\u0000\u0000\u0000!\u0001\u0000\u0000\u0000\u0000)\u0001\u0000\u0000"+ + "\u0000\u0001+\u0001\u0000\u0000\u0000\u00030\u0001\u0000\u0000\u0000\u0005"+ + "6\u0001\u0000\u0000\u0000\u0007;\u0001\u0000\u0000\u0000\t=\u0001\u0000"+ + "\u0000\u0000\u000b?\u0001\u0000\u0000\u0000\rA\u0001\u0000\u0000\u0000"+ + "\u000fC\u0001\u0000\u0000\u0000\u0011E\u0001\u0000\u0000\u0000\u0013G"+ + "\u0001\u0000\u0000\u0000\u0015Q\u0001\u0000\u0000\u0000\u0017V\u0001\u0000"+ + "\u0000\u0000\u0019\\\u0001\u0000\u0000\u0000\u001b^\u0001\u0000\u0000"+ + "\u0000\u001da\u0001\u0000\u0000\u0000\u001fe\u0001\u0000\u0000\u0000!"+ + "l\u0001\u0000\u0000\u0000#\u007f\u0001\u0000\u0000\u0000%\u0081\u0001"+ + "\u0000\u0000\u0000\'\u008a\u0001\u0000\u0000\u0000)\u008d\u0001\u0000"+ + "\u0000\u0000+,\u0005t\u0000\u0000,-\u0005r\u0000\u0000-.\u0005u\u0000"+ + "\u0000./\u0005e\u0000\u0000/\u0002\u0001\u0000\u0000\u000001\u0005f\u0000"+ + "\u000012\u0005a\u0000\u000023\u0005l\u0000\u000034\u0005s\u0000\u0000"+ + "45\u0005e\u0000\u00005\u0004\u0001\u0000\u0000\u000067\u0005n\u0000\u0000"+ + "78\u0005u\u0000\u000089\u0005l\u0000\u00009:\u0005l\u0000\u0000:\u0006"+ + "\u0001\u0000\u0000\u0000;<\u0005[\u0000\u0000<\b\u0001\u0000\u0000\u0000"+ + "=>\u0005]\u0000\u0000>\n\u0001\u0000\u0000\u0000?@\u0005{\u0000\u0000"+ + "@\f\u0001\u0000\u0000\u0000AB\u0005}\u0000\u0000B\u000e\u0001\u0000\u0000"+ + "\u0000CD\u0005,\u0000\u0000D\u0010\u0001\u0000\u0000\u0000EF\u0005:\u0000"+ + "\u0000F\u0012\u0001\u0000\u0000\u0000GL\u0005\"\u0000\u0000HK\u0003\u0015"+ + "\n\u0000IK\u0003\u001b\r\u0000JH\u0001\u0000\u0000\u0000JI\u0001\u0000"+ + "\u0000\u0000KN\u0001\u0000\u0000\u0000LJ\u0001\u0000\u0000\u0000LM\u0001"+ + "\u0000\u0000\u0000MO\u0001\u0000\u0000\u0000NL\u0001\u0000\u0000\u0000"+ + "OP\u0005\"\u0000\u0000P\u0014\u0001\u0000\u0000\u0000QT\u0005\\\u0000"+ + "\u0000RU\u0007\u0000\u0000\u0000SU\u0003\u0017\u000b\u0000TR\u0001\u0000"+ + "\u0000\u0000TS\u0001\u0000\u0000\u0000U\u0016\u0001\u0000\u0000\u0000"+ + "VW\u0005u\u0000\u0000WX\u0003\u0019\f\u0000XY\u0003\u0019\f\u0000YZ\u0003"+ + "\u0019\f\u0000Z[\u0003\u0019\f\u0000[\u0018\u0001\u0000\u0000\u0000\\"+ + "]\u0007\u0001\u0000\u0000]\u001a\u0001\u0000\u0000\u0000^_\b\u0002\u0000"+ + "\u0000_\u001c\u0001\u0000\u0000\u0000`b\u0005-\u0000\u0000a`\u0001\u0000"+ + "\u0000\u0000ab\u0001\u0000\u0000\u0000bc\u0001\u0000\u0000\u0000cd\u0003"+ + "#\u0011\u0000d\u001e\u0001\u0000\u0000\u0000ef\u0003\u001d\u000e\u0000"+ + "fh\u0005.\u0000\u0000gi\u0003\'\u0013\u0000hg\u0001\u0000\u0000\u0000"+ + "ij\u0001\u0000\u0000\u0000jh\u0001\u0000\u0000\u0000jk\u0001\u0000\u0000"+ + "\u0000k \u0001\u0000\u0000\u0000ls\u0003\u001d\u000e\u0000mo\u0005.\u0000"+ + "\u0000np\u0003\'\u0013\u0000on\u0001\u0000\u0000\u0000pq\u0001\u0000\u0000"+ + "\u0000qo\u0001\u0000\u0000\u0000qr\u0001\u0000\u0000\u0000rt\u0001\u0000"+ + "\u0000\u0000sm\u0001\u0000\u0000\u0000st\u0001\u0000\u0000\u0000tu\u0001"+ + "\u0000\u0000\u0000uv\u0003%\u0012\u0000v\"\u0001\u0000\u0000\u0000w\u0080"+ + "\u00050\u0000\u0000x|\u0007\u0003\u0000\u0000y{\u0003\'\u0013\u0000zy"+ + "\u0001\u0000\u0000\u0000{~\u0001\u0000\u0000\u0000|z\u0001\u0000\u0000"+ + "\u0000|}\u0001\u0000\u0000\u0000}\u0080\u0001\u0000\u0000\u0000~|\u0001"+ + "\u0000\u0000\u0000\u007fw\u0001\u0000\u0000\u0000\u007fx\u0001\u0000\u0000"+ + "\u0000\u0080$\u0001\u0000\u0000\u0000\u0081\u0083\u0007\u0004\u0000\u0000"+ + "\u0082\u0084\u0007\u0005\u0000\u0000\u0083\u0082\u0001\u0000\u0000\u0000"+ + "\u0083\u0084\u0001\u0000\u0000\u0000\u0084\u0086\u0001\u0000\u0000\u0000"+ + "\u0085\u0087\u0003\'\u0013\u0000\u0086\u0085\u0001\u0000\u0000\u0000\u0087"+ + "\u0088\u0001\u0000\u0000\u0000\u0088\u0086\u0001\u0000\u0000\u0000\u0088"+ + "\u0089\u0001\u0000\u0000\u0000\u0089&\u0001\u0000\u0000\u0000\u008a\u008b"+ + "\u0007\u0006\u0000\u0000\u008b(\u0001\u0000\u0000\u0000\u008c\u008e\u0007"+ + "\u0007\u0000\u0000\u008d\u008c\u0001\u0000\u0000\u0000\u008e\u008f\u0001"+ + "\u0000\u0000\u0000\u008f\u008d\u0001\u0000\u0000\u0000\u008f\u0090\u0001"+ + "\u0000\u0000\u0000\u0090\u0091\u0001\u0000\u0000\u0000\u0091\u0092\u0006"+ + "\u0014\u0000\u0000\u0092*\u0001\u0000\u0000\u0000\r\u0000JLTajqs|\u007f"+ + "\u0083\u0088\u008f\u0001\u0006\u0000\u0000"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonLexer.tokens b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonLexer.tokens similarity index 100% rename from src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonLexer.tokens rename to src/main/java/com/relogiclabs/jschema/internal/antlr/JsonLexer.tokens diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParser.interp b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParser.interp new file mode 100644 index 0000000..1b344ad --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParser.interp @@ -0,0 +1,45 @@ +token literal names: +null +'true' +'false' +'null' +'[' +']' +'{' +'}' +',' +':' +null +null +null +null +null + +token symbolic names: +null +TRUE +FALSE +NULL +LBRACKET +RBRACKET +LBRACE +RBRACE +COMMA +COLON +STRING +INTEGER +FLOAT +DOUBLE +WHITE_SPACE + +rule names: +json +valueNode +objectNode +propertyNode +arrayNode +primitiveNode + + +atn: +[4, 1, 14, 60, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 3, 1, 19, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 25, 8, 2, 10, 2, 12, 2, 28, 9, 2, 3, 2, 30, 8, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 5, 4, 42, 8, 4, 10, 4, 12, 4, 45, 9, 4, 3, 4, 47, 8, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 58, 8, 5, 1, 5, 0, 0, 6, 0, 2, 4, 6, 8, 10, 0, 0, 65, 0, 12, 1, 0, 0, 0, 2, 18, 1, 0, 0, 0, 4, 20, 1, 0, 0, 0, 6, 33, 1, 0, 0, 0, 8, 37, 1, 0, 0, 0, 10, 57, 1, 0, 0, 0, 12, 13, 3, 2, 1, 0, 13, 14, 5, 0, 0, 1, 14, 1, 1, 0, 0, 0, 15, 19, 3, 10, 5, 0, 16, 19, 3, 4, 2, 0, 17, 19, 3, 8, 4, 0, 18, 15, 1, 0, 0, 0, 18, 16, 1, 0, 0, 0, 18, 17, 1, 0, 0, 0, 19, 3, 1, 0, 0, 0, 20, 29, 5, 6, 0, 0, 21, 26, 3, 6, 3, 0, 22, 23, 5, 8, 0, 0, 23, 25, 3, 6, 3, 0, 24, 22, 1, 0, 0, 0, 25, 28, 1, 0, 0, 0, 26, 24, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 30, 1, 0, 0, 0, 28, 26, 1, 0, 0, 0, 29, 21, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 31, 1, 0, 0, 0, 31, 32, 5, 7, 0, 0, 32, 5, 1, 0, 0, 0, 33, 34, 5, 10, 0, 0, 34, 35, 5, 9, 0, 0, 35, 36, 3, 2, 1, 0, 36, 7, 1, 0, 0, 0, 37, 46, 5, 4, 0, 0, 38, 43, 3, 2, 1, 0, 39, 40, 5, 8, 0, 0, 40, 42, 3, 2, 1, 0, 41, 39, 1, 0, 0, 0, 42, 45, 1, 0, 0, 0, 43, 41, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 47, 1, 0, 0, 0, 45, 43, 1, 0, 0, 0, 46, 38, 1, 0, 0, 0, 46, 47, 1, 0, 0, 0, 47, 48, 1, 0, 0, 0, 48, 49, 5, 5, 0, 0, 49, 9, 1, 0, 0, 0, 50, 58, 5, 1, 0, 0, 51, 58, 5, 2, 0, 0, 52, 58, 5, 10, 0, 0, 53, 58, 5, 11, 0, 0, 54, 58, 5, 12, 0, 0, 55, 58, 5, 13, 0, 0, 56, 58, 5, 3, 0, 0, 57, 50, 1, 0, 0, 0, 57, 51, 1, 0, 0, 0, 57, 52, 1, 0, 0, 0, 57, 53, 1, 0, 0, 0, 57, 54, 1, 0, 0, 0, 57, 55, 1, 0, 0, 0, 57, 56, 1, 0, 0, 0, 58, 11, 1, 0, 0, 0, 6, 18, 26, 29, 43, 46, 57] \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParser.java b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParser.java new file mode 100644 index 0000000..b7f9f34 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParser.java @@ -0,0 +1,618 @@ +package com.relogiclabs.jschema.internal.antlr; + +import org.antlr.v4.runtime.NoViableAltException; +import org.antlr.v4.runtime.Parser; +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.RecognitionException; +import org.antlr.v4.runtime.RuntimeMetaData; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.Vocabulary; +import org.antlr.v4.runtime.VocabularyImpl; +import org.antlr.v4.runtime.atn.ATN; +import org.antlr.v4.runtime.atn.ATNDeserializer; +import org.antlr.v4.runtime.atn.ParserATNSimulator; +import org.antlr.v4.runtime.atn.PredictionContextCache; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.tree.ParseTreeVisitor; +import org.antlr.v4.runtime.tree.TerminalNode; + +import java.util.List; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) +public class JsonParser extends Parser { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + TRUE=1, FALSE=2, NULL=3, LBRACKET=4, RBRACKET=5, LBRACE=6, RBRACE=7, COMMA=8, + COLON=9, STRING=10, INTEGER=11, FLOAT=12, DOUBLE=13, WHITE_SPACE=14; + public static final int + RULE_json = 0, RULE_valueNode = 1, RULE_objectNode = 2, RULE_propertyNode = 3, + RULE_arrayNode = 4, RULE_primitiveNode = 5; + private static String[] makeRuleNames() { + return new String[] { + "json", "valueNode", "objectNode", "propertyNode", "arrayNode", "primitiveNode" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'true'", "'false'", "'null'", "'['", "']'", "'{'", "'}'", "','", + "':'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "TRUE", "FALSE", "NULL", "LBRACKET", "RBRACKET", "LBRACE", "RBRACE", + "COMMA", "COLON", "STRING", "INTEGER", "FLOAT", "DOUBLE", "WHITE_SPACE" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "JsonParser.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public JsonParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @SuppressWarnings("CheckReturnValue") + public static class JsonContext extends ParserRuleContext { + public ValueNodeContext valueNode() { + return getRuleContext(ValueNodeContext.class,0); + } + public TerminalNode EOF() { return getToken(JsonParser.EOF, 0); } + public JsonContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_json; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitJson(this); + else return visitor.visitChildren(this); + } + } + + public final JsonContext json() throws RecognitionException { + JsonContext _localctx = new JsonContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_json); + try { + enterOuterAlt(_localctx, 1); + { + setState(12); + valueNode(); + setState(13); + match(EOF); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ValueNodeContext extends ParserRuleContext { + public PrimitiveNodeContext primitiveNode() { + return getRuleContext(PrimitiveNodeContext.class,0); + } + public ObjectNodeContext objectNode() { + return getRuleContext(ObjectNodeContext.class,0); + } + public ArrayNodeContext arrayNode() { + return getRuleContext(ArrayNodeContext.class,0); + } + public ValueNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_valueNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitValueNode(this); + else return visitor.visitChildren(this); + } + } + + public final ValueNodeContext valueNode() throws RecognitionException { + ValueNodeContext _localctx = new ValueNodeContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_valueNode); + try { + setState(18); + _errHandler.sync(this); + switch (_input.LA(1)) { + case TRUE: + case FALSE: + case NULL: + case STRING: + case INTEGER: + case FLOAT: + case DOUBLE: + enterOuterAlt(_localctx, 1); + { + setState(15); + primitiveNode(); + } + break; + case LBRACE: + enterOuterAlt(_localctx, 2); + { + setState(16); + objectNode(); + } + break; + case LBRACKET: + enterOuterAlt(_localctx, 3); + { + setState(17); + arrayNode(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ObjectNodeContext extends ParserRuleContext { + public TerminalNode LBRACE() { return getToken(JsonParser.LBRACE, 0); } + public TerminalNode RBRACE() { return getToken(JsonParser.RBRACE, 0); } + public List propertyNode() { + return getRuleContexts(PropertyNodeContext.class); + } + public PropertyNodeContext propertyNode(int i) { + return getRuleContext(PropertyNodeContext.class,i); + } + public List COMMA() { return getTokens(JsonParser.COMMA); } + public TerminalNode COMMA(int i) { + return getToken(JsonParser.COMMA, i); + } + public ObjectNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_objectNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitObjectNode(this); + else return visitor.visitChildren(this); + } + } + + public final ObjectNodeContext objectNode() throws RecognitionException { + ObjectNodeContext _localctx = new ObjectNodeContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_objectNode); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(20); + match(LBRACE); + setState(29); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==STRING) { + { + setState(21); + propertyNode(); + setState(26); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==COMMA) { + { + { + setState(22); + match(COMMA); + setState(23); + propertyNode(); + } + } + setState(28); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(31); + match(RBRACE); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class PropertyNodeContext extends ParserRuleContext { + public TerminalNode STRING() { return getToken(JsonParser.STRING, 0); } + public TerminalNode COLON() { return getToken(JsonParser.COLON, 0); } + public ValueNodeContext valueNode() { + return getRuleContext(ValueNodeContext.class,0); + } + public PropertyNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_propertyNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPropertyNode(this); + else return visitor.visitChildren(this); + } + } + + public final PropertyNodeContext propertyNode() throws RecognitionException { + PropertyNodeContext _localctx = new PropertyNodeContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_propertyNode); + try { + enterOuterAlt(_localctx, 1); + { + setState(33); + match(STRING); + setState(34); + match(COLON); + setState(35); + valueNode(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ArrayNodeContext extends ParserRuleContext { + public TerminalNode LBRACKET() { return getToken(JsonParser.LBRACKET, 0); } + public TerminalNode RBRACKET() { return getToken(JsonParser.RBRACKET, 0); } + public List valueNode() { + return getRuleContexts(ValueNodeContext.class); + } + public ValueNodeContext valueNode(int i) { + return getRuleContext(ValueNodeContext.class,i); + } + public List COMMA() { return getTokens(JsonParser.COMMA); } + public TerminalNode COMMA(int i) { + return getToken(JsonParser.COMMA, i); + } + public ArrayNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_arrayNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitArrayNode(this); + else return visitor.visitChildren(this); + } + } + + public final ArrayNodeContext arrayNode() throws RecognitionException { + ArrayNodeContext _localctx = new ArrayNodeContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_arrayNode); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(37); + match(LBRACKET); + setState(46); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 15454L) != 0)) { + { + setState(38); + valueNode(); + setState(43); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==COMMA) { + { + { + setState(39); + match(COMMA); + setState(40); + valueNode(); + } + } + setState(45); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(48); + match(RBRACKET); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveNodeContext extends ParserRuleContext { + public PrimitiveNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_primitiveNode; } + + public PrimitiveNodeContext() { } + public void copyFrom(PrimitiveNodeContext ctx) { + super.copyFrom(ctx); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveDoubleContext extends PrimitiveNodeContext { + public TerminalNode DOUBLE() { return getToken(JsonParser.DOUBLE, 0); } + public PrimitiveDoubleContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveDouble(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveFloatContext extends PrimitiveNodeContext { + public TerminalNode FLOAT() { return getToken(JsonParser.FLOAT, 0); } + public PrimitiveFloatContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveFloat(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveNullContext extends PrimitiveNodeContext { + public TerminalNode NULL() { return getToken(JsonParser.NULL, 0); } + public PrimitiveNullContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveNull(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveTrueContext extends PrimitiveNodeContext { + public TerminalNode TRUE() { return getToken(JsonParser.TRUE, 0); } + public PrimitiveTrueContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveTrue(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveFalseContext extends PrimitiveNodeContext { + public TerminalNode FALSE() { return getToken(JsonParser.FALSE, 0); } + public PrimitiveFalseContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveFalse(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveStringContext extends PrimitiveNodeContext { + public TerminalNode STRING() { return getToken(JsonParser.STRING, 0); } + public PrimitiveStringContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveString(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveIntegerContext extends PrimitiveNodeContext { + public TerminalNode INTEGER() { return getToken(JsonParser.INTEGER, 0); } + public PrimitiveIntegerContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveInteger(this); + else return visitor.visitChildren(this); + } + } + + public final PrimitiveNodeContext primitiveNode() throws RecognitionException { + PrimitiveNodeContext _localctx = new PrimitiveNodeContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_primitiveNode); + try { + setState(57); + _errHandler.sync(this); + switch (_input.LA(1)) { + case TRUE: + _localctx = new PrimitiveTrueContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(50); + match(TRUE); + } + break; + case FALSE: + _localctx = new PrimitiveFalseContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(51); + match(FALSE); + } + break; + case STRING: + _localctx = new PrimitiveStringContext(_localctx); + enterOuterAlt(_localctx, 3); + { + setState(52); + match(STRING); + } + break; + case INTEGER: + _localctx = new PrimitiveIntegerContext(_localctx); + enterOuterAlt(_localctx, 4); + { + setState(53); + match(INTEGER); + } + break; + case FLOAT: + _localctx = new PrimitiveFloatContext(_localctx); + enterOuterAlt(_localctx, 5); + { + setState(54); + match(FLOAT); + } + break; + case DOUBLE: + _localctx = new PrimitiveDoubleContext(_localctx); + enterOuterAlt(_localctx, 6); + { + setState(55); + match(DOUBLE); + } + break; + case NULL: + _localctx = new PrimitiveNullContext(_localctx); + enterOuterAlt(_localctx, 7); + { + setState(56); + match(NULL); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static final String _serializedATN = + "\u0004\u0001\u000e<\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ + "\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+ + "\u0005\u0007\u0005\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001\u0001"+ + "\u0001\u0001\u0001\u0003\u0001\u0013\b\u0001\u0001\u0002\u0001\u0002\u0001"+ + "\u0002\u0001\u0002\u0005\u0002\u0019\b\u0002\n\u0002\f\u0002\u001c\t\u0002"+ + "\u0003\u0002\u001e\b\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+ + "\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004"+ + "\u0005\u0004*\b\u0004\n\u0004\f\u0004-\t\u0004\u0003\u0004/\b\u0004\u0001"+ + "\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001"+ + "\u0005\u0001\u0005\u0001\u0005\u0003\u0005:\b\u0005\u0001\u0005\u0000"+ + "\u0000\u0006\u0000\u0002\u0004\u0006\b\n\u0000\u0000A\u0000\f\u0001\u0000"+ + "\u0000\u0000\u0002\u0012\u0001\u0000\u0000\u0000\u0004\u0014\u0001\u0000"+ + "\u0000\u0000\u0006!\u0001\u0000\u0000\u0000\b%\u0001\u0000\u0000\u0000"+ + "\n9\u0001\u0000\u0000\u0000\f\r\u0003\u0002\u0001\u0000\r\u000e\u0005"+ + "\u0000\u0000\u0001\u000e\u0001\u0001\u0000\u0000\u0000\u000f\u0013\u0003"+ + "\n\u0005\u0000\u0010\u0013\u0003\u0004\u0002\u0000\u0011\u0013\u0003\b"+ + "\u0004\u0000\u0012\u000f\u0001\u0000\u0000\u0000\u0012\u0010\u0001\u0000"+ + "\u0000\u0000\u0012\u0011\u0001\u0000\u0000\u0000\u0013\u0003\u0001\u0000"+ + "\u0000\u0000\u0014\u001d\u0005\u0006\u0000\u0000\u0015\u001a\u0003\u0006"+ + "\u0003\u0000\u0016\u0017\u0005\b\u0000\u0000\u0017\u0019\u0003\u0006\u0003"+ + "\u0000\u0018\u0016\u0001\u0000\u0000\u0000\u0019\u001c\u0001\u0000\u0000"+ + "\u0000\u001a\u0018\u0001\u0000\u0000\u0000\u001a\u001b\u0001\u0000\u0000"+ + "\u0000\u001b\u001e\u0001\u0000\u0000\u0000\u001c\u001a\u0001\u0000\u0000"+ + "\u0000\u001d\u0015\u0001\u0000\u0000\u0000\u001d\u001e\u0001\u0000\u0000"+ + "\u0000\u001e\u001f\u0001\u0000\u0000\u0000\u001f \u0005\u0007\u0000\u0000"+ + " \u0005\u0001\u0000\u0000\u0000!\"\u0005\n\u0000\u0000\"#\u0005\t\u0000"+ + "\u0000#$\u0003\u0002\u0001\u0000$\u0007\u0001\u0000\u0000\u0000%.\u0005"+ + "\u0004\u0000\u0000&+\u0003\u0002\u0001\u0000\'(\u0005\b\u0000\u0000(*"+ + "\u0003\u0002\u0001\u0000)\'\u0001\u0000\u0000\u0000*-\u0001\u0000\u0000"+ + "\u0000+)\u0001\u0000\u0000\u0000+,\u0001\u0000\u0000\u0000,/\u0001\u0000"+ + "\u0000\u0000-+\u0001\u0000\u0000\u0000.&\u0001\u0000\u0000\u0000./\u0001"+ + "\u0000\u0000\u0000/0\u0001\u0000\u0000\u000001\u0005\u0005\u0000\u0000"+ + "1\t\u0001\u0000\u0000\u00002:\u0005\u0001\u0000\u00003:\u0005\u0002\u0000"+ + "\u00004:\u0005\n\u0000\u00005:\u0005\u000b\u0000\u00006:\u0005\f\u0000"+ + "\u00007:\u0005\r\u0000\u00008:\u0005\u0003\u0000\u000092\u0001\u0000\u0000"+ + "\u000093\u0001\u0000\u0000\u000094\u0001\u0000\u0000\u000095\u0001\u0000"+ + "\u0000\u000096\u0001\u0000\u0000\u000097\u0001\u0000\u0000\u000098\u0001"+ + "\u0000\u0000\u0000:\u000b\u0001\u0000\u0000\u0000\u0006\u0012\u001a\u001d"+ + "+.9"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParser.tokens b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParser.tokens similarity index 100% rename from src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParser.tokens rename to src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParser.tokens diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParserBaseVisitor.java b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParserBaseVisitor.java new file mode 100644 index 0000000..aac52cc --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParserBaseVisitor.java @@ -0,0 +1,98 @@ +package com.relogiclabs.jschema.internal.antlr; +import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; + +/** + * This class provides an empty implementation of {@link JsonParserVisitor}, + * which can be extended to create a visitor which only needs to handle a subset + * of the available methods. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +@SuppressWarnings("CheckReturnValue") +public class JsonParserBaseVisitor extends AbstractParseTreeVisitor implements JsonParserVisitor { + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitJson(JsonParser.JsonContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitValueNode(JsonParser.ValueNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitObjectNode(JsonParser.ObjectNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPropertyNode(JsonParser.PropertyNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitArrayNode(JsonParser.ArrayNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveTrue(JsonParser.PrimitiveTrueContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveFalse(JsonParser.PrimitiveFalseContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveString(JsonParser.PrimitiveStringContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveInteger(JsonParser.PrimitiveIntegerContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveFloat(JsonParser.PrimitiveFloatContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveDouble(JsonParser.PrimitiveDoubleContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveNull(JsonParser.PrimitiveNullContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParserVisitor.java b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParserVisitor.java new file mode 100644 index 0000000..bdeafa0 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/JsonParserVisitor.java @@ -0,0 +1,91 @@ +package com.relogiclabs.jschema.internal.antlr; +import org.antlr.v4.runtime.tree.ParseTreeVisitor; + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by {@link JsonParser}. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public interface JsonParserVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by {@link JsonParser#json}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitJson(JsonParser.JsonContext ctx); + /** + * Visit a parse tree produced by {@link JsonParser#valueNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitValueNode(JsonParser.ValueNodeContext ctx); + /** + * Visit a parse tree produced by {@link JsonParser#objectNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitObjectNode(JsonParser.ObjectNodeContext ctx); + /** + * Visit a parse tree produced by {@link JsonParser#propertyNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPropertyNode(JsonParser.PropertyNodeContext ctx); + /** + * Visit a parse tree produced by {@link JsonParser#arrayNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArrayNode(JsonParser.ArrayNodeContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveTrue} + * labeled alternative in {@link JsonParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveTrue(JsonParser.PrimitiveTrueContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveFalse} + * labeled alternative in {@link JsonParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveFalse(JsonParser.PrimitiveFalseContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveString} + * labeled alternative in {@link JsonParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveString(JsonParser.PrimitiveStringContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveInteger} + * labeled alternative in {@link JsonParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveInteger(JsonParser.PrimitiveIntegerContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveFloat} + * labeled alternative in {@link JsonParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveFloat(JsonParser.PrimitiveFloatContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveDouble} + * labeled alternative in {@link JsonParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveDouble(JsonParser.PrimitiveDoubleContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveNull} + * labeled alternative in {@link JsonParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveNull(JsonParser.PrimitiveNullContext ctx); +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.interp b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.interp new file mode 100644 index 0000000..5e2ba9e --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.interp @@ -0,0 +1,332 @@ +token literal names: +null +'%title' +'%version' +'%import' +'%pragma' +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +'?' +null +null +null +null +null +null +null +null +null +null +null +null +null +'var' +'if' +'else' +'while' +'for' +'foreach' +'in' +'break' +'constraint' +'target' +'caller' +'subroutine' +'tryof' +'throw' +'function' +'return' +'future' +null +null +null +'undefined' +'this' +'new' +'continue' +'do' +'const' +'switch' +'case' +'import' +'class' +'super' +'default' +null +null +null +null +null +null +null +null +null +null +';' +null +'.' +null +'..' +'...' +'=' +'++' +'--' +'+' +'-' +null +'/' +'>' +'<' +'<=' +'>=' +'==' +'!=' +null +'&&' +'||' +null +null +null + +token symbolic names: +null +TITLE +VERSION +IMPORT +PRAGMA +DEFINE +SCHEMA +SCRIPT +TRUE +FALSE +NULL +COLON +COMMA +STAR +LBRACE +RBRACE +LBRACKET +RBRACKET +LPAREN +RPAREN +OPTIONAL +UNDEFINED +FULL_IDENTIFIER +ALIAS +DATATYPE +FUNCTION +RECEIVER +STRING +INTEGER +FLOAT +DOUBLE +WHITE_SPACE +BLOCK_COMMENT +LINE_COMMENT +G_VAR +G_IF +G_ELSE +G_WHILE +G_FOR +G_FOREACH +G_IN +G_BREAK +G_CONSTRAINT +G_TARGET +G_CALLER +G_SUBROUTINE +G_TRYOF +G_THROW +G_FUNCTION +G_RETURN +G_FUTURE +G_TRUE +G_FALSE +G_NULL +G_UNDEFINED +G_THIS +G_NEW +G_CONTINUE +G_DO +G_CONST +G_SWITCH +G_CASE +G_IMPORT +G_CLASS +G_SUPER +G_DEFAULT +G_INTEGER +G_DOUBLE +G_STRING +G_IDENTIFIER +G_LBRACE +G_RBRACE +G_LBRACKET +G_RBRACKET +G_LPAREN +G_RPAREN +G_SEMI +G_COMMA +G_DOT +G_COLON +G_RANGE +G_ELLIPSIS +G_ASSIGN +G_INC +G_DEC +G_PLUS +G_MINUS +G_MUL +G_DIV +G_GT +G_LT +G_LE +G_GE +G_EQ +G_NE +G_NOT +G_AND +G_OR +WHITE_SPACE1 +BLOCK_COMMENT1 +LINE_COMMENT1 + +rule names: +TITLE +VERSION +IMPORT +PRAGMA +DEFINE +SCHEMA +SCRIPT +TRUE +FALSE +NULL +COLON +COMMA +STAR +LBRACE +RBRACE +LBRACKET +RBRACKET +LPAREN +RPAREN +OPTIONAL +UNDEFINED +FULL_IDENTIFIER +ALIAS +DATATYPE +FUNCTION +RECEIVER +IDENTIFIER +ALPHA +ALPHANUMERIC +STRING +ESCAPE +UNICODE +HEXDIGIT +SAFE_CODEPOINT +INTEGER +FLOAT +DOUBLE +FRACTION +INTDIGIT +EXPONENT +DIGIT +WHITE_SPACE +BLOCK_COMMENT +LINE_COMMENT +G_VAR +G_IF +G_ELSE +G_WHILE +G_FOR +G_FOREACH +G_IN +G_BREAK +G_CONSTRAINT +G_TARGET +G_CALLER +G_SUBROUTINE +G_TRYOF +G_THROW +G_FUNCTION +G_RETURN +G_FUTURE +G_TRUE +G_FALSE +G_NULL +G_UNDEFINED +G_THIS +G_NEW +G_CONTINUE +G_DO +G_CONST +G_SWITCH +G_CASE +G_IMPORT +G_CLASS +G_SUPER +G_DEFAULT +G_INTEGER +G_DOUBLE +G_STRING +G_IDENTIFIER +G_LBRACE +G_RBRACE +G_LBRACKET +G_RBRACKET +G_LPAREN +G_RPAREN +G_SEMI +G_COMMA +G_DOT +G_COLON +G_RANGE +G_ELLIPSIS +G_ASSIGN +G_INC +G_DEC +G_PLUS +G_MINUS +G_MUL +G_DIV +G_GT +G_LT +G_LE +G_GE +G_EQ +G_NE +G_NOT +G_AND +G_OR +DEFINE1 +SCHEMA1 +SCRIPT1 +WHITE_SPACE1 +BLOCK_COMMENT1 +LINE_COMMENT1 + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE +DIRECTIVE_SCRIPT1 + +atn: +[4, 0, 100, 785, 6, -1, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, 2, 68, 7, 68, 2, 69, 7, 69, 2, 70, 7, 70, 2, 71, 7, 71, 2, 72, 7, 72, 2, 73, 7, 73, 2, 74, 7, 74, 2, 75, 7, 75, 2, 76, 7, 76, 2, 77, 7, 77, 2, 78, 7, 78, 2, 79, 7, 79, 2, 80, 7, 80, 2, 81, 7, 81, 2, 82, 7, 82, 2, 83, 7, 83, 2, 84, 7, 84, 2, 85, 7, 85, 2, 86, 7, 86, 2, 87, 7, 87, 2, 88, 7, 88, 2, 89, 7, 89, 2, 90, 7, 90, 2, 91, 7, 91, 2, 92, 7, 92, 2, 93, 7, 93, 2, 94, 7, 94, 2, 95, 7, 95, 2, 96, 7, 96, 2, 97, 7, 97, 2, 98, 7, 98, 2, 99, 7, 99, 2, 100, 7, 100, 2, 101, 7, 101, 2, 102, 7, 102, 2, 103, 7, 103, 2, 104, 7, 104, 2, 105, 7, 105, 2, 106, 7, 106, 2, 107, 7, 107, 2, 108, 7, 108, 2, 109, 7, 109, 2, 110, 7, 110, 2, 111, 7, 111, 2, 112, 7, 112, 2, 113, 7, 113, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 5, 21, 330, 8, 21, 10, 21, 12, 21, 333, 9, 21, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 4, 23, 340, 8, 23, 11, 23, 12, 23, 341, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 5, 26, 352, 8, 26, 10, 26, 12, 26, 355, 9, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 5, 29, 364, 8, 29, 10, 29, 12, 29, 367, 9, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 3, 30, 374, 8, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 3, 34, 387, 8, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 3, 36, 396, 8, 36, 1, 36, 1, 36, 1, 37, 1, 37, 4, 37, 402, 8, 37, 11, 37, 12, 37, 403, 1, 38, 1, 38, 1, 38, 5, 38, 409, 8, 38, 10, 38, 12, 38, 412, 9, 38, 3, 38, 414, 8, 38, 1, 39, 1, 39, 3, 39, 418, 8, 39, 1, 39, 4, 39, 421, 8, 39, 11, 39, 12, 39, 422, 1, 40, 1, 40, 1, 41, 4, 41, 428, 8, 41, 11, 41, 12, 41, 429, 1, 41, 1, 41, 1, 42, 1, 42, 1, 42, 1, 42, 5, 42, 438, 8, 42, 10, 42, 12, 42, 441, 9, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 43, 5, 43, 452, 8, 43, 10, 43, 12, 43, 455, 9, 43, 1, 43, 1, 43, 1, 44, 1, 44, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 1, 47, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 50, 1, 50, 1, 50, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 57, 1, 57, 1, 57, 1, 57, 1, 57, 1, 57, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 60, 1, 60, 1, 60, 1, 60, 1, 60, 1, 60, 1, 60, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 66, 1, 66, 1, 66, 1, 66, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 68, 1, 68, 1, 68, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 70, 1, 70, 1, 70, 1, 70, 1, 70, 1, 70, 1, 70, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 76, 1, 76, 1, 77, 1, 77, 3, 77, 665, 8, 77, 1, 77, 3, 77, 668, 8, 77, 1, 78, 1, 78, 1, 79, 1, 79, 1, 80, 1, 80, 1, 81, 1, 81, 1, 82, 1, 82, 1, 83, 1, 83, 1, 84, 1, 84, 1, 85, 1, 85, 1, 86, 1, 86, 1, 87, 1, 87, 1, 88, 1, 88, 1, 89, 1, 89, 1, 90, 1, 90, 1, 90, 1, 91, 1, 91, 1, 91, 1, 91, 1, 92, 1, 92, 1, 93, 1, 93, 1, 93, 1, 94, 1, 94, 1, 94, 1, 95, 1, 95, 1, 96, 1, 96, 1, 97, 1, 97, 1, 98, 1, 98, 1, 99, 1, 99, 1, 100, 1, 100, 1, 101, 1, 101, 1, 101, 1, 102, 1, 102, 1, 102, 1, 103, 1, 103, 1, 103, 1, 104, 1, 104, 1, 104, 1, 105, 1, 105, 1, 106, 1, 106, 1, 106, 1, 107, 1, 107, 1, 107, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 111, 1, 111, 1, 111, 1, 111, 1, 112, 1, 112, 1, 112, 1, 112, 1, 113, 1, 113, 1, 113, 1, 113, 1, 439, 0, 114, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18, 9, 20, 10, 22, 11, 24, 12, 26, 13, 28, 14, 30, 15, 32, 16, 34, 17, 36, 18, 38, 19, 40, 20, 42, 21, 44, 22, 46, 23, 48, 24, 50, 25, 52, 26, 54, 0, 56, 0, 58, 0, 60, 27, 62, 0, 64, 0, 66, 0, 68, 0, 70, 28, 72, 29, 74, 30, 76, 0, 78, 0, 80, 0, 82, 0, 84, 31, 86, 32, 88, 33, 90, 34, 92, 35, 94, 36, 96, 37, 98, 38, 100, 39, 102, 40, 104, 41, 106, 42, 108, 43, 110, 44, 112, 45, 114, 46, 116, 47, 118, 48, 120, 49, 122, 50, 124, 51, 126, 52, 128, 53, 130, 54, 132, 55, 134, 56, 136, 57, 138, 58, 140, 59, 142, 60, 144, 61, 146, 62, 148, 63, 150, 64, 152, 65, 154, 66, 156, 67, 158, 68, 160, 69, 162, 70, 164, 71, 166, 72, 168, 73, 170, 74, 172, 75, 174, 76, 176, 77, 178, 78, 180, 79, 182, 80, 184, 81, 186, 82, 188, 83, 190, 84, 192, 85, 194, 86, 196, 87, 198, 88, 200, 89, 202, 90, 204, 91, 206, 92, 208, 93, 210, 94, 212, 95, 214, 96, 216, 97, 218, 0, 220, 0, 222, 0, 224, 98, 226, 99, 228, 100, 2, 0, 1, 11, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 8, 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 0, 31, 34, 34, 92, 92, 1, 0, 49, 57, 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 1, 0, 48, 57, 3, 0, 9, 10, 13, 13, 32, 32, 2, 0, 10, 10, 13, 13, 790, 0, 2, 1, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 6, 1, 0, 0, 0, 0, 8, 1, 0, 0, 0, 0, 10, 1, 0, 0, 0, 0, 12, 1, 0, 0, 0, 0, 14, 1, 0, 0, 0, 0, 16, 1, 0, 0, 0, 0, 18, 1, 0, 0, 0, 0, 20, 1, 0, 0, 0, 0, 22, 1, 0, 0, 0, 0, 24, 1, 0, 0, 0, 0, 26, 1, 0, 0, 0, 0, 28, 1, 0, 0, 0, 0, 30, 1, 0, 0, 0, 0, 32, 1, 0, 0, 0, 0, 34, 1, 0, 0, 0, 0, 36, 1, 0, 0, 0, 0, 38, 1, 0, 0, 0, 0, 40, 1, 0, 0, 0, 0, 42, 1, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 46, 1, 0, 0, 0, 0, 48, 1, 0, 0, 0, 0, 50, 1, 0, 0, 0, 0, 52, 1, 0, 0, 0, 0, 60, 1, 0, 0, 0, 0, 70, 1, 0, 0, 0, 0, 72, 1, 0, 0, 0, 0, 74, 1, 0, 0, 0, 0, 84, 1, 0, 0, 0, 0, 86, 1, 0, 0, 0, 0, 88, 1, 0, 0, 0, 1, 90, 1, 0, 0, 0, 1, 92, 1, 0, 0, 0, 1, 94, 1, 0, 0, 0, 1, 96, 1, 0, 0, 0, 1, 98, 1, 0, 0, 0, 1, 100, 1, 0, 0, 0, 1, 102, 1, 0, 0, 0, 1, 104, 1, 0, 0, 0, 1, 106, 1, 0, 0, 0, 1, 108, 1, 0, 0, 0, 1, 110, 1, 0, 0, 0, 1, 112, 1, 0, 0, 0, 1, 114, 1, 0, 0, 0, 1, 116, 1, 0, 0, 0, 1, 118, 1, 0, 0, 0, 1, 120, 1, 0, 0, 0, 1, 122, 1, 0, 0, 0, 1, 124, 1, 0, 0, 0, 1, 126, 1, 0, 0, 0, 1, 128, 1, 0, 0, 0, 1, 130, 1, 0, 0, 0, 1, 132, 1, 0, 0, 0, 1, 134, 1, 0, 0, 0, 1, 136, 1, 0, 0, 0, 1, 138, 1, 0, 0, 0, 1, 140, 1, 0, 0, 0, 1, 142, 1, 0, 0, 0, 1, 144, 1, 0, 0, 0, 1, 146, 1, 0, 0, 0, 1, 148, 1, 0, 0, 0, 1, 150, 1, 0, 0, 0, 1, 152, 1, 0, 0, 0, 1, 154, 1, 0, 0, 0, 1, 156, 1, 0, 0, 0, 1, 158, 1, 0, 0, 0, 1, 160, 1, 0, 0, 0, 1, 162, 1, 0, 0, 0, 1, 164, 1, 0, 0, 0, 1, 166, 1, 0, 0, 0, 1, 168, 1, 0, 0, 0, 1, 170, 1, 0, 0, 0, 1, 172, 1, 0, 0, 0, 1, 174, 1, 0, 0, 0, 1, 176, 1, 0, 0, 0, 1, 178, 1, 0, 0, 0, 1, 180, 1, 0, 0, 0, 1, 182, 1, 0, 0, 0, 1, 184, 1, 0, 0, 0, 1, 186, 1, 0, 0, 0, 1, 188, 1, 0, 0, 0, 1, 190, 1, 0, 0, 0, 1, 192, 1, 0, 0, 0, 1, 194, 1, 0, 0, 0, 1, 196, 1, 0, 0, 0, 1, 198, 1, 0, 0, 0, 1, 200, 1, 0, 0, 0, 1, 202, 1, 0, 0, 0, 1, 204, 1, 0, 0, 0, 1, 206, 1, 0, 0, 0, 1, 208, 1, 0, 0, 0, 1, 210, 1, 0, 0, 0, 1, 212, 1, 0, 0, 0, 1, 214, 1, 0, 0, 0, 1, 216, 1, 0, 0, 0, 1, 218, 1, 0, 0, 0, 1, 220, 1, 0, 0, 0, 1, 222, 1, 0, 0, 0, 1, 224, 1, 0, 0, 0, 1, 226, 1, 0, 0, 0, 1, 228, 1, 0, 0, 0, 2, 230, 1, 0, 0, 0, 4, 237, 1, 0, 0, 0, 6, 246, 1, 0, 0, 0, 8, 254, 1, 0, 0, 0, 10, 262, 1, 0, 0, 0, 12, 270, 1, 0, 0, 0, 14, 278, 1, 0, 0, 0, 16, 288, 1, 0, 0, 0, 18, 293, 1, 0, 0, 0, 20, 299, 1, 0, 0, 0, 22, 304, 1, 0, 0, 0, 24, 306, 1, 0, 0, 0, 26, 308, 1, 0, 0, 0, 28, 310, 1, 0, 0, 0, 30, 312, 1, 0, 0, 0, 32, 314, 1, 0, 0, 0, 34, 316, 1, 0, 0, 0, 36, 318, 1, 0, 0, 0, 38, 320, 1, 0, 0, 0, 40, 322, 1, 0, 0, 0, 42, 324, 1, 0, 0, 0, 44, 326, 1, 0, 0, 0, 46, 334, 1, 0, 0, 0, 48, 337, 1, 0, 0, 0, 50, 343, 1, 0, 0, 0, 52, 346, 1, 0, 0, 0, 54, 349, 1, 0, 0, 0, 56, 356, 1, 0, 0, 0, 58, 358, 1, 0, 0, 0, 60, 360, 1, 0, 0, 0, 62, 370, 1, 0, 0, 0, 64, 375, 1, 0, 0, 0, 66, 381, 1, 0, 0, 0, 68, 383, 1, 0, 0, 0, 70, 386, 1, 0, 0, 0, 72, 390, 1, 0, 0, 0, 74, 393, 1, 0, 0, 0, 76, 399, 1, 0, 0, 0, 78, 413, 1, 0, 0, 0, 80, 415, 1, 0, 0, 0, 82, 424, 1, 0, 0, 0, 84, 427, 1, 0, 0, 0, 86, 433, 1, 0, 0, 0, 88, 447, 1, 0, 0, 0, 90, 458, 1, 0, 0, 0, 92, 462, 1, 0, 0, 0, 94, 465, 1, 0, 0, 0, 96, 470, 1, 0, 0, 0, 98, 476, 1, 0, 0, 0, 100, 480, 1, 0, 0, 0, 102, 488, 1, 0, 0, 0, 104, 491, 1, 0, 0, 0, 106, 497, 1, 0, 0, 0, 108, 508, 1, 0, 0, 0, 110, 515, 1, 0, 0, 0, 112, 522, 1, 0, 0, 0, 114, 533, 1, 0, 0, 0, 116, 539, 1, 0, 0, 0, 118, 545, 1, 0, 0, 0, 120, 554, 1, 0, 0, 0, 122, 561, 1, 0, 0, 0, 124, 568, 1, 0, 0, 0, 126, 573, 1, 0, 0, 0, 128, 579, 1, 0, 0, 0, 130, 584, 1, 0, 0, 0, 132, 594, 1, 0, 0, 0, 134, 599, 1, 0, 0, 0, 136, 603, 1, 0, 0, 0, 138, 612, 1, 0, 0, 0, 140, 615, 1, 0, 0, 0, 142, 621, 1, 0, 0, 0, 144, 628, 1, 0, 0, 0, 146, 633, 1, 0, 0, 0, 148, 640, 1, 0, 0, 0, 150, 646, 1, 0, 0, 0, 152, 652, 1, 0, 0, 0, 154, 660, 1, 0, 0, 0, 156, 662, 1, 0, 0, 0, 158, 669, 1, 0, 0, 0, 160, 671, 1, 0, 0, 0, 162, 673, 1, 0, 0, 0, 164, 675, 1, 0, 0, 0, 166, 677, 1, 0, 0, 0, 168, 679, 1, 0, 0, 0, 170, 681, 1, 0, 0, 0, 172, 683, 1, 0, 0, 0, 174, 685, 1, 0, 0, 0, 176, 687, 1, 0, 0, 0, 178, 689, 1, 0, 0, 0, 180, 691, 1, 0, 0, 0, 182, 693, 1, 0, 0, 0, 184, 696, 1, 0, 0, 0, 186, 700, 1, 0, 0, 0, 188, 702, 1, 0, 0, 0, 190, 705, 1, 0, 0, 0, 192, 708, 1, 0, 0, 0, 194, 710, 1, 0, 0, 0, 196, 712, 1, 0, 0, 0, 198, 714, 1, 0, 0, 0, 200, 716, 1, 0, 0, 0, 202, 718, 1, 0, 0, 0, 204, 720, 1, 0, 0, 0, 206, 723, 1, 0, 0, 0, 208, 726, 1, 0, 0, 0, 210, 729, 1, 0, 0, 0, 212, 732, 1, 0, 0, 0, 214, 734, 1, 0, 0, 0, 216, 737, 1, 0, 0, 0, 218, 740, 1, 0, 0, 0, 220, 751, 1, 0, 0, 0, 222, 762, 1, 0, 0, 0, 224, 773, 1, 0, 0, 0, 226, 777, 1, 0, 0, 0, 228, 781, 1, 0, 0, 0, 230, 231, 5, 37, 0, 0, 231, 232, 5, 116, 0, 0, 232, 233, 5, 105, 0, 0, 233, 234, 5, 116, 0, 0, 234, 235, 5, 108, 0, 0, 235, 236, 5, 101, 0, 0, 236, 3, 1, 0, 0, 0, 237, 238, 5, 37, 0, 0, 238, 239, 5, 118, 0, 0, 239, 240, 5, 101, 0, 0, 240, 241, 5, 114, 0, 0, 241, 242, 5, 115, 0, 0, 242, 243, 5, 105, 0, 0, 243, 244, 5, 111, 0, 0, 244, 245, 5, 110, 0, 0, 245, 5, 1, 0, 0, 0, 246, 247, 5, 37, 0, 0, 247, 248, 5, 105, 0, 0, 248, 249, 5, 109, 0, 0, 249, 250, 5, 112, 0, 0, 250, 251, 5, 111, 0, 0, 251, 252, 5, 114, 0, 0, 252, 253, 5, 116, 0, 0, 253, 7, 1, 0, 0, 0, 254, 255, 5, 37, 0, 0, 255, 256, 5, 112, 0, 0, 256, 257, 5, 114, 0, 0, 257, 258, 5, 97, 0, 0, 258, 259, 5, 103, 0, 0, 259, 260, 5, 109, 0, 0, 260, 261, 5, 97, 0, 0, 261, 9, 1, 0, 0, 0, 262, 263, 5, 37, 0, 0, 263, 264, 5, 100, 0, 0, 264, 265, 5, 101, 0, 0, 265, 266, 5, 102, 0, 0, 266, 267, 5, 105, 0, 0, 267, 268, 5, 110, 0, 0, 268, 269, 5, 101, 0, 0, 269, 11, 1, 0, 0, 0, 270, 271, 5, 37, 0, 0, 271, 272, 5, 115, 0, 0, 272, 273, 5, 99, 0, 0, 273, 274, 5, 104, 0, 0, 274, 275, 5, 101, 0, 0, 275, 276, 5, 109, 0, 0, 276, 277, 5, 97, 0, 0, 277, 13, 1, 0, 0, 0, 278, 279, 5, 37, 0, 0, 279, 280, 5, 115, 0, 0, 280, 281, 5, 99, 0, 0, 281, 282, 5, 114, 0, 0, 282, 283, 5, 105, 0, 0, 283, 284, 5, 112, 0, 0, 284, 285, 5, 116, 0, 0, 285, 286, 1, 0, 0, 0, 286, 287, 6, 6, 0, 0, 287, 15, 1, 0, 0, 0, 288, 289, 5, 116, 0, 0, 289, 290, 5, 114, 0, 0, 290, 291, 5, 117, 0, 0, 291, 292, 5, 101, 0, 0, 292, 17, 1, 0, 0, 0, 293, 294, 5, 102, 0, 0, 294, 295, 5, 97, 0, 0, 295, 296, 5, 108, 0, 0, 296, 297, 5, 115, 0, 0, 297, 298, 5, 101, 0, 0, 298, 19, 1, 0, 0, 0, 299, 300, 5, 110, 0, 0, 300, 301, 5, 117, 0, 0, 301, 302, 5, 108, 0, 0, 302, 303, 5, 108, 0, 0, 303, 21, 1, 0, 0, 0, 304, 305, 5, 58, 0, 0, 305, 23, 1, 0, 0, 0, 306, 307, 5, 44, 0, 0, 307, 25, 1, 0, 0, 0, 308, 309, 5, 42, 0, 0, 309, 27, 1, 0, 0, 0, 310, 311, 5, 123, 0, 0, 311, 29, 1, 0, 0, 0, 312, 313, 5, 125, 0, 0, 313, 31, 1, 0, 0, 0, 314, 315, 5, 91, 0, 0, 315, 33, 1, 0, 0, 0, 316, 317, 5, 93, 0, 0, 317, 35, 1, 0, 0, 0, 318, 319, 5, 40, 0, 0, 319, 37, 1, 0, 0, 0, 320, 321, 5, 41, 0, 0, 321, 39, 1, 0, 0, 0, 322, 323, 5, 63, 0, 0, 323, 41, 1, 0, 0, 0, 324, 325, 5, 33, 0, 0, 325, 43, 1, 0, 0, 0, 326, 331, 3, 54, 26, 0, 327, 328, 5, 46, 0, 0, 328, 330, 3, 54, 26, 0, 329, 327, 1, 0, 0, 0, 330, 333, 1, 0, 0, 0, 331, 329, 1, 0, 0, 0, 331, 332, 1, 0, 0, 0, 332, 45, 1, 0, 0, 0, 333, 331, 1, 0, 0, 0, 334, 335, 5, 36, 0, 0, 335, 336, 3, 54, 26, 0, 336, 47, 1, 0, 0, 0, 337, 339, 5, 35, 0, 0, 338, 340, 3, 56, 27, 0, 339, 338, 1, 0, 0, 0, 340, 341, 1, 0, 0, 0, 341, 339, 1, 0, 0, 0, 341, 342, 1, 0, 0, 0, 342, 49, 1, 0, 0, 0, 343, 344, 5, 64, 0, 0, 344, 345, 3, 54, 26, 0, 345, 51, 1, 0, 0, 0, 346, 347, 5, 38, 0, 0, 347, 348, 3, 54, 26, 0, 348, 53, 1, 0, 0, 0, 349, 353, 3, 56, 27, 0, 350, 352, 3, 58, 28, 0, 351, 350, 1, 0, 0, 0, 352, 355, 1, 0, 0, 0, 353, 351, 1, 0, 0, 0, 353, 354, 1, 0, 0, 0, 354, 55, 1, 0, 0, 0, 355, 353, 1, 0, 0, 0, 356, 357, 7, 0, 0, 0, 357, 57, 1, 0, 0, 0, 358, 359, 7, 1, 0, 0, 359, 59, 1, 0, 0, 0, 360, 365, 5, 34, 0, 0, 361, 364, 3, 62, 30, 0, 362, 364, 3, 68, 33, 0, 363, 361, 1, 0, 0, 0, 363, 362, 1, 0, 0, 0, 364, 367, 1, 0, 0, 0, 365, 363, 1, 0, 0, 0, 365, 366, 1, 0, 0, 0, 366, 368, 1, 0, 0, 0, 367, 365, 1, 0, 0, 0, 368, 369, 5, 34, 0, 0, 369, 61, 1, 0, 0, 0, 370, 373, 5, 92, 0, 0, 371, 374, 7, 2, 0, 0, 372, 374, 3, 64, 31, 0, 373, 371, 1, 0, 0, 0, 373, 372, 1, 0, 0, 0, 374, 63, 1, 0, 0, 0, 375, 376, 5, 117, 0, 0, 376, 377, 3, 66, 32, 0, 377, 378, 3, 66, 32, 0, 378, 379, 3, 66, 32, 0, 379, 380, 3, 66, 32, 0, 380, 65, 1, 0, 0, 0, 381, 382, 7, 3, 0, 0, 382, 67, 1, 0, 0, 0, 383, 384, 8, 4, 0, 0, 384, 69, 1, 0, 0, 0, 385, 387, 5, 45, 0, 0, 386, 385, 1, 0, 0, 0, 386, 387, 1, 0, 0, 0, 387, 388, 1, 0, 0, 0, 388, 389, 3, 78, 38, 0, 389, 71, 1, 0, 0, 0, 390, 391, 3, 70, 34, 0, 391, 392, 3, 76, 37, 0, 392, 73, 1, 0, 0, 0, 393, 395, 3, 70, 34, 0, 394, 396, 3, 76, 37, 0, 395, 394, 1, 0, 0, 0, 395, 396, 1, 0, 0, 0, 396, 397, 1, 0, 0, 0, 397, 398, 3, 80, 39, 0, 398, 75, 1, 0, 0, 0, 399, 401, 5, 46, 0, 0, 400, 402, 3, 82, 40, 0, 401, 400, 1, 0, 0, 0, 402, 403, 1, 0, 0, 0, 403, 401, 1, 0, 0, 0, 403, 404, 1, 0, 0, 0, 404, 77, 1, 0, 0, 0, 405, 414, 5, 48, 0, 0, 406, 410, 7, 5, 0, 0, 407, 409, 3, 82, 40, 0, 408, 407, 1, 0, 0, 0, 409, 412, 1, 0, 0, 0, 410, 408, 1, 0, 0, 0, 410, 411, 1, 0, 0, 0, 411, 414, 1, 0, 0, 0, 412, 410, 1, 0, 0, 0, 413, 405, 1, 0, 0, 0, 413, 406, 1, 0, 0, 0, 414, 79, 1, 0, 0, 0, 415, 417, 7, 6, 0, 0, 416, 418, 7, 7, 0, 0, 417, 416, 1, 0, 0, 0, 417, 418, 1, 0, 0, 0, 418, 420, 1, 0, 0, 0, 419, 421, 3, 82, 40, 0, 420, 419, 1, 0, 0, 0, 421, 422, 1, 0, 0, 0, 422, 420, 1, 0, 0, 0, 422, 423, 1, 0, 0, 0, 423, 81, 1, 0, 0, 0, 424, 425, 7, 8, 0, 0, 425, 83, 1, 0, 0, 0, 426, 428, 7, 9, 0, 0, 427, 426, 1, 0, 0, 0, 428, 429, 1, 0, 0, 0, 429, 427, 1, 0, 0, 0, 429, 430, 1, 0, 0, 0, 430, 431, 1, 0, 0, 0, 431, 432, 6, 41, 1, 0, 432, 85, 1, 0, 0, 0, 433, 434, 5, 47, 0, 0, 434, 435, 5, 42, 0, 0, 435, 439, 1, 0, 0, 0, 436, 438, 9, 0, 0, 0, 437, 436, 1, 0, 0, 0, 438, 441, 1, 0, 0, 0, 439, 440, 1, 0, 0, 0, 439, 437, 1, 0, 0, 0, 440, 442, 1, 0, 0, 0, 441, 439, 1, 0, 0, 0, 442, 443, 5, 42, 0, 0, 443, 444, 5, 47, 0, 0, 444, 445, 1, 0, 0, 0, 445, 446, 6, 42, 1, 0, 446, 87, 1, 0, 0, 0, 447, 448, 5, 47, 0, 0, 448, 449, 5, 47, 0, 0, 449, 453, 1, 0, 0, 0, 450, 452, 8, 10, 0, 0, 451, 450, 1, 0, 0, 0, 452, 455, 1, 0, 0, 0, 453, 451, 1, 0, 0, 0, 453, 454, 1, 0, 0, 0, 454, 456, 1, 0, 0, 0, 455, 453, 1, 0, 0, 0, 456, 457, 6, 43, 1, 0, 457, 89, 1, 0, 0, 0, 458, 459, 5, 118, 0, 0, 459, 460, 5, 97, 0, 0, 460, 461, 5, 114, 0, 0, 461, 91, 1, 0, 0, 0, 462, 463, 5, 105, 0, 0, 463, 464, 5, 102, 0, 0, 464, 93, 1, 0, 0, 0, 465, 466, 5, 101, 0, 0, 466, 467, 5, 108, 0, 0, 467, 468, 5, 115, 0, 0, 468, 469, 5, 101, 0, 0, 469, 95, 1, 0, 0, 0, 470, 471, 5, 119, 0, 0, 471, 472, 5, 104, 0, 0, 472, 473, 5, 105, 0, 0, 473, 474, 5, 108, 0, 0, 474, 475, 5, 101, 0, 0, 475, 97, 1, 0, 0, 0, 476, 477, 5, 102, 0, 0, 477, 478, 5, 111, 0, 0, 478, 479, 5, 114, 0, 0, 479, 99, 1, 0, 0, 0, 480, 481, 5, 102, 0, 0, 481, 482, 5, 111, 0, 0, 482, 483, 5, 114, 0, 0, 483, 484, 5, 101, 0, 0, 484, 485, 5, 97, 0, 0, 485, 486, 5, 99, 0, 0, 486, 487, 5, 104, 0, 0, 487, 101, 1, 0, 0, 0, 488, 489, 5, 105, 0, 0, 489, 490, 5, 110, 0, 0, 490, 103, 1, 0, 0, 0, 491, 492, 5, 98, 0, 0, 492, 493, 5, 114, 0, 0, 493, 494, 5, 101, 0, 0, 494, 495, 5, 97, 0, 0, 495, 496, 5, 107, 0, 0, 496, 105, 1, 0, 0, 0, 497, 498, 5, 99, 0, 0, 498, 499, 5, 111, 0, 0, 499, 500, 5, 110, 0, 0, 500, 501, 5, 115, 0, 0, 501, 502, 5, 116, 0, 0, 502, 503, 5, 114, 0, 0, 503, 504, 5, 97, 0, 0, 504, 505, 5, 105, 0, 0, 505, 506, 5, 110, 0, 0, 506, 507, 5, 116, 0, 0, 507, 107, 1, 0, 0, 0, 508, 509, 5, 116, 0, 0, 509, 510, 5, 97, 0, 0, 510, 511, 5, 114, 0, 0, 511, 512, 5, 103, 0, 0, 512, 513, 5, 101, 0, 0, 513, 514, 5, 116, 0, 0, 514, 109, 1, 0, 0, 0, 515, 516, 5, 99, 0, 0, 516, 517, 5, 97, 0, 0, 517, 518, 5, 108, 0, 0, 518, 519, 5, 108, 0, 0, 519, 520, 5, 101, 0, 0, 520, 521, 5, 114, 0, 0, 521, 111, 1, 0, 0, 0, 522, 523, 5, 115, 0, 0, 523, 524, 5, 117, 0, 0, 524, 525, 5, 98, 0, 0, 525, 526, 5, 114, 0, 0, 526, 527, 5, 111, 0, 0, 527, 528, 5, 117, 0, 0, 528, 529, 5, 116, 0, 0, 529, 530, 5, 105, 0, 0, 530, 531, 5, 110, 0, 0, 531, 532, 5, 101, 0, 0, 532, 113, 1, 0, 0, 0, 533, 534, 5, 116, 0, 0, 534, 535, 5, 114, 0, 0, 535, 536, 5, 121, 0, 0, 536, 537, 5, 111, 0, 0, 537, 538, 5, 102, 0, 0, 538, 115, 1, 0, 0, 0, 539, 540, 5, 116, 0, 0, 540, 541, 5, 104, 0, 0, 541, 542, 5, 114, 0, 0, 542, 543, 5, 111, 0, 0, 543, 544, 5, 119, 0, 0, 544, 117, 1, 0, 0, 0, 545, 546, 5, 102, 0, 0, 546, 547, 5, 117, 0, 0, 547, 548, 5, 110, 0, 0, 548, 549, 5, 99, 0, 0, 549, 550, 5, 116, 0, 0, 550, 551, 5, 105, 0, 0, 551, 552, 5, 111, 0, 0, 552, 553, 5, 110, 0, 0, 553, 119, 1, 0, 0, 0, 554, 555, 5, 114, 0, 0, 555, 556, 5, 101, 0, 0, 556, 557, 5, 116, 0, 0, 557, 558, 5, 117, 0, 0, 558, 559, 5, 114, 0, 0, 559, 560, 5, 110, 0, 0, 560, 121, 1, 0, 0, 0, 561, 562, 5, 102, 0, 0, 562, 563, 5, 117, 0, 0, 563, 564, 5, 116, 0, 0, 564, 565, 5, 117, 0, 0, 565, 566, 5, 114, 0, 0, 566, 567, 5, 101, 0, 0, 567, 123, 1, 0, 0, 0, 568, 569, 5, 116, 0, 0, 569, 570, 5, 114, 0, 0, 570, 571, 5, 117, 0, 0, 571, 572, 5, 101, 0, 0, 572, 125, 1, 0, 0, 0, 573, 574, 5, 102, 0, 0, 574, 575, 5, 97, 0, 0, 575, 576, 5, 108, 0, 0, 576, 577, 5, 115, 0, 0, 577, 578, 5, 101, 0, 0, 578, 127, 1, 0, 0, 0, 579, 580, 5, 110, 0, 0, 580, 581, 5, 117, 0, 0, 581, 582, 5, 108, 0, 0, 582, 583, 5, 108, 0, 0, 583, 129, 1, 0, 0, 0, 584, 585, 5, 117, 0, 0, 585, 586, 5, 110, 0, 0, 586, 587, 5, 100, 0, 0, 587, 588, 5, 101, 0, 0, 588, 589, 5, 102, 0, 0, 589, 590, 5, 105, 0, 0, 590, 591, 5, 110, 0, 0, 591, 592, 5, 101, 0, 0, 592, 593, 5, 100, 0, 0, 593, 131, 1, 0, 0, 0, 594, 595, 5, 116, 0, 0, 595, 596, 5, 104, 0, 0, 596, 597, 5, 105, 0, 0, 597, 598, 5, 115, 0, 0, 598, 133, 1, 0, 0, 0, 599, 600, 5, 110, 0, 0, 600, 601, 5, 101, 0, 0, 601, 602, 5, 119, 0, 0, 602, 135, 1, 0, 0, 0, 603, 604, 5, 99, 0, 0, 604, 605, 5, 111, 0, 0, 605, 606, 5, 110, 0, 0, 606, 607, 5, 116, 0, 0, 607, 608, 5, 105, 0, 0, 608, 609, 5, 110, 0, 0, 609, 610, 5, 117, 0, 0, 610, 611, 5, 101, 0, 0, 611, 137, 1, 0, 0, 0, 612, 613, 5, 100, 0, 0, 613, 614, 5, 111, 0, 0, 614, 139, 1, 0, 0, 0, 615, 616, 5, 99, 0, 0, 616, 617, 5, 111, 0, 0, 617, 618, 5, 110, 0, 0, 618, 619, 5, 115, 0, 0, 619, 620, 5, 116, 0, 0, 620, 141, 1, 0, 0, 0, 621, 622, 5, 115, 0, 0, 622, 623, 5, 119, 0, 0, 623, 624, 5, 105, 0, 0, 624, 625, 5, 116, 0, 0, 625, 626, 5, 99, 0, 0, 626, 627, 5, 104, 0, 0, 627, 143, 1, 0, 0, 0, 628, 629, 5, 99, 0, 0, 629, 630, 5, 97, 0, 0, 630, 631, 5, 115, 0, 0, 631, 632, 5, 101, 0, 0, 632, 145, 1, 0, 0, 0, 633, 634, 5, 105, 0, 0, 634, 635, 5, 109, 0, 0, 635, 636, 5, 112, 0, 0, 636, 637, 5, 111, 0, 0, 637, 638, 5, 114, 0, 0, 638, 639, 5, 116, 0, 0, 639, 147, 1, 0, 0, 0, 640, 641, 5, 99, 0, 0, 641, 642, 5, 108, 0, 0, 642, 643, 5, 97, 0, 0, 643, 644, 5, 115, 0, 0, 644, 645, 5, 115, 0, 0, 645, 149, 1, 0, 0, 0, 646, 647, 5, 115, 0, 0, 647, 648, 5, 117, 0, 0, 648, 649, 5, 112, 0, 0, 649, 650, 5, 101, 0, 0, 650, 651, 5, 114, 0, 0, 651, 151, 1, 0, 0, 0, 652, 653, 5, 100, 0, 0, 653, 654, 5, 101, 0, 0, 654, 655, 5, 102, 0, 0, 655, 656, 5, 97, 0, 0, 656, 657, 5, 117, 0, 0, 657, 658, 5, 108, 0, 0, 658, 659, 5, 116, 0, 0, 659, 153, 1, 0, 0, 0, 660, 661, 3, 70, 34, 0, 661, 155, 1, 0, 0, 0, 662, 664, 3, 70, 34, 0, 663, 665, 3, 76, 37, 0, 664, 663, 1, 0, 0, 0, 664, 665, 1, 0, 0, 0, 665, 667, 1, 0, 0, 0, 666, 668, 3, 80, 39, 0, 667, 666, 1, 0, 0, 0, 667, 668, 1, 0, 0, 0, 668, 157, 1, 0, 0, 0, 669, 670, 3, 60, 29, 0, 670, 159, 1, 0, 0, 0, 671, 672, 3, 54, 26, 0, 672, 161, 1, 0, 0, 0, 673, 674, 5, 123, 0, 0, 674, 163, 1, 0, 0, 0, 675, 676, 5, 125, 0, 0, 676, 165, 1, 0, 0, 0, 677, 678, 5, 91, 0, 0, 678, 167, 1, 0, 0, 0, 679, 680, 5, 93, 0, 0, 680, 169, 1, 0, 0, 0, 681, 682, 5, 40, 0, 0, 682, 171, 1, 0, 0, 0, 683, 684, 5, 41, 0, 0, 684, 173, 1, 0, 0, 0, 685, 686, 5, 59, 0, 0, 686, 175, 1, 0, 0, 0, 687, 688, 5, 44, 0, 0, 688, 177, 1, 0, 0, 0, 689, 690, 5, 46, 0, 0, 690, 179, 1, 0, 0, 0, 691, 692, 5, 58, 0, 0, 692, 181, 1, 0, 0, 0, 693, 694, 5, 46, 0, 0, 694, 695, 5, 46, 0, 0, 695, 183, 1, 0, 0, 0, 696, 697, 5, 46, 0, 0, 697, 698, 5, 46, 0, 0, 698, 699, 5, 46, 0, 0, 699, 185, 1, 0, 0, 0, 700, 701, 5, 61, 0, 0, 701, 187, 1, 0, 0, 0, 702, 703, 5, 43, 0, 0, 703, 704, 5, 43, 0, 0, 704, 189, 1, 0, 0, 0, 705, 706, 5, 45, 0, 0, 706, 707, 5, 45, 0, 0, 707, 191, 1, 0, 0, 0, 708, 709, 5, 43, 0, 0, 709, 193, 1, 0, 0, 0, 710, 711, 5, 45, 0, 0, 711, 195, 1, 0, 0, 0, 712, 713, 5, 42, 0, 0, 713, 197, 1, 0, 0, 0, 714, 715, 5, 47, 0, 0, 715, 199, 1, 0, 0, 0, 716, 717, 5, 62, 0, 0, 717, 201, 1, 0, 0, 0, 718, 719, 5, 60, 0, 0, 719, 203, 1, 0, 0, 0, 720, 721, 5, 60, 0, 0, 721, 722, 5, 61, 0, 0, 722, 205, 1, 0, 0, 0, 723, 724, 5, 62, 0, 0, 724, 725, 5, 61, 0, 0, 725, 207, 1, 0, 0, 0, 726, 727, 5, 61, 0, 0, 727, 728, 5, 61, 0, 0, 728, 209, 1, 0, 0, 0, 729, 730, 5, 33, 0, 0, 730, 731, 5, 61, 0, 0, 731, 211, 1, 0, 0, 0, 732, 733, 5, 33, 0, 0, 733, 213, 1, 0, 0, 0, 734, 735, 5, 38, 0, 0, 735, 736, 5, 38, 0, 0, 736, 215, 1, 0, 0, 0, 737, 738, 5, 124, 0, 0, 738, 739, 5, 124, 0, 0, 739, 217, 1, 0, 0, 0, 740, 741, 5, 37, 0, 0, 741, 742, 5, 100, 0, 0, 742, 743, 5, 101, 0, 0, 743, 744, 5, 102, 0, 0, 744, 745, 5, 105, 0, 0, 745, 746, 5, 110, 0, 0, 746, 747, 5, 101, 0, 0, 747, 748, 1, 0, 0, 0, 748, 749, 6, 108, 2, 0, 749, 750, 6, 108, 3, 0, 750, 219, 1, 0, 0, 0, 751, 752, 5, 37, 0, 0, 752, 753, 5, 115, 0, 0, 753, 754, 5, 99, 0, 0, 754, 755, 5, 104, 0, 0, 755, 756, 5, 101, 0, 0, 756, 757, 5, 109, 0, 0, 757, 758, 5, 97, 0, 0, 758, 759, 1, 0, 0, 0, 759, 760, 6, 109, 4, 0, 760, 761, 6, 109, 3, 0, 761, 221, 1, 0, 0, 0, 762, 763, 5, 37, 0, 0, 763, 764, 5, 115, 0, 0, 764, 765, 5, 99, 0, 0, 765, 766, 5, 114, 0, 0, 766, 767, 5, 105, 0, 0, 767, 768, 5, 112, 0, 0, 768, 769, 5, 116, 0, 0, 769, 770, 1, 0, 0, 0, 770, 771, 6, 110, 5, 0, 771, 772, 6, 110, 3, 0, 772, 223, 1, 0, 0, 0, 773, 774, 3, 84, 41, 0, 774, 775, 1, 0, 0, 0, 775, 776, 6, 111, 1, 0, 776, 225, 1, 0, 0, 0, 777, 778, 3, 86, 42, 0, 778, 779, 1, 0, 0, 0, 779, 780, 6, 112, 1, 0, 780, 227, 1, 0, 0, 0, 781, 782, 3, 88, 43, 0, 782, 783, 1, 0, 0, 0, 783, 784, 6, 113, 1, 0, 784, 229, 1, 0, 0, 0, 20, 0, 1, 331, 341, 353, 363, 365, 373, 386, 395, 403, 410, 413, 417, 422, 429, 439, 453, 664, 667, 6, 5, 1, 0, 0, 1, 0, 7, 5, 0, 4, 0, 0, 7, 6, 0, 7, 7, 0] \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.java b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.java new file mode 100644 index 0000000..84ce05e --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.java @@ -0,0 +1,640 @@ +package com.relogiclabs.jschema.internal.antlr; + +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.RuntimeMetaData; +import org.antlr.v4.runtime.Vocabulary; +import org.antlr.v4.runtime.VocabularyImpl; +import org.antlr.v4.runtime.atn.ATN; +import org.antlr.v4.runtime.atn.ATNDeserializer; +import org.antlr.v4.runtime.atn.LexerATNSimulator; +import org.antlr.v4.runtime.atn.PredictionContextCache; +import org.antlr.v4.runtime.dfa.DFA; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) +public class SchemaLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + TITLE=1, VERSION=2, IMPORT=3, PRAGMA=4, DEFINE=5, SCHEMA=6, SCRIPT=7, + TRUE=8, FALSE=9, NULL=10, COLON=11, COMMA=12, STAR=13, LBRACE=14, RBRACE=15, + LBRACKET=16, RBRACKET=17, LPAREN=18, RPAREN=19, OPTIONAL=20, UNDEFINED=21, + FULL_IDENTIFIER=22, ALIAS=23, DATATYPE=24, FUNCTION=25, RECEIVER=26, STRING=27, + INTEGER=28, FLOAT=29, DOUBLE=30, WHITE_SPACE=31, BLOCK_COMMENT=32, LINE_COMMENT=33, + G_VAR=34, G_IF=35, G_ELSE=36, G_WHILE=37, G_FOR=38, G_FOREACH=39, G_IN=40, + G_BREAK=41, G_CONSTRAINT=42, G_TARGET=43, G_CALLER=44, G_SUBROUTINE=45, + G_TRYOF=46, G_THROW=47, G_FUNCTION=48, G_RETURN=49, G_FUTURE=50, G_TRUE=51, + G_FALSE=52, G_NULL=53, G_UNDEFINED=54, G_THIS=55, G_NEW=56, G_CONTINUE=57, + G_DO=58, G_CONST=59, G_SWITCH=60, G_CASE=61, G_IMPORT=62, G_CLASS=63, + G_SUPER=64, G_DEFAULT=65, G_INTEGER=66, G_DOUBLE=67, G_STRING=68, G_IDENTIFIER=69, + G_LBRACE=70, G_RBRACE=71, G_LBRACKET=72, G_RBRACKET=73, G_LPAREN=74, G_RPAREN=75, + G_SEMI=76, G_COMMA=77, G_DOT=78, G_COLON=79, G_RANGE=80, G_ELLIPSIS=81, + G_ASSIGN=82, G_INC=83, G_DEC=84, G_PLUS=85, G_MINUS=86, G_MUL=87, G_DIV=88, + G_GT=89, G_LT=90, G_LE=91, G_GE=92, G_EQ=93, G_NE=94, G_NOT=95, G_AND=96, + G_OR=97, WHITE_SPACE1=98, BLOCK_COMMENT1=99, LINE_COMMENT1=100; + public static final int + DIRECTIVE_SCRIPT1=1; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE", "DIRECTIVE_SCRIPT1" + }; + + private static String[] makeRuleNames() { + return new String[] { + "TITLE", "VERSION", "IMPORT", "PRAGMA", "DEFINE", "SCHEMA", "SCRIPT", + "TRUE", "FALSE", "NULL", "COLON", "COMMA", "STAR", "LBRACE", "RBRACE", + "LBRACKET", "RBRACKET", "LPAREN", "RPAREN", "OPTIONAL", "UNDEFINED", + "FULL_IDENTIFIER", "ALIAS", "DATATYPE", "FUNCTION", "RECEIVER", "IDENTIFIER", + "ALPHA", "ALPHANUMERIC", "STRING", "ESCAPE", "UNICODE", "HEXDIGIT", "SAFE_CODEPOINT", + "INTEGER", "FLOAT", "DOUBLE", "FRACTION", "INTDIGIT", "EXPONENT", "DIGIT", + "WHITE_SPACE", "BLOCK_COMMENT", "LINE_COMMENT", "G_VAR", "G_IF", "G_ELSE", + "G_WHILE", "G_FOR", "G_FOREACH", "G_IN", "G_BREAK", "G_CONSTRAINT", "G_TARGET", + "G_CALLER", "G_SUBROUTINE", "G_TRYOF", "G_THROW", "G_FUNCTION", "G_RETURN", + "G_FUTURE", "G_TRUE", "G_FALSE", "G_NULL", "G_UNDEFINED", "G_THIS", "G_NEW", + "G_CONTINUE", "G_DO", "G_CONST", "G_SWITCH", "G_CASE", "G_IMPORT", "G_CLASS", + "G_SUPER", "G_DEFAULT", "G_INTEGER", "G_DOUBLE", "G_STRING", "G_IDENTIFIER", + "G_LBRACE", "G_RBRACE", "G_LBRACKET", "G_RBRACKET", "G_LPAREN", "G_RPAREN", + "G_SEMI", "G_COMMA", "G_DOT", "G_COLON", "G_RANGE", "G_ELLIPSIS", "G_ASSIGN", + "G_INC", "G_DEC", "G_PLUS", "G_MINUS", "G_MUL", "G_DIV", "G_GT", "G_LT", + "G_LE", "G_GE", "G_EQ", "G_NE", "G_NOT", "G_AND", "G_OR", "DEFINE1", + "SCHEMA1", "SCRIPT1", "WHITE_SPACE1", "BLOCK_COMMENT1", "LINE_COMMENT1" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'%title'", "'%version'", "'%import'", "'%pragma'", null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, "'?'", null, null, null, null, null, null, null, null, null, null, + null, null, null, "'var'", "'if'", "'else'", "'while'", "'for'", "'foreach'", + "'in'", "'break'", "'constraint'", "'target'", "'caller'", "'subroutine'", + "'tryof'", "'throw'", "'function'", "'return'", "'future'", null, null, + null, "'undefined'", "'this'", "'new'", "'continue'", "'do'", "'const'", + "'switch'", "'case'", "'import'", "'class'", "'super'", "'default'", + null, null, null, null, null, null, null, null, null, null, "';'", null, + "'.'", null, "'..'", "'...'", "'='", "'++'", "'--'", "'+'", "'-'", null, + "'/'", "'>'", "'<'", "'<='", "'>='", "'=='", "'!='", null, "'&&'", "'||'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "TITLE", "VERSION", "IMPORT", "PRAGMA", "DEFINE", "SCHEMA", "SCRIPT", + "TRUE", "FALSE", "NULL", "COLON", "COMMA", "STAR", "LBRACE", "RBRACE", + "LBRACKET", "RBRACKET", "LPAREN", "RPAREN", "OPTIONAL", "UNDEFINED", + "FULL_IDENTIFIER", "ALIAS", "DATATYPE", "FUNCTION", "RECEIVER", "STRING", + "INTEGER", "FLOAT", "DOUBLE", "WHITE_SPACE", "BLOCK_COMMENT", "LINE_COMMENT", + "G_VAR", "G_IF", "G_ELSE", "G_WHILE", "G_FOR", "G_FOREACH", "G_IN", "G_BREAK", + "G_CONSTRAINT", "G_TARGET", "G_CALLER", "G_SUBROUTINE", "G_TRYOF", "G_THROW", + "G_FUNCTION", "G_RETURN", "G_FUTURE", "G_TRUE", "G_FALSE", "G_NULL", + "G_UNDEFINED", "G_THIS", "G_NEW", "G_CONTINUE", "G_DO", "G_CONST", "G_SWITCH", + "G_CASE", "G_IMPORT", "G_CLASS", "G_SUPER", "G_DEFAULT", "G_INTEGER", + "G_DOUBLE", "G_STRING", "G_IDENTIFIER", "G_LBRACE", "G_RBRACE", "G_LBRACKET", + "G_RBRACKET", "G_LPAREN", "G_RPAREN", "G_SEMI", "G_COMMA", "G_DOT", "G_COLON", + "G_RANGE", "G_ELLIPSIS", "G_ASSIGN", "G_INC", "G_DEC", "G_PLUS", "G_MINUS", + "G_MUL", "G_DIV", "G_GT", "G_LT", "G_LE", "G_GE", "G_EQ", "G_NE", "G_NOT", + "G_AND", "G_OR", "WHITE_SPACE1", "BLOCK_COMMENT1", "LINE_COMMENT1" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public SchemaLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "SchemaLexer.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\u0004\u0000d\u0311\u0006\uffff\uffff\u0006\uffff\uffff\u0002\u0000\u0007"+ + "\u0000\u0002\u0001\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007"+ + "\u0003\u0002\u0004\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007"+ + "\u0006\u0002\u0007\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n"+ + "\u0007\n\u0002\u000b\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002"+ + "\u000e\u0007\u000e\u0002\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002"+ + "\u0011\u0007\u0011\u0002\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002"+ + "\u0014\u0007\u0014\u0002\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002"+ + "\u0017\u0007\u0017\u0002\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002"+ + "\u001a\u0007\u001a\u0002\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002"+ + "\u001d\u0007\u001d\u0002\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002"+ + " \u0007 \u0002!\u0007!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002"+ + "%\u0007%\u0002&\u0007&\u0002\'\u0007\'\u0002(\u0007(\u0002)\u0007)\u0002"+ + "*\u0007*\u0002+\u0007+\u0002,\u0007,\u0002-\u0007-\u0002.\u0007.\u0002"+ + "/\u0007/\u00020\u00070\u00021\u00071\u00022\u00072\u00023\u00073\u0002"+ + "4\u00074\u00025\u00075\u00026\u00076\u00027\u00077\u00028\u00078\u0002"+ + "9\u00079\u0002:\u0007:\u0002;\u0007;\u0002<\u0007<\u0002=\u0007=\u0002"+ + ">\u0007>\u0002?\u0007?\u0002@\u0007@\u0002A\u0007A\u0002B\u0007B\u0002"+ + "C\u0007C\u0002D\u0007D\u0002E\u0007E\u0002F\u0007F\u0002G\u0007G\u0002"+ + "H\u0007H\u0002I\u0007I\u0002J\u0007J\u0002K\u0007K\u0002L\u0007L\u0002"+ + "M\u0007M\u0002N\u0007N\u0002O\u0007O\u0002P\u0007P\u0002Q\u0007Q\u0002"+ + "R\u0007R\u0002S\u0007S\u0002T\u0007T\u0002U\u0007U\u0002V\u0007V\u0002"+ + "W\u0007W\u0002X\u0007X\u0002Y\u0007Y\u0002Z\u0007Z\u0002[\u0007[\u0002"+ + "\\\u0007\\\u0002]\u0007]\u0002^\u0007^\u0002_\u0007_\u0002`\u0007`\u0002"+ + "a\u0007a\u0002b\u0007b\u0002c\u0007c\u0002d\u0007d\u0002e\u0007e\u0002"+ + "f\u0007f\u0002g\u0007g\u0002h\u0007h\u0002i\u0007i\u0002j\u0007j\u0002"+ + "k\u0007k\u0002l\u0007l\u0002m\u0007m\u0002n\u0007n\u0002o\u0007o\u0002"+ + "p\u0007p\u0002q\u0007q\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000"+ + "\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002"+ + "\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003"+ + "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004"+ + "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004"+ + "\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005"+ + "\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\b\u0001"+ + "\b\u0001\b\u0001\b\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0001\t\u0001"+ + "\t\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001\f\u0001\f\u0001\r\u0001"+ + "\r\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u0010\u0001\u0010"+ + "\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0013\u0001\u0013"+ + "\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0001\u0015\u0005\u0015"+ + "\u014a\b\u0015\n\u0015\f\u0015\u014d\t\u0015\u0001\u0016\u0001\u0016\u0001"+ + "\u0016\u0001\u0017\u0001\u0017\u0004\u0017\u0154\b\u0017\u000b\u0017\f"+ + "\u0017\u0155\u0001\u0018\u0001\u0018\u0001\u0018\u0001\u0019\u0001\u0019"+ + "\u0001\u0019\u0001\u001a\u0001\u001a\u0005\u001a\u0160\b\u001a\n\u001a"+ + "\f\u001a\u0163\t\u001a\u0001\u001b\u0001\u001b\u0001\u001c\u0001\u001c"+ + "\u0001\u001d\u0001\u001d\u0001\u001d\u0005\u001d\u016c\b\u001d\n\u001d"+ + "\f\u001d\u016f\t\u001d\u0001\u001d\u0001\u001d\u0001\u001e\u0001\u001e"+ + "\u0001\u001e\u0003\u001e\u0176\b\u001e\u0001\u001f\u0001\u001f\u0001\u001f"+ + "\u0001\u001f\u0001\u001f\u0001\u001f\u0001 \u0001 \u0001!\u0001!\u0001"+ + "\"\u0003\"\u0183\b\"\u0001\"\u0001\"\u0001#\u0001#\u0001#\u0001$\u0001"+ + "$\u0003$\u018c\b$\u0001$\u0001$\u0001%\u0001%\u0004%\u0192\b%\u000b%\f"+ + "%\u0193\u0001&\u0001&\u0001&\u0005&\u0199\b&\n&\f&\u019c\t&\u0003&\u019e"+ + "\b&\u0001\'\u0001\'\u0003\'\u01a2\b\'\u0001\'\u0004\'\u01a5\b\'\u000b"+ + "\'\f\'\u01a6\u0001(\u0001(\u0001)\u0004)\u01ac\b)\u000b)\f)\u01ad\u0001"+ + ")\u0001)\u0001*\u0001*\u0001*\u0001*\u0005*\u01b6\b*\n*\f*\u01b9\t*\u0001"+ + "*\u0001*\u0001*\u0001*\u0001*\u0001+\u0001+\u0001+\u0001+\u0005+\u01c4"+ + "\b+\n+\f+\u01c7\t+\u0001+\u0001+\u0001,\u0001,\u0001,\u0001,\u0001-\u0001"+ + "-\u0001-\u0001.\u0001.\u0001.\u0001.\u0001.\u0001/\u0001/\u0001/\u0001"+ + "/\u0001/\u0001/\u00010\u00010\u00010\u00010\u00011\u00011\u00011\u0001"+ + "1\u00011\u00011\u00011\u00011\u00012\u00012\u00012\u00013\u00013\u0001"+ + "3\u00013\u00013\u00013\u00014\u00014\u00014\u00014\u00014\u00014\u0001"+ + "4\u00014\u00014\u00014\u00014\u00015\u00015\u00015\u00015\u00015\u0001"+ + "5\u00015\u00016\u00016\u00016\u00016\u00016\u00016\u00016\u00017\u0001"+ + "7\u00017\u00017\u00017\u00017\u00017\u00017\u00017\u00017\u00017\u0001"+ + "8\u00018\u00018\u00018\u00018\u00018\u00019\u00019\u00019\u00019\u0001"+ + "9\u00019\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001:\u0001"+ + ":\u0001;\u0001;\u0001;\u0001;\u0001;\u0001;\u0001;\u0001<\u0001<\u0001"+ + "<\u0001<\u0001<\u0001<\u0001<\u0001=\u0001=\u0001=\u0001=\u0001=\u0001"+ + ">\u0001>\u0001>\u0001>\u0001>\u0001>\u0001?\u0001?\u0001?\u0001?\u0001"+ + "?\u0001@\u0001@\u0001@\u0001@\u0001@\u0001@\u0001@\u0001@\u0001@\u0001"+ + "@\u0001A\u0001A\u0001A\u0001A\u0001A\u0001B\u0001B\u0001B\u0001B\u0001"+ + "C\u0001C\u0001C\u0001C\u0001C\u0001C\u0001C\u0001C\u0001C\u0001D\u0001"+ + "D\u0001D\u0001E\u0001E\u0001E\u0001E\u0001E\u0001E\u0001F\u0001F\u0001"+ + "F\u0001F\u0001F\u0001F\u0001F\u0001G\u0001G\u0001G\u0001G\u0001G\u0001"+ + "H\u0001H\u0001H\u0001H\u0001H\u0001H\u0001H\u0001I\u0001I\u0001I\u0001"+ + "I\u0001I\u0001I\u0001J\u0001J\u0001J\u0001J\u0001J\u0001J\u0001K\u0001"+ + "K\u0001K\u0001K\u0001K\u0001K\u0001K\u0001K\u0001L\u0001L\u0001M\u0001"+ + "M\u0003M\u0299\bM\u0001M\u0003M\u029c\bM\u0001N\u0001N\u0001O\u0001O\u0001"+ + "P\u0001P\u0001Q\u0001Q\u0001R\u0001R\u0001S\u0001S\u0001T\u0001T\u0001"+ + "U\u0001U\u0001V\u0001V\u0001W\u0001W\u0001X\u0001X\u0001Y\u0001Y\u0001"+ + "Z\u0001Z\u0001Z\u0001[\u0001[\u0001[\u0001[\u0001\\\u0001\\\u0001]\u0001"+ + "]\u0001]\u0001^\u0001^\u0001^\u0001_\u0001_\u0001`\u0001`\u0001a\u0001"+ + "a\u0001b\u0001b\u0001c\u0001c\u0001d\u0001d\u0001e\u0001e\u0001e\u0001"+ + "f\u0001f\u0001f\u0001g\u0001g\u0001g\u0001h\u0001h\u0001h\u0001i\u0001"+ + "i\u0001j\u0001j\u0001j\u0001k\u0001k\u0001k\u0001l\u0001l\u0001l\u0001"+ + "l\u0001l\u0001l\u0001l\u0001l\u0001l\u0001l\u0001l\u0001m\u0001m\u0001"+ + "m\u0001m\u0001m\u0001m\u0001m\u0001m\u0001m\u0001m\u0001m\u0001n\u0001"+ + "n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001"+ + "o\u0001o\u0001o\u0001o\u0001p\u0001p\u0001p\u0001p\u0001q\u0001q\u0001"+ + "q\u0001q\u0001\u01b7\u0000r\u0002\u0001\u0004\u0002\u0006\u0003\b\u0004"+ + "\n\u0005\f\u0006\u000e\u0007\u0010\b\u0012\t\u0014\n\u0016\u000b\u0018"+ + "\f\u001a\r\u001c\u000e\u001e\u000f \u0010\"\u0011$\u0012&\u0013(\u0014"+ + "*\u0015,\u0016.\u00170\u00182\u00194\u001a6\u00008\u0000:\u0000<\u001b"+ + ">\u0000@\u0000B\u0000D\u0000F\u001cH\u001dJ\u001eL\u0000N\u0000P\u0000"+ + "R\u0000T\u001fV X!Z\"\\#^$`%b&d\'f(h)j*l+n,p-r.t/v0x1z2|3~4\u00805\u0082"+ + "6\u00847\u00868\u00889\u008a:\u008c;\u008e<\u0090=\u0092>\u0094?\u0096"+ + "@\u0098A\u009aB\u009cC\u009eD\u00a0E\u00a2F\u00a4G\u00a6H\u00a8I\u00aa"+ + "J\u00acK\u00aeL\u00b0M\u00b2N\u00b4O\u00b6P\u00b8Q\u00baR\u00bcS\u00be"+ + "T\u00c0U\u00c2V\u00c4W\u00c6X\u00c8Y\u00caZ\u00cc[\u00ce\\\u00d0]\u00d2"+ + "^\u00d4_\u00d6`\u00d8a\u00da\u0000\u00dc\u0000\u00de\u0000\u00e0b\u00e2"+ + "c\u00e4d\u0002\u0000\u0001\u000b\u0003\u0000AZ__az\u0004\u000009AZ__a"+ + "z\b\u0000\"\"//\\\\bbffnnrrtt\u0003\u000009AFaf\u0003\u0000\u0000\u001f"+ + "\"\"\\\\\u0001\u000019\u0002\u0000EEee\u0002\u0000++--\u0001\u000009\u0003"+ + "\u0000\t\n\r\r \u0002\u0000\n\n\r\r\u0316\u0000\u0002\u0001\u0000\u0000"+ + "\u0000\u0000\u0004\u0001\u0000\u0000\u0000\u0000\u0006\u0001\u0000\u0000"+ + "\u0000\u0000\b\u0001\u0000\u0000\u0000\u0000\n\u0001\u0000\u0000\u0000"+ + "\u0000\f\u0001\u0000\u0000\u0000\u0000\u000e\u0001\u0000\u0000\u0000\u0000"+ + "\u0010\u0001\u0000\u0000\u0000\u0000\u0012\u0001\u0000\u0000\u0000\u0000"+ + "\u0014\u0001\u0000\u0000\u0000\u0000\u0016\u0001\u0000\u0000\u0000\u0000"+ + "\u0018\u0001\u0000\u0000\u0000\u0000\u001a\u0001\u0000\u0000\u0000\u0000"+ + "\u001c\u0001\u0000\u0000\u0000\u0000\u001e\u0001\u0000\u0000\u0000\u0000"+ + " \u0001\u0000\u0000\u0000\u0000\"\u0001\u0000\u0000\u0000\u0000$\u0001"+ + "\u0000\u0000\u0000\u0000&\u0001\u0000\u0000\u0000\u0000(\u0001\u0000\u0000"+ + "\u0000\u0000*\u0001\u0000\u0000\u0000\u0000,\u0001\u0000\u0000\u0000\u0000"+ + ".\u0001\u0000\u0000\u0000\u00000\u0001\u0000\u0000\u0000\u00002\u0001"+ + "\u0000\u0000\u0000\u00004\u0001\u0000\u0000\u0000\u0000<\u0001\u0000\u0000"+ + "\u0000\u0000F\u0001\u0000\u0000\u0000\u0000H\u0001\u0000\u0000\u0000\u0000"+ + "J\u0001\u0000\u0000\u0000\u0000T\u0001\u0000\u0000\u0000\u0000V\u0001"+ + "\u0000\u0000\u0000\u0000X\u0001\u0000\u0000\u0000\u0001Z\u0001\u0000\u0000"+ + "\u0000\u0001\\\u0001\u0000\u0000\u0000\u0001^\u0001\u0000\u0000\u0000"+ + "\u0001`\u0001\u0000\u0000\u0000\u0001b\u0001\u0000\u0000\u0000\u0001d"+ + "\u0001\u0000\u0000\u0000\u0001f\u0001\u0000\u0000\u0000\u0001h\u0001\u0000"+ + "\u0000\u0000\u0001j\u0001\u0000\u0000\u0000\u0001l\u0001\u0000\u0000\u0000"+ + "\u0001n\u0001\u0000\u0000\u0000\u0001p\u0001\u0000\u0000\u0000\u0001r"+ + "\u0001\u0000\u0000\u0000\u0001t\u0001\u0000\u0000\u0000\u0001v\u0001\u0000"+ + "\u0000\u0000\u0001x\u0001\u0000\u0000\u0000\u0001z\u0001\u0000\u0000\u0000"+ + "\u0001|\u0001\u0000\u0000\u0000\u0001~\u0001\u0000\u0000\u0000\u0001\u0080"+ + "\u0001\u0000\u0000\u0000\u0001\u0082\u0001\u0000\u0000\u0000\u0001\u0084"+ + "\u0001\u0000\u0000\u0000\u0001\u0086\u0001\u0000\u0000\u0000\u0001\u0088"+ + "\u0001\u0000\u0000\u0000\u0001\u008a\u0001\u0000\u0000\u0000\u0001\u008c"+ + "\u0001\u0000\u0000\u0000\u0001\u008e\u0001\u0000\u0000\u0000\u0001\u0090"+ + "\u0001\u0000\u0000\u0000\u0001\u0092\u0001\u0000\u0000\u0000\u0001\u0094"+ + "\u0001\u0000\u0000\u0000\u0001\u0096\u0001\u0000\u0000\u0000\u0001\u0098"+ + "\u0001\u0000\u0000\u0000\u0001\u009a\u0001\u0000\u0000\u0000\u0001\u009c"+ + "\u0001\u0000\u0000\u0000\u0001\u009e\u0001\u0000\u0000\u0000\u0001\u00a0"+ + "\u0001\u0000\u0000\u0000\u0001\u00a2\u0001\u0000\u0000\u0000\u0001\u00a4"+ + "\u0001\u0000\u0000\u0000\u0001\u00a6\u0001\u0000\u0000\u0000\u0001\u00a8"+ + "\u0001\u0000\u0000\u0000\u0001\u00aa\u0001\u0000\u0000\u0000\u0001\u00ac"+ + "\u0001\u0000\u0000\u0000\u0001\u00ae\u0001\u0000\u0000\u0000\u0001\u00b0"+ + "\u0001\u0000\u0000\u0000\u0001\u00b2\u0001\u0000\u0000\u0000\u0001\u00b4"+ + "\u0001\u0000\u0000\u0000\u0001\u00b6\u0001\u0000\u0000\u0000\u0001\u00b8"+ + "\u0001\u0000\u0000\u0000\u0001\u00ba\u0001\u0000\u0000\u0000\u0001\u00bc"+ + "\u0001\u0000\u0000\u0000\u0001\u00be\u0001\u0000\u0000\u0000\u0001\u00c0"+ + "\u0001\u0000\u0000\u0000\u0001\u00c2\u0001\u0000\u0000\u0000\u0001\u00c4"+ + "\u0001\u0000\u0000\u0000\u0001\u00c6\u0001\u0000\u0000\u0000\u0001\u00c8"+ + "\u0001\u0000\u0000\u0000\u0001\u00ca\u0001\u0000\u0000\u0000\u0001\u00cc"+ + "\u0001\u0000\u0000\u0000\u0001\u00ce\u0001\u0000\u0000\u0000\u0001\u00d0"+ + "\u0001\u0000\u0000\u0000\u0001\u00d2\u0001\u0000\u0000\u0000\u0001\u00d4"+ + "\u0001\u0000\u0000\u0000\u0001\u00d6\u0001\u0000\u0000\u0000\u0001\u00d8"+ + "\u0001\u0000\u0000\u0000\u0001\u00da\u0001\u0000\u0000\u0000\u0001\u00dc"+ + "\u0001\u0000\u0000\u0000\u0001\u00de\u0001\u0000\u0000\u0000\u0001\u00e0"+ + "\u0001\u0000\u0000\u0000\u0001\u00e2\u0001\u0000\u0000\u0000\u0001\u00e4"+ + "\u0001\u0000\u0000\u0000\u0002\u00e6\u0001\u0000\u0000\u0000\u0004\u00ed"+ + "\u0001\u0000\u0000\u0000\u0006\u00f6\u0001\u0000\u0000\u0000\b\u00fe\u0001"+ + "\u0000\u0000\u0000\n\u0106\u0001\u0000\u0000\u0000\f\u010e\u0001\u0000"+ + "\u0000\u0000\u000e\u0116\u0001\u0000\u0000\u0000\u0010\u0120\u0001\u0000"+ + "\u0000\u0000\u0012\u0125\u0001\u0000\u0000\u0000\u0014\u012b\u0001\u0000"+ + "\u0000\u0000\u0016\u0130\u0001\u0000\u0000\u0000\u0018\u0132\u0001\u0000"+ + "\u0000\u0000\u001a\u0134\u0001\u0000\u0000\u0000\u001c\u0136\u0001\u0000"+ + "\u0000\u0000\u001e\u0138\u0001\u0000\u0000\u0000 \u013a\u0001\u0000\u0000"+ + "\u0000\"\u013c\u0001\u0000\u0000\u0000$\u013e\u0001\u0000\u0000\u0000"+ + "&\u0140\u0001\u0000\u0000\u0000(\u0142\u0001\u0000\u0000\u0000*\u0144"+ + "\u0001\u0000\u0000\u0000,\u0146\u0001\u0000\u0000\u0000.\u014e\u0001\u0000"+ + "\u0000\u00000\u0151\u0001\u0000\u0000\u00002\u0157\u0001\u0000\u0000\u0000"+ + "4\u015a\u0001\u0000\u0000\u00006\u015d\u0001\u0000\u0000\u00008\u0164"+ + "\u0001\u0000\u0000\u0000:\u0166\u0001\u0000\u0000\u0000<\u0168\u0001\u0000"+ + "\u0000\u0000>\u0172\u0001\u0000\u0000\u0000@\u0177\u0001\u0000\u0000\u0000"+ + "B\u017d\u0001\u0000\u0000\u0000D\u017f\u0001\u0000\u0000\u0000F\u0182"+ + "\u0001\u0000\u0000\u0000H\u0186\u0001\u0000\u0000\u0000J\u0189\u0001\u0000"+ + "\u0000\u0000L\u018f\u0001\u0000\u0000\u0000N\u019d\u0001\u0000\u0000\u0000"+ + "P\u019f\u0001\u0000\u0000\u0000R\u01a8\u0001\u0000\u0000\u0000T\u01ab"+ + "\u0001\u0000\u0000\u0000V\u01b1\u0001\u0000\u0000\u0000X\u01bf\u0001\u0000"+ + "\u0000\u0000Z\u01ca\u0001\u0000\u0000\u0000\\\u01ce\u0001\u0000\u0000"+ + "\u0000^\u01d1\u0001\u0000\u0000\u0000`\u01d6\u0001\u0000\u0000\u0000b"+ + "\u01dc\u0001\u0000\u0000\u0000d\u01e0\u0001\u0000\u0000\u0000f\u01e8\u0001"+ + "\u0000\u0000\u0000h\u01eb\u0001\u0000\u0000\u0000j\u01f1\u0001\u0000\u0000"+ + "\u0000l\u01fc\u0001\u0000\u0000\u0000n\u0203\u0001\u0000\u0000\u0000p"+ + "\u020a\u0001\u0000\u0000\u0000r\u0215\u0001\u0000\u0000\u0000t\u021b\u0001"+ + "\u0000\u0000\u0000v\u0221\u0001\u0000\u0000\u0000x\u022a\u0001\u0000\u0000"+ + "\u0000z\u0231\u0001\u0000\u0000\u0000|\u0238\u0001\u0000\u0000\u0000~"+ + "\u023d\u0001\u0000\u0000\u0000\u0080\u0243\u0001\u0000\u0000\u0000\u0082"+ + "\u0248\u0001\u0000\u0000\u0000\u0084\u0252\u0001\u0000\u0000\u0000\u0086"+ + "\u0257\u0001\u0000\u0000\u0000\u0088\u025b\u0001\u0000\u0000\u0000\u008a"+ + "\u0264\u0001\u0000\u0000\u0000\u008c\u0267\u0001\u0000\u0000\u0000\u008e"+ + "\u026d\u0001\u0000\u0000\u0000\u0090\u0274\u0001\u0000\u0000\u0000\u0092"+ + "\u0279\u0001\u0000\u0000\u0000\u0094\u0280\u0001\u0000\u0000\u0000\u0096"+ + "\u0286\u0001\u0000\u0000\u0000\u0098\u028c\u0001\u0000\u0000\u0000\u009a"+ + "\u0294\u0001\u0000\u0000\u0000\u009c\u0296\u0001\u0000\u0000\u0000\u009e"+ + "\u029d\u0001\u0000\u0000\u0000\u00a0\u029f\u0001\u0000\u0000\u0000\u00a2"+ + "\u02a1\u0001\u0000\u0000\u0000\u00a4\u02a3\u0001\u0000\u0000\u0000\u00a6"+ + "\u02a5\u0001\u0000\u0000\u0000\u00a8\u02a7\u0001\u0000\u0000\u0000\u00aa"+ + "\u02a9\u0001\u0000\u0000\u0000\u00ac\u02ab\u0001\u0000\u0000\u0000\u00ae"+ + "\u02ad\u0001\u0000\u0000\u0000\u00b0\u02af\u0001\u0000\u0000\u0000\u00b2"+ + "\u02b1\u0001\u0000\u0000\u0000\u00b4\u02b3\u0001\u0000\u0000\u0000\u00b6"+ + "\u02b5\u0001\u0000\u0000\u0000\u00b8\u02b8\u0001\u0000\u0000\u0000\u00ba"+ + "\u02bc\u0001\u0000\u0000\u0000\u00bc\u02be\u0001\u0000\u0000\u0000\u00be"+ + "\u02c1\u0001\u0000\u0000\u0000\u00c0\u02c4\u0001\u0000\u0000\u0000\u00c2"+ + "\u02c6\u0001\u0000\u0000\u0000\u00c4\u02c8\u0001\u0000\u0000\u0000\u00c6"+ + "\u02ca\u0001\u0000\u0000\u0000\u00c8\u02cc\u0001\u0000\u0000\u0000\u00ca"+ + "\u02ce\u0001\u0000\u0000\u0000\u00cc\u02d0\u0001\u0000\u0000\u0000\u00ce"+ + "\u02d3\u0001\u0000\u0000\u0000\u00d0\u02d6\u0001\u0000\u0000\u0000\u00d2"+ + "\u02d9\u0001\u0000\u0000\u0000\u00d4\u02dc\u0001\u0000\u0000\u0000\u00d6"+ + "\u02de\u0001\u0000\u0000\u0000\u00d8\u02e1\u0001\u0000\u0000\u0000\u00da"+ + "\u02e4\u0001\u0000\u0000\u0000\u00dc\u02ef\u0001\u0000\u0000\u0000\u00de"+ + "\u02fa\u0001\u0000\u0000\u0000\u00e0\u0305\u0001\u0000\u0000\u0000\u00e2"+ + "\u0309\u0001\u0000\u0000\u0000\u00e4\u030d\u0001\u0000\u0000\u0000\u00e6"+ + "\u00e7\u0005%\u0000\u0000\u00e7\u00e8\u0005t\u0000\u0000\u00e8\u00e9\u0005"+ + "i\u0000\u0000\u00e9\u00ea\u0005t\u0000\u0000\u00ea\u00eb\u0005l\u0000"+ + "\u0000\u00eb\u00ec\u0005e\u0000\u0000\u00ec\u0003\u0001\u0000\u0000\u0000"+ + "\u00ed\u00ee\u0005%\u0000\u0000\u00ee\u00ef\u0005v\u0000\u0000\u00ef\u00f0"+ + "\u0005e\u0000\u0000\u00f0\u00f1\u0005r\u0000\u0000\u00f1\u00f2\u0005s"+ + "\u0000\u0000\u00f2\u00f3\u0005i\u0000\u0000\u00f3\u00f4\u0005o\u0000\u0000"+ + "\u00f4\u00f5\u0005n\u0000\u0000\u00f5\u0005\u0001\u0000\u0000\u0000\u00f6"+ + "\u00f7\u0005%\u0000\u0000\u00f7\u00f8\u0005i\u0000\u0000\u00f8\u00f9\u0005"+ + "m\u0000\u0000\u00f9\u00fa\u0005p\u0000\u0000\u00fa\u00fb\u0005o\u0000"+ + "\u0000\u00fb\u00fc\u0005r\u0000\u0000\u00fc\u00fd\u0005t\u0000\u0000\u00fd"+ + "\u0007\u0001\u0000\u0000\u0000\u00fe\u00ff\u0005%\u0000\u0000\u00ff\u0100"+ + "\u0005p\u0000\u0000\u0100\u0101\u0005r\u0000\u0000\u0101\u0102\u0005a"+ + "\u0000\u0000\u0102\u0103\u0005g\u0000\u0000\u0103\u0104\u0005m\u0000\u0000"+ + "\u0104\u0105\u0005a\u0000\u0000\u0105\t\u0001\u0000\u0000\u0000\u0106"+ + "\u0107\u0005%\u0000\u0000\u0107\u0108\u0005d\u0000\u0000\u0108\u0109\u0005"+ + "e\u0000\u0000\u0109\u010a\u0005f\u0000\u0000\u010a\u010b\u0005i\u0000"+ + "\u0000\u010b\u010c\u0005n\u0000\u0000\u010c\u010d\u0005e\u0000\u0000\u010d"+ + "\u000b\u0001\u0000\u0000\u0000\u010e\u010f\u0005%\u0000\u0000\u010f\u0110"+ + "\u0005s\u0000\u0000\u0110\u0111\u0005c\u0000\u0000\u0111\u0112\u0005h"+ + "\u0000\u0000\u0112\u0113\u0005e\u0000\u0000\u0113\u0114\u0005m\u0000\u0000"+ + "\u0114\u0115\u0005a\u0000\u0000\u0115\r\u0001\u0000\u0000\u0000\u0116"+ + "\u0117\u0005%\u0000\u0000\u0117\u0118\u0005s\u0000\u0000\u0118\u0119\u0005"+ + "c\u0000\u0000\u0119\u011a\u0005r\u0000\u0000\u011a\u011b\u0005i\u0000"+ + "\u0000\u011b\u011c\u0005p\u0000\u0000\u011c\u011d\u0005t\u0000\u0000\u011d"+ + "\u011e\u0001\u0000\u0000\u0000\u011e\u011f\u0006\u0006\u0000\u0000\u011f"+ + "\u000f\u0001\u0000\u0000\u0000\u0120\u0121\u0005t\u0000\u0000\u0121\u0122"+ + "\u0005r\u0000\u0000\u0122\u0123\u0005u\u0000\u0000\u0123\u0124\u0005e"+ + "\u0000\u0000\u0124\u0011\u0001\u0000\u0000\u0000\u0125\u0126\u0005f\u0000"+ + "\u0000\u0126\u0127\u0005a\u0000\u0000\u0127\u0128\u0005l\u0000\u0000\u0128"+ + "\u0129\u0005s\u0000\u0000\u0129\u012a\u0005e\u0000\u0000\u012a\u0013\u0001"+ + "\u0000\u0000\u0000\u012b\u012c\u0005n\u0000\u0000\u012c\u012d\u0005u\u0000"+ + "\u0000\u012d\u012e\u0005l\u0000\u0000\u012e\u012f\u0005l\u0000\u0000\u012f"+ + "\u0015\u0001\u0000\u0000\u0000\u0130\u0131\u0005:\u0000\u0000\u0131\u0017"+ + "\u0001\u0000\u0000\u0000\u0132\u0133\u0005,\u0000\u0000\u0133\u0019\u0001"+ + "\u0000\u0000\u0000\u0134\u0135\u0005*\u0000\u0000\u0135\u001b\u0001\u0000"+ + "\u0000\u0000\u0136\u0137\u0005{\u0000\u0000\u0137\u001d\u0001\u0000\u0000"+ + "\u0000\u0138\u0139\u0005}\u0000\u0000\u0139\u001f\u0001\u0000\u0000\u0000"+ + "\u013a\u013b\u0005[\u0000\u0000\u013b!\u0001\u0000\u0000\u0000\u013c\u013d"+ + "\u0005]\u0000\u0000\u013d#\u0001\u0000\u0000\u0000\u013e\u013f\u0005("+ + "\u0000\u0000\u013f%\u0001\u0000\u0000\u0000\u0140\u0141\u0005)\u0000\u0000"+ + "\u0141\'\u0001\u0000\u0000\u0000\u0142\u0143\u0005?\u0000\u0000\u0143"+ + ")\u0001\u0000\u0000\u0000\u0144\u0145\u0005!\u0000\u0000\u0145+\u0001"+ + "\u0000\u0000\u0000\u0146\u014b\u00036\u001a\u0000\u0147\u0148\u0005.\u0000"+ + "\u0000\u0148\u014a\u00036\u001a\u0000\u0149\u0147\u0001\u0000\u0000\u0000"+ + "\u014a\u014d\u0001\u0000\u0000\u0000\u014b\u0149\u0001\u0000\u0000\u0000"+ + "\u014b\u014c\u0001\u0000\u0000\u0000\u014c-\u0001\u0000\u0000\u0000\u014d"+ + "\u014b\u0001\u0000\u0000\u0000\u014e\u014f\u0005$\u0000\u0000\u014f\u0150"+ + "\u00036\u001a\u0000\u0150/\u0001\u0000\u0000\u0000\u0151\u0153\u0005#"+ + "\u0000\u0000\u0152\u0154\u00038\u001b\u0000\u0153\u0152\u0001\u0000\u0000"+ + "\u0000\u0154\u0155\u0001\u0000\u0000\u0000\u0155\u0153\u0001\u0000\u0000"+ + "\u0000\u0155\u0156\u0001\u0000\u0000\u0000\u01561\u0001\u0000\u0000\u0000"+ + "\u0157\u0158\u0005@\u0000\u0000\u0158\u0159\u00036\u001a\u0000\u01593"+ + "\u0001\u0000\u0000\u0000\u015a\u015b\u0005&\u0000\u0000\u015b\u015c\u0003"+ + "6\u001a\u0000\u015c5\u0001\u0000\u0000\u0000\u015d\u0161\u00038\u001b"+ + "\u0000\u015e\u0160\u0003:\u001c\u0000\u015f\u015e\u0001\u0000\u0000\u0000"+ + "\u0160\u0163\u0001\u0000\u0000\u0000\u0161\u015f\u0001\u0000\u0000\u0000"+ + "\u0161\u0162\u0001\u0000\u0000\u0000\u01627\u0001\u0000\u0000\u0000\u0163"+ + "\u0161\u0001\u0000\u0000\u0000\u0164\u0165\u0007\u0000\u0000\u0000\u0165"+ + "9\u0001\u0000\u0000\u0000\u0166\u0167\u0007\u0001\u0000\u0000\u0167;\u0001"+ + "\u0000\u0000\u0000\u0168\u016d\u0005\"\u0000\u0000\u0169\u016c\u0003>"+ + "\u001e\u0000\u016a\u016c\u0003D!\u0000\u016b\u0169\u0001\u0000\u0000\u0000"+ + "\u016b\u016a\u0001\u0000\u0000\u0000\u016c\u016f\u0001\u0000\u0000\u0000"+ + "\u016d\u016b\u0001\u0000\u0000\u0000\u016d\u016e\u0001\u0000\u0000\u0000"+ + "\u016e\u0170\u0001\u0000\u0000\u0000\u016f\u016d\u0001\u0000\u0000\u0000"+ + "\u0170\u0171\u0005\"\u0000\u0000\u0171=\u0001\u0000\u0000\u0000\u0172"+ + "\u0175\u0005\\\u0000\u0000\u0173\u0176\u0007\u0002\u0000\u0000\u0174\u0176"+ + "\u0003@\u001f\u0000\u0175\u0173\u0001\u0000\u0000\u0000\u0175\u0174\u0001"+ + "\u0000\u0000\u0000\u0176?\u0001\u0000\u0000\u0000\u0177\u0178\u0005u\u0000"+ + "\u0000\u0178\u0179\u0003B \u0000\u0179\u017a\u0003B \u0000\u017a\u017b"+ + "\u0003B \u0000\u017b\u017c\u0003B \u0000\u017cA\u0001\u0000\u0000\u0000"+ + "\u017d\u017e\u0007\u0003\u0000\u0000\u017eC\u0001\u0000\u0000\u0000\u017f"+ + "\u0180\b\u0004\u0000\u0000\u0180E\u0001\u0000\u0000\u0000\u0181\u0183"+ + "\u0005-\u0000\u0000\u0182\u0181\u0001\u0000\u0000\u0000\u0182\u0183\u0001"+ + "\u0000\u0000\u0000\u0183\u0184\u0001\u0000\u0000\u0000\u0184\u0185\u0003"+ + "N&\u0000\u0185G\u0001\u0000\u0000\u0000\u0186\u0187\u0003F\"\u0000\u0187"+ + "\u0188\u0003L%\u0000\u0188I\u0001\u0000\u0000\u0000\u0189\u018b\u0003"+ + "F\"\u0000\u018a\u018c\u0003L%\u0000\u018b\u018a\u0001\u0000\u0000\u0000"+ + "\u018b\u018c\u0001\u0000\u0000\u0000\u018c\u018d\u0001\u0000\u0000\u0000"+ + "\u018d\u018e\u0003P\'\u0000\u018eK\u0001\u0000\u0000\u0000\u018f\u0191"+ + "\u0005.\u0000\u0000\u0190\u0192\u0003R(\u0000\u0191\u0190\u0001\u0000"+ + "\u0000\u0000\u0192\u0193\u0001\u0000\u0000\u0000\u0193\u0191\u0001\u0000"+ + "\u0000\u0000\u0193\u0194\u0001\u0000\u0000\u0000\u0194M\u0001\u0000\u0000"+ + "\u0000\u0195\u019e\u00050\u0000\u0000\u0196\u019a\u0007\u0005\u0000\u0000"+ + "\u0197\u0199\u0003R(\u0000\u0198\u0197\u0001\u0000\u0000\u0000\u0199\u019c"+ + "\u0001\u0000\u0000\u0000\u019a\u0198\u0001\u0000\u0000\u0000\u019a\u019b"+ + "\u0001\u0000\u0000\u0000\u019b\u019e\u0001\u0000\u0000\u0000\u019c\u019a"+ + "\u0001\u0000\u0000\u0000\u019d\u0195\u0001\u0000\u0000\u0000\u019d\u0196"+ + "\u0001\u0000\u0000\u0000\u019eO\u0001\u0000\u0000\u0000\u019f\u01a1\u0007"+ + "\u0006\u0000\u0000\u01a0\u01a2\u0007\u0007\u0000\u0000\u01a1\u01a0\u0001"+ + "\u0000\u0000\u0000\u01a1\u01a2\u0001\u0000\u0000\u0000\u01a2\u01a4\u0001"+ + "\u0000\u0000\u0000\u01a3\u01a5\u0003R(\u0000\u01a4\u01a3\u0001\u0000\u0000"+ + "\u0000\u01a5\u01a6\u0001\u0000\u0000\u0000\u01a6\u01a4\u0001\u0000\u0000"+ + "\u0000\u01a6\u01a7\u0001\u0000\u0000\u0000\u01a7Q\u0001\u0000\u0000\u0000"+ + "\u01a8\u01a9\u0007\b\u0000\u0000\u01a9S\u0001\u0000\u0000\u0000\u01aa"+ + "\u01ac\u0007\t\u0000\u0000\u01ab\u01aa\u0001\u0000\u0000\u0000\u01ac\u01ad"+ + "\u0001\u0000\u0000\u0000\u01ad\u01ab\u0001\u0000\u0000\u0000\u01ad\u01ae"+ + "\u0001\u0000\u0000\u0000\u01ae\u01af\u0001\u0000\u0000\u0000\u01af\u01b0"+ + "\u0006)\u0001\u0000\u01b0U\u0001\u0000\u0000\u0000\u01b1\u01b2\u0005/"+ + "\u0000\u0000\u01b2\u01b3\u0005*\u0000\u0000\u01b3\u01b7\u0001\u0000\u0000"+ + "\u0000\u01b4\u01b6\t\u0000\u0000\u0000\u01b5\u01b4\u0001\u0000\u0000\u0000"+ + "\u01b6\u01b9\u0001\u0000\u0000\u0000\u01b7\u01b8\u0001\u0000\u0000\u0000"+ + "\u01b7\u01b5\u0001\u0000\u0000\u0000\u01b8\u01ba\u0001\u0000\u0000\u0000"+ + "\u01b9\u01b7\u0001\u0000\u0000\u0000\u01ba\u01bb\u0005*\u0000\u0000\u01bb"+ + "\u01bc\u0005/\u0000\u0000\u01bc\u01bd\u0001\u0000\u0000\u0000\u01bd\u01be"+ + "\u0006*\u0001\u0000\u01beW\u0001\u0000\u0000\u0000\u01bf\u01c0\u0005/"+ + "\u0000\u0000\u01c0\u01c1\u0005/\u0000\u0000\u01c1\u01c5\u0001\u0000\u0000"+ + "\u0000\u01c2\u01c4\b\n\u0000\u0000\u01c3\u01c2\u0001\u0000\u0000\u0000"+ + "\u01c4\u01c7\u0001\u0000\u0000\u0000\u01c5\u01c3\u0001\u0000\u0000\u0000"+ + "\u01c5\u01c6\u0001\u0000\u0000\u0000\u01c6\u01c8\u0001\u0000\u0000\u0000"+ + "\u01c7\u01c5\u0001\u0000\u0000\u0000\u01c8\u01c9\u0006+\u0001\u0000\u01c9"+ + "Y\u0001\u0000\u0000\u0000\u01ca\u01cb\u0005v\u0000\u0000\u01cb\u01cc\u0005"+ + "a\u0000\u0000\u01cc\u01cd\u0005r\u0000\u0000\u01cd[\u0001\u0000\u0000"+ + "\u0000\u01ce\u01cf\u0005i\u0000\u0000\u01cf\u01d0\u0005f\u0000\u0000\u01d0"+ + "]\u0001\u0000\u0000\u0000\u01d1\u01d2\u0005e\u0000\u0000\u01d2\u01d3\u0005"+ + "l\u0000\u0000\u01d3\u01d4\u0005s\u0000\u0000\u01d4\u01d5\u0005e\u0000"+ + "\u0000\u01d5_\u0001\u0000\u0000\u0000\u01d6\u01d7\u0005w\u0000\u0000\u01d7"+ + "\u01d8\u0005h\u0000\u0000\u01d8\u01d9\u0005i\u0000\u0000\u01d9\u01da\u0005"+ + "l\u0000\u0000\u01da\u01db\u0005e\u0000\u0000\u01dba\u0001\u0000\u0000"+ + "\u0000\u01dc\u01dd\u0005f\u0000\u0000\u01dd\u01de\u0005o\u0000\u0000\u01de"+ + "\u01df\u0005r\u0000\u0000\u01dfc\u0001\u0000\u0000\u0000\u01e0\u01e1\u0005"+ + "f\u0000\u0000\u01e1\u01e2\u0005o\u0000\u0000\u01e2\u01e3\u0005r\u0000"+ + "\u0000\u01e3\u01e4\u0005e\u0000\u0000\u01e4\u01e5\u0005a\u0000\u0000\u01e5"+ + "\u01e6\u0005c\u0000\u0000\u01e6\u01e7\u0005h\u0000\u0000\u01e7e\u0001"+ + "\u0000\u0000\u0000\u01e8\u01e9\u0005i\u0000\u0000\u01e9\u01ea\u0005n\u0000"+ + "\u0000\u01eag\u0001\u0000\u0000\u0000\u01eb\u01ec\u0005b\u0000\u0000\u01ec"+ + "\u01ed\u0005r\u0000\u0000\u01ed\u01ee\u0005e\u0000\u0000\u01ee\u01ef\u0005"+ + "a\u0000\u0000\u01ef\u01f0\u0005k\u0000\u0000\u01f0i\u0001\u0000\u0000"+ + "\u0000\u01f1\u01f2\u0005c\u0000\u0000\u01f2\u01f3\u0005o\u0000\u0000\u01f3"+ + "\u01f4\u0005n\u0000\u0000\u01f4\u01f5\u0005s\u0000\u0000\u01f5\u01f6\u0005"+ + "t\u0000\u0000\u01f6\u01f7\u0005r\u0000\u0000\u01f7\u01f8\u0005a\u0000"+ + "\u0000\u01f8\u01f9\u0005i\u0000\u0000\u01f9\u01fa\u0005n\u0000\u0000\u01fa"+ + "\u01fb\u0005t\u0000\u0000\u01fbk\u0001\u0000\u0000\u0000\u01fc\u01fd\u0005"+ + "t\u0000\u0000\u01fd\u01fe\u0005a\u0000\u0000\u01fe\u01ff\u0005r\u0000"+ + "\u0000\u01ff\u0200\u0005g\u0000\u0000\u0200\u0201\u0005e\u0000\u0000\u0201"+ + "\u0202\u0005t\u0000\u0000\u0202m\u0001\u0000\u0000\u0000\u0203\u0204\u0005"+ + "c\u0000\u0000\u0204\u0205\u0005a\u0000\u0000\u0205\u0206\u0005l\u0000"+ + "\u0000\u0206\u0207\u0005l\u0000\u0000\u0207\u0208\u0005e\u0000\u0000\u0208"+ + "\u0209\u0005r\u0000\u0000\u0209o\u0001\u0000\u0000\u0000\u020a\u020b\u0005"+ + "s\u0000\u0000\u020b\u020c\u0005u\u0000\u0000\u020c\u020d\u0005b\u0000"+ + "\u0000\u020d\u020e\u0005r\u0000\u0000\u020e\u020f\u0005o\u0000\u0000\u020f"+ + "\u0210\u0005u\u0000\u0000\u0210\u0211\u0005t\u0000\u0000\u0211\u0212\u0005"+ + "i\u0000\u0000\u0212\u0213\u0005n\u0000\u0000\u0213\u0214\u0005e\u0000"+ + "\u0000\u0214q\u0001\u0000\u0000\u0000\u0215\u0216\u0005t\u0000\u0000\u0216"+ + "\u0217\u0005r\u0000\u0000\u0217\u0218\u0005y\u0000\u0000\u0218\u0219\u0005"+ + "o\u0000\u0000\u0219\u021a\u0005f\u0000\u0000\u021as\u0001\u0000\u0000"+ + "\u0000\u021b\u021c\u0005t\u0000\u0000\u021c\u021d\u0005h\u0000\u0000\u021d"+ + "\u021e\u0005r\u0000\u0000\u021e\u021f\u0005o\u0000\u0000\u021f\u0220\u0005"+ + "w\u0000\u0000\u0220u\u0001\u0000\u0000\u0000\u0221\u0222\u0005f\u0000"+ + "\u0000\u0222\u0223\u0005u\u0000\u0000\u0223\u0224\u0005n\u0000\u0000\u0224"+ + "\u0225\u0005c\u0000\u0000\u0225\u0226\u0005t\u0000\u0000\u0226\u0227\u0005"+ + "i\u0000\u0000\u0227\u0228\u0005o\u0000\u0000\u0228\u0229\u0005n\u0000"+ + "\u0000\u0229w\u0001\u0000\u0000\u0000\u022a\u022b\u0005r\u0000\u0000\u022b"+ + "\u022c\u0005e\u0000\u0000\u022c\u022d\u0005t\u0000\u0000\u022d\u022e\u0005"+ + "u\u0000\u0000\u022e\u022f\u0005r\u0000\u0000\u022f\u0230\u0005n\u0000"+ + "\u0000\u0230y\u0001\u0000\u0000\u0000\u0231\u0232\u0005f\u0000\u0000\u0232"+ + "\u0233\u0005u\u0000\u0000\u0233\u0234\u0005t\u0000\u0000\u0234\u0235\u0005"+ + "u\u0000\u0000\u0235\u0236\u0005r\u0000\u0000\u0236\u0237\u0005e\u0000"+ + "\u0000\u0237{\u0001\u0000\u0000\u0000\u0238\u0239\u0005t\u0000\u0000\u0239"+ + "\u023a\u0005r\u0000\u0000\u023a\u023b\u0005u\u0000\u0000\u023b\u023c\u0005"+ + "e\u0000\u0000\u023c}\u0001\u0000\u0000\u0000\u023d\u023e\u0005f\u0000"+ + "\u0000\u023e\u023f\u0005a\u0000\u0000\u023f\u0240\u0005l\u0000\u0000\u0240"+ + "\u0241\u0005s\u0000\u0000\u0241\u0242\u0005e\u0000\u0000\u0242\u007f\u0001"+ + "\u0000\u0000\u0000\u0243\u0244\u0005n\u0000\u0000\u0244\u0245\u0005u\u0000"+ + "\u0000\u0245\u0246\u0005l\u0000\u0000\u0246\u0247\u0005l\u0000\u0000\u0247"+ + "\u0081\u0001\u0000\u0000\u0000\u0248\u0249\u0005u\u0000\u0000\u0249\u024a"+ + "\u0005n\u0000\u0000\u024a\u024b\u0005d\u0000\u0000\u024b\u024c\u0005e"+ + "\u0000\u0000\u024c\u024d\u0005f\u0000\u0000\u024d\u024e\u0005i\u0000\u0000"+ + "\u024e\u024f\u0005n\u0000\u0000\u024f\u0250\u0005e\u0000\u0000\u0250\u0251"+ + "\u0005d\u0000\u0000\u0251\u0083\u0001\u0000\u0000\u0000\u0252\u0253\u0005"+ + "t\u0000\u0000\u0253\u0254\u0005h\u0000\u0000\u0254\u0255\u0005i\u0000"+ + "\u0000\u0255\u0256\u0005s\u0000\u0000\u0256\u0085\u0001\u0000\u0000\u0000"+ + "\u0257\u0258\u0005n\u0000\u0000\u0258\u0259\u0005e\u0000\u0000\u0259\u025a"+ + "\u0005w\u0000\u0000\u025a\u0087\u0001\u0000\u0000\u0000\u025b\u025c\u0005"+ + "c\u0000\u0000\u025c\u025d\u0005o\u0000\u0000\u025d\u025e\u0005n\u0000"+ + "\u0000\u025e\u025f\u0005t\u0000\u0000\u025f\u0260\u0005i\u0000\u0000\u0260"+ + "\u0261\u0005n\u0000\u0000\u0261\u0262\u0005u\u0000\u0000\u0262\u0263\u0005"+ + "e\u0000\u0000\u0263\u0089\u0001\u0000\u0000\u0000\u0264\u0265\u0005d\u0000"+ + "\u0000\u0265\u0266\u0005o\u0000\u0000\u0266\u008b\u0001\u0000\u0000\u0000"+ + "\u0267\u0268\u0005c\u0000\u0000\u0268\u0269\u0005o\u0000\u0000\u0269\u026a"+ + "\u0005n\u0000\u0000\u026a\u026b\u0005s\u0000\u0000\u026b\u026c\u0005t"+ + "\u0000\u0000\u026c\u008d\u0001\u0000\u0000\u0000\u026d\u026e\u0005s\u0000"+ + "\u0000\u026e\u026f\u0005w\u0000\u0000\u026f\u0270\u0005i\u0000\u0000\u0270"+ + "\u0271\u0005t\u0000\u0000\u0271\u0272\u0005c\u0000\u0000\u0272\u0273\u0005"+ + "h\u0000\u0000\u0273\u008f\u0001\u0000\u0000\u0000\u0274\u0275\u0005c\u0000"+ + "\u0000\u0275\u0276\u0005a\u0000\u0000\u0276\u0277\u0005s\u0000\u0000\u0277"+ + "\u0278\u0005e\u0000\u0000\u0278\u0091\u0001\u0000\u0000\u0000\u0279\u027a"+ + "\u0005i\u0000\u0000\u027a\u027b\u0005m\u0000\u0000\u027b\u027c\u0005p"+ + "\u0000\u0000\u027c\u027d\u0005o\u0000\u0000\u027d\u027e\u0005r\u0000\u0000"+ + "\u027e\u027f\u0005t\u0000\u0000\u027f\u0093\u0001\u0000\u0000\u0000\u0280"+ + "\u0281\u0005c\u0000\u0000\u0281\u0282\u0005l\u0000\u0000\u0282\u0283\u0005"+ + "a\u0000\u0000\u0283\u0284\u0005s\u0000\u0000\u0284\u0285\u0005s\u0000"+ + "\u0000\u0285\u0095\u0001\u0000\u0000\u0000\u0286\u0287\u0005s\u0000\u0000"+ + "\u0287\u0288\u0005u\u0000\u0000\u0288\u0289\u0005p\u0000\u0000\u0289\u028a"+ + "\u0005e\u0000\u0000\u028a\u028b\u0005r\u0000\u0000\u028b\u0097\u0001\u0000"+ + "\u0000\u0000\u028c\u028d\u0005d\u0000\u0000\u028d\u028e\u0005e\u0000\u0000"+ + "\u028e\u028f\u0005f\u0000\u0000\u028f\u0290\u0005a\u0000\u0000\u0290\u0291"+ + "\u0005u\u0000\u0000\u0291\u0292\u0005l\u0000\u0000\u0292\u0293\u0005t"+ + "\u0000\u0000\u0293\u0099\u0001\u0000\u0000\u0000\u0294\u0295\u0003F\""+ + "\u0000\u0295\u009b\u0001\u0000\u0000\u0000\u0296\u0298\u0003F\"\u0000"+ + "\u0297\u0299\u0003L%\u0000\u0298\u0297\u0001\u0000\u0000\u0000\u0298\u0299"+ + "\u0001\u0000\u0000\u0000\u0299\u029b\u0001\u0000\u0000\u0000\u029a\u029c"+ + "\u0003P\'\u0000\u029b\u029a\u0001\u0000\u0000\u0000\u029b\u029c\u0001"+ + "\u0000\u0000\u0000\u029c\u009d\u0001\u0000\u0000\u0000\u029d\u029e\u0003"+ + "<\u001d\u0000\u029e\u009f\u0001\u0000\u0000\u0000\u029f\u02a0\u00036\u001a"+ + "\u0000\u02a0\u00a1\u0001\u0000\u0000\u0000\u02a1\u02a2\u0005{\u0000\u0000"+ + "\u02a2\u00a3\u0001\u0000\u0000\u0000\u02a3\u02a4\u0005}\u0000\u0000\u02a4"+ + "\u00a5\u0001\u0000\u0000\u0000\u02a5\u02a6\u0005[\u0000\u0000\u02a6\u00a7"+ + "\u0001\u0000\u0000\u0000\u02a7\u02a8\u0005]\u0000\u0000\u02a8\u00a9\u0001"+ + "\u0000\u0000\u0000\u02a9\u02aa\u0005(\u0000\u0000\u02aa\u00ab\u0001\u0000"+ + "\u0000\u0000\u02ab\u02ac\u0005)\u0000\u0000\u02ac\u00ad\u0001\u0000\u0000"+ + "\u0000\u02ad\u02ae\u0005;\u0000\u0000\u02ae\u00af\u0001\u0000\u0000\u0000"+ + "\u02af\u02b0\u0005,\u0000\u0000\u02b0\u00b1\u0001\u0000\u0000\u0000\u02b1"+ + "\u02b2\u0005.\u0000\u0000\u02b2\u00b3\u0001\u0000\u0000\u0000\u02b3\u02b4"+ + "\u0005:\u0000\u0000\u02b4\u00b5\u0001\u0000\u0000\u0000\u02b5\u02b6\u0005"+ + ".\u0000\u0000\u02b6\u02b7\u0005.\u0000\u0000\u02b7\u00b7\u0001\u0000\u0000"+ + "\u0000\u02b8\u02b9\u0005.\u0000\u0000\u02b9\u02ba\u0005.\u0000\u0000\u02ba"+ + "\u02bb\u0005.\u0000\u0000\u02bb\u00b9\u0001\u0000\u0000\u0000\u02bc\u02bd"+ + "\u0005=\u0000\u0000\u02bd\u00bb\u0001\u0000\u0000\u0000\u02be\u02bf\u0005"+ + "+\u0000\u0000\u02bf\u02c0\u0005+\u0000\u0000\u02c0\u00bd\u0001\u0000\u0000"+ + "\u0000\u02c1\u02c2\u0005-\u0000\u0000\u02c2\u02c3\u0005-\u0000\u0000\u02c3"+ + "\u00bf\u0001\u0000\u0000\u0000\u02c4\u02c5\u0005+\u0000\u0000\u02c5\u00c1"+ + "\u0001\u0000\u0000\u0000\u02c6\u02c7\u0005-\u0000\u0000\u02c7\u00c3\u0001"+ + "\u0000\u0000\u0000\u02c8\u02c9\u0005*\u0000\u0000\u02c9\u00c5\u0001\u0000"+ + "\u0000\u0000\u02ca\u02cb\u0005/\u0000\u0000\u02cb\u00c7\u0001\u0000\u0000"+ + "\u0000\u02cc\u02cd\u0005>\u0000\u0000\u02cd\u00c9\u0001\u0000\u0000\u0000"+ + "\u02ce\u02cf\u0005<\u0000\u0000\u02cf\u00cb\u0001\u0000\u0000\u0000\u02d0"+ + "\u02d1\u0005<\u0000\u0000\u02d1\u02d2\u0005=\u0000\u0000\u02d2\u00cd\u0001"+ + "\u0000\u0000\u0000\u02d3\u02d4\u0005>\u0000\u0000\u02d4\u02d5\u0005=\u0000"+ + "\u0000\u02d5\u00cf\u0001\u0000\u0000\u0000\u02d6\u02d7\u0005=\u0000\u0000"+ + "\u02d7\u02d8\u0005=\u0000\u0000\u02d8\u00d1\u0001\u0000\u0000\u0000\u02d9"+ + "\u02da\u0005!\u0000\u0000\u02da\u02db\u0005=\u0000\u0000\u02db\u00d3\u0001"+ + "\u0000\u0000\u0000\u02dc\u02dd\u0005!\u0000\u0000\u02dd\u00d5\u0001\u0000"+ + "\u0000\u0000\u02de\u02df\u0005&\u0000\u0000\u02df\u02e0\u0005&\u0000\u0000"+ + "\u02e0\u00d7\u0001\u0000\u0000\u0000\u02e1\u02e2\u0005|\u0000\u0000\u02e2"+ + "\u02e3\u0005|\u0000\u0000\u02e3\u00d9\u0001\u0000\u0000\u0000\u02e4\u02e5"+ + "\u0005%\u0000\u0000\u02e5\u02e6\u0005d\u0000\u0000\u02e6\u02e7\u0005e"+ + "\u0000\u0000\u02e7\u02e8\u0005f\u0000\u0000\u02e8\u02e9\u0005i\u0000\u0000"+ + "\u02e9\u02ea\u0005n\u0000\u0000\u02ea\u02eb\u0005e\u0000\u0000\u02eb\u02ec"+ + "\u0001\u0000\u0000\u0000\u02ec\u02ed\u0006l\u0002\u0000\u02ed\u02ee\u0006"+ + "l\u0003\u0000\u02ee\u00db\u0001\u0000\u0000\u0000\u02ef\u02f0\u0005%\u0000"+ + "\u0000\u02f0\u02f1\u0005s\u0000\u0000\u02f1\u02f2\u0005c\u0000\u0000\u02f2"+ + "\u02f3\u0005h\u0000\u0000\u02f3\u02f4\u0005e\u0000\u0000\u02f4\u02f5\u0005"+ + "m\u0000\u0000\u02f5\u02f6\u0005a\u0000\u0000\u02f6\u02f7\u0001\u0000\u0000"+ + "\u0000\u02f7\u02f8\u0006m\u0004\u0000\u02f8\u02f9\u0006m\u0003\u0000\u02f9"+ + "\u00dd\u0001\u0000\u0000\u0000\u02fa\u02fb\u0005%\u0000\u0000\u02fb\u02fc"+ + "\u0005s\u0000\u0000\u02fc\u02fd\u0005c\u0000\u0000\u02fd\u02fe\u0005r"+ + "\u0000\u0000\u02fe\u02ff\u0005i\u0000\u0000\u02ff\u0300\u0005p\u0000\u0000"+ + "\u0300\u0301\u0005t\u0000\u0000\u0301\u0302\u0001\u0000\u0000\u0000\u0302"+ + "\u0303\u0006n\u0005\u0000\u0303\u0304\u0006n\u0003\u0000\u0304\u00df\u0001"+ + "\u0000\u0000\u0000\u0305\u0306\u0003T)\u0000\u0306\u0307\u0001\u0000\u0000"+ + "\u0000\u0307\u0308\u0006o\u0001\u0000\u0308\u00e1\u0001\u0000\u0000\u0000"+ + "\u0309\u030a\u0003V*\u0000\u030a\u030b\u0001\u0000\u0000\u0000\u030b\u030c"+ + "\u0006p\u0001\u0000\u030c\u00e3\u0001\u0000\u0000\u0000\u030d\u030e\u0003"+ + "X+\u0000\u030e\u030f\u0001\u0000\u0000\u0000\u030f\u0310\u0006q\u0001"+ + "\u0000\u0310\u00e5\u0001\u0000\u0000\u0000\u0014\u0000\u0001\u014b\u0155"+ + "\u0161\u016b\u016d\u0175\u0182\u018b\u0193\u019a\u019d\u01a1\u01a6\u01ad"+ + "\u01b7\u01c5\u0298\u029b\u0006\u0005\u0001\u0000\u0000\u0001\u0000\u0007"+ + "\u0005\u0000\u0004\u0000\u0000\u0007\u0006\u0000\u0007\u0007\u0000"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.tokens b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.tokens new file mode 100644 index 0000000..4de9797 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.tokens @@ -0,0 +1,152 @@ +TITLE=1 +VERSION=2 +IMPORT=3 +PRAGMA=4 +DEFINE=5 +SCHEMA=6 +SCRIPT=7 +TRUE=8 +FALSE=9 +NULL=10 +COLON=11 +COMMA=12 +STAR=13 +LBRACE=14 +RBRACE=15 +LBRACKET=16 +RBRACKET=17 +LPAREN=18 +RPAREN=19 +OPTIONAL=20 +UNDEFINED=21 +FULL_IDENTIFIER=22 +ALIAS=23 +DATATYPE=24 +FUNCTION=25 +RECEIVER=26 +STRING=27 +INTEGER=28 +FLOAT=29 +DOUBLE=30 +WHITE_SPACE=31 +BLOCK_COMMENT=32 +LINE_COMMENT=33 +G_VAR=34 +G_IF=35 +G_ELSE=36 +G_WHILE=37 +G_FOR=38 +G_FOREACH=39 +G_IN=40 +G_BREAK=41 +G_CONSTRAINT=42 +G_TARGET=43 +G_CALLER=44 +G_SUBROUTINE=45 +G_TRYOF=46 +G_THROW=47 +G_FUNCTION=48 +G_RETURN=49 +G_FUTURE=50 +G_TRUE=51 +G_FALSE=52 +G_NULL=53 +G_UNDEFINED=54 +G_THIS=55 +G_NEW=56 +G_CONTINUE=57 +G_DO=58 +G_CONST=59 +G_SWITCH=60 +G_CASE=61 +G_IMPORT=62 +G_CLASS=63 +G_SUPER=64 +G_DEFAULT=65 +G_INTEGER=66 +G_DOUBLE=67 +G_STRING=68 +G_IDENTIFIER=69 +G_LBRACE=70 +G_RBRACE=71 +G_LBRACKET=72 +G_RBRACKET=73 +G_LPAREN=74 +G_RPAREN=75 +G_SEMI=76 +G_COMMA=77 +G_DOT=78 +G_COLON=79 +G_RANGE=80 +G_ELLIPSIS=81 +G_ASSIGN=82 +G_INC=83 +G_DEC=84 +G_PLUS=85 +G_MINUS=86 +G_MUL=87 +G_DIV=88 +G_GT=89 +G_LT=90 +G_LE=91 +G_GE=92 +G_EQ=93 +G_NE=94 +G_NOT=95 +G_AND=96 +G_OR=97 +WHITE_SPACE1=98 +BLOCK_COMMENT1=99 +LINE_COMMENT1=100 +'%title'=1 +'%version'=2 +'%import'=3 +'%pragma'=4 +'?'=20 +'var'=34 +'if'=35 +'else'=36 +'while'=37 +'for'=38 +'foreach'=39 +'in'=40 +'break'=41 +'constraint'=42 +'target'=43 +'caller'=44 +'subroutine'=45 +'tryof'=46 +'throw'=47 +'function'=48 +'return'=49 +'future'=50 +'undefined'=54 +'this'=55 +'new'=56 +'continue'=57 +'do'=58 +'const'=59 +'switch'=60 +'case'=61 +'import'=62 +'class'=63 +'super'=64 +'default'=65 +';'=76 +'.'=78 +'..'=80 +'...'=81 +'='=82 +'++'=83 +'--'=84 +'+'=85 +'-'=86 +'/'=88 +'>'=89 +'<'=90 +'<='=91 +'>='=92 +'=='=93 +'!='=94 +'&&'=96 +'||'=97 diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.interp b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.interp new file mode 100644 index 0000000..4dca097 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.interp @@ -0,0 +1,248 @@ +token literal names: +null +'%title' +'%version' +'%import' +'%pragma' +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +'?' +null +null +null +null +null +null +null +null +null +null +null +null +null +'var' +'if' +'else' +'while' +'for' +'foreach' +'in' +'break' +'constraint' +'target' +'caller' +'subroutine' +'tryof' +'throw' +'function' +'return' +'future' +null +null +null +'undefined' +'this' +'new' +'continue' +'do' +'const' +'switch' +'case' +'import' +'class' +'super' +'default' +null +null +null +null +null +null +null +null +null +null +';' +null +'.' +null +'..' +'...' +'=' +'++' +'--' +'+' +'-' +null +'/' +'>' +'<' +'<=' +'>=' +'==' +'!=' +null +'&&' +'||' +null +null +null + +token symbolic names: +null +TITLE +VERSION +IMPORT +PRAGMA +DEFINE +SCHEMA +SCRIPT +TRUE +FALSE +NULL +COLON +COMMA +STAR +LBRACE +RBRACE +LBRACKET +RBRACKET +LPAREN +RPAREN +OPTIONAL +UNDEFINED +FULL_IDENTIFIER +ALIAS +DATATYPE +FUNCTION +RECEIVER +STRING +INTEGER +FLOAT +DOUBLE +WHITE_SPACE +BLOCK_COMMENT +LINE_COMMENT +G_VAR +G_IF +G_ELSE +G_WHILE +G_FOR +G_FOREACH +G_IN +G_BREAK +G_CONSTRAINT +G_TARGET +G_CALLER +G_SUBROUTINE +G_TRYOF +G_THROW +G_FUNCTION +G_RETURN +G_FUTURE +G_TRUE +G_FALSE +G_NULL +G_UNDEFINED +G_THIS +G_NEW +G_CONTINUE +G_DO +G_CONST +G_SWITCH +G_CASE +G_IMPORT +G_CLASS +G_SUPER +G_DEFAULT +G_INTEGER +G_DOUBLE +G_STRING +G_IDENTIFIER +G_LBRACE +G_RBRACE +G_LBRACKET +G_RBRACKET +G_LPAREN +G_RPAREN +G_SEMI +G_COMMA +G_DOT +G_COLON +G_RANGE +G_ELLIPSIS +G_ASSIGN +G_INC +G_DEC +G_PLUS +G_MINUS +G_MUL +G_DIV +G_GT +G_LT +G_LE +G_GE +G_EQ +G_NE +G_NOT +G_AND +G_OR +WHITE_SPACE1 +BLOCK_COMMENT1 +LINE_COMMENT1 + +rule names: +schema +schemaMain +titleNode +versionNode +importNode +pragmaNode +defineNode +aliasNode +validatorMain +validatorNode +valueNode +receiverNode +objectNode +propertyNode +arrayNode +datatypeNode +functionNode +argumentNode +primitiveNode +scriptNode +globalStatement +statement +functionDeclaration +varStatement +varInitialization +expressionStatement +ifStatement +whileStatement +forStatement +expressionList +foreachStatement +returnStatement +breakStatement +blockStatement +expression +refExpression +literal + + +atn: +[4, 1, 100, 567, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 1, 0, 3, 0, 76, 8, 0, 1, 0, 3, 0, 79, 8, 0, 1, 0, 1, 0, 5, 0, 83, 8, 0, 10, 0, 12, 0, 86, 9, 0, 1, 0, 1, 0, 5, 0, 90, 8, 0, 10, 0, 12, 0, 93, 9, 0, 1, 0, 1, 0, 1, 0, 5, 0, 98, 8, 0, 10, 0, 12, 0, 101, 9, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 108, 8, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 127, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 5, 8, 143, 8, 8, 10, 8, 12, 8, 146, 9, 8, 1, 8, 5, 8, 149, 8, 8, 10, 8, 12, 8, 152, 9, 8, 1, 8, 5, 8, 155, 8, 8, 10, 8, 12, 8, 158, 9, 8, 1, 8, 3, 8, 161, 8, 8, 1, 8, 4, 8, 164, 8, 8, 11, 8, 12, 8, 165, 1, 8, 5, 8, 169, 8, 8, 10, 8, 12, 8, 172, 9, 8, 1, 8, 5, 8, 175, 8, 8, 10, 8, 12, 8, 178, 9, 8, 1, 8, 3, 8, 181, 8, 8, 1, 8, 4, 8, 184, 8, 8, 11, 8, 12, 8, 185, 1, 8, 5, 8, 189, 8, 8, 10, 8, 12, 8, 192, 9, 8, 1, 8, 3, 8, 195, 8, 8, 3, 8, 197, 8, 8, 1, 9, 1, 9, 3, 9, 201, 8, 9, 1, 10, 1, 10, 1, 10, 3, 10, 206, 8, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 5, 12, 214, 8, 12, 10, 12, 12, 12, 217, 9, 12, 3, 12, 219, 8, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 5, 14, 231, 8, 14, 10, 14, 12, 14, 234, 9, 14, 3, 14, 236, 8, 14, 1, 14, 1, 14, 1, 15, 1, 15, 3, 15, 242, 8, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 248, 8, 15, 1, 16, 1, 16, 3, 16, 252, 8, 16, 1, 16, 1, 16, 1, 16, 1, 16, 5, 16, 258, 8, 16, 10, 16, 12, 16, 261, 9, 16, 3, 16, 263, 8, 16, 1, 16, 3, 16, 266, 8, 16, 1, 17, 1, 17, 3, 17, 270, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 280, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 4, 19, 286, 8, 19, 11, 19, 12, 19, 287, 1, 19, 1, 19, 1, 20, 1, 20, 3, 20, 294, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 305, 8, 21, 1, 22, 1, 22, 3, 22, 309, 8, 22, 1, 22, 1, 22, 3, 22, 313, 8, 22, 1, 22, 3, 22, 316, 8, 22, 1, 22, 1, 22, 3, 22, 320, 8, 22, 3, 22, 322, 8, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 5, 22, 329, 8, 22, 10, 22, 12, 22, 332, 9, 22, 1, 22, 3, 22, 335, 8, 22, 3, 22, 337, 8, 22, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 5, 23, 346, 8, 23, 10, 23, 12, 23, 349, 9, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 3, 24, 356, 8, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 3, 26, 368, 8, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 3, 28, 382, 8, 28, 1, 28, 3, 28, 385, 8, 28, 1, 28, 1, 28, 3, 28, 389, 8, 28, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 5, 29, 397, 8, 29, 10, 29, 12, 29, 400, 9, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 5, 33, 420, 8, 33, 10, 33, 12, 33, 423, 9, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 3, 34, 464, 8, 34, 1, 34, 1, 34, 3, 34, 468, 8, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 3, 34, 491, 8, 34, 5, 34, 493, 8, 34, 10, 34, 12, 34, 496, 9, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 504, 8, 35, 10, 35, 12, 35, 507, 9, 35, 3, 35, 509, 8, 35, 1, 35, 1, 35, 1, 35, 1, 35, 3, 35, 515, 8, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 525, 8, 35, 10, 35, 12, 35, 528, 9, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 539, 8, 36, 10, 36, 12, 36, 542, 9, 36, 3, 36, 544, 8, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 555, 8, 36, 10, 36, 12, 36, 558, 9, 36, 3, 36, 560, 8, 36, 1, 36, 1, 36, 1, 36, 3, 36, 565, 8, 36, 1, 36, 0, 2, 68, 70, 37, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 0, 5, 1, 0, 87, 88, 1, 0, 85, 86, 1, 0, 89, 92, 1, 0, 93, 94, 1, 0, 68, 69, 641, 0, 107, 1, 0, 0, 0, 2, 109, 1, 0, 0, 0, 4, 113, 1, 0, 0, 0, 6, 117, 1, 0, 0, 0, 8, 121, 1, 0, 0, 0, 10, 128, 1, 0, 0, 0, 12, 133, 1, 0, 0, 0, 14, 138, 1, 0, 0, 0, 16, 196, 1, 0, 0, 0, 18, 200, 1, 0, 0, 0, 20, 205, 1, 0, 0, 0, 22, 207, 1, 0, 0, 0, 24, 209, 1, 0, 0, 0, 26, 222, 1, 0, 0, 0, 28, 226, 1, 0, 0, 0, 30, 239, 1, 0, 0, 0, 32, 249, 1, 0, 0, 0, 34, 269, 1, 0, 0, 0, 36, 279, 1, 0, 0, 0, 38, 281, 1, 0, 0, 0, 40, 293, 1, 0, 0, 0, 42, 304, 1, 0, 0, 0, 44, 321, 1, 0, 0, 0, 46, 341, 1, 0, 0, 0, 48, 352, 1, 0, 0, 0, 50, 357, 1, 0, 0, 0, 52, 360, 1, 0, 0, 0, 54, 369, 1, 0, 0, 0, 56, 375, 1, 0, 0, 0, 58, 393, 1, 0, 0, 0, 60, 401, 1, 0, 0, 0, 62, 410, 1, 0, 0, 0, 64, 414, 1, 0, 0, 0, 66, 417, 1, 0, 0, 0, 68, 467, 1, 0, 0, 0, 70, 514, 1, 0, 0, 0, 72, 564, 1, 0, 0, 0, 74, 76, 3, 4, 2, 0, 75, 74, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 78, 1, 0, 0, 0, 77, 79, 3, 6, 3, 0, 78, 77, 1, 0, 0, 0, 78, 79, 1, 0, 0, 0, 79, 84, 1, 0, 0, 0, 80, 83, 3, 8, 4, 0, 81, 83, 3, 10, 5, 0, 82, 80, 1, 0, 0, 0, 82, 81, 1, 0, 0, 0, 83, 86, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 85, 1, 0, 0, 0, 85, 91, 1, 0, 0, 0, 86, 84, 1, 0, 0, 0, 87, 90, 3, 12, 6, 0, 88, 90, 3, 38, 19, 0, 89, 87, 1, 0, 0, 0, 89, 88, 1, 0, 0, 0, 90, 93, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 94, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 94, 99, 3, 2, 1, 0, 95, 98, 3, 12, 6, 0, 96, 98, 3, 38, 19, 0, 97, 95, 1, 0, 0, 0, 97, 96, 1, 0, 0, 0, 98, 101, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 99, 100, 1, 0, 0, 0, 100, 102, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 102, 103, 5, 0, 0, 1, 103, 108, 1, 0, 0, 0, 104, 105, 3, 18, 9, 0, 105, 106, 5, 0, 0, 1, 106, 108, 1, 0, 0, 0, 107, 75, 1, 0, 0, 0, 107, 104, 1, 0, 0, 0, 108, 1, 1, 0, 0, 0, 109, 110, 5, 6, 0, 0, 110, 111, 5, 11, 0, 0, 111, 112, 3, 18, 9, 0, 112, 3, 1, 0, 0, 0, 113, 114, 5, 1, 0, 0, 114, 115, 5, 11, 0, 0, 115, 116, 5, 27, 0, 0, 116, 5, 1, 0, 0, 0, 117, 118, 5, 2, 0, 0, 118, 119, 5, 11, 0, 0, 119, 120, 5, 27, 0, 0, 120, 7, 1, 0, 0, 0, 121, 122, 5, 3, 0, 0, 122, 123, 5, 11, 0, 0, 123, 126, 5, 22, 0, 0, 124, 125, 5, 12, 0, 0, 125, 127, 5, 22, 0, 0, 126, 124, 1, 0, 0, 0, 126, 127, 1, 0, 0, 0, 127, 9, 1, 0, 0, 0, 128, 129, 5, 4, 0, 0, 129, 130, 5, 22, 0, 0, 130, 131, 5, 11, 0, 0, 131, 132, 3, 36, 18, 0, 132, 11, 1, 0, 0, 0, 133, 134, 5, 5, 0, 0, 134, 135, 3, 14, 7, 0, 135, 136, 5, 11, 0, 0, 136, 137, 3, 16, 8, 0, 137, 13, 1, 0, 0, 0, 138, 139, 5, 23, 0, 0, 139, 15, 1, 0, 0, 0, 140, 144, 3, 20, 10, 0, 141, 143, 3, 32, 16, 0, 142, 141, 1, 0, 0, 0, 143, 146, 1, 0, 0, 0, 144, 142, 1, 0, 0, 0, 144, 145, 1, 0, 0, 0, 145, 150, 1, 0, 0, 0, 146, 144, 1, 0, 0, 0, 147, 149, 3, 30, 15, 0, 148, 147, 1, 0, 0, 0, 149, 152, 1, 0, 0, 0, 150, 148, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 156, 1, 0, 0, 0, 152, 150, 1, 0, 0, 0, 153, 155, 3, 22, 11, 0, 154, 153, 1, 0, 0, 0, 155, 158, 1, 0, 0, 0, 156, 154, 1, 0, 0, 0, 156, 157, 1, 0, 0, 0, 157, 160, 1, 0, 0, 0, 158, 156, 1, 0, 0, 0, 159, 161, 5, 20, 0, 0, 160, 159, 1, 0, 0, 0, 160, 161, 1, 0, 0, 0, 161, 197, 1, 0, 0, 0, 162, 164, 3, 32, 16, 0, 163, 162, 1, 0, 0, 0, 164, 165, 1, 0, 0, 0, 165, 163, 1, 0, 0, 0, 165, 166, 1, 0, 0, 0, 166, 170, 1, 0, 0, 0, 167, 169, 3, 30, 15, 0, 168, 167, 1, 0, 0, 0, 169, 172, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 170, 171, 1, 0, 0, 0, 171, 176, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 173, 175, 3, 22, 11, 0, 174, 173, 1, 0, 0, 0, 175, 178, 1, 0, 0, 0, 176, 174, 1, 0, 0, 0, 176, 177, 1, 0, 0, 0, 177, 180, 1, 0, 0, 0, 178, 176, 1, 0, 0, 0, 179, 181, 5, 20, 0, 0, 180, 179, 1, 0, 0, 0, 180, 181, 1, 0, 0, 0, 181, 197, 1, 0, 0, 0, 182, 184, 3, 30, 15, 0, 183, 182, 1, 0, 0, 0, 184, 185, 1, 0, 0, 0, 185, 183, 1, 0, 0, 0, 185, 186, 1, 0, 0, 0, 186, 190, 1, 0, 0, 0, 187, 189, 3, 22, 11, 0, 188, 187, 1, 0, 0, 0, 189, 192, 1, 0, 0, 0, 190, 188, 1, 0, 0, 0, 190, 191, 1, 0, 0, 0, 191, 194, 1, 0, 0, 0, 192, 190, 1, 0, 0, 0, 193, 195, 5, 20, 0, 0, 194, 193, 1, 0, 0, 0, 194, 195, 1, 0, 0, 0, 195, 197, 1, 0, 0, 0, 196, 140, 1, 0, 0, 0, 196, 163, 1, 0, 0, 0, 196, 183, 1, 0, 0, 0, 197, 17, 1, 0, 0, 0, 198, 201, 3, 16, 8, 0, 199, 201, 3, 14, 7, 0, 200, 198, 1, 0, 0, 0, 200, 199, 1, 0, 0, 0, 201, 19, 1, 0, 0, 0, 202, 206, 3, 36, 18, 0, 203, 206, 3, 24, 12, 0, 204, 206, 3, 28, 14, 0, 205, 202, 1, 0, 0, 0, 205, 203, 1, 0, 0, 0, 205, 204, 1, 0, 0, 0, 206, 21, 1, 0, 0, 0, 207, 208, 5, 26, 0, 0, 208, 23, 1, 0, 0, 0, 209, 218, 5, 14, 0, 0, 210, 215, 3, 26, 13, 0, 211, 212, 5, 12, 0, 0, 212, 214, 3, 26, 13, 0, 213, 211, 1, 0, 0, 0, 214, 217, 1, 0, 0, 0, 215, 213, 1, 0, 0, 0, 215, 216, 1, 0, 0, 0, 216, 219, 1, 0, 0, 0, 217, 215, 1, 0, 0, 0, 218, 210, 1, 0, 0, 0, 218, 219, 1, 0, 0, 0, 219, 220, 1, 0, 0, 0, 220, 221, 5, 15, 0, 0, 221, 25, 1, 0, 0, 0, 222, 223, 5, 27, 0, 0, 223, 224, 5, 11, 0, 0, 224, 225, 3, 18, 9, 0, 225, 27, 1, 0, 0, 0, 226, 235, 5, 16, 0, 0, 227, 232, 3, 18, 9, 0, 228, 229, 5, 12, 0, 0, 229, 231, 3, 18, 9, 0, 230, 228, 1, 0, 0, 0, 231, 234, 1, 0, 0, 0, 232, 230, 1, 0, 0, 0, 232, 233, 1, 0, 0, 0, 233, 236, 1, 0, 0, 0, 234, 232, 1, 0, 0, 0, 235, 227, 1, 0, 0, 0, 235, 236, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 238, 5, 17, 0, 0, 238, 29, 1, 0, 0, 0, 239, 241, 5, 24, 0, 0, 240, 242, 5, 13, 0, 0, 241, 240, 1, 0, 0, 0, 241, 242, 1, 0, 0, 0, 242, 247, 1, 0, 0, 0, 243, 244, 5, 18, 0, 0, 244, 245, 3, 14, 7, 0, 245, 246, 5, 19, 0, 0, 246, 248, 1, 0, 0, 0, 247, 243, 1, 0, 0, 0, 247, 248, 1, 0, 0, 0, 248, 31, 1, 0, 0, 0, 249, 251, 5, 25, 0, 0, 250, 252, 5, 13, 0, 0, 251, 250, 1, 0, 0, 0, 251, 252, 1, 0, 0, 0, 252, 265, 1, 0, 0, 0, 253, 262, 5, 18, 0, 0, 254, 259, 3, 34, 17, 0, 255, 256, 5, 12, 0, 0, 256, 258, 3, 34, 17, 0, 257, 255, 1, 0, 0, 0, 258, 261, 1, 0, 0, 0, 259, 257, 1, 0, 0, 0, 259, 260, 1, 0, 0, 0, 260, 263, 1, 0, 0, 0, 261, 259, 1, 0, 0, 0, 262, 254, 1, 0, 0, 0, 262, 263, 1, 0, 0, 0, 263, 264, 1, 0, 0, 0, 264, 266, 5, 19, 0, 0, 265, 253, 1, 0, 0, 0, 265, 266, 1, 0, 0, 0, 266, 33, 1, 0, 0, 0, 267, 270, 3, 20, 10, 0, 268, 270, 3, 22, 11, 0, 269, 267, 1, 0, 0, 0, 269, 268, 1, 0, 0, 0, 270, 35, 1, 0, 0, 0, 271, 280, 5, 8, 0, 0, 272, 280, 5, 9, 0, 0, 273, 280, 5, 27, 0, 0, 274, 280, 5, 28, 0, 0, 275, 280, 5, 29, 0, 0, 276, 280, 5, 30, 0, 0, 277, 280, 5, 10, 0, 0, 278, 280, 5, 21, 0, 0, 279, 271, 1, 0, 0, 0, 279, 272, 1, 0, 0, 0, 279, 273, 1, 0, 0, 0, 279, 274, 1, 0, 0, 0, 279, 275, 1, 0, 0, 0, 279, 276, 1, 0, 0, 0, 279, 277, 1, 0, 0, 0, 279, 278, 1, 0, 0, 0, 280, 37, 1, 0, 0, 0, 281, 282, 5, 7, 0, 0, 282, 283, 5, 79, 0, 0, 283, 285, 5, 70, 0, 0, 284, 286, 3, 40, 20, 0, 285, 284, 1, 0, 0, 0, 286, 287, 1, 0, 0, 0, 287, 285, 1, 0, 0, 0, 287, 288, 1, 0, 0, 0, 288, 289, 1, 0, 0, 0, 289, 290, 5, 71, 0, 0, 290, 39, 1, 0, 0, 0, 291, 294, 3, 44, 22, 0, 292, 294, 3, 46, 23, 0, 293, 291, 1, 0, 0, 0, 293, 292, 1, 0, 0, 0, 294, 41, 1, 0, 0, 0, 295, 305, 3, 46, 23, 0, 296, 305, 3, 50, 25, 0, 297, 305, 3, 52, 26, 0, 298, 305, 3, 54, 27, 0, 299, 305, 3, 56, 28, 0, 300, 305, 3, 60, 30, 0, 301, 305, 3, 62, 31, 0, 302, 305, 3, 64, 32, 0, 303, 305, 3, 66, 33, 0, 304, 295, 1, 0, 0, 0, 304, 296, 1, 0, 0, 0, 304, 297, 1, 0, 0, 0, 304, 298, 1, 0, 0, 0, 304, 299, 1, 0, 0, 0, 304, 300, 1, 0, 0, 0, 304, 301, 1, 0, 0, 0, 304, 302, 1, 0, 0, 0, 304, 303, 1, 0, 0, 0, 305, 43, 1, 0, 0, 0, 306, 308, 5, 42, 0, 0, 307, 309, 5, 48, 0, 0, 308, 307, 1, 0, 0, 0, 308, 309, 1, 0, 0, 0, 309, 322, 1, 0, 0, 0, 310, 312, 5, 50, 0, 0, 311, 313, 5, 42, 0, 0, 312, 311, 1, 0, 0, 0, 312, 313, 1, 0, 0, 0, 313, 315, 1, 0, 0, 0, 314, 316, 5, 48, 0, 0, 315, 314, 1, 0, 0, 0, 315, 316, 1, 0, 0, 0, 316, 322, 1, 0, 0, 0, 317, 319, 5, 45, 0, 0, 318, 320, 5, 48, 0, 0, 319, 318, 1, 0, 0, 0, 319, 320, 1, 0, 0, 0, 320, 322, 1, 0, 0, 0, 321, 306, 1, 0, 0, 0, 321, 310, 1, 0, 0, 0, 321, 317, 1, 0, 0, 0, 322, 323, 1, 0, 0, 0, 323, 324, 5, 69, 0, 0, 324, 336, 5, 74, 0, 0, 325, 330, 5, 69, 0, 0, 326, 327, 5, 77, 0, 0, 327, 329, 5, 69, 0, 0, 328, 326, 1, 0, 0, 0, 329, 332, 1, 0, 0, 0, 330, 328, 1, 0, 0, 0, 330, 331, 1, 0, 0, 0, 331, 334, 1, 0, 0, 0, 332, 330, 1, 0, 0, 0, 333, 335, 5, 81, 0, 0, 334, 333, 1, 0, 0, 0, 334, 335, 1, 0, 0, 0, 335, 337, 1, 0, 0, 0, 336, 325, 1, 0, 0, 0, 336, 337, 1, 0, 0, 0, 337, 338, 1, 0, 0, 0, 338, 339, 5, 75, 0, 0, 339, 340, 3, 66, 33, 0, 340, 45, 1, 0, 0, 0, 341, 342, 5, 34, 0, 0, 342, 347, 3, 48, 24, 0, 343, 344, 5, 77, 0, 0, 344, 346, 3, 48, 24, 0, 345, 343, 1, 0, 0, 0, 346, 349, 1, 0, 0, 0, 347, 345, 1, 0, 0, 0, 347, 348, 1, 0, 0, 0, 348, 350, 1, 0, 0, 0, 349, 347, 1, 0, 0, 0, 350, 351, 5, 76, 0, 0, 351, 47, 1, 0, 0, 0, 352, 355, 5, 69, 0, 0, 353, 354, 5, 82, 0, 0, 354, 356, 3, 68, 34, 0, 355, 353, 1, 0, 0, 0, 355, 356, 1, 0, 0, 0, 356, 49, 1, 0, 0, 0, 357, 358, 3, 68, 34, 0, 358, 359, 5, 76, 0, 0, 359, 51, 1, 0, 0, 0, 360, 361, 5, 35, 0, 0, 361, 362, 5, 74, 0, 0, 362, 363, 3, 68, 34, 0, 363, 364, 5, 75, 0, 0, 364, 367, 3, 42, 21, 0, 365, 366, 5, 36, 0, 0, 366, 368, 3, 42, 21, 0, 367, 365, 1, 0, 0, 0, 367, 368, 1, 0, 0, 0, 368, 53, 1, 0, 0, 0, 369, 370, 5, 37, 0, 0, 370, 371, 5, 74, 0, 0, 371, 372, 3, 68, 34, 0, 372, 373, 5, 75, 0, 0, 373, 374, 3, 42, 21, 0, 374, 55, 1, 0, 0, 0, 375, 376, 5, 38, 0, 0, 376, 381, 5, 74, 0, 0, 377, 382, 3, 46, 23, 0, 378, 379, 3, 58, 29, 0, 379, 380, 5, 76, 0, 0, 380, 382, 1, 0, 0, 0, 381, 377, 1, 0, 0, 0, 381, 378, 1, 0, 0, 0, 381, 382, 1, 0, 0, 0, 382, 384, 1, 0, 0, 0, 383, 385, 3, 68, 34, 0, 384, 383, 1, 0, 0, 0, 384, 385, 1, 0, 0, 0, 385, 386, 1, 0, 0, 0, 386, 388, 5, 76, 0, 0, 387, 389, 3, 58, 29, 0, 388, 387, 1, 0, 0, 0, 388, 389, 1, 0, 0, 0, 389, 390, 1, 0, 0, 0, 390, 391, 5, 75, 0, 0, 391, 392, 3, 42, 21, 0, 392, 57, 1, 0, 0, 0, 393, 398, 3, 68, 34, 0, 394, 395, 5, 77, 0, 0, 395, 397, 3, 68, 34, 0, 396, 394, 1, 0, 0, 0, 397, 400, 1, 0, 0, 0, 398, 396, 1, 0, 0, 0, 398, 399, 1, 0, 0, 0, 399, 59, 1, 0, 0, 0, 400, 398, 1, 0, 0, 0, 401, 402, 5, 39, 0, 0, 402, 403, 5, 74, 0, 0, 403, 404, 5, 34, 0, 0, 404, 405, 5, 69, 0, 0, 405, 406, 5, 40, 0, 0, 406, 407, 3, 68, 34, 0, 407, 408, 5, 75, 0, 0, 408, 409, 3, 42, 21, 0, 409, 61, 1, 0, 0, 0, 410, 411, 5, 49, 0, 0, 411, 412, 3, 68, 34, 0, 412, 413, 5, 76, 0, 0, 413, 63, 1, 0, 0, 0, 414, 415, 5, 41, 0, 0, 415, 416, 5, 76, 0, 0, 416, 65, 1, 0, 0, 0, 417, 421, 5, 70, 0, 0, 418, 420, 3, 42, 21, 0, 419, 418, 1, 0, 0, 0, 420, 423, 1, 0, 0, 0, 421, 419, 1, 0, 0, 0, 421, 422, 1, 0, 0, 0, 422, 424, 1, 0, 0, 0, 423, 421, 1, 0, 0, 0, 424, 425, 5, 71, 0, 0, 425, 67, 1, 0, 0, 0, 426, 427, 6, 34, -1, 0, 427, 468, 3, 70, 35, 0, 428, 429, 5, 86, 0, 0, 429, 468, 3, 68, 34, 19, 430, 431, 5, 95, 0, 0, 431, 468, 3, 68, 34, 18, 432, 433, 3, 70, 35, 0, 433, 434, 5, 83, 0, 0, 434, 468, 1, 0, 0, 0, 435, 436, 3, 70, 35, 0, 436, 437, 5, 84, 0, 0, 437, 468, 1, 0, 0, 0, 438, 439, 5, 83, 0, 0, 439, 468, 3, 70, 35, 0, 440, 441, 5, 84, 0, 0, 441, 468, 3, 70, 35, 0, 442, 443, 5, 80, 0, 0, 443, 468, 3, 68, 34, 10, 444, 445, 3, 70, 35, 0, 445, 446, 5, 82, 0, 0, 446, 447, 3, 68, 34, 5, 447, 468, 1, 0, 0, 0, 448, 468, 3, 72, 36, 0, 449, 450, 5, 74, 0, 0, 450, 451, 3, 68, 34, 0, 451, 452, 5, 75, 0, 0, 452, 468, 1, 0, 0, 0, 453, 454, 5, 46, 0, 0, 454, 455, 5, 74, 0, 0, 455, 456, 3, 68, 34, 0, 456, 457, 5, 75, 0, 0, 457, 468, 1, 0, 0, 0, 458, 459, 5, 47, 0, 0, 459, 460, 5, 74, 0, 0, 460, 463, 3, 68, 34, 0, 461, 462, 5, 77, 0, 0, 462, 464, 3, 68, 34, 0, 463, 461, 1, 0, 0, 0, 463, 464, 1, 0, 0, 0, 464, 465, 1, 0, 0, 0, 465, 466, 5, 75, 0, 0, 466, 468, 1, 0, 0, 0, 467, 426, 1, 0, 0, 0, 467, 428, 1, 0, 0, 0, 467, 430, 1, 0, 0, 0, 467, 432, 1, 0, 0, 0, 467, 435, 1, 0, 0, 0, 467, 438, 1, 0, 0, 0, 467, 440, 1, 0, 0, 0, 467, 442, 1, 0, 0, 0, 467, 444, 1, 0, 0, 0, 467, 448, 1, 0, 0, 0, 467, 449, 1, 0, 0, 0, 467, 453, 1, 0, 0, 0, 467, 458, 1, 0, 0, 0, 468, 494, 1, 0, 0, 0, 469, 470, 10, 13, 0, 0, 470, 471, 7, 0, 0, 0, 471, 493, 3, 68, 34, 14, 472, 473, 10, 12, 0, 0, 473, 474, 7, 1, 0, 0, 474, 493, 3, 68, 34, 13, 475, 476, 10, 9, 0, 0, 476, 477, 7, 2, 0, 0, 477, 493, 3, 68, 34, 10, 478, 479, 10, 8, 0, 0, 479, 480, 7, 3, 0, 0, 480, 493, 3, 68, 34, 9, 481, 482, 10, 7, 0, 0, 482, 483, 5, 96, 0, 0, 483, 493, 3, 68, 34, 8, 484, 485, 10, 6, 0, 0, 485, 486, 5, 97, 0, 0, 486, 493, 3, 68, 34, 7, 487, 488, 10, 11, 0, 0, 488, 490, 5, 80, 0, 0, 489, 491, 3, 68, 34, 0, 490, 489, 1, 0, 0, 0, 490, 491, 1, 0, 0, 0, 491, 493, 1, 0, 0, 0, 492, 469, 1, 0, 0, 0, 492, 472, 1, 0, 0, 0, 492, 475, 1, 0, 0, 0, 492, 478, 1, 0, 0, 0, 492, 481, 1, 0, 0, 0, 492, 484, 1, 0, 0, 0, 492, 487, 1, 0, 0, 0, 493, 496, 1, 0, 0, 0, 494, 492, 1, 0, 0, 0, 494, 495, 1, 0, 0, 0, 495, 69, 1, 0, 0, 0, 496, 494, 1, 0, 0, 0, 497, 498, 6, 35, -1, 0, 498, 499, 5, 69, 0, 0, 499, 508, 5, 74, 0, 0, 500, 505, 3, 68, 34, 0, 501, 502, 5, 77, 0, 0, 502, 504, 3, 68, 34, 0, 503, 501, 1, 0, 0, 0, 504, 507, 1, 0, 0, 0, 505, 503, 1, 0, 0, 0, 505, 506, 1, 0, 0, 0, 506, 509, 1, 0, 0, 0, 507, 505, 1, 0, 0, 0, 508, 500, 1, 0, 0, 0, 508, 509, 1, 0, 0, 0, 509, 510, 1, 0, 0, 0, 510, 515, 5, 75, 0, 0, 511, 515, 5, 43, 0, 0, 512, 515, 5, 44, 0, 0, 513, 515, 5, 69, 0, 0, 514, 497, 1, 0, 0, 0, 514, 511, 1, 0, 0, 0, 514, 512, 1, 0, 0, 0, 514, 513, 1, 0, 0, 0, 515, 526, 1, 0, 0, 0, 516, 517, 10, 6, 0, 0, 517, 518, 5, 78, 0, 0, 518, 525, 5, 69, 0, 0, 519, 520, 10, 5, 0, 0, 520, 521, 5, 72, 0, 0, 521, 522, 3, 68, 34, 0, 522, 523, 5, 73, 0, 0, 523, 525, 1, 0, 0, 0, 524, 516, 1, 0, 0, 0, 524, 519, 1, 0, 0, 0, 525, 528, 1, 0, 0, 0, 526, 524, 1, 0, 0, 0, 526, 527, 1, 0, 0, 0, 527, 71, 1, 0, 0, 0, 528, 526, 1, 0, 0, 0, 529, 565, 5, 51, 0, 0, 530, 565, 5, 52, 0, 0, 531, 565, 5, 66, 0, 0, 532, 565, 5, 67, 0, 0, 533, 565, 5, 68, 0, 0, 534, 543, 5, 72, 0, 0, 535, 540, 3, 68, 34, 0, 536, 537, 5, 77, 0, 0, 537, 539, 3, 68, 34, 0, 538, 536, 1, 0, 0, 0, 539, 542, 1, 0, 0, 0, 540, 538, 1, 0, 0, 0, 540, 541, 1, 0, 0, 0, 541, 544, 1, 0, 0, 0, 542, 540, 1, 0, 0, 0, 543, 535, 1, 0, 0, 0, 543, 544, 1, 0, 0, 0, 544, 545, 1, 0, 0, 0, 545, 565, 5, 73, 0, 0, 546, 559, 5, 70, 0, 0, 547, 548, 7, 4, 0, 0, 548, 549, 5, 79, 0, 0, 549, 556, 3, 68, 34, 0, 550, 551, 5, 77, 0, 0, 551, 552, 7, 4, 0, 0, 552, 553, 5, 79, 0, 0, 553, 555, 3, 68, 34, 0, 554, 550, 1, 0, 0, 0, 555, 558, 1, 0, 0, 0, 556, 554, 1, 0, 0, 0, 556, 557, 1, 0, 0, 0, 557, 560, 1, 0, 0, 0, 558, 556, 1, 0, 0, 0, 559, 547, 1, 0, 0, 0, 559, 560, 1, 0, 0, 0, 560, 561, 1, 0, 0, 0, 561, 565, 5, 71, 0, 0, 562, 565, 5, 53, 0, 0, 563, 565, 5, 54, 0, 0, 564, 529, 1, 0, 0, 0, 564, 530, 1, 0, 0, 0, 564, 531, 1, 0, 0, 0, 564, 532, 1, 0, 0, 0, 564, 533, 1, 0, 0, 0, 564, 534, 1, 0, 0, 0, 564, 546, 1, 0, 0, 0, 564, 562, 1, 0, 0, 0, 564, 563, 1, 0, 0, 0, 565, 73, 1, 0, 0, 0, 70, 75, 78, 82, 84, 89, 91, 97, 99, 107, 126, 144, 150, 156, 160, 165, 170, 176, 180, 185, 190, 194, 196, 200, 205, 215, 218, 232, 235, 241, 247, 251, 259, 262, 265, 269, 279, 287, 293, 304, 308, 312, 315, 319, 321, 330, 334, 336, 347, 355, 367, 381, 384, 388, 398, 421, 463, 467, 490, 492, 494, 505, 508, 514, 524, 526, 540, 543, 556, 559, 564] \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.java b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.java new file mode 100644 index 0000000..9e003ca --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.java @@ -0,0 +1,4398 @@ +package com.relogiclabs.jschema.internal.antlr; + +import org.antlr.v4.runtime.FailedPredicateException; +import org.antlr.v4.runtime.NoViableAltException; +import org.antlr.v4.runtime.Parser; +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.RecognitionException; +import org.antlr.v4.runtime.RuleContext; +import org.antlr.v4.runtime.RuntimeMetaData; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.Vocabulary; +import org.antlr.v4.runtime.VocabularyImpl; +import org.antlr.v4.runtime.atn.ATN; +import org.antlr.v4.runtime.atn.ATNDeserializer; +import org.antlr.v4.runtime.atn.ParserATNSimulator; +import org.antlr.v4.runtime.atn.PredictionContextCache; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.tree.ParseTreeVisitor; +import org.antlr.v4.runtime.tree.TerminalNode; + +import java.util.ArrayList; +import java.util.List; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) +public class SchemaParser extends Parser { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + TITLE=1, VERSION=2, IMPORT=3, PRAGMA=4, DEFINE=5, SCHEMA=6, SCRIPT=7, + TRUE=8, FALSE=9, NULL=10, COLON=11, COMMA=12, STAR=13, LBRACE=14, RBRACE=15, + LBRACKET=16, RBRACKET=17, LPAREN=18, RPAREN=19, OPTIONAL=20, UNDEFINED=21, + FULL_IDENTIFIER=22, ALIAS=23, DATATYPE=24, FUNCTION=25, RECEIVER=26, STRING=27, + INTEGER=28, FLOAT=29, DOUBLE=30, WHITE_SPACE=31, BLOCK_COMMENT=32, LINE_COMMENT=33, + G_VAR=34, G_IF=35, G_ELSE=36, G_WHILE=37, G_FOR=38, G_FOREACH=39, G_IN=40, + G_BREAK=41, G_CONSTRAINT=42, G_TARGET=43, G_CALLER=44, G_SUBROUTINE=45, + G_TRYOF=46, G_THROW=47, G_FUNCTION=48, G_RETURN=49, G_FUTURE=50, G_TRUE=51, + G_FALSE=52, G_NULL=53, G_UNDEFINED=54, G_THIS=55, G_NEW=56, G_CONTINUE=57, + G_DO=58, G_CONST=59, G_SWITCH=60, G_CASE=61, G_IMPORT=62, G_CLASS=63, + G_SUPER=64, G_DEFAULT=65, G_INTEGER=66, G_DOUBLE=67, G_STRING=68, G_IDENTIFIER=69, + G_LBRACE=70, G_RBRACE=71, G_LBRACKET=72, G_RBRACKET=73, G_LPAREN=74, G_RPAREN=75, + G_SEMI=76, G_COMMA=77, G_DOT=78, G_COLON=79, G_RANGE=80, G_ELLIPSIS=81, + G_ASSIGN=82, G_INC=83, G_DEC=84, G_PLUS=85, G_MINUS=86, G_MUL=87, G_DIV=88, + G_GT=89, G_LT=90, G_LE=91, G_GE=92, G_EQ=93, G_NE=94, G_NOT=95, G_AND=96, + G_OR=97, WHITE_SPACE1=98, BLOCK_COMMENT1=99, LINE_COMMENT1=100; + public static final int + RULE_schema = 0, RULE_schemaMain = 1, RULE_titleNode = 2, RULE_versionNode = 3, + RULE_importNode = 4, RULE_pragmaNode = 5, RULE_defineNode = 6, RULE_aliasNode = 7, + RULE_validatorMain = 8, RULE_validatorNode = 9, RULE_valueNode = 10, RULE_receiverNode = 11, + RULE_objectNode = 12, RULE_propertyNode = 13, RULE_arrayNode = 14, RULE_datatypeNode = 15, + RULE_functionNode = 16, RULE_argumentNode = 17, RULE_primitiveNode = 18, + RULE_scriptNode = 19, RULE_globalStatement = 20, RULE_statement = 21, + RULE_functionDeclaration = 22, RULE_varStatement = 23, RULE_varInitialization = 24, + RULE_expressionStatement = 25, RULE_ifStatement = 26, RULE_whileStatement = 27, + RULE_forStatement = 28, RULE_expressionList = 29, RULE_foreachStatement = 30, + RULE_returnStatement = 31, RULE_breakStatement = 32, RULE_blockStatement = 33, + RULE_expression = 34, RULE_refExpression = 35, RULE_literal = 36; + private static String[] makeRuleNames() { + return new String[] { + "schema", "schemaMain", "titleNode", "versionNode", "importNode", "pragmaNode", + "defineNode", "aliasNode", "validatorMain", "validatorNode", "valueNode", + "receiverNode", "objectNode", "propertyNode", "arrayNode", "datatypeNode", + "functionNode", "argumentNode", "primitiveNode", "scriptNode", "globalStatement", + "statement", "functionDeclaration", "varStatement", "varInitialization", + "expressionStatement", "ifStatement", "whileStatement", "forStatement", + "expressionList", "foreachStatement", "returnStatement", "breakStatement", + "blockStatement", "expression", "refExpression", "literal" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'%title'", "'%version'", "'%import'", "'%pragma'", null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, "'?'", null, null, null, null, null, null, null, null, null, null, + null, null, null, "'var'", "'if'", "'else'", "'while'", "'for'", "'foreach'", + "'in'", "'break'", "'constraint'", "'target'", "'caller'", "'subroutine'", + "'tryof'", "'throw'", "'function'", "'return'", "'future'", null, null, + null, "'undefined'", "'this'", "'new'", "'continue'", "'do'", "'const'", + "'switch'", "'case'", "'import'", "'class'", "'super'", "'default'", + null, null, null, null, null, null, null, null, null, null, "';'", null, + "'.'", null, "'..'", "'...'", "'='", "'++'", "'--'", "'+'", "'-'", null, + "'/'", "'>'", "'<'", "'<='", "'>='", "'=='", "'!='", null, "'&&'", "'||'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "TITLE", "VERSION", "IMPORT", "PRAGMA", "DEFINE", "SCHEMA", "SCRIPT", + "TRUE", "FALSE", "NULL", "COLON", "COMMA", "STAR", "LBRACE", "RBRACE", + "LBRACKET", "RBRACKET", "LPAREN", "RPAREN", "OPTIONAL", "UNDEFINED", + "FULL_IDENTIFIER", "ALIAS", "DATATYPE", "FUNCTION", "RECEIVER", "STRING", + "INTEGER", "FLOAT", "DOUBLE", "WHITE_SPACE", "BLOCK_COMMENT", "LINE_COMMENT", + "G_VAR", "G_IF", "G_ELSE", "G_WHILE", "G_FOR", "G_FOREACH", "G_IN", "G_BREAK", + "G_CONSTRAINT", "G_TARGET", "G_CALLER", "G_SUBROUTINE", "G_TRYOF", "G_THROW", + "G_FUNCTION", "G_RETURN", "G_FUTURE", "G_TRUE", "G_FALSE", "G_NULL", + "G_UNDEFINED", "G_THIS", "G_NEW", "G_CONTINUE", "G_DO", "G_CONST", "G_SWITCH", + "G_CASE", "G_IMPORT", "G_CLASS", "G_SUPER", "G_DEFAULT", "G_INTEGER", + "G_DOUBLE", "G_STRING", "G_IDENTIFIER", "G_LBRACE", "G_RBRACE", "G_LBRACKET", + "G_RBRACKET", "G_LPAREN", "G_RPAREN", "G_SEMI", "G_COMMA", "G_DOT", "G_COLON", + "G_RANGE", "G_ELLIPSIS", "G_ASSIGN", "G_INC", "G_DEC", "G_PLUS", "G_MINUS", + "G_MUL", "G_DIV", "G_GT", "G_LT", "G_LE", "G_GE", "G_EQ", "G_NE", "G_NOT", + "G_AND", "G_OR", "WHITE_SPACE1", "BLOCK_COMMENT1", "LINE_COMMENT1" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "SchemaParser.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public SchemaParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @SuppressWarnings("CheckReturnValue") + public static class SchemaContext extends ParserRuleContext { + public SchemaContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_schema; } + + public SchemaContext() { } + public void copyFrom(SchemaContext ctx) { + super.copyFrom(ctx); + } + } + @SuppressWarnings("CheckReturnValue") + public static class CompleteSchemaContext extends SchemaContext { + public SchemaMainContext schemaMain() { + return getRuleContext(SchemaMainContext.class,0); + } + public TerminalNode EOF() { return getToken(SchemaParser.EOF, 0); } + public TitleNodeContext titleNode() { + return getRuleContext(TitleNodeContext.class,0); + } + public VersionNodeContext versionNode() { + return getRuleContext(VersionNodeContext.class,0); + } + public List importNode() { + return getRuleContexts(ImportNodeContext.class); + } + public ImportNodeContext importNode(int i) { + return getRuleContext(ImportNodeContext.class,i); + } + public List pragmaNode() { + return getRuleContexts(PragmaNodeContext.class); + } + public PragmaNodeContext pragmaNode(int i) { + return getRuleContext(PragmaNodeContext.class,i); + } + public List defineNode() { + return getRuleContexts(DefineNodeContext.class); + } + public DefineNodeContext defineNode(int i) { + return getRuleContext(DefineNodeContext.class,i); + } + public List scriptNode() { + return getRuleContexts(ScriptNodeContext.class); + } + public ScriptNodeContext scriptNode(int i) { + return getRuleContext(ScriptNodeContext.class,i); + } + public CompleteSchemaContext(SchemaContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitCompleteSchema(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class ShortSchemaContext extends SchemaContext { + public ValidatorNodeContext validatorNode() { + return getRuleContext(ValidatorNodeContext.class,0); + } + public TerminalNode EOF() { return getToken(SchemaParser.EOF, 0); } + public ShortSchemaContext(SchemaContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitShortSchema(this); + else return visitor.visitChildren(this); + } + } + + public final SchemaContext schema() throws RecognitionException { + SchemaContext _localctx = new SchemaContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_schema); + int _la; + try { + setState(107); + _errHandler.sync(this); + switch (_input.LA(1)) { + case TITLE: + case VERSION: + case IMPORT: + case PRAGMA: + case DEFINE: + case SCHEMA: + case SCRIPT: + _localctx = new CompleteSchemaContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(75); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==TITLE) { + { + setState(74); + titleNode(); + } + } + + setState(78); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==VERSION) { + { + setState(77); + versionNode(); + } + } + + setState(84); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==IMPORT || _la==PRAGMA) { + { + setState(82); + _errHandler.sync(this); + switch (_input.LA(1)) { + case IMPORT: + { + setState(80); + importNode(); + } + break; + case PRAGMA: + { + setState(81); + pragmaNode(); + } + break; + default: + throw new NoViableAltException(this); + } + } + setState(86); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(91); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==DEFINE || _la==SCRIPT) { + { + setState(89); + _errHandler.sync(this); + switch (_input.LA(1)) { + case DEFINE: + { + setState(87); + defineNode(); + } + break; + case SCRIPT: + { + setState(88); + scriptNode(); + } + break; + default: + throw new NoViableAltException(this); + } + } + setState(93); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(94); + schemaMain(); + setState(99); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==DEFINE || _la==SCRIPT) { + { + setState(97); + _errHandler.sync(this); + switch (_input.LA(1)) { + case DEFINE: + { + setState(95); + defineNode(); + } + break; + case SCRIPT: + { + setState(96); + scriptNode(); + } + break; + default: + throw new NoViableAltException(this); + } + } + setState(101); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(102); + match(EOF); + } + break; + case TRUE: + case FALSE: + case NULL: + case LBRACE: + case LBRACKET: + case UNDEFINED: + case ALIAS: + case DATATYPE: + case FUNCTION: + case STRING: + case INTEGER: + case FLOAT: + case DOUBLE: + _localctx = new ShortSchemaContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(104); + validatorNode(); + setState(105); + match(EOF); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class SchemaMainContext extends ParserRuleContext { + public TerminalNode SCHEMA() { return getToken(SchemaParser.SCHEMA, 0); } + public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } + public ValidatorNodeContext validatorNode() { + return getRuleContext(ValidatorNodeContext.class,0); + } + public SchemaMainContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_schemaMain; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitSchemaMain(this); + else return visitor.visitChildren(this); + } + } + + public final SchemaMainContext schemaMain() throws RecognitionException { + SchemaMainContext _localctx = new SchemaMainContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_schemaMain); + try { + enterOuterAlt(_localctx, 1); + { + setState(109); + match(SCHEMA); + setState(110); + match(COLON); + setState(111); + validatorNode(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class TitleNodeContext extends ParserRuleContext { + public TerminalNode TITLE() { return getToken(SchemaParser.TITLE, 0); } + public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } + public TerminalNode STRING() { return getToken(SchemaParser.STRING, 0); } + public TitleNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_titleNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitTitleNode(this); + else return visitor.visitChildren(this); + } + } + + public final TitleNodeContext titleNode() throws RecognitionException { + TitleNodeContext _localctx = new TitleNodeContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_titleNode); + try { + enterOuterAlt(_localctx, 1); + { + setState(113); + match(TITLE); + setState(114); + match(COLON); + setState(115); + match(STRING); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class VersionNodeContext extends ParserRuleContext { + public TerminalNode VERSION() { return getToken(SchemaParser.VERSION, 0); } + public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } + public TerminalNode STRING() { return getToken(SchemaParser.STRING, 0); } + public VersionNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_versionNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitVersionNode(this); + else return visitor.visitChildren(this); + } + } + + public final VersionNodeContext versionNode() throws RecognitionException { + VersionNodeContext _localctx = new VersionNodeContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_versionNode); + try { + enterOuterAlt(_localctx, 1); + { + setState(117); + match(VERSION); + setState(118); + match(COLON); + setState(119); + match(STRING); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ImportNodeContext extends ParserRuleContext { + public TerminalNode IMPORT() { return getToken(SchemaParser.IMPORT, 0); } + public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } + public List FULL_IDENTIFIER() { return getTokens(SchemaParser.FULL_IDENTIFIER); } + public TerminalNode FULL_IDENTIFIER(int i) { + return getToken(SchemaParser.FULL_IDENTIFIER, i); + } + public TerminalNode COMMA() { return getToken(SchemaParser.COMMA, 0); } + public ImportNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_importNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitImportNode(this); + else return visitor.visitChildren(this); + } + } + + public final ImportNodeContext importNode() throws RecognitionException { + ImportNodeContext _localctx = new ImportNodeContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_importNode); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(121); + match(IMPORT); + setState(122); + match(COLON); + setState(123); + match(FULL_IDENTIFIER); + setState(126); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==COMMA) { + { + setState(124); + match(COMMA); + setState(125); + match(FULL_IDENTIFIER); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class PragmaNodeContext extends ParserRuleContext { + public TerminalNode PRAGMA() { return getToken(SchemaParser.PRAGMA, 0); } + public TerminalNode FULL_IDENTIFIER() { return getToken(SchemaParser.FULL_IDENTIFIER, 0); } + public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } + public PrimitiveNodeContext primitiveNode() { + return getRuleContext(PrimitiveNodeContext.class,0); + } + public PragmaNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_pragmaNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPragmaNode(this); + else return visitor.visitChildren(this); + } + } + + public final PragmaNodeContext pragmaNode() throws RecognitionException { + PragmaNodeContext _localctx = new PragmaNodeContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_pragmaNode); + try { + enterOuterAlt(_localctx, 1); + { + setState(128); + match(PRAGMA); + setState(129); + match(FULL_IDENTIFIER); + setState(130); + match(COLON); + setState(131); + primitiveNode(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DefineNodeContext extends ParserRuleContext { + public TerminalNode DEFINE() { return getToken(SchemaParser.DEFINE, 0); } + public AliasNodeContext aliasNode() { + return getRuleContext(AliasNodeContext.class,0); + } + public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } + public ValidatorMainContext validatorMain() { + return getRuleContext(ValidatorMainContext.class,0); + } + public DefineNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_defineNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitDefineNode(this); + else return visitor.visitChildren(this); + } + } + + public final DefineNodeContext defineNode() throws RecognitionException { + DefineNodeContext _localctx = new DefineNodeContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_defineNode); + try { + enterOuterAlt(_localctx, 1); + { + setState(133); + match(DEFINE); + setState(134); + aliasNode(); + setState(135); + match(COLON); + setState(136); + validatorMain(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class AliasNodeContext extends ParserRuleContext { + public TerminalNode ALIAS() { return getToken(SchemaParser.ALIAS, 0); } + public AliasNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_aliasNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitAliasNode(this); + else return visitor.visitChildren(this); + } + } + + public final AliasNodeContext aliasNode() throws RecognitionException { + AliasNodeContext _localctx = new AliasNodeContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_aliasNode); + try { + enterOuterAlt(_localctx, 1); + { + setState(138); + match(ALIAS); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ValidatorMainContext extends ParserRuleContext { + public ValueNodeContext valueNode() { + return getRuleContext(ValueNodeContext.class,0); + } + public List functionNode() { + return getRuleContexts(FunctionNodeContext.class); + } + public FunctionNodeContext functionNode(int i) { + return getRuleContext(FunctionNodeContext.class,i); + } + public List datatypeNode() { + return getRuleContexts(DatatypeNodeContext.class); + } + public DatatypeNodeContext datatypeNode(int i) { + return getRuleContext(DatatypeNodeContext.class,i); + } + public List receiverNode() { + return getRuleContexts(ReceiverNodeContext.class); + } + public ReceiverNodeContext receiverNode(int i) { + return getRuleContext(ReceiverNodeContext.class,i); + } + public TerminalNode OPTIONAL() { return getToken(SchemaParser.OPTIONAL, 0); } + public ValidatorMainContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_validatorMain; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitValidatorMain(this); + else return visitor.visitChildren(this); + } + } + + public final ValidatorMainContext validatorMain() throws RecognitionException { + ValidatorMainContext _localctx = new ValidatorMainContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_validatorMain); + int _la; + try { + setState(196); + _errHandler.sync(this); + switch (_input.LA(1)) { + case TRUE: + case FALSE: + case NULL: + case LBRACE: + case LBRACKET: + case UNDEFINED: + case STRING: + case INTEGER: + case FLOAT: + case DOUBLE: + enterOuterAlt(_localctx, 1); + { + setState(140); + valueNode(); + setState(144); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==FUNCTION) { + { + { + setState(141); + functionNode(); + } + } + setState(146); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(150); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==DATATYPE) { + { + { + setState(147); + datatypeNode(); + } + } + setState(152); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(156); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==RECEIVER) { + { + { + setState(153); + receiverNode(); + } + } + setState(158); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(160); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==OPTIONAL) { + { + setState(159); + match(OPTIONAL); + } + } + + } + break; + case FUNCTION: + enterOuterAlt(_localctx, 2); + { + setState(163); + _errHandler.sync(this); + _la = _input.LA(1); + do { + { + { + setState(162); + functionNode(); + } + } + setState(165); + _errHandler.sync(this); + _la = _input.LA(1); + } while ( _la==FUNCTION ); + setState(170); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==DATATYPE) { + { + { + setState(167); + datatypeNode(); + } + } + setState(172); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(176); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==RECEIVER) { + { + { + setState(173); + receiverNode(); + } + } + setState(178); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(180); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==OPTIONAL) { + { + setState(179); + match(OPTIONAL); + } + } + + } + break; + case DATATYPE: + enterOuterAlt(_localctx, 3); + { + setState(183); + _errHandler.sync(this); + _la = _input.LA(1); + do { + { + { + setState(182); + datatypeNode(); + } + } + setState(185); + _errHandler.sync(this); + _la = _input.LA(1); + } while ( _la==DATATYPE ); + setState(190); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==RECEIVER) { + { + { + setState(187); + receiverNode(); + } + } + setState(192); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(194); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==OPTIONAL) { + { + setState(193); + match(OPTIONAL); + } + } + + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ValidatorNodeContext extends ParserRuleContext { + public ValidatorMainContext validatorMain() { + return getRuleContext(ValidatorMainContext.class,0); + } + public AliasNodeContext aliasNode() { + return getRuleContext(AliasNodeContext.class,0); + } + public ValidatorNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_validatorNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitValidatorNode(this); + else return visitor.visitChildren(this); + } + } + + public final ValidatorNodeContext validatorNode() throws RecognitionException { + ValidatorNodeContext _localctx = new ValidatorNodeContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_validatorNode); + try { + setState(200); + _errHandler.sync(this); + switch (_input.LA(1)) { + case TRUE: + case FALSE: + case NULL: + case LBRACE: + case LBRACKET: + case UNDEFINED: + case DATATYPE: + case FUNCTION: + case STRING: + case INTEGER: + case FLOAT: + case DOUBLE: + enterOuterAlt(_localctx, 1); + { + setState(198); + validatorMain(); + } + break; + case ALIAS: + enterOuterAlt(_localctx, 2); + { + setState(199); + aliasNode(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ValueNodeContext extends ParserRuleContext { + public PrimitiveNodeContext primitiveNode() { + return getRuleContext(PrimitiveNodeContext.class,0); + } + public ObjectNodeContext objectNode() { + return getRuleContext(ObjectNodeContext.class,0); + } + public ArrayNodeContext arrayNode() { + return getRuleContext(ArrayNodeContext.class,0); + } + public ValueNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_valueNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitValueNode(this); + else return visitor.visitChildren(this); + } + } + + public final ValueNodeContext valueNode() throws RecognitionException { + ValueNodeContext _localctx = new ValueNodeContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_valueNode); + try { + setState(205); + _errHandler.sync(this); + switch (_input.LA(1)) { + case TRUE: + case FALSE: + case NULL: + case UNDEFINED: + case STRING: + case INTEGER: + case FLOAT: + case DOUBLE: + enterOuterAlt(_localctx, 1); + { + setState(202); + primitiveNode(); + } + break; + case LBRACE: + enterOuterAlt(_localctx, 2); + { + setState(203); + objectNode(); + } + break; + case LBRACKET: + enterOuterAlt(_localctx, 3); + { + setState(204); + arrayNode(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ReceiverNodeContext extends ParserRuleContext { + public TerminalNode RECEIVER() { return getToken(SchemaParser.RECEIVER, 0); } + public ReceiverNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_receiverNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitReceiverNode(this); + else return visitor.visitChildren(this); + } + } + + public final ReceiverNodeContext receiverNode() throws RecognitionException { + ReceiverNodeContext _localctx = new ReceiverNodeContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_receiverNode); + try { + enterOuterAlt(_localctx, 1); + { + setState(207); + match(RECEIVER); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ObjectNodeContext extends ParserRuleContext { + public TerminalNode LBRACE() { return getToken(SchemaParser.LBRACE, 0); } + public TerminalNode RBRACE() { return getToken(SchemaParser.RBRACE, 0); } + public List propertyNode() { + return getRuleContexts(PropertyNodeContext.class); + } + public PropertyNodeContext propertyNode(int i) { + return getRuleContext(PropertyNodeContext.class,i); + } + public List COMMA() { return getTokens(SchemaParser.COMMA); } + public TerminalNode COMMA(int i) { + return getToken(SchemaParser.COMMA, i); + } + public ObjectNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_objectNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitObjectNode(this); + else return visitor.visitChildren(this); + } + } + + public final ObjectNodeContext objectNode() throws RecognitionException { + ObjectNodeContext _localctx = new ObjectNodeContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_objectNode); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(209); + match(LBRACE); + setState(218); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==STRING) { + { + setState(210); + propertyNode(); + setState(215); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==COMMA) { + { + { + setState(211); + match(COMMA); + setState(212); + propertyNode(); + } + } + setState(217); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(220); + match(RBRACE); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class PropertyNodeContext extends ParserRuleContext { + public TerminalNode STRING() { return getToken(SchemaParser.STRING, 0); } + public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } + public ValidatorNodeContext validatorNode() { + return getRuleContext(ValidatorNodeContext.class,0); + } + public PropertyNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_propertyNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPropertyNode(this); + else return visitor.visitChildren(this); + } + } + + public final PropertyNodeContext propertyNode() throws RecognitionException { + PropertyNodeContext _localctx = new PropertyNodeContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_propertyNode); + try { + enterOuterAlt(_localctx, 1); + { + setState(222); + match(STRING); + setState(223); + match(COLON); + setState(224); + validatorNode(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ArrayNodeContext extends ParserRuleContext { + public TerminalNode LBRACKET() { return getToken(SchemaParser.LBRACKET, 0); } + public TerminalNode RBRACKET() { return getToken(SchemaParser.RBRACKET, 0); } + public List validatorNode() { + return getRuleContexts(ValidatorNodeContext.class); + } + public ValidatorNodeContext validatorNode(int i) { + return getRuleContext(ValidatorNodeContext.class,i); + } + public List COMMA() { return getTokens(SchemaParser.COMMA); } + public TerminalNode COMMA(int i) { + return getToken(SchemaParser.COMMA, i); + } + public ArrayNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_arrayNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitArrayNode(this); + else return visitor.visitChildren(this); + } + } + + public final ArrayNodeContext arrayNode() throws RecognitionException { + ArrayNodeContext _localctx = new ArrayNodeContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_arrayNode); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(226); + match(LBRACKET); + setState(235); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 2074167040L) != 0)) { + { + setState(227); + validatorNode(); + setState(232); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==COMMA) { + { + { + setState(228); + match(COMMA); + setState(229); + validatorNode(); + } + } + setState(234); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(237); + match(RBRACKET); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DatatypeNodeContext extends ParserRuleContext { + public TerminalNode DATATYPE() { return getToken(SchemaParser.DATATYPE, 0); } + public TerminalNode STAR() { return getToken(SchemaParser.STAR, 0); } + public TerminalNode LPAREN() { return getToken(SchemaParser.LPAREN, 0); } + public AliasNodeContext aliasNode() { + return getRuleContext(AliasNodeContext.class,0); + } + public TerminalNode RPAREN() { return getToken(SchemaParser.RPAREN, 0); } + public DatatypeNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_datatypeNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitDatatypeNode(this); + else return visitor.visitChildren(this); + } + } + + public final DatatypeNodeContext datatypeNode() throws RecognitionException { + DatatypeNodeContext _localctx = new DatatypeNodeContext(_ctx, getState()); + enterRule(_localctx, 30, RULE_datatypeNode); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(239); + match(DATATYPE); + setState(241); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==STAR) { + { + setState(240); + match(STAR); + } + } + + setState(247); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==LPAREN) { + { + setState(243); + match(LPAREN); + setState(244); + aliasNode(); + setState(245); + match(RPAREN); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class FunctionNodeContext extends ParserRuleContext { + public TerminalNode FUNCTION() { return getToken(SchemaParser.FUNCTION, 0); } + public TerminalNode STAR() { return getToken(SchemaParser.STAR, 0); } + public TerminalNode LPAREN() { return getToken(SchemaParser.LPAREN, 0); } + public TerminalNode RPAREN() { return getToken(SchemaParser.RPAREN, 0); } + public List argumentNode() { + return getRuleContexts(ArgumentNodeContext.class); + } + public ArgumentNodeContext argumentNode(int i) { + return getRuleContext(ArgumentNodeContext.class,i); + } + public List COMMA() { return getTokens(SchemaParser.COMMA); } + public TerminalNode COMMA(int i) { + return getToken(SchemaParser.COMMA, i); + } + public FunctionNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_functionNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitFunctionNode(this); + else return visitor.visitChildren(this); + } + } + + public final FunctionNodeContext functionNode() throws RecognitionException { + FunctionNodeContext _localctx = new FunctionNodeContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_functionNode); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(249); + match(FUNCTION); + setState(251); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==STAR) { + { + setState(250); + match(STAR); + } + } + + setState(265); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==LPAREN) { + { + setState(253); + match(LPAREN); + setState(262); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 2082555648L) != 0)) { + { + setState(254); + argumentNode(); + setState(259); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==COMMA) { + { + { + setState(255); + match(COMMA); + setState(256); + argumentNode(); + } + } + setState(261); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(264); + match(RPAREN); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ArgumentNodeContext extends ParserRuleContext { + public ValueNodeContext valueNode() { + return getRuleContext(ValueNodeContext.class,0); + } + public ReceiverNodeContext receiverNode() { + return getRuleContext(ReceiverNodeContext.class,0); + } + public ArgumentNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_argumentNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitArgumentNode(this); + else return visitor.visitChildren(this); + } + } + + public final ArgumentNodeContext argumentNode() throws RecognitionException { + ArgumentNodeContext _localctx = new ArgumentNodeContext(_ctx, getState()); + enterRule(_localctx, 34, RULE_argumentNode); + try { + setState(269); + _errHandler.sync(this); + switch (_input.LA(1)) { + case TRUE: + case FALSE: + case NULL: + case LBRACE: + case LBRACKET: + case UNDEFINED: + case STRING: + case INTEGER: + case FLOAT: + case DOUBLE: + enterOuterAlt(_localctx, 1); + { + setState(267); + valueNode(); + } + break; + case RECEIVER: + enterOuterAlt(_localctx, 2); + { + setState(268); + receiverNode(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveNodeContext extends ParserRuleContext { + public PrimitiveNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_primitiveNode; } + + public PrimitiveNodeContext() { } + public void copyFrom(PrimitiveNodeContext ctx) { + super.copyFrom(ctx); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveDoubleContext extends PrimitiveNodeContext { + public TerminalNode DOUBLE() { return getToken(SchemaParser.DOUBLE, 0); } + public PrimitiveDoubleContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveDouble(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveFloatContext extends PrimitiveNodeContext { + public TerminalNode FLOAT() { return getToken(SchemaParser.FLOAT, 0); } + public PrimitiveFloatContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveFloat(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveNullContext extends PrimitiveNodeContext { + public TerminalNode NULL() { return getToken(SchemaParser.NULL, 0); } + public PrimitiveNullContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveNull(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveUndefinedContext extends PrimitiveNodeContext { + public TerminalNode UNDEFINED() { return getToken(SchemaParser.UNDEFINED, 0); } + public PrimitiveUndefinedContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveUndefined(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveTrueContext extends PrimitiveNodeContext { + public TerminalNode TRUE() { return getToken(SchemaParser.TRUE, 0); } + public PrimitiveTrueContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveTrue(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveFalseContext extends PrimitiveNodeContext { + public TerminalNode FALSE() { return getToken(SchemaParser.FALSE, 0); } + public PrimitiveFalseContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveFalse(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveStringContext extends PrimitiveNodeContext { + public TerminalNode STRING() { return getToken(SchemaParser.STRING, 0); } + public PrimitiveStringContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveString(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PrimitiveIntegerContext extends PrimitiveNodeContext { + public TerminalNode INTEGER() { return getToken(SchemaParser.INTEGER, 0); } + public PrimitiveIntegerContext(PrimitiveNodeContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveInteger(this); + else return visitor.visitChildren(this); + } + } + + public final PrimitiveNodeContext primitiveNode() throws RecognitionException { + PrimitiveNodeContext _localctx = new PrimitiveNodeContext(_ctx, getState()); + enterRule(_localctx, 36, RULE_primitiveNode); + try { + setState(279); + _errHandler.sync(this); + switch (_input.LA(1)) { + case TRUE: + _localctx = new PrimitiveTrueContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(271); + match(TRUE); + } + break; + case FALSE: + _localctx = new PrimitiveFalseContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(272); + match(FALSE); + } + break; + case STRING: + _localctx = new PrimitiveStringContext(_localctx); + enterOuterAlt(_localctx, 3); + { + setState(273); + match(STRING); + } + break; + case INTEGER: + _localctx = new PrimitiveIntegerContext(_localctx); + enterOuterAlt(_localctx, 4); + { + setState(274); + match(INTEGER); + } + break; + case FLOAT: + _localctx = new PrimitiveFloatContext(_localctx); + enterOuterAlt(_localctx, 5); + { + setState(275); + match(FLOAT); + } + break; + case DOUBLE: + _localctx = new PrimitiveDoubleContext(_localctx); + enterOuterAlt(_localctx, 6); + { + setState(276); + match(DOUBLE); + } + break; + case NULL: + _localctx = new PrimitiveNullContext(_localctx); + enterOuterAlt(_localctx, 7); + { + setState(277); + match(NULL); + } + break; + case UNDEFINED: + _localctx = new PrimitiveUndefinedContext(_localctx); + enterOuterAlt(_localctx, 8); + { + setState(278); + match(UNDEFINED); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ScriptNodeContext extends ParserRuleContext { + public TerminalNode SCRIPT() { return getToken(SchemaParser.SCRIPT, 0); } + public TerminalNode G_COLON() { return getToken(SchemaParser.G_COLON, 0); } + public TerminalNode G_LBRACE() { return getToken(SchemaParser.G_LBRACE, 0); } + public TerminalNode G_RBRACE() { return getToken(SchemaParser.G_RBRACE, 0); } + public List globalStatement() { + return getRuleContexts(GlobalStatementContext.class); + } + public GlobalStatementContext globalStatement(int i) { + return getRuleContext(GlobalStatementContext.class,i); + } + public ScriptNodeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_scriptNode; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitScriptNode(this); + else return visitor.visitChildren(this); + } + } + + public final ScriptNodeContext scriptNode() throws RecognitionException { + ScriptNodeContext _localctx = new ScriptNodeContext(_ctx, getState()); + enterRule(_localctx, 38, RULE_scriptNode); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(281); + match(SCRIPT); + setState(282); + match(G_COLON); + setState(283); + match(G_LBRACE); + setState(285); + _errHandler.sync(this); + _la = _input.LA(1); + do { + { + { + setState(284); + globalStatement(); + } + } + setState(287); + _errHandler.sync(this); + _la = _input.LA(1); + } while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & 1165499505311744L) != 0) ); + setState(289); + match(G_RBRACE); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class GlobalStatementContext extends ParserRuleContext { + public FunctionDeclarationContext functionDeclaration() { + return getRuleContext(FunctionDeclarationContext.class,0); + } + public VarStatementContext varStatement() { + return getRuleContext(VarStatementContext.class,0); + } + public GlobalStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_globalStatement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitGlobalStatement(this); + else return visitor.visitChildren(this); + } + } + + public final GlobalStatementContext globalStatement() throws RecognitionException { + GlobalStatementContext _localctx = new GlobalStatementContext(_ctx, getState()); + enterRule(_localctx, 40, RULE_globalStatement); + try { + setState(293); + _errHandler.sync(this); + switch (_input.LA(1)) { + case G_CONSTRAINT: + case G_SUBROUTINE: + case G_FUTURE: + enterOuterAlt(_localctx, 1); + { + setState(291); + functionDeclaration(); + } + break; + case G_VAR: + enterOuterAlt(_localctx, 2); + { + setState(292); + varStatement(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class StatementContext extends ParserRuleContext { + public VarStatementContext varStatement() { + return getRuleContext(VarStatementContext.class,0); + } + public ExpressionStatementContext expressionStatement() { + return getRuleContext(ExpressionStatementContext.class,0); + } + public IfStatementContext ifStatement() { + return getRuleContext(IfStatementContext.class,0); + } + public WhileStatementContext whileStatement() { + return getRuleContext(WhileStatementContext.class,0); + } + public ForStatementContext forStatement() { + return getRuleContext(ForStatementContext.class,0); + } + public ForeachStatementContext foreachStatement() { + return getRuleContext(ForeachStatementContext.class,0); + } + public ReturnStatementContext returnStatement() { + return getRuleContext(ReturnStatementContext.class,0); + } + public BreakStatementContext breakStatement() { + return getRuleContext(BreakStatementContext.class,0); + } + public BlockStatementContext blockStatement() { + return getRuleContext(BlockStatementContext.class,0); + } + public StatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_statement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitStatement(this); + else return visitor.visitChildren(this); + } + } + + public final StatementContext statement() throws RecognitionException { + StatementContext _localctx = new StatementContext(_ctx, getState()); + enterRule(_localctx, 42, RULE_statement); + try { + setState(304); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,38,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(295); + varStatement(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(296); + expressionStatement(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(297); + ifStatement(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(298); + whileStatement(); + } + break; + case 5: + enterOuterAlt(_localctx, 5); + { + setState(299); + forStatement(); + } + break; + case 6: + enterOuterAlt(_localctx, 6); + { + setState(300); + foreachStatement(); + } + break; + case 7: + enterOuterAlt(_localctx, 7); + { + setState(301); + returnStatement(); + } + break; + case 8: + enterOuterAlt(_localctx, 8); + { + setState(302); + breakStatement(); + } + break; + case 9: + enterOuterAlt(_localctx, 9); + { + setState(303); + blockStatement(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class FunctionDeclarationContext extends ParserRuleContext { + public Token name; + public TerminalNode G_LPAREN() { return getToken(SchemaParser.G_LPAREN, 0); } + public TerminalNode G_RPAREN() { return getToken(SchemaParser.G_RPAREN, 0); } + public BlockStatementContext blockStatement() { + return getRuleContext(BlockStatementContext.class,0); + } + public List G_IDENTIFIER() { return getTokens(SchemaParser.G_IDENTIFIER); } + public TerminalNode G_IDENTIFIER(int i) { + return getToken(SchemaParser.G_IDENTIFIER, i); + } + public TerminalNode G_CONSTRAINT() { return getToken(SchemaParser.G_CONSTRAINT, 0); } + public TerminalNode G_FUTURE() { return getToken(SchemaParser.G_FUTURE, 0); } + public TerminalNode G_SUBROUTINE() { return getToken(SchemaParser.G_SUBROUTINE, 0); } + public TerminalNode G_FUNCTION() { return getToken(SchemaParser.G_FUNCTION, 0); } + public List G_COMMA() { return getTokens(SchemaParser.G_COMMA); } + public TerminalNode G_COMMA(int i) { + return getToken(SchemaParser.G_COMMA, i); + } + public TerminalNode G_ELLIPSIS() { return getToken(SchemaParser.G_ELLIPSIS, 0); } + public FunctionDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_functionDeclaration; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitFunctionDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final FunctionDeclarationContext functionDeclaration() throws RecognitionException { + FunctionDeclarationContext _localctx = new FunctionDeclarationContext(_ctx, getState()); + enterRule(_localctx, 44, RULE_functionDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(321); + _errHandler.sync(this); + switch (_input.LA(1)) { + case G_CONSTRAINT: + { + setState(306); + match(G_CONSTRAINT); + setState(308); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==G_FUNCTION) { + { + setState(307); + match(G_FUNCTION); + } + } + + } + break; + case G_FUTURE: + { + setState(310); + match(G_FUTURE); + setState(312); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==G_CONSTRAINT) { + { + setState(311); + match(G_CONSTRAINT); + } + } + + setState(315); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==G_FUNCTION) { + { + setState(314); + match(G_FUNCTION); + } + } + + } + break; + case G_SUBROUTINE: + { + setState(317); + match(G_SUBROUTINE); + setState(319); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==G_FUNCTION) { + { + setState(318); + match(G_FUNCTION); + } + } + + } + break; + default: + throw new NoViableAltException(this); + } + setState(323); + ((FunctionDeclarationContext)_localctx).name = match(G_IDENTIFIER); + setState(324); + match(G_LPAREN); + setState(336); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==G_IDENTIFIER) { + { + setState(325); + match(G_IDENTIFIER); + setState(330); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==G_COMMA) { + { + { + setState(326); + match(G_COMMA); + setState(327); + match(G_IDENTIFIER); + } + } + setState(332); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(334); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==G_ELLIPSIS) { + { + setState(333); + match(G_ELLIPSIS); + } + } + + } + } + + setState(338); + match(G_RPAREN); + setState(339); + blockStatement(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class VarStatementContext extends ParserRuleContext { + public TerminalNode G_VAR() { return getToken(SchemaParser.G_VAR, 0); } + public List varInitialization() { + return getRuleContexts(VarInitializationContext.class); + } + public VarInitializationContext varInitialization(int i) { + return getRuleContext(VarInitializationContext.class,i); + } + public TerminalNode G_SEMI() { return getToken(SchemaParser.G_SEMI, 0); } + public List G_COMMA() { return getTokens(SchemaParser.G_COMMA); } + public TerminalNode G_COMMA(int i) { + return getToken(SchemaParser.G_COMMA, i); + } + public VarStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_varStatement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitVarStatement(this); + else return visitor.visitChildren(this); + } + } + + public final VarStatementContext varStatement() throws RecognitionException { + VarStatementContext _localctx = new VarStatementContext(_ctx, getState()); + enterRule(_localctx, 46, RULE_varStatement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(341); + match(G_VAR); + setState(342); + varInitialization(); + setState(347); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==G_COMMA) { + { + { + setState(343); + match(G_COMMA); + setState(344); + varInitialization(); + } + } + setState(349); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(350); + match(G_SEMI); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class VarInitializationContext extends ParserRuleContext { + public TerminalNode G_IDENTIFIER() { return getToken(SchemaParser.G_IDENTIFIER, 0); } + public TerminalNode G_ASSIGN() { return getToken(SchemaParser.G_ASSIGN, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public VarInitializationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_varInitialization; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitVarInitialization(this); + else return visitor.visitChildren(this); + } + } + + public final VarInitializationContext varInitialization() throws RecognitionException { + VarInitializationContext _localctx = new VarInitializationContext(_ctx, getState()); + enterRule(_localctx, 48, RULE_varInitialization); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(352); + match(G_IDENTIFIER); + setState(355); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==G_ASSIGN) { + { + setState(353); + match(G_ASSIGN); + setState(354); + expression(0); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ExpressionStatementContext extends ParserRuleContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode G_SEMI() { return getToken(SchemaParser.G_SEMI, 0); } + public ExpressionStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expressionStatement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitExpressionStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ExpressionStatementContext expressionStatement() throws RecognitionException { + ExpressionStatementContext _localctx = new ExpressionStatementContext(_ctx, getState()); + enterRule(_localctx, 50, RULE_expressionStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(357); + expression(0); + setState(358); + match(G_SEMI); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class IfStatementContext extends ParserRuleContext { + public TerminalNode G_IF() { return getToken(SchemaParser.G_IF, 0); } + public TerminalNode G_LPAREN() { return getToken(SchemaParser.G_LPAREN, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode G_RPAREN() { return getToken(SchemaParser.G_RPAREN, 0); } + public List statement() { + return getRuleContexts(StatementContext.class); + } + public StatementContext statement(int i) { + return getRuleContext(StatementContext.class,i); + } + public TerminalNode G_ELSE() { return getToken(SchemaParser.G_ELSE, 0); } + public IfStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_ifStatement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitIfStatement(this); + else return visitor.visitChildren(this); + } + } + + public final IfStatementContext ifStatement() throws RecognitionException { + IfStatementContext _localctx = new IfStatementContext(_ctx, getState()); + enterRule(_localctx, 52, RULE_ifStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(360); + match(G_IF); + setState(361); + match(G_LPAREN); + setState(362); + expression(0); + setState(363); + match(G_RPAREN); + setState(364); + statement(); + setState(367); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,49,_ctx) ) { + case 1: + { + setState(365); + match(G_ELSE); + setState(366); + statement(); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class WhileStatementContext extends ParserRuleContext { + public TerminalNode G_WHILE() { return getToken(SchemaParser.G_WHILE, 0); } + public TerminalNode G_LPAREN() { return getToken(SchemaParser.G_LPAREN, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode G_RPAREN() { return getToken(SchemaParser.G_RPAREN, 0); } + public StatementContext statement() { + return getRuleContext(StatementContext.class,0); + } + public WhileStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_whileStatement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitWhileStatement(this); + else return visitor.visitChildren(this); + } + } + + public final WhileStatementContext whileStatement() throws RecognitionException { + WhileStatementContext _localctx = new WhileStatementContext(_ctx, getState()); + enterRule(_localctx, 54, RULE_whileStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(369); + match(G_WHILE); + setState(370); + match(G_LPAREN); + setState(371); + expression(0); + setState(372); + match(G_RPAREN); + setState(373); + statement(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ForStatementContext extends ParserRuleContext { + public ExpressionListContext initialization; + public ExpressionContext condition; + public ExpressionListContext updation; + public TerminalNode G_FOR() { return getToken(SchemaParser.G_FOR, 0); } + public TerminalNode G_LPAREN() { return getToken(SchemaParser.G_LPAREN, 0); } + public List G_SEMI() { return getTokens(SchemaParser.G_SEMI); } + public TerminalNode G_SEMI(int i) { + return getToken(SchemaParser.G_SEMI, i); + } + public TerminalNode G_RPAREN() { return getToken(SchemaParser.G_RPAREN, 0); } + public StatementContext statement() { + return getRuleContext(StatementContext.class,0); + } + public VarStatementContext varStatement() { + return getRuleContext(VarStatementContext.class,0); + } + public List expressionList() { + return getRuleContexts(ExpressionListContext.class); + } + public ExpressionListContext expressionList(int i) { + return getRuleContext(ExpressionListContext.class,i); + } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public ForStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_forStatement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitForStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ForStatementContext forStatement() throws RecognitionException { + ForStatementContext _localctx = new ForStatementContext(_ctx, getState()); + enterRule(_localctx, 56, RULE_forStatement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(375); + match(G_FOR); + setState(376); + match(G_LPAREN); + setState(381); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,50,_ctx) ) { + case 1: + { + setState(377); + varStatement(); + } + break; + case 2: + { + setState(378); + ((ForStatementContext)_localctx).initialization = expressionList(); + setState(379); + match(G_SEMI); + } + break; + } + setState(384); + _errHandler.sync(this); + _la = _input.LA(1); + if (((((_la - 43)) & ~0x3f) == 0 && ((1L << (_la - 43)) & 4515834638634779L) != 0)) { + { + setState(383); + ((ForStatementContext)_localctx).condition = expression(0); + } + } + + setState(386); + match(G_SEMI); + setState(388); + _errHandler.sync(this); + _la = _input.LA(1); + if (((((_la - 43)) & ~0x3f) == 0 && ((1L << (_la - 43)) & 4515834638634779L) != 0)) { + { + setState(387); + ((ForStatementContext)_localctx).updation = expressionList(); + } + } + + setState(390); + match(G_RPAREN); + setState(391); + statement(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ExpressionListContext extends ParserRuleContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public List G_COMMA() { return getTokens(SchemaParser.G_COMMA); } + public TerminalNode G_COMMA(int i) { + return getToken(SchemaParser.G_COMMA, i); + } + public ExpressionListContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expressionList; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitExpressionList(this); + else return visitor.visitChildren(this); + } + } + + public final ExpressionListContext expressionList() throws RecognitionException { + ExpressionListContext _localctx = new ExpressionListContext(_ctx, getState()); + enterRule(_localctx, 58, RULE_expressionList); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(393); + expression(0); + setState(398); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==G_COMMA) { + { + { + setState(394); + match(G_COMMA); + setState(395); + expression(0); + } + } + setState(400); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ForeachStatementContext extends ParserRuleContext { + public TerminalNode G_FOREACH() { return getToken(SchemaParser.G_FOREACH, 0); } + public TerminalNode G_LPAREN() { return getToken(SchemaParser.G_LPAREN, 0); } + public TerminalNode G_VAR() { return getToken(SchemaParser.G_VAR, 0); } + public TerminalNode G_IDENTIFIER() { return getToken(SchemaParser.G_IDENTIFIER, 0); } + public TerminalNode G_IN() { return getToken(SchemaParser.G_IN, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode G_RPAREN() { return getToken(SchemaParser.G_RPAREN, 0); } + public StatementContext statement() { + return getRuleContext(StatementContext.class,0); + } + public ForeachStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_foreachStatement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitForeachStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ForeachStatementContext foreachStatement() throws RecognitionException { + ForeachStatementContext _localctx = new ForeachStatementContext(_ctx, getState()); + enterRule(_localctx, 60, RULE_foreachStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(401); + match(G_FOREACH); + setState(402); + match(G_LPAREN); + setState(403); + match(G_VAR); + setState(404); + match(G_IDENTIFIER); + setState(405); + match(G_IN); + setState(406); + expression(0); + setState(407); + match(G_RPAREN); + setState(408); + statement(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ReturnStatementContext extends ParserRuleContext { + public TerminalNode G_RETURN() { return getToken(SchemaParser.G_RETURN, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode G_SEMI() { return getToken(SchemaParser.G_SEMI, 0); } + public ReturnStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_returnStatement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitReturnStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ReturnStatementContext returnStatement() throws RecognitionException { + ReturnStatementContext _localctx = new ReturnStatementContext(_ctx, getState()); + enterRule(_localctx, 62, RULE_returnStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(410); + match(G_RETURN); + setState(411); + expression(0); + setState(412); + match(G_SEMI); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class BreakStatementContext extends ParserRuleContext { + public TerminalNode G_BREAK() { return getToken(SchemaParser.G_BREAK, 0); } + public TerminalNode G_SEMI() { return getToken(SchemaParser.G_SEMI, 0); } + public BreakStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_breakStatement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitBreakStatement(this); + else return visitor.visitChildren(this); + } + } + + public final BreakStatementContext breakStatement() throws RecognitionException { + BreakStatementContext _localctx = new BreakStatementContext(_ctx, getState()); + enterRule(_localctx, 64, RULE_breakStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(414); + match(G_BREAK); + setState(415); + match(G_SEMI); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class BlockStatementContext extends ParserRuleContext { + public TerminalNode G_LBRACE() { return getToken(SchemaParser.G_LBRACE, 0); } + public TerminalNode G_RBRACE() { return getToken(SchemaParser.G_RBRACE, 0); } + public List statement() { + return getRuleContexts(StatementContext.class); + } + public StatementContext statement(int i) { + return getRuleContext(StatementContext.class,i); + } + public BlockStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_blockStatement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitBlockStatement(this); + else return visitor.visitChildren(this); + } + } + + public final BlockStatementContext blockStatement() throws RecognitionException { + BlockStatementContext _localctx = new BlockStatementContext(_ctx, getState()); + enterRule(_localctx, 66, RULE_blockStatement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(417); + match(G_LBRACE); + setState(421); + _errHandler.sync(this); + _la = _input.LA(1); + while (((((_la - 34)) & ~0x3f) == 0 && ((1L << (_la - 34)) & 2312107334981039803L) != 0)) { + { + { + setState(418); + statement(); + } + } + setState(423); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(424); + match(G_RBRACE); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ExpressionContext extends ParserRuleContext { + public ExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expression; } + + public ExpressionContext() { } + public void copyFrom(ExpressionContext ctx) { + super.copyFrom(ctx); + } + } + @SuppressWarnings("CheckReturnValue") + public static class RangeEndExpressionContext extends ExpressionContext { + public TerminalNode G_RANGE() { return getToken(SchemaParser.G_RANGE, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public RangeEndExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitRangeEndExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class ParenthesizedExpressionContext extends ExpressionContext { + public TerminalNode G_LPAREN() { return getToken(SchemaParser.G_LPAREN, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode G_RPAREN() { return getToken(SchemaParser.G_RPAREN, 0); } + public ParenthesizedExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitParenthesizedExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PostIncrementExpressionContext extends ExpressionContext { + public RefExpressionContext refExpression() { + return getRuleContext(RefExpressionContext.class,0); + } + public TerminalNode G_INC() { return getToken(SchemaParser.G_INC, 0); } + public PostIncrementExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPostIncrementExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class AdditiveExpressionContext extends ExpressionContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public TerminalNode G_PLUS() { return getToken(SchemaParser.G_PLUS, 0); } + public TerminalNode G_MINUS() { return getToken(SchemaParser.G_MINUS, 0); } + public AdditiveExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitAdditiveExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class RelationalExpressionContext extends ExpressionContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public TerminalNode G_GE() { return getToken(SchemaParser.G_GE, 0); } + public TerminalNode G_LE() { return getToken(SchemaParser.G_LE, 0); } + public TerminalNode G_GT() { return getToken(SchemaParser.G_GT, 0); } + public TerminalNode G_LT() { return getToken(SchemaParser.G_LT, 0); } + public RelationalExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitRelationalExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class LogicalAndExpressionContext extends ExpressionContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public TerminalNode G_AND() { return getToken(SchemaParser.G_AND, 0); } + public LogicalAndExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitLogicalAndExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PreDecrementExpressionContext extends ExpressionContext { + public TerminalNode G_DEC() { return getToken(SchemaParser.G_DEC, 0); } + public RefExpressionContext refExpression() { + return getRuleContext(RefExpressionContext.class,0); + } + public PreDecrementExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPreDecrementExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PreIncrementExpressionContext extends ExpressionContext { + public TerminalNode G_INC() { return getToken(SchemaParser.G_INC, 0); } + public RefExpressionContext refExpression() { + return getRuleContext(RefExpressionContext.class,0); + } + public PreIncrementExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPreIncrementExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class LiteralExpressionContext extends ExpressionContext { + public LiteralContext literal() { + return getRuleContext(LiteralContext.class,0); + } + public LiteralExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitLiteralExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class LogicalOrExpressionContext extends ExpressionContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public TerminalNode G_OR() { return getToken(SchemaParser.G_OR, 0); } + public LogicalOrExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitLogicalOrExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class LogicalNotExpressionContext extends ExpressionContext { + public TerminalNode G_NOT() { return getToken(SchemaParser.G_NOT, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public LogicalNotExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitLogicalNotExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class ThrowExpressionContext extends ExpressionContext { + public TerminalNode G_THROW() { return getToken(SchemaParser.G_THROW, 0); } + public TerminalNode G_LPAREN() { return getToken(SchemaParser.G_LPAREN, 0); } + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public TerminalNode G_RPAREN() { return getToken(SchemaParser.G_RPAREN, 0); } + public TerminalNode G_COMMA() { return getToken(SchemaParser.G_COMMA, 0); } + public ThrowExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitThrowExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class AllRefExpressionContext extends ExpressionContext { + public RefExpressionContext refExpression() { + return getRuleContext(RefExpressionContext.class,0); + } + public AllRefExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitAllRefExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class TryofExpressionContext extends ExpressionContext { + public TerminalNode G_TRYOF() { return getToken(SchemaParser.G_TRYOF, 0); } + public TerminalNode G_LPAREN() { return getToken(SchemaParser.G_LPAREN, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode G_RPAREN() { return getToken(SchemaParser.G_RPAREN, 0); } + public TryofExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitTryofExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class UnaryMinusExpressionContext extends ExpressionContext { + public TerminalNode G_MINUS() { return getToken(SchemaParser.G_MINUS, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public UnaryMinusExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitUnaryMinusExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class AssignmentExpressionContext extends ExpressionContext { + public RefExpressionContext refExpression() { + return getRuleContext(RefExpressionContext.class,0); + } + public TerminalNode G_ASSIGN() { return getToken(SchemaParser.G_ASSIGN, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public AssignmentExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitAssignmentExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class PostDecrementExpressionContext extends ExpressionContext { + public RefExpressionContext refExpression() { + return getRuleContext(RefExpressionContext.class,0); + } + public TerminalNode G_DEC() { return getToken(SchemaParser.G_DEC, 0); } + public PostDecrementExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPostDecrementExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class EqualityExpressionContext extends ExpressionContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public TerminalNode G_EQ() { return getToken(SchemaParser.G_EQ, 0); } + public TerminalNode G_NE() { return getToken(SchemaParser.G_NE, 0); } + public EqualityExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitEqualityExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class MultiplicativeExpressionContext extends ExpressionContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public TerminalNode G_MUL() { return getToken(SchemaParser.G_MUL, 0); } + public TerminalNode G_DIV() { return getToken(SchemaParser.G_DIV, 0); } + public MultiplicativeExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitMultiplicativeExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class RangeBothExpressionContext extends ExpressionContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public TerminalNode G_RANGE() { return getToken(SchemaParser.G_RANGE, 0); } + public RangeBothExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitRangeBothExpression(this); + else return visitor.visitChildren(this); + } + } + + public final ExpressionContext expression() throws RecognitionException { + return expression(0); + } + + private ExpressionContext expression(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + ExpressionContext _localctx = new ExpressionContext(_ctx, _parentState); + ExpressionContext _prevctx = _localctx; + int _startState = 68; + enterRecursionRule(_localctx, 68, RULE_expression, _p); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(467); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,56,_ctx) ) { + case 1: + { + _localctx = new AllRefExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + + setState(427); + refExpression(0); + } + break; + case 2: + { + _localctx = new UnaryMinusExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(428); + match(G_MINUS); + setState(429); + expression(19); + } + break; + case 3: + { + _localctx = new LogicalNotExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(430); + match(G_NOT); + setState(431); + expression(18); + } + break; + case 4: + { + _localctx = new PostIncrementExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(432); + refExpression(0); + setState(433); + match(G_INC); + } + break; + case 5: + { + _localctx = new PostDecrementExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(435); + refExpression(0); + setState(436); + match(G_DEC); + } + break; + case 6: + { + _localctx = new PreIncrementExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(438); + match(G_INC); + setState(439); + refExpression(0); + } + break; + case 7: + { + _localctx = new PreDecrementExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(440); + match(G_DEC); + setState(441); + refExpression(0); + } + break; + case 8: + { + _localctx = new RangeEndExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(442); + match(G_RANGE); + setState(443); + expression(10); + } + break; + case 9: + { + _localctx = new AssignmentExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(444); + refExpression(0); + setState(445); + match(G_ASSIGN); + setState(446); + expression(5); + } + break; + case 10: + { + _localctx = new LiteralExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(448); + literal(); + } + break; + case 11: + { + _localctx = new ParenthesizedExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(449); + match(G_LPAREN); + setState(450); + expression(0); + setState(451); + match(G_RPAREN); + } + break; + case 12: + { + _localctx = new TryofExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(453); + match(G_TRYOF); + setState(454); + match(G_LPAREN); + setState(455); + expression(0); + setState(456); + match(G_RPAREN); + } + break; + case 13: + { + _localctx = new ThrowExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(458); + match(G_THROW); + setState(459); + match(G_LPAREN); + setState(460); + expression(0); + setState(463); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==G_COMMA) { + { + setState(461); + match(G_COMMA); + setState(462); + expression(0); + } + } + + setState(465); + match(G_RPAREN); + } + break; + } + _ctx.stop = _input.LT(-1); + setState(494); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,59,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + setState(492); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,58,_ctx) ) { + case 1: + { + _localctx = new MultiplicativeExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(469); + if (!(precpred(_ctx, 13))) throw new FailedPredicateException(this, "precpred(_ctx, 13)"); + setState(470); + _la = _input.LA(1); + if ( !(_la==G_MUL || _la==G_DIV) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(471); + expression(14); + } + break; + case 2: + { + _localctx = new AdditiveExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(472); + if (!(precpred(_ctx, 12))) throw new FailedPredicateException(this, "precpred(_ctx, 12)"); + setState(473); + _la = _input.LA(1); + if ( !(_la==G_PLUS || _la==G_MINUS) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(474); + expression(13); + } + break; + case 3: + { + _localctx = new RelationalExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(475); + if (!(precpred(_ctx, 9))) throw new FailedPredicateException(this, "precpred(_ctx, 9)"); + setState(476); + _la = _input.LA(1); + if ( !(((((_la - 89)) & ~0x3f) == 0 && ((1L << (_la - 89)) & 15L) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(477); + expression(10); + } + break; + case 4: + { + _localctx = new EqualityExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(478); + if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); + setState(479); + _la = _input.LA(1); + if ( !(_la==G_EQ || _la==G_NE) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(480); + expression(9); + } + break; + case 5: + { + _localctx = new LogicalAndExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(481); + if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); + setState(482); + match(G_AND); + setState(483); + expression(8); + } + break; + case 6: + { + _localctx = new LogicalOrExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(484); + if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); + setState(485); + match(G_OR); + setState(486); + expression(7); + } + break; + case 7: + { + _localctx = new RangeBothExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(487); + if (!(precpred(_ctx, 11))) throw new FailedPredicateException(this, "precpred(_ctx, 11)"); + setState(488); + match(G_RANGE); + setState(490); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,57,_ctx) ) { + case 1: + { + setState(489); + expression(0); + } + break; + } + } + break; + } + } + } + setState(496); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,59,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class RefExpressionContext extends ParserRuleContext { + public RefExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_refExpression; } + + public RefExpressionContext() { } + public void copyFrom(RefExpressionContext ctx) { + super.copyFrom(ctx); + } + } + @SuppressWarnings("CheckReturnValue") + public static class CallerExpressionContext extends RefExpressionContext { + public TerminalNode G_CALLER() { return getToken(SchemaParser.G_CALLER, 0); } + public CallerExpressionContext(RefExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitCallerExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class InvokeExpressionContext extends RefExpressionContext { + public TerminalNode G_IDENTIFIER() { return getToken(SchemaParser.G_IDENTIFIER, 0); } + public TerminalNode G_LPAREN() { return getToken(SchemaParser.G_LPAREN, 0); } + public TerminalNode G_RPAREN() { return getToken(SchemaParser.G_RPAREN, 0); } + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public List G_COMMA() { return getTokens(SchemaParser.G_COMMA); } + public TerminalNode G_COMMA(int i) { + return getToken(SchemaParser.G_COMMA, i); + } + public InvokeExpressionContext(RefExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitInvokeExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class DotExpressionContext extends RefExpressionContext { + public RefExpressionContext refExpression() { + return getRuleContext(RefExpressionContext.class,0); + } + public TerminalNode G_DOT() { return getToken(SchemaParser.G_DOT, 0); } + public TerminalNode G_IDENTIFIER() { return getToken(SchemaParser.G_IDENTIFIER, 0); } + public DotExpressionContext(RefExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitDotExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class TargetExpressionContext extends RefExpressionContext { + public TerminalNode G_TARGET() { return getToken(SchemaParser.G_TARGET, 0); } + public TargetExpressionContext(RefExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitTargetExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class IndexExpressionContext extends RefExpressionContext { + public RefExpressionContext refExpression() { + return getRuleContext(RefExpressionContext.class,0); + } + public TerminalNode G_LBRACKET() { return getToken(SchemaParser.G_LBRACKET, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode G_RBRACKET() { return getToken(SchemaParser.G_RBRACKET, 0); } + public IndexExpressionContext(RefExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitIndexExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class IdentifierExpressionContext extends RefExpressionContext { + public TerminalNode G_IDENTIFIER() { return getToken(SchemaParser.G_IDENTIFIER, 0); } + public IdentifierExpressionContext(RefExpressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitIdentifierExpression(this); + else return visitor.visitChildren(this); + } + } + + public final RefExpressionContext refExpression() throws RecognitionException { + return refExpression(0); + } + + private RefExpressionContext refExpression(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + RefExpressionContext _localctx = new RefExpressionContext(_ctx, _parentState); + RefExpressionContext _prevctx = _localctx; + int _startState = 70; + enterRecursionRule(_localctx, 70, RULE_refExpression, _p); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(514); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,62,_ctx) ) { + case 1: + { + _localctx = new InvokeExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + + setState(498); + match(G_IDENTIFIER); + setState(499); + match(G_LPAREN); + setState(508); + _errHandler.sync(this); + _la = _input.LA(1); + if (((((_la - 43)) & ~0x3f) == 0 && ((1L << (_la - 43)) & 4515834638634779L) != 0)) { + { + setState(500); + expression(0); + setState(505); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==G_COMMA) { + { + { + setState(501); + match(G_COMMA); + setState(502); + expression(0); + } + } + setState(507); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(510); + match(G_RPAREN); + } + break; + case 2: + { + _localctx = new TargetExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(511); + match(G_TARGET); + } + break; + case 3: + { + _localctx = new CallerExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(512); + match(G_CALLER); + } + break; + case 4: + { + _localctx = new IdentifierExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(513); + match(G_IDENTIFIER); + } + break; + } + _ctx.stop = _input.LT(-1); + setState(526); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,64,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + setState(524); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,63,_ctx) ) { + case 1: + { + _localctx = new DotExpressionContext(new RefExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_refExpression); + setState(516); + if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); + setState(517); + match(G_DOT); + setState(518); + match(G_IDENTIFIER); + } + break; + case 2: + { + _localctx = new IndexExpressionContext(new RefExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_refExpression); + setState(519); + if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); + setState(520); + match(G_LBRACKET); + setState(521); + expression(0); + setState(522); + match(G_RBRACKET); + } + break; + } + } + } + setState(528); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,64,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class LiteralContext extends ParserRuleContext { + public LiteralContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_literal; } + + public LiteralContext() { } + public void copyFrom(LiteralContext ctx) { + super.copyFrom(ctx); + } + } + @SuppressWarnings("CheckReturnValue") + public static class ObjectLiteralContext extends LiteralContext { + public Token G_IDENTIFIER; + public List keys = new ArrayList(); + public Token G_STRING; + public Token _tset1193; + public ExpressionContext expression; + public List values = new ArrayList(); + public Token _tset1215; + public TerminalNode G_LBRACE() { return getToken(SchemaParser.G_LBRACE, 0); } + public TerminalNode G_RBRACE() { return getToken(SchemaParser.G_RBRACE, 0); } + public List G_COLON() { return getTokens(SchemaParser.G_COLON); } + public TerminalNode G_COLON(int i) { + return getToken(SchemaParser.G_COLON, i); + } + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public List G_IDENTIFIER() { return getTokens(SchemaParser.G_IDENTIFIER); } + public TerminalNode G_IDENTIFIER(int i) { + return getToken(SchemaParser.G_IDENTIFIER, i); + } + public List G_STRING() { return getTokens(SchemaParser.G_STRING); } + public TerminalNode G_STRING(int i) { + return getToken(SchemaParser.G_STRING, i); + } + public List G_COMMA() { return getTokens(SchemaParser.G_COMMA); } + public TerminalNode G_COMMA(int i) { + return getToken(SchemaParser.G_COMMA, i); + } + public ObjectLiteralContext(LiteralContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitObjectLiteral(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class UndefinedLiteralContext extends LiteralContext { + public TerminalNode G_UNDEFINED() { return getToken(SchemaParser.G_UNDEFINED, 0); } + public UndefinedLiteralContext(LiteralContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitUndefinedLiteral(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class TrueLiteralContext extends LiteralContext { + public TerminalNode G_TRUE() { return getToken(SchemaParser.G_TRUE, 0); } + public TrueLiteralContext(LiteralContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitTrueLiteral(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class StringLiteralContext extends LiteralContext { + public TerminalNode G_STRING() { return getToken(SchemaParser.G_STRING, 0); } + public StringLiteralContext(LiteralContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitStringLiteral(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class DoubleLiteralContext extends LiteralContext { + public TerminalNode G_DOUBLE() { return getToken(SchemaParser.G_DOUBLE, 0); } + public DoubleLiteralContext(LiteralContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitDoubleLiteral(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class ArrayLiteralContext extends LiteralContext { + public TerminalNode G_LBRACKET() { return getToken(SchemaParser.G_LBRACKET, 0); } + public TerminalNode G_RBRACKET() { return getToken(SchemaParser.G_RBRACKET, 0); } + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public List G_COMMA() { return getTokens(SchemaParser.G_COMMA); } + public TerminalNode G_COMMA(int i) { + return getToken(SchemaParser.G_COMMA, i); + } + public ArrayLiteralContext(LiteralContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitArrayLiteral(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class NullLiteralContext extends LiteralContext { + public TerminalNode G_NULL() { return getToken(SchemaParser.G_NULL, 0); } + public NullLiteralContext(LiteralContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitNullLiteral(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class IntegerLiteralContext extends LiteralContext { + public TerminalNode G_INTEGER() { return getToken(SchemaParser.G_INTEGER, 0); } + public IntegerLiteralContext(LiteralContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitIntegerLiteral(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class FalseLiteralContext extends LiteralContext { + public TerminalNode G_FALSE() { return getToken(SchemaParser.G_FALSE, 0); } + public FalseLiteralContext(LiteralContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitFalseLiteral(this); + else return visitor.visitChildren(this); + } + } + + public final LiteralContext literal() throws RecognitionException { + LiteralContext _localctx = new LiteralContext(_ctx, getState()); + enterRule(_localctx, 72, RULE_literal); + int _la; + try { + setState(564); + _errHandler.sync(this); + switch (_input.LA(1)) { + case G_TRUE: + _localctx = new TrueLiteralContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(529); + match(G_TRUE); + } + break; + case G_FALSE: + _localctx = new FalseLiteralContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(530); + match(G_FALSE); + } + break; + case G_INTEGER: + _localctx = new IntegerLiteralContext(_localctx); + enterOuterAlt(_localctx, 3); + { + setState(531); + match(G_INTEGER); + } + break; + case G_DOUBLE: + _localctx = new DoubleLiteralContext(_localctx); + enterOuterAlt(_localctx, 4); + { + setState(532); + match(G_DOUBLE); + } + break; + case G_STRING: + _localctx = new StringLiteralContext(_localctx); + enterOuterAlt(_localctx, 5); + { + setState(533); + match(G_STRING); + } + break; + case G_LBRACKET: + _localctx = new ArrayLiteralContext(_localctx); + enterOuterAlt(_localctx, 6); + { + setState(534); + match(G_LBRACKET); + setState(543); + _errHandler.sync(this); + _la = _input.LA(1); + if (((((_la - 43)) & ~0x3f) == 0 && ((1L << (_la - 43)) & 4515834638634779L) != 0)) { + { + setState(535); + expression(0); + setState(540); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==G_COMMA) { + { + { + setState(536); + match(G_COMMA); + setState(537); + expression(0); + } + } + setState(542); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(545); + match(G_RBRACKET); + } + break; + case G_LBRACE: + _localctx = new ObjectLiteralContext(_localctx); + enterOuterAlt(_localctx, 7); + { + setState(546); + match(G_LBRACE); + setState(559); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==G_STRING || _la==G_IDENTIFIER) { + { + setState(547); + ((ObjectLiteralContext)_localctx)._tset1193 = _input.LT(1); + _la = _input.LA(1); + if ( !(_la==G_STRING || _la==G_IDENTIFIER) ) { + ((ObjectLiteralContext)_localctx)._tset1193 = (Token)_errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + ((ObjectLiteralContext)_localctx).keys.add(((ObjectLiteralContext)_localctx)._tset1193); + setState(548); + match(G_COLON); + setState(549); + ((ObjectLiteralContext)_localctx).expression = expression(0); + ((ObjectLiteralContext)_localctx).values.add(((ObjectLiteralContext)_localctx).expression); + setState(556); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==G_COMMA) { + { + { + setState(550); + match(G_COMMA); + setState(551); + ((ObjectLiteralContext)_localctx)._tset1215 = _input.LT(1); + _la = _input.LA(1); + if ( !(_la==G_STRING || _la==G_IDENTIFIER) ) { + ((ObjectLiteralContext)_localctx)._tset1215 = (Token)_errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + ((ObjectLiteralContext)_localctx).keys.add(((ObjectLiteralContext)_localctx)._tset1215); + setState(552); + match(G_COLON); + setState(553); + ((ObjectLiteralContext)_localctx).expression = expression(0); + ((ObjectLiteralContext)_localctx).values.add(((ObjectLiteralContext)_localctx).expression); + } + } + setState(558); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(561); + match(G_RBRACE); + } + break; + case G_NULL: + _localctx = new NullLiteralContext(_localctx); + enterOuterAlt(_localctx, 8); + { + setState(562); + match(G_NULL); + } + break; + case G_UNDEFINED: + _localctx = new UndefinedLiteralContext(_localctx); + enterOuterAlt(_localctx, 9); + { + setState(563); + match(G_UNDEFINED); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { + switch (ruleIndex) { + case 34: + return expression_sempred((ExpressionContext)_localctx, predIndex); + case 35: + return refExpression_sempred((RefExpressionContext)_localctx, predIndex); + } + return true; + } + private boolean expression_sempred(ExpressionContext _localctx, int predIndex) { + switch (predIndex) { + case 0: + return precpred(_ctx, 13); + case 1: + return precpred(_ctx, 12); + case 2: + return precpred(_ctx, 9); + case 3: + return precpred(_ctx, 8); + case 4: + return precpred(_ctx, 7); + case 5: + return precpred(_ctx, 6); + case 6: + return precpred(_ctx, 11); + } + return true; + } + private boolean refExpression_sempred(RefExpressionContext _localctx, int predIndex) { + switch (predIndex) { + case 7: + return precpred(_ctx, 6); + case 8: + return precpred(_ctx, 5); + } + return true; + } + + public static final String _serializedATN = + "\u0004\u0001d\u0237\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ + "\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+ + "\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007\u0002"+ + "\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b\u0007\u000b\u0002"+ + "\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0002\u000f\u0007\u000f"+ + "\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011\u0002\u0012\u0007\u0012"+ + "\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014\u0002\u0015\u0007\u0015"+ + "\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002\u0018\u0007\u0018"+ + "\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002\u001b\u0007\u001b"+ + "\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002\u001e\u0007\u001e"+ + "\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007!\u0002\"\u0007\"\u0002"+ + "#\u0007#\u0002$\u0007$\u0001\u0000\u0003\u0000L\b\u0000\u0001\u0000\u0003"+ + "\u0000O\b\u0000\u0001\u0000\u0001\u0000\u0005\u0000S\b\u0000\n\u0000\f"+ + "\u0000V\t\u0000\u0001\u0000\u0001\u0000\u0005\u0000Z\b\u0000\n\u0000\f"+ + "\u0000]\t\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0005\u0000b\b\u0000"+ + "\n\u0000\f\u0000e\t\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000"+ + "\u0001\u0000\u0003\u0000l\b\u0000\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003"+ + "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004"+ + "\u0001\u0004\u0001\u0004\u0003\u0004\u007f\b\u0004\u0001\u0005\u0001\u0005"+ + "\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0001\b\u0001\b\u0005"+ + "\b\u008f\b\b\n\b\f\b\u0092\t\b\u0001\b\u0005\b\u0095\b\b\n\b\f\b\u0098"+ + "\t\b\u0001\b\u0005\b\u009b\b\b\n\b\f\b\u009e\t\b\u0001\b\u0003\b\u00a1"+ + "\b\b\u0001\b\u0004\b\u00a4\b\b\u000b\b\f\b\u00a5\u0001\b\u0005\b\u00a9"+ + "\b\b\n\b\f\b\u00ac\t\b\u0001\b\u0005\b\u00af\b\b\n\b\f\b\u00b2\t\b\u0001"+ + "\b\u0003\b\u00b5\b\b\u0001\b\u0004\b\u00b8\b\b\u000b\b\f\b\u00b9\u0001"+ + "\b\u0005\b\u00bd\b\b\n\b\f\b\u00c0\t\b\u0001\b\u0003\b\u00c3\b\b\u0003"+ + "\b\u00c5\b\b\u0001\t\u0001\t\u0003\t\u00c9\b\t\u0001\n\u0001\n\u0001\n"+ + "\u0003\n\u00ce\b\n\u0001\u000b\u0001\u000b\u0001\f\u0001\f\u0001\f\u0001"+ + "\f\u0005\f\u00d6\b\f\n\f\f\f\u00d9\t\f\u0003\f\u00db\b\f\u0001\f\u0001"+ + "\f\u0001\r\u0001\r\u0001\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000e"+ + "\u0001\u000e\u0005\u000e\u00e7\b\u000e\n\u000e\f\u000e\u00ea\t\u000e\u0003"+ + "\u000e\u00ec\b\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0003"+ + "\u000f\u00f2\b\u000f\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u000f\u0003"+ + "\u000f\u00f8\b\u000f\u0001\u0010\u0001\u0010\u0003\u0010\u00fc\b\u0010"+ + "\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0005\u0010\u0102\b\u0010"+ + "\n\u0010\f\u0010\u0105\t\u0010\u0003\u0010\u0107\b\u0010\u0001\u0010\u0003"+ + "\u0010\u010a\b\u0010\u0001\u0011\u0001\u0011\u0003\u0011\u010e\b\u0011"+ + "\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012"+ + "\u0001\u0012\u0001\u0012\u0003\u0012\u0118\b\u0012\u0001\u0013\u0001\u0013"+ + "\u0001\u0013\u0001\u0013\u0004\u0013\u011e\b\u0013\u000b\u0013\f\u0013"+ + "\u011f\u0001\u0013\u0001\u0013\u0001\u0014\u0001\u0014\u0003\u0014\u0126"+ + "\b\u0014\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001"+ + "\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0003\u0015\u0131\b\u0015\u0001"+ + "\u0016\u0001\u0016\u0003\u0016\u0135\b\u0016\u0001\u0016\u0001\u0016\u0003"+ + "\u0016\u0139\b\u0016\u0001\u0016\u0003\u0016\u013c\b\u0016\u0001\u0016"+ + "\u0001\u0016\u0003\u0016\u0140\b\u0016\u0003\u0016\u0142\b\u0016\u0001"+ + "\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0005\u0016\u0149"+ + "\b\u0016\n\u0016\f\u0016\u014c\t\u0016\u0001\u0016\u0003\u0016\u014f\b"+ + "\u0016\u0003\u0016\u0151\b\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001"+ + "\u0017\u0001\u0017\u0001\u0017\u0001\u0017\u0005\u0017\u015a\b\u0017\n"+ + "\u0017\f\u0017\u015d\t\u0017\u0001\u0017\u0001\u0017\u0001\u0018\u0001"+ + "\u0018\u0001\u0018\u0003\u0018\u0164\b\u0018\u0001\u0019\u0001\u0019\u0001"+ + "\u0019\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001a\u0001"+ + "\u001a\u0001\u001a\u0003\u001a\u0170\b\u001a\u0001\u001b\u0001\u001b\u0001"+ + "\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001c\u0001\u001c\u0001"+ + "\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0003\u001c\u017e\b\u001c\u0001"+ + "\u001c\u0003\u001c\u0181\b\u001c\u0001\u001c\u0001\u001c\u0003\u001c\u0185"+ + "\b\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001d\u0001\u001d\u0001"+ + "\u001d\u0005\u001d\u018d\b\u001d\n\u001d\f\u001d\u0190\t\u001d\u0001\u001e"+ + "\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e"+ + "\u0001\u001e\u0001\u001e\u0001\u001f\u0001\u001f\u0001\u001f\u0001\u001f"+ + "\u0001 \u0001 \u0001 \u0001!\u0001!\u0005!\u01a4\b!\n!\f!\u01a7\t!\u0001"+ + "!\u0001!\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ + "\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ + "\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ + "\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ + "\"\u0001\"\u0001\"\u0003\"\u01d0\b\"\u0001\"\u0001\"\u0003\"\u01d4\b\""+ + "\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ + "\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ + "\"\u0001\"\u0001\"\u0001\"\u0003\"\u01eb\b\"\u0005\"\u01ed\b\"\n\"\f\""+ + "\u01f0\t\"\u0001#\u0001#\u0001#\u0001#\u0001#\u0001#\u0005#\u01f8\b#\n"+ + "#\f#\u01fb\t#\u0003#\u01fd\b#\u0001#\u0001#\u0001#\u0001#\u0003#\u0203"+ + "\b#\u0001#\u0001#\u0001#\u0001#\u0001#\u0001#\u0001#\u0001#\u0005#\u020d"+ + "\b#\n#\f#\u0210\t#\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0001"+ + "$\u0001$\u0005$\u021b\b$\n$\f$\u021e\t$\u0003$\u0220\b$\u0001$\u0001$"+ + "\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0005$\u022b\b$\n$\f"+ + "$\u022e\t$\u0003$\u0230\b$\u0001$\u0001$\u0001$\u0003$\u0235\b$\u0001"+ + "$\u0000\u0002DF%\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014"+ + "\u0016\u0018\u001a\u001c\u001e \"$&(*,.02468:<>@BDFH\u0000\u0005\u0001"+ + "\u0000WX\u0001\u0000UV\u0001\u0000Y\\\u0001\u0000]^\u0001\u0000DE\u0281"+ + "\u0000k\u0001\u0000\u0000\u0000\u0002m\u0001\u0000\u0000\u0000\u0004q"+ + "\u0001\u0000\u0000\u0000\u0006u\u0001\u0000\u0000\u0000\by\u0001\u0000"+ + "\u0000\u0000\n\u0080\u0001\u0000\u0000\u0000\f\u0085\u0001\u0000\u0000"+ + "\u0000\u000e\u008a\u0001\u0000\u0000\u0000\u0010\u00c4\u0001\u0000\u0000"+ + "\u0000\u0012\u00c8\u0001\u0000\u0000\u0000\u0014\u00cd\u0001\u0000\u0000"+ + "\u0000\u0016\u00cf\u0001\u0000\u0000\u0000\u0018\u00d1\u0001\u0000\u0000"+ + "\u0000\u001a\u00de\u0001\u0000\u0000\u0000\u001c\u00e2\u0001\u0000\u0000"+ + "\u0000\u001e\u00ef\u0001\u0000\u0000\u0000 \u00f9\u0001\u0000\u0000\u0000"+ + "\"\u010d\u0001\u0000\u0000\u0000$\u0117\u0001\u0000\u0000\u0000&\u0119"+ + "\u0001\u0000\u0000\u0000(\u0125\u0001\u0000\u0000\u0000*\u0130\u0001\u0000"+ + "\u0000\u0000,\u0141\u0001\u0000\u0000\u0000.\u0155\u0001\u0000\u0000\u0000"+ + "0\u0160\u0001\u0000\u0000\u00002\u0165\u0001\u0000\u0000\u00004\u0168"+ + "\u0001\u0000\u0000\u00006\u0171\u0001\u0000\u0000\u00008\u0177\u0001\u0000"+ + "\u0000\u0000:\u0189\u0001\u0000\u0000\u0000<\u0191\u0001\u0000\u0000\u0000"+ + ">\u019a\u0001\u0000\u0000\u0000@\u019e\u0001\u0000\u0000\u0000B\u01a1"+ + "\u0001\u0000\u0000\u0000D\u01d3\u0001\u0000\u0000\u0000F\u0202\u0001\u0000"+ + "\u0000\u0000H\u0234\u0001\u0000\u0000\u0000JL\u0003\u0004\u0002\u0000"+ + "KJ\u0001\u0000\u0000\u0000KL\u0001\u0000\u0000\u0000LN\u0001\u0000\u0000"+ + "\u0000MO\u0003\u0006\u0003\u0000NM\u0001\u0000\u0000\u0000NO\u0001\u0000"+ + "\u0000\u0000OT\u0001\u0000\u0000\u0000PS\u0003\b\u0004\u0000QS\u0003\n"+ + "\u0005\u0000RP\u0001\u0000\u0000\u0000RQ\u0001\u0000\u0000\u0000SV\u0001"+ + "\u0000\u0000\u0000TR\u0001\u0000\u0000\u0000TU\u0001\u0000\u0000\u0000"+ + "U[\u0001\u0000\u0000\u0000VT\u0001\u0000\u0000\u0000WZ\u0003\f\u0006\u0000"+ + "XZ\u0003&\u0013\u0000YW\u0001\u0000\u0000\u0000YX\u0001\u0000\u0000\u0000"+ + "Z]\u0001\u0000\u0000\u0000[Y\u0001\u0000\u0000\u0000[\\\u0001\u0000\u0000"+ + "\u0000\\^\u0001\u0000\u0000\u0000][\u0001\u0000\u0000\u0000^c\u0003\u0002"+ + "\u0001\u0000_b\u0003\f\u0006\u0000`b\u0003&\u0013\u0000a_\u0001\u0000"+ + "\u0000\u0000a`\u0001\u0000\u0000\u0000be\u0001\u0000\u0000\u0000ca\u0001"+ + "\u0000\u0000\u0000cd\u0001\u0000\u0000\u0000df\u0001\u0000\u0000\u0000"+ + "ec\u0001\u0000\u0000\u0000fg\u0005\u0000\u0000\u0001gl\u0001\u0000\u0000"+ + "\u0000hi\u0003\u0012\t\u0000ij\u0005\u0000\u0000\u0001jl\u0001\u0000\u0000"+ + "\u0000kK\u0001\u0000\u0000\u0000kh\u0001\u0000\u0000\u0000l\u0001\u0001"+ + "\u0000\u0000\u0000mn\u0005\u0006\u0000\u0000no\u0005\u000b\u0000\u0000"+ + "op\u0003\u0012\t\u0000p\u0003\u0001\u0000\u0000\u0000qr\u0005\u0001\u0000"+ + "\u0000rs\u0005\u000b\u0000\u0000st\u0005\u001b\u0000\u0000t\u0005\u0001"+ + "\u0000\u0000\u0000uv\u0005\u0002\u0000\u0000vw\u0005\u000b\u0000\u0000"+ + "wx\u0005\u001b\u0000\u0000x\u0007\u0001\u0000\u0000\u0000yz\u0005\u0003"+ + "\u0000\u0000z{\u0005\u000b\u0000\u0000{~\u0005\u0016\u0000\u0000|}\u0005"+ + "\f\u0000\u0000}\u007f\u0005\u0016\u0000\u0000~|\u0001\u0000\u0000\u0000"+ + "~\u007f\u0001\u0000\u0000\u0000\u007f\t\u0001\u0000\u0000\u0000\u0080"+ + "\u0081\u0005\u0004\u0000\u0000\u0081\u0082\u0005\u0016\u0000\u0000\u0082"+ + "\u0083\u0005\u000b\u0000\u0000\u0083\u0084\u0003$\u0012\u0000\u0084\u000b"+ + "\u0001\u0000\u0000\u0000\u0085\u0086\u0005\u0005\u0000\u0000\u0086\u0087"+ + "\u0003\u000e\u0007\u0000\u0087\u0088\u0005\u000b\u0000\u0000\u0088\u0089"+ + "\u0003\u0010\b\u0000\u0089\r\u0001\u0000\u0000\u0000\u008a\u008b\u0005"+ + "\u0017\u0000\u0000\u008b\u000f\u0001\u0000\u0000\u0000\u008c\u0090\u0003"+ + "\u0014\n\u0000\u008d\u008f\u0003 \u0010\u0000\u008e\u008d\u0001\u0000"+ + "\u0000\u0000\u008f\u0092\u0001\u0000\u0000\u0000\u0090\u008e\u0001\u0000"+ + "\u0000\u0000\u0090\u0091\u0001\u0000\u0000\u0000\u0091\u0096\u0001\u0000"+ + "\u0000\u0000\u0092\u0090\u0001\u0000\u0000\u0000\u0093\u0095\u0003\u001e"+ + "\u000f\u0000\u0094\u0093\u0001\u0000\u0000\u0000\u0095\u0098\u0001\u0000"+ + "\u0000\u0000\u0096\u0094\u0001\u0000\u0000\u0000\u0096\u0097\u0001\u0000"+ + "\u0000\u0000\u0097\u009c\u0001\u0000\u0000\u0000\u0098\u0096\u0001\u0000"+ + "\u0000\u0000\u0099\u009b\u0003\u0016\u000b\u0000\u009a\u0099\u0001\u0000"+ + "\u0000\u0000\u009b\u009e\u0001\u0000\u0000\u0000\u009c\u009a\u0001\u0000"+ + "\u0000\u0000\u009c\u009d\u0001\u0000\u0000\u0000\u009d\u00a0\u0001\u0000"+ + "\u0000\u0000\u009e\u009c\u0001\u0000\u0000\u0000\u009f\u00a1\u0005\u0014"+ + "\u0000\u0000\u00a0\u009f\u0001\u0000\u0000\u0000\u00a0\u00a1\u0001\u0000"+ + "\u0000\u0000\u00a1\u00c5\u0001\u0000\u0000\u0000\u00a2\u00a4\u0003 \u0010"+ + "\u0000\u00a3\u00a2\u0001\u0000\u0000\u0000\u00a4\u00a5\u0001\u0000\u0000"+ + "\u0000\u00a5\u00a3\u0001\u0000\u0000\u0000\u00a5\u00a6\u0001\u0000\u0000"+ + "\u0000\u00a6\u00aa\u0001\u0000\u0000\u0000\u00a7\u00a9\u0003\u001e\u000f"+ + "\u0000\u00a8\u00a7\u0001\u0000\u0000\u0000\u00a9\u00ac\u0001\u0000\u0000"+ + "\u0000\u00aa\u00a8\u0001\u0000\u0000\u0000\u00aa\u00ab\u0001\u0000\u0000"+ + "\u0000\u00ab\u00b0\u0001\u0000\u0000\u0000\u00ac\u00aa\u0001\u0000\u0000"+ + "\u0000\u00ad\u00af\u0003\u0016\u000b\u0000\u00ae\u00ad\u0001\u0000\u0000"+ + "\u0000\u00af\u00b2\u0001\u0000\u0000\u0000\u00b0\u00ae\u0001\u0000\u0000"+ + "\u0000\u00b0\u00b1\u0001\u0000\u0000\u0000\u00b1\u00b4\u0001\u0000\u0000"+ + "\u0000\u00b2\u00b0\u0001\u0000\u0000\u0000\u00b3\u00b5\u0005\u0014\u0000"+ + "\u0000\u00b4\u00b3\u0001\u0000\u0000\u0000\u00b4\u00b5\u0001\u0000\u0000"+ + "\u0000\u00b5\u00c5\u0001\u0000\u0000\u0000\u00b6\u00b8\u0003\u001e\u000f"+ + "\u0000\u00b7\u00b6\u0001\u0000\u0000\u0000\u00b8\u00b9\u0001\u0000\u0000"+ + "\u0000\u00b9\u00b7\u0001\u0000\u0000\u0000\u00b9\u00ba\u0001\u0000\u0000"+ + "\u0000\u00ba\u00be\u0001\u0000\u0000\u0000\u00bb\u00bd\u0003\u0016\u000b"+ + "\u0000\u00bc\u00bb\u0001\u0000\u0000\u0000\u00bd\u00c0\u0001\u0000\u0000"+ + "\u0000\u00be\u00bc\u0001\u0000\u0000\u0000\u00be\u00bf\u0001\u0000\u0000"+ + "\u0000\u00bf\u00c2\u0001\u0000\u0000\u0000\u00c0\u00be\u0001\u0000\u0000"+ + "\u0000\u00c1\u00c3\u0005\u0014\u0000\u0000\u00c2\u00c1\u0001\u0000\u0000"+ + "\u0000\u00c2\u00c3\u0001\u0000\u0000\u0000\u00c3\u00c5\u0001\u0000\u0000"+ + "\u0000\u00c4\u008c\u0001\u0000\u0000\u0000\u00c4\u00a3\u0001\u0000\u0000"+ + "\u0000\u00c4\u00b7\u0001\u0000\u0000\u0000\u00c5\u0011\u0001\u0000\u0000"+ + "\u0000\u00c6\u00c9\u0003\u0010\b\u0000\u00c7\u00c9\u0003\u000e\u0007\u0000"+ + "\u00c8\u00c6\u0001\u0000\u0000\u0000\u00c8\u00c7\u0001\u0000\u0000\u0000"+ + "\u00c9\u0013\u0001\u0000\u0000\u0000\u00ca\u00ce\u0003$\u0012\u0000\u00cb"+ + "\u00ce\u0003\u0018\f\u0000\u00cc\u00ce\u0003\u001c\u000e\u0000\u00cd\u00ca"+ + "\u0001\u0000\u0000\u0000\u00cd\u00cb\u0001\u0000\u0000\u0000\u00cd\u00cc"+ + "\u0001\u0000\u0000\u0000\u00ce\u0015\u0001\u0000\u0000\u0000\u00cf\u00d0"+ + "\u0005\u001a\u0000\u0000\u00d0\u0017\u0001\u0000\u0000\u0000\u00d1\u00da"+ + "\u0005\u000e\u0000\u0000\u00d2\u00d7\u0003\u001a\r\u0000\u00d3\u00d4\u0005"+ + "\f\u0000\u0000\u00d4\u00d6\u0003\u001a\r\u0000\u00d5\u00d3\u0001\u0000"+ + "\u0000\u0000\u00d6\u00d9\u0001\u0000\u0000\u0000\u00d7\u00d5\u0001\u0000"+ + "\u0000\u0000\u00d7\u00d8\u0001\u0000\u0000\u0000\u00d8\u00db\u0001\u0000"+ + "\u0000\u0000\u00d9\u00d7\u0001\u0000\u0000\u0000\u00da\u00d2\u0001\u0000"+ + "\u0000\u0000\u00da\u00db\u0001\u0000\u0000\u0000\u00db\u00dc\u0001\u0000"+ + "\u0000\u0000\u00dc\u00dd\u0005\u000f\u0000\u0000\u00dd\u0019\u0001\u0000"+ + "\u0000\u0000\u00de\u00df\u0005\u001b\u0000\u0000\u00df\u00e0\u0005\u000b"+ + "\u0000\u0000\u00e0\u00e1\u0003\u0012\t\u0000\u00e1\u001b\u0001\u0000\u0000"+ + "\u0000\u00e2\u00eb\u0005\u0010\u0000\u0000\u00e3\u00e8\u0003\u0012\t\u0000"+ + "\u00e4\u00e5\u0005\f\u0000\u0000\u00e5\u00e7\u0003\u0012\t\u0000\u00e6"+ + "\u00e4\u0001\u0000\u0000\u0000\u00e7\u00ea\u0001\u0000\u0000\u0000\u00e8"+ + "\u00e6\u0001\u0000\u0000\u0000\u00e8\u00e9\u0001\u0000\u0000\u0000\u00e9"+ + "\u00ec\u0001\u0000\u0000\u0000\u00ea\u00e8\u0001\u0000\u0000\u0000\u00eb"+ + "\u00e3\u0001\u0000\u0000\u0000\u00eb\u00ec\u0001\u0000\u0000\u0000\u00ec"+ + "\u00ed\u0001\u0000\u0000\u0000\u00ed\u00ee\u0005\u0011\u0000\u0000\u00ee"+ + "\u001d\u0001\u0000\u0000\u0000\u00ef\u00f1\u0005\u0018\u0000\u0000\u00f0"+ + "\u00f2\u0005\r\u0000\u0000\u00f1\u00f0\u0001\u0000\u0000\u0000\u00f1\u00f2"+ + "\u0001\u0000\u0000\u0000\u00f2\u00f7\u0001\u0000\u0000\u0000\u00f3\u00f4"+ + "\u0005\u0012\u0000\u0000\u00f4\u00f5\u0003\u000e\u0007\u0000\u00f5\u00f6"+ + "\u0005\u0013\u0000\u0000\u00f6\u00f8\u0001\u0000\u0000\u0000\u00f7\u00f3"+ + "\u0001\u0000\u0000\u0000\u00f7\u00f8\u0001\u0000\u0000\u0000\u00f8\u001f"+ + "\u0001\u0000\u0000\u0000\u00f9\u00fb\u0005\u0019\u0000\u0000\u00fa\u00fc"+ + "\u0005\r\u0000\u0000\u00fb\u00fa\u0001\u0000\u0000\u0000\u00fb\u00fc\u0001"+ + "\u0000\u0000\u0000\u00fc\u0109\u0001\u0000\u0000\u0000\u00fd\u0106\u0005"+ + "\u0012\u0000\u0000\u00fe\u0103\u0003\"\u0011\u0000\u00ff\u0100\u0005\f"+ + "\u0000\u0000\u0100\u0102\u0003\"\u0011\u0000\u0101\u00ff\u0001\u0000\u0000"+ + "\u0000\u0102\u0105\u0001\u0000\u0000\u0000\u0103\u0101\u0001\u0000\u0000"+ + "\u0000\u0103\u0104\u0001\u0000\u0000\u0000\u0104\u0107\u0001\u0000\u0000"+ + "\u0000\u0105\u0103\u0001\u0000\u0000\u0000\u0106\u00fe\u0001\u0000\u0000"+ + "\u0000\u0106\u0107\u0001\u0000\u0000\u0000\u0107\u0108\u0001\u0000\u0000"+ + "\u0000\u0108\u010a\u0005\u0013\u0000\u0000\u0109\u00fd\u0001\u0000\u0000"+ + "\u0000\u0109\u010a\u0001\u0000\u0000\u0000\u010a!\u0001\u0000\u0000\u0000"+ + "\u010b\u010e\u0003\u0014\n\u0000\u010c\u010e\u0003\u0016\u000b\u0000\u010d"+ + "\u010b\u0001\u0000\u0000\u0000\u010d\u010c\u0001\u0000\u0000\u0000\u010e"+ + "#\u0001\u0000\u0000\u0000\u010f\u0118\u0005\b\u0000\u0000\u0110\u0118"+ + "\u0005\t\u0000\u0000\u0111\u0118\u0005\u001b\u0000\u0000\u0112\u0118\u0005"+ + "\u001c\u0000\u0000\u0113\u0118\u0005\u001d\u0000\u0000\u0114\u0118\u0005"+ + "\u001e\u0000\u0000\u0115\u0118\u0005\n\u0000\u0000\u0116\u0118\u0005\u0015"+ + "\u0000\u0000\u0117\u010f\u0001\u0000\u0000\u0000\u0117\u0110\u0001\u0000"+ + "\u0000\u0000\u0117\u0111\u0001\u0000\u0000\u0000\u0117\u0112\u0001\u0000"+ + "\u0000\u0000\u0117\u0113\u0001\u0000\u0000\u0000\u0117\u0114\u0001\u0000"+ + "\u0000\u0000\u0117\u0115\u0001\u0000\u0000\u0000\u0117\u0116\u0001\u0000"+ + "\u0000\u0000\u0118%\u0001\u0000\u0000\u0000\u0119\u011a\u0005\u0007\u0000"+ + "\u0000\u011a\u011b\u0005O\u0000\u0000\u011b\u011d\u0005F\u0000\u0000\u011c"+ + "\u011e\u0003(\u0014\u0000\u011d\u011c\u0001\u0000\u0000\u0000\u011e\u011f"+ + "\u0001\u0000\u0000\u0000\u011f\u011d\u0001\u0000\u0000\u0000\u011f\u0120"+ + "\u0001\u0000\u0000\u0000\u0120\u0121\u0001\u0000\u0000\u0000\u0121\u0122"+ + "\u0005G\u0000\u0000\u0122\'\u0001\u0000\u0000\u0000\u0123\u0126\u0003"+ + ",\u0016\u0000\u0124\u0126\u0003.\u0017\u0000\u0125\u0123\u0001\u0000\u0000"+ + "\u0000\u0125\u0124\u0001\u0000\u0000\u0000\u0126)\u0001\u0000\u0000\u0000"+ + "\u0127\u0131\u0003.\u0017\u0000\u0128\u0131\u00032\u0019\u0000\u0129\u0131"+ + "\u00034\u001a\u0000\u012a\u0131\u00036\u001b\u0000\u012b\u0131\u00038"+ + "\u001c\u0000\u012c\u0131\u0003<\u001e\u0000\u012d\u0131\u0003>\u001f\u0000"+ + "\u012e\u0131\u0003@ \u0000\u012f\u0131\u0003B!\u0000\u0130\u0127\u0001"+ + "\u0000\u0000\u0000\u0130\u0128\u0001\u0000\u0000\u0000\u0130\u0129\u0001"+ + "\u0000\u0000\u0000\u0130\u012a\u0001\u0000\u0000\u0000\u0130\u012b\u0001"+ + "\u0000\u0000\u0000\u0130\u012c\u0001\u0000\u0000\u0000\u0130\u012d\u0001"+ + "\u0000\u0000\u0000\u0130\u012e\u0001\u0000\u0000\u0000\u0130\u012f\u0001"+ + "\u0000\u0000\u0000\u0131+\u0001\u0000\u0000\u0000\u0132\u0134\u0005*\u0000"+ + "\u0000\u0133\u0135\u00050\u0000\u0000\u0134\u0133\u0001\u0000\u0000\u0000"+ + "\u0134\u0135\u0001\u0000\u0000\u0000\u0135\u0142\u0001\u0000\u0000\u0000"+ + "\u0136\u0138\u00052\u0000\u0000\u0137\u0139\u0005*\u0000\u0000\u0138\u0137"+ + "\u0001\u0000\u0000\u0000\u0138\u0139\u0001\u0000\u0000\u0000\u0139\u013b"+ + "\u0001\u0000\u0000\u0000\u013a\u013c\u00050\u0000\u0000\u013b\u013a\u0001"+ + "\u0000\u0000\u0000\u013b\u013c\u0001\u0000\u0000\u0000\u013c\u0142\u0001"+ + "\u0000\u0000\u0000\u013d\u013f\u0005-\u0000\u0000\u013e\u0140\u00050\u0000"+ + "\u0000\u013f\u013e\u0001\u0000\u0000\u0000\u013f\u0140\u0001\u0000\u0000"+ + "\u0000\u0140\u0142\u0001\u0000\u0000\u0000\u0141\u0132\u0001\u0000\u0000"+ + "\u0000\u0141\u0136\u0001\u0000\u0000\u0000\u0141\u013d\u0001\u0000\u0000"+ + "\u0000\u0142\u0143\u0001\u0000\u0000\u0000\u0143\u0144\u0005E\u0000\u0000"+ + "\u0144\u0150\u0005J\u0000\u0000\u0145\u014a\u0005E\u0000\u0000\u0146\u0147"+ + "\u0005M\u0000\u0000\u0147\u0149\u0005E\u0000\u0000\u0148\u0146\u0001\u0000"+ + "\u0000\u0000\u0149\u014c\u0001\u0000\u0000\u0000\u014a\u0148\u0001\u0000"+ + "\u0000\u0000\u014a\u014b\u0001\u0000\u0000\u0000\u014b\u014e\u0001\u0000"+ + "\u0000\u0000\u014c\u014a\u0001\u0000\u0000\u0000\u014d\u014f\u0005Q\u0000"+ + "\u0000\u014e\u014d\u0001\u0000\u0000\u0000\u014e\u014f\u0001\u0000\u0000"+ + "\u0000\u014f\u0151\u0001\u0000\u0000\u0000\u0150\u0145\u0001\u0000\u0000"+ + "\u0000\u0150\u0151\u0001\u0000\u0000\u0000\u0151\u0152\u0001\u0000\u0000"+ + "\u0000\u0152\u0153\u0005K\u0000\u0000\u0153\u0154\u0003B!\u0000\u0154"+ + "-\u0001\u0000\u0000\u0000\u0155\u0156\u0005\"\u0000\u0000\u0156\u015b"+ + "\u00030\u0018\u0000\u0157\u0158\u0005M\u0000\u0000\u0158\u015a\u00030"+ + "\u0018\u0000\u0159\u0157\u0001\u0000\u0000\u0000\u015a\u015d\u0001\u0000"+ + "\u0000\u0000\u015b\u0159\u0001\u0000\u0000\u0000\u015b\u015c\u0001\u0000"+ + "\u0000\u0000\u015c\u015e\u0001\u0000\u0000\u0000\u015d\u015b\u0001\u0000"+ + "\u0000\u0000\u015e\u015f\u0005L\u0000\u0000\u015f/\u0001\u0000\u0000\u0000"+ + "\u0160\u0163\u0005E\u0000\u0000\u0161\u0162\u0005R\u0000\u0000\u0162\u0164"+ + "\u0003D\"\u0000\u0163\u0161\u0001\u0000\u0000\u0000\u0163\u0164\u0001"+ + "\u0000\u0000\u0000\u01641\u0001\u0000\u0000\u0000\u0165\u0166\u0003D\""+ + "\u0000\u0166\u0167\u0005L\u0000\u0000\u01673\u0001\u0000\u0000\u0000\u0168"+ + "\u0169\u0005#\u0000\u0000\u0169\u016a\u0005J\u0000\u0000\u016a\u016b\u0003"+ + "D\"\u0000\u016b\u016c\u0005K\u0000\u0000\u016c\u016f\u0003*\u0015\u0000"+ + "\u016d\u016e\u0005$\u0000\u0000\u016e\u0170\u0003*\u0015\u0000\u016f\u016d"+ + "\u0001\u0000\u0000\u0000\u016f\u0170\u0001\u0000\u0000\u0000\u01705\u0001"+ + "\u0000\u0000\u0000\u0171\u0172\u0005%\u0000\u0000\u0172\u0173\u0005J\u0000"+ + "\u0000\u0173\u0174\u0003D\"\u0000\u0174\u0175\u0005K\u0000\u0000\u0175"+ + "\u0176\u0003*\u0015\u0000\u01767\u0001\u0000\u0000\u0000\u0177\u0178\u0005"+ + "&\u0000\u0000\u0178\u017d\u0005J\u0000\u0000\u0179\u017e\u0003.\u0017"+ + "\u0000\u017a\u017b\u0003:\u001d\u0000\u017b\u017c\u0005L\u0000\u0000\u017c"+ + "\u017e\u0001\u0000\u0000\u0000\u017d\u0179\u0001\u0000\u0000\u0000\u017d"+ + "\u017a\u0001\u0000\u0000\u0000\u017d\u017e\u0001\u0000\u0000\u0000\u017e"+ + "\u0180\u0001\u0000\u0000\u0000\u017f\u0181\u0003D\"\u0000\u0180\u017f"+ + "\u0001\u0000\u0000\u0000\u0180\u0181\u0001\u0000\u0000\u0000\u0181\u0182"+ + "\u0001\u0000\u0000\u0000\u0182\u0184\u0005L\u0000\u0000\u0183\u0185\u0003"+ + ":\u001d\u0000\u0184\u0183\u0001\u0000\u0000\u0000\u0184\u0185\u0001\u0000"+ + "\u0000\u0000\u0185\u0186\u0001\u0000\u0000\u0000\u0186\u0187\u0005K\u0000"+ + "\u0000\u0187\u0188\u0003*\u0015\u0000\u01889\u0001\u0000\u0000\u0000\u0189"+ + "\u018e\u0003D\"\u0000\u018a\u018b\u0005M\u0000\u0000\u018b\u018d\u0003"+ + "D\"\u0000\u018c\u018a\u0001\u0000\u0000\u0000\u018d\u0190\u0001\u0000"+ + "\u0000\u0000\u018e\u018c\u0001\u0000\u0000\u0000\u018e\u018f\u0001\u0000"+ + "\u0000\u0000\u018f;\u0001\u0000\u0000\u0000\u0190\u018e\u0001\u0000\u0000"+ + "\u0000\u0191\u0192\u0005\'\u0000\u0000\u0192\u0193\u0005J\u0000\u0000"+ + "\u0193\u0194\u0005\"\u0000\u0000\u0194\u0195\u0005E\u0000\u0000\u0195"+ + "\u0196\u0005(\u0000\u0000\u0196\u0197\u0003D\"\u0000\u0197\u0198\u0005"+ + "K\u0000\u0000\u0198\u0199\u0003*\u0015\u0000\u0199=\u0001\u0000\u0000"+ + "\u0000\u019a\u019b\u00051\u0000\u0000\u019b\u019c\u0003D\"\u0000\u019c"+ + "\u019d\u0005L\u0000\u0000\u019d?\u0001\u0000\u0000\u0000\u019e\u019f\u0005"+ + ")\u0000\u0000\u019f\u01a0\u0005L\u0000\u0000\u01a0A\u0001\u0000\u0000"+ + "\u0000\u01a1\u01a5\u0005F\u0000\u0000\u01a2\u01a4\u0003*\u0015\u0000\u01a3"+ + "\u01a2\u0001\u0000\u0000\u0000\u01a4\u01a7\u0001\u0000\u0000\u0000\u01a5"+ + "\u01a3\u0001\u0000\u0000\u0000\u01a5\u01a6\u0001\u0000\u0000\u0000\u01a6"+ + "\u01a8\u0001\u0000\u0000\u0000\u01a7\u01a5\u0001\u0000\u0000\u0000\u01a8"+ + "\u01a9\u0005G\u0000\u0000\u01a9C\u0001\u0000\u0000\u0000\u01aa\u01ab\u0006"+ + "\"\uffff\uffff\u0000\u01ab\u01d4\u0003F#\u0000\u01ac\u01ad\u0005V\u0000"+ + "\u0000\u01ad\u01d4\u0003D\"\u0013\u01ae\u01af\u0005_\u0000\u0000\u01af"+ + "\u01d4\u0003D\"\u0012\u01b0\u01b1\u0003F#\u0000\u01b1\u01b2\u0005S\u0000"+ + "\u0000\u01b2\u01d4\u0001\u0000\u0000\u0000\u01b3\u01b4\u0003F#\u0000\u01b4"+ + "\u01b5\u0005T\u0000\u0000\u01b5\u01d4\u0001\u0000\u0000\u0000\u01b6\u01b7"+ + "\u0005S\u0000\u0000\u01b7\u01d4\u0003F#\u0000\u01b8\u01b9\u0005T\u0000"+ + "\u0000\u01b9\u01d4\u0003F#\u0000\u01ba\u01bb\u0005P\u0000\u0000\u01bb"+ + "\u01d4\u0003D\"\n\u01bc\u01bd\u0003F#\u0000\u01bd\u01be\u0005R\u0000\u0000"+ + "\u01be\u01bf\u0003D\"\u0005\u01bf\u01d4\u0001\u0000\u0000\u0000\u01c0"+ + "\u01d4\u0003H$\u0000\u01c1\u01c2\u0005J\u0000\u0000\u01c2\u01c3\u0003"+ + "D\"\u0000\u01c3\u01c4\u0005K\u0000\u0000\u01c4\u01d4\u0001\u0000\u0000"+ + "\u0000\u01c5\u01c6\u0005.\u0000\u0000\u01c6\u01c7\u0005J\u0000\u0000\u01c7"+ + "\u01c8\u0003D\"\u0000\u01c8\u01c9\u0005K\u0000\u0000\u01c9\u01d4\u0001"+ + "\u0000\u0000\u0000\u01ca\u01cb\u0005/\u0000\u0000\u01cb\u01cc\u0005J\u0000"+ + "\u0000\u01cc\u01cf\u0003D\"\u0000\u01cd\u01ce\u0005M\u0000\u0000\u01ce"+ + "\u01d0\u0003D\"\u0000\u01cf\u01cd\u0001\u0000\u0000\u0000\u01cf\u01d0"+ + "\u0001\u0000\u0000\u0000\u01d0\u01d1\u0001\u0000\u0000\u0000\u01d1\u01d2"+ + "\u0005K\u0000\u0000\u01d2\u01d4\u0001\u0000\u0000\u0000\u01d3\u01aa\u0001"+ + "\u0000\u0000\u0000\u01d3\u01ac\u0001\u0000\u0000\u0000\u01d3\u01ae\u0001"+ + "\u0000\u0000\u0000\u01d3\u01b0\u0001\u0000\u0000\u0000\u01d3\u01b3\u0001"+ + "\u0000\u0000\u0000\u01d3\u01b6\u0001\u0000\u0000\u0000\u01d3\u01b8\u0001"+ + "\u0000\u0000\u0000\u01d3\u01ba\u0001\u0000\u0000\u0000\u01d3\u01bc\u0001"+ + "\u0000\u0000\u0000\u01d3\u01c0\u0001\u0000\u0000\u0000\u01d3\u01c1\u0001"+ + "\u0000\u0000\u0000\u01d3\u01c5\u0001\u0000\u0000\u0000\u01d3\u01ca\u0001"+ + "\u0000\u0000\u0000\u01d4\u01ee\u0001\u0000\u0000\u0000\u01d5\u01d6\n\r"+ + "\u0000\u0000\u01d6\u01d7\u0007\u0000\u0000\u0000\u01d7\u01ed\u0003D\""+ + "\u000e\u01d8\u01d9\n\f\u0000\u0000\u01d9\u01da\u0007\u0001\u0000\u0000"+ + "\u01da\u01ed\u0003D\"\r\u01db\u01dc\n\t\u0000\u0000\u01dc\u01dd\u0007"+ + "\u0002\u0000\u0000\u01dd\u01ed\u0003D\"\n\u01de\u01df\n\b\u0000\u0000"+ + "\u01df\u01e0\u0007\u0003\u0000\u0000\u01e0\u01ed\u0003D\"\t\u01e1\u01e2"+ + "\n\u0007\u0000\u0000\u01e2\u01e3\u0005`\u0000\u0000\u01e3\u01ed\u0003"+ + "D\"\b\u01e4\u01e5\n\u0006\u0000\u0000\u01e5\u01e6\u0005a\u0000\u0000\u01e6"+ + "\u01ed\u0003D\"\u0007\u01e7\u01e8\n\u000b\u0000\u0000\u01e8\u01ea\u0005"+ + "P\u0000\u0000\u01e9\u01eb\u0003D\"\u0000\u01ea\u01e9\u0001\u0000\u0000"+ + "\u0000\u01ea\u01eb\u0001\u0000\u0000\u0000\u01eb\u01ed\u0001\u0000\u0000"+ + "\u0000\u01ec\u01d5\u0001\u0000\u0000\u0000\u01ec\u01d8\u0001\u0000\u0000"+ + "\u0000\u01ec\u01db\u0001\u0000\u0000\u0000\u01ec\u01de\u0001\u0000\u0000"+ + "\u0000\u01ec\u01e1\u0001\u0000\u0000\u0000\u01ec\u01e4\u0001\u0000\u0000"+ + "\u0000\u01ec\u01e7\u0001\u0000\u0000\u0000\u01ed\u01f0\u0001\u0000\u0000"+ + "\u0000\u01ee\u01ec\u0001\u0000\u0000\u0000\u01ee\u01ef\u0001\u0000\u0000"+ + "\u0000\u01efE\u0001\u0000\u0000\u0000\u01f0\u01ee\u0001\u0000\u0000\u0000"+ + "\u01f1\u01f2\u0006#\uffff\uffff\u0000\u01f2\u01f3\u0005E\u0000\u0000\u01f3"+ + "\u01fc\u0005J\u0000\u0000\u01f4\u01f9\u0003D\"\u0000\u01f5\u01f6\u0005"+ + "M\u0000\u0000\u01f6\u01f8\u0003D\"\u0000\u01f7\u01f5\u0001\u0000\u0000"+ + "\u0000\u01f8\u01fb\u0001\u0000\u0000\u0000\u01f9\u01f7\u0001\u0000\u0000"+ + "\u0000\u01f9\u01fa\u0001\u0000\u0000\u0000\u01fa\u01fd\u0001\u0000\u0000"+ + "\u0000\u01fb\u01f9\u0001\u0000\u0000\u0000\u01fc\u01f4\u0001\u0000\u0000"+ + "\u0000\u01fc\u01fd\u0001\u0000\u0000\u0000\u01fd\u01fe\u0001\u0000\u0000"+ + "\u0000\u01fe\u0203\u0005K\u0000\u0000\u01ff\u0203\u0005+\u0000\u0000\u0200"+ + "\u0203\u0005,\u0000\u0000\u0201\u0203\u0005E\u0000\u0000\u0202\u01f1\u0001"+ + "\u0000\u0000\u0000\u0202\u01ff\u0001\u0000\u0000\u0000\u0202\u0200\u0001"+ + "\u0000\u0000\u0000\u0202\u0201\u0001\u0000\u0000\u0000\u0203\u020e\u0001"+ + "\u0000\u0000\u0000\u0204\u0205\n\u0006\u0000\u0000\u0205\u0206\u0005N"+ + "\u0000\u0000\u0206\u020d\u0005E\u0000\u0000\u0207\u0208\n\u0005\u0000"+ + "\u0000\u0208\u0209\u0005H\u0000\u0000\u0209\u020a\u0003D\"\u0000\u020a"+ + "\u020b\u0005I\u0000\u0000\u020b\u020d\u0001\u0000\u0000\u0000\u020c\u0204"+ + "\u0001\u0000\u0000\u0000\u020c\u0207\u0001\u0000\u0000\u0000\u020d\u0210"+ + "\u0001\u0000\u0000\u0000\u020e\u020c\u0001\u0000\u0000\u0000\u020e\u020f"+ + "\u0001\u0000\u0000\u0000\u020fG\u0001\u0000\u0000\u0000\u0210\u020e\u0001"+ + "\u0000\u0000\u0000\u0211\u0235\u00053\u0000\u0000\u0212\u0235\u00054\u0000"+ + "\u0000\u0213\u0235\u0005B\u0000\u0000\u0214\u0235\u0005C\u0000\u0000\u0215"+ + "\u0235\u0005D\u0000\u0000\u0216\u021f\u0005H\u0000\u0000\u0217\u021c\u0003"+ + "D\"\u0000\u0218\u0219\u0005M\u0000\u0000\u0219\u021b\u0003D\"\u0000\u021a"+ + "\u0218\u0001\u0000\u0000\u0000\u021b\u021e\u0001\u0000\u0000\u0000\u021c"+ + "\u021a\u0001\u0000\u0000\u0000\u021c\u021d\u0001\u0000\u0000\u0000\u021d"+ + "\u0220\u0001\u0000\u0000\u0000\u021e\u021c\u0001\u0000\u0000\u0000\u021f"+ + "\u0217\u0001\u0000\u0000\u0000\u021f\u0220\u0001\u0000\u0000\u0000\u0220"+ + "\u0221\u0001\u0000\u0000\u0000\u0221\u0235\u0005I\u0000\u0000\u0222\u022f"+ + "\u0005F\u0000\u0000\u0223\u0224\u0007\u0004\u0000\u0000\u0224\u0225\u0005"+ + "O\u0000\u0000\u0225\u022c\u0003D\"\u0000\u0226\u0227\u0005M\u0000\u0000"+ + "\u0227\u0228\u0007\u0004\u0000\u0000\u0228\u0229\u0005O\u0000\u0000\u0229"+ + "\u022b\u0003D\"\u0000\u022a\u0226\u0001\u0000\u0000\u0000\u022b\u022e"+ + "\u0001\u0000\u0000\u0000\u022c\u022a\u0001\u0000\u0000\u0000\u022c\u022d"+ + "\u0001\u0000\u0000\u0000\u022d\u0230\u0001\u0000\u0000\u0000\u022e\u022c"+ + "\u0001\u0000\u0000\u0000\u022f\u0223\u0001\u0000\u0000\u0000\u022f\u0230"+ + "\u0001\u0000\u0000\u0000\u0230\u0231\u0001\u0000\u0000\u0000\u0231\u0235"+ + "\u0005G\u0000\u0000\u0232\u0235\u00055\u0000\u0000\u0233\u0235\u00056"+ + "\u0000\u0000\u0234\u0211\u0001\u0000\u0000\u0000\u0234\u0212\u0001\u0000"+ + "\u0000\u0000\u0234\u0213\u0001\u0000\u0000\u0000\u0234\u0214\u0001\u0000"+ + "\u0000\u0000\u0234\u0215\u0001\u0000\u0000\u0000\u0234\u0216\u0001\u0000"+ + "\u0000\u0000\u0234\u0222\u0001\u0000\u0000\u0000\u0234\u0232\u0001\u0000"+ + "\u0000\u0000\u0234\u0233\u0001\u0000\u0000\u0000\u0235I\u0001\u0000\u0000"+ + "\u0000FKNRTY[ack~\u0090\u0096\u009c\u00a0\u00a5\u00aa\u00b0\u00b4\u00b9"+ + "\u00be\u00c2\u00c4\u00c8\u00cd\u00d7\u00da\u00e8\u00eb\u00f1\u00f7\u00fb"+ + "\u0103\u0106\u0109\u010d\u0117\u011f\u0125\u0130\u0134\u0138\u013b\u013f"+ + "\u0141\u014a\u014e\u0150\u015b\u0163\u016f\u017d\u0180\u0184\u018e\u01a5"+ + "\u01cf\u01d3\u01ea\u01ec\u01ee\u01f9\u01fc\u0202\u020c\u020e\u021c\u021f"+ + "\u022c\u022f\u0234"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.tokens b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.tokens new file mode 100644 index 0000000..4de9797 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.tokens @@ -0,0 +1,152 @@ +TITLE=1 +VERSION=2 +IMPORT=3 +PRAGMA=4 +DEFINE=5 +SCHEMA=6 +SCRIPT=7 +TRUE=8 +FALSE=9 +NULL=10 +COLON=11 +COMMA=12 +STAR=13 +LBRACE=14 +RBRACE=15 +LBRACKET=16 +RBRACKET=17 +LPAREN=18 +RPAREN=19 +OPTIONAL=20 +UNDEFINED=21 +FULL_IDENTIFIER=22 +ALIAS=23 +DATATYPE=24 +FUNCTION=25 +RECEIVER=26 +STRING=27 +INTEGER=28 +FLOAT=29 +DOUBLE=30 +WHITE_SPACE=31 +BLOCK_COMMENT=32 +LINE_COMMENT=33 +G_VAR=34 +G_IF=35 +G_ELSE=36 +G_WHILE=37 +G_FOR=38 +G_FOREACH=39 +G_IN=40 +G_BREAK=41 +G_CONSTRAINT=42 +G_TARGET=43 +G_CALLER=44 +G_SUBROUTINE=45 +G_TRYOF=46 +G_THROW=47 +G_FUNCTION=48 +G_RETURN=49 +G_FUTURE=50 +G_TRUE=51 +G_FALSE=52 +G_NULL=53 +G_UNDEFINED=54 +G_THIS=55 +G_NEW=56 +G_CONTINUE=57 +G_DO=58 +G_CONST=59 +G_SWITCH=60 +G_CASE=61 +G_IMPORT=62 +G_CLASS=63 +G_SUPER=64 +G_DEFAULT=65 +G_INTEGER=66 +G_DOUBLE=67 +G_STRING=68 +G_IDENTIFIER=69 +G_LBRACE=70 +G_RBRACE=71 +G_LBRACKET=72 +G_RBRACKET=73 +G_LPAREN=74 +G_RPAREN=75 +G_SEMI=76 +G_COMMA=77 +G_DOT=78 +G_COLON=79 +G_RANGE=80 +G_ELLIPSIS=81 +G_ASSIGN=82 +G_INC=83 +G_DEC=84 +G_PLUS=85 +G_MINUS=86 +G_MUL=87 +G_DIV=88 +G_GT=89 +G_LT=90 +G_LE=91 +G_GE=92 +G_EQ=93 +G_NE=94 +G_NOT=95 +G_AND=96 +G_OR=97 +WHITE_SPACE1=98 +BLOCK_COMMENT1=99 +LINE_COMMENT1=100 +'%title'=1 +'%version'=2 +'%import'=3 +'%pragma'=4 +'?'=20 +'var'=34 +'if'=35 +'else'=36 +'while'=37 +'for'=38 +'foreach'=39 +'in'=40 +'break'=41 +'constraint'=42 +'target'=43 +'caller'=44 +'subroutine'=45 +'tryof'=46 +'throw'=47 +'function'=48 +'return'=49 +'future'=50 +'undefined'=54 +'this'=55 +'new'=56 +'continue'=57 +'do'=58 +'const'=59 +'switch'=60 +'case'=61 +'import'=62 +'class'=63 +'super'=64 +'default'=65 +';'=76 +'.'=78 +'..'=80 +'...'=81 +'='=82 +'++'=83 +'--'=84 +'+'=85 +'-'=86 +'/'=88 +'>'=89 +'<'=90 +'<='=91 +'>='=92 +'=='=93 +'!='=94 +'&&'=96 +'||'=97 diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParserBaseVisitor.java b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParserBaseVisitor.java new file mode 100644 index 0000000..d63efcd --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParserBaseVisitor.java @@ -0,0 +1,553 @@ +package com.relogiclabs.jschema.internal.antlr; +import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; + +/** + * This class provides an empty implementation of {@link SchemaParserVisitor}, + * which can be extended to create a visitor which only needs to handle a subset + * of the available methods. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +@SuppressWarnings("CheckReturnValue") +public class SchemaParserBaseVisitor extends AbstractParseTreeVisitor implements SchemaParserVisitor { + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitCompleteSchema(SchemaParser.CompleteSchemaContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitShortSchema(SchemaParser.ShortSchemaContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitSchemaMain(SchemaParser.SchemaMainContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitTitleNode(SchemaParser.TitleNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitVersionNode(SchemaParser.VersionNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitImportNode(SchemaParser.ImportNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPragmaNode(SchemaParser.PragmaNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitDefineNode(SchemaParser.DefineNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitAliasNode(SchemaParser.AliasNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitValidatorMain(SchemaParser.ValidatorMainContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitValidatorNode(SchemaParser.ValidatorNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitValueNode(SchemaParser.ValueNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitReceiverNode(SchemaParser.ReceiverNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitObjectNode(SchemaParser.ObjectNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPropertyNode(SchemaParser.PropertyNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitArrayNode(SchemaParser.ArrayNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitDatatypeNode(SchemaParser.DatatypeNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitFunctionNode(SchemaParser.FunctionNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitArgumentNode(SchemaParser.ArgumentNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveTrue(SchemaParser.PrimitiveTrueContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveFalse(SchemaParser.PrimitiveFalseContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveString(SchemaParser.PrimitiveStringContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveInteger(SchemaParser.PrimitiveIntegerContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveFloat(SchemaParser.PrimitiveFloatContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveDouble(SchemaParser.PrimitiveDoubleContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveNull(SchemaParser.PrimitiveNullContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimitiveUndefined(SchemaParser.PrimitiveUndefinedContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitScriptNode(SchemaParser.ScriptNodeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitGlobalStatement(SchemaParser.GlobalStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitStatement(SchemaParser.StatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitFunctionDeclaration(SchemaParser.FunctionDeclarationContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitVarStatement(SchemaParser.VarStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitVarInitialization(SchemaParser.VarInitializationContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitExpressionStatement(SchemaParser.ExpressionStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitIfStatement(SchemaParser.IfStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitWhileStatement(SchemaParser.WhileStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitForStatement(SchemaParser.ForStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitExpressionList(SchemaParser.ExpressionListContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitForeachStatement(SchemaParser.ForeachStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitReturnStatement(SchemaParser.ReturnStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitBreakStatement(SchemaParser.BreakStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitBlockStatement(SchemaParser.BlockStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitRangeEndExpression(SchemaParser.RangeEndExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitParenthesizedExpression(SchemaParser.ParenthesizedExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPostIncrementExpression(SchemaParser.PostIncrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitAdditiveExpression(SchemaParser.AdditiveExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitRelationalExpression(SchemaParser.RelationalExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitLogicalAndExpression(SchemaParser.LogicalAndExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPreDecrementExpression(SchemaParser.PreDecrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPreIncrementExpression(SchemaParser.PreIncrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitLiteralExpression(SchemaParser.LiteralExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitLogicalOrExpression(SchemaParser.LogicalOrExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitLogicalNotExpression(SchemaParser.LogicalNotExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitThrowExpression(SchemaParser.ThrowExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitAllRefExpression(SchemaParser.AllRefExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitTryofExpression(SchemaParser.TryofExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitUnaryMinusExpression(SchemaParser.UnaryMinusExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitAssignmentExpression(SchemaParser.AssignmentExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPostDecrementExpression(SchemaParser.PostDecrementExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitEqualityExpression(SchemaParser.EqualityExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitMultiplicativeExpression(SchemaParser.MultiplicativeExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitRangeBothExpression(SchemaParser.RangeBothExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitCallerExpression(SchemaParser.CallerExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitInvokeExpression(SchemaParser.InvokeExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitDotExpression(SchemaParser.DotExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitTargetExpression(SchemaParser.TargetExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitIndexExpression(SchemaParser.IndexExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitIdentifierExpression(SchemaParser.IdentifierExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitTrueLiteral(SchemaParser.TrueLiteralContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitFalseLiteral(SchemaParser.FalseLiteralContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitIntegerLiteral(SchemaParser.IntegerLiteralContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitDoubleLiteral(SchemaParser.DoubleLiteralContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitStringLiteral(SchemaParser.StringLiteralContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitArrayLiteral(SchemaParser.ArrayLiteralContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitObjectLiteral(SchemaParser.ObjectLiteralContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitNullLiteral(SchemaParser.NullLiteralContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitUndefinedLiteral(SchemaParser.UndefinedLiteralContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParserVisitor.java b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParserVisitor.java new file mode 100644 index 0000000..be19107 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParserVisitor.java @@ -0,0 +1,519 @@ +package com.relogiclabs.jschema.internal.antlr; +import org.antlr.v4.runtime.tree.ParseTreeVisitor; + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by {@link SchemaParser}. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public interface SchemaParserVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by the {@code CompleteSchema} + * labeled alternative in {@link SchemaParser#schema}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCompleteSchema(SchemaParser.CompleteSchemaContext ctx); + /** + * Visit a parse tree produced by the {@code ShortSchema} + * labeled alternative in {@link SchemaParser#schema}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitShortSchema(SchemaParser.ShortSchemaContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#schemaMain}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSchemaMain(SchemaParser.SchemaMainContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#titleNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTitleNode(SchemaParser.TitleNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#versionNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitVersionNode(SchemaParser.VersionNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#importNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitImportNode(SchemaParser.ImportNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#pragmaNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPragmaNode(SchemaParser.PragmaNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#defineNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDefineNode(SchemaParser.DefineNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#aliasNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAliasNode(SchemaParser.AliasNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#validatorMain}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitValidatorMain(SchemaParser.ValidatorMainContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#validatorNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitValidatorNode(SchemaParser.ValidatorNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#valueNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitValueNode(SchemaParser.ValueNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#receiverNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitReceiverNode(SchemaParser.ReceiverNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#objectNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitObjectNode(SchemaParser.ObjectNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#propertyNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPropertyNode(SchemaParser.PropertyNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#arrayNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArrayNode(SchemaParser.ArrayNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#datatypeNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDatatypeNode(SchemaParser.DatatypeNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#functionNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunctionNode(SchemaParser.FunctionNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#argumentNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArgumentNode(SchemaParser.ArgumentNodeContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveTrue} + * labeled alternative in {@link SchemaParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveTrue(SchemaParser.PrimitiveTrueContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveFalse} + * labeled alternative in {@link SchemaParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveFalse(SchemaParser.PrimitiveFalseContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveString} + * labeled alternative in {@link SchemaParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveString(SchemaParser.PrimitiveStringContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveInteger} + * labeled alternative in {@link SchemaParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveInteger(SchemaParser.PrimitiveIntegerContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveFloat} + * labeled alternative in {@link SchemaParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveFloat(SchemaParser.PrimitiveFloatContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveDouble} + * labeled alternative in {@link SchemaParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveDouble(SchemaParser.PrimitiveDoubleContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveNull} + * labeled alternative in {@link SchemaParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveNull(SchemaParser.PrimitiveNullContext ctx); + /** + * Visit a parse tree produced by the {@code PrimitiveUndefined} + * labeled alternative in {@link SchemaParser#primitiveNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimitiveUndefined(SchemaParser.PrimitiveUndefinedContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#scriptNode}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitScriptNode(SchemaParser.ScriptNodeContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#globalStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitGlobalStatement(SchemaParser.GlobalStatementContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStatement(SchemaParser.StatementContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#functionDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunctionDeclaration(SchemaParser.FunctionDeclarationContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#varStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitVarStatement(SchemaParser.VarStatementContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#varInitialization}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitVarInitialization(SchemaParser.VarInitializationContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#expressionStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpressionStatement(SchemaParser.ExpressionStatementContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#ifStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIfStatement(SchemaParser.IfStatementContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#whileStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitWhileStatement(SchemaParser.WhileStatementContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#forStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitForStatement(SchemaParser.ForStatementContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#expressionList}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpressionList(SchemaParser.ExpressionListContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#foreachStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitForeachStatement(SchemaParser.ForeachStatementContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#returnStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitReturnStatement(SchemaParser.ReturnStatementContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#breakStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBreakStatement(SchemaParser.BreakStatementContext ctx); + /** + * Visit a parse tree produced by {@link SchemaParser#blockStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBlockStatement(SchemaParser.BlockStatementContext ctx); + /** + * Visit a parse tree produced by the {@code RangeEndExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitRangeEndExpression(SchemaParser.RangeEndExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code ParenthesizedExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParenthesizedExpression(SchemaParser.ParenthesizedExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code PostIncrementExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPostIncrementExpression(SchemaParser.PostIncrementExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code AdditiveExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAdditiveExpression(SchemaParser.AdditiveExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code RelationalExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitRelationalExpression(SchemaParser.RelationalExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code LogicalAndExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLogicalAndExpression(SchemaParser.LogicalAndExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code PreDecrementExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPreDecrementExpression(SchemaParser.PreDecrementExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code PreIncrementExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPreIncrementExpression(SchemaParser.PreIncrementExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code LiteralExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLiteralExpression(SchemaParser.LiteralExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code LogicalOrExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLogicalOrExpression(SchemaParser.LogicalOrExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code LogicalNotExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLogicalNotExpression(SchemaParser.LogicalNotExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code ThrowExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitThrowExpression(SchemaParser.ThrowExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code AllRefExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAllRefExpression(SchemaParser.AllRefExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code TryofExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTryofExpression(SchemaParser.TryofExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code UnaryMinusExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitUnaryMinusExpression(SchemaParser.UnaryMinusExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code AssignmentExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAssignmentExpression(SchemaParser.AssignmentExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code PostDecrementExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPostDecrementExpression(SchemaParser.PostDecrementExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code EqualityExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEqualityExpression(SchemaParser.EqualityExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code MultiplicativeExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMultiplicativeExpression(SchemaParser.MultiplicativeExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code RangeBothExpression} + * labeled alternative in {@link SchemaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitRangeBothExpression(SchemaParser.RangeBothExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code CallerExpression} + * labeled alternative in {@link SchemaParser#refExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCallerExpression(SchemaParser.CallerExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code InvokeExpression} + * labeled alternative in {@link SchemaParser#refExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInvokeExpression(SchemaParser.InvokeExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code DotExpression} + * labeled alternative in {@link SchemaParser#refExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDotExpression(SchemaParser.DotExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code TargetExpression} + * labeled alternative in {@link SchemaParser#refExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTargetExpression(SchemaParser.TargetExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code IndexExpression} + * labeled alternative in {@link SchemaParser#refExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIndexExpression(SchemaParser.IndexExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code IdentifierExpression} + * labeled alternative in {@link SchemaParser#refExpression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIdentifierExpression(SchemaParser.IdentifierExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code TrueLiteral} + * labeled alternative in {@link SchemaParser#literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTrueLiteral(SchemaParser.TrueLiteralContext ctx); + /** + * Visit a parse tree produced by the {@code FalseLiteral} + * labeled alternative in {@link SchemaParser#literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFalseLiteral(SchemaParser.FalseLiteralContext ctx); + /** + * Visit a parse tree produced by the {@code IntegerLiteral} + * labeled alternative in {@link SchemaParser#literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIntegerLiteral(SchemaParser.IntegerLiteralContext ctx); + /** + * Visit a parse tree produced by the {@code DoubleLiteral} + * labeled alternative in {@link SchemaParser#literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDoubleLiteral(SchemaParser.DoubleLiteralContext ctx); + /** + * Visit a parse tree produced by the {@code StringLiteral} + * labeled alternative in {@link SchemaParser#literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStringLiteral(SchemaParser.StringLiteralContext ctx); + /** + * Visit a parse tree produced by the {@code ArrayLiteral} + * labeled alternative in {@link SchemaParser#literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArrayLiteral(SchemaParser.ArrayLiteralContext ctx); + /** + * Visit a parse tree produced by the {@code ObjectLiteral} + * labeled alternative in {@link SchemaParser#literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitObjectLiteral(SchemaParser.ObjectLiteralContext ctx); + /** + * Visit a parse tree produced by the {@code NullLiteral} + * labeled alternative in {@link SchemaParser#literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNullLiteral(SchemaParser.NullLiteralContext ctx); + /** + * Visit a parse tree produced by the {@code UndefinedLiteral} + * labeled alternative in {@link SchemaParser#literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitUndefinedLiteral(SchemaParser.UndefinedLiteralContext ctx); +} \ No newline at end of file From 0185c7d25edb9de36b3e017b39773b33bb80c495 Mon Sep 17 00:00:00 2001 From: Zahid Hossain <60911932+zhossain-info@users.noreply.github.com> Date: Tue, 20 Feb 2024 23:02:07 +0600 Subject: [PATCH 06/12] Add script interpreter engine for schema --- .../jschema/internal/engine/Evaluator.java | 8 + .../jschema/internal/engine/ScopeContext.java | 73 ++++ .../internal/engine/ScriptContext.java | 14 + .../internal/engine/ScriptErrorHelper.java | 193 ++++++++++ .../internal/engine/ScriptFunction.java | 84 +++++ .../internal/engine/ScriptOperation.java | 15 + .../internal/engine/ScriptTreeHelper.java | 149 ++++++++ .../internal/engine/ScriptTreeVisitor.java | 9 + .../internal/engine/ScriptTreeVisitor1.java | 344 ++++++++++++++++++ .../internal/engine/ScriptTreeVisitor2.java | 235 ++++++++++++ .../internal/engine/ScriptTreeVisitor3.java | 311 ++++++++++++++++ 11 files changed, 1435 insertions(+) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/engine/Evaluator.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/engine/ScopeContext.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/engine/ScriptContext.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/engine/ScriptErrorHelper.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/engine/ScriptFunction.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/engine/ScriptOperation.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeHelper.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor1.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor2.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor3.java diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/Evaluator.java b/src/main/java/com/relogiclabs/jschema/internal/engine/Evaluator.java new file mode 100644 index 0000000..db04c25 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/Evaluator.java @@ -0,0 +1,8 @@ +package com.relogiclabs.jschema.internal.engine; + +import com.relogiclabs.jschema.type.EValue; + +@FunctionalInterface +public interface Evaluator { + EValue evaluate(ScopeContext scope); +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScopeContext.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScopeContext.java new file mode 100644 index 0000000..7e8d828 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScopeContext.java @@ -0,0 +1,73 @@ +package com.relogiclabs.jschema.internal.engine; + +import com.relogiclabs.jschema.exception.ScriptFunctionException; +import com.relogiclabs.jschema.exception.ScriptVariableException; +import com.relogiclabs.jschema.internal.script.GFunction; +import com.relogiclabs.jschema.internal.script.GReference; +import com.relogiclabs.jschema.tree.RuntimeContext; +import com.relogiclabs.jschema.type.EValue; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +import static com.relogiclabs.jschema.internal.library.ScriptLibrary.resolveStatic; +import static com.relogiclabs.jschema.internal.script.GFunction.CONSTRAINT_MARKER; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.FUNS02; +import static com.relogiclabs.jschema.message.ErrorCode.FUNS03; +import static com.relogiclabs.jschema.message.ErrorCode.VARD01; +import static org.apache.commons.lang3.StringUtils.substringBefore; + +public class ScopeContext { + @Getter private final ScopeContext parent; + private final Map symbols; + + public ScopeContext(ScopeContext parent) { + this.parent = parent; + this.symbols = new HashMap<>(); + } + + public GReference addVariable(String name, EValue value) { + if(symbols.containsKey(name)) throw new ScriptVariableException(VARD01, + concat("Variable '", name, "' already defined in the scope")); + var reference = new GReference(value); + symbols.put(name, reference); + return reference; + } + + public void addFunction(String name, GFunction function) { + if(symbols.containsKey(name)) { + if(name.startsWith(CONSTRAINT_MARKER)) + throw failOnDuplicateDefinition(FUNS02, "Constraint", name); + else throw failOnDuplicateDefinition(FUNS03, "Subroutine", name); + } + symbols.put(name, function); + } + + private static ScriptFunctionException failOnDuplicateDefinition(String code, + String functionType, String name) { + return new ScriptFunctionException(code, concat(functionType, " function '", + substringBefore(name, '#'), "' with matching parameter(s) already defined")); + } + + public EValue resolve(String name) { + var current = this; + do { + var value = current.symbols.get(name); + if(value != null) return value; + current = current.parent; + } while(current != null); + return resolveStatic(name); + } + + public RuntimeContext getRuntime() { + var current = this; + while(current.parent != null) current = current.parent; + return current.getRuntime(); + } + + public void update(String name, EValue value) { + symbols.put(name, value); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptContext.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptContext.java new file mode 100644 index 0000000..94962ca --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptContext.java @@ -0,0 +1,14 @@ +package com.relogiclabs.jschema.internal.engine; + +import com.relogiclabs.jschema.tree.RuntimeContext; +import lombok.Getter; + +@Getter +public class ScriptContext extends ScopeContext { + private final RuntimeContext runtime; + + public ScriptContext(RuntimeContext runtime) { + super(null); + this.runtime = runtime; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptErrorHelper.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptErrorHelper.java new file mode 100644 index 0000000..2a8e33b --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptErrorHelper.java @@ -0,0 +1,193 @@ +package com.relogiclabs.jschema.internal.engine; + +import com.relogiclabs.jschema.exception.InvalidFunctionException; +import com.relogiclabs.jschema.exception.ScriptInvocationException; +import com.relogiclabs.jschema.exception.ScriptOperationException; +import com.relogiclabs.jschema.exception.ScriptRuntimeException; +import com.relogiclabs.jschema.exception.SystemOperationException; +import com.relogiclabs.jschema.internal.script.GRange; +import com.relogiclabs.jschema.type.EArray; +import com.relogiclabs.jschema.type.EInteger; +import com.relogiclabs.jschema.type.EObject; +import com.relogiclabs.jschema.type.EString; +import com.relogiclabs.jschema.type.EValue; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.tree.TerminalNode; + +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.ASIN01; +import static com.relogiclabs.jschema.message.ErrorCode.CALR01; +import static com.relogiclabs.jschema.message.ErrorCode.FUNS01; +import static com.relogiclabs.jschema.message.ErrorCode.FUNS04; +import static com.relogiclabs.jschema.message.ErrorCode.INDX02; +import static com.relogiclabs.jschema.message.ErrorCode.INDX03; +import static com.relogiclabs.jschema.message.ErrorCode.INDX04; +import static com.relogiclabs.jschema.message.ErrorCode.INDX05; +import static com.relogiclabs.jschema.message.ErrorCode.PRPS02; +import static com.relogiclabs.jschema.message.ErrorCode.RETN01; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS04; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS05; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS06; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS07; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS08; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS09; +import static com.relogiclabs.jschema.message.ErrorCode.TRGT01; +import static com.relogiclabs.jschema.message.ErrorCode.VARD02; +import static com.relogiclabs.jschema.message.MessageFormatter.createOutline; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; + + +public final class ScriptErrorHelper { + private ScriptErrorHelper() { + throw new UnsupportedOperationException(); + } + + static InvalidFunctionException failOnDuplicateParameterName(TerminalNode node) { + return new InvalidFunctionException(formatForSchema(FUNS01, + concat("Duplicate parameter name '", node.getText(), "'"), node.getSymbol())); + } + + static ScriptRuntimeException failOnInvalidReturnType(EValue value, Token token) { + return new ScriptRuntimeException(formatForSchema(RETN01, + concat("Invalid return type ", value.getType(), " for constraint function"), token)); + } + + static ScriptRuntimeException failOnPropertyNotExist(EObject object, String property, + Token token) { + return new ScriptRuntimeException(formatForSchema(PRPS02, concat("Property '", + property, "' not exist in readonly ", object.getType()), token)); + } + + static RuntimeException failOnIndexOutOfBounds(EString string, EInteger index, + Token token, RuntimeException cause) { + var indexValue = index.getValue(); + if(indexValue < 0) return new ScriptRuntimeException(formatForSchema(INDX03, + concat("Invalid negative index ", index, " for string starts at 0"), + token), cause); + var length = string.length(); + if(indexValue >= length) return new ScriptRuntimeException(formatForSchema(INDX02, + concat("Index ", index, " out of bounds for string length ", length), + token), cause); + return cause; + } + + static RuntimeException failOnIndexOutOfBounds(EArray array, EInteger index, + Token token, RuntimeException cause) { + var indexValue = index.getValue(); + if(indexValue < 0) return new ScriptRuntimeException(formatForSchema(INDX05, + concat("Invalid negative index ", index, " for array starts at 0"), + token), cause); + var size = array.size(); + if(indexValue >= size) return new ScriptRuntimeException(formatForSchema(INDX04, + concat("Index ", index, " out of bounds for array length ", size), + token), cause); + return cause; + } + + static RuntimeException failOnInvalidRangeIndex(EString string, GRange range, Token token, + RuntimeException cause) { + int length = string.length(), start = range.getStart(length), end = range.getEnd(length); + if(start < 0 || start > length) throw new ScriptRuntimeException(formatForSchema(RNGS04, + concat("Range start index ", start, " out of bounds for string length ", length), + token), cause); + if(end < 0 || end > length) return new ScriptRuntimeException(formatForSchema(RNGS05, + concat("Range end index ", end, " out of bounds for string length ", length), + token), cause); + if(start > end) return new ScriptRuntimeException(formatForSchema(RNGS06, + concat("Range start index ", start, " > end index ", end, " for string ", + createOutline(string)), token), cause); + return cause; + } + + static RuntimeException failOnInvalidRangeIndex(EArray array, GRange range, Token token, + RuntimeException cause) { + int size = array.size(), start = range.getStart(size), end = range.getEnd(size); + if(start < 0 || start > size) throw new ScriptRuntimeException(formatForSchema(RNGS07, + concat("Range start index ", start, " out of bounds for array length ", size), + token), cause); + if(end < 0 || end > size) return new ScriptRuntimeException(formatForSchema(RNGS08, + concat("Range end index ", end, " out of bounds for array length ", size), + token), cause); + if(start > end) return new ScriptRuntimeException(formatForSchema(RNGS09, + concat("Range start index ", start, " > end index ", end, " for array ", + createOutline(array)), token), cause); + return cause; + } + + static ScriptRuntimeException failOnInvalidLValueIncrement(String code, Token token) { + return new ScriptRuntimeException(formatForSchema(code, + "Invalid l-value for increment", token)); + } + + static ScriptRuntimeException failOnInvalidLValueDecrement(String code, Token token) { + return new ScriptRuntimeException(formatForSchema(code, + "Invalid l-value for decrement", token)); + } + + static ScriptRuntimeException failOnInvalidLValueAssignment(Token token) { + return new ScriptRuntimeException(formatForSchema(ASIN01, + "Invalid l-value for assignment", token)); + } + + static ScriptInvocationException failOnTargetNotFound(Token token) { + return new ScriptInvocationException(TRGT01, "Target not found for function '%s'", token); + } + + static ScriptInvocationException failOnCallerNotFound(Token token) { + return new ScriptInvocationException(CALR01, "Caller not found for function '%s'", token); + } + + static ScriptRuntimeException failOnIdentifierNotFound(Token identifier) { + return new ScriptRuntimeException(formatForSchema(VARD02, + concat("Identifier '", identifier.getText(), "' not found"), identifier)); + } + + static ScriptRuntimeException failOnFunctionNotFound(String name, int arity, Token token) { + return new ScriptRuntimeException(formatForSchema(FUNS04, + concat("Function '", name, "' with ", arity, " parameter(s) not found"), token)); + } + + static ScriptRuntimeException failOnRuntime(String code, String message, + Token token, Throwable cause) { + return new ScriptRuntimeException(formatForSchema(code, message, token), cause); + } + + static ScriptInvocationException failOnVariadicArgument(String code) { + return new ScriptInvocationException(code, + "Too few argument for invocation of variadic function '%s'"); + } + + static ScriptInvocationException failOnFixedArgument(String code) { + return new ScriptInvocationException(code, + "Invalid number of arguments for function '%s'"); + } + + static SystemOperationException failOnSystemException(String code, + Exception exception, Token token) { + return new SystemOperationException(formatForSchema(code, exception.getMessage(), + token), exception); + } + + static ScriptRuntimeException failOnOperation(String code, String operationName, + EValue value, Token token, Throwable cause) { + return new ScriptOperationException(formatForSchema(code, concat("Invalid ", + operationName, " operation on type ", value.getType()), token), cause); + } + + static ScriptRuntimeException failOnOperation(String code, String operationName, + EValue value, TerminalNode node) { + return failOnOperation(code, operationName, value, node.getSymbol(), null); + } + + static ScriptRuntimeException failOnOperation(String code, String operationName, + EValue value1, EValue value2, Token token, Throwable cause) { + return new ScriptOperationException(formatForSchema(code, concat("Invalid ", + operationName, " operation on types ", value1.getType(), " and ", + value2.getType()), token), cause); + } + + static ScriptRuntimeException failOnOperation(String code, String operationName, + EValue value1, EValue value2, TerminalNode node) { + return failOnOperation(code, operationName, value1, value2, node.getSymbol(), null); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptFunction.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptFunction.java new file mode 100644 index 0000000..a995329 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptFunction.java @@ -0,0 +1,84 @@ +package com.relogiclabs.jschema.internal.engine; + +import com.relogiclabs.jschema.exception.InvalidFunctionException; +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.exception.ScriptCommonException; +import com.relogiclabs.jschema.exception.ScriptInitiatedException; +import com.relogiclabs.jschema.function.FutureFunction; +import com.relogiclabs.jschema.internal.script.GArray; +import com.relogiclabs.jschema.internal.script.GFunction; +import com.relogiclabs.jschema.internal.tree.EFunction; +import com.relogiclabs.jschema.node.JFunction; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.type.EBoolean; +import com.relogiclabs.jschema.type.EValue; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +import static com.relogiclabs.jschema.internal.library.ScriptConstant.CALLER_HVAR; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.TARGET_HVAR; +import static com.relogiclabs.jschema.internal.util.CollectionHelper.subList; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC10; +import static com.relogiclabs.jschema.type.EValue.VOID; + +@Getter +@RequiredArgsConstructor +public final class ScriptFunction implements EFunction { + private final String name; + private final GFunction function; + + @Override + public Object invoke(JFunction caller, Object[] arguments) { + var parameters = function.getParameters(); + var scope = new ScopeContext(caller.getRuntime().getScriptContext()); + scope.update(CALLER_HVAR, caller); + scope.update(TARGET_HVAR, (EValue) arguments[0]); + int i = 1; + for(var p : parameters) scope.addVariable(p.getName(), (EValue) arguments[i++]); + return function.isFuture() + ? (FutureFunction) () -> invoke(function, scope) + : invoke(function, scope); + } + + private boolean invoke(GFunction function, ScopeContext scope) { + try { + var result = function.invoke(scope); + if(result == VOID) return true; + if(!(result instanceof EBoolean b)) throw new InvalidFunctionException(FUNC10, + concat("Function '", name, "' must return a boolean value")); + return b.getValue(); + } catch(JsonSchemaException | ScriptInitiatedException e) { + throw e; + } catch(ScriptCommonException e) { + scope.getRuntime().getExceptions().fail(e); + return false; + } + } + + @Override + public List prebind(List arguments) { + var parameters = function.getParameters(); + var minArgSize = function.isVariadic() ? parameters.length - 1 : parameters.length; + if(arguments.size() < minArgSize) return null; + var result = new ArrayList<>(parameters.length); + for(int i = 0; i < parameters.length; i++) { + if(parameters[i].isVariadic()) result.add(new GArray(subList(arguments, i))); + else result.add(arguments.get(i)); + } + return result; + } + + @Override + public Class getTargetType() { + return JNode.class; + } + + @Override + public int getArity() { + return function.isVariadic() ? -1 : function.getParameters().length + 1; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptOperation.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptOperation.java new file mode 100644 index 0000000..6fab363 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptOperation.java @@ -0,0 +1,15 @@ +package com.relogiclabs.jschema.internal.engine; + +public interface ScriptOperation { + String ADDITION = "addition"; + String SUBTRACTION = "subtraction"; + String MULTIPLICATION = "multiplication"; + String DIVISION = "division"; + String INDEX = "index"; + String RANGE = "range"; + String COMPARISON = "comparison"; + String PROPERTY = "property access"; + String INCREMENT = "increment"; + String DECREMENT = "decrement"; + String NEGATION = "negation"; +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeHelper.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeHelper.java new file mode 100644 index 0000000..454ef52 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeHelper.java @@ -0,0 +1,149 @@ +package com.relogiclabs.jschema.internal.engine; + +import com.relogiclabs.jschema.internal.antlr.SchemaLexer; +import com.relogiclabs.jschema.internal.script.GDouble; +import com.relogiclabs.jschema.internal.script.GFunction; +import com.relogiclabs.jschema.internal.script.GInteger; +import com.relogiclabs.jschema.internal.script.GObject; +import com.relogiclabs.jschema.internal.script.GParameter; +import com.relogiclabs.jschema.internal.script.GRange; +import com.relogiclabs.jschema.internal.script.GReference; +import com.relogiclabs.jschema.tree.RuntimeContext; +import com.relogiclabs.jschema.type.EArray; +import com.relogiclabs.jschema.type.EBoolean; +import com.relogiclabs.jschema.type.EInteger; +import com.relogiclabs.jschema.type.ENull; +import com.relogiclabs.jschema.type.ENumber; +import com.relogiclabs.jschema.type.EObject; +import com.relogiclabs.jschema.type.EString; +import com.relogiclabs.jschema.type.EUndefined; +import com.relogiclabs.jschema.type.EValue; +import org.antlr.v4.runtime.tree.ParseTree; +import org.antlr.v4.runtime.tree.TerminalNode; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnDuplicateParameterName; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnFixedArgument; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnVariadicArgument; +import static com.relogiclabs.jschema.internal.script.GFunction.CONSTRAINT_MARKER; +import static com.relogiclabs.jschema.internal.util.StreamHelper.halt; +import static java.util.stream.Collectors.toMap; + +public final class ScriptTreeHelper { + private static final String TRYOF_VALUE = "value"; + private static final String TRYOF_ERROR = "error"; + + private ScriptTreeHelper() { + throw new UnsupportedOperationException(); + } + + public static boolean areEqual(EValue v1, EValue v2, RuntimeContext rc) { + v1 = dereference(v1); + v2 = dereference(v2); + if(v1 instanceof ENumber n1 && v2 instanceof ENumber n2) + return rc.areEqual(n1.toDouble(), n2.toDouble()); + if(v1 instanceof EBoolean b1 && v2 instanceof EBoolean b2) + return b1.getValue() == b2.getValue(); + if(v1 instanceof EString s1 && v2 instanceof EString s2) + return s1.getValue().equals(s2.getValue()); + if(v1 instanceof ENull && v2 instanceof ENull) return true; + if(v1 instanceof EUndefined && v2 instanceof EUndefined) return true; + if(v1 instanceof EArray a1 && v2 instanceof EArray a2) { + if(a1.size() != a2.size()) return false; + for(int i = 0; i < a1.size(); i++) + if(!areEqual(a1.get(i), a2.get(i), rc)) return false; + return true; + } + if(v1 instanceof EObject o1 && v2 instanceof EObject o2) { + if(o1.size() != o2.size()) return false; + for(var k : o1.keySet()) + if(!areEqual(o1.get(k), o2.get(k), rc)) return false; + return true; + } + if(v1 instanceof GRange r1 && v2 instanceof GRange r2) + return r1.equals(r2); + return false; + } + + public static EValue dereference(EValue value) { + while(value instanceof GReference reference) + value = reference.getValue(); + return value; + } + + static int getFunctionMode(TerminalNode constraint, TerminalNode future, TerminalNode subroutine) { + return getFunctionMode(constraint) | getFunctionMode(future) | getFunctionMode(subroutine); + } + + private static int getFunctionMode(TerminalNode node) { + if(node == null) return 0; + return switch(node.getSymbol().getType()) { + case SchemaLexer.G_CONSTRAINT -> GFunction.CONSTRAINT_MODE; + case SchemaLexer.G_FUTURE -> GFunction.FUTURE_MODE; + case SchemaLexer.G_SUBROUTINE -> GFunction.SUBROUTINE_MODE; + default -> 0; + }; + } + + static ENumber increment(ENumber number) { + if(number instanceof EInteger i) return GInteger.of(i.getValue() + 1); + return GDouble.of(number.toDouble() + 1); + } + + static ENumber decrement(ENumber number) { + if(number instanceof EInteger i) return GInteger.of(i.getValue() - 1); + return GDouble.of(number.toDouble() - 1); + } + + static String formatFunctionName(String baseName, GParameter[] parameters) { + if(hasVariadic(parameters)) return baseName + "#..."; + return baseName + "#" + parameters.length; + } + + static String toConstraintName(String functionName) { + return CONSTRAINT_MARKER.concat(functionName); + } + + static GParameter[] toParameters(List identifiers, + TerminalNode ellipsis) { + identifiers.stream().collect(toMap(ParseTree::getText, Function.identity(), + (i1, i2) -> halt(failOnDuplicateParameterName(i2)) + )); + var parameters = identifiers.stream().map(ParseTree::getText) + .collect(Collectors.toCollection(ArrayList::new)); + if(ellipsis != null) updateLast(parameters, ellipsis.getText()); + return parameters.stream().map(GParameter::new).toArray(GParameter[]::new); + } + + public static void areCompatible(GParameter[] parameters, List arguments, String code) { + if(hasVariadic(parameters)) { + if(arguments.size() < parameters.length - 1) throw failOnVariadicArgument(code); + } else if(arguments.size() != parameters.length) throw failOnFixedArgument(code); + } + + public static String stringify(Object object) { + if(object instanceof EString s) return s.getValue(); + return object.toString(); + } + + static GObject createTryofMonad(EValue value, EValue error) { + GObject object = new GObject(2); + object.set(TRYOF_VALUE, value); + object.set(TRYOF_ERROR, error); + return object; + } + + private static void updateLast(List list, String suffix) { + var last = list.size() - 1; + list.set(last, list.get(last).concat(suffix)); + } + + private static boolean hasVariadic(GParameter[] parameters) { + if(parameters.length == 0) return false; + return parameters[parameters.length - 1].isVariadic(); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor.java new file mode 100644 index 0000000..29e4543 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor.java @@ -0,0 +1,9 @@ +package com.relogiclabs.jschema.internal.engine; + +import com.relogiclabs.jschema.tree.RuntimeContext; +import org.antlr.v4.runtime.tree.ParseTreeProperty; + +public interface ScriptTreeVisitor { + RuntimeContext getRuntime(); + ParseTreeProperty getScripts(); +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor1.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor1.java new file mode 100644 index 0000000..48995e0 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor1.java @@ -0,0 +1,344 @@ +package com.relogiclabs.jschema.internal.engine; + +import com.relogiclabs.jschema.exception.CommonException; +import com.relogiclabs.jschema.exception.ScriptRuntimeException; +import com.relogiclabs.jschema.exception.ScriptTemplateException; +import com.relogiclabs.jschema.internal.antlr.SchemaParser; +import com.relogiclabs.jschema.internal.antlr.SchemaParserBaseVisitor; +import com.relogiclabs.jschema.internal.script.GArray; +import com.relogiclabs.jschema.internal.script.GControl; +import com.relogiclabs.jschema.internal.script.GDouble; +import com.relogiclabs.jschema.internal.script.GFunction; +import com.relogiclabs.jschema.internal.script.GInteger; +import com.relogiclabs.jschema.internal.script.GIterator; +import com.relogiclabs.jschema.internal.script.GObject; +import com.relogiclabs.jschema.internal.script.GString; +import com.relogiclabs.jschema.tree.RuntimeContext; +import com.relogiclabs.jschema.type.EBoolean; +import lombok.Getter; +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.tree.ParseTree; +import org.antlr.v4.runtime.tree.ParseTreeProperty; + +import static com.relogiclabs.jschema.internal.antlr.SchemaLexer.G_STRING; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnInvalidReturnType; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnRuntime; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnSystemException; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.dereference; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.formatFunctionName; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.getFunctionMode; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.toConstraintName; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.toParameters; +import static com.relogiclabs.jschema.internal.script.GBoolean.FALSE; +import static com.relogiclabs.jschema.internal.script.GBoolean.TRUE; +import static com.relogiclabs.jschema.internal.script.GControl.BREAK; +import static com.relogiclabs.jschema.internal.script.GFunction.isConstraint; +import static com.relogiclabs.jschema.internal.util.CollectionHelper.subList; +import static com.relogiclabs.jschema.internal.util.StringHelper.toEncoded; +import static com.relogiclabs.jschema.message.ErrorCode.ARRL01; +import static com.relogiclabs.jschema.message.ErrorCode.BLOK01; +import static com.relogiclabs.jschema.message.ErrorCode.EXPR01; +import static com.relogiclabs.jschema.message.ErrorCode.EXPR02; +import static com.relogiclabs.jschema.message.ErrorCode.FORS01; +import static com.relogiclabs.jschema.message.ErrorCode.FREC01; +import static com.relogiclabs.jschema.message.ErrorCode.FUNS07; +import static com.relogiclabs.jschema.message.ErrorCode.IFST01; +import static com.relogiclabs.jschema.message.ErrorCode.IFST02; +import static com.relogiclabs.jschema.message.ErrorCode.OBJL01; +import static com.relogiclabs.jschema.message.ErrorCode.RETN02; +import static com.relogiclabs.jschema.message.ErrorCode.RETN03; +import static com.relogiclabs.jschema.message.ErrorCode.SRPT01; +import static com.relogiclabs.jschema.message.ErrorCode.SRPT02; +import static com.relogiclabs.jschema.message.ErrorCode.VARD03; +import static com.relogiclabs.jschema.message.ErrorCode.VRIN01; +import static com.relogiclabs.jschema.message.ErrorCode.WHIL01; +import static com.relogiclabs.jschema.type.ENull.NULL; +import static com.relogiclabs.jschema.type.EUndefined.UNDEFINED; +import static com.relogiclabs.jschema.type.EValue.VOID; +import static lombok.AccessLevel.NONE; + +@Getter +public abstract class ScriptTreeVisitor1 extends SchemaParserBaseVisitor + implements ScriptTreeVisitor { + private static final Evaluator VOID_SUPPLIER = s -> VOID; + private static final Evaluator TRUE_SUPPLIER = s -> TRUE; + private static final Evaluator FALSE_SUPPLIER = s -> FALSE; + private static final Evaluator NULL_SUPPLIER = S -> NULL; + private static final Evaluator UNDEFINED_SUPPLIER = s -> UNDEFINED; + private static final Evaluator BREAK_SUPPLIER = s -> BREAK; + + final RuntimeContext runtime; + private final ParseTreeProperty scripts; + @Getter(NONE) private Class returnType; + + public ScriptTreeVisitor1(RuntimeContext runtime) { + this.runtime = runtime; + this.scripts = new ParseTreeProperty<>(); + } + + @Override + public Evaluator visitCompleteSchema(SchemaParser.CompleteSchemaContext ctx) { + var scripts = ctx.scriptNode().stream().map(this::processScript).toList(); + if(scripts.isEmpty()) return VOID_SUPPLIER; + return tryCatch(scope -> { + for(var s : scripts) s.evaluate(scope); + return VOID; + }, SRPT01, ctx); + } + + @Override + public Evaluator visitShortSchema(SchemaParser.ShortSchemaContext ctx) { + return VOID_SUPPLIER; + } + + private Evaluator processScript(ParserRuleContext context) { + var evaluator = visit(context); + scripts.put(context, evaluator); + return evaluator; + } + + @Override + public Evaluator visitScriptNode(SchemaParser.ScriptNodeContext ctx) { + var statements = ctx.globalStatement().stream().map(this::visit).toList(); + return tryCatch(scope -> { + for(var s : statements) s.evaluate(scope); + return VOID; + }, SRPT02, ctx); + } + + @Override + public Evaluator visitFunctionDeclaration(SchemaParser.FunctionDeclarationContext ctx) { + var baseName = ctx.name.getText(); + var mode = getFunctionMode(ctx.G_CONSTRAINT(), ctx.G_FUTURE(), ctx.G_SUBROUTINE()); + var parameters = toParameters(subList(ctx.G_IDENTIFIER(), 1), ctx.G_ELLIPSIS()); + var constraint = isConstraint(mode); + var functionName = constraint + ? toConstraintName(formatFunctionName(baseName, parameters)) + : formatFunctionName(baseName, parameters); + if(constraint) returnType = EBoolean.class; + var functionBody = visit(ctx.blockStatement()); + returnType = null; + var function = new GFunction(parameters, functionBody, mode); + return tryCatch(scope -> { + scope.addFunction(functionName, function); + if(constraint) runtime.getFunctions() + .addFunction(new ScriptFunction(baseName, function)); + return VOID; + }, FUNS07, ctx); + } + + @Override + public Evaluator visitVarStatement(SchemaParser.VarStatementContext ctx) { + var varInitialization = ctx.varInitialization().stream().map(this::visit).toList(); + return tryCatch(scope -> { + for(var i : varInitialization) i.evaluate(scope); + return VOID; + }, VARD03, ctx); + } + + @Override + public Evaluator visitVarInitialization(SchemaParser.VarInitializationContext ctx) { + var varName = ctx.G_IDENTIFIER().getText(); + var expression = visit(ctx.expression(), VOID_SUPPLIER); + return tryCatch(scope -> { + scope.addVariable(varName, expression.evaluate(scope)); + return VOID; + }, VRIN01, ctx); + } + + @Override + public Evaluator visitExpressionStatement(SchemaParser.ExpressionStatementContext ctx) { + var expression = visit(ctx.expression()); + return tryCatch(scope -> { + expression.evaluate(scope); + return VOID; + }, EXPR01, ctx); + } + + @Override + public Evaluator visitIfStatement(SchemaParser.IfStatementContext ctx) { + var condition = visit(ctx.expression()); + var thenStatement = visit(ctx.statement(0)); + if(ctx.G_ELSE() == null) return tryCatch(scope -> { + if(condition.evaluate(scope).toBoolean()) + return thenStatement.evaluate(scope); + return VOID; + }, IFST01, ctx); + + var elseStatement = visit(ctx.statement(1)); + return tryCatch(scope -> { + if(condition.evaluate(scope).toBoolean()) + return thenStatement.evaluate(scope); + else return elseStatement.evaluate(scope); + }, IFST02, ctx); + } + + @Override + public Evaluator visitWhileStatement(SchemaParser.WhileStatementContext ctx) { + var condition = visit(ctx.expression()); + var statement = visit(ctx.statement()); + return tryCatch(scope -> { + while(condition.evaluate(scope).toBoolean()) { + var result = statement.evaluate(scope); + if(result instanceof GControl ctrl) return ctrl.toIteration(); + } + return VOID; + }, WHIL01, ctx); + } + + @Override + public Evaluator visitForStatement(SchemaParser.ForStatementContext ctx) { + var initialization = visit(ctx.varStatement(), visit(ctx.initialization, VOID_SUPPLIER)); + var condition = visit(ctx.condition, TRUE_SUPPLIER); + var updation = visit(ctx.updation, VOID_SUPPLIER); + var statement = visit(ctx.statement()); + return tryCatch(scope -> { + var forScope = new ScopeContext(scope); + for(initialization.evaluate(forScope); + condition.evaluate(forScope).toBoolean(); + updation.evaluate(forScope)) { + var result = statement.evaluate(forScope); + if(result instanceof GControl ctrl) return ctrl.toIteration(); + } + return VOID; + }, FORS01, ctx); + } + + @Override + public Evaluator visitExpressionList(SchemaParser.ExpressionListContext ctx) { + var expressions = ctx.expression().stream().map(this::visit).toList(); + return tryCatch(scope -> { + for(var e : expressions) e.evaluate(scope); + return VOID; + }, EXPR02, ctx); + } + + @Override + public Evaluator visitForeachStatement(SchemaParser.ForeachStatementContext ctx) { + var varName = ctx.G_IDENTIFIER().getText(); + var collection = visit(ctx.expression()); + var statement = visit(ctx.statement()); + return tryCatch(scope -> { + var forScope = new ScopeContext(scope); + var reference = forScope.addVariable(varName, VOID); + for(var v : GIterator.of(collection.evaluate(scope))) { + reference.setValue(v); + var result = statement.evaluate(forScope); + if(result instanceof GControl ctrl) return ctrl.toIteration(); + } + return VOID; + }, FREC01, ctx); + } + + @Override + public Evaluator visitReturnStatement(SchemaParser.ReturnStatementContext ctx) { + var expression = visit(ctx.expression()); + if(returnType == null) return tryCatch(scope -> GControl.ofReturn( + expression.evaluate(scope)), RETN02, ctx); + var thisReturnType = returnType; + return tryCatch(scope -> { + var v1 = expression.evaluate(scope); + if(!thisReturnType.isInstance(v1)) + throw failOnInvalidReturnType(v1, ctx.expression().getStart()); + return GControl.ofReturn(v1); + }, RETN03, ctx); + } + + @Override + public Evaluator visitBreakStatement(SchemaParser.BreakStatementContext ctx) { + return BREAK_SUPPLIER; + } + + @Override + public Evaluator visitBlockStatement(SchemaParser.BlockStatementContext ctx) { + var statements = ctx.statement().stream().map(this::visit).toList(); + return tryCatch(scope -> { + var blockScope = new ScopeContext(scope); + for(var s : statements) { + var result = s.evaluate(blockScope); + if(result instanceof GControl ctrl) return ctrl; + } + return VOID; + }, BLOK01, ctx); + } + + @Override + public Evaluator visitTrueLiteral(SchemaParser.TrueLiteralContext ctx) { + return TRUE_SUPPLIER; + } + + @Override + public Evaluator visitFalseLiteral(SchemaParser.FalseLiteralContext ctx) { + return FALSE_SUPPLIER; + } + + @Override + public Evaluator visitNullLiteral(SchemaParser.NullLiteralContext ctx) { + return NULL_SUPPLIER; + } + + @Override + public Evaluator visitUndefinedLiteral(SchemaParser.UndefinedLiteralContext ctx) { + return UNDEFINED_SUPPLIER; + } + + @Override + public Evaluator visitIntegerLiteral(SchemaParser.IntegerLiteralContext ctx) { + var value = GInteger.of(Long.parseLong(ctx.G_INTEGER().getText())); + return scope -> value; + } + + @Override + public Evaluator visitDoubleLiteral(SchemaParser.DoubleLiteralContext ctx) { + var value = GDouble.of(Double.parseDouble(ctx.G_DOUBLE().getText())); + return scope -> value; + } + + @Override + public Evaluator visitStringLiteral(SchemaParser.StringLiteralContext ctx) { + var value = GString.of(toEncoded(ctx.getText())); + return scope -> value; + } + + @Override + public Evaluator visitArrayLiteral(SchemaParser.ArrayLiteralContext ctx) { + var list = ctx.expression().stream().map(this::visit).toList(); + return tryCatch(scope -> new GArray(list.stream().map(e + -> e.evaluate(scope)).toList()), ARRL01, ctx); + } + + @Override + public Evaluator visitObjectLiteral(SchemaParser.ObjectLiteralContext ctx) { + var keys = ctx.keys.stream().map(t -> t.getType() == G_STRING + ? toEncoded(t.getText()) : t.getText()).toList(); + var values = ctx.values.stream().map(this::visit).toList(); + return tryCatch(scope -> new GObject(keys, values.stream().map(v + -> v.evaluate(scope)).toList()), OBJL01, ctx); + } + + static Evaluator tryCatch(Evaluator evaluator, String code, + ParserRuleContext context) { + return scope -> { + try { + return evaluator.evaluate(scope); + } catch(ScriptRuntimeException | ScriptTemplateException e) { + throw e; + } catch(CommonException e) { + throw failOnRuntime(e.getCode(), e.getMessage(), context.start, e); + } catch(Exception e) { + throw failOnSystemException(code, e, context.start); + } + }; + } + + @Override + public Evaluator visit(ParseTree tree) { + if(tree == null) return null; + return super.visit(tree); + } + + private Evaluator visit(ParseTree tree, Evaluator defaultValue) { + if(tree == null) return defaultValue; + return super.visit(tree); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor2.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor2.java new file mode 100644 index 0000000..fe2e998 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor2.java @@ -0,0 +1,235 @@ +package com.relogiclabs.jschema.internal.engine; + +import com.relogiclabs.jschema.exception.ScriptArgumentException; +import com.relogiclabs.jschema.exception.ScriptInitiatedException; +import com.relogiclabs.jschema.exception.ScriptInvocationException; +import com.relogiclabs.jschema.internal.antlr.SchemaParser; +import com.relogiclabs.jschema.internal.script.GArray; +import com.relogiclabs.jschema.internal.script.GControl; +import com.relogiclabs.jschema.internal.script.GRange; +import com.relogiclabs.jschema.internal.script.GString; +import com.relogiclabs.jschema.internal.script.RFunction; +import com.relogiclabs.jschema.internal.util.LogHelper; +import com.relogiclabs.jschema.tree.RuntimeContext; +import com.relogiclabs.jschema.type.EArray; +import com.relogiclabs.jschema.type.EInteger; +import com.relogiclabs.jschema.type.EObject; +import com.relogiclabs.jschema.type.EString; + +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnCallerNotFound; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnFunctionNotFound; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnIdentifierNotFound; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnIndexOutOfBounds; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnInvalidRangeIndex; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnOperation; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnPropertyNotExist; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnRuntime; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnTargetNotFound; +import static com.relogiclabs.jschema.internal.engine.ScriptOperation.INDEX; +import static com.relogiclabs.jschema.internal.engine.ScriptOperation.PROPERTY; +import static com.relogiclabs.jschema.internal.engine.ScriptOperation.RANGE; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.createTryofMonad; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.dereference; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.stringify; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.CALLER_HVAR; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.TARGET_HVAR; +import static com.relogiclabs.jschema.message.ErrorCode.CALR02; +import static com.relogiclabs.jschema.message.ErrorCode.INDX06; +import static com.relogiclabs.jschema.message.ErrorCode.INDX07; +import static com.relogiclabs.jschema.message.ErrorCode.INDX08; +import static com.relogiclabs.jschema.message.ErrorCode.INVK01; +import static com.relogiclabs.jschema.message.ErrorCode.PRPS01; +import static com.relogiclabs.jschema.message.ErrorCode.PRPS03; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS01; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS02; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS03; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS10; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS11; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS12; +import static com.relogiclabs.jschema.message.ErrorCode.RNGS13; +import static com.relogiclabs.jschema.message.ErrorCode.THRO01; +import static com.relogiclabs.jschema.message.ErrorCode.THRO02; +import static com.relogiclabs.jschema.message.ErrorCode.TRGT02; +import static com.relogiclabs.jschema.message.ErrorCode.VARD04; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; +import static com.relogiclabs.jschema.type.EUndefined.UNDEFINED; +import static com.relogiclabs.jschema.type.EValue.VOID; + +public abstract class ScriptTreeVisitor2 extends ScriptTreeVisitor1 { + private static final Evaluator CODE_SUPPLIER = s -> GString.of(THRO01); + + public ScriptTreeVisitor2(RuntimeContext runtime) { + super(runtime); + } + + @Override + public Evaluator visitDotExpression(SchemaParser.DotExpressionContext ctx) { + var e1 = visit(ctx.refExpression()); + var s2 = ctx.G_IDENTIFIER().getText(); + return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + if(!(v1 instanceof EObject o1)) throw failOnOperation(PRPS01, PROPERTY, v1, ctx.G_DOT()); + var v2 = o1.get(s2); + if(v2 == null) throw failOnPropertyNotExist(o1, s2, ctx.G_IDENTIFIER().getSymbol()); + return v2; + }, PRPS03, ctx); + } + + @Override + public Evaluator visitIndexExpression(SchemaParser.IndexExpressionContext ctx) { + var e1 = visit(ctx.refExpression()); + var e2 = visit(ctx.expression()); + return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + var v2 = dereference(e2.evaluate(scope)); + if(v1 instanceof EArray a1 && v2 instanceof EInteger i2) { + try { + return a1.get((int) i2.getValue()); + } catch(IndexOutOfBoundsException e) { + throw failOnIndexOutOfBounds(a1, i2, ctx.expression().getStart(), e); + } + } + if(v1 instanceof EArray a1 && v2 instanceof GRange r2) { + try { + return GArray.from(a1, r2); + } catch(IndexOutOfBoundsException | IllegalArgumentException e) { + throw failOnInvalidRangeIndex(a1, r2, ctx.expression().getStart(), e); + } + } + if(v1 instanceof EObject o1 && v2 instanceof EString s2) { + var v3 = o1.get(s2.getValue()); + if(v3 == null) throw failOnPropertyNotExist(o1, s2.getValue(), + ctx.expression().getStart()); + return v3; + } + if(v1 instanceof EString s1 && v2 instanceof EInteger i2) { + try { + return GString.of(s1.getValue().charAt((int) i2.getValue())); + } catch(IndexOutOfBoundsException e) { + throw failOnIndexOutOfBounds(s1, i2, ctx.expression().getStart(), e); + } + } + if(v1 instanceof EString s1 && v2 instanceof GRange r2) { + try { + return GString.from(s1, r2); + } catch(IndexOutOfBoundsException | IllegalArgumentException e) { + throw failOnInvalidRangeIndex(s1, r2, ctx.expression().getStart(), e); + } + } + if(v2 instanceof EInteger) throw failOnOperation(INDX06, INDEX, v1, ctx.G_LBRACKET()); + if(v2 instanceof GRange) throw failOnOperation(RNGS10, RANGE, v1, ctx.G_LBRACKET()); + throw failOnOperation(INDX07, INDEX, v1, v2, ctx.G_LBRACKET()); + }, INDX08, ctx); + } + + @Override + public Evaluator visitInvokeExpression(SchemaParser.InvokeExpressionContext ctx) { + var e1 = ctx.G_IDENTIFIER(); + var e2 = ctx.expression().stream().map(this::visit).toList(); + var s1 = e1.getText(); + var n1 = s1 + "#" + e2.size(); + var n2 = s1.concat("#..."); + return tryCatch(scope -> { + try { + var v1 = scope.resolve(n1); + if(v1 == VOID) v1 = scope.resolve(n2); + if(!(v1 instanceof RFunction f1)) throw failOnFunctionNotFound(s1, + e2.size(), e1.getSymbol()); + var v2 = e2.stream().map(a -> dereference(a.evaluate(scope))).toList(); + var v3 = f1.invoke(f1.bind(scope, v2), v2); + if(v3 instanceof GControl ctrl) return ctrl.toFunction(); + return v3; + } catch(ScriptInvocationException e) { + throw failOnRuntime(e.getCode(), e.getMessage(s1), e.getToken(e1.getSymbol()), e); + } catch(ScriptArgumentException e) { + throw failOnRuntime(e.getCode(), e.getMessage(s1), e1.getSymbol(), e); + } + }, INVK01, ctx); + } + + @Override + public Evaluator visitTryofExpression(SchemaParser.TryofExpressionContext ctx) { + var e1 = visit(ctx.expression()); + return scope -> { + try { + var value = dereference(e1.evaluate(scope)); + return createTryofMonad(value, UNDEFINED); + } catch(Exception e) { + LogHelper.log(e, ctx.expression().getStart()); + return createTryofMonad(UNDEFINED, GString.of(e.getMessage())); + } + }; + } + + @Override + public Evaluator visitThrowExpression(SchemaParser.ThrowExpressionContext ctx) { + var hasCode = ctx.G_COMMA() != null; + var e1 = hasCode ? visit(ctx.expression(0)) : CODE_SUPPLIER; + var e2 = hasCode ? visit(ctx.expression(1)) : visit(ctx.expression(0)); + return tryCatch(scope -> { + var s1 = stringify(dereference(e1.evaluate(scope))); + var s2 = stringify(dereference(e2.evaluate(scope))); + throw new ScriptInitiatedException(formatForSchema(s1, s2, + ctx.G_THROW().getSymbol())); + }, THRO02, ctx); + } + + @Override + public Evaluator visitTargetExpression(SchemaParser.TargetExpressionContext ctx) { + return tryCatch(scope -> { + var v1 = scope.resolve(TARGET_HVAR); + if(v1 == VOID) throw failOnTargetNotFound(ctx.G_TARGET().getSymbol()); + return v1; + }, TRGT02, ctx); + } + + @Override + public Evaluator visitCallerExpression(SchemaParser.CallerExpressionContext ctx) { + return tryCatch(scope -> { + var v1 = scope.resolve(CALLER_HVAR); + if(v1 == VOID) throw failOnCallerNotFound(ctx.G_CALLER().getSymbol()); + return v1; + }, CALR02, ctx); + } + + @Override + public Evaluator visitIdentifierExpression(SchemaParser.IdentifierExpressionContext ctx) { + var e1 = ctx.G_IDENTIFIER(); + var s1 = e1.getText(); + return tryCatch(scope -> { + var v1 = scope.resolve(s1); + if(v1 == VOID) throw failOnIdentifierNotFound(e1.getSymbol()); + return v1; + }, VARD04, ctx); + } + + @Override + public Evaluator visitRangeBothExpression(SchemaParser.RangeBothExpressionContext ctx) { + var e1 = visit(ctx.expression(0)); + var e2 = visit(ctx.expression(1)); + if(e2 == null) return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + if(!(v1 instanceof EInteger i1)) throw failOnOperation(RNGS01, + RANGE, v1, ctx.G_RANGE()); + return GRange.of(i1, null); + }, RNGS11, ctx); + + return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + var v2 = dereference(e2.evaluate(scope)); + if(!(v1 instanceof EInteger i1) || !(v2 instanceof EInteger i2)) + throw failOnOperation(RNGS02, RANGE, v1, v2, ctx.G_RANGE()); + return GRange.of(i1, i2); + }, RNGS12, ctx); + } + + @Override + public Evaluator visitRangeEndExpression(SchemaParser.RangeEndExpressionContext ctx) { + var e2 = visit(ctx.expression()); + return tryCatch(scope -> { + var v2 = dereference(e2.evaluate(scope)); + if(!(v2 instanceof EInteger i2)) throw failOnOperation(RNGS03, RANGE, v2, ctx.G_RANGE()); + return GRange.of(null, i2); + }, RNGS13, ctx); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor3.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor3.java new file mode 100644 index 0000000..6c6f716 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor3.java @@ -0,0 +1,311 @@ +package com.relogiclabs.jschema.internal.engine; + +import com.relogiclabs.jschema.internal.antlr.SchemaParser; +import com.relogiclabs.jschema.internal.script.GBoolean; +import com.relogiclabs.jschema.internal.script.GDouble; +import com.relogiclabs.jschema.internal.script.GInteger; +import com.relogiclabs.jschema.internal.script.GReference; +import com.relogiclabs.jschema.internal.script.GString; +import com.relogiclabs.jschema.tree.RuntimeContext; +import com.relogiclabs.jschema.type.EInteger; +import com.relogiclabs.jschema.type.ENumber; +import com.relogiclabs.jschema.type.EString; + +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnInvalidLValueAssignment; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnInvalidLValueDecrement; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnInvalidLValueIncrement; +import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnOperation; +import static com.relogiclabs.jschema.internal.engine.ScriptOperation.ADDITION; +import static com.relogiclabs.jschema.internal.engine.ScriptOperation.COMPARISON; +import static com.relogiclabs.jschema.internal.engine.ScriptOperation.DECREMENT; +import static com.relogiclabs.jschema.internal.engine.ScriptOperation.DIVISION; +import static com.relogiclabs.jschema.internal.engine.ScriptOperation.INCREMENT; +import static com.relogiclabs.jschema.internal.engine.ScriptOperation.MULTIPLICATION; +import static com.relogiclabs.jschema.internal.engine.ScriptOperation.NEGATION; +import static com.relogiclabs.jschema.internal.engine.ScriptOperation.SUBTRACTION; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.areEqual; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.decrement; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.dereference; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.increment; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.stringify; +import static com.relogiclabs.jschema.internal.script.GBoolean.FALSE; +import static com.relogiclabs.jschema.internal.script.GBoolean.TRUE; +import static com.relogiclabs.jschema.message.ErrorCode.ADDT01; +import static com.relogiclabs.jschema.message.ErrorCode.ADDT02; +import static com.relogiclabs.jschema.message.ErrorCode.ANDL01; +import static com.relogiclabs.jschema.message.ErrorCode.ASIN02; +import static com.relogiclabs.jschema.message.ErrorCode.DECR01; +import static com.relogiclabs.jschema.message.ErrorCode.DECR02; +import static com.relogiclabs.jschema.message.ErrorCode.DECR03; +import static com.relogiclabs.jschema.message.ErrorCode.DECR04; +import static com.relogiclabs.jschema.message.ErrorCode.DECR05; +import static com.relogiclabs.jschema.message.ErrorCode.DECR06; +import static com.relogiclabs.jschema.message.ErrorCode.DIVD01; +import static com.relogiclabs.jschema.message.ErrorCode.DIVD02; +import static com.relogiclabs.jschema.message.ErrorCode.EQUL01; +import static com.relogiclabs.jschema.message.ErrorCode.INCR01; +import static com.relogiclabs.jschema.message.ErrorCode.INCR02; +import static com.relogiclabs.jschema.message.ErrorCode.INCR03; +import static com.relogiclabs.jschema.message.ErrorCode.INCR04; +import static com.relogiclabs.jschema.message.ErrorCode.INCR05; +import static com.relogiclabs.jschema.message.ErrorCode.INCR06; +import static com.relogiclabs.jschema.message.ErrorCode.MULT01; +import static com.relogiclabs.jschema.message.ErrorCode.MULT02; +import static com.relogiclabs.jschema.message.ErrorCode.NEGT01; +import static com.relogiclabs.jschema.message.ErrorCode.NEGT02; +import static com.relogiclabs.jschema.message.ErrorCode.NEQL01; +import static com.relogiclabs.jschema.message.ErrorCode.NOTL01; +import static com.relogiclabs.jschema.message.ErrorCode.ORLG01; +import static com.relogiclabs.jschema.message.ErrorCode.RELA01; +import static com.relogiclabs.jschema.message.ErrorCode.RELA02; +import static com.relogiclabs.jschema.message.ErrorCode.RELA03; +import static com.relogiclabs.jschema.message.ErrorCode.RELA04; +import static com.relogiclabs.jschema.message.ErrorCode.RELA05; +import static com.relogiclabs.jschema.message.ErrorCode.RELA06; +import static com.relogiclabs.jschema.message.ErrorCode.RELA07; +import static com.relogiclabs.jschema.message.ErrorCode.RELA08; +import static com.relogiclabs.jschema.message.ErrorCode.SUBT01; +import static com.relogiclabs.jschema.message.ErrorCode.SUBT02; + +public final class ScriptTreeVisitor3 extends ScriptTreeVisitor2 { + public ScriptTreeVisitor3(RuntimeContext runtime) { + super(runtime); + } + + @Override + public Evaluator visitUnaryMinusExpression(SchemaParser.UnaryMinusExpressionContext ctx) { + var e1 = visit(ctx.expression()); + return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + if(v1 instanceof EInteger i1) return GInteger.of(-i1.getValue()); + if(v1 instanceof ENumber n1) return GDouble.of(-n1.toDouble()); + throw failOnOperation(NEGT01, NEGATION, v1, ctx.G_MINUS()); + }, NEGT02, ctx); + } + + @Override + public Evaluator visitLogicalNotExpression(SchemaParser.LogicalNotExpressionContext ctx) { + var e1 = visit(ctx.expression()); + return tryCatch(scope -> e1.evaluate(scope).toBoolean() ? FALSE : TRUE, + NOTL01, ctx); + } + + @Override + public Evaluator visitPostIncrementExpression(SchemaParser.PostIncrementExpressionContext ctx) { + var e1 = visit(ctx.refExpression()); + return tryCatch(scope -> { + var v1 = e1.evaluate(scope); + if(!(v1 instanceof GReference r1)) throw failOnInvalidLValueIncrement(INCR01, + ctx.refExpression().getStart()); + if(!(r1.getValue() instanceof ENumber n1)) throw failOnOperation(INCR02, + INCREMENT, v1, ctx.G_INC()); + r1.setValue(increment(n1)); + return n1; + }, INCR05, ctx); + } + + @Override + public Evaluator visitPreIncrementExpression(SchemaParser.PreIncrementExpressionContext ctx) { + var e1 = visit(ctx.refExpression()); + return tryCatch(scope -> { + var v1 = e1.evaluate(scope); + if(!(v1 instanceof GReference r1)) throw failOnInvalidLValueIncrement(INCR03, + ctx.refExpression().getStart()); + if(!(r1.getValue() instanceof ENumber n1)) throw failOnOperation(INCR04, + INCREMENT, v1, ctx.G_INC()); + r1.setValue(n1 = increment(n1)); + return n1; + }, INCR06, ctx); + } + + @Override + public Evaluator visitPostDecrementExpression(SchemaParser.PostDecrementExpressionContext ctx) { + var e1 = visit(ctx.refExpression()); + return tryCatch(scope -> { + var v1 = e1.evaluate(scope); + if(!(v1 instanceof GReference r1)) throw failOnInvalidLValueDecrement(DECR01, + ctx.refExpression().getStart()); + if(!(r1.getValue() instanceof ENumber n1)) throw failOnOperation(DECR02, + DECREMENT, v1, ctx.G_DEC()); + r1.setValue(decrement(n1)); + return n1; + }, DECR05, ctx); + } + + @Override + public Evaluator visitPreDecrementExpression(SchemaParser.PreDecrementExpressionContext ctx) { + var e1 = visit(ctx.refExpression()); + return tryCatch(scope -> { + var v1 = e1.evaluate(scope); + if(!(v1 instanceof GReference r1)) throw failOnInvalidLValueDecrement(DECR03, + ctx.refExpression().getStart()); + if(!(r1.getValue() instanceof ENumber n1)) throw failOnOperation(DECR04, + DECREMENT, v1, ctx.G_DEC()); + r1.setValue(n1 = decrement(n1)); + return n1; + }, DECR06, ctx); + } + + @Override + public Evaluator visitMultiplicativeExpression(SchemaParser.MultiplicativeExpressionContext ctx) { + var e1 = visit(ctx.expression(0)); + var e2 = visit(ctx.expression(1)); + if(ctx.G_MUL() != null) return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + var v2 = dereference(e2.evaluate(scope)); + if(v1 instanceof EInteger i1 && v2 instanceof EInteger i2) + return GInteger.of(i1.getValue() * i2.getValue()); + if(v1 instanceof ENumber n1 && v2 instanceof ENumber n2) + return GDouble.of(n1.toDouble() * n2.toDouble()); + throw failOnOperation(MULT01, MULTIPLICATION, v1, v2, ctx.G_MUL()); + }, MULT02, ctx); + + if(ctx.G_DIV() != null) return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + var v2 = dereference(e2.evaluate(scope)); + if(v1 instanceof EInteger i1 && v2 instanceof EInteger i2) + return GInteger.of(i1.getValue() / i2.getValue()); + if(v1 instanceof ENumber n1 && v2 instanceof ENumber n2) + return GDouble.of(n1.toDouble() / n2.toDouble()); + throw failOnOperation(DIVD01, DIVISION, v1, v2, ctx.G_DIV()); + }, DIVD02, ctx); + + throw new IllegalStateException("Invalid parser state"); + } + + @Override + public Evaluator visitAdditiveExpression(SchemaParser.AdditiveExpressionContext ctx) { + var e1 = visit(ctx.expression(0)); + var e2 = visit(ctx.expression(1)); + if(ctx.G_PLUS() != null) return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + var v2 = dereference(e2.evaluate(scope)); + if(v1 instanceof EInteger i1 && v2 instanceof EInteger i2) + return GInteger.of(i1.getValue() + i2.getValue()); + if(v1 instanceof ENumber n1 && v2 instanceof ENumber n2) + return GDouble.of(n1.toDouble() + n2.toDouble()); + if(v1 instanceof EString || v2 instanceof EString) + return GString.of(stringify(v1) + stringify(v2)); + throw failOnOperation(ADDT01, ADDITION, v1, v2, ctx.G_PLUS()); + }, ADDT02, ctx); + + if(ctx.G_MINUS() != null) return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + var v2 = dereference(e2.evaluate(scope)); + if(v1 instanceof EInteger i1 && v2 instanceof EInteger i2) + return GInteger.of(i1.getValue() - i2.getValue()); + if(v1 instanceof ENumber n1 && v2 instanceof ENumber n2) + return GDouble.of(n1.toDouble() - n2.toDouble()); + throw failOnOperation(SUBT01, SUBTRACTION, v1, v2, ctx.G_MINUS()); + }, SUBT02, ctx); + + throw new IllegalStateException("Invalid parser state"); + } + + @Override + public Evaluator visitRelationalExpression(SchemaParser.RelationalExpressionContext ctx) { + var e1 = visit(ctx.expression(0)); + var e2 = visit(ctx.expression(1)); + if(ctx.G_GT() != null) return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + var v2 = dereference(e2.evaluate(scope)); + if(!(v1 instanceof ENumber n1) || !(v2 instanceof ENumber n2)) + throw failOnOperation(RELA01, COMPARISON, v1, v2, ctx.G_GT()); + double d1 = n1.toDouble(), d2 = n2.toDouble(); + if(runtime.areEqual(d1, d2)) return FALSE; + return d1 > d2 ? TRUE : FALSE; + }, RELA05, ctx); + + if(ctx.G_GE() != null) return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + var v2 = dereference(e2.evaluate(scope)); + if(!(v1 instanceof ENumber n1) || !(v2 instanceof ENumber n2)) + throw failOnOperation(RELA02, COMPARISON, v1, v2, ctx.G_GE()); + double d1 = n1.toDouble(), d2 = n2.toDouble(); + if(runtime.areEqual(d1, d2)) return TRUE; + return d1 > d2 ? TRUE : FALSE; + }, RELA06, ctx); + + if(ctx.G_LT() != null) return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + var v2 = dereference(e2.evaluate(scope)); + if(!(v1 instanceof ENumber n1) || !(v2 instanceof ENumber n2)) + throw failOnOperation(RELA03, COMPARISON, v1, v2, ctx.G_LT()); + double d1 = n1.toDouble(), d2 = n2.toDouble(); + if(runtime.areEqual(d1, d2)) return FALSE; + return d1 < d2 ? TRUE : FALSE; + }, RELA07, ctx); + + if(ctx.G_LE() != null) return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + var v2 = dereference(e2.evaluate(scope)); + if(!(v1 instanceof ENumber n1) || !(v2 instanceof ENumber n2)) + throw failOnOperation(RELA04, COMPARISON, v1, v2, ctx.G_LE()); + double d1 = n1.toDouble(), d2 = n2.toDouble(); + if(runtime.areEqual(d1, d2)) return TRUE; + return d1 < d2 ? TRUE : FALSE; + }, RELA08, ctx); + + throw new IllegalStateException("Invalid parser state"); + } + + @Override + public Evaluator visitEqualityExpression(SchemaParser.EqualityExpressionContext ctx) { + var e1 = visit(ctx.expression(0)); + var e2 = visit(ctx.expression(1)); + if(ctx.G_EQ() != null) return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + var v2 = dereference(e2.evaluate(scope)); + return GBoolean.of(areEqual(v1, v2, runtime)); + }, EQUL01, ctx); + + if(ctx.G_NE() != null) return tryCatch(scope -> { + var v1 = dereference(e1.evaluate(scope)); + var v2 = dereference(e2.evaluate(scope)); + return GBoolean.of(!areEqual(v1, v2, runtime)); + }, NEQL01, ctx); + + throw new IllegalStateException("Invalid parser state"); + } + + @Override + public Evaluator visitLogicalAndExpression(SchemaParser.LogicalAndExpressionContext ctx) { + var e1 = visit(ctx.expression(0)); + var e2 = visit(ctx.expression(1)); + return tryCatch(scope -> { + var v1 = e1.evaluate(scope); + if(!v1.toBoolean()) return v1; + return e2.evaluate(scope); + }, ANDL01, ctx); + } + + @Override + public Evaluator visitLogicalOrExpression(SchemaParser.LogicalOrExpressionContext ctx) { + var e1 = visit(ctx.expression(0)); + var e2 = visit(ctx.expression(1)); + return tryCatch(scope -> { + var v1 = e1.evaluate(scope); + if(v1.toBoolean()) return v1; + return e2.evaluate(scope); + }, ORLG01, ctx); + } + + @Override + public Evaluator visitAssignmentExpression(SchemaParser.AssignmentExpressionContext ctx) { + var e1 = visit(ctx.refExpression()); + var e2 = visit(ctx.expression()); + return tryCatch(scope -> { + var v2 = e2.evaluate(scope); + var v1 = e1.evaluate(scope); + if(!(v1 instanceof GReference r1)) throw failOnInvalidLValueAssignment( + ctx.refExpression().getStart()); + r1.setValue(v2); + return v2; + }, ASIN02, ctx); + } + + @Override + public Evaluator visitParenthesizedExpression(SchemaParser.ParenthesizedExpressionContext ctx) { + return visit(ctx.expression()); + } +} \ No newline at end of file From 5e7ed386db1ca51b3d57103107fa1d5f4308cad6 Mon Sep 17 00:00:00 2001 From: Zahid Hossain <60911932+zhossain-info@users.noreply.github.com> Date: Wed, 21 Feb 2024 14:44:43 +0600 Subject: [PATCH 07/12] Add script data type implementations --- .../jschema/internal/script/GArray.java | 65 ++++++++++++++ .../jschema/internal/script/GBoolean.java | 25 ++++++ .../jschema/internal/script/GControl.java | 37 ++++++++ .../jschema/internal/script/GDouble.java | 18 ++++ .../jschema/internal/script/GFunction.java | 67 ++++++++++++++ .../jschema/internal/script/GInteger.java | 33 +++++++ .../jschema/internal/script/GIterator.java | 87 +++++++++++++++++++ .../jschema/internal/script/GObject.java | 62 +++++++++++++ .../jschema/internal/script/GParameter.java | 24 +++++ .../jschema/internal/script/GRange.java | 46 ++++++++++ .../jschema/internal/script/GReference.java | 49 +++++++++++ .../jschema/internal/script/GString.java | 29 +++++++ .../jschema/internal/script/RFunction.java | 13 +++ 13 files changed, 555 insertions(+) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/GArray.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/GBoolean.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/GControl.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/GDouble.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/GFunction.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/GInteger.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/GIterator.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/GObject.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/GParameter.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/GRange.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/GReference.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/GString.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/script/RFunction.java diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GArray.java b/src/main/java/com/relogiclabs/jschema/internal/script/GArray.java new file mode 100644 index 0000000..d6ad114 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GArray.java @@ -0,0 +1,65 @@ +package com.relogiclabs.jschema.internal.script; + +import com.relogiclabs.jschema.exception.ScriptCommonException; +import com.relogiclabs.jschema.type.EArray; +import com.relogiclabs.jschema.type.EValue; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.internal.util.StringHelper.joinWith; +import static com.relogiclabs.jschema.message.ErrorCode.INDX01; + +@Getter +@EqualsAndHashCode +public final class GArray implements EArray { + private static final int MAX_LIMIT = Short.MAX_VALUE; + private final List elements; + + private GArray(int size) { + this.elements = new ArrayList<>(size); + } + + public GArray(Collection collection) { + this.elements = new ArrayList<>(collection.size()); + for(var v : collection) elements.add(new GReference(v)); + } + + public static GArray filledFrom(EValue value, int size) { + var array = new GArray(size); + for(int i = 0; i < size; i++) array.elements.add(new GReference(value)); + return array; + } + + public static GArray from(EArray array, GRange range) { + var list = array.elements(); + var size = list.size(); + return new GArray(list.subList(range.getStart(size), range.getEnd(size))); + } + + @Override + public EValue get(int index) { + var size = elements.size(); + if(index < size) return elements.get(index); + if(index > MAX_LIMIT) throw new ScriptCommonException(INDX01, + concat("Array index ", index, " exceeds maximum size limit")); + if(index > size) throw new ArrayIndexOutOfBoundsException(index); + var element = new GReference(VOID); + elements.add(element); + return element; + } + + @Override + public List elements() { + return elements; + } + + @Override + public String toString() { + return joinWith(elements, ", ", "[", "]"); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GBoolean.java b/src/main/java/com/relogiclabs/jschema/internal/script/GBoolean.java new file mode 100644 index 0000000..1f8cdd8 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GBoolean.java @@ -0,0 +1,25 @@ +package com.relogiclabs.jschema.internal.script; + +import com.relogiclabs.jschema.type.EBoolean; +import lombok.EqualsAndHashCode; +import lombok.RequiredArgsConstructor; + +import static lombok.AccessLevel.PRIVATE; + +@EqualsAndHashCode +@RequiredArgsConstructor(access = PRIVATE) +public final class GBoolean implements EBoolean { + public static final GBoolean TRUE = new GBoolean(true); + public static final GBoolean FALSE = new GBoolean(false); + + private final boolean value; + + public static GBoolean of(boolean value) { + return value? TRUE : FALSE; + } + + @Override + public boolean getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GControl.java b/src/main/java/com/relogiclabs/jschema/internal/script/GControl.java new file mode 100644 index 0000000..6c25b49 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GControl.java @@ -0,0 +1,37 @@ +package com.relogiclabs.jschema.internal.script; + +import com.relogiclabs.jschema.type.EValue; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import static lombok.AccessLevel.PRIVATE; + +@RequiredArgsConstructor(access = PRIVATE) +public final class GControl implements EValue { + private static final int BREAK_FLAG = 1; + private static final int RETURN_FLAG = 2; + public static final GControl BREAK = new GControl(BREAK_FLAG, VOID); + + private final int flag; + @Getter private final EValue value; + + public static GControl ofReturn(EValue value) { + return new GControl(RETURN_FLAG, value); + } + + public boolean isBreak() { + return flag == BREAK_FLAG; + } + + public boolean isReturn() { + return flag == RETURN_FLAG; + } + + public EValue toIteration() { + return flag == BREAK_FLAG ? VOID : this; + } + + public EValue toFunction() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GDouble.java b/src/main/java/com/relogiclabs/jschema/internal/script/GDouble.java new file mode 100644 index 0000000..198b7c9 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GDouble.java @@ -0,0 +1,18 @@ +package com.relogiclabs.jschema.internal.script; + +import com.relogiclabs.jschema.type.EDouble; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@EqualsAndHashCode +@RequiredArgsConstructor(staticName = "of") +public final class GDouble implements EDouble { + private final double value; + + @Override + public String toString() { + return String.valueOf(value); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GFunction.java b/src/main/java/com/relogiclabs/jschema/internal/script/GFunction.java new file mode 100644 index 0000000..0033781 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GFunction.java @@ -0,0 +1,67 @@ +package com.relogiclabs.jschema.internal.script; + +import com.relogiclabs.jschema.internal.engine.Evaluator; +import com.relogiclabs.jschema.internal.engine.ScopeContext; +import com.relogiclabs.jschema.type.EValue; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import java.util.List; + +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.areCompatible; +import static com.relogiclabs.jschema.internal.util.CollectionHelper.getLast; +import static com.relogiclabs.jschema.internal.util.CollectionHelper.subList; +import static com.relogiclabs.jschema.internal.util.MiscellaneousHelper.hasFlag; +import static com.relogiclabs.jschema.message.ErrorCode.FUNS05; + +@Getter +@RequiredArgsConstructor +public final class GFunction implements RFunction { + public static final String CONSTRAINT_MARKER = "@"; + public static final int CONSTRAINT_MODE = 1; + public static final int FUTURE_MODE = 3; + public static final int SUBROUTINE_MODE = 4; + + private final GParameter[] parameters; + private final boolean variadic; + private final Evaluator body; + private final int mode; + + public GFunction(GParameter[] parameters, Evaluator body, int mode) { + this.parameters = parameters; + this.body = body; + this.mode = mode; + this.variadic = parameters.length != 0 && getLast(parameters).isVariadic(); + } + + @Override + public EValue invoke(ScopeContext functionScope, List arguments) { + return invoke(functionScope); + } + + public EValue invoke(ScopeContext functionScope) { + var v1 = getBody().evaluate(functionScope); + if(v1 instanceof GControl ctrl) return ctrl.getValue(); + return VOID; + } + + @Override + public ScopeContext bind(ScopeContext parentScope, List arguments) { + areCompatible(parameters, arguments, FUNS05); + var scope = new ScopeContext(parentScope); + var i = 0; + for(var p : parameters) { + if(p.isVariadic()) scope.addVariable(p.getName(), new GArray(subList(arguments, i))); + else scope.addVariable(p.getName(), arguments.get(i++)); + } + return scope; + } + + public boolean isFuture() { + return hasFlag(mode, FUTURE_MODE); + } + + public static boolean isConstraint(int mode) { + return hasFlag(mode, CONSTRAINT_MODE); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GInteger.java b/src/main/java/com/relogiclabs/jschema/internal/script/GInteger.java new file mode 100644 index 0000000..09be8d5 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GInteger.java @@ -0,0 +1,33 @@ +package com.relogiclabs.jschema.internal.script; + +import com.relogiclabs.jschema.type.EInteger; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import static lombok.AccessLevel.PRIVATE; + +@Getter +@EqualsAndHashCode +@RequiredArgsConstructor(access = PRIVATE) +public final class GInteger implements EInteger { + private static final int CACHE_SIZE = 256; + private static final GInteger[] CACHE = createCache(CACHE_SIZE); + private final long value; + + public static GInteger of(long value) { + if(value >= 0 && value < CACHE_SIZE) return CACHE[(int) value]; + return new GInteger(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + private static GInteger[] createCache(int size) { + GInteger[] cache = new GInteger[size]; + for(int i = 0; i < size; i++) cache[i] = new GInteger(i); + return cache; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GIterator.java b/src/main/java/com/relogiclabs/jschema/internal/script/GIterator.java new file mode 100644 index 0000000..e976311 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GIterator.java @@ -0,0 +1,87 @@ +package com.relogiclabs.jschema.internal.script; + +import com.relogiclabs.jschema.exception.ScriptCommonException; +import com.relogiclabs.jschema.type.EArray; +import com.relogiclabs.jschema.type.EObject; +import com.relogiclabs.jschema.type.EString; +import com.relogiclabs.jschema.type.EValue; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import java.util.Iterator; + +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.dereference; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.ITER01; +import static lombok.AccessLevel.PRIVATE; + +@Getter +@RequiredArgsConstructor(access = PRIVATE) +public final class GIterator implements Iterable { + private final EValue iterable; + + public static GIterator of(EValue iterable) { + return new GIterator(dereference(iterable)); + } + + @Override + public Iterator iterator() { + if(iterable instanceof EArray array) return iterator(array); + if(iterable instanceof EObject object) return iterator(object); + if(iterable instanceof EString string) return iterator(string); + else throw new ScriptCommonException(ITER01, + concat("Invalid type ", iterable.getType(), " for iteration")); + } + + public Iterator iterator(EArray array) { + while(array.size() == 1) { + if(array.get(0) instanceof EArray) + array = (EArray) array.get(0); + else break; + } + var iterator = array.elements().iterator(); + return new Iterator<>() { + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public EValue next() { + return iterator.next(); + } + }; + } + + public Iterator iterator(EString string) { + String value = string.getValue(); + return new Iterator<>() { + private int index = 0; + + @Override + public boolean hasNext() { + return index < value.length(); + } + + @Override + public EValue next() { + return GString.of(value.charAt(index++)); + } + }; + } + + public Iterator iterator(EObject object) { + var iterator = object.keySet().iterator(); + return new Iterator<>() { + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public EValue next() { + return GString.of(iterator.next()); + } + }; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GObject.java b/src/main/java/com/relogiclabs/jschema/internal/script/GObject.java new file mode 100644 index 0000000..29b6a32 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GObject.java @@ -0,0 +1,62 @@ +package com.relogiclabs.jschema.internal.script; + +import com.relogiclabs.jschema.type.EObject; +import com.relogiclabs.jschema.type.EValue; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static com.relogiclabs.jschema.internal.util.StringHelper.joinWith; +import static com.relogiclabs.jschema.internal.util.StringHelper.quote; + +@Getter +@EqualsAndHashCode +public final class GObject implements EObject { + private final Map properties; + + public GObject(int capacity) { + properties = new LinkedHashMap<>(capacity); + } + + public GObject(EObject value) { + this(value.size()); + for(var e : value.keySet()) properties.put(e, new GReference(value.get(e))); + } + + public GObject(List keys, List values) { + this(keys.size()); + for(int i = 0; i < keys.size(); i++) + properties.put(keys.get(i), new GReference(values.get(i))); + } + + @Override + public EValue get(String key) { + var value = properties.get(key); + if(value == null) properties.put(key, value = new GReference(VOID)); + return value; + } + + public void set(String key, EValue value) { + properties.put(key, value); + } + + @Override + public int size() { + return properties.size(); + } + + @Override + public Set keySet() { + return properties.keySet(); + } + + @Override + public String toString() { + return joinWith(properties.entrySet().stream() + .map(e -> quote(e.getKey()) + ": " + e.getValue()), ", ", "{", "}"); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GParameter.java b/src/main/java/com/relogiclabs/jschema/internal/script/GParameter.java new file mode 100644 index 0000000..6f5d11c --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GParameter.java @@ -0,0 +1,24 @@ +package com.relogiclabs.jschema.internal.script; + +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import static org.apache.commons.lang3.StringUtils.removeEnd; + +@Getter +@EqualsAndHashCode +public final class GParameter { + private static final String VARIADIC_MARKER = "..."; + private final String name; + private final boolean variadic; + + public GParameter(String name) { + this.variadic = name.endsWith(VARIADIC_MARKER); + this.name = removeEnd(name, VARIADIC_MARKER); + } + + @Override + public String toString() { + return variadic ? name + VARIADIC_MARKER : name; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GRange.java b/src/main/java/com/relogiclabs/jschema/internal/script/GRange.java new file mode 100644 index 0000000..c6f5fcd --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GRange.java @@ -0,0 +1,46 @@ +package com.relogiclabs.jschema.internal.script; + +import com.relogiclabs.jschema.type.EInteger; +import com.relogiclabs.jschema.type.EType; +import com.relogiclabs.jschema.type.EValue; +import lombok.EqualsAndHashCode; +import lombok.RequiredArgsConstructor; + +import static lombok.AccessLevel.PRIVATE; +import static org.apache.commons.lang3.StringUtils.EMPTY; + +@EqualsAndHashCode +@RequiredArgsConstructor(access = PRIVATE) +public final class GRange implements EValue { + public static final String RANGE_MARKER = ".."; + private final int start; + private final int end; + + public static GRange of(EInteger start, EInteger end) { + var v1 = start == null ? Integer.MIN_VALUE : (int) start.getValue(); + var v2 = end == null ? Integer.MIN_VALUE : (int) end.getValue(); + return new GRange(v1, v2); + } + + public int getStart(int size) { + if(start == Integer.MIN_VALUE) return 0; + return start >= 0 ? start : size + start; + } + + public int getEnd(int size) { + if(end == Integer.MIN_VALUE) return size; + return end >= 0 ? end : size + end; + } + + @Override + public EType getType() { + return EType.RANGE; + } + + @Override + public String toString() { + var pStart = start != Integer.MIN_VALUE ? start : EMPTY; + var pEnd = end != Integer.MIN_VALUE ? end : EMPTY; + return pStart + RANGE_MARKER + pEnd; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GReference.java b/src/main/java/com/relogiclabs/jschema/internal/script/GReference.java new file mode 100644 index 0000000..8da2537 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GReference.java @@ -0,0 +1,49 @@ +package com.relogiclabs.jschema.internal.script; + +import com.relogiclabs.jschema.type.EType; +import com.relogiclabs.jschema.type.EValue; +import lombok.Getter; + +import java.util.Objects; + +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.dereference; + +@Getter +public final class GReference implements EValue { + private EValue value; + + public GReference(EValue value) { + this.value = dereference(value); + } + + public void setValue(EValue value) { + this.value = dereference(value); + } + + @Override + public EType getType() { + return value.getType(); + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(!(o instanceof EValue)) return false; + return Objects.equals(value, o); + } + + @Override + public int hashCode() { + return value.hashCode(); + } + + @Override + public boolean toBoolean() { + return value.toBoolean(); + } + + @Override + public String toString() { + return value.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GString.java b/src/main/java/com/relogiclabs/jschema/internal/script/GString.java new file mode 100644 index 0000000..fef80a0 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GString.java @@ -0,0 +1,29 @@ +package com.relogiclabs.jschema.internal.script; + +import com.relogiclabs.jschema.type.EString; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import static com.relogiclabs.jschema.internal.util.StringHelper.quote; + +@Getter +@RequiredArgsConstructor(staticName = "of") +public final class GString implements EString { + private final String value; + + public static GString of(char value) { + return new GString(String.valueOf(value)); + } + + public static GString from(EString string, GRange range) { + var value = string.getValue(); + var length = value.length(); + return GString.of(value.substring(range.getStart(length), + range.getEnd(length))); + } + + @Override + public String toString() { + return quote(value); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/RFunction.java b/src/main/java/com/relogiclabs/jschema/internal/script/RFunction.java new file mode 100644 index 0000000..351346c --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/script/RFunction.java @@ -0,0 +1,13 @@ +package com.relogiclabs.jschema.internal.script; + +import com.relogiclabs.jschema.internal.engine.ScopeContext; +import com.relogiclabs.jschema.type.EValue; + +import java.util.List; + +public interface RFunction extends EValue { + ScopeContext bind(ScopeContext parentScope, List arguments); + EValue invoke(ScopeContext functionScope, List arguments); + GParameter[] getParameters(); + boolean isVariadic(); +} \ No newline at end of file From dc35ab14afef53ef18d9317e3f767db28a186fa0 Mon Sep 17 00:00:00 2001 From: Zahid Hossain <60911932+zhossain-info@users.noreply.github.com> Date: Wed, 21 Feb 2024 16:56:38 +0600 Subject: [PATCH 08/12] Update schema nodes for script engine --- .../relogiclabs/jschema/node/Derivable.java | 5 + .../com/relogiclabs/jschema/node/JAlias.java | 39 ++++ .../com/relogiclabs/jschema/node/JArray.java | 92 ++++++++++ .../relogiclabs/jschema/node/JBoolean.java | 53 ++++++ .../schema/type => jschema/node}/JBranch.java | 4 +- .../type => jschema/node}/JComposite.java | 9 +- .../relogiclabs/jschema/node/JDataType.java | 96 ++++++++++ .../schema/type => jschema/node}/JDate.java | 9 +- .../type => jschema/node}/JDateTime.java | 11 +- .../type => jschema/node}/JDefinition.java | 8 +- .../type => jschema/node}/JDirective.java | 4 +- .../com/relogiclabs/jschema/node/JDouble.java | 53 ++++++ .../com/relogiclabs/jschema/node/JFloat.java | 59 +++++++ .../relogiclabs/jschema/node/JFunction.java | 82 +++++++++ .../com/relogiclabs/jschema/node/JImport.java | 29 +++ .../relogiclabs/jschema/node/JInteger.java | 51 ++++++ .../schema/type => jschema/node}/JLeaf.java | 4 +- .../com/relogiclabs/jschema/node/JNode.java | 77 ++++++++ .../schema/type => jschema/node}/JNull.java | 16 +- .../schema/type => jschema/node}/JNumber.java | 14 +- .../com/relogiclabs/jschema/node/JObject.java | 134 ++++++++++++++ .../com/relogiclabs/jschema/node/JPragma.java | 38 ++++ .../type => jschema/node}/JPrimitive.java | 9 +- .../relogiclabs/jschema/node/JProperty.java | 69 ++++++++ .../relogiclabs/jschema/node/JReceiver.java | 84 +++++++++ .../com/relogiclabs/jschema/node/JRoot.java | 76 ++++++++ .../com/relogiclabs/jschema/node/JScript.java | 28 +++ .../com/relogiclabs/jschema/node/JString.java | 58 ++++++ .../schema/type => jschema/node}/JTime.java | 9 +- .../schema/type => jschema/node}/JTitle.java | 6 +- .../type => jschema/node}/JUndefined.java | 7 +- .../relogiclabs/jschema/node/JValidator.java | 166 ++++++++++++++++++ .../type => jschema/node}/JVersion.java | 4 +- .../relogiclabs/jschema/node/JsonTypable.java | 7 + .../relogiclabs/jschema/node/JsonType.java | 107 +++++++++++ .../relogiclabs/jschema/node/NestedMode.java | 5 + .../relogiclabs/jschema/node/PragmaValue.java | 5 + .../json/schema/type/JInclude.java | 29 --- 38 files changed, 1461 insertions(+), 95 deletions(-) create mode 100644 src/main/java/com/relogiclabs/jschema/node/Derivable.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JAlias.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JArray.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JBoolean.java rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JBranch.java (52%) rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JComposite.java (61%) create mode 100644 src/main/java/com/relogiclabs/jschema/node/JDataType.java rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JDate.java (58%) rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JDateTime.java (52%) rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JDefinition.java (74%) rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JDirective.java (69%) create mode 100644 src/main/java/com/relogiclabs/jschema/node/JDouble.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JFloat.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JFunction.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JImport.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JInteger.java rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JLeaf.java (60%) create mode 100644 src/main/java/com/relogiclabs/jschema/node/JNode.java rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JNull.java (55%) rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JNumber.java (61%) create mode 100644 src/main/java/com/relogiclabs/jschema/node/JObject.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JPragma.java rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JPrimitive.java (58%) create mode 100644 src/main/java/com/relogiclabs/jschema/node/JProperty.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JReceiver.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JRoot.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JScript.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JString.java rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JTime.java (58%) rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JTitle.java (76%) rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JUndefined.java (68%) create mode 100644 src/main/java/com/relogiclabs/jschema/node/JValidator.java rename src/main/java/com/relogiclabs/{json/schema/type => jschema/node}/JVersion.java (83%) create mode 100644 src/main/java/com/relogiclabs/jschema/node/JsonTypable.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/JsonType.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/NestedMode.java create mode 100644 src/main/java/com/relogiclabs/jschema/node/PragmaValue.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JInclude.java diff --git a/src/main/java/com/relogiclabs/jschema/node/Derivable.java b/src/main/java/com/relogiclabs/jschema/node/Derivable.java new file mode 100644 index 0000000..fc1fe71 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/Derivable.java @@ -0,0 +1,5 @@ +package com.relogiclabs.jschema.node; + +public interface Derivable { + JNode getDerived(); +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JAlias.java b/src/main/java/com/relogiclabs/jschema/node/JAlias.java new file mode 100644 index 0000000..16ef31a --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JAlias.java @@ -0,0 +1,39 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.DefinitionNotFoundException; +import com.relogiclabs.jschema.internal.builder.JAliasBuilder; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.DEFI02; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; +import static java.util.Objects.requireNonNull; + +@Getter +@EqualsAndHashCode +public final class JAlias extends JLeaf { + private final String name; + + private JAlias(JAliasBuilder builder) { + super(builder); + name = requireNonNull(builder.name()); + } + + public static JAlias from(JAliasBuilder builder) { + return new JAlias(builder).initialize(); + } + + @Override + public boolean match(JNode node) { + var definitions = getRuntime().getDefinitions(); + if(!definitions.containsKey(this)) throw new DefinitionNotFoundException(formatForSchema( + DEFI02, concat("Definition of '", name, "' not found"), getContext())); + return definitions.get(this).match(node); + } + + @Override + public String toString() { + return name; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JArray.java b/src/main/java/com/relogiclabs/jschema/node/JArray.java new file mode 100644 index 0000000..de60910 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JArray.java @@ -0,0 +1,92 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.exception.MisplacedOptionalException; +import com.relogiclabs.jschema.internal.builder.JArrayBuilder; +import com.relogiclabs.jschema.internal.message.ActualHelper; +import com.relogiclabs.jschema.internal.message.ExpectedHelper; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.type.EArray; +import com.relogiclabs.jschema.type.EValue; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.ArrayElementNotFound; +import static com.relogiclabs.jschema.internal.util.StringHelper.joinWith; +import static com.relogiclabs.jschema.message.ErrorCode.ARRY01; +import static com.relogiclabs.jschema.message.ErrorCode.ARRY02; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; +import static java.util.Objects.requireNonNull; + +@Getter +@EqualsAndHashCode +public final class JArray extends JComposite implements EArray, Iterable { + private final List elements; + + private JArray(JArrayBuilder builder) { + super(builder); + elements = requireNonNull(builder.elements()); + children = elements; + } + + public static JArray from(JArrayBuilder builder) { + return new JArray(builder).initialize(); + } + + @Override + public Collection components() { + return elements; + } + + @Override + public boolean match(JNode node) { + var other = castType(node, JArray.class); + if(other == null) return false; + boolean result = true, restOptional = false; + for(var i = 0; i < elements.size(); i++) { + var optional = isOptional(elements.get(i)); + if((restOptional |= optional) != optional) + return fail(new MisplacedOptionalException(formatForSchema(ARRY02, + "Mandatory array element cannot appear after optional element", + elements.get(i)))); + if(i >= other.elements.size() && !optional) + return fail(new JsonSchemaException( + new ErrorDetail(ARRY01, ArrayElementNotFound), + ExpectedHelper.asArrayElementNotFound(elements.get(i), i), + ActualHelper.asArrayElementNotFound(other, i))); + if(i >= other.elements.size()) continue; + result &= elements.get(i).match(other.elements.get(i)); + } + return result; + } + + private static boolean isOptional(JNode node) { + if(node instanceof JValidator validator) + return validator.isOptional(); + return false; + } + + @Override + public EValue get(int index) { + return elements.get(index); + } + + @Override + public List elements() { + return elements; + } + + @Override + public Iterator iterator() { + return elements.iterator(); + } + + @Override + public String toString() { + return joinWith(elements, ", ", "[", "]"); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JBoolean.java b/src/main/java/com/relogiclabs/jschema/node/JBoolean.java new file mode 100644 index 0000000..52e6736 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JBoolean.java @@ -0,0 +1,53 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.internal.builder.JBooleanBuilder; +import com.relogiclabs.jschema.internal.message.ActualHelper; +import com.relogiclabs.jschema.internal.message.ExpectedHelper; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.type.EBoolean; +import lombok.EqualsAndHashCode; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.ValueMismatch; +import static com.relogiclabs.jschema.message.ErrorCode.BOOL01; +import static java.util.Objects.requireNonNull; + +@EqualsAndHashCode +public final class JBoolean extends JPrimitive implements EBoolean, PragmaValue { + private final boolean value; + + private JBoolean(JBooleanBuilder builder) { + super(builder); + value = requireNonNull(builder.value()); + } + + public static JBoolean from(JBooleanBuilder builder) { + return new JBoolean(builder).initialize(); + } + + @Override + public boolean match(JNode node) { + var other = castType(node, JBoolean.class); + if(other == null) return false; + if(value == other.value) return true; + return fail(new JsonSchemaException( + new ErrorDetail(BOOL01, ValueMismatch), + ExpectedHelper.asValueMismatch(this), + ActualHelper.asValueMismatch(other))); + } + + @Override + public boolean getValue() { + return value; + } + + @Override + public Boolean toNativeValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JBranch.java b/src/main/java/com/relogiclabs/jschema/node/JBranch.java similarity index 52% rename from src/main/java/com/relogiclabs/json/schema/type/JBranch.java rename to src/main/java/com/relogiclabs/jschema/node/JBranch.java index bd65da9..b97e45a 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JBranch.java +++ b/src/main/java/com/relogiclabs/jschema/node/JBranch.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.internal.builder.JNodeBuilder; +import com.relogiclabs.jschema.internal.builder.JNodeBuilder; public abstract class JBranch extends JNode { JBranch(JNodeBuilder builder) { diff --git a/src/main/java/com/relogiclabs/json/schema/type/JComposite.java b/src/main/java/com/relogiclabs/jschema/node/JComposite.java similarity index 61% rename from src/main/java/com/relogiclabs/json/schema/type/JComposite.java rename to src/main/java/com/relogiclabs/jschema/node/JComposite.java index 0dd3c41..4bd30ad 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JComposite.java +++ b/src/main/java/com/relogiclabs/jschema/node/JComposite.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.internal.builder.JNodeBuilder; +import com.relogiclabs.jschema.internal.builder.JNodeBuilder; import java.util.Collection; @@ -11,11 +11,6 @@ public abstract class JComposite extends JBranch implements JsonTypable { public abstract Collection components(); - @Override - public JsonType getType() { - return JsonType.COMPOSITE; - } - @Override public JNode getNode() { return this; diff --git a/src/main/java/com/relogiclabs/jschema/node/JDataType.java b/src/main/java/com/relogiclabs/jschema/node/JDataType.java new file mode 100644 index 0000000..aa338f4 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JDataType.java @@ -0,0 +1,96 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.DefinitionNotFoundException; +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.internal.builder.JDataTypeBuilder; +import com.relogiclabs.jschema.internal.message.ActualHelper; +import com.relogiclabs.jschema.internal.message.ExpectedHelper; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.util.Reference; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.DataTypeArgumentFailed; +import static com.relogiclabs.jschema.internal.message.MessageHelper.DataTypeMismatch; +import static com.relogiclabs.jschema.internal.util.CollectionHelper.asList; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.DEFI03; +import static com.relogiclabs.jschema.message.ErrorCode.DEFI04; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP04; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP05; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP06; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP07; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; +import static java.util.Objects.requireNonNull; +import static org.apache.commons.lang3.StringUtils.isEmpty; +import static org.apache.commons.lang3.StringUtils.uncapitalize; + +@Getter +@EqualsAndHashCode +public final class JDataType extends JBranch implements NestedMode { + static final String NESTED_MARKER = "*"; + static final String DATA_TYPE_NAME = "DATA_TYPE_NAME"; + private final JsonType jsonType; + private final JAlias alias; + private final boolean nested; + + private JDataType(JDataTypeBuilder builder) { + super(builder); + jsonType = requireNonNull(builder.jsonType()); + nested = requireNonNull(builder.nested()); + alias = builder.alias(); + children = asList(alias); + } + + public static JDataType from(JDataTypeBuilder builder) { + return new JDataType(builder).initialize(); + } + + @Override + public boolean match(JNode node) { + Reference error = new Reference<>(); + if(!jsonType.match(node, error)) return failTypeWith(new JsonSchemaException( + new ErrorDetail(nested ? DTYP06 : DTYP04, + formatMessage(DataTypeMismatch, error.getValue())), + ExpectedHelper.asDataTypeMismatch(this), + ActualHelper.asDataTypeMismatch(node))); + if(alias == null) return true; + var validator = getRuntime().getDefinitions().get(alias); + if(validator == null) return fail(new DefinitionNotFoundException(formatForSchema( + nested ? DEFI04 : DEFI03, concat("No definition found for '", alias, "'"), this))); + if(!validator.match(node)) return fail(new JsonSchemaException( + new ErrorDetail(nested ? DTYP07 : DTYP05, DataTypeArgumentFailed), + ExpectedHelper.asDataTypeArgumentFailed(this), + ActualHelper.asDataTypeArgumentFailed(node))); + return true; + } + + private boolean failTypeWith(JsonSchemaException exception) { + exception.setAttribute(DATA_TYPE_NAME, toString(true)); + return fail(exception); + } + + private static String formatMessage(String main, String optional) { + return isEmpty(optional) ? main : concat(main, " (", uncapitalize(optional), ")"); + } + + boolean isApplicable(JNode node) { + return !nested || node instanceof JComposite; + } + + boolean isMatchNull() { + return !nested && jsonType.isNullType(); + } + + @Override + public String toString() { + return toString(false); + } + + public String toString(boolean baseForm) { + var builder = new StringBuilder(jsonType.toString()); + if(nested && !baseForm) builder.append(NESTED_MARKER); + if(alias != null && !baseForm) builder.append("(").append(alias).append(")"); + return builder.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JDate.java b/src/main/java/com/relogiclabs/jschema/node/JDate.java similarity index 58% rename from src/main/java/com/relogiclabs/json/schema/type/JDate.java rename to src/main/java/com/relogiclabs/jschema/node/JDate.java index 6ebab83..4338a53 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JDate.java +++ b/src/main/java/com/relogiclabs/jschema/node/JDate.java @@ -1,6 +1,7 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.time.JsonDateTime; +import com.relogiclabs.jschema.time.JsonDateTime; +import com.relogiclabs.jschema.type.EType; public final class JDate extends JDateTime { private JDate(JString node, JsonDateTime dateTime) { @@ -11,7 +12,7 @@ public static JDate from(JString node, JsonDateTime dateTime) { return new JDate(node, dateTime); } - public JsonType getType() { - return JsonType.DATE; + public EType getType() { + return EType.DATE; } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JDateTime.java b/src/main/java/com/relogiclabs/jschema/node/JDateTime.java similarity index 52% rename from src/main/java/com/relogiclabs/json/schema/type/JDateTime.java rename to src/main/java/com/relogiclabs/jschema/node/JDateTime.java index 20a78e0..bec0b92 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JDateTime.java +++ b/src/main/java/com/relogiclabs/jschema/node/JDateTime.java @@ -1,7 +1,8 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.internal.time.DateTimeParser; -import com.relogiclabs.json.schema.time.JsonDateTime; +import com.relogiclabs.jschema.internal.time.DateTimeParser; +import com.relogiclabs.jschema.time.JsonDateTime; +import com.relogiclabs.jschema.type.EType; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,8 +17,8 @@ public abstract class JDateTime extends JString { } public DateTimeParser getDateTimeParser() { - if(getType() == JsonType.DATE) return getRuntime().getPragmas().getDateTypeParser(); - if(getType() == JsonType.TIME) return getRuntime().getPragmas().getTimeTypeParser(); + if(getType() == EType.DATE) return getRuntime().getPragmas().getDateTypeParser(); + if(getType() == EType.TIME) return getRuntime().getPragmas().getTimeTypeParser(); throw new IllegalStateException("Invalid date time type"); } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JDefinition.java b/src/main/java/com/relogiclabs/jschema/node/JDefinition.java similarity index 74% rename from src/main/java/com/relogiclabs/json/schema/type/JDefinition.java rename to src/main/java/com/relogiclabs/jschema/node/JDefinition.java index cbcf279..f12f469 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JDefinition.java +++ b/src/main/java/com/relogiclabs/jschema/node/JDefinition.java @@ -1,11 +1,11 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.internal.builder.JDefinitionBuilder; +import com.relogiclabs.jschema.internal.builder.JDefinitionBuilder; import lombok.EqualsAndHashCode; import lombok.Getter; -import static com.relogiclabs.json.schema.internal.util.CollectionHelper.asList; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.internal.util.CollectionHelper.asList; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; import static java.util.Objects.requireNonNull; @Getter diff --git a/src/main/java/com/relogiclabs/json/schema/type/JDirective.java b/src/main/java/com/relogiclabs/jschema/node/JDirective.java similarity index 69% rename from src/main/java/com/relogiclabs/json/schema/type/JDirective.java rename to src/main/java/com/relogiclabs/jschema/node/JDirective.java index fa2d261..1ba6f71 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JDirective.java +++ b/src/main/java/com/relogiclabs/jschema/node/JDirective.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.internal.builder.JNodeBuilder; +import com.relogiclabs.jschema.internal.builder.JNodeBuilder; public abstract class JDirective extends JNode { JDirective(JNodeBuilder builder) { diff --git a/src/main/java/com/relogiclabs/jschema/node/JDouble.java b/src/main/java/com/relogiclabs/jschema/node/JDouble.java new file mode 100644 index 0000000..5bb5876 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JDouble.java @@ -0,0 +1,53 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.internal.builder.JDoubleBuilder; +import com.relogiclabs.jschema.internal.message.ActualHelper; +import com.relogiclabs.jschema.internal.message.ExpectedHelper; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.type.EDouble; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import java.text.DecimalFormat; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.ValueMismatch; +import static com.relogiclabs.jschema.message.ErrorCode.DUBL01; +import static java.util.Objects.requireNonNull; + +@Getter +@EqualsAndHashCode +public final class JDouble extends JNumber implements EDouble, PragmaValue { + private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("0.0##############E0"); + private final double value; + + private JDouble(JDoubleBuilder builder) { + super(builder); + value = requireNonNull(builder.value()); + } + + public static JDouble from(JDoubleBuilder builder) { + return new JDouble(builder).initialize(); + } + + @Override + public boolean match(JNode node) { + var other = castType(node, JDouble.class); + if(other == null) return false; + if(areEqual(value, other.value)) return true; + return fail(new JsonSchemaException( + new ErrorDetail(DUBL01, ValueMismatch), + ExpectedHelper.asValueMismatch(this), + ActualHelper.asValueMismatch(other))); + } + + @Override + public Double toNativeValue() { + return value; + } + + @Override + public String toString() { + return DOUBLE_FORMAT.format(value); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JFloat.java b/src/main/java/com/relogiclabs/jschema/node/JFloat.java new file mode 100644 index 0000000..ac8edb9 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JFloat.java @@ -0,0 +1,59 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.internal.builder.JFloatBuilder; +import com.relogiclabs.jschema.internal.message.ActualHelper; +import com.relogiclabs.jschema.internal.message.ExpectedHelper; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.type.EDouble; +import com.relogiclabs.jschema.type.EType; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import java.text.DecimalFormat; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.ValueMismatch; +import static com.relogiclabs.jschema.message.ErrorCode.FLOT01; +import static java.util.Objects.requireNonNull; + +@Getter +@EqualsAndHashCode +public final class JFloat extends JNumber implements EDouble, PragmaValue { + private static final DecimalFormat FLOAT_FORMAT = new DecimalFormat("0.0##############"); + private final double value; + + private JFloat(JFloatBuilder builder) { + super(builder); + value = requireNonNull(builder.value()); + } + + public static JFloat from(JFloatBuilder builder) { + return new JFloat(builder).initialize(); + } + + @Override + public EType getType() { + return EType.FLOAT; + } + + @Override + public boolean match(JNode node) { + var other = castType(node, JFloat.class); + if(other == null) return false; + if(areEqual(value, other.value)) return true; + return fail(new JsonSchemaException( + new ErrorDetail(FLOT01, ValueMismatch), + ExpectedHelper.asValueMismatch(this), + ActualHelper.asValueMismatch(other))); + } + + @Override + public Double toNativeValue() { + return value; + } + + @Override + public String toString() { + return FLOAT_FORMAT.format(value); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JFunction.java b/src/main/java/com/relogiclabs/jschema/node/JFunction.java new file mode 100644 index 0000000..8a2361a --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JFunction.java @@ -0,0 +1,82 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.exception.TargetInvocationException; +import com.relogiclabs.jschema.internal.builder.JFunctionBuilder; +import com.relogiclabs.jschema.internal.message.ActualHelper; +import com.relogiclabs.jschema.internal.message.ExpectedHelper; +import com.relogiclabs.jschema.internal.tree.FunctionCache; +import com.relogiclabs.jschema.message.ErrorDetail; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import java.util.List; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.InvalidNestedFunction; +import static com.relogiclabs.jschema.internal.util.MiscellaneousHelper.nonNullFrom; +import static com.relogiclabs.jschema.internal.util.StreamHelper.forEachTrue; +import static com.relogiclabs.jschema.internal.util.StringHelper.join; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC06; +import static java.util.Objects.requireNonNull; + +@Getter +@EqualsAndHashCode +public final class JFunction extends JBranch implements NestedMode { + static final String NESTED_MARKER = "*"; + private final String name; + private final boolean nested; + private final List arguments; + private final FunctionCache cache; + + private JFunction(JFunctionBuilder builder) { + super(builder); + name = requireNonNull(builder.name()); + nested = requireNonNull(builder.nested()); + arguments = requireNonNull(builder.arguments()); + children = arguments; + cache = new FunctionCache(); + } + + public static JFunction from(JFunctionBuilder builder) { + return new JFunction(builder).initialize(); + } + + @Override + public boolean match(JNode node) { + if(!nested) return invokeFunction(node); + if(!(node instanceof JComposite composite)) + return fail(new JsonSchemaException( + new ErrorDetail(FUNC06, InvalidNestedFunction), + ExpectedHelper.asInvalidFunction(this), + ActualHelper.asInvalidFunction(node))); + return forEachTrue(composite.components().stream().map(this::invokeFunction)); + } + + private boolean invokeFunction(JNode node) { + try { + return getRuntime().getFunctions().invokeFunction(this, node); + } catch(Exception ex) { + var exception = ex instanceof TargetInvocationException + ? nonNullFrom(ex.getCause(), ex) : ex; + if(exception instanceof RuntimeException runtimeException) throw runtimeException; + else throw new RuntimeException(exception); + } + } + + @Override + public boolean isNested() { + return nested; + } + + boolean isApplicable(JNode node) { + return !nested || node instanceof JComposite; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(name); + if(nested) builder.append(NESTED_MARKER); + builder.append(join(arguments, ", ", "(", ")")); + return builder.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JImport.java b/src/main/java/com/relogiclabs/jschema/node/JImport.java new file mode 100644 index 0000000..5075cf1 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JImport.java @@ -0,0 +1,29 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.internal.builder.JImportBuilder; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static java.util.Objects.requireNonNull; + +@Getter +@EqualsAndHashCode +public final class JImport extends JDirective { + static final String IMPORT_MARKER = "%import"; + private final String className; + + private JImport(JImportBuilder builder) { + super(builder); + className = requireNonNull(builder.className()); + } + + public static JImport from(JImportBuilder builder) { + return new JImport(builder).initialize(); + } + + @Override + public String toString() { + return concat(IMPORT_MARKER, ": ", className); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JInteger.java b/src/main/java/com/relogiclabs/jschema/node/JInteger.java new file mode 100644 index 0000000..5c14974 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JInteger.java @@ -0,0 +1,51 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.internal.builder.JIntegerBuilder; +import com.relogiclabs.jschema.internal.message.ActualHelper; +import com.relogiclabs.jschema.internal.message.ExpectedHelper; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.type.EInteger; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.ValueMismatch; +import static com.relogiclabs.jschema.message.ErrorCode.INTE01; +import static java.util.Objects.requireNonNull; + +@Getter +@EqualsAndHashCode +public final class JInteger extends JNumber implements EInteger, PragmaValue { + private final long value; + + private JInteger(JIntegerBuilder builder) { + super(builder); + value = requireNonNull(builder.value()); + } + + public static JInteger from(JIntegerBuilder builder) { + return new JInteger(builder).initialize(); + } + + @Override + public boolean match(JNode node) { + var other = castType(node, JInteger.class); + if(other == null) return false; + if(value == other.value) return true; + return fail(new JsonSchemaException( + new ErrorDetail(INTE01, ValueMismatch), + ExpectedHelper.asValueMismatch(this), + ActualHelper.asValueMismatch(other))); + } + + @Override + public Long toNativeValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JLeaf.java b/src/main/java/com/relogiclabs/jschema/node/JLeaf.java similarity index 60% rename from src/main/java/com/relogiclabs/json/schema/type/JLeaf.java rename to src/main/java/com/relogiclabs/jschema/node/JLeaf.java index 79a5b05..71749f8 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JLeaf.java +++ b/src/main/java/com/relogiclabs/jschema/node/JLeaf.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.internal.builder.JNodeBuilder; +import com.relogiclabs.jschema.internal.builder.JNodeBuilder; public abstract class JLeaf extends JNode { JLeaf(JNodeBuilder builder) { diff --git a/src/main/java/com/relogiclabs/jschema/node/JNode.java b/src/main/java/com/relogiclabs/jschema/node/JNode.java new file mode 100644 index 0000000..6f57449 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JNode.java @@ -0,0 +1,77 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.internal.builder.JNodeBuilder; +import com.relogiclabs.jschema.internal.message.ActualHelper; +import com.relogiclabs.jschema.internal.message.ExpectedHelper; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.tree.Context; +import com.relogiclabs.jschema.tree.RuntimeContext; +import com.relogiclabs.jschema.type.EValue; +import lombok.Getter; + +import java.util.Collection; +import java.util.Map; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.DataTypeMismatch; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP02; +import static com.relogiclabs.jschema.message.MessageFormatter.createOutline; +import static java.util.Collections.emptyList; +import static java.util.Objects.requireNonNull; + +public abstract class JNode implements EValue { + private final Map relations; + @Getter private final Context context; + @Getter protected Collection children = emptyList(); + + JNode(JNodeBuilder builder) { + requireNonNull(builder); + relations = requireNonNull(builder.relations()); + context = requireNonNull(builder.context()); + } + + JNode(JNode node) { + requireNonNull(node); + relations = requireNonNull(node.relations); + context = requireNonNull(node.context); + children = requireNonNull(node.children); + } + + public JNode getParent() { + return relations.get(this); + } + + @SuppressWarnings("unchecked") + T initialize() { + for(var c : getChildren()) relations.put(c, this); + return (T) this; + } + + public RuntimeContext getRuntime() { + return context.getRuntime(); + } + + T castType(JNode node, Class type) { + if(type.isInstance(node)) return type.cast(node); + fail(new JsonSchemaException( + new ErrorDetail(DTYP02, DataTypeMismatch), + ExpectedHelper.asDataTypeMismatch(this), + ActualHelper.asDataTypeMismatch(node))); + return null; + } + + boolean checkType(JNode node, Class type) { + return castType(node, type) != null; + } + + public abstract boolean match(JNode node); + public abstract String toString(); + + public String getOutline() { + return createOutline(this); + } + + boolean fail(RuntimeException exception) { + return getRuntime().getExceptions().fail(exception); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JNull.java b/src/main/java/com/relogiclabs/jschema/node/JNull.java similarity index 55% rename from src/main/java/com/relogiclabs/json/schema/type/JNull.java rename to src/main/java/com/relogiclabs/jschema/node/JNull.java index d6dee13..f95f3f3 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JNull.java +++ b/src/main/java/com/relogiclabs/jschema/node/JNull.java @@ -1,12 +1,11 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.internal.builder.JNullBuilder; +import com.relogiclabs.jschema.internal.builder.JNullBuilder; +import com.relogiclabs.jschema.type.ENull; import lombok.EqualsAndHashCode; @EqualsAndHashCode -public final class JNull extends JPrimitive { - static final String NULL_MARKER = "null"; - +public final class JNull extends JPrimitive implements ENull { private JNull(JNullBuilder builder) { super(builder); } @@ -15,11 +14,6 @@ public static JNull from(JNullBuilder builder) { return new JNull(builder).initialize(); } - @Override - public JsonType getType() { - return JsonType.NULL; - } - @Override public boolean match(JNode node) { return checkType(node, JNull.class); @@ -27,6 +21,6 @@ public boolean match(JNode node) { @Override public String toString() { - return NULL_MARKER; + return ENull.STRING; } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JNumber.java b/src/main/java/com/relogiclabs/jschema/node/JNumber.java similarity index 61% rename from src/main/java/com/relogiclabs/json/schema/type/JNumber.java rename to src/main/java/com/relogiclabs/jschema/node/JNumber.java index b2ece01..da799c0 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JNumber.java +++ b/src/main/java/com/relogiclabs/jschema/node/JNumber.java @@ -1,14 +1,13 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.internal.builder.JPrimitiveBuilder; +import com.relogiclabs.jschema.internal.builder.JPrimitiveBuilder; +import com.relogiclabs.jschema.type.ENumber; -public abstract class JNumber extends JPrimitive { +public abstract class JNumber extends JPrimitive implements ENumber { JNumber(JPrimitiveBuilder builder) { super(builder); } - public abstract double toDouble(); - public double compare(JNumber number) { return compare(number.toDouble()); } @@ -22,9 +21,4 @@ public double compare(double other) { boolean areEqual(double value1, double value2) { return getRuntime().areEqual(value1, value2); } - - @Override - public JsonType getType() { - return JsonType.NUMBER; - } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JObject.java b/src/main/java/com/relogiclabs/jschema/node/JObject.java new file mode 100644 index 0000000..39a6ad7 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JObject.java @@ -0,0 +1,134 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.collection.IndexMap; +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.internal.builder.JObjectBuilder; +import com.relogiclabs.jschema.internal.message.ActualHelper; +import com.relogiclabs.jschema.internal.message.ExpectedHelper; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.type.EObject; +import com.relogiclabs.jschema.type.EValue; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.PropertyNotFound; +import static com.relogiclabs.jschema.internal.message.MessageHelper.PropertyOrderMismatch; +import static com.relogiclabs.jschema.internal.message.MessageHelper.UndefinedPropertyFound; +import static com.relogiclabs.jschema.internal.util.MiscellaneousHelper.nonNullFrom; +import static com.relogiclabs.jschema.internal.util.StringHelper.joinWith; +import static com.relogiclabs.jschema.message.ErrorCode.PROP05; +import static com.relogiclabs.jschema.message.ErrorCode.PROP06; +import static com.relogiclabs.jschema.message.ErrorCode.PROP07; +import static java.util.Objects.requireNonNull; + +@EqualsAndHashCode +public final class JObject extends JComposite implements EObject, Iterable { + @Getter private final IndexMap properties; + private final List components; + + private JObject(JObjectBuilder builder) { + super(builder); + properties = requireNonNull(builder.properties()); + components = properties.values().stream().map(JProperty::getValue).toList(); + children = properties.values(); + } + + public static JObject from(JObjectBuilder builder) { + return new JObject(builder).initialize(); + } + + @Override + public boolean match(JNode node) { + var other = castType(node, JObject.class); + if(other == null) return false; + var result = true; + var unresolved = new HashSet<>(other.properties.keySet()); + for(var i = 0; i < properties.size(); i++) { + var thisProp = properties.get(i); + var otherProp = getOtherProp(other, i); + if(otherProp != null) { + result &= thisProp.getValue().match(otherProp.getValue()); + unresolved.remove(thisProp.getKey()); + continue; + } + if(!((JValidator) thisProp.getValue()).isOptional()) + return fail(new JsonSchemaException( + new ErrorDetail(PROP05, PropertyNotFound), + ExpectedHelper.asPropertyNotFound(thisProp), + ActualHelper.asPropertyNotFound(node, thisProp))); + } + if(unresolved.isEmpty() || getRuntime().getPragmas() + .isIgnoreUndefinedProperties()) return result; + for(String key : unresolved) { + var property = other.properties.get(key); + result &= fail(new JsonSchemaException( + new ErrorDetail(PROP06, UndefinedPropertyFound), + ExpectedHelper.asUndefinedProperty(this, property), + ActualHelper.asUndefinedProperty(property))); + } + return result; + } + + private JProperty getOtherProp(JObject other, int index) { + var thisProp = properties.get(index); + JProperty otherProp = null; + if(!getRuntime().getPragmas().isIgnoreObjectPropertyOrder()) { + var atProp = getPropAt(other.properties, index); + if(areKeysEqual(atProp, thisProp)) otherProp = atProp; + JProperty existing = null; + if(otherProp == null) existing = other.properties.get(thisProp.getKey()); + if(otherProp == null && existing != null) + fail(new JsonSchemaException( + new ErrorDetail(PROP07, PropertyOrderMismatch), + ExpectedHelper.asPropertyOrderMismatch(thisProp), + ActualHelper.asPropertyOrderMismatch(nonNullFrom(atProp, other)))); + } else otherProp = other.properties.get(thisProp.getKey()); + return otherProp; + } + + private static JProperty getPropAt(IndexMap properties, int index) { + return index >= properties.size() ? null : properties.get(index); + } + + private static boolean areKeysEqual(JProperty p1, JProperty p2) { + if(p1 == null || p2 == null) return false; + return p1.getKey().equals(p2.getKey()); + } + + @Override + public Collection components() { + return components; + } + + @Override + public EValue get(String key) { + var property = properties.get(key); + return property == null ? null : property.getValue(); + } + + @Override + public int size() { + return properties.size(); + } + + @Override + public Set keySet() { + return properties.keySet(); + } + + @Override + public Iterator iterator() { + return properties.iterator(); + } + + @Override + public String toString() { + return joinWith(properties.values(), ", ", "{", "}"); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JPragma.java b/src/main/java/com/relogiclabs/jschema/node/JPragma.java new file mode 100644 index 0000000..983c02f --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JPragma.java @@ -0,0 +1,38 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.internal.builder.JPragmaBuilder; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import static com.relogiclabs.jschema.internal.util.CollectionHelper.asList; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static java.util.Objects.requireNonNull; + +@Getter +@EqualsAndHashCode +public final class JPragma extends JDirective { + static final String PRAGMA_MARKER = "%pragma"; + private final String name; + private final PragmaValue value; + + private JPragma(JPragmaBuilder builder) { + super(builder); + name = requireNonNull(builder.name()); + value = (PragmaValue) requireNonNull(builder.value()); + children = asList(builder.value()); + } + + public static JPragma from(JPragmaBuilder builder) { + return new JPragma(builder).initialize(); + } + + @SuppressWarnings("unchecked") + public PragmaValue getValue() { + return (PragmaValue) value; + } + + @Override + public String toString() { + return concat(PRAGMA_MARKER, " ", name, ": ", value); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JPrimitive.java b/src/main/java/com/relogiclabs/jschema/node/JPrimitive.java similarity index 58% rename from src/main/java/com/relogiclabs/json/schema/type/JPrimitive.java rename to src/main/java/com/relogiclabs/jschema/node/JPrimitive.java index 745a066..b5b46b9 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JPrimitive.java +++ b/src/main/java/com/relogiclabs/jschema/node/JPrimitive.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.internal.builder.JNodeBuilder; +import com.relogiclabs.jschema.internal.builder.JNodeBuilder; public abstract class JPrimitive extends JLeaf implements JsonTypable { JPrimitive(JNodeBuilder builder) { @@ -11,11 +11,6 @@ public abstract class JPrimitive extends JLeaf implements JsonTypable { super(node); } - @Override - public JsonType getType() { - return JsonType.PRIMITIVE; - } - @Override public JNode getNode() { return this; diff --git a/src/main/java/com/relogiclabs/jschema/node/JProperty.java b/src/main/java/com/relogiclabs/jschema/node/JProperty.java new file mode 100644 index 0000000..118c56c --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JProperty.java @@ -0,0 +1,69 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.collection.Keyable; +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.internal.builder.JPropertyBuilder; +import com.relogiclabs.jschema.internal.message.ActualHelper; +import com.relogiclabs.jschema.internal.message.ExpectedHelper; +import com.relogiclabs.jschema.message.ErrorDetail; +import lombok.Getter; + +import java.util.Objects; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.PropertyKeyMismatch; +import static com.relogiclabs.jschema.internal.message.MessageHelper.PropertyValueMismatch; +import static com.relogiclabs.jschema.internal.util.CollectionHelper.asList; +import static com.relogiclabs.jschema.internal.util.StringHelper.quote; +import static com.relogiclabs.jschema.message.ErrorCode.PROP01; +import static com.relogiclabs.jschema.message.ErrorCode.PROP02; +import static java.util.Objects.requireNonNull; + +@Getter +public final class JProperty extends JBranch implements Keyable { + private final String key; + private final JNode value; + + private JProperty(JPropertyBuilder builder) { + super(builder); + key = requireNonNull(builder.key()); + value = requireNonNull(builder.value()); + children = asList(value); + } + + public static JProperty from(JPropertyBuilder builder) { + return new JProperty(builder).initialize(); + } + + @Override + public boolean equals(Object other) { + if(this == other) return true; + if(other == null || getClass() != other.getClass()) return false; + JProperty property = (JProperty) other; + return Objects.equals(key, property.key); + } + + @Override + public int hashCode() { + return Objects.hash(key); + } + + @Override + public boolean match(JNode node) { + var other = castType(node, JProperty.class); + if(other == null) return false; + if(!key.equals(other.key)) return fail(new JsonSchemaException( + new ErrorDetail(PROP01, PropertyKeyMismatch), + ExpectedHelper.asValueMismatch(this), + ActualHelper.asValueMismatch(other))); + if(!value.match(other.value)) return fail(new JsonSchemaException( + new ErrorDetail(PROP02, PropertyValueMismatch), + ExpectedHelper.asValueMismatch(this), + ActualHelper.asValueMismatch(other))); + return true; + } + + @Override + public String toString() { + return quote(key) + ": " + value; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JReceiver.java b/src/main/java/com/relogiclabs/jschema/node/JReceiver.java new file mode 100644 index 0000000..2310a96 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JReceiver.java @@ -0,0 +1,84 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.NoValueReceivedException; +import com.relogiclabs.jschema.exception.ReceiverNotFoundException; +import com.relogiclabs.jschema.internal.builder.JReceiverBuilder; +import com.relogiclabs.jschema.type.EArray; +import com.relogiclabs.jschema.type.EValue; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import java.util.Iterator; +import java.util.List; + +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.RECV01; +import static com.relogiclabs.jschema.message.ErrorCode.RECV03; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; +import static java.util.Objects.requireNonNull; + +@Getter +@EqualsAndHashCode +public final class JReceiver extends JLeaf implements EArray, Iterable { + private final String name; + + private JReceiver(JReceiverBuilder builder) { + super(builder); + name = requireNonNull(builder.name()); + } + + public static JReceiver from(JReceiverBuilder builder) { + return new JReceiver(builder).initialize(); + } + + @Override + public boolean match(JNode node) { + throw new IllegalStateException("Invalid runtime state"); + } + + public int getValueCount() { + return fetchValueNodes().size(); + } + + private List fetchValueNodes() { + var list = getRuntime().getReceivers().fetch(this); + if(list == null) throw new ReceiverNotFoundException(formatForSchema(RECV01, + concat("Receiver '", name, "' not found"), this)); + return list; + } + + @SuppressWarnings("unchecked") + public T getValueNode() { + var list = fetchValueNodes(); + if(list.isEmpty()) throw new NoValueReceivedException(formatForSchema(RECV03, + concat("No value received for '", name, "'"), this)); + if(list.size() > 1) throw new UnsupportedOperationException("Multiple values exist"); + return (T) list.get(0); + } + + @SuppressWarnings("unchecked") + public List getValueNodes() { + var list = fetchValueNodes(); + return list.stream().map(i -> (T) i).toList(); + } + + @Override + public EValue get(int index) { + return fetchValueNodes().get(index); + } + + @Override + public List elements() { + return fetchValueNodes(); + } + + @Override + public Iterator iterator() { + return fetchValueNodes().iterator(); + } + + @Override + public String toString() { + return name; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JRoot.java b/src/main/java/com/relogiclabs/jschema/node/JRoot.java new file mode 100644 index 0000000..25c8869 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JRoot.java @@ -0,0 +1,76 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.internal.builder.JRootBuilder; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; + +import static com.relogiclabs.jschema.internal.util.CollectionHelper.addToList; +import static com.relogiclabs.jschema.internal.util.StringHelper.join; +import static java.util.Collections.unmodifiableCollection; +import static java.util.Objects.requireNonNull; + +@Getter +@EqualsAndHashCode +public final class JRoot extends JNode { + private static final String NEW_LINE = System.lineSeparator(); + + private final JTitle title; + private final JVersion version; + private final List imports; + private final List pragmas; + private final List definitions; + private final List scripts; + private final JNode value; + + private JRoot(JRootBuilder builder) { + super(builder); + title = builder.title(); + version = builder.version(); + imports = builder.imports(); + pragmas = builder.pragmas(); + definitions = builder.definitions(); + scripts = builder.scripts(); + value = requireNonNull(builder.value()); + var nodes = new ArrayList(); + addToList(nodes, title, version); + addToList(nodes, imports, pragmas, definitions); + addToList(nodes, value); + children = unmodifiableCollection(children); + } + + public static JRoot from(JRootBuilder builder) { + return new JRoot(builder).initialize(); + } + + @Override + public boolean match(JNode node) { + var other = castType(node, JRoot.class); + if(other == null) return false; + return value.match(other.value); + } + + @Override + public String toString() { + var builder = new StringBuilder(); + appendTo(builder, title); + appendTo(builder, version); + appendTo(builder, imports); + appendTo(builder, pragmas); + appendTo(builder, definitions); + appendTo(builder, value); + return builder.toString().trim(); + } + + private void appendTo(StringBuilder builder, JNode node) { + if(node == null) return; + builder.append(node).append(NEW_LINE); + } + + private void appendTo(StringBuilder builder, List list) { + if(list == null || list.isEmpty()) return; + builder.append(join(list, NEW_LINE, "", NEW_LINE)); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JScript.java b/src/main/java/com/relogiclabs/jschema/node/JScript.java new file mode 100644 index 0000000..ec35c91 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JScript.java @@ -0,0 +1,28 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.internal.builder.JScriptBuilder; +import com.relogiclabs.jschema.internal.engine.Evaluator; +import lombok.EqualsAndHashCode; + +import static java.util.Objects.requireNonNull; + +@EqualsAndHashCode +public final class JScript extends JDirective { + private final Evaluator evaluator; + private final String source; + + private JScript(JScriptBuilder builder) { + super(builder); + this.evaluator = requireNonNull(builder.evaluator()); + this.source = requireNonNull(builder.source()); + } + + public static JScript from(JScriptBuilder builder) { + return new JScript(builder).initialize(); + } + + @Override + public String toString() { + return source; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JString.java b/src/main/java/com/relogiclabs/jschema/node/JString.java new file mode 100644 index 0000000..2d2ee40 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JString.java @@ -0,0 +1,58 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.internal.builder.JStringBuilder; +import com.relogiclabs.jschema.internal.message.ActualHelper; +import com.relogiclabs.jschema.internal.message.ExpectedHelper; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.type.EString; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.ValueMismatch; +import static com.relogiclabs.jschema.internal.util.StringHelper.quote; +import static com.relogiclabs.jschema.message.ErrorCode.STRN01; +import static java.util.Objects.requireNonNull; + +@Getter +@EqualsAndHashCode +public class JString extends JPrimitive implements EString, Derivable, PragmaValue { + private final String value; + @Getter @Setter private JNode derived; + + private JString(JStringBuilder builder) { + super(builder); + value = requireNonNull(builder.value()); + } + + JString(JString node) { + super(node); + this.value = requireNonNull(node.value); + } + + public static JString from(JStringBuilder builder) { + return new JString(builder).initialize(); + } + + @Override + public boolean match(JNode node) { + var other = castType(node, JString.class); + if(other == null) return false; + if(value.equals(other.value)) return true; + return fail(new JsonSchemaException( + new ErrorDetail(STRN01, ValueMismatch), + ExpectedHelper.asValueMismatch(this), + ActualHelper.asValueMismatch(other))); + } + + @Override + public String toNativeValue() { + return value; + } + + @Override + public String toString() { + return quote(value); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JTime.java b/src/main/java/com/relogiclabs/jschema/node/JTime.java similarity index 58% rename from src/main/java/com/relogiclabs/json/schema/type/JTime.java rename to src/main/java/com/relogiclabs/jschema/node/JTime.java index c5cabd3..d500289 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JTime.java +++ b/src/main/java/com/relogiclabs/jschema/node/JTime.java @@ -1,6 +1,7 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.time.JsonDateTime; +import com.relogiclabs.jschema.time.JsonDateTime; +import com.relogiclabs.jschema.type.EType; public final class JTime extends JDateTime { private JTime(JString node, JsonDateTime dateTime) { @@ -11,7 +12,7 @@ public static JTime from(JString node, JsonDateTime dateTime) { return new JTime(node, dateTime); } - public JsonType getType() { - return JsonType.TIME; + public EType getType() { + return EType.TIME; } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JTitle.java b/src/main/java/com/relogiclabs/jschema/node/JTitle.java similarity index 76% rename from src/main/java/com/relogiclabs/json/schema/type/JTitle.java rename to src/main/java/com/relogiclabs/jschema/node/JTitle.java index 1583f10..bc8f62a 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JTitle.java +++ b/src/main/java/com/relogiclabs/jschema/node/JTitle.java @@ -1,10 +1,10 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.internal.builder.JTitleBuilder; +import com.relogiclabs.jschema.internal.builder.JTitleBuilder; import lombok.EqualsAndHashCode; import lombok.Getter; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; import static java.util.Objects.requireNonNull; @Getter diff --git a/src/main/java/com/relogiclabs/json/schema/type/JUndefined.java b/src/main/java/com/relogiclabs/jschema/node/JUndefined.java similarity index 68% rename from src/main/java/com/relogiclabs/json/schema/type/JUndefined.java rename to src/main/java/com/relogiclabs/jschema/node/JUndefined.java index 37d3094..97c9ce4 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JUndefined.java +++ b/src/main/java/com/relogiclabs/jschema/node/JUndefined.java @@ -1,10 +1,11 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.internal.builder.JUndefinedBuilder; +import com.relogiclabs.jschema.internal.builder.JUndefinedBuilder; +import com.relogiclabs.jschema.type.EUndefined; import lombok.EqualsAndHashCode; @EqualsAndHashCode -public final class JUndefined extends JLeaf { +public final class JUndefined extends JLeaf implements EUndefined { static final String UNDEFINED_MARKER = "!"; private JUndefined(JUndefinedBuilder builder) { diff --git a/src/main/java/com/relogiclabs/jschema/node/JValidator.java b/src/main/java/com/relogiclabs/jschema/node/JValidator.java new file mode 100644 index 0000000..1ba4552 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JValidator.java @@ -0,0 +1,166 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.internal.builder.JValidatorBuilder; +import com.relogiclabs.jschema.internal.message.ActualHelper; +import com.relogiclabs.jschema.internal.message.ExpectedHelper; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ExpectedDetail; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.InvalidNonCompositeType; +import static com.relogiclabs.jschema.internal.message.MessageHelper.ValidationFailed; +import static com.relogiclabs.jschema.internal.util.CollectionHelper.addToList; +import static com.relogiclabs.jschema.internal.util.CollectionHelper.tryGetLast; +import static com.relogiclabs.jschema.internal.util.StreamHelper.forEachTrue; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.internal.util.StringHelper.join; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP03; +import static com.relogiclabs.jschema.message.ErrorCode.VALD01; +import static com.relogiclabs.jschema.node.JDataType.DATA_TYPE_NAME; +import static java.util.Collections.unmodifiableCollection; +import static lombok.AccessLevel.NONE; + +@Getter +@EqualsAndHashCode +public final class JValidator extends JBranch { + static final String OPTIONAL_MARKER = "?"; + + private final JNode value; + private final List functions; + private final List dataTypes; + private final List receivers; + private final boolean optional; + + @Getter(NONE) + @EqualsAndHashCode.Exclude + private final List exceptions; + + private JValidator(JValidatorBuilder builder) { + super(builder); + value = builder.value(); + functions = builder.functions(); + dataTypes = builder.dataTypes(); + receivers = builder.receivers(); + optional = builder.optional(); + exceptions = new LinkedList<>(); + getRuntime().getReceivers().register(receivers); + var nodes = new ArrayList(); + addToList(nodes, value); + addToList(nodes, functions, dataTypes, receivers); + children = unmodifiableCollection(nodes); + } + + public static JValidator from(JValidatorBuilder builder) { + return new JValidator(builder).initialize(); + } + + @Override + public boolean match(JNode node) { + boolean rValue = true; + var other = castType(node, JsonTypable.class); + if(other == null) return false; + getRuntime().getReceivers().receive(receivers, node); + if(node instanceof JNull && dataTypes.stream() + .anyMatch(JDataType::isMatchNull)) return true; + if(value != null) rValue &= value.match(other.getNode()); + if(!rValue) return fail(new JsonSchemaException( + new ErrorDetail(VALD01, ValidationFailed), + ExpectedHelper.asGeneralValueMismatch(value), + ActualHelper.asGeneralValueMismatch(node))); + var rDataType = matchDataType(node); + var fDataType = rDataType && dataTypes.size() != 0; + boolean rFunction = forEachTrue(functions.stream() + .filter(f -> f.isApplicable(node) || !fDataType) + .map(f -> f.match(node))); + return rValue & rDataType & rFunction; + } + + private boolean matchDataType(JNode node) { + if(getRuntime().getExceptions().tryExecute(() -> checkDataType(node))) return true; + saveTryBuffer(); + for(var e : exceptions) fail((RuntimeException) e); + return false; + } + + private static List processTryBuffer(List buffer) { + var list = new ArrayList(buffer.size()); + for(var e : buffer) { + var result = mergeException(tryGetLast(list), e); + if(result != null) list.set(list.size() - 1, result); + else list.add(e); + } + return list; + } + + private static JsonSchemaException mergeException(Exception ex1, Exception ex2) { + if(!(ex1 instanceof JsonSchemaException e1)) return null; + if(!(ex2 instanceof JsonSchemaException e2)) return null; + if(!e1.getCode().equals(e2.getCode())) return null; + var a1 = e1.getAttribute(DATA_TYPE_NAME); + var a2 = e2.getAttribute(DATA_TYPE_NAME); + if(a1 == null || a2 == null) return null; + var result = new JsonSchemaException(e1.getError(), mergeExpected(e1, e2), e2.getActual()); + result.setAttribute(DATA_TYPE_NAME, a1 + a2); + return result; + } + + private static ExpectedDetail mergeExpected(JsonSchemaException ex1, + JsonSchemaException ex2) { + var typeName2 = ex2.getAttribute(DATA_TYPE_NAME); + var expected1 = ex1.getExpected(); + return new ExpectedDetail(expected1.getContext(), + concat(expected1.getMessage(), " or ", typeName2)); + } + + private boolean checkDataType(JNode node) { + var list1 = dataTypes.stream().filter(d -> !d.isNested()).toList(); + var result1 = anyMatch(list1, node); + if(result1) getTryBuffer().clear(); + var list2 = dataTypes.stream().filter(d -> d.isNested() + && (d.isApplicable(node) || !result1)).toList(); + if(list2.isEmpty()) return result1 || list1.isEmpty(); + if(!(node instanceof JComposite composite)) + return fail(new JsonSchemaException( + new ErrorDetail(DTYP03, InvalidNonCompositeType), + ExpectedHelper.asInvalidNonCompositeType(list2.get(0)), + ActualHelper.asInvalidNonCompositeType(node))); + saveTryBuffer(); + var result2 = forEachTrue(composite.components().stream() + .map(n -> anyMatch(list2, n))); + return (result1 || list1.isEmpty()) && result2; + } + + private boolean anyMatch(List list, JNode node) { + getTryBuffer().clear(); + for(var d : list) if(d.match(node)) return true; + saveTryBuffer(); + return false; + } + + private List getTryBuffer() { + return getRuntime().getExceptions().getTryBuffer(); + } + + private void saveTryBuffer() { + List tryBuffer = getTryBuffer(); + if(tryBuffer.isEmpty()) return; + exceptions.addAll(processTryBuffer(tryBuffer)); + tryBuffer.clear(); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + if(value != null) builder.append(value); + builder.append(join(functions, " ", " ")); + builder.append(join(dataTypes, " ", " ")); + if(optional) builder.append(" " + OPTIONAL_MARKER); + return builder.toString().trim(); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JVersion.java b/src/main/java/com/relogiclabs/jschema/node/JVersion.java similarity index 83% rename from src/main/java/com/relogiclabs/json/schema/type/JVersion.java rename to src/main/java/com/relogiclabs/jschema/node/JVersion.java index c2fb1b4..6233077 100644 --- a/src/main/java/com/relogiclabs/json/schema/type/JVersion.java +++ b/src/main/java/com/relogiclabs/jschema/node/JVersion.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.type; +package com.relogiclabs.jschema.node; -import com.relogiclabs.json.schema.internal.builder.JVersionBuilder; +import com.relogiclabs.jschema.internal.builder.JVersionBuilder; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/relogiclabs/jschema/node/JsonTypable.java b/src/main/java/com/relogiclabs/jschema/node/JsonTypable.java new file mode 100644 index 0000000..30e8a14 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JsonTypable.java @@ -0,0 +1,7 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.type.EValue; + +public interface JsonTypable extends EValue { + JNode getNode(); +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JsonType.java b/src/main/java/com/relogiclabs/jschema/node/JsonType.java new file mode 100644 index 0000000..1db91ac --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/JsonType.java @@ -0,0 +1,107 @@ +package com.relogiclabs.jschema.node; + +import com.relogiclabs.jschema.exception.InvalidDataTypeException; +import com.relogiclabs.jschema.tree.Location; +import com.relogiclabs.jschema.type.EType; +import com.relogiclabs.jschema.util.Reference; +import org.antlr.v4.runtime.tree.TerminalNode; + +import java.util.HashMap; +import java.util.Map; + +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP01; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; +import static com.relogiclabs.jschema.type.EType.ANY; +import static com.relogiclabs.jschema.type.EType.ARRAY; +import static com.relogiclabs.jschema.type.EType.BOOLEAN; +import static com.relogiclabs.jschema.type.EType.COMPOSITE; +import static com.relogiclabs.jschema.type.EType.DATE; +import static com.relogiclabs.jschema.type.EType.DOUBLE; +import static com.relogiclabs.jschema.type.EType.FLOAT; +import static com.relogiclabs.jschema.type.EType.INTEGER; +import static com.relogiclabs.jschema.type.EType.NULL; +import static com.relogiclabs.jschema.type.EType.NUMBER; +import static com.relogiclabs.jschema.type.EType.OBJECT; +import static com.relogiclabs.jschema.type.EType.PRIMITIVE; +import static com.relogiclabs.jschema.type.EType.STRING; +import static com.relogiclabs.jschema.type.EType.TIME; + +public final class JsonType { + private static final Map stringTypeMap = new HashMap<>(); + private static final Map> typeClassMap = new HashMap<>(); + private static final Map, EType> classTypeMap = new HashMap<>(); + + private final EType type; + private final Class nodeClass; + + static { + mapType(BOOLEAN, JBoolean.class); + mapType(INTEGER, JInteger.class); + mapType(FLOAT, JFloat.class); + mapType(DOUBLE, JDouble.class); + mapType(NUMBER, JNumber.class); + mapType(STRING, JString.class); + mapType(ARRAY, JArray.class); + mapType(OBJECT, JObject.class); + mapType(NULL, JNull.class); + mapType(DATE, JString.class); + mapType(TIME, JString.class); + mapType(PRIMITIVE, JPrimitive.class); + mapType(COMPOSITE, JComposite.class); + mapType(ANY, JsonTypable.class); + } + + public JsonType(EType type) { + this.type = type; + this.nodeClass = typeClassMap.get(type); + } + + private static void mapType(EType type, Class typeClass) { + stringTypeMap.put(type.getName(), type); + classTypeMap.putIfAbsent(typeClass, type); + typeClassMap.put(type, typeClass); + } + + public static JsonType from(TerminalNode node) { + return from(node.getText(), Location.from(node.getSymbol())); + } + + public static EType from(Class type) { + return classTypeMap.get(type); + } + + private static JsonType from(String name, Location location) { + var type = stringTypeMap.get(name); + if(type == null) throw new InvalidDataTypeException(formatForSchema(DTYP01, + concat("Invalid data type ", name), location)); + return new JsonType(type); + } + + public boolean match(JNode node, Reference error) { + if(!nodeClass.isInstance(node)) return false; + if(type == DATE) { + var date = (JString) node; + var dateTime = node.getRuntime().getPragmas().getDateTypeParser() + .tryParse(date.getValue(), error); + if(dateTime == null) return false; + date.setDerived(JDate.from(date, dateTime)); + } else if(type == TIME) { + var time = (JString) node; + var dateTime = node.getRuntime().getPragmas().getTimeTypeParser() + .tryParse(time.getValue(), error); + if(dateTime == null) return false; + time.setDerived(JTime.from(time, dateTime)); + } + return true; + } + + boolean isNullType() { + return type == NULL; + } + + @Override + public String toString() { + return type.getName(); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/NestedMode.java b/src/main/java/com/relogiclabs/jschema/node/NestedMode.java new file mode 100644 index 0000000..43df5a0 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/NestedMode.java @@ -0,0 +1,5 @@ +package com.relogiclabs.jschema.node; + +public interface NestedMode { + boolean isNested(); +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/PragmaValue.java b/src/main/java/com/relogiclabs/jschema/node/PragmaValue.java new file mode 100644 index 0000000..2547088 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/node/PragmaValue.java @@ -0,0 +1,5 @@ +package com.relogiclabs.jschema.node; + +public interface PragmaValue { + T toNativeValue(); +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JInclude.java b/src/main/java/com/relogiclabs/json/schema/type/JInclude.java deleted file mode 100644 index 3dc1d5e..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JInclude.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.internal.builder.JIncludeBuilder; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static java.util.Objects.requireNonNull; - -@Getter -@EqualsAndHashCode -public final class JInclude extends JDirective { - static final String INCLUDE_MARKER = "%include"; - private final String className; - - private JInclude(JIncludeBuilder builder) { - super(builder); - className = requireNonNull(builder.className()); - } - - public static JInclude from(JIncludeBuilder builder) { - return new JInclude(builder).initialize(); - } - - @Override - public String toString() { - return concat(INCLUDE_MARKER, ": ", className); - } -} \ No newline at end of file From d6d4710620cc579220ed92e7c53f21c77fef476e Mon Sep 17 00:00:00 2001 From: Zahid Hossain <60911932+zhossain-info@users.noreply.github.com> Date: Wed, 21 Feb 2024 20:08:44 +0600 Subject: [PATCH 09/12] Add built-in function library for script --- .../jschema/internal/library/NFunction.java | 46 ++ .../jschema/internal/library/NHandler.java | 11 + .../internal/library/ScriptConstant.java | 43 ++ .../internal/library/ScriptLibrary.java | 452 ++++++++++++++++++ 4 files changed, 552 insertions(+) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/library/NFunction.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/library/NHandler.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/library/ScriptConstant.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/library/ScriptLibrary.java diff --git a/src/main/java/com/relogiclabs/jschema/internal/library/NFunction.java b/src/main/java/com/relogiclabs/jschema/internal/library/NFunction.java new file mode 100644 index 0000000..3bed946 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/library/NFunction.java @@ -0,0 +1,46 @@ +package com.relogiclabs.jschema.internal.library; + +import com.relogiclabs.jschema.internal.engine.ScopeContext; +import com.relogiclabs.jschema.internal.script.GParameter; +import com.relogiclabs.jschema.internal.script.RFunction; +import com.relogiclabs.jschema.type.EValue; +import lombok.Getter; + +import java.util.Arrays; +import java.util.List; + +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.areCompatible; +import static com.relogiclabs.jschema.internal.util.CollectionHelper.getLast; +import static com.relogiclabs.jschema.message.ErrorCode.FUNS06; + +@Getter +public class NFunction implements RFunction { + private final NHandler handler; + private final GParameter[] parameters; + + public NFunction(NHandler handler, String... parameters) { + this.handler = handler; + this.parameters = toParameters(parameters); + } + + private static GParameter[] toParameters(String... names) { + return Arrays.stream(names).map(GParameter::new).toArray(GParameter[]::new); + } + + @Override + public EValue invoke(ScopeContext functionScope, List arguments) { + return handler.invoke(functionScope, arguments); + } + + @Override + public ScopeContext bind(ScopeContext parentScope, List arguments) { + areCompatible(parameters, arguments, FUNS06); + return parentScope; + } + + @Override + public boolean isVariadic() { + if(parameters.length == 0) return false; + return getLast(parameters).isVariadic(); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/library/NHandler.java b/src/main/java/com/relogiclabs/jschema/internal/library/NHandler.java new file mode 100644 index 0000000..c102d74 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/library/NHandler.java @@ -0,0 +1,11 @@ +package com.relogiclabs.jschema.internal.library; + +import com.relogiclabs.jschema.internal.engine.ScopeContext; +import com.relogiclabs.jschema.type.EValue; + +import java.util.List; + +@FunctionalInterface +public interface NHandler { + EValue invoke(ScopeContext scope, List arguments); +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/library/ScriptConstant.java b/src/main/java/com/relogiclabs/jschema/internal/library/ScriptConstant.java new file mode 100644 index 0000000..3a06d7d --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/library/ScriptConstant.java @@ -0,0 +1,43 @@ +package com.relogiclabs.jschema.internal.library; + +public interface ScriptConstant { + String CALLER_HVAR = "+caller"; + String TARGET_HVAR = "+target"; + + String ACTUAL_FN1 = "actual#1"; + String ACTUAL_FN2 = "actual#2"; + String CEIL_FN1 = "ceil#1"; + String COPY_FN1 = "copy#1"; + String EXPECTED_FN1 = "expected#1"; + String EXPECTED_FN2 = "expected#2"; + String FAIL_FN1 = "fail#1"; + String FAIL_FN2 = "fail#2"; + String FAIL_FN4 = "fail#4"; + String FILL_FN2 = "fill#2"; + String FIND_FN2 = "find#2"; + String FIND_FN3 = "find#3"; + String FLOOR_FN1 = "floor#1"; + String LOG_FN1 = "log#1"; + String MOD_FN2 = "mod#2"; + String POW_FN2 = "pow#2"; + String PRINT_FNV = "print#..."; + String REGULAR_FN1 = "regular#1"; + String SIZE_FN1 = "size#1"; + String STRINGIFY_FN1 = "stringify#1"; + String TICKS_FN0 = "ticks#0"; + String TYPE_FN1 = "type#1"; + + String ACTUAL_ID = "actual"; + String ARGS_IDV = "args..."; + String CODE_ID = "code"; + String EXPECTED_ID = "expected"; + String FROM_ID = "from"; + String GROUP_ID = "group"; + String ITEM_ID = "item"; + String MESSAGE_ID = "message"; + String NODE_ID = "node"; + String SIZE_ID = "size"; + String VALUE1_ID = "value1"; + String VALUE2_ID = "value2"; + String VALUE_ID = "value"; +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/library/ScriptLibrary.java b/src/main/java/com/relogiclabs/jschema/internal/library/ScriptLibrary.java new file mode 100644 index 0000000..9cd34f5 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/library/ScriptLibrary.java @@ -0,0 +1,452 @@ +package com.relogiclabs.jschema.internal.library; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.exception.ScriptArgumentException; +import com.relogiclabs.jschema.exception.ScriptInitiatedException; +import com.relogiclabs.jschema.internal.engine.ScriptTreeHelper; +import com.relogiclabs.jschema.internal.script.GArray; +import com.relogiclabs.jschema.internal.script.GDouble; +import com.relogiclabs.jschema.internal.script.GInteger; +import com.relogiclabs.jschema.internal.script.GObject; +import com.relogiclabs.jschema.internal.script.GString; +import com.relogiclabs.jschema.message.ActualDetail; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ExpectedDetail; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.type.EArray; +import com.relogiclabs.jschema.type.EDouble; +import com.relogiclabs.jschema.type.EInteger; +import com.relogiclabs.jschema.type.ENull; +import com.relogiclabs.jschema.type.ENumber; +import com.relogiclabs.jschema.type.EObject; +import com.relogiclabs.jschema.type.EString; +import com.relogiclabs.jschema.type.EUndefined; +import com.relogiclabs.jschema.type.EValue; + +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; + +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.areEqual; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.dereference; +import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.stringify; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.ACTUAL_FN1; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.ACTUAL_FN2; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.ACTUAL_ID; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.ARGS_IDV; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.CALLER_HVAR; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.CEIL_FN1; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.CODE_ID; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.COPY_FN1; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.EXPECTED_FN1; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.EXPECTED_FN2; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.EXPECTED_ID; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.FAIL_FN1; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.FAIL_FN2; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.FAIL_FN4; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.FILL_FN2; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.FIND_FN2; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.FIND_FN3; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.FLOOR_FN1; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.FROM_ID; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.GROUP_ID; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.ITEM_ID; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.LOG_FN1; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.MESSAGE_ID; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.MOD_FN2; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.NODE_ID; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.POW_FN2; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.PRINT_FNV; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.REGULAR_FN1; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.SIZE_FN1; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.SIZE_ID; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.STRINGIFY_FN1; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.TARGET_HVAR; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.TICKS_FN0; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.TYPE_FN1; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.VALUE1_ID; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.VALUE2_ID; +import static com.relogiclabs.jschema.internal.library.ScriptConstant.VALUE_ID; +import static com.relogiclabs.jschema.internal.script.GBoolean.FALSE; +import static com.relogiclabs.jschema.internal.script.GBoolean.TRUE; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.ACTL01; +import static com.relogiclabs.jschema.message.ErrorCode.ACTL02; +import static com.relogiclabs.jschema.message.ErrorCode.ACTL03; +import static com.relogiclabs.jschema.message.ErrorCode.CEIL01; +import static com.relogiclabs.jschema.message.ErrorCode.EXPC01; +import static com.relogiclabs.jschema.message.ErrorCode.EXPC02; +import static com.relogiclabs.jschema.message.ErrorCode.EXPC03; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL01; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL02; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL03; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL04; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL05; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL06; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL07; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL08; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL09; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL10; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL11; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL12; +import static com.relogiclabs.jschema.message.ErrorCode.FILL01; +import static com.relogiclabs.jschema.message.ErrorCode.FIND01; +import static com.relogiclabs.jschema.message.ErrorCode.FIND02; +import static com.relogiclabs.jschema.message.ErrorCode.FIND03; +import static com.relogiclabs.jschema.message.ErrorCode.FIND04; +import static com.relogiclabs.jschema.message.ErrorCode.FIND05; +import static com.relogiclabs.jschema.message.ErrorCode.FIND06; +import static com.relogiclabs.jschema.message.ErrorCode.FLOR01; +import static com.relogiclabs.jschema.message.ErrorCode.LOGA01; +import static com.relogiclabs.jschema.message.ErrorCode.MODU01; +import static com.relogiclabs.jschema.message.ErrorCode.MODU02; +import static com.relogiclabs.jschema.message.ErrorCode.POWR01; +import static com.relogiclabs.jschema.message.ErrorCode.POWR02; +import static com.relogiclabs.jschema.message.ErrorCode.SIZE01; +import static com.relogiclabs.jschema.message.MessageFormatter.createOutline; +import static com.relogiclabs.jschema.message.MessageFormatter.formatOfSchema; +import static com.relogiclabs.jschema.type.EValue.VOID; + +public class ScriptLibrary { + private static final ScriptLibrary LIBRARY = new ScriptLibrary(); + private final Map symbols; + + private ScriptLibrary() { + symbols = new HashMap<>(30); + scriptPrintFunction(); + scriptTypeFunction(); + scriptSizeFunction(); + scriptStringifyFunction(); + scriptFindFunction1(); + scriptFindFunction2(); + scriptRegularFunction(); + scriptFailFunction1(); + scriptFailFunction2(); + scriptFailFunction3(); + scriptExpectedFunction1(); + scriptExpectedFunction2(); + scriptActualFunction1(); + scriptActualFunction2(); + scriptCopyFunction(); + scriptFillFunction(); + scriptCeilFunction(); + scriptFloorFunction(); + scriptModFunction(); + scriptPowFunction(); + scriptLogFunction(); + scriptTicksFunction(); + } + + public static EValue resolveStatic(String name) { + var value = LIBRARY.symbols.get(name); + return value == null ? VOID : value; + } + + private void scriptPrintFunction() { + var handler = (NHandler) (scope, arguments) -> { + System.out.println(arguments.stream().map(ScriptTreeHelper::stringify) + .collect(Collectors.joining(" "))); + return VOID; + }; + var function = new NFunction(handler, MESSAGE_ID, ARGS_IDV); + symbols.put(PRINT_FNV, function); + } + + private void scriptTypeFunction() { + var handler = (NHandler) (scope, arguments) + -> GString.of(arguments.get(0).getType().getName()); + var function = new NFunction(handler, VALUE_ID); + symbols.put(TYPE_FN1, function); + } + + private void scriptSizeFunction() { + var handler = (NHandler) (scope, arguments) -> { + var value = arguments.get(0); + if(value instanceof EArray a) return GInteger.of(a.size()); + if(value instanceof EObject o) return GInteger.of(o.size()); + if(value instanceof EString s) return GInteger.of(s.length()); + throw failOnInvalidArgumentType(SIZE01, VALUE_ID, value); + }; + var function = new NFunction(handler, VALUE_ID); + symbols.put(SIZE_FN1, function); + } + + private void scriptStringifyFunction() { + var handler = (NHandler) (scope, arguments) + -> GString.of(stringify(arguments.get(0))); + var function = new NFunction(handler, VALUE_ID); + symbols.put(STRINGIFY_FN1, function); + } + + private void scriptFindFunction1() { + var handler = (NHandler) (scope, arguments) -> { + var group = arguments.get(0); + var item = arguments.get(1); + var rc = scope.getRuntime(); + if(group instanceof EArray g) { + var s = g.size(); + for(int i = 0; i < s; i++) if(areEqual(g.get(i), item, rc)) return GInteger.of(i); + return GInteger.of(-1); + } else if(group instanceof EString g) { + return GInteger.of(g.getValue().indexOf(getString(item, ITEM_ID, FIND01))); + } else throw failOnInvalidArgumentType(FIND02, GROUP_ID, group); + }; + var function = new NFunction(handler, GROUP_ID, ITEM_ID); + symbols.put(FIND_FN2, function); + } + + private void scriptFindFunction2() { + var handler = (NHandler) (scope, arguments) -> { + var group = arguments.get(0); + var item = arguments.get(1); + var from = arguments.get(2); + var rc = scope.getRuntime(); + if(group instanceof EArray g) { + var s = g.size(); + for(int i = (int) getInteger(from, FROM_ID, FIND03); i < s; i++) + if(areEqual(g.get(i), item, rc)) return GInteger.of(i); + return GInteger.of(-1); + } else if(group instanceof EString g) { + return GInteger.of(g.getValue().indexOf(getString(item, ITEM_ID, FIND04), + (int) getInteger(from, FROM_ID, FIND05))); + } else throw failOnInvalidArgumentType(FIND06, GROUP_ID, group); + }; + var function = new NFunction(handler, GROUP_ID, ITEM_ID, FROM_ID); + symbols.put(FIND_FN3, function); + } + + private void scriptRegularFunction() { + var handler = (NHandler) (scope, arguments) -> { + var value = arguments.get(0); + if(value instanceof ENull) return FALSE; + if(value instanceof EUndefined) return FALSE; + if(value == VOID) return FALSE; + return TRUE; + }; + var function = new NFunction(handler, VALUE_ID); + symbols.put(REGULAR_FN1, function); + } + + private void scriptFailFunction1() { + var handler = (NHandler) (scope, arguments) -> { + var runtime = scope.getRuntime(); + var caller = scope.resolve(CALLER_HVAR); + if(caller == VOID) caller = null; + runtime.getExceptions().fail(new ScriptInitiatedException(FAIL01, + formatOfSchema(FAIL01, getString(arguments.get(0), MESSAGE_ID, FAIL02), + (JNode) caller))); + return FALSE; + }; + var function = new NFunction(handler, MESSAGE_ID); + symbols.put(FAIL_FN1, function); + } + + private void scriptFailFunction2() { + var handler = (NHandler) (scope, arguments) -> { + var runtime = scope.getRuntime(); + var caller = scope.resolve(CALLER_HVAR); + if(caller == VOID) caller = null; + var code = getString(arguments.get(0), CODE_ID, FAIL03); + runtime.getExceptions().fail(new ScriptInitiatedException(code, + formatOfSchema(code, getString(arguments.get(1), MESSAGE_ID, FAIL04), + (JNode) caller))); + return FALSE; + }; + var function = new NFunction(handler, CODE_ID, MESSAGE_ID); + symbols.put(FAIL_FN2, function); + } + + private void scriptFailFunction3() { + var handler = (NHandler) (scope, arguments) -> { + var code = getString(arguments.get(0), CODE_ID, FAIL05); + var message = getString(arguments.get(1), MESSAGE_ID, FAIL06); + var expected = castObject(arguments.get(2), EXPECTED_ID, FAIL07); + var actual = castObject(arguments.get(3), ACTUAL_ID, FAIL08); + var runtime = scope.getRuntime(); + + runtime.getExceptions().fail(new JsonSchemaException( + new ErrorDetail(code, message), + new ExpectedDetail(getNode(expected, NODE_ID, EXPECTED_ID, FAIL09), + getString(expected, MESSAGE_ID, EXPECTED_ID, FAIL10)), + new ActualDetail(getNode(actual, NODE_ID, ACTUAL_ID, FAIL11), + getString(actual, MESSAGE_ID, ACTUAL_ID, FAIL12)))); + return FALSE; + }; + var function = new NFunction(handler, CODE_ID, MESSAGE_ID, EXPECTED_ID, ACTUAL_ID); + symbols.put(FAIL_FN4, function); + } + + private static JNode getNode(EObject object, String key, String parameter, String code) { + var value = dereference(object.get(key)); + if(value == VOID || !(value instanceof JNode node)) + throw failOnInvalidArgumentValue(code, parameter, object); + return node; + } + + private static String getString(EObject object, String key, String parameter, String code) { + var value = dereference(object.get(key)); + if(value == VOID || !(value instanceof EString string)) + throw failOnInvalidArgumentValue(code, parameter, object); + return string.getValue(); + } + + private void scriptExpectedFunction1() { + var handler = (NHandler) (scope, arguments) -> { + var object = new GObject(2); + object.set(NODE_ID, scope.resolve(CALLER_HVAR)); + object.set(MESSAGE_ID, castString(arguments.get(0), MESSAGE_ID, EXPC01)); + return object; + }; + var function = new NFunction(handler, MESSAGE_ID); + symbols.put(EXPECTED_FN1, function); + } + + private void scriptExpectedFunction2() { + var handler = (NHandler) (scope, arguments) -> { + var object = new GObject(2); + object.set(NODE_ID, getNode(arguments.get(0), NODE_ID, EXPC02)); + object.set(MESSAGE_ID, castString(arguments.get(1), MESSAGE_ID, EXPC03)); + return object; + }; + var function = new NFunction(handler, NODE_ID, MESSAGE_ID); + symbols.put(EXPECTED_FN2, function); + } + + private void scriptActualFunction1() { + var handler = (NHandler) (scope, arguments) -> { + var object = new GObject(2); + object.set(NODE_ID, scope.resolve(TARGET_HVAR)); + object.set(MESSAGE_ID, castString(arguments.get(0), MESSAGE_ID, ACTL01)); + return object; + }; + var function = new NFunction(handler, MESSAGE_ID); + symbols.put(ACTUAL_FN1, function); + } + + private void scriptActualFunction2() { + var handler = (NHandler) (scope, arguments) -> { + var object = new GObject(2); + object.set(NODE_ID, getNode(arguments.get(0), NODE_ID, ACTL02)); + object.set(MESSAGE_ID, castString(arguments.get(1), MESSAGE_ID, ACTL03)); + return object; + }; + var function = new NFunction(handler, NODE_ID, MESSAGE_ID); + symbols.put(ACTUAL_FN2, function); + } + + private void scriptCopyFunction() { + var handler = (NHandler) (scope, arguments) -> { + var value = arguments.get(0); + if(value instanceof EArray a) return new GArray(a.elements()); + if(value instanceof EObject o) return new GObject(o); + if(value instanceof EString s) return GString.of(s.getValue()); + if(value instanceof EInteger i) return GInteger.of(i.getValue()); + if(value instanceof EDouble d) return GDouble.of(d.getValue()); + return value; + }; + var function = new NFunction(handler, VALUE_ID); + symbols.put(COPY_FN1, function); + } + + private void scriptFillFunction() { + var handler = (NHandler) (scope, arguments) -> GArray.filledFrom( + arguments.get(0), (int) getInteger(arguments.get(1), SIZE_ID, FILL01)); + var function = new NFunction(handler, VALUE_ID, SIZE_ID); + symbols.put(FILL_FN2, function); + } + + private void scriptCeilFunction() { + var handler = (NHandler) (scope, arguments) -> GInteger.of((long) Math.ceil( + getNumber(arguments.get(0), VALUE_ID, CEIL01))); + var function = new NFunction(handler, VALUE_ID); + symbols.put(CEIL_FN1, function); + } + + private void scriptFloorFunction() { + var handler = (NHandler) (scope, arguments) -> GInteger.of((long) Math.floor( + getNumber(arguments.get(0), VALUE_ID, FLOR01))); + var function = new NFunction(handler, VALUE_ID); + symbols.put(FLOOR_FN1, function); + } + + private void scriptModFunction() { + var handler = (NHandler) (scope, arguments) -> { + var val1 = arguments.get(0); + var val2 = arguments.get(1); + var num1 = getNumber(val1, VALUE1_ID, MODU01); + var num2 = getNumber(val2, VALUE2_ID, MODU02); + if(val1 instanceof EInteger i1 && val2 instanceof EInteger i2) + return GInteger.of(i1.getValue() % i2.getValue()); + return GDouble.of(num1 % num2); + }; + var function = new NFunction(handler, VALUE1_ID, VALUE2_ID); + symbols.put(MOD_FN2, function); + } + + private void scriptPowFunction() { + var handler = (NHandler) (scope, arguments) -> GDouble.of(Math.pow( + getNumber(arguments.get(0), VALUE1_ID, POWR01), + getNumber(arguments.get(1), VALUE2_ID, POWR02) + )); + var function = new NFunction(handler, VALUE1_ID, VALUE2_ID); + symbols.put(POW_FN2, function); + } + + private void scriptLogFunction() { + var handler = (NHandler) (scope, arguments) -> { + var value = getNumber(arguments.get(0), VALUE_ID, LOGA01); + return GDouble.of(Math.log(value)); + }; + var function = new NFunction(handler, VALUE_ID); + symbols.put(LOG_FN1, function); + } + + private void scriptTicksFunction() { + var handler = (NHandler) (scope, arguments) -> GInteger.of(System.nanoTime()); + var function = new NFunction(handler); + symbols.put(TICKS_FN0, function); + } + + private static long getInteger(EValue value, String parameter, String code) { + if(!(value instanceof EInteger v)) throw failOnInvalidArgumentType(code, parameter, value); + return v.getValue(); + } + + private static double getNumber(EValue value, String parameter, String code) { + if(!(value instanceof ENumber v)) throw failOnInvalidArgumentType(code, parameter, value); + return v.toDouble(); + } + + private static String getString(EValue value, String parameter, String code) { + if(!(value instanceof EString v)) throw failOnInvalidArgumentType(code, parameter, value); + return v.getValue(); + } + + private static JNode getNode(EValue value, String parameter, String code) { + if(!(value instanceof JNode n)) throw failOnInvalidArgumentType(code, parameter, value); + return n; + } + + private static EString castString(EValue value, String parameter, String code) { + if(!(value instanceof EString v)) throw failOnInvalidArgumentType(code, parameter, value); + return v; + } + + private static EObject castObject(EValue value, String parameter, String code) { + if(!(value instanceof EObject v)) throw failOnInvalidArgumentType(code, parameter, value); + return v; + } + + private static ScriptArgumentException failOnInvalidArgumentType(String code, + String parameter, EValue value) { + return new ScriptArgumentException(code, concat("Invalid argument type ", + value.getType(), " for parameter '", parameter, "' of function '%s'")); + } + + private static ScriptArgumentException failOnInvalidArgumentValue(String code, + String parameter, EValue value) { + return new ScriptArgumentException(code, concat("Invalid argument value ", + createOutline(value), " for parameter '", parameter, + "' of function '%s'")); + } +} \ No newline at end of file From 654f11d15126ad0ad3a918bab8cee0867819ab30 Mon Sep 17 00:00:00 2001 From: Zahid Hossain <60911932+zhossain-info@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:20:56 +0600 Subject: [PATCH 10/12] Refactor core functions for schema --- .../jschema/function/CoreFunctions1.java | 166 ++++++++++++++ .../jschema/function/CoreFunctions2.java | 203 ++++++++++++++++++ .../jschema/function/CoreFunctions3.java | 154 +++++++++++++ .../jschema/function/CoreFunctions4.java | 162 ++++++++++++++ .../jschema/function/FunctionProvider.java | 20 ++ .../jschema/function/FutureFunction.java | 6 + .../internal/function/DateTimeAgent.java | 51 +++++ .../json/schema/function/FunctionBase.java | 20 -- 8 files changed, 762 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/relogiclabs/jschema/function/CoreFunctions1.java create mode 100644 src/main/java/com/relogiclabs/jschema/function/CoreFunctions2.java create mode 100644 src/main/java/com/relogiclabs/jschema/function/CoreFunctions3.java create mode 100644 src/main/java/com/relogiclabs/jschema/function/CoreFunctions4.java create mode 100644 src/main/java/com/relogiclabs/jschema/function/FunctionProvider.java create mode 100644 src/main/java/com/relogiclabs/jschema/function/FutureFunction.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/function/DateTimeAgent.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/function/FunctionBase.java diff --git a/src/main/java/com/relogiclabs/jschema/function/CoreFunctions1.java b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions1.java new file mode 100644 index 0000000..51609e6 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions1.java @@ -0,0 +1,166 @@ +package com.relogiclabs.jschema.function; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.message.ActualDetail; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ExpectedDetail; +import com.relogiclabs.jschema.node.JArray; +import com.relogiclabs.jschema.node.JInteger; +import com.relogiclabs.jschema.node.JObject; +import com.relogiclabs.jschema.node.JString; +import com.relogiclabs.jschema.node.JUndefined; +import com.relogiclabs.jschema.tree.RuntimeContext; + +import static com.relogiclabs.jschema.message.ErrorCode.ALEN01; +import static com.relogiclabs.jschema.message.ErrorCode.ALEN02; +import static com.relogiclabs.jschema.message.ErrorCode.ALEN03; +import static com.relogiclabs.jschema.message.ErrorCode.ALEN04; +import static com.relogiclabs.jschema.message.ErrorCode.ALEN05; +import static com.relogiclabs.jschema.message.ErrorCode.OLEN01; +import static com.relogiclabs.jschema.message.ErrorCode.OLEN02; +import static com.relogiclabs.jschema.message.ErrorCode.OLEN03; +import static com.relogiclabs.jschema.message.ErrorCode.OLEN04; +import static com.relogiclabs.jschema.message.ErrorCode.OLEN05; +import static com.relogiclabs.jschema.message.ErrorCode.SLEN01; +import static com.relogiclabs.jschema.message.ErrorCode.SLEN02; +import static com.relogiclabs.jschema.message.ErrorCode.SLEN03; +import static com.relogiclabs.jschema.message.ErrorCode.SLEN04; +import static com.relogiclabs.jschema.message.ErrorCode.SLEN05; + +public abstract class CoreFunctions1 extends FunctionProvider { + public CoreFunctions1(RuntimeContext runtime) { + super(runtime); + } + + public boolean length(JString target, JInteger length) { + var rLength = target.length(); + if(rLength != length.getValue()) return fail(new JsonSchemaException( + new ErrorDetail(SLEN01, "Invalid length of string ", target), + new ExpectedDetail(function, "a string of length ", length), + new ActualDetail(target, "found ", rLength, " which does not match"))); + return true; + } + + public boolean length(JArray target, JInteger length) { + var rLength = target.getElements().size(); + if(rLength != length.getValue()) return fail(new JsonSchemaException( + new ErrorDetail(ALEN01, "Invalid length of array ", target.getOutline()), + new ExpectedDetail(function, "an array of length ", length), + new ActualDetail(target, "found ", rLength, " which does not match"))); + return true; + } + + public boolean length(JObject target, JInteger length) { + var rLength = target.getProperties().size(); + if(rLength != length.getValue()) return fail(new JsonSchemaException( + new ErrorDetail(OLEN01, "Invalid size or length of object ", target.getOutline()), + new ExpectedDetail(function, "an object of length ", length), + new ActualDetail(target, "found ", rLength, " which does not match"))); + return true; + } + + public boolean length(JString target, JInteger minimum, JInteger maximum) { + var length = target.length(); + if(length < minimum.getValue()) + return fail(new JsonSchemaException(new ErrorDetail(SLEN02, + "String ", target.getOutline(), " length is outside of range"), + new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), + new ActualDetail(target, "found ", length, " that is less than ", minimum))); + if(length > maximum.getValue()) + return fail(new JsonSchemaException(new ErrorDetail(SLEN03, + "String ", target.getOutline(), " length is outside of range"), + new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), + new ActualDetail(target, "found ", length, " that is greater than ", maximum))); + return true; + } + + public boolean length(JString target, JInteger minimum, JUndefined undefined) { + var length = target.length(); + if(length < minimum.getValue()) + return fail(new JsonSchemaException(new ErrorDetail(SLEN04, + "String ", target.getOutline(), " length is outside of range"), + new ExpectedDetail(function, "length in range [", minimum, ", ", undefined, "]"), + new ActualDetail(target, "found ", length, " that is less than ", minimum))); + return true; + } + + public boolean length(JString target, JUndefined undefined, JInteger maximum) { + var length = target.length(); + if(length > maximum.getValue()) + return fail(new JsonSchemaException(new ErrorDetail(SLEN05, + "String ", target.getOutline(), " length is outside of range"), + new ExpectedDetail(function, "length in range [", undefined, ", ", maximum, "]"), + new ActualDetail(target, "found ", length, " that is greater than ", maximum))); + return true; + } + + public boolean length(JArray target, JInteger minimum, JInteger maximum) { + var length = target.getElements().size(); + if(length < minimum.getValue()) + return fail(new JsonSchemaException(new ErrorDetail(ALEN02, + "Array ", target.getOutline(), " length is outside of range"), + new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), + new ActualDetail(target, "found ", length, " that is less than ", minimum))); + if(length > maximum.getValue()) + return fail(new JsonSchemaException(new ErrorDetail(ALEN03, + "Array ", target.getOutline(), " length is outside of range"), + new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), + new ActualDetail(target, "found ", length, " that is greater than ", maximum))); + return true; + } + + public boolean length(JArray target, JInteger minimum, JUndefined undefined) { + var length = target.getElements().size(); + if(length < minimum.getValue()) + return fail(new JsonSchemaException(new ErrorDetail(ALEN04, + "Array ", target.getOutline(), " length is outside of range"), + new ExpectedDetail(function, "length in range [", minimum, ", ", undefined, "]"), + new ActualDetail(target, "found ", length, " that is less than ", minimum))); + return true; + } + + public boolean length(JArray target, JUndefined undefined, JInteger maximum) { + var length = target.getElements().size(); + if(length > maximum.getValue()) + return fail(new JsonSchemaException(new ErrorDetail(ALEN05, + "Array ", target.getOutline(), " length is outside of range"), + new ExpectedDetail(function, "length in range [", undefined, ", ", maximum, "]"), + new ActualDetail(target, "found ", length, " that is greater than ", maximum))); + return true; + } + + public boolean length(JObject target, JInteger minimum, JInteger maximum) { + var length = target.getProperties().size(); + if(length < minimum.getValue()) + return fail(new JsonSchemaException(new ErrorDetail(OLEN02, + "Object ", target.getOutline(), " size or length is outside of range"), + new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), + new ActualDetail(target, "found ", length, " that is less than ", minimum))); + if(length > maximum.getValue()) + return fail(new JsonSchemaException(new ErrorDetail(OLEN03, + "Object ", target.getOutline(), " size or length is outside of range"), + new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), + new ActualDetail(target, "found ", length, " that is greater than ", maximum))); + return true; + } + + public boolean length(JObject target, JInteger minimum, JUndefined undefined) { + var length = target.getProperties().size(); + if(length < minimum.getValue()) + return fail(new JsonSchemaException(new ErrorDetail(OLEN04, + "Object ", target.getOutline(), " size or length is outside of range"), + new ExpectedDetail(function, "length in range [", minimum, ", ", undefined, "]"), + new ActualDetail(target, "found ", length, " that is less than ", minimum))); + return true; + } + + public boolean length(JObject target, JUndefined undefined, JInteger maximum) { + var length = target.getProperties().size(); + if(length > maximum.getValue()) + return fail(new JsonSchemaException(new ErrorDetail(OLEN05, + "Object ", target.getOutline(), " size or length is outside of range"), + new ExpectedDetail(function, "length in range [", undefined, ", ", maximum, "]"), + new ActualDetail(target, "found ", length, " that is greater than ", maximum))); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/function/CoreFunctions2.java b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions2.java new file mode 100644 index 0000000..f6cd189 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions2.java @@ -0,0 +1,203 @@ +package com.relogiclabs.jschema.function; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.message.ActualDetail; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ExpectedDetail; +import com.relogiclabs.jschema.node.JArray; +import com.relogiclabs.jschema.node.JBoolean; +import com.relogiclabs.jschema.node.JNumber; +import com.relogiclabs.jschema.node.JObject; +import com.relogiclabs.jschema.node.JString; +import com.relogiclabs.jschema.node.JUndefined; +import com.relogiclabs.jschema.tree.RuntimeContext; + +import java.util.Arrays; +import java.util.function.Supplier; + +import static com.relogiclabs.jschema.internal.util.StringHelper.joinWith; +import static com.relogiclabs.jschema.message.ErrorCode.ENUM01; +import static com.relogiclabs.jschema.message.ErrorCode.ENUM02; +import static com.relogiclabs.jschema.message.ErrorCode.MAXI01; +import static com.relogiclabs.jschema.message.ErrorCode.MAXI02; +import static com.relogiclabs.jschema.message.ErrorCode.MAXI03; +import static com.relogiclabs.jschema.message.ErrorCode.MINI01; +import static com.relogiclabs.jschema.message.ErrorCode.MINI02; +import static com.relogiclabs.jschema.message.ErrorCode.MINI03; +import static com.relogiclabs.jschema.message.ErrorCode.NEGI01; +import static com.relogiclabs.jschema.message.ErrorCode.NEGI02; +import static com.relogiclabs.jschema.message.ErrorCode.NEMT01; +import static com.relogiclabs.jschema.message.ErrorCode.NEMT02; +import static com.relogiclabs.jschema.message.ErrorCode.NEMT03; +import static com.relogiclabs.jschema.message.ErrorCode.POSI01; +import static com.relogiclabs.jschema.message.ErrorCode.POSI02; +import static com.relogiclabs.jschema.message.ErrorCode.RANG01; +import static com.relogiclabs.jschema.message.ErrorCode.RANG02; +import static com.relogiclabs.jschema.message.ErrorCode.RANG03; +import static com.relogiclabs.jschema.message.ErrorCode.RANG04; + +public abstract class CoreFunctions2 extends CoreFunctions1 { + public CoreFunctions2(RuntimeContext runtime) { + super(runtime); + } + + // enum is a keyword in Java but _ will be escaped + public boolean _enum(JString target, JString... items) { + var list = Arrays.asList(items); + if(!list.contains(target)) return fail(new JsonSchemaException( + new ErrorDetail(ENUM01, "String is not in enum list"), + new ExpectedDetail(function, "string in list ", joinWith(list, ", ", "[", "]")), + new ActualDetail(target, "string ", target, " is not found in list"))); + return true; + } + + public boolean _enum(JNumber target, JNumber... items) { + var list = Arrays.asList(items); + if(!list.contains(target)) return fail(new JsonSchemaException( + new ErrorDetail(ENUM02, "Number is not in enum list"), + new ExpectedDetail(function, "number in list ", joinWith(list, ", ", "[", "]")), + new ActualDetail(target, "number ", target, " is not found in list"))); + return true; + } + + public boolean minimum(JNumber target, JNumber minimum) { + if(target.compare(minimum) < 0) + return fail(new JsonSchemaException( + new ErrorDetail(MINI01, "Number is less than provided minimum"), + new ExpectedDetail(function, "a number greater than or equal to ", minimum), + new ActualDetail(target, "number ", target, " is less than ", minimum))); + return true; + } + + public boolean minimum(JNumber target, JNumber minimum, JBoolean exclusive) { + Supplier relationTo = () -> exclusive.getValue() + ? "greater than" + : "greater than or equal to"; + + if(target.compare(minimum) < 0) + return fail(new JsonSchemaException( + new ErrorDetail(MINI02, "Number is less than provided minimum"), + new ExpectedDetail(function, "a number ", relationTo.get(), " ", minimum), + new ActualDetail(target, "number ", target, " is less than ", minimum))); + if(exclusive.getValue() && target.compare(minimum) == 0) + return fail(new JsonSchemaException( + new ErrorDetail(MINI03, "Number is equal to provided minimum"), + new ExpectedDetail(function, "a number ", relationTo.get(), " ", minimum), + new ActualDetail(target, "number ", target, " is equal to ", minimum))); + return true; + } + + public boolean maximum(JNumber target, JNumber maximum) { + if(target.compare(maximum) > 0) + return fail(new JsonSchemaException( + new ErrorDetail(MAXI01, "Number is greater than provided maximum"), + new ExpectedDetail(function, "a number less than or equal ", maximum), + new ActualDetail(target, "number ", target, " is greater than ", maximum))); + return true; + } + + public boolean maximum(JNumber target, JNumber maximum, JBoolean exclusive) { + Supplier relationTo = () -> exclusive.getValue() + ? "less than" + : "less than or equal to"; + + if(target.compare(maximum) > 0) + return fail(new JsonSchemaException( + new ErrorDetail(MAXI02, "Number is greater than provided maximum"), + new ExpectedDetail(function, "a number ", relationTo.get(), " ", maximum), + new ActualDetail(target, "number ", target, " is greater than ", maximum))); + if(exclusive.getValue() && target.compare(maximum) == 0) + return fail(new JsonSchemaException( + new ErrorDetail(MAXI03, "Number is equal to provided maximum"), + new ExpectedDetail(function, "a number ", relationTo.get(), " ", maximum), + new ActualDetail(target, "number ", target, " is equal to ", maximum))); + return true; + } + + public boolean positive(JNumber target) { + if(target.compare(0) <= 0) return fail(new JsonSchemaException( + new ErrorDetail(POSI01, "Number is not positive"), + new ExpectedDetail(function, "a positive number"), + new ActualDetail(target, "number ", target, " is less than or equal to zero"))); + return true; + } + + public boolean negative(JNumber target) { + if(target.compare(0) >= 0) return fail(new JsonSchemaException( + new ErrorDetail(NEGI01, "Number is not negative"), + new ExpectedDetail(function, "a negative number"), + new ActualDetail(target, "number ", target, " is greater than or equal to zero"))); + return true; + } + + public boolean positive(JNumber target, JNumber reference) { + if(target.compare(reference) < 0) return fail(new JsonSchemaException( + new ErrorDetail(POSI02, "Number is not positive from reference"), + new ExpectedDetail(function, "a positive number from ", reference), + new ActualDetail(target, "number ", target, " is less than reference"))); + return true; + } + + public boolean negative(JNumber target, JNumber reference) { + if(target.compare(reference) > 0) return fail(new JsonSchemaException( + new ErrorDetail(NEGI02, "Number is not negative from reference"), + new ExpectedDetail(function, "a negative number from ", reference), + new ActualDetail(target, "number ", target, " is greater than reference"))); + return true; + } + + public boolean range(JNumber target, JNumber minimum, JNumber maximum) { + if(target.compare(minimum) < 0) return fail(new JsonSchemaException( + new ErrorDetail(RANG01, "Number is outside of range"), + new ExpectedDetail(function, "number in range [", minimum, ", ", maximum, "]"), + new ActualDetail(target, "number ", target, " is less than ", minimum))); + if(target.compare(maximum) > 0) return fail(new JsonSchemaException( + new ErrorDetail(RANG02, "Number is outside of range"), + new ExpectedDetail(function, "number in range [", minimum, ", ", maximum, "]"), + new ActualDetail(target, "number ", target, " is greater than ", maximum))); + return true; + } + + public boolean range(JNumber target, JNumber minimum, JUndefined undefined) { + if(target.compare(minimum) < 0) return fail(new JsonSchemaException( + new ErrorDetail(RANG03, "Number is outside of range"), + new ExpectedDetail(function, "number in range [", minimum, ", ", undefined, "]"), + new ActualDetail(target, "number ", target, " is less than ", minimum))); + return true; + } + + public boolean range(JNumber target, JUndefined undefined, JNumber maximum) { + if(target.compare(maximum) > 0) return fail(new JsonSchemaException( + new ErrorDetail(RANG04, "Number is outside of range"), + new ExpectedDetail(function, "number in range [", undefined, ", ", maximum, "]"), + new ActualDetail(target, "number ", target, " is greater than ", maximum))); + return true; + } + + public boolean nonempty(JString target) { + var length = target.length(); + if(length <= 0) return fail(new JsonSchemaException( + new ErrorDetail(NEMT01, "String is empty"), + new ExpectedDetail(function, "Non empty string"), + new ActualDetail(target, "found empty string"))); + return true; + } + + public boolean nonempty(JArray target) { + var length = target.getElements().size(); + if(length <= 0) return fail(new JsonSchemaException( + new ErrorDetail(NEMT02, "Array is empty"), + new ExpectedDetail(function, "Non empty array"), + new ActualDetail(target, "found empty array"))); + return true; + } + + public boolean nonempty(JObject target) { + var length = target.getProperties().size(); + if(length <= 0) return fail(new JsonSchemaException( + new ErrorDetail(NEMT03, "Object is empty"), + new ExpectedDetail(function, "Non empty object"), + new ActualDetail(target, "found empty object"))); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/function/CoreFunctions3.java b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions3.java new file mode 100644 index 0000000..49fc64c --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions3.java @@ -0,0 +1,154 @@ +package com.relogiclabs.jschema.function; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.message.ActualDetail; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ExpectedDetail; +import com.relogiclabs.jschema.node.JArray; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JObject; +import com.relogiclabs.jschema.node.JString; +import com.relogiclabs.jschema.tree.RuntimeContext; + +import java.net.URI; +import java.util.Arrays; +import java.util.regex.Pattern; + +import static com.relogiclabs.jschema.internal.util.CollectionHelper.containsKeys; +import static com.relogiclabs.jschema.internal.util.CollectionHelper.containsValues; +import static com.relogiclabs.jschema.internal.util.StreamHelper.count; +import static com.relogiclabs.jschema.internal.util.StringHelper.quote; +import static com.relogiclabs.jschema.message.ErrorCode.ELEM01; +import static com.relogiclabs.jschema.message.ErrorCode.EMAL01; +import static com.relogiclabs.jschema.message.ErrorCode.KEYS01; +import static com.relogiclabs.jschema.message.ErrorCode.PHON01; +import static com.relogiclabs.jschema.message.ErrorCode.REGX01; +import static com.relogiclabs.jschema.message.ErrorCode.URLA01; +import static com.relogiclabs.jschema.message.ErrorCode.URLA02; +import static com.relogiclabs.jschema.message.ErrorCode.URLA03; +import static com.relogiclabs.jschema.message.ErrorCode.URLA04; +import static com.relogiclabs.jschema.message.ErrorCode.VALU01; + +public abstract class CoreFunctions3 extends CoreFunctions2 { + private static final String URI_SCHEME_HTTPS = "https"; + private static final String URI_SCHEME_HTTP = "http"; + + private static final Pattern EMAIL_REGEX + = Pattern.compile("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}"); + private static final Pattern PHONE_REGEX + = Pattern.compile("\\+?[0-9 ()-]+"); + + public CoreFunctions3(RuntimeContext runtime) { + super(runtime); + } + + public boolean elements(JArray target, JNode... items) { + return count(Arrays.stream(items) + .filter(n -> !target.getElements().contains(n)) + .map(n -> failOnElement(target, n))) == 0; + } + + private boolean failOnElement(JArray target, JNode node) { + return fail(new JsonSchemaException( + new ErrorDetail(ELEM01, "Value is not an element of array"), + new ExpectedDetail(function, "array with value ", node), + new ActualDetail(target, "not found in ", target.getOutline()))); + } + + public boolean keys(JObject target, JString... items) { + return count(containsKeys(target.getProperties(), items) + .stream().map(s -> failOnKey(target, s))) == 0; + } + + private boolean failOnKey(JObject target, String string) { + return fail(new JsonSchemaException( + new ErrorDetail(KEYS01, "Object does not contain the key"), + new ExpectedDetail(function, "object with key ", quote(string)), + new ActualDetail(target, "does not contain in ", target.getOutline()))); + } + + public boolean values(JObject target, JNode... items) { + return count(containsValues(target.getProperties(), items) + .stream().map(n -> failOnValue(target, n))) == 0; + } + + private boolean failOnValue(JObject target, JNode node) { + return fail(new JsonSchemaException( + new ErrorDetail(VALU01, "Object does not contain the value"), + new ExpectedDetail(function, "object with value ", node), + new ActualDetail(target, "does not contain in ", target.getOutline()))); + } + + public boolean regex(JString target, JString pattern) { + if(!Pattern.matches(pattern.getValue(), target.getValue())) + return fail(new JsonSchemaException( + new ErrorDetail(REGX01, "Regex pattern does not match"), + new ExpectedDetail(function, "string of pattern ", pattern.getOutline()), + new ActualDetail(target, "found ", target.getOutline(), + " that mismatches with pattern"))); + return true; + } + + public boolean email(JString target) { + // Based on SMTP protocol RFC 5322 + if(!EMAIL_REGEX.matcher(target.getValue()).matches()) + return fail(new JsonSchemaException( + new ErrorDetail(EMAL01, "Invalid email address"), + new ExpectedDetail(function, "a valid email address"), + new ActualDetail(target, "found ", target, " that is invalid"))); + return true; + } + + public boolean url(JString target) { + boolean result; + URI uri; + try { + uri = new URI(target.getValue()); + result = switch(uri.getScheme()) { + case URI_SCHEME_HTTP, URI_SCHEME_HTTPS -> true; + default -> false; + }; + } catch (Exception e) { + return fail(new JsonSchemaException( + new ErrorDetail(URLA01, "Invalid url address"), + new ExpectedDetail(function, "a valid url address"), + new ActualDetail(target, "found ", target, " that is invalid"))); + } + if(!result) return fail(new JsonSchemaException( + new ErrorDetail(URLA02, "Invalid url address scheme"), + new ExpectedDetail(function, "HTTP or HTTPS scheme"), + new ActualDetail(target, "found ", quote(uri.getScheme()), " from ", + target, " that has invalid scheme"))); + return true; + } + + public boolean url(JString target, JString scheme) { + boolean result; + URI uri; + try { + uri = new URI(target.getValue()); + } catch (Exception e) { + return fail(new JsonSchemaException( + new ErrorDetail(URLA03, "Invalid url address"), + new ExpectedDetail(function, "a valid url address"), + new ActualDetail(target, "found ", target, " that is invalid"))); + } + result = scheme.getValue().equals(uri.getScheme()); + if(!result) return fail(new JsonSchemaException( + new ErrorDetail(URLA04, "Mismatch url address scheme"), + new ExpectedDetail(function, "scheme ", scheme, " for url address"), + new ActualDetail(target, "found ", quote(uri.getScheme()), " from ", + target, " that does not matched"))); + return true; + } + + public boolean phone(JString target) { + // Based on ITU-T E.163 and E.164 (extended) + if(!PHONE_REGEX.matcher(target.getValue()).matches()) + return fail(new JsonSchemaException( + new ErrorDetail(PHON01, "Invalid phone number format"), + new ExpectedDetail(function, "a valid phone number"), + new ActualDetail(target, "found ", target, " that is invalid"))); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/function/CoreFunctions4.java b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions4.java new file mode 100644 index 0000000..ebc4935 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions4.java @@ -0,0 +1,162 @@ +package com.relogiclabs.jschema.function; + +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.internal.function.DateTimeAgent; +import com.relogiclabs.jschema.internal.time.DateTimeParser; +import com.relogiclabs.jschema.message.ActualDetail; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ExpectedDetail; +import com.relogiclabs.jschema.node.JDateTime; +import com.relogiclabs.jschema.node.JString; +import com.relogiclabs.jschema.node.JUndefined; +import com.relogiclabs.jschema.time.DateTimeType; +import com.relogiclabs.jschema.tree.RuntimeContext; + +import static com.relogiclabs.jschema.message.ErrorCode.AFTR01; +import static com.relogiclabs.jschema.message.ErrorCode.AFTR02; +import static com.relogiclabs.jschema.message.ErrorCode.BFOR01; +import static com.relogiclabs.jschema.message.ErrorCode.BFOR02; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG01; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG02; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG03; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG04; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG05; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG06; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG07; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG08; +import static com.relogiclabs.jschema.message.ErrorCode.ENDE01; +import static com.relogiclabs.jschema.message.ErrorCode.ENDE02; +import static com.relogiclabs.jschema.message.ErrorCode.STRT01; +import static com.relogiclabs.jschema.message.ErrorCode.STRT02; +import static com.relogiclabs.jschema.time.DateTimeType.DATE_TYPE; + +public class CoreFunctions4 extends CoreFunctions3 { + public CoreFunctions4(RuntimeContext runtime) { + super(runtime); + } + + public boolean date(JString target, JString pattern) { + return dateTime(target, pattern, DATE_TYPE); + } + + public boolean time(JString target, JString pattern) { + return dateTime(target, pattern, DateTimeType.TIME_TYPE); + } + + private boolean dateTime(JString target, JString pattern, DateTimeType type) { + return new DateTimeAgent(pattern.getValue(), type).parse(function, target) != null; + } + + public boolean before(JDateTime target, JString reference) { + var dateTime = getDateTime(target.getDateTimeParser(), reference); + if(dateTime == null) return false; + if(target.getDateTime().compare(dateTime.getDateTime()) < 0) return true; + var type = target.getDateTime().getType(); + var code = type == DATE_TYPE ? BFOR01 : BFOR02; + return fail(new JsonSchemaException( + new ErrorDetail(code, type, " is not earlier than specified"), + new ExpectedDetail(reference, "a ", type, " before ", reference), + new ActualDetail(target, "found ", target, " which is not inside limit") + )); + } + + public boolean after(JDateTime target, JString reference) { + var dateTime = getDateTime(target.getDateTimeParser(), reference); + if(dateTime == null) return false; + if(target.getDateTime().compare(dateTime.getDateTime()) > 0) return true; + var type = target.getDateTime().getType(); + var code = type == DATE_TYPE ? AFTR01 : AFTR02; + return fail(new JsonSchemaException( + new ErrorDetail(code, type, " is not later than specified"), + new ExpectedDetail(reference, "a ", type, " after ", reference), + new ActualDetail(target, "found ", target, " which is not inside limit") + )); + } + + public boolean range(JDateTime target, JString start, JString end) { + var rStart = getDateTime(target.getDateTimeParser(), start); + if(rStart == null) return false; + var rEnd = getDateTime(target.getDateTimeParser(), end); + if(rEnd == null) return false; + if(target.getDateTime().compare(rStart.getDateTime()) < 0) + return failOnStartDate(target, rStart, getErrorCode(target, DRNG01, DRNG02)); + if(target.getDateTime().compare(rEnd.getDateTime()) > 0) + return failOnEndDate(target, rEnd, getErrorCode(target, DRNG03, DRNG04)); + return true; + } + + private static String getErrorCode(JDateTime target, String date, String time) { + return target.getDateTime().getType() == DATE_TYPE ? date : time; + } + + private boolean failOnStartDate(JDateTime target, JDateTime start, String code) { + var type = target.getDateTime().getType(); + return fail(new JsonSchemaException( + new ErrorDetail(code, type, " is earlier than start ", type), + new ExpectedDetail(start, "a ", type, " from or after ", start), + new ActualDetail(target, "found ", target, " which is before start ", type) + )); + } + + private boolean failOnEndDate(JDateTime target, JDateTime end, String code) { + var type = target.getDateTime().getType(); + return fail(new JsonSchemaException( + new ErrorDetail(code, type, " is later than end ", type), + new ExpectedDetail(end, "a ", type, " until or before ", end), + new ActualDetail(target, "found ", target, " which is after end ", type) + )); + } + + public boolean range(JDateTime target, JUndefined start, JString end) { + var rEnd = getDateTime(target.getDateTimeParser(), end); + if(rEnd == null) return false; + if (target.getDateTime().compare(rEnd.getDateTime()) <= 0) return true; + return failOnEndDate(target, rEnd, getErrorCode(target, DRNG05, DRNG06)); + } + + public boolean range(JDateTime target, JString start, JUndefined end) { + var rStart = getDateTime(target.getDateTimeParser(), start); + if(rStart == null) return false; + if (target.getDateTime().compare(rStart.getDateTime()) >= 0) return true; + return failOnStartDate(target, rStart, getErrorCode(target, DRNG07, DRNG08)); + } + + public boolean start(JDateTime target, JString reference) { + var dateTime = getDateTime(target.getDateTimeParser(), reference); + if(dateTime == null) return false; + if(target.getDateTime().compare(dateTime.getDateTime()) < 0) { + var type = target.getDateTime().getType(); + var code = type == DATE_TYPE ? STRT01 : STRT02; + return fail(new JsonSchemaException( + new ErrorDetail(code, type, " is earlier than specified"), + new ExpectedDetail(dateTime, "a ", type, " from or after ", dateTime), + new ActualDetail(target, "found ", target, " which is before limit") + )); + } + return true; + } + + public boolean end(JDateTime target, JString reference) { + var dateTime = getDateTime(target.getDateTimeParser(), reference); + if(dateTime == null) return false; + if(target.getDateTime().compare(dateTime.getDateTime()) > 0) { + var type = target.getDateTime().getType(); + var code = type == DATE_TYPE ? ENDE01 : ENDE02; + return fail(new JsonSchemaException( + new ErrorDetail(code, type, " is later than specified"), + new ExpectedDetail(dateTime, "a ", type, " until or before ", dateTime), + new ActualDetail(target, "found ", target, " which is after limit") + )); + } + return true; + } + + private JDateTime getDateTime(DateTimeParser parser, JString dateTime) { + if(dateTime.getDerived() instanceof JDateTime result + && result.getDateTime().getType() == parser.getType()) return result; + var jDateTime = new DateTimeAgent(parser).parse(function, dateTime); + if(jDateTime == null) return null; + dateTime.setDerived(jDateTime.createNode(dateTime)); + return (JDateTime) dateTime.getDerived(); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/function/FunctionProvider.java b/src/main/java/com/relogiclabs/jschema/function/FunctionProvider.java new file mode 100644 index 0000000..fdfdf7b --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/function/FunctionProvider.java @@ -0,0 +1,20 @@ +package com.relogiclabs.jschema.function; + +import com.relogiclabs.jschema.node.JFunction; +import com.relogiclabs.jschema.tree.RuntimeContext; +import lombok.Getter; +import lombok.Setter; + +@Getter +public abstract class FunctionProvider { + protected final RuntimeContext runtime; + @Setter protected JFunction function; + + public FunctionProvider(RuntimeContext runtime) { + this.runtime = runtime; + } + + protected boolean fail(RuntimeException exception) { + return runtime.getExceptions().fail(exception); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/function/FutureFunction.java b/src/main/java/com/relogiclabs/jschema/function/FutureFunction.java new file mode 100644 index 0000000..033838e --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/function/FutureFunction.java @@ -0,0 +1,6 @@ +package com.relogiclabs.jschema.function; + +@FunctionalInterface +public interface FutureFunction { + boolean invoke(); +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/function/DateTimeAgent.java b/src/main/java/com/relogiclabs/jschema/internal/function/DateTimeAgent.java new file mode 100644 index 0000000..2bd6539 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/function/DateTimeAgent.java @@ -0,0 +1,51 @@ +package com.relogiclabs.jschema.internal.function; + +import com.relogiclabs.jschema.exception.DateTimeLexerException; +import com.relogiclabs.jschema.exception.InvalidDateTimeException; +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.internal.time.DateTimeParser; +import com.relogiclabs.jschema.message.ActualDetail; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ExpectedDetail; +import com.relogiclabs.jschema.node.JFunction; +import com.relogiclabs.jschema.node.JString; +import com.relogiclabs.jschema.time.DateTimeType; +import com.relogiclabs.jschema.time.JsonDateTime; + +public class DateTimeAgent { + private final String pattern; + private final DateTimeType type; + private DateTimeParser parser; + + public DateTimeAgent(String pattern, DateTimeType type) { + this.pattern = pattern; + this.type = type; + } + + public DateTimeAgent(DateTimeParser parser) { + this.pattern = parser.getPattern(); + this.type = parser.getType(); + this.parser = parser; + } + + public JsonDateTime parse(JFunction function, JString dateTime) { + var exceptions = function.getRuntime().getExceptions(); + try { + if(parser == null) parser = new DateTimeParser(pattern, type); + return parser.parse(dateTime.getValue()); + } catch(DateTimeLexerException ex) { + exceptions.fail(new JsonSchemaException( + new ErrorDetail(ex.getCode(), ex.getMessage()), + new ExpectedDetail(function, "a valid ", type, " pattern"), + new ActualDetail(dateTime, "found ", pattern, " that is invalid"), + ex)); + } catch(InvalidDateTimeException ex) { + exceptions.fail(new JsonSchemaException( + new ErrorDetail(ex.getCode(), ex.getMessage()), + new ExpectedDetail(function, "a valid ", type, " formatted as ", pattern), + new ActualDetail(dateTime, "found ", dateTime, " that is invalid or malformatted"), + ex)); + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/function/FunctionBase.java b/src/main/java/com/relogiclabs/json/schema/function/FunctionBase.java deleted file mode 100644 index 2df0496..0000000 --- a/src/main/java/com/relogiclabs/json/schema/function/FunctionBase.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.relogiclabs.json.schema.function; - -import com.relogiclabs.json.schema.tree.RuntimeContext; -import com.relogiclabs.json.schema.type.JFunction; -import lombok.Getter; -import lombok.Setter; - -@Getter -public abstract class FunctionBase { - protected final RuntimeContext runtime; - @Setter protected JFunction function; - - public FunctionBase(RuntimeContext runtime) { - this.runtime = runtime; - } - - protected boolean failWith(RuntimeException exception) { - return runtime.getExceptions().failWith(exception); - } -} \ No newline at end of file From 780589233e52471459fa6cfc732321a0a6c2cc97 Mon Sep 17 00:00:00 2001 From: Zahid Hossain <60911932+zhossain-info@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:50:20 +0600 Subject: [PATCH 11/12] Refactor packages for schema features --- .../{json/schema => jschema}/JsonAssert.java | 44 +- .../{json/schema => jschema}/JsonSchema.java | 43 +- .../collection/IndexMap.java | 2 +- .../collection/Keyable.java | 2 +- .../jschema/function/CoreFunctions1.java | 30 +- .../jschema/function/CoreFunctions2.java | 49 +- .../jschema/function/CoreFunctions3.java | 20 +- .../jschema/function/CoreFunctions4.java | 4 +- .../jschema/function/FunctionProvider.java | 2 +- .../jschema/internal/antlr/SchemaLexer.interp | 2 +- .../jschema/internal/antlr/SchemaLexer.java | 749 ++++--- .../internal/antlr/SchemaParser.interp | 2 +- .../jschema/internal/antlr/SchemaParser.java | 976 ++++----- .../internal/collection/IndexHashMap.java | 6 +- .../jschema/internal/engine/ScopeContext.java | 4 +- .../internal/engine/ScriptErrorHelper.java | 2 +- .../internal/engine/ScriptTreeHelper.java | 18 +- .../internal/engine/ScriptTreeVisitor1.java | 2 +- .../internal/function/DateTimeAgent.java | 15 +- .../jschema/internal/grammar/SchemaLexer.g4 | 2 +- .../jschema/internal/grammar/SchemaParser.g4 | 2 +- .../jschema/internal/library/NFunction.java | 10 +- .../internal/library/ScriptLibrary.java | 82 +- .../internal/message/ActualHelper.java | 14 +- .../internal/message/ExpectedHelper.java | 18 +- .../internal/message/MessageHelper.java | 15 +- .../jschema/internal/script/GArray.java | 6 +- .../jschema/internal/script/GFunction.java | 10 +- .../jschema/internal/script/GInteger.java | 14 +- .../jschema/internal/script/GParameter.java | 8 +- .../jschema/internal/script/GRange.java | 14 +- .../jschema/internal/script/GReference.java | 5 +- .../jschema/internal/script/RFunction.java | 5 + .../internal/time/DateTimeContext.java | 48 +- .../jschema/internal/time/DateTimeParser.java | 166 ++ .../internal/time/SegmentProcessor.java | 130 +- .../jschema/internal/tree/EFunction.java | 14 + .../jschema/internal/tree/FunctionCache.java | 44 + .../internal/tree/FunctionKey.java | 14 +- .../internal/tree/JsonTreeVisitor.java | 68 +- .../jschema/internal/tree/NativeFunction.java | 117 ++ .../internal/tree/PragmaDescriptor.java | 8 +- .../internal/tree/SchemaTreeVisitor.java | 319 +++ .../{engine => tree}/ScriptFunction.java | 26 +- .../jschema/internal/tree/TreeHelper.java | 38 + .../internal/util/CollectionHelper.java | 14 +- .../internal/util/LexerErrorListener.java | 40 +- .../jschema/internal/util/LogHelper.java | 67 + .../internal/util/MiscellaneousHelper.java | 19 + .../internal/util/ParserErrorListener.java | 55 + .../internal/util/StreamHelper.java | 2 +- .../internal/util/StringHelper.java | 36 +- .../message/ActualDetail.java | 8 +- .../message/ContextDetail.java | 8 +- .../schema => jschema}/message/ErrorCode.java | 135 +- .../message/ErrorDetail.java | 4 +- .../message/ExpectedDetail.java | 8 +- .../message/MessageFormatter.java | 54 +- .../jschema/message/OutlineFormatter.java | 22 + .../com/relogiclabs/jschema/node/JNode.java | 2 +- .../com/relogiclabs/jschema/node/JString.java | 2 +- .../relogiclabs/jschema/node/JsonType.java | 18 +- .../schema => jschema}/time/DateTimeType.java | 10 +- .../schema => jschema}/time/JsonDateTime.java | 16 +- .../time/JsonUtcOffset.java | 6 +- .../schema => jschema}/tree/Context.java | 2 +- .../schema => jschema}/tree/DataTree.java | 4 +- .../tree/ExceptionRegistry.java | 15 +- .../jschema/tree/FunctionRegistry.java | 205 ++ .../schema => jschema}/tree/JsonTree.java | 18 +- .../schema => jschema}/tree/Location.java | 2 +- .../tree/PragmaRegistry.java | 24 +- .../tree/ReceiverRegistry.java | 6 +- .../jschema/tree/RuntimeContext.java | 73 + .../schema => jschema}/tree/SchemaTree.java | 25 +- .../schema => jschema}/tree/TreeType.java | 2 +- .../schema => jschema}/util/Reference.java | 2 +- .../exception/DuplicateIncludeException.java | 9 - .../exception/InvalidIncludeException.java | 9 - .../json/schema/function/CoreFunctions1.java | 166 -- .../json/schema/function/CoreFunctions2.java | 203 -- .../json/schema/function/CoreFunctions3.java | 154 -- .../json/schema/function/CoreFunctions4.java | 162 -- .../json/schema/function/FutureValidator.java | 6 - .../internal/antlr/DateTimeLexer.interp | 110 - .../schema/internal/antlr/DateTimeLexer.java | 245 --- .../schema/internal/antlr/JsonLexer.interp | 66 - .../json/schema/internal/antlr/JsonLexer.java | 210 -- .../schema/internal/antlr/JsonParser.interp | 45 - .../schema/internal/antlr/JsonParser.java | 618 ------ .../internal/antlr/JsonParserBaseVisitor.java | 98 - .../internal/antlr/JsonParserVisitor.java | 91 - .../schema/internal/antlr/SchemaLexer.interp | 142 -- .../schema/internal/antlr/SchemaLexer.java | 364 ---- .../schema/internal/antlr/SchemaLexer.tokens | 56 - .../schema/internal/antlr/SchemaParser.interp | 104 - .../schema/internal/antlr/SchemaParser.java | 1797 ----------------- .../schema/internal/antlr/SchemaParser.tokens | 56 - .../antlr/SchemaParserBaseVisitor.java | 203 -- .../internal/antlr/SchemaParserVisitor.java | 184 -- .../internal/function/DateTimeAgent.java | 51 - .../schema/internal/grammar/SchemaLexer.g4 | 74 - .../schema/internal/grammar/SchemaParser.g4 | 93 - .../schema/internal/time/DateTimeParser.java | 166 -- .../schema/internal/tree/FunctionCache.java | 50 - .../schema/internal/tree/MethodPointer.java | 65 - .../internal/tree/SchemaTreeVisitor.java | 324 --- .../json/schema/internal/tree/TreeHelper.java | 23 - .../schema/internal/util/DebugUtilities.java | 46 - .../internal/util/MiscellaneousHelper.java | 16 - .../internal/util/ParserErrorListener.java | 51 - .../json/schema/tree/FunctionRegistry.java | 229 --- .../json/schema/tree/RuntimeContext.java | 71 - .../json/schema/type/Derivable.java | 5 - .../relogiclabs/json/schema/type/JAlias.java | 40 - .../relogiclabs/json/schema/type/JArray.java | 79 - .../json/schema/type/JBoolean.java | 54 - .../json/schema/type/JDataType.java | 98 - .../relogiclabs/json/schema/type/JDouble.java | 62 - .../relogiclabs/json/schema/type/JFloat.java | 62 - .../json/schema/type/JFunction.java | 81 - .../json/schema/type/JInteger.java | 60 - .../relogiclabs/json/schema/type/JNode.java | 75 - .../relogiclabs/json/schema/type/JObject.java | 114 -- .../relogiclabs/json/schema/type/JPragma.java | 38 - .../json/schema/type/JProperty.java | 69 - .../json/schema/type/JReceiver.java | 68 - .../relogiclabs/json/schema/type/JRoot.java | 74 - .../relogiclabs/json/schema/type/JString.java | 62 - .../json/schema/type/JValidator.java | 166 -- .../json/schema/type/JsonTypable.java | 8 - .../json/schema/type/JsonType.java | 86 - .../json/schema/type/NestedMode.java | 5 - .../json/schema/type/PragmaValue.java | 5 - src/main/java/lombok.config | 4 +- .../test}/external/ExternalFunctions.java | 68 +- .../test}/external/ExternalFunctions1.java | 4 +- .../test}/external/ExternalFunctions2.java | 10 +- .../test}/external/ExternalFunctions3.java | 8 +- .../test/external/ExternalFunctions4.java | 17 + .../test/external/ExternalFunctions5.java | 10 + .../test}/negative/AggregatedTests.java | 202 +- .../test}/negative/ArrayTests.java | 32 +- .../test}/negative/BooleanTests.java | 14 +- .../test}/negative/ComponentTests.java | 12 +- .../test}/negative/DataTypeTests.java | 20 +- .../test}/negative/DateTimeTests.java | 84 +- .../test}/negative/FunctionTests.java | 83 +- .../test}/negative/IntegerTests.java | 22 +- .../test}/negative/NumberTests.java | 24 +- .../test}/negative/ObjectTests.java | 34 +- .../test}/negative/OtherTests.java | 26 +- .../test}/negative/PragmaTests.java | 58 +- .../test}/negative/ReceiverTests.java | 38 +- .../test}/negative/StringTests.java | 42 +- .../test}/positive/AggregatedTests.java | 191 +- .../test}/positive/ArrayTests.java | 6 +- .../test}/positive/BooleanTests.java | 4 +- .../test}/positive/ComponentTests.java | 10 +- .../test}/positive/DataTypeTests.java | 6 +- .../test}/positive/DateTimeTests.java | 4 +- .../test}/positive/DirectiveTests.java | 8 +- .../test}/positive/FunctionTests.java | 14 +- .../test}/positive/IntegerTests.java | 4 +- .../test}/positive/NumberTests.java | 4 +- .../test}/positive/ObjectTests.java | 8 +- .../test}/positive/OptionalTests.java | 4 +- .../test}/positive/OtherTests.java | 8 +- .../test}/positive/PragmaTests.java | 4 +- .../test}/positive/ReceiverTests.java | 14 +- .../test}/positive/StringTests.java | 4 +- .../schema/external/ExternalFunctions4.java | 17 - .../schema/external/ExternalFunctions5.java | 10 - 173 files changed, 3435 insertions(+), 9438 deletions(-) rename src/main/java/com/relogiclabs/{json/schema => jschema}/JsonAssert.java (64%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/JsonSchema.java (52%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/collection/IndexMap.java (86%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/collection/Keyable.java (51%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/collection/IndexHashMap.java (94%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/message/ActualHelper.java (82%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/message/ExpectedHelper.java (79%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/message/MessageHelper.java (78%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/time/DateTimeContext.java (85%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/time/DateTimeParser.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/time/SegmentProcessor.java (72%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/tree/EFunction.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/tree/FunctionCache.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/tree/FunctionKey.java (50%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/tree/JsonTreeVisitor.java (60%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/tree/NativeFunction.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/tree/PragmaDescriptor.java (89%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/tree/SchemaTreeVisitor.java rename src/main/java/com/relogiclabs/jschema/internal/{engine => tree}/ScriptFunction.java (95%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/tree/TreeHelper.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/util/CollectionHelper.java (83%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/util/LexerErrorListener.java (52%) create mode 100644 src/main/java/com/relogiclabs/jschema/internal/util/LogHelper.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/util/MiscellaneousHelper.java create mode 100644 src/main/java/com/relogiclabs/jschema/internal/util/ParserErrorListener.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/util/StreamHelper.java (93%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/internal/util/StringHelper.java (75%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/message/ActualDetail.java (77%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/message/ContextDetail.java (67%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/message/ErrorCode.java (54%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/message/ErrorDetail.java (87%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/message/ExpectedDetail.java (77%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/message/MessageFormatter.java (71%) create mode 100644 src/main/java/com/relogiclabs/jschema/message/OutlineFormatter.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/time/DateTimeType.java (52%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/time/JsonDateTime.java (88%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/time/JsonUtcOffset.java (89%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/tree/Context.java (93%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/tree/DataTree.java (62%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/tree/ExceptionRegistry.java (81%) create mode 100644 src/main/java/com/relogiclabs/jschema/tree/FunctionRegistry.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/tree/JsonTree.java (65%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/tree/Location.java (87%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/tree/PragmaRegistry.java (79%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/tree/ReceiverRegistry.java (86%) create mode 100644 src/main/java/com/relogiclabs/jschema/tree/RuntimeContext.java rename src/main/java/com/relogiclabs/{json/schema => jschema}/tree/SchemaTree.java (51%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/tree/TreeType.java (86%) rename src/main/java/com/relogiclabs/{json/schema => jschema}/util/Reference.java (83%) delete mode 100644 src/main/java/com/relogiclabs/json/schema/exception/DuplicateIncludeException.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/exception/InvalidIncludeException.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/function/CoreFunctions1.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/function/CoreFunctions2.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/function/CoreFunctions3.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/function/CoreFunctions4.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/function/FutureValidator.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/DateTimeLexer.interp delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/DateTimeLexer.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonLexer.interp delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonLexer.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParser.interp delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParser.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParserBaseVisitor.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParserVisitor.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaLexer.interp delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaLexer.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaLexer.tokens delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParser.interp delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParser.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParser.tokens delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParserBaseVisitor.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParserVisitor.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/function/DateTimeAgent.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/grammar/SchemaLexer.g4 delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/grammar/SchemaParser.g4 delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/time/DateTimeParser.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/tree/FunctionCache.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/tree/MethodPointer.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/tree/SchemaTreeVisitor.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/tree/TreeHelper.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/util/DebugUtilities.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/util/MiscellaneousHelper.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/internal/util/ParserErrorListener.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/tree/FunctionRegistry.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/tree/RuntimeContext.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/Derivable.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JAlias.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JArray.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JBoolean.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JDataType.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JDouble.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JFloat.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JFunction.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JInteger.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JNode.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JObject.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JPragma.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JProperty.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JReceiver.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JRoot.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JString.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JValidator.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JsonTypable.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/JsonType.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/NestedMode.java delete mode 100644 src/main/java/com/relogiclabs/json/schema/type/PragmaValue.java rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/external/ExternalFunctions.java (64%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/external/ExternalFunctions1.java (74%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/external/ExternalFunctions2.java (53%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/external/ExternalFunctions3.java (50%) create mode 100644 src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions4.java create mode 100644 src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions5.java rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/AggregatedTests.java (54%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/ArrayTests.java (89%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/BooleanTests.java (88%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/ComponentTests.java (81%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/DataTypeTests.java (91%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/DateTimeTests.java (89%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/FunctionTests.java (60%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/IntegerTests.java (89%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/NumberTests.java (90%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/ObjectTests.java (90%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/OtherTests.java (85%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/PragmaTests.java (89%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/ReceiverTests.java (79%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/negative/StringTests.java (89%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/AggregatedTests.java (63%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/ArrayTests.java (97%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/BooleanTests.java (94%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/ComponentTests.java (95%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/DataTypeTests.java (96%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/DateTimeTests.java (99%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/DirectiveTests.java (88%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/FunctionTests.java (79%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/IntegerTests.java (96%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/NumberTests.java (97%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/ObjectTests.java (97%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/OptionalTests.java (94%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/OtherTests.java (89%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/PragmaTests.java (98%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/ReceiverTests.java (88%) rename src/test/java/com/relogiclabs/{json/schema => jschema/test}/positive/StringTests.java (98%) delete mode 100644 src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions4.java delete mode 100644 src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions5.java diff --git a/src/main/java/com/relogiclabs/json/schema/JsonAssert.java b/src/main/java/com/relogiclabs/jschema/JsonAssert.java similarity index 64% rename from src/main/java/com/relogiclabs/json/schema/JsonAssert.java rename to src/main/java/com/relogiclabs/jschema/JsonAssert.java index 6c6eac6..c237a74 100644 --- a/src/main/java/com/relogiclabs/json/schema/JsonAssert.java +++ b/src/main/java/com/relogiclabs/jschema/JsonAssert.java @@ -1,21 +1,21 @@ -package com.relogiclabs.json.schema; +package com.relogiclabs.jschema; -import com.relogiclabs.json.schema.internal.util.DebugUtilities; -import com.relogiclabs.json.schema.tree.DataTree; -import com.relogiclabs.json.schema.tree.JsonTree; -import com.relogiclabs.json.schema.tree.RuntimeContext; -import com.relogiclabs.json.schema.tree.SchemaTree; -import com.relogiclabs.json.schema.tree.TreeType; +import com.relogiclabs.jschema.internal.util.LogHelper; +import com.relogiclabs.jschema.tree.DataTree; +import com.relogiclabs.jschema.tree.JsonTree; +import com.relogiclabs.jschema.tree.RuntimeContext; +import com.relogiclabs.jschema.tree.SchemaTree; +import com.relogiclabs.jschema.tree.TreeType; import lombok.Getter; -import static com.relogiclabs.json.schema.message.MessageFormatter.JSON_ASSERTION; -import static com.relogiclabs.json.schema.message.MessageFormatter.SCHEMA_ASSERTION; -import static com.relogiclabs.json.schema.tree.TreeType.JSON_TREE; -import static com.relogiclabs.json.schema.tree.TreeType.SCHEMA_TREE; +import static com.relogiclabs.jschema.message.MessageFormatter.JSON_ASSERTION; +import static com.relogiclabs.jschema.message.MessageFormatter.SCHEMA_ASSERTION; +import static com.relogiclabs.jschema.tree.TreeType.JSON_TREE; +import static com.relogiclabs.jschema.tree.TreeType.SCHEMA_TREE; /** * The class provides assertion functionalities to validate JSON documents against - * a Schema or JSON. + * a JSchema or JSON document. */ @Getter public class JsonAssert { @@ -24,8 +24,8 @@ public class JsonAssert { /** * Initializes a new instance of the {@link JsonAssert} class for the - * specified Schema string. - * @param schema A Schema string for validation or conformation + * specified JSchema string. + * @param schema A JSchema string for validation or conformation */ public JsonAssert(String schema) { this(schema, SCHEMA_TREE); @@ -33,10 +33,10 @@ public JsonAssert(String schema) { /** * Initializes a new instance of the {@link JsonAssert} class for the specified - * {@code expected} string, which can be either a Schema or a JSON representation. - * @param expected An expected Schema or JSON string for validation or conformation + * {@code expected} string, which can be either a JSchema or a JSON representation. + * @param expected An expected JSchema or JSON string for validation or conformation * @param type The type of string provided by {@code expected}, indicating whether it represents - * a Schema or JSON. Use {@link TreeType#SCHEMA_TREE} for Schema and {@link TreeType#JSON_TREE} + * a JSchema or JSON. Use {@link TreeType#SCHEMA_TREE} for JSchema and {@link TreeType#JSON_TREE} * for JSON. */ public JsonAssert(String expected, TreeType type) { @@ -50,22 +50,22 @@ public JsonAssert(String expected, TreeType type) { } /** - * Tests whether the input JSON string conforms to the expected Schema or JSON + * Tests whether the input JSON string conforms to the expected JSchema or JSON * specified in the {@link JsonAssert} constructor. * @param json The actual input JSON to conform or validate */ public void isValid(String json) { runtime.clear(); var jsonTree = new JsonTree(runtime, json); - DebugUtilities.print(expectedTree, jsonTree); + LogHelper.debug(expectedTree, jsonTree); if(!expectedTree.match(jsonTree)) throw new IllegalStateException("Invalid runtime state"); } /** - * Tests whether the specified JSON string conforms to the given Schema string - * and throws an exception if the JSON string does not conform to the Schema. - * @param schema The expected Schema to conform or validate + * Tests whether the specified JSON string conforms to the given JSchema string + * and throws an exception if the JSON string does not conform to the JSchema. + * @param schema The expected JSchema to conform or validate * @param json The actual JSON to conform or validate */ public static void isValid(String schema, String json) { diff --git a/src/main/java/com/relogiclabs/json/schema/JsonSchema.java b/src/main/java/com/relogiclabs/jschema/JsonSchema.java similarity index 52% rename from src/main/java/com/relogiclabs/json/schema/JsonSchema.java rename to src/main/java/com/relogiclabs/jschema/JsonSchema.java index 2162e89..1b24443 100644 --- a/src/main/java/com/relogiclabs/json/schema/JsonSchema.java +++ b/src/main/java/com/relogiclabs/jschema/JsonSchema.java @@ -1,16 +1,16 @@ -package com.relogiclabs.json.schema; +package com.relogiclabs.jschema; -import com.relogiclabs.json.schema.internal.util.DebugUtilities; -import com.relogiclabs.json.schema.tree.ExceptionRegistry; -import com.relogiclabs.json.schema.tree.JsonTree; -import com.relogiclabs.json.schema.tree.RuntimeContext; -import com.relogiclabs.json.schema.tree.SchemaTree; +import com.relogiclabs.jschema.internal.util.LogHelper; +import com.relogiclabs.jschema.tree.ExceptionRegistry; +import com.relogiclabs.jschema.tree.JsonTree; +import com.relogiclabs.jschema.tree.RuntimeContext; +import com.relogiclabs.jschema.tree.SchemaTree; import lombok.Getter; -import static com.relogiclabs.json.schema.message.MessageFormatter.SCHEMA_VALIDATION; +import static com.relogiclabs.jschema.message.MessageFormatter.SCHEMA_VALIDATION; /** - * {@code JsonSchema} provides Schema validation functionalities for JSON document. + * {@code JsonSchema} provides JSchema validation functionalities for JSON document. */ @Getter public class JsonSchema { @@ -20,8 +20,8 @@ public class JsonSchema { /** * Initializes a new instance of the {@link JsonSchema} class for the - * specified Schema string. - * @param schema A Schema string for validation + * specified JSchema string. + * @param schema A JSchema string for validation */ public JsonSchema(String schema) { runtime = new RuntimeContext(SCHEMA_VALIDATION, false); @@ -30,32 +30,35 @@ public JsonSchema(String schema) { } /** - * Indicates whether the input JSON string conforms to the Schema specified + * Indicates whether the input JSON string conforms to the JSchema specified * in the {@link JsonSchema} constructor. - * @param json The JSON to validate with Schema - * @return Returns {@code true} if the JSON string conforms to the Schema and {@code false} otherwise. + * @param json The JSON to validate with JSchema + * @return Returns {@code true} if the JSON string conforms to the JSchema and {@code false} otherwise. */ public boolean isValid(String json) { runtime.clear(); var jsonTree = new JsonTree(runtime, json); - DebugUtilities.print(schemaTree, jsonTree); + LogHelper.debug(schemaTree, jsonTree); return schemaTree.match(jsonTree); } /** - * Writes error messages that occur during Schema validation process, to the + * Writes error messages that occur during JSchema validation process, to the * standard error output stream. */ public void writeError() { - for(var exception : exceptions) - System.err.println(exception.getMessage()); + if(exceptions.getCount() == 0) { + System.out.println("No error has occurred"); + return; + } + for(var exception : exceptions) System.err.println(exception.getMessage()); } /** - * Indicates whether the input JSON string conforms to the given Schema string. - * @param schema The Schema string to conform or validate + * Indicates whether the input JSON string conforms to the given JSchema string. + * @param schema The JSchema string to conform or validate * @param json The JSON string to conform or validate - * @return Returns {@code true} if the JSON string conforms to the Schema and {@code false} otherwise. + * @return Returns {@code true} if the JSON string conforms to the JSchema and {@code false} otherwise. */ public static boolean isValid(String schema, String json) { var jsonSchema = new JsonSchema(schema); diff --git a/src/main/java/com/relogiclabs/json/schema/collection/IndexMap.java b/src/main/java/com/relogiclabs/jschema/collection/IndexMap.java similarity index 86% rename from src/main/java/com/relogiclabs/json/schema/collection/IndexMap.java rename to src/main/java/com/relogiclabs/jschema/collection/IndexMap.java index 0fb032e..34f471a 100644 --- a/src/main/java/com/relogiclabs/json/schema/collection/IndexMap.java +++ b/src/main/java/com/relogiclabs/jschema/collection/IndexMap.java @@ -1,4 +1,4 @@ -package com.relogiclabs.json.schema.collection; +package com.relogiclabs.jschema.collection; import java.util.Collection; import java.util.Set; diff --git a/src/main/java/com/relogiclabs/json/schema/collection/Keyable.java b/src/main/java/com/relogiclabs/jschema/collection/Keyable.java similarity index 51% rename from src/main/java/com/relogiclabs/json/schema/collection/Keyable.java rename to src/main/java/com/relogiclabs/jschema/collection/Keyable.java index bc00c04..943866b 100644 --- a/src/main/java/com/relogiclabs/json/schema/collection/Keyable.java +++ b/src/main/java/com/relogiclabs/jschema/collection/Keyable.java @@ -1,4 +1,4 @@ -package com.relogiclabs.json.schema.collection; +package com.relogiclabs.jschema.collection; public interface Keyable { TK getKey(); diff --git a/src/main/java/com/relogiclabs/jschema/function/CoreFunctions1.java b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions1.java index 51609e6..c40968e 100644 --- a/src/main/java/com/relogiclabs/jschema/function/CoreFunctions1.java +++ b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions1.java @@ -36,7 +36,7 @@ public boolean length(JString target, JInteger length) { var rLength = target.length(); if(rLength != length.getValue()) return fail(new JsonSchemaException( new ErrorDetail(SLEN01, "Invalid length of string ", target), - new ExpectedDetail(function, "a string of length ", length), + new ExpectedDetail(caller, "a string of length ", length), new ActualDetail(target, "found ", rLength, " which does not match"))); return true; } @@ -45,7 +45,7 @@ public boolean length(JArray target, JInteger length) { var rLength = target.getElements().size(); if(rLength != length.getValue()) return fail(new JsonSchemaException( new ErrorDetail(ALEN01, "Invalid length of array ", target.getOutline()), - new ExpectedDetail(function, "an array of length ", length), + new ExpectedDetail(caller, "an array of length ", length), new ActualDetail(target, "found ", rLength, " which does not match"))); return true; } @@ -54,7 +54,7 @@ public boolean length(JObject target, JInteger length) { var rLength = target.getProperties().size(); if(rLength != length.getValue()) return fail(new JsonSchemaException( new ErrorDetail(OLEN01, "Invalid size or length of object ", target.getOutline()), - new ExpectedDetail(function, "an object of length ", length), + new ExpectedDetail(caller, "an object of length ", length), new ActualDetail(target, "found ", rLength, " which does not match"))); return true; } @@ -64,12 +64,12 @@ public boolean length(JString target, JInteger minimum, JInteger maximum) { if(length < minimum.getValue()) return fail(new JsonSchemaException(new ErrorDetail(SLEN02, "String ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), + new ExpectedDetail(caller, "length in range [", minimum, ", ", maximum, "]"), new ActualDetail(target, "found ", length, " that is less than ", minimum))); if(length > maximum.getValue()) return fail(new JsonSchemaException(new ErrorDetail(SLEN03, "String ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), + new ExpectedDetail(caller, "length in range [", minimum, ", ", maximum, "]"), new ActualDetail(target, "found ", length, " that is greater than ", maximum))); return true; } @@ -79,7 +79,7 @@ public boolean length(JString target, JInteger minimum, JUndefined undefined) { if(length < minimum.getValue()) return fail(new JsonSchemaException(new ErrorDetail(SLEN04, "String ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", undefined, "]"), + new ExpectedDetail(caller, "length in range [", minimum, ", ", undefined, "]"), new ActualDetail(target, "found ", length, " that is less than ", minimum))); return true; } @@ -89,7 +89,7 @@ public boolean length(JString target, JUndefined undefined, JInteger maximum) { if(length > maximum.getValue()) return fail(new JsonSchemaException(new ErrorDetail(SLEN05, "String ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", undefined, ", ", maximum, "]"), + new ExpectedDetail(caller, "length in range [", undefined, ", ", maximum, "]"), new ActualDetail(target, "found ", length, " that is greater than ", maximum))); return true; } @@ -99,12 +99,12 @@ public boolean length(JArray target, JInteger minimum, JInteger maximum) { if(length < minimum.getValue()) return fail(new JsonSchemaException(new ErrorDetail(ALEN02, "Array ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), + new ExpectedDetail(caller, "length in range [", minimum, ", ", maximum, "]"), new ActualDetail(target, "found ", length, " that is less than ", minimum))); if(length > maximum.getValue()) return fail(new JsonSchemaException(new ErrorDetail(ALEN03, "Array ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), + new ExpectedDetail(caller, "length in range [", minimum, ", ", maximum, "]"), new ActualDetail(target, "found ", length, " that is greater than ", maximum))); return true; } @@ -114,7 +114,7 @@ public boolean length(JArray target, JInteger minimum, JUndefined undefined) { if(length < minimum.getValue()) return fail(new JsonSchemaException(new ErrorDetail(ALEN04, "Array ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", undefined, "]"), + new ExpectedDetail(caller, "length in range [", minimum, ", ", undefined, "]"), new ActualDetail(target, "found ", length, " that is less than ", minimum))); return true; } @@ -124,7 +124,7 @@ public boolean length(JArray target, JUndefined undefined, JInteger maximum) { if(length > maximum.getValue()) return fail(new JsonSchemaException(new ErrorDetail(ALEN05, "Array ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", undefined, ", ", maximum, "]"), + new ExpectedDetail(caller, "length in range [", undefined, ", ", maximum, "]"), new ActualDetail(target, "found ", length, " that is greater than ", maximum))); return true; } @@ -134,12 +134,12 @@ public boolean length(JObject target, JInteger minimum, JInteger maximum) { if(length < minimum.getValue()) return fail(new JsonSchemaException(new ErrorDetail(OLEN02, "Object ", target.getOutline(), " size or length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), + new ExpectedDetail(caller, "length in range [", minimum, ", ", maximum, "]"), new ActualDetail(target, "found ", length, " that is less than ", minimum))); if(length > maximum.getValue()) return fail(new JsonSchemaException(new ErrorDetail(OLEN03, "Object ", target.getOutline(), " size or length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), + new ExpectedDetail(caller, "length in range [", minimum, ", ", maximum, "]"), new ActualDetail(target, "found ", length, " that is greater than ", maximum))); return true; } @@ -149,7 +149,7 @@ public boolean length(JObject target, JInteger minimum, JUndefined undefined) { if(length < minimum.getValue()) return fail(new JsonSchemaException(new ErrorDetail(OLEN04, "Object ", target.getOutline(), " size or length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", undefined, "]"), + new ExpectedDetail(caller, "length in range [", minimum, ", ", undefined, "]"), new ActualDetail(target, "found ", length, " that is less than ", minimum))); return true; } @@ -159,7 +159,7 @@ public boolean length(JObject target, JUndefined undefined, JInteger maximum) { if(length > maximum.getValue()) return fail(new JsonSchemaException(new ErrorDetail(OLEN05, "Object ", target.getOutline(), " size or length is outside of range"), - new ExpectedDetail(function, "length in range [", undefined, ", ", maximum, "]"), + new ExpectedDetail(caller, "length in range [", undefined, ", ", maximum, "]"), new ActualDetail(target, "found ", length, " that is greater than ", maximum))); return true; } diff --git a/src/main/java/com/relogiclabs/jschema/function/CoreFunctions2.java b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions2.java index f6cd189..21289fc 100644 --- a/src/main/java/com/relogiclabs/jschema/function/CoreFunctions2.java +++ b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions2.java @@ -13,7 +13,6 @@ import com.relogiclabs.jschema.tree.RuntimeContext; import java.util.Arrays; -import java.util.function.Supplier; import static com.relogiclabs.jschema.internal.util.StringHelper.joinWith; import static com.relogiclabs.jschema.message.ErrorCode.ENUM01; @@ -46,7 +45,7 @@ public boolean _enum(JString target, JString... items) { var list = Arrays.asList(items); if(!list.contains(target)) return fail(new JsonSchemaException( new ErrorDetail(ENUM01, "String is not in enum list"), - new ExpectedDetail(function, "string in list ", joinWith(list, ", ", "[", "]")), + new ExpectedDetail(caller, "string in list ", joinWith(list, ", ", "[", "]")), new ActualDetail(target, "string ", target, " is not found in list"))); return true; } @@ -55,7 +54,7 @@ public boolean _enum(JNumber target, JNumber... items) { var list = Arrays.asList(items); if(!list.contains(target)) return fail(new JsonSchemaException( new ErrorDetail(ENUM02, "Number is not in enum list"), - new ExpectedDetail(function, "number in list ", joinWith(list, ", ", "[", "]")), + new ExpectedDetail(caller, "number in list ", joinWith(list, ", ", "[", "]")), new ActualDetail(target, "number ", target, " is not found in list"))); return true; } @@ -64,25 +63,22 @@ public boolean minimum(JNumber target, JNumber minimum) { if(target.compare(minimum) < 0) return fail(new JsonSchemaException( new ErrorDetail(MINI01, "Number is less than provided minimum"), - new ExpectedDetail(function, "a number greater than or equal to ", minimum), + new ExpectedDetail(caller, "a number greater than or equal to ", minimum), new ActualDetail(target, "number ", target, " is less than ", minimum))); return true; } public boolean minimum(JNumber target, JNumber minimum, JBoolean exclusive) { - Supplier relationTo = () -> exclusive.getValue() - ? "greater than" - : "greater than or equal to"; - + var relationTo = exclusive.getValue() ? "greater than " : "greater than or equal to "; if(target.compare(minimum) < 0) return fail(new JsonSchemaException( new ErrorDetail(MINI02, "Number is less than provided minimum"), - new ExpectedDetail(function, "a number ", relationTo.get(), " ", minimum), + new ExpectedDetail(caller, "a number ", relationTo, minimum), new ActualDetail(target, "number ", target, " is less than ", minimum))); if(exclusive.getValue() && target.compare(minimum) == 0) return fail(new JsonSchemaException( new ErrorDetail(MINI03, "Number is equal to provided minimum"), - new ExpectedDetail(function, "a number ", relationTo.get(), " ", minimum), + new ExpectedDetail(caller, "a number ", relationTo, minimum), new ActualDetail(target, "number ", target, " is equal to ", minimum))); return true; } @@ -91,25 +87,22 @@ public boolean maximum(JNumber target, JNumber maximum) { if(target.compare(maximum) > 0) return fail(new JsonSchemaException( new ErrorDetail(MAXI01, "Number is greater than provided maximum"), - new ExpectedDetail(function, "a number less than or equal ", maximum), + new ExpectedDetail(caller, "a number less than or equal ", maximum), new ActualDetail(target, "number ", target, " is greater than ", maximum))); return true; } public boolean maximum(JNumber target, JNumber maximum, JBoolean exclusive) { - Supplier relationTo = () -> exclusive.getValue() - ? "less than" - : "less than or equal to"; - + var relationTo = exclusive.getValue() ? "less than " : "less than or equal to "; if(target.compare(maximum) > 0) return fail(new JsonSchemaException( new ErrorDetail(MAXI02, "Number is greater than provided maximum"), - new ExpectedDetail(function, "a number ", relationTo.get(), " ", maximum), + new ExpectedDetail(caller, "a number ", relationTo, maximum), new ActualDetail(target, "number ", target, " is greater than ", maximum))); if(exclusive.getValue() && target.compare(maximum) == 0) return fail(new JsonSchemaException( new ErrorDetail(MAXI03, "Number is equal to provided maximum"), - new ExpectedDetail(function, "a number ", relationTo.get(), " ", maximum), + new ExpectedDetail(caller, "a number ", relationTo, maximum), new ActualDetail(target, "number ", target, " is equal to ", maximum))); return true; } @@ -117,7 +110,7 @@ public boolean maximum(JNumber target, JNumber maximum, JBoolean exclusive) { public boolean positive(JNumber target) { if(target.compare(0) <= 0) return fail(new JsonSchemaException( new ErrorDetail(POSI01, "Number is not positive"), - new ExpectedDetail(function, "a positive number"), + new ExpectedDetail(caller, "a positive number"), new ActualDetail(target, "number ", target, " is less than or equal to zero"))); return true; } @@ -125,7 +118,7 @@ public boolean positive(JNumber target) { public boolean negative(JNumber target) { if(target.compare(0) >= 0) return fail(new JsonSchemaException( new ErrorDetail(NEGI01, "Number is not negative"), - new ExpectedDetail(function, "a negative number"), + new ExpectedDetail(caller, "a negative number"), new ActualDetail(target, "number ", target, " is greater than or equal to zero"))); return true; } @@ -133,7 +126,7 @@ public boolean negative(JNumber target) { public boolean positive(JNumber target, JNumber reference) { if(target.compare(reference) < 0) return fail(new JsonSchemaException( new ErrorDetail(POSI02, "Number is not positive from reference"), - new ExpectedDetail(function, "a positive number from ", reference), + new ExpectedDetail(caller, "a positive number from ", reference), new ActualDetail(target, "number ", target, " is less than reference"))); return true; } @@ -141,7 +134,7 @@ public boolean positive(JNumber target, JNumber reference) { public boolean negative(JNumber target, JNumber reference) { if(target.compare(reference) > 0) return fail(new JsonSchemaException( new ErrorDetail(NEGI02, "Number is not negative from reference"), - new ExpectedDetail(function, "a negative number from ", reference), + new ExpectedDetail(caller, "a negative number from ", reference), new ActualDetail(target, "number ", target, " is greater than reference"))); return true; } @@ -149,11 +142,11 @@ public boolean negative(JNumber target, JNumber reference) { public boolean range(JNumber target, JNumber minimum, JNumber maximum) { if(target.compare(minimum) < 0) return fail(new JsonSchemaException( new ErrorDetail(RANG01, "Number is outside of range"), - new ExpectedDetail(function, "number in range [", minimum, ", ", maximum, "]"), + new ExpectedDetail(caller, "number in range [", minimum, ", ", maximum, "]"), new ActualDetail(target, "number ", target, " is less than ", minimum))); if(target.compare(maximum) > 0) return fail(new JsonSchemaException( new ErrorDetail(RANG02, "Number is outside of range"), - new ExpectedDetail(function, "number in range [", minimum, ", ", maximum, "]"), + new ExpectedDetail(caller, "number in range [", minimum, ", ", maximum, "]"), new ActualDetail(target, "number ", target, " is greater than ", maximum))); return true; } @@ -161,7 +154,7 @@ public boolean range(JNumber target, JNumber minimum, JNumber maximum) { public boolean range(JNumber target, JNumber minimum, JUndefined undefined) { if(target.compare(minimum) < 0) return fail(new JsonSchemaException( new ErrorDetail(RANG03, "Number is outside of range"), - new ExpectedDetail(function, "number in range [", minimum, ", ", undefined, "]"), + new ExpectedDetail(caller, "number in range [", minimum, ", ", undefined, "]"), new ActualDetail(target, "number ", target, " is less than ", minimum))); return true; } @@ -169,7 +162,7 @@ public boolean range(JNumber target, JNumber minimum, JUndefined undefined) { public boolean range(JNumber target, JUndefined undefined, JNumber maximum) { if(target.compare(maximum) > 0) return fail(new JsonSchemaException( new ErrorDetail(RANG04, "Number is outside of range"), - new ExpectedDetail(function, "number in range [", undefined, ", ", maximum, "]"), + new ExpectedDetail(caller, "number in range [", undefined, ", ", maximum, "]"), new ActualDetail(target, "number ", target, " is greater than ", maximum))); return true; } @@ -178,7 +171,7 @@ public boolean nonempty(JString target) { var length = target.length(); if(length <= 0) return fail(new JsonSchemaException( new ErrorDetail(NEMT01, "String is empty"), - new ExpectedDetail(function, "Non empty string"), + new ExpectedDetail(caller, "Non empty string"), new ActualDetail(target, "found empty string"))); return true; } @@ -187,7 +180,7 @@ public boolean nonempty(JArray target) { var length = target.getElements().size(); if(length <= 0) return fail(new JsonSchemaException( new ErrorDetail(NEMT02, "Array is empty"), - new ExpectedDetail(function, "Non empty array"), + new ExpectedDetail(caller, "Non empty array"), new ActualDetail(target, "found empty array"))); return true; } @@ -196,7 +189,7 @@ public boolean nonempty(JObject target) { var length = target.getProperties().size(); if(length <= 0) return fail(new JsonSchemaException( new ErrorDetail(NEMT03, "Object is empty"), - new ExpectedDetail(function, "Non empty object"), + new ExpectedDetail(caller, "Non empty object"), new ActualDetail(target, "found empty object"))); return true; } diff --git a/src/main/java/com/relogiclabs/jschema/function/CoreFunctions3.java b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions3.java index 49fc64c..e9d3925 100644 --- a/src/main/java/com/relogiclabs/jschema/function/CoreFunctions3.java +++ b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions3.java @@ -51,7 +51,7 @@ public boolean elements(JArray target, JNode... items) { private boolean failOnElement(JArray target, JNode node) { return fail(new JsonSchemaException( new ErrorDetail(ELEM01, "Value is not an element of array"), - new ExpectedDetail(function, "array with value ", node), + new ExpectedDetail(caller, "array with value ", node), new ActualDetail(target, "not found in ", target.getOutline()))); } @@ -63,7 +63,7 @@ public boolean keys(JObject target, JString... items) { private boolean failOnKey(JObject target, String string) { return fail(new JsonSchemaException( new ErrorDetail(KEYS01, "Object does not contain the key"), - new ExpectedDetail(function, "object with key ", quote(string)), + new ExpectedDetail(caller, "object with key ", quote(string)), new ActualDetail(target, "does not contain in ", target.getOutline()))); } @@ -75,7 +75,7 @@ public boolean values(JObject target, JNode... items) { private boolean failOnValue(JObject target, JNode node) { return fail(new JsonSchemaException( new ErrorDetail(VALU01, "Object does not contain the value"), - new ExpectedDetail(function, "object with value ", node), + new ExpectedDetail(caller, "object with value ", node), new ActualDetail(target, "does not contain in ", target.getOutline()))); } @@ -83,7 +83,7 @@ public boolean regex(JString target, JString pattern) { if(!Pattern.matches(pattern.getValue(), target.getValue())) return fail(new JsonSchemaException( new ErrorDetail(REGX01, "Regex pattern does not match"), - new ExpectedDetail(function, "string of pattern ", pattern.getOutline()), + new ExpectedDetail(caller, "string of pattern ", pattern.getOutline()), new ActualDetail(target, "found ", target.getOutline(), " that mismatches with pattern"))); return true; @@ -94,7 +94,7 @@ public boolean email(JString target) { if(!EMAIL_REGEX.matcher(target.getValue()).matches()) return fail(new JsonSchemaException( new ErrorDetail(EMAL01, "Invalid email address"), - new ExpectedDetail(function, "a valid email address"), + new ExpectedDetail(caller, "a valid email address"), new ActualDetail(target, "found ", target, " that is invalid"))); return true; } @@ -111,12 +111,12 @@ public boolean url(JString target) { } catch (Exception e) { return fail(new JsonSchemaException( new ErrorDetail(URLA01, "Invalid url address"), - new ExpectedDetail(function, "a valid url address"), + new ExpectedDetail(caller, "a valid url address"), new ActualDetail(target, "found ", target, " that is invalid"))); } if(!result) return fail(new JsonSchemaException( new ErrorDetail(URLA02, "Invalid url address scheme"), - new ExpectedDetail(function, "HTTP or HTTPS scheme"), + new ExpectedDetail(caller, "HTTP or HTTPS scheme"), new ActualDetail(target, "found ", quote(uri.getScheme()), " from ", target, " that has invalid scheme"))); return true; @@ -130,13 +130,13 @@ public boolean url(JString target, JString scheme) { } catch (Exception e) { return fail(new JsonSchemaException( new ErrorDetail(URLA03, "Invalid url address"), - new ExpectedDetail(function, "a valid url address"), + new ExpectedDetail(caller, "a valid url address"), new ActualDetail(target, "found ", target, " that is invalid"))); } result = scheme.getValue().equals(uri.getScheme()); if(!result) return fail(new JsonSchemaException( new ErrorDetail(URLA04, "Mismatch url address scheme"), - new ExpectedDetail(function, "scheme ", scheme, " for url address"), + new ExpectedDetail(caller, "scheme ", scheme, " for url address"), new ActualDetail(target, "found ", quote(uri.getScheme()), " from ", target, " that does not matched"))); return true; @@ -147,7 +147,7 @@ public boolean phone(JString target) { if(!PHONE_REGEX.matcher(target.getValue()).matches()) return fail(new JsonSchemaException( new ErrorDetail(PHON01, "Invalid phone number format"), - new ExpectedDetail(function, "a valid phone number"), + new ExpectedDetail(caller, "a valid phone number"), new ActualDetail(target, "found ", target, " that is invalid"))); return true; } diff --git a/src/main/java/com/relogiclabs/jschema/function/CoreFunctions4.java b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions4.java index ebc4935..a5bc3ca 100644 --- a/src/main/java/com/relogiclabs/jschema/function/CoreFunctions4.java +++ b/src/main/java/com/relogiclabs/jschema/function/CoreFunctions4.java @@ -44,7 +44,7 @@ public boolean time(JString target, JString pattern) { } private boolean dateTime(JString target, JString pattern, DateTimeType type) { - return new DateTimeAgent(pattern.getValue(), type).parse(function, target) != null; + return new DateTimeAgent(pattern.getValue(), type).parse(caller, target) != null; } public boolean before(JDateTime target, JString reference) { @@ -154,7 +154,7 @@ public boolean end(JDateTime target, JString reference) { private JDateTime getDateTime(DateTimeParser parser, JString dateTime) { if(dateTime.getDerived() instanceof JDateTime result && result.getDateTime().getType() == parser.getType()) return result; - var jDateTime = new DateTimeAgent(parser).parse(function, dateTime); + var jDateTime = new DateTimeAgent(parser).parse(caller, dateTime); if(jDateTime == null) return null; dateTime.setDerived(jDateTime.createNode(dateTime)); return (JDateTime) dateTime.getDerived(); diff --git a/src/main/java/com/relogiclabs/jschema/function/FunctionProvider.java b/src/main/java/com/relogiclabs/jschema/function/FunctionProvider.java index fdfdf7b..b51c86d 100644 --- a/src/main/java/com/relogiclabs/jschema/function/FunctionProvider.java +++ b/src/main/java/com/relogiclabs/jschema/function/FunctionProvider.java @@ -8,7 +8,7 @@ @Getter public abstract class FunctionProvider { protected final RuntimeContext runtime; - @Setter protected JFunction function; + @Setter protected JFunction caller; public FunctionProvider(RuntimeContext runtime) { this.runtime = runtime; diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.interp b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.interp index 5e2ba9e..12a0252 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.interp +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.interp @@ -329,4 +329,4 @@ DEFAULT_MODE DIRECTIVE_SCRIPT1 atn: -[4, 0, 100, 785, 6, -1, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, 2, 68, 7, 68, 2, 69, 7, 69, 2, 70, 7, 70, 2, 71, 7, 71, 2, 72, 7, 72, 2, 73, 7, 73, 2, 74, 7, 74, 2, 75, 7, 75, 2, 76, 7, 76, 2, 77, 7, 77, 2, 78, 7, 78, 2, 79, 7, 79, 2, 80, 7, 80, 2, 81, 7, 81, 2, 82, 7, 82, 2, 83, 7, 83, 2, 84, 7, 84, 2, 85, 7, 85, 2, 86, 7, 86, 2, 87, 7, 87, 2, 88, 7, 88, 2, 89, 7, 89, 2, 90, 7, 90, 2, 91, 7, 91, 2, 92, 7, 92, 2, 93, 7, 93, 2, 94, 7, 94, 2, 95, 7, 95, 2, 96, 7, 96, 2, 97, 7, 97, 2, 98, 7, 98, 2, 99, 7, 99, 2, 100, 7, 100, 2, 101, 7, 101, 2, 102, 7, 102, 2, 103, 7, 103, 2, 104, 7, 104, 2, 105, 7, 105, 2, 106, 7, 106, 2, 107, 7, 107, 2, 108, 7, 108, 2, 109, 7, 109, 2, 110, 7, 110, 2, 111, 7, 111, 2, 112, 7, 112, 2, 113, 7, 113, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 5, 21, 330, 8, 21, 10, 21, 12, 21, 333, 9, 21, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 4, 23, 340, 8, 23, 11, 23, 12, 23, 341, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 5, 26, 352, 8, 26, 10, 26, 12, 26, 355, 9, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 5, 29, 364, 8, 29, 10, 29, 12, 29, 367, 9, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 3, 30, 374, 8, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 3, 34, 387, 8, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 3, 36, 396, 8, 36, 1, 36, 1, 36, 1, 37, 1, 37, 4, 37, 402, 8, 37, 11, 37, 12, 37, 403, 1, 38, 1, 38, 1, 38, 5, 38, 409, 8, 38, 10, 38, 12, 38, 412, 9, 38, 3, 38, 414, 8, 38, 1, 39, 1, 39, 3, 39, 418, 8, 39, 1, 39, 4, 39, 421, 8, 39, 11, 39, 12, 39, 422, 1, 40, 1, 40, 1, 41, 4, 41, 428, 8, 41, 11, 41, 12, 41, 429, 1, 41, 1, 41, 1, 42, 1, 42, 1, 42, 1, 42, 5, 42, 438, 8, 42, 10, 42, 12, 42, 441, 9, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 43, 5, 43, 452, 8, 43, 10, 43, 12, 43, 455, 9, 43, 1, 43, 1, 43, 1, 44, 1, 44, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 1, 47, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 50, 1, 50, 1, 50, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 57, 1, 57, 1, 57, 1, 57, 1, 57, 1, 57, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 60, 1, 60, 1, 60, 1, 60, 1, 60, 1, 60, 1, 60, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 66, 1, 66, 1, 66, 1, 66, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 68, 1, 68, 1, 68, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 70, 1, 70, 1, 70, 1, 70, 1, 70, 1, 70, 1, 70, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 76, 1, 76, 1, 77, 1, 77, 3, 77, 665, 8, 77, 1, 77, 3, 77, 668, 8, 77, 1, 78, 1, 78, 1, 79, 1, 79, 1, 80, 1, 80, 1, 81, 1, 81, 1, 82, 1, 82, 1, 83, 1, 83, 1, 84, 1, 84, 1, 85, 1, 85, 1, 86, 1, 86, 1, 87, 1, 87, 1, 88, 1, 88, 1, 89, 1, 89, 1, 90, 1, 90, 1, 90, 1, 91, 1, 91, 1, 91, 1, 91, 1, 92, 1, 92, 1, 93, 1, 93, 1, 93, 1, 94, 1, 94, 1, 94, 1, 95, 1, 95, 1, 96, 1, 96, 1, 97, 1, 97, 1, 98, 1, 98, 1, 99, 1, 99, 1, 100, 1, 100, 1, 101, 1, 101, 1, 101, 1, 102, 1, 102, 1, 102, 1, 103, 1, 103, 1, 103, 1, 104, 1, 104, 1, 104, 1, 105, 1, 105, 1, 106, 1, 106, 1, 106, 1, 107, 1, 107, 1, 107, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 111, 1, 111, 1, 111, 1, 111, 1, 112, 1, 112, 1, 112, 1, 112, 1, 113, 1, 113, 1, 113, 1, 113, 1, 439, 0, 114, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18, 9, 20, 10, 22, 11, 24, 12, 26, 13, 28, 14, 30, 15, 32, 16, 34, 17, 36, 18, 38, 19, 40, 20, 42, 21, 44, 22, 46, 23, 48, 24, 50, 25, 52, 26, 54, 0, 56, 0, 58, 0, 60, 27, 62, 0, 64, 0, 66, 0, 68, 0, 70, 28, 72, 29, 74, 30, 76, 0, 78, 0, 80, 0, 82, 0, 84, 31, 86, 32, 88, 33, 90, 34, 92, 35, 94, 36, 96, 37, 98, 38, 100, 39, 102, 40, 104, 41, 106, 42, 108, 43, 110, 44, 112, 45, 114, 46, 116, 47, 118, 48, 120, 49, 122, 50, 124, 51, 126, 52, 128, 53, 130, 54, 132, 55, 134, 56, 136, 57, 138, 58, 140, 59, 142, 60, 144, 61, 146, 62, 148, 63, 150, 64, 152, 65, 154, 66, 156, 67, 158, 68, 160, 69, 162, 70, 164, 71, 166, 72, 168, 73, 170, 74, 172, 75, 174, 76, 176, 77, 178, 78, 180, 79, 182, 80, 184, 81, 186, 82, 188, 83, 190, 84, 192, 85, 194, 86, 196, 87, 198, 88, 200, 89, 202, 90, 204, 91, 206, 92, 208, 93, 210, 94, 212, 95, 214, 96, 216, 97, 218, 0, 220, 0, 222, 0, 224, 98, 226, 99, 228, 100, 2, 0, 1, 11, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 8, 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 0, 31, 34, 34, 92, 92, 1, 0, 49, 57, 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 1, 0, 48, 57, 3, 0, 9, 10, 13, 13, 32, 32, 2, 0, 10, 10, 13, 13, 790, 0, 2, 1, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 6, 1, 0, 0, 0, 0, 8, 1, 0, 0, 0, 0, 10, 1, 0, 0, 0, 0, 12, 1, 0, 0, 0, 0, 14, 1, 0, 0, 0, 0, 16, 1, 0, 0, 0, 0, 18, 1, 0, 0, 0, 0, 20, 1, 0, 0, 0, 0, 22, 1, 0, 0, 0, 0, 24, 1, 0, 0, 0, 0, 26, 1, 0, 0, 0, 0, 28, 1, 0, 0, 0, 0, 30, 1, 0, 0, 0, 0, 32, 1, 0, 0, 0, 0, 34, 1, 0, 0, 0, 0, 36, 1, 0, 0, 0, 0, 38, 1, 0, 0, 0, 0, 40, 1, 0, 0, 0, 0, 42, 1, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 46, 1, 0, 0, 0, 0, 48, 1, 0, 0, 0, 0, 50, 1, 0, 0, 0, 0, 52, 1, 0, 0, 0, 0, 60, 1, 0, 0, 0, 0, 70, 1, 0, 0, 0, 0, 72, 1, 0, 0, 0, 0, 74, 1, 0, 0, 0, 0, 84, 1, 0, 0, 0, 0, 86, 1, 0, 0, 0, 0, 88, 1, 0, 0, 0, 1, 90, 1, 0, 0, 0, 1, 92, 1, 0, 0, 0, 1, 94, 1, 0, 0, 0, 1, 96, 1, 0, 0, 0, 1, 98, 1, 0, 0, 0, 1, 100, 1, 0, 0, 0, 1, 102, 1, 0, 0, 0, 1, 104, 1, 0, 0, 0, 1, 106, 1, 0, 0, 0, 1, 108, 1, 0, 0, 0, 1, 110, 1, 0, 0, 0, 1, 112, 1, 0, 0, 0, 1, 114, 1, 0, 0, 0, 1, 116, 1, 0, 0, 0, 1, 118, 1, 0, 0, 0, 1, 120, 1, 0, 0, 0, 1, 122, 1, 0, 0, 0, 1, 124, 1, 0, 0, 0, 1, 126, 1, 0, 0, 0, 1, 128, 1, 0, 0, 0, 1, 130, 1, 0, 0, 0, 1, 132, 1, 0, 0, 0, 1, 134, 1, 0, 0, 0, 1, 136, 1, 0, 0, 0, 1, 138, 1, 0, 0, 0, 1, 140, 1, 0, 0, 0, 1, 142, 1, 0, 0, 0, 1, 144, 1, 0, 0, 0, 1, 146, 1, 0, 0, 0, 1, 148, 1, 0, 0, 0, 1, 150, 1, 0, 0, 0, 1, 152, 1, 0, 0, 0, 1, 154, 1, 0, 0, 0, 1, 156, 1, 0, 0, 0, 1, 158, 1, 0, 0, 0, 1, 160, 1, 0, 0, 0, 1, 162, 1, 0, 0, 0, 1, 164, 1, 0, 0, 0, 1, 166, 1, 0, 0, 0, 1, 168, 1, 0, 0, 0, 1, 170, 1, 0, 0, 0, 1, 172, 1, 0, 0, 0, 1, 174, 1, 0, 0, 0, 1, 176, 1, 0, 0, 0, 1, 178, 1, 0, 0, 0, 1, 180, 1, 0, 0, 0, 1, 182, 1, 0, 0, 0, 1, 184, 1, 0, 0, 0, 1, 186, 1, 0, 0, 0, 1, 188, 1, 0, 0, 0, 1, 190, 1, 0, 0, 0, 1, 192, 1, 0, 0, 0, 1, 194, 1, 0, 0, 0, 1, 196, 1, 0, 0, 0, 1, 198, 1, 0, 0, 0, 1, 200, 1, 0, 0, 0, 1, 202, 1, 0, 0, 0, 1, 204, 1, 0, 0, 0, 1, 206, 1, 0, 0, 0, 1, 208, 1, 0, 0, 0, 1, 210, 1, 0, 0, 0, 1, 212, 1, 0, 0, 0, 1, 214, 1, 0, 0, 0, 1, 216, 1, 0, 0, 0, 1, 218, 1, 0, 0, 0, 1, 220, 1, 0, 0, 0, 1, 222, 1, 0, 0, 0, 1, 224, 1, 0, 0, 0, 1, 226, 1, 0, 0, 0, 1, 228, 1, 0, 0, 0, 2, 230, 1, 0, 0, 0, 4, 237, 1, 0, 0, 0, 6, 246, 1, 0, 0, 0, 8, 254, 1, 0, 0, 0, 10, 262, 1, 0, 0, 0, 12, 270, 1, 0, 0, 0, 14, 278, 1, 0, 0, 0, 16, 288, 1, 0, 0, 0, 18, 293, 1, 0, 0, 0, 20, 299, 1, 0, 0, 0, 22, 304, 1, 0, 0, 0, 24, 306, 1, 0, 0, 0, 26, 308, 1, 0, 0, 0, 28, 310, 1, 0, 0, 0, 30, 312, 1, 0, 0, 0, 32, 314, 1, 0, 0, 0, 34, 316, 1, 0, 0, 0, 36, 318, 1, 0, 0, 0, 38, 320, 1, 0, 0, 0, 40, 322, 1, 0, 0, 0, 42, 324, 1, 0, 0, 0, 44, 326, 1, 0, 0, 0, 46, 334, 1, 0, 0, 0, 48, 337, 1, 0, 0, 0, 50, 343, 1, 0, 0, 0, 52, 346, 1, 0, 0, 0, 54, 349, 1, 0, 0, 0, 56, 356, 1, 0, 0, 0, 58, 358, 1, 0, 0, 0, 60, 360, 1, 0, 0, 0, 62, 370, 1, 0, 0, 0, 64, 375, 1, 0, 0, 0, 66, 381, 1, 0, 0, 0, 68, 383, 1, 0, 0, 0, 70, 386, 1, 0, 0, 0, 72, 390, 1, 0, 0, 0, 74, 393, 1, 0, 0, 0, 76, 399, 1, 0, 0, 0, 78, 413, 1, 0, 0, 0, 80, 415, 1, 0, 0, 0, 82, 424, 1, 0, 0, 0, 84, 427, 1, 0, 0, 0, 86, 433, 1, 0, 0, 0, 88, 447, 1, 0, 0, 0, 90, 458, 1, 0, 0, 0, 92, 462, 1, 0, 0, 0, 94, 465, 1, 0, 0, 0, 96, 470, 1, 0, 0, 0, 98, 476, 1, 0, 0, 0, 100, 480, 1, 0, 0, 0, 102, 488, 1, 0, 0, 0, 104, 491, 1, 0, 0, 0, 106, 497, 1, 0, 0, 0, 108, 508, 1, 0, 0, 0, 110, 515, 1, 0, 0, 0, 112, 522, 1, 0, 0, 0, 114, 533, 1, 0, 0, 0, 116, 539, 1, 0, 0, 0, 118, 545, 1, 0, 0, 0, 120, 554, 1, 0, 0, 0, 122, 561, 1, 0, 0, 0, 124, 568, 1, 0, 0, 0, 126, 573, 1, 0, 0, 0, 128, 579, 1, 0, 0, 0, 130, 584, 1, 0, 0, 0, 132, 594, 1, 0, 0, 0, 134, 599, 1, 0, 0, 0, 136, 603, 1, 0, 0, 0, 138, 612, 1, 0, 0, 0, 140, 615, 1, 0, 0, 0, 142, 621, 1, 0, 0, 0, 144, 628, 1, 0, 0, 0, 146, 633, 1, 0, 0, 0, 148, 640, 1, 0, 0, 0, 150, 646, 1, 0, 0, 0, 152, 652, 1, 0, 0, 0, 154, 660, 1, 0, 0, 0, 156, 662, 1, 0, 0, 0, 158, 669, 1, 0, 0, 0, 160, 671, 1, 0, 0, 0, 162, 673, 1, 0, 0, 0, 164, 675, 1, 0, 0, 0, 166, 677, 1, 0, 0, 0, 168, 679, 1, 0, 0, 0, 170, 681, 1, 0, 0, 0, 172, 683, 1, 0, 0, 0, 174, 685, 1, 0, 0, 0, 176, 687, 1, 0, 0, 0, 178, 689, 1, 0, 0, 0, 180, 691, 1, 0, 0, 0, 182, 693, 1, 0, 0, 0, 184, 696, 1, 0, 0, 0, 186, 700, 1, 0, 0, 0, 188, 702, 1, 0, 0, 0, 190, 705, 1, 0, 0, 0, 192, 708, 1, 0, 0, 0, 194, 710, 1, 0, 0, 0, 196, 712, 1, 0, 0, 0, 198, 714, 1, 0, 0, 0, 200, 716, 1, 0, 0, 0, 202, 718, 1, 0, 0, 0, 204, 720, 1, 0, 0, 0, 206, 723, 1, 0, 0, 0, 208, 726, 1, 0, 0, 0, 210, 729, 1, 0, 0, 0, 212, 732, 1, 0, 0, 0, 214, 734, 1, 0, 0, 0, 216, 737, 1, 0, 0, 0, 218, 740, 1, 0, 0, 0, 220, 751, 1, 0, 0, 0, 222, 762, 1, 0, 0, 0, 224, 773, 1, 0, 0, 0, 226, 777, 1, 0, 0, 0, 228, 781, 1, 0, 0, 0, 230, 231, 5, 37, 0, 0, 231, 232, 5, 116, 0, 0, 232, 233, 5, 105, 0, 0, 233, 234, 5, 116, 0, 0, 234, 235, 5, 108, 0, 0, 235, 236, 5, 101, 0, 0, 236, 3, 1, 0, 0, 0, 237, 238, 5, 37, 0, 0, 238, 239, 5, 118, 0, 0, 239, 240, 5, 101, 0, 0, 240, 241, 5, 114, 0, 0, 241, 242, 5, 115, 0, 0, 242, 243, 5, 105, 0, 0, 243, 244, 5, 111, 0, 0, 244, 245, 5, 110, 0, 0, 245, 5, 1, 0, 0, 0, 246, 247, 5, 37, 0, 0, 247, 248, 5, 105, 0, 0, 248, 249, 5, 109, 0, 0, 249, 250, 5, 112, 0, 0, 250, 251, 5, 111, 0, 0, 251, 252, 5, 114, 0, 0, 252, 253, 5, 116, 0, 0, 253, 7, 1, 0, 0, 0, 254, 255, 5, 37, 0, 0, 255, 256, 5, 112, 0, 0, 256, 257, 5, 114, 0, 0, 257, 258, 5, 97, 0, 0, 258, 259, 5, 103, 0, 0, 259, 260, 5, 109, 0, 0, 260, 261, 5, 97, 0, 0, 261, 9, 1, 0, 0, 0, 262, 263, 5, 37, 0, 0, 263, 264, 5, 100, 0, 0, 264, 265, 5, 101, 0, 0, 265, 266, 5, 102, 0, 0, 266, 267, 5, 105, 0, 0, 267, 268, 5, 110, 0, 0, 268, 269, 5, 101, 0, 0, 269, 11, 1, 0, 0, 0, 270, 271, 5, 37, 0, 0, 271, 272, 5, 115, 0, 0, 272, 273, 5, 99, 0, 0, 273, 274, 5, 104, 0, 0, 274, 275, 5, 101, 0, 0, 275, 276, 5, 109, 0, 0, 276, 277, 5, 97, 0, 0, 277, 13, 1, 0, 0, 0, 278, 279, 5, 37, 0, 0, 279, 280, 5, 115, 0, 0, 280, 281, 5, 99, 0, 0, 281, 282, 5, 114, 0, 0, 282, 283, 5, 105, 0, 0, 283, 284, 5, 112, 0, 0, 284, 285, 5, 116, 0, 0, 285, 286, 1, 0, 0, 0, 286, 287, 6, 6, 0, 0, 287, 15, 1, 0, 0, 0, 288, 289, 5, 116, 0, 0, 289, 290, 5, 114, 0, 0, 290, 291, 5, 117, 0, 0, 291, 292, 5, 101, 0, 0, 292, 17, 1, 0, 0, 0, 293, 294, 5, 102, 0, 0, 294, 295, 5, 97, 0, 0, 295, 296, 5, 108, 0, 0, 296, 297, 5, 115, 0, 0, 297, 298, 5, 101, 0, 0, 298, 19, 1, 0, 0, 0, 299, 300, 5, 110, 0, 0, 300, 301, 5, 117, 0, 0, 301, 302, 5, 108, 0, 0, 302, 303, 5, 108, 0, 0, 303, 21, 1, 0, 0, 0, 304, 305, 5, 58, 0, 0, 305, 23, 1, 0, 0, 0, 306, 307, 5, 44, 0, 0, 307, 25, 1, 0, 0, 0, 308, 309, 5, 42, 0, 0, 309, 27, 1, 0, 0, 0, 310, 311, 5, 123, 0, 0, 311, 29, 1, 0, 0, 0, 312, 313, 5, 125, 0, 0, 313, 31, 1, 0, 0, 0, 314, 315, 5, 91, 0, 0, 315, 33, 1, 0, 0, 0, 316, 317, 5, 93, 0, 0, 317, 35, 1, 0, 0, 0, 318, 319, 5, 40, 0, 0, 319, 37, 1, 0, 0, 0, 320, 321, 5, 41, 0, 0, 321, 39, 1, 0, 0, 0, 322, 323, 5, 63, 0, 0, 323, 41, 1, 0, 0, 0, 324, 325, 5, 33, 0, 0, 325, 43, 1, 0, 0, 0, 326, 331, 3, 54, 26, 0, 327, 328, 5, 46, 0, 0, 328, 330, 3, 54, 26, 0, 329, 327, 1, 0, 0, 0, 330, 333, 1, 0, 0, 0, 331, 329, 1, 0, 0, 0, 331, 332, 1, 0, 0, 0, 332, 45, 1, 0, 0, 0, 333, 331, 1, 0, 0, 0, 334, 335, 5, 36, 0, 0, 335, 336, 3, 54, 26, 0, 336, 47, 1, 0, 0, 0, 337, 339, 5, 35, 0, 0, 338, 340, 3, 56, 27, 0, 339, 338, 1, 0, 0, 0, 340, 341, 1, 0, 0, 0, 341, 339, 1, 0, 0, 0, 341, 342, 1, 0, 0, 0, 342, 49, 1, 0, 0, 0, 343, 344, 5, 64, 0, 0, 344, 345, 3, 54, 26, 0, 345, 51, 1, 0, 0, 0, 346, 347, 5, 38, 0, 0, 347, 348, 3, 54, 26, 0, 348, 53, 1, 0, 0, 0, 349, 353, 3, 56, 27, 0, 350, 352, 3, 58, 28, 0, 351, 350, 1, 0, 0, 0, 352, 355, 1, 0, 0, 0, 353, 351, 1, 0, 0, 0, 353, 354, 1, 0, 0, 0, 354, 55, 1, 0, 0, 0, 355, 353, 1, 0, 0, 0, 356, 357, 7, 0, 0, 0, 357, 57, 1, 0, 0, 0, 358, 359, 7, 1, 0, 0, 359, 59, 1, 0, 0, 0, 360, 365, 5, 34, 0, 0, 361, 364, 3, 62, 30, 0, 362, 364, 3, 68, 33, 0, 363, 361, 1, 0, 0, 0, 363, 362, 1, 0, 0, 0, 364, 367, 1, 0, 0, 0, 365, 363, 1, 0, 0, 0, 365, 366, 1, 0, 0, 0, 366, 368, 1, 0, 0, 0, 367, 365, 1, 0, 0, 0, 368, 369, 5, 34, 0, 0, 369, 61, 1, 0, 0, 0, 370, 373, 5, 92, 0, 0, 371, 374, 7, 2, 0, 0, 372, 374, 3, 64, 31, 0, 373, 371, 1, 0, 0, 0, 373, 372, 1, 0, 0, 0, 374, 63, 1, 0, 0, 0, 375, 376, 5, 117, 0, 0, 376, 377, 3, 66, 32, 0, 377, 378, 3, 66, 32, 0, 378, 379, 3, 66, 32, 0, 379, 380, 3, 66, 32, 0, 380, 65, 1, 0, 0, 0, 381, 382, 7, 3, 0, 0, 382, 67, 1, 0, 0, 0, 383, 384, 8, 4, 0, 0, 384, 69, 1, 0, 0, 0, 385, 387, 5, 45, 0, 0, 386, 385, 1, 0, 0, 0, 386, 387, 1, 0, 0, 0, 387, 388, 1, 0, 0, 0, 388, 389, 3, 78, 38, 0, 389, 71, 1, 0, 0, 0, 390, 391, 3, 70, 34, 0, 391, 392, 3, 76, 37, 0, 392, 73, 1, 0, 0, 0, 393, 395, 3, 70, 34, 0, 394, 396, 3, 76, 37, 0, 395, 394, 1, 0, 0, 0, 395, 396, 1, 0, 0, 0, 396, 397, 1, 0, 0, 0, 397, 398, 3, 80, 39, 0, 398, 75, 1, 0, 0, 0, 399, 401, 5, 46, 0, 0, 400, 402, 3, 82, 40, 0, 401, 400, 1, 0, 0, 0, 402, 403, 1, 0, 0, 0, 403, 401, 1, 0, 0, 0, 403, 404, 1, 0, 0, 0, 404, 77, 1, 0, 0, 0, 405, 414, 5, 48, 0, 0, 406, 410, 7, 5, 0, 0, 407, 409, 3, 82, 40, 0, 408, 407, 1, 0, 0, 0, 409, 412, 1, 0, 0, 0, 410, 408, 1, 0, 0, 0, 410, 411, 1, 0, 0, 0, 411, 414, 1, 0, 0, 0, 412, 410, 1, 0, 0, 0, 413, 405, 1, 0, 0, 0, 413, 406, 1, 0, 0, 0, 414, 79, 1, 0, 0, 0, 415, 417, 7, 6, 0, 0, 416, 418, 7, 7, 0, 0, 417, 416, 1, 0, 0, 0, 417, 418, 1, 0, 0, 0, 418, 420, 1, 0, 0, 0, 419, 421, 3, 82, 40, 0, 420, 419, 1, 0, 0, 0, 421, 422, 1, 0, 0, 0, 422, 420, 1, 0, 0, 0, 422, 423, 1, 0, 0, 0, 423, 81, 1, 0, 0, 0, 424, 425, 7, 8, 0, 0, 425, 83, 1, 0, 0, 0, 426, 428, 7, 9, 0, 0, 427, 426, 1, 0, 0, 0, 428, 429, 1, 0, 0, 0, 429, 427, 1, 0, 0, 0, 429, 430, 1, 0, 0, 0, 430, 431, 1, 0, 0, 0, 431, 432, 6, 41, 1, 0, 432, 85, 1, 0, 0, 0, 433, 434, 5, 47, 0, 0, 434, 435, 5, 42, 0, 0, 435, 439, 1, 0, 0, 0, 436, 438, 9, 0, 0, 0, 437, 436, 1, 0, 0, 0, 438, 441, 1, 0, 0, 0, 439, 440, 1, 0, 0, 0, 439, 437, 1, 0, 0, 0, 440, 442, 1, 0, 0, 0, 441, 439, 1, 0, 0, 0, 442, 443, 5, 42, 0, 0, 443, 444, 5, 47, 0, 0, 444, 445, 1, 0, 0, 0, 445, 446, 6, 42, 1, 0, 446, 87, 1, 0, 0, 0, 447, 448, 5, 47, 0, 0, 448, 449, 5, 47, 0, 0, 449, 453, 1, 0, 0, 0, 450, 452, 8, 10, 0, 0, 451, 450, 1, 0, 0, 0, 452, 455, 1, 0, 0, 0, 453, 451, 1, 0, 0, 0, 453, 454, 1, 0, 0, 0, 454, 456, 1, 0, 0, 0, 455, 453, 1, 0, 0, 0, 456, 457, 6, 43, 1, 0, 457, 89, 1, 0, 0, 0, 458, 459, 5, 118, 0, 0, 459, 460, 5, 97, 0, 0, 460, 461, 5, 114, 0, 0, 461, 91, 1, 0, 0, 0, 462, 463, 5, 105, 0, 0, 463, 464, 5, 102, 0, 0, 464, 93, 1, 0, 0, 0, 465, 466, 5, 101, 0, 0, 466, 467, 5, 108, 0, 0, 467, 468, 5, 115, 0, 0, 468, 469, 5, 101, 0, 0, 469, 95, 1, 0, 0, 0, 470, 471, 5, 119, 0, 0, 471, 472, 5, 104, 0, 0, 472, 473, 5, 105, 0, 0, 473, 474, 5, 108, 0, 0, 474, 475, 5, 101, 0, 0, 475, 97, 1, 0, 0, 0, 476, 477, 5, 102, 0, 0, 477, 478, 5, 111, 0, 0, 478, 479, 5, 114, 0, 0, 479, 99, 1, 0, 0, 0, 480, 481, 5, 102, 0, 0, 481, 482, 5, 111, 0, 0, 482, 483, 5, 114, 0, 0, 483, 484, 5, 101, 0, 0, 484, 485, 5, 97, 0, 0, 485, 486, 5, 99, 0, 0, 486, 487, 5, 104, 0, 0, 487, 101, 1, 0, 0, 0, 488, 489, 5, 105, 0, 0, 489, 490, 5, 110, 0, 0, 490, 103, 1, 0, 0, 0, 491, 492, 5, 98, 0, 0, 492, 493, 5, 114, 0, 0, 493, 494, 5, 101, 0, 0, 494, 495, 5, 97, 0, 0, 495, 496, 5, 107, 0, 0, 496, 105, 1, 0, 0, 0, 497, 498, 5, 99, 0, 0, 498, 499, 5, 111, 0, 0, 499, 500, 5, 110, 0, 0, 500, 501, 5, 115, 0, 0, 501, 502, 5, 116, 0, 0, 502, 503, 5, 114, 0, 0, 503, 504, 5, 97, 0, 0, 504, 505, 5, 105, 0, 0, 505, 506, 5, 110, 0, 0, 506, 507, 5, 116, 0, 0, 507, 107, 1, 0, 0, 0, 508, 509, 5, 116, 0, 0, 509, 510, 5, 97, 0, 0, 510, 511, 5, 114, 0, 0, 511, 512, 5, 103, 0, 0, 512, 513, 5, 101, 0, 0, 513, 514, 5, 116, 0, 0, 514, 109, 1, 0, 0, 0, 515, 516, 5, 99, 0, 0, 516, 517, 5, 97, 0, 0, 517, 518, 5, 108, 0, 0, 518, 519, 5, 108, 0, 0, 519, 520, 5, 101, 0, 0, 520, 521, 5, 114, 0, 0, 521, 111, 1, 0, 0, 0, 522, 523, 5, 115, 0, 0, 523, 524, 5, 117, 0, 0, 524, 525, 5, 98, 0, 0, 525, 526, 5, 114, 0, 0, 526, 527, 5, 111, 0, 0, 527, 528, 5, 117, 0, 0, 528, 529, 5, 116, 0, 0, 529, 530, 5, 105, 0, 0, 530, 531, 5, 110, 0, 0, 531, 532, 5, 101, 0, 0, 532, 113, 1, 0, 0, 0, 533, 534, 5, 116, 0, 0, 534, 535, 5, 114, 0, 0, 535, 536, 5, 121, 0, 0, 536, 537, 5, 111, 0, 0, 537, 538, 5, 102, 0, 0, 538, 115, 1, 0, 0, 0, 539, 540, 5, 116, 0, 0, 540, 541, 5, 104, 0, 0, 541, 542, 5, 114, 0, 0, 542, 543, 5, 111, 0, 0, 543, 544, 5, 119, 0, 0, 544, 117, 1, 0, 0, 0, 545, 546, 5, 102, 0, 0, 546, 547, 5, 117, 0, 0, 547, 548, 5, 110, 0, 0, 548, 549, 5, 99, 0, 0, 549, 550, 5, 116, 0, 0, 550, 551, 5, 105, 0, 0, 551, 552, 5, 111, 0, 0, 552, 553, 5, 110, 0, 0, 553, 119, 1, 0, 0, 0, 554, 555, 5, 114, 0, 0, 555, 556, 5, 101, 0, 0, 556, 557, 5, 116, 0, 0, 557, 558, 5, 117, 0, 0, 558, 559, 5, 114, 0, 0, 559, 560, 5, 110, 0, 0, 560, 121, 1, 0, 0, 0, 561, 562, 5, 102, 0, 0, 562, 563, 5, 117, 0, 0, 563, 564, 5, 116, 0, 0, 564, 565, 5, 117, 0, 0, 565, 566, 5, 114, 0, 0, 566, 567, 5, 101, 0, 0, 567, 123, 1, 0, 0, 0, 568, 569, 5, 116, 0, 0, 569, 570, 5, 114, 0, 0, 570, 571, 5, 117, 0, 0, 571, 572, 5, 101, 0, 0, 572, 125, 1, 0, 0, 0, 573, 574, 5, 102, 0, 0, 574, 575, 5, 97, 0, 0, 575, 576, 5, 108, 0, 0, 576, 577, 5, 115, 0, 0, 577, 578, 5, 101, 0, 0, 578, 127, 1, 0, 0, 0, 579, 580, 5, 110, 0, 0, 580, 581, 5, 117, 0, 0, 581, 582, 5, 108, 0, 0, 582, 583, 5, 108, 0, 0, 583, 129, 1, 0, 0, 0, 584, 585, 5, 117, 0, 0, 585, 586, 5, 110, 0, 0, 586, 587, 5, 100, 0, 0, 587, 588, 5, 101, 0, 0, 588, 589, 5, 102, 0, 0, 589, 590, 5, 105, 0, 0, 590, 591, 5, 110, 0, 0, 591, 592, 5, 101, 0, 0, 592, 593, 5, 100, 0, 0, 593, 131, 1, 0, 0, 0, 594, 595, 5, 116, 0, 0, 595, 596, 5, 104, 0, 0, 596, 597, 5, 105, 0, 0, 597, 598, 5, 115, 0, 0, 598, 133, 1, 0, 0, 0, 599, 600, 5, 110, 0, 0, 600, 601, 5, 101, 0, 0, 601, 602, 5, 119, 0, 0, 602, 135, 1, 0, 0, 0, 603, 604, 5, 99, 0, 0, 604, 605, 5, 111, 0, 0, 605, 606, 5, 110, 0, 0, 606, 607, 5, 116, 0, 0, 607, 608, 5, 105, 0, 0, 608, 609, 5, 110, 0, 0, 609, 610, 5, 117, 0, 0, 610, 611, 5, 101, 0, 0, 611, 137, 1, 0, 0, 0, 612, 613, 5, 100, 0, 0, 613, 614, 5, 111, 0, 0, 614, 139, 1, 0, 0, 0, 615, 616, 5, 99, 0, 0, 616, 617, 5, 111, 0, 0, 617, 618, 5, 110, 0, 0, 618, 619, 5, 115, 0, 0, 619, 620, 5, 116, 0, 0, 620, 141, 1, 0, 0, 0, 621, 622, 5, 115, 0, 0, 622, 623, 5, 119, 0, 0, 623, 624, 5, 105, 0, 0, 624, 625, 5, 116, 0, 0, 625, 626, 5, 99, 0, 0, 626, 627, 5, 104, 0, 0, 627, 143, 1, 0, 0, 0, 628, 629, 5, 99, 0, 0, 629, 630, 5, 97, 0, 0, 630, 631, 5, 115, 0, 0, 631, 632, 5, 101, 0, 0, 632, 145, 1, 0, 0, 0, 633, 634, 5, 105, 0, 0, 634, 635, 5, 109, 0, 0, 635, 636, 5, 112, 0, 0, 636, 637, 5, 111, 0, 0, 637, 638, 5, 114, 0, 0, 638, 639, 5, 116, 0, 0, 639, 147, 1, 0, 0, 0, 640, 641, 5, 99, 0, 0, 641, 642, 5, 108, 0, 0, 642, 643, 5, 97, 0, 0, 643, 644, 5, 115, 0, 0, 644, 645, 5, 115, 0, 0, 645, 149, 1, 0, 0, 0, 646, 647, 5, 115, 0, 0, 647, 648, 5, 117, 0, 0, 648, 649, 5, 112, 0, 0, 649, 650, 5, 101, 0, 0, 650, 651, 5, 114, 0, 0, 651, 151, 1, 0, 0, 0, 652, 653, 5, 100, 0, 0, 653, 654, 5, 101, 0, 0, 654, 655, 5, 102, 0, 0, 655, 656, 5, 97, 0, 0, 656, 657, 5, 117, 0, 0, 657, 658, 5, 108, 0, 0, 658, 659, 5, 116, 0, 0, 659, 153, 1, 0, 0, 0, 660, 661, 3, 70, 34, 0, 661, 155, 1, 0, 0, 0, 662, 664, 3, 70, 34, 0, 663, 665, 3, 76, 37, 0, 664, 663, 1, 0, 0, 0, 664, 665, 1, 0, 0, 0, 665, 667, 1, 0, 0, 0, 666, 668, 3, 80, 39, 0, 667, 666, 1, 0, 0, 0, 667, 668, 1, 0, 0, 0, 668, 157, 1, 0, 0, 0, 669, 670, 3, 60, 29, 0, 670, 159, 1, 0, 0, 0, 671, 672, 3, 54, 26, 0, 672, 161, 1, 0, 0, 0, 673, 674, 5, 123, 0, 0, 674, 163, 1, 0, 0, 0, 675, 676, 5, 125, 0, 0, 676, 165, 1, 0, 0, 0, 677, 678, 5, 91, 0, 0, 678, 167, 1, 0, 0, 0, 679, 680, 5, 93, 0, 0, 680, 169, 1, 0, 0, 0, 681, 682, 5, 40, 0, 0, 682, 171, 1, 0, 0, 0, 683, 684, 5, 41, 0, 0, 684, 173, 1, 0, 0, 0, 685, 686, 5, 59, 0, 0, 686, 175, 1, 0, 0, 0, 687, 688, 5, 44, 0, 0, 688, 177, 1, 0, 0, 0, 689, 690, 5, 46, 0, 0, 690, 179, 1, 0, 0, 0, 691, 692, 5, 58, 0, 0, 692, 181, 1, 0, 0, 0, 693, 694, 5, 46, 0, 0, 694, 695, 5, 46, 0, 0, 695, 183, 1, 0, 0, 0, 696, 697, 5, 46, 0, 0, 697, 698, 5, 46, 0, 0, 698, 699, 5, 46, 0, 0, 699, 185, 1, 0, 0, 0, 700, 701, 5, 61, 0, 0, 701, 187, 1, 0, 0, 0, 702, 703, 5, 43, 0, 0, 703, 704, 5, 43, 0, 0, 704, 189, 1, 0, 0, 0, 705, 706, 5, 45, 0, 0, 706, 707, 5, 45, 0, 0, 707, 191, 1, 0, 0, 0, 708, 709, 5, 43, 0, 0, 709, 193, 1, 0, 0, 0, 710, 711, 5, 45, 0, 0, 711, 195, 1, 0, 0, 0, 712, 713, 5, 42, 0, 0, 713, 197, 1, 0, 0, 0, 714, 715, 5, 47, 0, 0, 715, 199, 1, 0, 0, 0, 716, 717, 5, 62, 0, 0, 717, 201, 1, 0, 0, 0, 718, 719, 5, 60, 0, 0, 719, 203, 1, 0, 0, 0, 720, 721, 5, 60, 0, 0, 721, 722, 5, 61, 0, 0, 722, 205, 1, 0, 0, 0, 723, 724, 5, 62, 0, 0, 724, 725, 5, 61, 0, 0, 725, 207, 1, 0, 0, 0, 726, 727, 5, 61, 0, 0, 727, 728, 5, 61, 0, 0, 728, 209, 1, 0, 0, 0, 729, 730, 5, 33, 0, 0, 730, 731, 5, 61, 0, 0, 731, 211, 1, 0, 0, 0, 732, 733, 5, 33, 0, 0, 733, 213, 1, 0, 0, 0, 734, 735, 5, 38, 0, 0, 735, 736, 5, 38, 0, 0, 736, 215, 1, 0, 0, 0, 737, 738, 5, 124, 0, 0, 738, 739, 5, 124, 0, 0, 739, 217, 1, 0, 0, 0, 740, 741, 5, 37, 0, 0, 741, 742, 5, 100, 0, 0, 742, 743, 5, 101, 0, 0, 743, 744, 5, 102, 0, 0, 744, 745, 5, 105, 0, 0, 745, 746, 5, 110, 0, 0, 746, 747, 5, 101, 0, 0, 747, 748, 1, 0, 0, 0, 748, 749, 6, 108, 2, 0, 749, 750, 6, 108, 3, 0, 750, 219, 1, 0, 0, 0, 751, 752, 5, 37, 0, 0, 752, 753, 5, 115, 0, 0, 753, 754, 5, 99, 0, 0, 754, 755, 5, 104, 0, 0, 755, 756, 5, 101, 0, 0, 756, 757, 5, 109, 0, 0, 757, 758, 5, 97, 0, 0, 758, 759, 1, 0, 0, 0, 759, 760, 6, 109, 4, 0, 760, 761, 6, 109, 3, 0, 761, 221, 1, 0, 0, 0, 762, 763, 5, 37, 0, 0, 763, 764, 5, 115, 0, 0, 764, 765, 5, 99, 0, 0, 765, 766, 5, 114, 0, 0, 766, 767, 5, 105, 0, 0, 767, 768, 5, 112, 0, 0, 768, 769, 5, 116, 0, 0, 769, 770, 1, 0, 0, 0, 770, 771, 6, 110, 5, 0, 771, 772, 6, 110, 3, 0, 772, 223, 1, 0, 0, 0, 773, 774, 3, 84, 41, 0, 774, 775, 1, 0, 0, 0, 775, 776, 6, 111, 1, 0, 776, 225, 1, 0, 0, 0, 777, 778, 3, 86, 42, 0, 778, 779, 1, 0, 0, 0, 779, 780, 6, 112, 1, 0, 780, 227, 1, 0, 0, 0, 781, 782, 3, 88, 43, 0, 782, 783, 1, 0, 0, 0, 783, 784, 6, 113, 1, 0, 784, 229, 1, 0, 0, 0, 20, 0, 1, 331, 341, 353, 363, 365, 373, 386, 395, 403, 410, 413, 417, 422, 429, 439, 453, 664, 667, 6, 5, 1, 0, 0, 1, 0, 7, 5, 0, 4, 0, 0, 7, 6, 0, 7, 7, 0] \ No newline at end of file +[4, 0, 100, 784, 6, -1, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, 2, 68, 7, 68, 2, 69, 7, 69, 2, 70, 7, 70, 2, 71, 7, 71, 2, 72, 7, 72, 2, 73, 7, 73, 2, 74, 7, 74, 2, 75, 7, 75, 2, 76, 7, 76, 2, 77, 7, 77, 2, 78, 7, 78, 2, 79, 7, 79, 2, 80, 7, 80, 2, 81, 7, 81, 2, 82, 7, 82, 2, 83, 7, 83, 2, 84, 7, 84, 2, 85, 7, 85, 2, 86, 7, 86, 2, 87, 7, 87, 2, 88, 7, 88, 2, 89, 7, 89, 2, 90, 7, 90, 2, 91, 7, 91, 2, 92, 7, 92, 2, 93, 7, 93, 2, 94, 7, 94, 2, 95, 7, 95, 2, 96, 7, 96, 2, 97, 7, 97, 2, 98, 7, 98, 2, 99, 7, 99, 2, 100, 7, 100, 2, 101, 7, 101, 2, 102, 7, 102, 2, 103, 7, 103, 2, 104, 7, 104, 2, 105, 7, 105, 2, 106, 7, 106, 2, 107, 7, 107, 2, 108, 7, 108, 2, 109, 7, 109, 2, 110, 7, 110, 2, 111, 7, 111, 2, 112, 7, 112, 2, 113, 7, 113, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 5, 21, 330, 8, 21, 10, 21, 12, 21, 333, 9, 21, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 4, 23, 340, 8, 23, 11, 23, 12, 23, 341, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 5, 26, 352, 8, 26, 10, 26, 12, 26, 355, 9, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 5, 29, 364, 8, 29, 10, 29, 12, 29, 367, 9, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 3, 30, 374, 8, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 3, 34, 387, 8, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 3, 36, 396, 8, 36, 1, 36, 1, 36, 1, 37, 1, 37, 4, 37, 402, 8, 37, 11, 37, 12, 37, 403, 1, 38, 1, 38, 1, 38, 5, 38, 409, 8, 38, 10, 38, 12, 38, 412, 9, 38, 3, 38, 414, 8, 38, 1, 39, 1, 39, 3, 39, 418, 8, 39, 1, 39, 4, 39, 421, 8, 39, 11, 39, 12, 39, 422, 1, 40, 1, 40, 1, 41, 4, 41, 428, 8, 41, 11, 41, 12, 41, 429, 1, 41, 1, 41, 1, 42, 1, 42, 1, 42, 1, 42, 5, 42, 438, 8, 42, 10, 42, 12, 42, 441, 9, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 43, 5, 43, 452, 8, 43, 10, 43, 12, 43, 455, 9, 43, 1, 43, 1, 43, 1, 44, 1, 44, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 1, 47, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 49, 1, 50, 1, 50, 1, 50, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 57, 1, 57, 1, 57, 1, 57, 1, 57, 1, 57, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 60, 1, 60, 1, 60, 1, 60, 1, 60, 1, 60, 1, 60, 1, 61, 1, 61, 1, 61, 1, 61, 1, 61, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 66, 1, 66, 1, 66, 1, 66, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 68, 1, 68, 1, 68, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 70, 1, 70, 1, 70, 1, 70, 1, 70, 1, 70, 1, 70, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 76, 1, 76, 1, 77, 1, 77, 3, 77, 665, 8, 77, 1, 77, 3, 77, 668, 8, 77, 1, 78, 1, 78, 1, 79, 1, 79, 1, 80, 1, 80, 1, 81, 1, 81, 1, 82, 1, 82, 1, 83, 1, 83, 1, 84, 1, 84, 1, 85, 1, 85, 1, 86, 1, 86, 1, 87, 1, 87, 1, 88, 1, 88, 1, 89, 1, 89, 1, 90, 1, 90, 1, 90, 1, 91, 1, 91, 1, 91, 1, 91, 1, 92, 1, 92, 1, 93, 1, 93, 1, 93, 1, 94, 1, 94, 1, 94, 1, 95, 1, 95, 1, 96, 1, 96, 1, 97, 1, 97, 1, 98, 1, 98, 1, 99, 1, 99, 1, 100, 1, 100, 1, 101, 1, 101, 1, 101, 1, 102, 1, 102, 1, 102, 1, 103, 1, 103, 1, 103, 1, 104, 1, 104, 1, 104, 1, 105, 1, 105, 1, 106, 1, 106, 1, 106, 1, 107, 1, 107, 1, 107, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 108, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 111, 1, 111, 1, 111, 1, 111, 1, 112, 1, 112, 1, 112, 1, 112, 1, 113, 1, 113, 1, 113, 1, 113, 1, 439, 0, 114, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18, 9, 20, 10, 22, 11, 24, 12, 26, 13, 28, 14, 30, 15, 32, 16, 34, 17, 36, 18, 38, 19, 40, 20, 42, 21, 44, 22, 46, 23, 48, 24, 50, 25, 52, 26, 54, 0, 56, 0, 58, 0, 60, 27, 62, 0, 64, 0, 66, 0, 68, 0, 70, 28, 72, 29, 74, 30, 76, 0, 78, 0, 80, 0, 82, 0, 84, 31, 86, 32, 88, 33, 90, 34, 92, 35, 94, 36, 96, 37, 98, 38, 100, 39, 102, 40, 104, 41, 106, 42, 108, 43, 110, 44, 112, 45, 114, 46, 116, 47, 118, 48, 120, 49, 122, 50, 124, 51, 126, 52, 128, 53, 130, 54, 132, 55, 134, 56, 136, 57, 138, 58, 140, 59, 142, 60, 144, 61, 146, 62, 148, 63, 150, 64, 152, 65, 154, 66, 156, 67, 158, 68, 160, 69, 162, 70, 164, 71, 166, 72, 168, 73, 170, 74, 172, 75, 174, 76, 176, 77, 178, 78, 180, 79, 182, 80, 184, 81, 186, 82, 188, 83, 190, 84, 192, 85, 194, 86, 196, 87, 198, 88, 200, 89, 202, 90, 204, 91, 206, 92, 208, 93, 210, 94, 212, 95, 214, 96, 216, 97, 218, 0, 220, 0, 222, 0, 224, 98, 226, 99, 228, 100, 2, 0, 1, 11, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 8, 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 0, 31, 34, 34, 92, 92, 1, 0, 49, 57, 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 1, 0, 48, 57, 3, 0, 9, 10, 13, 13, 32, 32, 2, 0, 10, 10, 13, 13, 789, 0, 2, 1, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 6, 1, 0, 0, 0, 0, 8, 1, 0, 0, 0, 0, 10, 1, 0, 0, 0, 0, 12, 1, 0, 0, 0, 0, 14, 1, 0, 0, 0, 0, 16, 1, 0, 0, 0, 0, 18, 1, 0, 0, 0, 0, 20, 1, 0, 0, 0, 0, 22, 1, 0, 0, 0, 0, 24, 1, 0, 0, 0, 0, 26, 1, 0, 0, 0, 0, 28, 1, 0, 0, 0, 0, 30, 1, 0, 0, 0, 0, 32, 1, 0, 0, 0, 0, 34, 1, 0, 0, 0, 0, 36, 1, 0, 0, 0, 0, 38, 1, 0, 0, 0, 0, 40, 1, 0, 0, 0, 0, 42, 1, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 46, 1, 0, 0, 0, 0, 48, 1, 0, 0, 0, 0, 50, 1, 0, 0, 0, 0, 52, 1, 0, 0, 0, 0, 60, 1, 0, 0, 0, 0, 70, 1, 0, 0, 0, 0, 72, 1, 0, 0, 0, 0, 74, 1, 0, 0, 0, 0, 84, 1, 0, 0, 0, 0, 86, 1, 0, 0, 0, 0, 88, 1, 0, 0, 0, 1, 90, 1, 0, 0, 0, 1, 92, 1, 0, 0, 0, 1, 94, 1, 0, 0, 0, 1, 96, 1, 0, 0, 0, 1, 98, 1, 0, 0, 0, 1, 100, 1, 0, 0, 0, 1, 102, 1, 0, 0, 0, 1, 104, 1, 0, 0, 0, 1, 106, 1, 0, 0, 0, 1, 108, 1, 0, 0, 0, 1, 110, 1, 0, 0, 0, 1, 112, 1, 0, 0, 0, 1, 114, 1, 0, 0, 0, 1, 116, 1, 0, 0, 0, 1, 118, 1, 0, 0, 0, 1, 120, 1, 0, 0, 0, 1, 122, 1, 0, 0, 0, 1, 124, 1, 0, 0, 0, 1, 126, 1, 0, 0, 0, 1, 128, 1, 0, 0, 0, 1, 130, 1, 0, 0, 0, 1, 132, 1, 0, 0, 0, 1, 134, 1, 0, 0, 0, 1, 136, 1, 0, 0, 0, 1, 138, 1, 0, 0, 0, 1, 140, 1, 0, 0, 0, 1, 142, 1, 0, 0, 0, 1, 144, 1, 0, 0, 0, 1, 146, 1, 0, 0, 0, 1, 148, 1, 0, 0, 0, 1, 150, 1, 0, 0, 0, 1, 152, 1, 0, 0, 0, 1, 154, 1, 0, 0, 0, 1, 156, 1, 0, 0, 0, 1, 158, 1, 0, 0, 0, 1, 160, 1, 0, 0, 0, 1, 162, 1, 0, 0, 0, 1, 164, 1, 0, 0, 0, 1, 166, 1, 0, 0, 0, 1, 168, 1, 0, 0, 0, 1, 170, 1, 0, 0, 0, 1, 172, 1, 0, 0, 0, 1, 174, 1, 0, 0, 0, 1, 176, 1, 0, 0, 0, 1, 178, 1, 0, 0, 0, 1, 180, 1, 0, 0, 0, 1, 182, 1, 0, 0, 0, 1, 184, 1, 0, 0, 0, 1, 186, 1, 0, 0, 0, 1, 188, 1, 0, 0, 0, 1, 190, 1, 0, 0, 0, 1, 192, 1, 0, 0, 0, 1, 194, 1, 0, 0, 0, 1, 196, 1, 0, 0, 0, 1, 198, 1, 0, 0, 0, 1, 200, 1, 0, 0, 0, 1, 202, 1, 0, 0, 0, 1, 204, 1, 0, 0, 0, 1, 206, 1, 0, 0, 0, 1, 208, 1, 0, 0, 0, 1, 210, 1, 0, 0, 0, 1, 212, 1, 0, 0, 0, 1, 214, 1, 0, 0, 0, 1, 216, 1, 0, 0, 0, 1, 218, 1, 0, 0, 0, 1, 220, 1, 0, 0, 0, 1, 222, 1, 0, 0, 0, 1, 224, 1, 0, 0, 0, 1, 226, 1, 0, 0, 0, 1, 228, 1, 0, 0, 0, 2, 230, 1, 0, 0, 0, 4, 237, 1, 0, 0, 0, 6, 246, 1, 0, 0, 0, 8, 254, 1, 0, 0, 0, 10, 262, 1, 0, 0, 0, 12, 270, 1, 0, 0, 0, 14, 278, 1, 0, 0, 0, 16, 288, 1, 0, 0, 0, 18, 293, 1, 0, 0, 0, 20, 299, 1, 0, 0, 0, 22, 304, 1, 0, 0, 0, 24, 306, 1, 0, 0, 0, 26, 308, 1, 0, 0, 0, 28, 310, 1, 0, 0, 0, 30, 312, 1, 0, 0, 0, 32, 314, 1, 0, 0, 0, 34, 316, 1, 0, 0, 0, 36, 318, 1, 0, 0, 0, 38, 320, 1, 0, 0, 0, 40, 322, 1, 0, 0, 0, 42, 324, 1, 0, 0, 0, 44, 326, 1, 0, 0, 0, 46, 334, 1, 0, 0, 0, 48, 337, 1, 0, 0, 0, 50, 343, 1, 0, 0, 0, 52, 346, 1, 0, 0, 0, 54, 349, 1, 0, 0, 0, 56, 356, 1, 0, 0, 0, 58, 358, 1, 0, 0, 0, 60, 360, 1, 0, 0, 0, 62, 370, 1, 0, 0, 0, 64, 375, 1, 0, 0, 0, 66, 381, 1, 0, 0, 0, 68, 383, 1, 0, 0, 0, 70, 386, 1, 0, 0, 0, 72, 390, 1, 0, 0, 0, 74, 393, 1, 0, 0, 0, 76, 399, 1, 0, 0, 0, 78, 413, 1, 0, 0, 0, 80, 415, 1, 0, 0, 0, 82, 424, 1, 0, 0, 0, 84, 427, 1, 0, 0, 0, 86, 433, 1, 0, 0, 0, 88, 447, 1, 0, 0, 0, 90, 458, 1, 0, 0, 0, 92, 462, 1, 0, 0, 0, 94, 465, 1, 0, 0, 0, 96, 470, 1, 0, 0, 0, 98, 476, 1, 0, 0, 0, 100, 480, 1, 0, 0, 0, 102, 488, 1, 0, 0, 0, 104, 491, 1, 0, 0, 0, 106, 497, 1, 0, 0, 0, 108, 508, 1, 0, 0, 0, 110, 515, 1, 0, 0, 0, 112, 522, 1, 0, 0, 0, 114, 533, 1, 0, 0, 0, 116, 539, 1, 0, 0, 0, 118, 545, 1, 0, 0, 0, 120, 554, 1, 0, 0, 0, 122, 561, 1, 0, 0, 0, 124, 568, 1, 0, 0, 0, 126, 573, 1, 0, 0, 0, 128, 579, 1, 0, 0, 0, 130, 584, 1, 0, 0, 0, 132, 594, 1, 0, 0, 0, 134, 599, 1, 0, 0, 0, 136, 603, 1, 0, 0, 0, 138, 612, 1, 0, 0, 0, 140, 615, 1, 0, 0, 0, 142, 621, 1, 0, 0, 0, 144, 628, 1, 0, 0, 0, 146, 633, 1, 0, 0, 0, 148, 640, 1, 0, 0, 0, 150, 646, 1, 0, 0, 0, 152, 652, 1, 0, 0, 0, 154, 660, 1, 0, 0, 0, 156, 662, 1, 0, 0, 0, 158, 669, 1, 0, 0, 0, 160, 671, 1, 0, 0, 0, 162, 673, 1, 0, 0, 0, 164, 675, 1, 0, 0, 0, 166, 677, 1, 0, 0, 0, 168, 679, 1, 0, 0, 0, 170, 681, 1, 0, 0, 0, 172, 683, 1, 0, 0, 0, 174, 685, 1, 0, 0, 0, 176, 687, 1, 0, 0, 0, 178, 689, 1, 0, 0, 0, 180, 691, 1, 0, 0, 0, 182, 693, 1, 0, 0, 0, 184, 696, 1, 0, 0, 0, 186, 700, 1, 0, 0, 0, 188, 702, 1, 0, 0, 0, 190, 705, 1, 0, 0, 0, 192, 708, 1, 0, 0, 0, 194, 710, 1, 0, 0, 0, 196, 712, 1, 0, 0, 0, 198, 714, 1, 0, 0, 0, 200, 716, 1, 0, 0, 0, 202, 718, 1, 0, 0, 0, 204, 720, 1, 0, 0, 0, 206, 723, 1, 0, 0, 0, 208, 726, 1, 0, 0, 0, 210, 729, 1, 0, 0, 0, 212, 732, 1, 0, 0, 0, 214, 734, 1, 0, 0, 0, 216, 737, 1, 0, 0, 0, 218, 740, 1, 0, 0, 0, 220, 751, 1, 0, 0, 0, 222, 762, 1, 0, 0, 0, 224, 772, 1, 0, 0, 0, 226, 776, 1, 0, 0, 0, 228, 780, 1, 0, 0, 0, 230, 231, 5, 37, 0, 0, 231, 232, 5, 116, 0, 0, 232, 233, 5, 105, 0, 0, 233, 234, 5, 116, 0, 0, 234, 235, 5, 108, 0, 0, 235, 236, 5, 101, 0, 0, 236, 3, 1, 0, 0, 0, 237, 238, 5, 37, 0, 0, 238, 239, 5, 118, 0, 0, 239, 240, 5, 101, 0, 0, 240, 241, 5, 114, 0, 0, 241, 242, 5, 115, 0, 0, 242, 243, 5, 105, 0, 0, 243, 244, 5, 111, 0, 0, 244, 245, 5, 110, 0, 0, 245, 5, 1, 0, 0, 0, 246, 247, 5, 37, 0, 0, 247, 248, 5, 105, 0, 0, 248, 249, 5, 109, 0, 0, 249, 250, 5, 112, 0, 0, 250, 251, 5, 111, 0, 0, 251, 252, 5, 114, 0, 0, 252, 253, 5, 116, 0, 0, 253, 7, 1, 0, 0, 0, 254, 255, 5, 37, 0, 0, 255, 256, 5, 112, 0, 0, 256, 257, 5, 114, 0, 0, 257, 258, 5, 97, 0, 0, 258, 259, 5, 103, 0, 0, 259, 260, 5, 109, 0, 0, 260, 261, 5, 97, 0, 0, 261, 9, 1, 0, 0, 0, 262, 263, 5, 37, 0, 0, 263, 264, 5, 100, 0, 0, 264, 265, 5, 101, 0, 0, 265, 266, 5, 102, 0, 0, 266, 267, 5, 105, 0, 0, 267, 268, 5, 110, 0, 0, 268, 269, 5, 101, 0, 0, 269, 11, 1, 0, 0, 0, 270, 271, 5, 37, 0, 0, 271, 272, 5, 115, 0, 0, 272, 273, 5, 99, 0, 0, 273, 274, 5, 104, 0, 0, 274, 275, 5, 101, 0, 0, 275, 276, 5, 109, 0, 0, 276, 277, 5, 97, 0, 0, 277, 13, 1, 0, 0, 0, 278, 279, 5, 37, 0, 0, 279, 280, 5, 115, 0, 0, 280, 281, 5, 99, 0, 0, 281, 282, 5, 114, 0, 0, 282, 283, 5, 105, 0, 0, 283, 284, 5, 112, 0, 0, 284, 285, 5, 116, 0, 0, 285, 286, 1, 0, 0, 0, 286, 287, 6, 6, 0, 0, 287, 15, 1, 0, 0, 0, 288, 289, 5, 116, 0, 0, 289, 290, 5, 114, 0, 0, 290, 291, 5, 117, 0, 0, 291, 292, 5, 101, 0, 0, 292, 17, 1, 0, 0, 0, 293, 294, 5, 102, 0, 0, 294, 295, 5, 97, 0, 0, 295, 296, 5, 108, 0, 0, 296, 297, 5, 115, 0, 0, 297, 298, 5, 101, 0, 0, 298, 19, 1, 0, 0, 0, 299, 300, 5, 110, 0, 0, 300, 301, 5, 117, 0, 0, 301, 302, 5, 108, 0, 0, 302, 303, 5, 108, 0, 0, 303, 21, 1, 0, 0, 0, 304, 305, 5, 58, 0, 0, 305, 23, 1, 0, 0, 0, 306, 307, 5, 44, 0, 0, 307, 25, 1, 0, 0, 0, 308, 309, 5, 42, 0, 0, 309, 27, 1, 0, 0, 0, 310, 311, 5, 123, 0, 0, 311, 29, 1, 0, 0, 0, 312, 313, 5, 125, 0, 0, 313, 31, 1, 0, 0, 0, 314, 315, 5, 91, 0, 0, 315, 33, 1, 0, 0, 0, 316, 317, 5, 93, 0, 0, 317, 35, 1, 0, 0, 0, 318, 319, 5, 40, 0, 0, 319, 37, 1, 0, 0, 0, 320, 321, 5, 41, 0, 0, 321, 39, 1, 0, 0, 0, 322, 323, 5, 63, 0, 0, 323, 41, 1, 0, 0, 0, 324, 325, 5, 33, 0, 0, 325, 43, 1, 0, 0, 0, 326, 331, 3, 54, 26, 0, 327, 328, 5, 46, 0, 0, 328, 330, 3, 54, 26, 0, 329, 327, 1, 0, 0, 0, 330, 333, 1, 0, 0, 0, 331, 329, 1, 0, 0, 0, 331, 332, 1, 0, 0, 0, 332, 45, 1, 0, 0, 0, 333, 331, 1, 0, 0, 0, 334, 335, 5, 36, 0, 0, 335, 336, 3, 54, 26, 0, 336, 47, 1, 0, 0, 0, 337, 339, 5, 35, 0, 0, 338, 340, 3, 56, 27, 0, 339, 338, 1, 0, 0, 0, 340, 341, 1, 0, 0, 0, 341, 339, 1, 0, 0, 0, 341, 342, 1, 0, 0, 0, 342, 49, 1, 0, 0, 0, 343, 344, 5, 64, 0, 0, 344, 345, 3, 54, 26, 0, 345, 51, 1, 0, 0, 0, 346, 347, 5, 38, 0, 0, 347, 348, 3, 54, 26, 0, 348, 53, 1, 0, 0, 0, 349, 353, 3, 56, 27, 0, 350, 352, 3, 58, 28, 0, 351, 350, 1, 0, 0, 0, 352, 355, 1, 0, 0, 0, 353, 351, 1, 0, 0, 0, 353, 354, 1, 0, 0, 0, 354, 55, 1, 0, 0, 0, 355, 353, 1, 0, 0, 0, 356, 357, 7, 0, 0, 0, 357, 57, 1, 0, 0, 0, 358, 359, 7, 1, 0, 0, 359, 59, 1, 0, 0, 0, 360, 365, 5, 34, 0, 0, 361, 364, 3, 62, 30, 0, 362, 364, 3, 68, 33, 0, 363, 361, 1, 0, 0, 0, 363, 362, 1, 0, 0, 0, 364, 367, 1, 0, 0, 0, 365, 363, 1, 0, 0, 0, 365, 366, 1, 0, 0, 0, 366, 368, 1, 0, 0, 0, 367, 365, 1, 0, 0, 0, 368, 369, 5, 34, 0, 0, 369, 61, 1, 0, 0, 0, 370, 373, 5, 92, 0, 0, 371, 374, 7, 2, 0, 0, 372, 374, 3, 64, 31, 0, 373, 371, 1, 0, 0, 0, 373, 372, 1, 0, 0, 0, 374, 63, 1, 0, 0, 0, 375, 376, 5, 117, 0, 0, 376, 377, 3, 66, 32, 0, 377, 378, 3, 66, 32, 0, 378, 379, 3, 66, 32, 0, 379, 380, 3, 66, 32, 0, 380, 65, 1, 0, 0, 0, 381, 382, 7, 3, 0, 0, 382, 67, 1, 0, 0, 0, 383, 384, 8, 4, 0, 0, 384, 69, 1, 0, 0, 0, 385, 387, 5, 45, 0, 0, 386, 385, 1, 0, 0, 0, 386, 387, 1, 0, 0, 0, 387, 388, 1, 0, 0, 0, 388, 389, 3, 78, 38, 0, 389, 71, 1, 0, 0, 0, 390, 391, 3, 70, 34, 0, 391, 392, 3, 76, 37, 0, 392, 73, 1, 0, 0, 0, 393, 395, 3, 70, 34, 0, 394, 396, 3, 76, 37, 0, 395, 394, 1, 0, 0, 0, 395, 396, 1, 0, 0, 0, 396, 397, 1, 0, 0, 0, 397, 398, 3, 80, 39, 0, 398, 75, 1, 0, 0, 0, 399, 401, 5, 46, 0, 0, 400, 402, 3, 82, 40, 0, 401, 400, 1, 0, 0, 0, 402, 403, 1, 0, 0, 0, 403, 401, 1, 0, 0, 0, 403, 404, 1, 0, 0, 0, 404, 77, 1, 0, 0, 0, 405, 414, 5, 48, 0, 0, 406, 410, 7, 5, 0, 0, 407, 409, 3, 82, 40, 0, 408, 407, 1, 0, 0, 0, 409, 412, 1, 0, 0, 0, 410, 408, 1, 0, 0, 0, 410, 411, 1, 0, 0, 0, 411, 414, 1, 0, 0, 0, 412, 410, 1, 0, 0, 0, 413, 405, 1, 0, 0, 0, 413, 406, 1, 0, 0, 0, 414, 79, 1, 0, 0, 0, 415, 417, 7, 6, 0, 0, 416, 418, 7, 7, 0, 0, 417, 416, 1, 0, 0, 0, 417, 418, 1, 0, 0, 0, 418, 420, 1, 0, 0, 0, 419, 421, 3, 82, 40, 0, 420, 419, 1, 0, 0, 0, 421, 422, 1, 0, 0, 0, 422, 420, 1, 0, 0, 0, 422, 423, 1, 0, 0, 0, 423, 81, 1, 0, 0, 0, 424, 425, 7, 8, 0, 0, 425, 83, 1, 0, 0, 0, 426, 428, 7, 9, 0, 0, 427, 426, 1, 0, 0, 0, 428, 429, 1, 0, 0, 0, 429, 427, 1, 0, 0, 0, 429, 430, 1, 0, 0, 0, 430, 431, 1, 0, 0, 0, 431, 432, 6, 41, 1, 0, 432, 85, 1, 0, 0, 0, 433, 434, 5, 47, 0, 0, 434, 435, 5, 42, 0, 0, 435, 439, 1, 0, 0, 0, 436, 438, 9, 0, 0, 0, 437, 436, 1, 0, 0, 0, 438, 441, 1, 0, 0, 0, 439, 440, 1, 0, 0, 0, 439, 437, 1, 0, 0, 0, 440, 442, 1, 0, 0, 0, 441, 439, 1, 0, 0, 0, 442, 443, 5, 42, 0, 0, 443, 444, 5, 47, 0, 0, 444, 445, 1, 0, 0, 0, 445, 446, 6, 42, 1, 0, 446, 87, 1, 0, 0, 0, 447, 448, 5, 47, 0, 0, 448, 449, 5, 47, 0, 0, 449, 453, 1, 0, 0, 0, 450, 452, 8, 10, 0, 0, 451, 450, 1, 0, 0, 0, 452, 455, 1, 0, 0, 0, 453, 451, 1, 0, 0, 0, 453, 454, 1, 0, 0, 0, 454, 456, 1, 0, 0, 0, 455, 453, 1, 0, 0, 0, 456, 457, 6, 43, 1, 0, 457, 89, 1, 0, 0, 0, 458, 459, 5, 118, 0, 0, 459, 460, 5, 97, 0, 0, 460, 461, 5, 114, 0, 0, 461, 91, 1, 0, 0, 0, 462, 463, 5, 105, 0, 0, 463, 464, 5, 102, 0, 0, 464, 93, 1, 0, 0, 0, 465, 466, 5, 101, 0, 0, 466, 467, 5, 108, 0, 0, 467, 468, 5, 115, 0, 0, 468, 469, 5, 101, 0, 0, 469, 95, 1, 0, 0, 0, 470, 471, 5, 119, 0, 0, 471, 472, 5, 104, 0, 0, 472, 473, 5, 105, 0, 0, 473, 474, 5, 108, 0, 0, 474, 475, 5, 101, 0, 0, 475, 97, 1, 0, 0, 0, 476, 477, 5, 102, 0, 0, 477, 478, 5, 111, 0, 0, 478, 479, 5, 114, 0, 0, 479, 99, 1, 0, 0, 0, 480, 481, 5, 102, 0, 0, 481, 482, 5, 111, 0, 0, 482, 483, 5, 114, 0, 0, 483, 484, 5, 101, 0, 0, 484, 485, 5, 97, 0, 0, 485, 486, 5, 99, 0, 0, 486, 487, 5, 104, 0, 0, 487, 101, 1, 0, 0, 0, 488, 489, 5, 105, 0, 0, 489, 490, 5, 110, 0, 0, 490, 103, 1, 0, 0, 0, 491, 492, 5, 98, 0, 0, 492, 493, 5, 114, 0, 0, 493, 494, 5, 101, 0, 0, 494, 495, 5, 97, 0, 0, 495, 496, 5, 107, 0, 0, 496, 105, 1, 0, 0, 0, 497, 498, 5, 99, 0, 0, 498, 499, 5, 111, 0, 0, 499, 500, 5, 110, 0, 0, 500, 501, 5, 115, 0, 0, 501, 502, 5, 116, 0, 0, 502, 503, 5, 114, 0, 0, 503, 504, 5, 97, 0, 0, 504, 505, 5, 105, 0, 0, 505, 506, 5, 110, 0, 0, 506, 507, 5, 116, 0, 0, 507, 107, 1, 0, 0, 0, 508, 509, 5, 116, 0, 0, 509, 510, 5, 97, 0, 0, 510, 511, 5, 114, 0, 0, 511, 512, 5, 103, 0, 0, 512, 513, 5, 101, 0, 0, 513, 514, 5, 116, 0, 0, 514, 109, 1, 0, 0, 0, 515, 516, 5, 99, 0, 0, 516, 517, 5, 97, 0, 0, 517, 518, 5, 108, 0, 0, 518, 519, 5, 108, 0, 0, 519, 520, 5, 101, 0, 0, 520, 521, 5, 114, 0, 0, 521, 111, 1, 0, 0, 0, 522, 523, 5, 115, 0, 0, 523, 524, 5, 117, 0, 0, 524, 525, 5, 98, 0, 0, 525, 526, 5, 114, 0, 0, 526, 527, 5, 111, 0, 0, 527, 528, 5, 117, 0, 0, 528, 529, 5, 116, 0, 0, 529, 530, 5, 105, 0, 0, 530, 531, 5, 110, 0, 0, 531, 532, 5, 101, 0, 0, 532, 113, 1, 0, 0, 0, 533, 534, 5, 116, 0, 0, 534, 535, 5, 114, 0, 0, 535, 536, 5, 121, 0, 0, 536, 537, 5, 111, 0, 0, 537, 538, 5, 102, 0, 0, 538, 115, 1, 0, 0, 0, 539, 540, 5, 116, 0, 0, 540, 541, 5, 104, 0, 0, 541, 542, 5, 114, 0, 0, 542, 543, 5, 111, 0, 0, 543, 544, 5, 119, 0, 0, 544, 117, 1, 0, 0, 0, 545, 546, 5, 102, 0, 0, 546, 547, 5, 117, 0, 0, 547, 548, 5, 110, 0, 0, 548, 549, 5, 99, 0, 0, 549, 550, 5, 116, 0, 0, 550, 551, 5, 105, 0, 0, 551, 552, 5, 111, 0, 0, 552, 553, 5, 110, 0, 0, 553, 119, 1, 0, 0, 0, 554, 555, 5, 114, 0, 0, 555, 556, 5, 101, 0, 0, 556, 557, 5, 116, 0, 0, 557, 558, 5, 117, 0, 0, 558, 559, 5, 114, 0, 0, 559, 560, 5, 110, 0, 0, 560, 121, 1, 0, 0, 0, 561, 562, 5, 102, 0, 0, 562, 563, 5, 117, 0, 0, 563, 564, 5, 116, 0, 0, 564, 565, 5, 117, 0, 0, 565, 566, 5, 114, 0, 0, 566, 567, 5, 101, 0, 0, 567, 123, 1, 0, 0, 0, 568, 569, 5, 116, 0, 0, 569, 570, 5, 114, 0, 0, 570, 571, 5, 117, 0, 0, 571, 572, 5, 101, 0, 0, 572, 125, 1, 0, 0, 0, 573, 574, 5, 102, 0, 0, 574, 575, 5, 97, 0, 0, 575, 576, 5, 108, 0, 0, 576, 577, 5, 115, 0, 0, 577, 578, 5, 101, 0, 0, 578, 127, 1, 0, 0, 0, 579, 580, 5, 110, 0, 0, 580, 581, 5, 117, 0, 0, 581, 582, 5, 108, 0, 0, 582, 583, 5, 108, 0, 0, 583, 129, 1, 0, 0, 0, 584, 585, 5, 117, 0, 0, 585, 586, 5, 110, 0, 0, 586, 587, 5, 100, 0, 0, 587, 588, 5, 101, 0, 0, 588, 589, 5, 102, 0, 0, 589, 590, 5, 105, 0, 0, 590, 591, 5, 110, 0, 0, 591, 592, 5, 101, 0, 0, 592, 593, 5, 100, 0, 0, 593, 131, 1, 0, 0, 0, 594, 595, 5, 116, 0, 0, 595, 596, 5, 104, 0, 0, 596, 597, 5, 105, 0, 0, 597, 598, 5, 115, 0, 0, 598, 133, 1, 0, 0, 0, 599, 600, 5, 110, 0, 0, 600, 601, 5, 101, 0, 0, 601, 602, 5, 119, 0, 0, 602, 135, 1, 0, 0, 0, 603, 604, 5, 99, 0, 0, 604, 605, 5, 111, 0, 0, 605, 606, 5, 110, 0, 0, 606, 607, 5, 116, 0, 0, 607, 608, 5, 105, 0, 0, 608, 609, 5, 110, 0, 0, 609, 610, 5, 117, 0, 0, 610, 611, 5, 101, 0, 0, 611, 137, 1, 0, 0, 0, 612, 613, 5, 100, 0, 0, 613, 614, 5, 111, 0, 0, 614, 139, 1, 0, 0, 0, 615, 616, 5, 99, 0, 0, 616, 617, 5, 111, 0, 0, 617, 618, 5, 110, 0, 0, 618, 619, 5, 115, 0, 0, 619, 620, 5, 116, 0, 0, 620, 141, 1, 0, 0, 0, 621, 622, 5, 115, 0, 0, 622, 623, 5, 119, 0, 0, 623, 624, 5, 105, 0, 0, 624, 625, 5, 116, 0, 0, 625, 626, 5, 99, 0, 0, 626, 627, 5, 104, 0, 0, 627, 143, 1, 0, 0, 0, 628, 629, 5, 99, 0, 0, 629, 630, 5, 97, 0, 0, 630, 631, 5, 115, 0, 0, 631, 632, 5, 101, 0, 0, 632, 145, 1, 0, 0, 0, 633, 634, 5, 105, 0, 0, 634, 635, 5, 109, 0, 0, 635, 636, 5, 112, 0, 0, 636, 637, 5, 111, 0, 0, 637, 638, 5, 114, 0, 0, 638, 639, 5, 116, 0, 0, 639, 147, 1, 0, 0, 0, 640, 641, 5, 99, 0, 0, 641, 642, 5, 108, 0, 0, 642, 643, 5, 97, 0, 0, 643, 644, 5, 115, 0, 0, 644, 645, 5, 115, 0, 0, 645, 149, 1, 0, 0, 0, 646, 647, 5, 115, 0, 0, 647, 648, 5, 117, 0, 0, 648, 649, 5, 112, 0, 0, 649, 650, 5, 101, 0, 0, 650, 651, 5, 114, 0, 0, 651, 151, 1, 0, 0, 0, 652, 653, 5, 100, 0, 0, 653, 654, 5, 101, 0, 0, 654, 655, 5, 102, 0, 0, 655, 656, 5, 97, 0, 0, 656, 657, 5, 117, 0, 0, 657, 658, 5, 108, 0, 0, 658, 659, 5, 116, 0, 0, 659, 153, 1, 0, 0, 0, 660, 661, 3, 70, 34, 0, 661, 155, 1, 0, 0, 0, 662, 664, 3, 70, 34, 0, 663, 665, 3, 76, 37, 0, 664, 663, 1, 0, 0, 0, 664, 665, 1, 0, 0, 0, 665, 667, 1, 0, 0, 0, 666, 668, 3, 80, 39, 0, 667, 666, 1, 0, 0, 0, 667, 668, 1, 0, 0, 0, 668, 157, 1, 0, 0, 0, 669, 670, 3, 60, 29, 0, 670, 159, 1, 0, 0, 0, 671, 672, 3, 54, 26, 0, 672, 161, 1, 0, 0, 0, 673, 674, 5, 123, 0, 0, 674, 163, 1, 0, 0, 0, 675, 676, 5, 125, 0, 0, 676, 165, 1, 0, 0, 0, 677, 678, 5, 91, 0, 0, 678, 167, 1, 0, 0, 0, 679, 680, 5, 93, 0, 0, 680, 169, 1, 0, 0, 0, 681, 682, 5, 40, 0, 0, 682, 171, 1, 0, 0, 0, 683, 684, 5, 41, 0, 0, 684, 173, 1, 0, 0, 0, 685, 686, 5, 59, 0, 0, 686, 175, 1, 0, 0, 0, 687, 688, 5, 44, 0, 0, 688, 177, 1, 0, 0, 0, 689, 690, 5, 46, 0, 0, 690, 179, 1, 0, 0, 0, 691, 692, 5, 58, 0, 0, 692, 181, 1, 0, 0, 0, 693, 694, 5, 46, 0, 0, 694, 695, 5, 46, 0, 0, 695, 183, 1, 0, 0, 0, 696, 697, 5, 46, 0, 0, 697, 698, 5, 46, 0, 0, 698, 699, 5, 46, 0, 0, 699, 185, 1, 0, 0, 0, 700, 701, 5, 61, 0, 0, 701, 187, 1, 0, 0, 0, 702, 703, 5, 43, 0, 0, 703, 704, 5, 43, 0, 0, 704, 189, 1, 0, 0, 0, 705, 706, 5, 45, 0, 0, 706, 707, 5, 45, 0, 0, 707, 191, 1, 0, 0, 0, 708, 709, 5, 43, 0, 0, 709, 193, 1, 0, 0, 0, 710, 711, 5, 45, 0, 0, 711, 195, 1, 0, 0, 0, 712, 713, 5, 42, 0, 0, 713, 197, 1, 0, 0, 0, 714, 715, 5, 47, 0, 0, 715, 199, 1, 0, 0, 0, 716, 717, 5, 62, 0, 0, 717, 201, 1, 0, 0, 0, 718, 719, 5, 60, 0, 0, 719, 203, 1, 0, 0, 0, 720, 721, 5, 60, 0, 0, 721, 722, 5, 61, 0, 0, 722, 205, 1, 0, 0, 0, 723, 724, 5, 62, 0, 0, 724, 725, 5, 61, 0, 0, 725, 207, 1, 0, 0, 0, 726, 727, 5, 61, 0, 0, 727, 728, 5, 61, 0, 0, 728, 209, 1, 0, 0, 0, 729, 730, 5, 33, 0, 0, 730, 731, 5, 61, 0, 0, 731, 211, 1, 0, 0, 0, 732, 733, 5, 33, 0, 0, 733, 213, 1, 0, 0, 0, 734, 735, 5, 38, 0, 0, 735, 736, 5, 38, 0, 0, 736, 215, 1, 0, 0, 0, 737, 738, 5, 124, 0, 0, 738, 739, 5, 124, 0, 0, 739, 217, 1, 0, 0, 0, 740, 741, 5, 37, 0, 0, 741, 742, 5, 100, 0, 0, 742, 743, 5, 101, 0, 0, 743, 744, 5, 102, 0, 0, 744, 745, 5, 105, 0, 0, 745, 746, 5, 110, 0, 0, 746, 747, 5, 101, 0, 0, 747, 748, 1, 0, 0, 0, 748, 749, 6, 108, 2, 0, 749, 750, 6, 108, 3, 0, 750, 219, 1, 0, 0, 0, 751, 752, 5, 37, 0, 0, 752, 753, 5, 115, 0, 0, 753, 754, 5, 99, 0, 0, 754, 755, 5, 104, 0, 0, 755, 756, 5, 101, 0, 0, 756, 757, 5, 109, 0, 0, 757, 758, 5, 97, 0, 0, 758, 759, 1, 0, 0, 0, 759, 760, 6, 109, 4, 0, 760, 761, 6, 109, 3, 0, 761, 221, 1, 0, 0, 0, 762, 763, 5, 37, 0, 0, 763, 764, 5, 115, 0, 0, 764, 765, 5, 99, 0, 0, 765, 766, 5, 114, 0, 0, 766, 767, 5, 105, 0, 0, 767, 768, 5, 112, 0, 0, 768, 769, 5, 116, 0, 0, 769, 770, 1, 0, 0, 0, 770, 771, 6, 110, 5, 0, 771, 223, 1, 0, 0, 0, 772, 773, 3, 84, 41, 0, 773, 774, 1, 0, 0, 0, 774, 775, 6, 111, 1, 0, 775, 225, 1, 0, 0, 0, 776, 777, 3, 86, 42, 0, 777, 778, 1, 0, 0, 0, 778, 779, 6, 112, 1, 0, 779, 227, 1, 0, 0, 0, 780, 781, 3, 88, 43, 0, 781, 782, 1, 0, 0, 0, 782, 783, 6, 113, 1, 0, 783, 229, 1, 0, 0, 0, 20, 0, 1, 331, 341, 353, 363, 365, 373, 386, 395, 403, 410, 413, 417, 422, 429, 439, 453, 664, 667, 6, 5, 1, 0, 0, 1, 0, 7, 5, 0, 4, 0, 0, 7, 6, 0, 7, 7, 0] \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.java b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.java index 84ce05e..b578a54 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.java +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaLexer.java @@ -162,7 +162,7 @@ public SchemaLexer(CharStream input) { public ATN getATN() { return _ATN; } public static final String _serializedATN = - "\u0004\u0000d\u0311\u0006\uffff\uffff\u0006\uffff\uffff\u0002\u0000\u0007"+ + "\u0004\u0000d\u0310\u0006\uffff\uffff\u0006\uffff\uffff\u0002\u0000\u0007"+ "\u0000\u0002\u0001\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007"+ "\u0003\u0002\u0004\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007"+ "\u0006\u0002\u0007\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n"+ @@ -252,380 +252,379 @@ public SchemaLexer(CharStream input) { "i\u0001j\u0001j\u0001j\u0001k\u0001k\u0001k\u0001l\u0001l\u0001l\u0001"+ "l\u0001l\u0001l\u0001l\u0001l\u0001l\u0001l\u0001l\u0001m\u0001m\u0001"+ "m\u0001m\u0001m\u0001m\u0001m\u0001m\u0001m\u0001m\u0001m\u0001n\u0001"+ - "n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001"+ - "o\u0001o\u0001o\u0001o\u0001p\u0001p\u0001p\u0001p\u0001q\u0001q\u0001"+ - "q\u0001q\u0001\u01b7\u0000r\u0002\u0001\u0004\u0002\u0006\u0003\b\u0004"+ - "\n\u0005\f\u0006\u000e\u0007\u0010\b\u0012\t\u0014\n\u0016\u000b\u0018"+ - "\f\u001a\r\u001c\u000e\u001e\u000f \u0010\"\u0011$\u0012&\u0013(\u0014"+ - "*\u0015,\u0016.\u00170\u00182\u00194\u001a6\u00008\u0000:\u0000<\u001b"+ - ">\u0000@\u0000B\u0000D\u0000F\u001cH\u001dJ\u001eL\u0000N\u0000P\u0000"+ - "R\u0000T\u001fV X!Z\"\\#^$`%b&d\'f(h)j*l+n,p-r.t/v0x1z2|3~4\u00805\u0082"+ - "6\u00847\u00868\u00889\u008a:\u008c;\u008e<\u0090=\u0092>\u0094?\u0096"+ - "@\u0098A\u009aB\u009cC\u009eD\u00a0E\u00a2F\u00a4G\u00a6H\u00a8I\u00aa"+ - "J\u00acK\u00aeL\u00b0M\u00b2N\u00b4O\u00b6P\u00b8Q\u00baR\u00bcS\u00be"+ - "T\u00c0U\u00c2V\u00c4W\u00c6X\u00c8Y\u00caZ\u00cc[\u00ce\\\u00d0]\u00d2"+ - "^\u00d4_\u00d6`\u00d8a\u00da\u0000\u00dc\u0000\u00de\u0000\u00e0b\u00e2"+ - "c\u00e4d\u0002\u0000\u0001\u000b\u0003\u0000AZ__az\u0004\u000009AZ__a"+ - "z\b\u0000\"\"//\\\\bbffnnrrtt\u0003\u000009AFaf\u0003\u0000\u0000\u001f"+ - "\"\"\\\\\u0001\u000019\u0002\u0000EEee\u0002\u0000++--\u0001\u000009\u0003"+ - "\u0000\t\n\r\r \u0002\u0000\n\n\r\r\u0316\u0000\u0002\u0001\u0000\u0000"+ - "\u0000\u0000\u0004\u0001\u0000\u0000\u0000\u0000\u0006\u0001\u0000\u0000"+ - "\u0000\u0000\b\u0001\u0000\u0000\u0000\u0000\n\u0001\u0000\u0000\u0000"+ - "\u0000\f\u0001\u0000\u0000\u0000\u0000\u000e\u0001\u0000\u0000\u0000\u0000"+ - "\u0010\u0001\u0000\u0000\u0000\u0000\u0012\u0001\u0000\u0000\u0000\u0000"+ - "\u0014\u0001\u0000\u0000\u0000\u0000\u0016\u0001\u0000\u0000\u0000\u0000"+ - "\u0018\u0001\u0000\u0000\u0000\u0000\u001a\u0001\u0000\u0000\u0000\u0000"+ - "\u001c\u0001\u0000\u0000\u0000\u0000\u001e\u0001\u0000\u0000\u0000\u0000"+ - " \u0001\u0000\u0000\u0000\u0000\"\u0001\u0000\u0000\u0000\u0000$\u0001"+ - "\u0000\u0000\u0000\u0000&\u0001\u0000\u0000\u0000\u0000(\u0001\u0000\u0000"+ - "\u0000\u0000*\u0001\u0000\u0000\u0000\u0000,\u0001\u0000\u0000\u0000\u0000"+ - ".\u0001\u0000\u0000\u0000\u00000\u0001\u0000\u0000\u0000\u00002\u0001"+ - "\u0000\u0000\u0000\u00004\u0001\u0000\u0000\u0000\u0000<\u0001\u0000\u0000"+ - "\u0000\u0000F\u0001\u0000\u0000\u0000\u0000H\u0001\u0000\u0000\u0000\u0000"+ - "J\u0001\u0000\u0000\u0000\u0000T\u0001\u0000\u0000\u0000\u0000V\u0001"+ - "\u0000\u0000\u0000\u0000X\u0001\u0000\u0000\u0000\u0001Z\u0001\u0000\u0000"+ - "\u0000\u0001\\\u0001\u0000\u0000\u0000\u0001^\u0001\u0000\u0000\u0000"+ - "\u0001`\u0001\u0000\u0000\u0000\u0001b\u0001\u0000\u0000\u0000\u0001d"+ - "\u0001\u0000\u0000\u0000\u0001f\u0001\u0000\u0000\u0000\u0001h\u0001\u0000"+ - "\u0000\u0000\u0001j\u0001\u0000\u0000\u0000\u0001l\u0001\u0000\u0000\u0000"+ - "\u0001n\u0001\u0000\u0000\u0000\u0001p\u0001\u0000\u0000\u0000\u0001r"+ - "\u0001\u0000\u0000\u0000\u0001t\u0001\u0000\u0000\u0000\u0001v\u0001\u0000"+ - "\u0000\u0000\u0001x\u0001\u0000\u0000\u0000\u0001z\u0001\u0000\u0000\u0000"+ - "\u0001|\u0001\u0000\u0000\u0000\u0001~\u0001\u0000\u0000\u0000\u0001\u0080"+ - "\u0001\u0000\u0000\u0000\u0001\u0082\u0001\u0000\u0000\u0000\u0001\u0084"+ - "\u0001\u0000\u0000\u0000\u0001\u0086\u0001\u0000\u0000\u0000\u0001\u0088"+ - "\u0001\u0000\u0000\u0000\u0001\u008a\u0001\u0000\u0000\u0000\u0001\u008c"+ - "\u0001\u0000\u0000\u0000\u0001\u008e\u0001\u0000\u0000\u0000\u0001\u0090"+ - "\u0001\u0000\u0000\u0000\u0001\u0092\u0001\u0000\u0000\u0000\u0001\u0094"+ - "\u0001\u0000\u0000\u0000\u0001\u0096\u0001\u0000\u0000\u0000\u0001\u0098"+ - "\u0001\u0000\u0000\u0000\u0001\u009a\u0001\u0000\u0000\u0000\u0001\u009c"+ - "\u0001\u0000\u0000\u0000\u0001\u009e\u0001\u0000\u0000\u0000\u0001\u00a0"+ - "\u0001\u0000\u0000\u0000\u0001\u00a2\u0001\u0000\u0000\u0000\u0001\u00a4"+ - "\u0001\u0000\u0000\u0000\u0001\u00a6\u0001\u0000\u0000\u0000\u0001\u00a8"+ - "\u0001\u0000\u0000\u0000\u0001\u00aa\u0001\u0000\u0000\u0000\u0001\u00ac"+ - "\u0001\u0000\u0000\u0000\u0001\u00ae\u0001\u0000\u0000\u0000\u0001\u00b0"+ - "\u0001\u0000\u0000\u0000\u0001\u00b2\u0001\u0000\u0000\u0000\u0001\u00b4"+ - "\u0001\u0000\u0000\u0000\u0001\u00b6\u0001\u0000\u0000\u0000\u0001\u00b8"+ - "\u0001\u0000\u0000\u0000\u0001\u00ba\u0001\u0000\u0000\u0000\u0001\u00bc"+ - "\u0001\u0000\u0000\u0000\u0001\u00be\u0001\u0000\u0000\u0000\u0001\u00c0"+ - "\u0001\u0000\u0000\u0000\u0001\u00c2\u0001\u0000\u0000\u0000\u0001\u00c4"+ - "\u0001\u0000\u0000\u0000\u0001\u00c6\u0001\u0000\u0000\u0000\u0001\u00c8"+ - "\u0001\u0000\u0000\u0000\u0001\u00ca\u0001\u0000\u0000\u0000\u0001\u00cc"+ - "\u0001\u0000\u0000\u0000\u0001\u00ce\u0001\u0000\u0000\u0000\u0001\u00d0"+ - "\u0001\u0000\u0000\u0000\u0001\u00d2\u0001\u0000\u0000\u0000\u0001\u00d4"+ - "\u0001\u0000\u0000\u0000\u0001\u00d6\u0001\u0000\u0000\u0000\u0001\u00d8"+ - "\u0001\u0000\u0000\u0000\u0001\u00da\u0001\u0000\u0000\u0000\u0001\u00dc"+ - "\u0001\u0000\u0000\u0000\u0001\u00de\u0001\u0000\u0000\u0000\u0001\u00e0"+ - "\u0001\u0000\u0000\u0000\u0001\u00e2\u0001\u0000\u0000\u0000\u0001\u00e4"+ - "\u0001\u0000\u0000\u0000\u0002\u00e6\u0001\u0000\u0000\u0000\u0004\u00ed"+ - "\u0001\u0000\u0000\u0000\u0006\u00f6\u0001\u0000\u0000\u0000\b\u00fe\u0001"+ - "\u0000\u0000\u0000\n\u0106\u0001\u0000\u0000\u0000\f\u010e\u0001\u0000"+ - "\u0000\u0000\u000e\u0116\u0001\u0000\u0000\u0000\u0010\u0120\u0001\u0000"+ - "\u0000\u0000\u0012\u0125\u0001\u0000\u0000\u0000\u0014\u012b\u0001\u0000"+ - "\u0000\u0000\u0016\u0130\u0001\u0000\u0000\u0000\u0018\u0132\u0001\u0000"+ - "\u0000\u0000\u001a\u0134\u0001\u0000\u0000\u0000\u001c\u0136\u0001\u0000"+ - "\u0000\u0000\u001e\u0138\u0001\u0000\u0000\u0000 \u013a\u0001\u0000\u0000"+ - "\u0000\"\u013c\u0001\u0000\u0000\u0000$\u013e\u0001\u0000\u0000\u0000"+ - "&\u0140\u0001\u0000\u0000\u0000(\u0142\u0001\u0000\u0000\u0000*\u0144"+ - "\u0001\u0000\u0000\u0000,\u0146\u0001\u0000\u0000\u0000.\u014e\u0001\u0000"+ - "\u0000\u00000\u0151\u0001\u0000\u0000\u00002\u0157\u0001\u0000\u0000\u0000"+ - "4\u015a\u0001\u0000\u0000\u00006\u015d\u0001\u0000\u0000\u00008\u0164"+ - "\u0001\u0000\u0000\u0000:\u0166\u0001\u0000\u0000\u0000<\u0168\u0001\u0000"+ - "\u0000\u0000>\u0172\u0001\u0000\u0000\u0000@\u0177\u0001\u0000\u0000\u0000"+ - "B\u017d\u0001\u0000\u0000\u0000D\u017f\u0001\u0000\u0000\u0000F\u0182"+ - "\u0001\u0000\u0000\u0000H\u0186\u0001\u0000\u0000\u0000J\u0189\u0001\u0000"+ - "\u0000\u0000L\u018f\u0001\u0000\u0000\u0000N\u019d\u0001\u0000\u0000\u0000"+ - "P\u019f\u0001\u0000\u0000\u0000R\u01a8\u0001\u0000\u0000\u0000T\u01ab"+ - "\u0001\u0000\u0000\u0000V\u01b1\u0001\u0000\u0000\u0000X\u01bf\u0001\u0000"+ - "\u0000\u0000Z\u01ca\u0001\u0000\u0000\u0000\\\u01ce\u0001\u0000\u0000"+ - "\u0000^\u01d1\u0001\u0000\u0000\u0000`\u01d6\u0001\u0000\u0000\u0000b"+ - "\u01dc\u0001\u0000\u0000\u0000d\u01e0\u0001\u0000\u0000\u0000f\u01e8\u0001"+ - "\u0000\u0000\u0000h\u01eb\u0001\u0000\u0000\u0000j\u01f1\u0001\u0000\u0000"+ - "\u0000l\u01fc\u0001\u0000\u0000\u0000n\u0203\u0001\u0000\u0000\u0000p"+ - "\u020a\u0001\u0000\u0000\u0000r\u0215\u0001\u0000\u0000\u0000t\u021b\u0001"+ - "\u0000\u0000\u0000v\u0221\u0001\u0000\u0000\u0000x\u022a\u0001\u0000\u0000"+ - "\u0000z\u0231\u0001\u0000\u0000\u0000|\u0238\u0001\u0000\u0000\u0000~"+ - "\u023d\u0001\u0000\u0000\u0000\u0080\u0243\u0001\u0000\u0000\u0000\u0082"+ - "\u0248\u0001\u0000\u0000\u0000\u0084\u0252\u0001\u0000\u0000\u0000\u0086"+ - "\u0257\u0001\u0000\u0000\u0000\u0088\u025b\u0001\u0000\u0000\u0000\u008a"+ - "\u0264\u0001\u0000\u0000\u0000\u008c\u0267\u0001\u0000\u0000\u0000\u008e"+ - "\u026d\u0001\u0000\u0000\u0000\u0090\u0274\u0001\u0000\u0000\u0000\u0092"+ - "\u0279\u0001\u0000\u0000\u0000\u0094\u0280\u0001\u0000\u0000\u0000\u0096"+ - "\u0286\u0001\u0000\u0000\u0000\u0098\u028c\u0001\u0000\u0000\u0000\u009a"+ - "\u0294\u0001\u0000\u0000\u0000\u009c\u0296\u0001\u0000\u0000\u0000\u009e"+ - "\u029d\u0001\u0000\u0000\u0000\u00a0\u029f\u0001\u0000\u0000\u0000\u00a2"+ - "\u02a1\u0001\u0000\u0000\u0000\u00a4\u02a3\u0001\u0000\u0000\u0000\u00a6"+ - "\u02a5\u0001\u0000\u0000\u0000\u00a8\u02a7\u0001\u0000\u0000\u0000\u00aa"+ - "\u02a9\u0001\u0000\u0000\u0000\u00ac\u02ab\u0001\u0000\u0000\u0000\u00ae"+ - "\u02ad\u0001\u0000\u0000\u0000\u00b0\u02af\u0001\u0000\u0000\u0000\u00b2"+ - "\u02b1\u0001\u0000\u0000\u0000\u00b4\u02b3\u0001\u0000\u0000\u0000\u00b6"+ - "\u02b5\u0001\u0000\u0000\u0000\u00b8\u02b8\u0001\u0000\u0000\u0000\u00ba"+ - "\u02bc\u0001\u0000\u0000\u0000\u00bc\u02be\u0001\u0000\u0000\u0000\u00be"+ - "\u02c1\u0001\u0000\u0000\u0000\u00c0\u02c4\u0001\u0000\u0000\u0000\u00c2"+ - "\u02c6\u0001\u0000\u0000\u0000\u00c4\u02c8\u0001\u0000\u0000\u0000\u00c6"+ - "\u02ca\u0001\u0000\u0000\u0000\u00c8\u02cc\u0001\u0000\u0000\u0000\u00ca"+ - "\u02ce\u0001\u0000\u0000\u0000\u00cc\u02d0\u0001\u0000\u0000\u0000\u00ce"+ - "\u02d3\u0001\u0000\u0000\u0000\u00d0\u02d6\u0001\u0000\u0000\u0000\u00d2"+ - "\u02d9\u0001\u0000\u0000\u0000\u00d4\u02dc\u0001\u0000\u0000\u0000\u00d6"+ - "\u02de\u0001\u0000\u0000\u0000\u00d8\u02e1\u0001\u0000\u0000\u0000\u00da"+ - "\u02e4\u0001\u0000\u0000\u0000\u00dc\u02ef\u0001\u0000\u0000\u0000\u00de"+ - "\u02fa\u0001\u0000\u0000\u0000\u00e0\u0305\u0001\u0000\u0000\u0000\u00e2"+ - "\u0309\u0001\u0000\u0000\u0000\u00e4\u030d\u0001\u0000\u0000\u0000\u00e6"+ - "\u00e7\u0005%\u0000\u0000\u00e7\u00e8\u0005t\u0000\u0000\u00e8\u00e9\u0005"+ - "i\u0000\u0000\u00e9\u00ea\u0005t\u0000\u0000\u00ea\u00eb\u0005l\u0000"+ - "\u0000\u00eb\u00ec\u0005e\u0000\u0000\u00ec\u0003\u0001\u0000\u0000\u0000"+ - "\u00ed\u00ee\u0005%\u0000\u0000\u00ee\u00ef\u0005v\u0000\u0000\u00ef\u00f0"+ - "\u0005e\u0000\u0000\u00f0\u00f1\u0005r\u0000\u0000\u00f1\u00f2\u0005s"+ - "\u0000\u0000\u00f2\u00f3\u0005i\u0000\u0000\u00f3\u00f4\u0005o\u0000\u0000"+ - "\u00f4\u00f5\u0005n\u0000\u0000\u00f5\u0005\u0001\u0000\u0000\u0000\u00f6"+ - "\u00f7\u0005%\u0000\u0000\u00f7\u00f8\u0005i\u0000\u0000\u00f8\u00f9\u0005"+ - "m\u0000\u0000\u00f9\u00fa\u0005p\u0000\u0000\u00fa\u00fb\u0005o\u0000"+ - "\u0000\u00fb\u00fc\u0005r\u0000\u0000\u00fc\u00fd\u0005t\u0000\u0000\u00fd"+ - "\u0007\u0001\u0000\u0000\u0000\u00fe\u00ff\u0005%\u0000\u0000\u00ff\u0100"+ - "\u0005p\u0000\u0000\u0100\u0101\u0005r\u0000\u0000\u0101\u0102\u0005a"+ - "\u0000\u0000\u0102\u0103\u0005g\u0000\u0000\u0103\u0104\u0005m\u0000\u0000"+ - "\u0104\u0105\u0005a\u0000\u0000\u0105\t\u0001\u0000\u0000\u0000\u0106"+ - "\u0107\u0005%\u0000\u0000\u0107\u0108\u0005d\u0000\u0000\u0108\u0109\u0005"+ - "e\u0000\u0000\u0109\u010a\u0005f\u0000\u0000\u010a\u010b\u0005i\u0000"+ - "\u0000\u010b\u010c\u0005n\u0000\u0000\u010c\u010d\u0005e\u0000\u0000\u010d"+ - "\u000b\u0001\u0000\u0000\u0000\u010e\u010f\u0005%\u0000\u0000\u010f\u0110"+ - "\u0005s\u0000\u0000\u0110\u0111\u0005c\u0000\u0000\u0111\u0112\u0005h"+ - "\u0000\u0000\u0112\u0113\u0005e\u0000\u0000\u0113\u0114\u0005m\u0000\u0000"+ - "\u0114\u0115\u0005a\u0000\u0000\u0115\r\u0001\u0000\u0000\u0000\u0116"+ - "\u0117\u0005%\u0000\u0000\u0117\u0118\u0005s\u0000\u0000\u0118\u0119\u0005"+ - "c\u0000\u0000\u0119\u011a\u0005r\u0000\u0000\u011a\u011b\u0005i\u0000"+ - "\u0000\u011b\u011c\u0005p\u0000\u0000\u011c\u011d\u0005t\u0000\u0000\u011d"+ - "\u011e\u0001\u0000\u0000\u0000\u011e\u011f\u0006\u0006\u0000\u0000\u011f"+ - "\u000f\u0001\u0000\u0000\u0000\u0120\u0121\u0005t\u0000\u0000\u0121\u0122"+ - "\u0005r\u0000\u0000\u0122\u0123\u0005u\u0000\u0000\u0123\u0124\u0005e"+ - "\u0000\u0000\u0124\u0011\u0001\u0000\u0000\u0000\u0125\u0126\u0005f\u0000"+ - "\u0000\u0126\u0127\u0005a\u0000\u0000\u0127\u0128\u0005l\u0000\u0000\u0128"+ - "\u0129\u0005s\u0000\u0000\u0129\u012a\u0005e\u0000\u0000\u012a\u0013\u0001"+ - "\u0000\u0000\u0000\u012b\u012c\u0005n\u0000\u0000\u012c\u012d\u0005u\u0000"+ - "\u0000\u012d\u012e\u0005l\u0000\u0000\u012e\u012f\u0005l\u0000\u0000\u012f"+ - "\u0015\u0001\u0000\u0000\u0000\u0130\u0131\u0005:\u0000\u0000\u0131\u0017"+ - "\u0001\u0000\u0000\u0000\u0132\u0133\u0005,\u0000\u0000\u0133\u0019\u0001"+ - "\u0000\u0000\u0000\u0134\u0135\u0005*\u0000\u0000\u0135\u001b\u0001\u0000"+ - "\u0000\u0000\u0136\u0137\u0005{\u0000\u0000\u0137\u001d\u0001\u0000\u0000"+ - "\u0000\u0138\u0139\u0005}\u0000\u0000\u0139\u001f\u0001\u0000\u0000\u0000"+ - "\u013a\u013b\u0005[\u0000\u0000\u013b!\u0001\u0000\u0000\u0000\u013c\u013d"+ - "\u0005]\u0000\u0000\u013d#\u0001\u0000\u0000\u0000\u013e\u013f\u0005("+ - "\u0000\u0000\u013f%\u0001\u0000\u0000\u0000\u0140\u0141\u0005)\u0000\u0000"+ - "\u0141\'\u0001\u0000\u0000\u0000\u0142\u0143\u0005?\u0000\u0000\u0143"+ - ")\u0001\u0000\u0000\u0000\u0144\u0145\u0005!\u0000\u0000\u0145+\u0001"+ - "\u0000\u0000\u0000\u0146\u014b\u00036\u001a\u0000\u0147\u0148\u0005.\u0000"+ - "\u0000\u0148\u014a\u00036\u001a\u0000\u0149\u0147\u0001\u0000\u0000\u0000"+ - "\u014a\u014d\u0001\u0000\u0000\u0000\u014b\u0149\u0001\u0000\u0000\u0000"+ - "\u014b\u014c\u0001\u0000\u0000\u0000\u014c-\u0001\u0000\u0000\u0000\u014d"+ - "\u014b\u0001\u0000\u0000\u0000\u014e\u014f\u0005$\u0000\u0000\u014f\u0150"+ - "\u00036\u001a\u0000\u0150/\u0001\u0000\u0000\u0000\u0151\u0153\u0005#"+ - "\u0000\u0000\u0152\u0154\u00038\u001b\u0000\u0153\u0152\u0001\u0000\u0000"+ - "\u0000\u0154\u0155\u0001\u0000\u0000\u0000\u0155\u0153\u0001\u0000\u0000"+ - "\u0000\u0155\u0156\u0001\u0000\u0000\u0000\u01561\u0001\u0000\u0000\u0000"+ - "\u0157\u0158\u0005@\u0000\u0000\u0158\u0159\u00036\u001a\u0000\u01593"+ - "\u0001\u0000\u0000\u0000\u015a\u015b\u0005&\u0000\u0000\u015b\u015c\u0003"+ - "6\u001a\u0000\u015c5\u0001\u0000\u0000\u0000\u015d\u0161\u00038\u001b"+ - "\u0000\u015e\u0160\u0003:\u001c\u0000\u015f\u015e\u0001\u0000\u0000\u0000"+ - "\u0160\u0163\u0001\u0000\u0000\u0000\u0161\u015f\u0001\u0000\u0000\u0000"+ - "\u0161\u0162\u0001\u0000\u0000\u0000\u01627\u0001\u0000\u0000\u0000\u0163"+ - "\u0161\u0001\u0000\u0000\u0000\u0164\u0165\u0007\u0000\u0000\u0000\u0165"+ - "9\u0001\u0000\u0000\u0000\u0166\u0167\u0007\u0001\u0000\u0000\u0167;\u0001"+ - "\u0000\u0000\u0000\u0168\u016d\u0005\"\u0000\u0000\u0169\u016c\u0003>"+ - "\u001e\u0000\u016a\u016c\u0003D!\u0000\u016b\u0169\u0001\u0000\u0000\u0000"+ - "\u016b\u016a\u0001\u0000\u0000\u0000\u016c\u016f\u0001\u0000\u0000\u0000"+ - "\u016d\u016b\u0001\u0000\u0000\u0000\u016d\u016e\u0001\u0000\u0000\u0000"+ - "\u016e\u0170\u0001\u0000\u0000\u0000\u016f\u016d\u0001\u0000\u0000\u0000"+ - "\u0170\u0171\u0005\"\u0000\u0000\u0171=\u0001\u0000\u0000\u0000\u0172"+ - "\u0175\u0005\\\u0000\u0000\u0173\u0176\u0007\u0002\u0000\u0000\u0174\u0176"+ - "\u0003@\u001f\u0000\u0175\u0173\u0001\u0000\u0000\u0000\u0175\u0174\u0001"+ - "\u0000\u0000\u0000\u0176?\u0001\u0000\u0000\u0000\u0177\u0178\u0005u\u0000"+ - "\u0000\u0178\u0179\u0003B \u0000\u0179\u017a\u0003B \u0000\u017a\u017b"+ - "\u0003B \u0000\u017b\u017c\u0003B \u0000\u017cA\u0001\u0000\u0000\u0000"+ - "\u017d\u017e\u0007\u0003\u0000\u0000\u017eC\u0001\u0000\u0000\u0000\u017f"+ - "\u0180\b\u0004\u0000\u0000\u0180E\u0001\u0000\u0000\u0000\u0181\u0183"+ - "\u0005-\u0000\u0000\u0182\u0181\u0001\u0000\u0000\u0000\u0182\u0183\u0001"+ - "\u0000\u0000\u0000\u0183\u0184\u0001\u0000\u0000\u0000\u0184\u0185\u0003"+ - "N&\u0000\u0185G\u0001\u0000\u0000\u0000\u0186\u0187\u0003F\"\u0000\u0187"+ - "\u0188\u0003L%\u0000\u0188I\u0001\u0000\u0000\u0000\u0189\u018b\u0003"+ - "F\"\u0000\u018a\u018c\u0003L%\u0000\u018b\u018a\u0001\u0000\u0000\u0000"+ - "\u018b\u018c\u0001\u0000\u0000\u0000\u018c\u018d\u0001\u0000\u0000\u0000"+ - "\u018d\u018e\u0003P\'\u0000\u018eK\u0001\u0000\u0000\u0000\u018f\u0191"+ - "\u0005.\u0000\u0000\u0190\u0192\u0003R(\u0000\u0191\u0190\u0001\u0000"+ - "\u0000\u0000\u0192\u0193\u0001\u0000\u0000\u0000\u0193\u0191\u0001\u0000"+ - "\u0000\u0000\u0193\u0194\u0001\u0000\u0000\u0000\u0194M\u0001\u0000\u0000"+ - "\u0000\u0195\u019e\u00050\u0000\u0000\u0196\u019a\u0007\u0005\u0000\u0000"+ - "\u0197\u0199\u0003R(\u0000\u0198\u0197\u0001\u0000\u0000\u0000\u0199\u019c"+ - "\u0001\u0000\u0000\u0000\u019a\u0198\u0001\u0000\u0000\u0000\u019a\u019b"+ - "\u0001\u0000\u0000\u0000\u019b\u019e\u0001\u0000\u0000\u0000\u019c\u019a"+ - "\u0001\u0000\u0000\u0000\u019d\u0195\u0001\u0000\u0000\u0000\u019d\u0196"+ - "\u0001\u0000\u0000\u0000\u019eO\u0001\u0000\u0000\u0000\u019f\u01a1\u0007"+ - "\u0006\u0000\u0000\u01a0\u01a2\u0007\u0007\u0000\u0000\u01a1\u01a0\u0001"+ - "\u0000\u0000\u0000\u01a1\u01a2\u0001\u0000\u0000\u0000\u01a2\u01a4\u0001"+ - "\u0000\u0000\u0000\u01a3\u01a5\u0003R(\u0000\u01a4\u01a3\u0001\u0000\u0000"+ - "\u0000\u01a5\u01a6\u0001\u0000\u0000\u0000\u01a6\u01a4\u0001\u0000\u0000"+ - "\u0000\u01a6\u01a7\u0001\u0000\u0000\u0000\u01a7Q\u0001\u0000\u0000\u0000"+ - "\u01a8\u01a9\u0007\b\u0000\u0000\u01a9S\u0001\u0000\u0000\u0000\u01aa"+ - "\u01ac\u0007\t\u0000\u0000\u01ab\u01aa\u0001\u0000\u0000\u0000\u01ac\u01ad"+ - "\u0001\u0000\u0000\u0000\u01ad\u01ab\u0001\u0000\u0000\u0000\u01ad\u01ae"+ - "\u0001\u0000\u0000\u0000\u01ae\u01af\u0001\u0000\u0000\u0000\u01af\u01b0"+ - "\u0006)\u0001\u0000\u01b0U\u0001\u0000\u0000\u0000\u01b1\u01b2\u0005/"+ - "\u0000\u0000\u01b2\u01b3\u0005*\u0000\u0000\u01b3\u01b7\u0001\u0000\u0000"+ - "\u0000\u01b4\u01b6\t\u0000\u0000\u0000\u01b5\u01b4\u0001\u0000\u0000\u0000"+ - "\u01b6\u01b9\u0001\u0000\u0000\u0000\u01b7\u01b8\u0001\u0000\u0000\u0000"+ - "\u01b7\u01b5\u0001\u0000\u0000\u0000\u01b8\u01ba\u0001\u0000\u0000\u0000"+ - "\u01b9\u01b7\u0001\u0000\u0000\u0000\u01ba\u01bb\u0005*\u0000\u0000\u01bb"+ - "\u01bc\u0005/\u0000\u0000\u01bc\u01bd\u0001\u0000\u0000\u0000\u01bd\u01be"+ - "\u0006*\u0001\u0000\u01beW\u0001\u0000\u0000\u0000\u01bf\u01c0\u0005/"+ - "\u0000\u0000\u01c0\u01c1\u0005/\u0000\u0000\u01c1\u01c5\u0001\u0000\u0000"+ - "\u0000\u01c2\u01c4\b\n\u0000\u0000\u01c3\u01c2\u0001\u0000\u0000\u0000"+ - "\u01c4\u01c7\u0001\u0000\u0000\u0000\u01c5\u01c3\u0001\u0000\u0000\u0000"+ - "\u01c5\u01c6\u0001\u0000\u0000\u0000\u01c6\u01c8\u0001\u0000\u0000\u0000"+ - "\u01c7\u01c5\u0001\u0000\u0000\u0000\u01c8\u01c9\u0006+\u0001\u0000\u01c9"+ - "Y\u0001\u0000\u0000\u0000\u01ca\u01cb\u0005v\u0000\u0000\u01cb\u01cc\u0005"+ - "a\u0000\u0000\u01cc\u01cd\u0005r\u0000\u0000\u01cd[\u0001\u0000\u0000"+ - "\u0000\u01ce\u01cf\u0005i\u0000\u0000\u01cf\u01d0\u0005f\u0000\u0000\u01d0"+ - "]\u0001\u0000\u0000\u0000\u01d1\u01d2\u0005e\u0000\u0000\u01d2\u01d3\u0005"+ - "l\u0000\u0000\u01d3\u01d4\u0005s\u0000\u0000\u01d4\u01d5\u0005e\u0000"+ - "\u0000\u01d5_\u0001\u0000\u0000\u0000\u01d6\u01d7\u0005w\u0000\u0000\u01d7"+ - "\u01d8\u0005h\u0000\u0000\u01d8\u01d9\u0005i\u0000\u0000\u01d9\u01da\u0005"+ - "l\u0000\u0000\u01da\u01db\u0005e\u0000\u0000\u01dba\u0001\u0000\u0000"+ - "\u0000\u01dc\u01dd\u0005f\u0000\u0000\u01dd\u01de\u0005o\u0000\u0000\u01de"+ - "\u01df\u0005r\u0000\u0000\u01dfc\u0001\u0000\u0000\u0000\u01e0\u01e1\u0005"+ - "f\u0000\u0000\u01e1\u01e2\u0005o\u0000\u0000\u01e2\u01e3\u0005r\u0000"+ - "\u0000\u01e3\u01e4\u0005e\u0000\u0000\u01e4\u01e5\u0005a\u0000\u0000\u01e5"+ - "\u01e6\u0005c\u0000\u0000\u01e6\u01e7\u0005h\u0000\u0000\u01e7e\u0001"+ - "\u0000\u0000\u0000\u01e8\u01e9\u0005i\u0000\u0000\u01e9\u01ea\u0005n\u0000"+ - "\u0000\u01eag\u0001\u0000\u0000\u0000\u01eb\u01ec\u0005b\u0000\u0000\u01ec"+ - "\u01ed\u0005r\u0000\u0000\u01ed\u01ee\u0005e\u0000\u0000\u01ee\u01ef\u0005"+ - "a\u0000\u0000\u01ef\u01f0\u0005k\u0000\u0000\u01f0i\u0001\u0000\u0000"+ - "\u0000\u01f1\u01f2\u0005c\u0000\u0000\u01f2\u01f3\u0005o\u0000\u0000\u01f3"+ - "\u01f4\u0005n\u0000\u0000\u01f4\u01f5\u0005s\u0000\u0000\u01f5\u01f6\u0005"+ - "t\u0000\u0000\u01f6\u01f7\u0005r\u0000\u0000\u01f7\u01f8\u0005a\u0000"+ - "\u0000\u01f8\u01f9\u0005i\u0000\u0000\u01f9\u01fa\u0005n\u0000\u0000\u01fa"+ - "\u01fb\u0005t\u0000\u0000\u01fbk\u0001\u0000\u0000\u0000\u01fc\u01fd\u0005"+ - "t\u0000\u0000\u01fd\u01fe\u0005a\u0000\u0000\u01fe\u01ff\u0005r\u0000"+ - "\u0000\u01ff\u0200\u0005g\u0000\u0000\u0200\u0201\u0005e\u0000\u0000\u0201"+ - "\u0202\u0005t\u0000\u0000\u0202m\u0001\u0000\u0000\u0000\u0203\u0204\u0005"+ - "c\u0000\u0000\u0204\u0205\u0005a\u0000\u0000\u0205\u0206\u0005l\u0000"+ - "\u0000\u0206\u0207\u0005l\u0000\u0000\u0207\u0208\u0005e\u0000\u0000\u0208"+ - "\u0209\u0005r\u0000\u0000\u0209o\u0001\u0000\u0000\u0000\u020a\u020b\u0005"+ - "s\u0000\u0000\u020b\u020c\u0005u\u0000\u0000\u020c\u020d\u0005b\u0000"+ - "\u0000\u020d\u020e\u0005r\u0000\u0000\u020e\u020f\u0005o\u0000\u0000\u020f"+ - "\u0210\u0005u\u0000\u0000\u0210\u0211\u0005t\u0000\u0000\u0211\u0212\u0005"+ - "i\u0000\u0000\u0212\u0213\u0005n\u0000\u0000\u0213\u0214\u0005e\u0000"+ - "\u0000\u0214q\u0001\u0000\u0000\u0000\u0215\u0216\u0005t\u0000\u0000\u0216"+ - "\u0217\u0005r\u0000\u0000\u0217\u0218\u0005y\u0000\u0000\u0218\u0219\u0005"+ - "o\u0000\u0000\u0219\u021a\u0005f\u0000\u0000\u021as\u0001\u0000\u0000"+ - "\u0000\u021b\u021c\u0005t\u0000\u0000\u021c\u021d\u0005h\u0000\u0000\u021d"+ - "\u021e\u0005r\u0000\u0000\u021e\u021f\u0005o\u0000\u0000\u021f\u0220\u0005"+ - "w\u0000\u0000\u0220u\u0001\u0000\u0000\u0000\u0221\u0222\u0005f\u0000"+ - "\u0000\u0222\u0223\u0005u\u0000\u0000\u0223\u0224\u0005n\u0000\u0000\u0224"+ - "\u0225\u0005c\u0000\u0000\u0225\u0226\u0005t\u0000\u0000\u0226\u0227\u0005"+ - "i\u0000\u0000\u0227\u0228\u0005o\u0000\u0000\u0228\u0229\u0005n\u0000"+ - "\u0000\u0229w\u0001\u0000\u0000\u0000\u022a\u022b\u0005r\u0000\u0000\u022b"+ - "\u022c\u0005e\u0000\u0000\u022c\u022d\u0005t\u0000\u0000\u022d\u022e\u0005"+ - "u\u0000\u0000\u022e\u022f\u0005r\u0000\u0000\u022f\u0230\u0005n\u0000"+ - "\u0000\u0230y\u0001\u0000\u0000\u0000\u0231\u0232\u0005f\u0000\u0000\u0232"+ - "\u0233\u0005u\u0000\u0000\u0233\u0234\u0005t\u0000\u0000\u0234\u0235\u0005"+ - "u\u0000\u0000\u0235\u0236\u0005r\u0000\u0000\u0236\u0237\u0005e\u0000"+ - "\u0000\u0237{\u0001\u0000\u0000\u0000\u0238\u0239\u0005t\u0000\u0000\u0239"+ - "\u023a\u0005r\u0000\u0000\u023a\u023b\u0005u\u0000\u0000\u023b\u023c\u0005"+ - "e\u0000\u0000\u023c}\u0001\u0000\u0000\u0000\u023d\u023e\u0005f\u0000"+ - "\u0000\u023e\u023f\u0005a\u0000\u0000\u023f\u0240\u0005l\u0000\u0000\u0240"+ - "\u0241\u0005s\u0000\u0000\u0241\u0242\u0005e\u0000\u0000\u0242\u007f\u0001"+ - "\u0000\u0000\u0000\u0243\u0244\u0005n\u0000\u0000\u0244\u0245\u0005u\u0000"+ - "\u0000\u0245\u0246\u0005l\u0000\u0000\u0246\u0247\u0005l\u0000\u0000\u0247"+ - "\u0081\u0001\u0000\u0000\u0000\u0248\u0249\u0005u\u0000\u0000\u0249\u024a"+ - "\u0005n\u0000\u0000\u024a\u024b\u0005d\u0000\u0000\u024b\u024c\u0005e"+ - "\u0000\u0000\u024c\u024d\u0005f\u0000\u0000\u024d\u024e\u0005i\u0000\u0000"+ - "\u024e\u024f\u0005n\u0000\u0000\u024f\u0250\u0005e\u0000\u0000\u0250\u0251"+ - "\u0005d\u0000\u0000\u0251\u0083\u0001\u0000\u0000\u0000\u0252\u0253\u0005"+ - "t\u0000\u0000\u0253\u0254\u0005h\u0000\u0000\u0254\u0255\u0005i\u0000"+ - "\u0000\u0255\u0256\u0005s\u0000\u0000\u0256\u0085\u0001\u0000\u0000\u0000"+ - "\u0257\u0258\u0005n\u0000\u0000\u0258\u0259\u0005e\u0000\u0000\u0259\u025a"+ - "\u0005w\u0000\u0000\u025a\u0087\u0001\u0000\u0000\u0000\u025b\u025c\u0005"+ - "c\u0000\u0000\u025c\u025d\u0005o\u0000\u0000\u025d\u025e\u0005n\u0000"+ - "\u0000\u025e\u025f\u0005t\u0000\u0000\u025f\u0260\u0005i\u0000\u0000\u0260"+ - "\u0261\u0005n\u0000\u0000\u0261\u0262\u0005u\u0000\u0000\u0262\u0263\u0005"+ - "e\u0000\u0000\u0263\u0089\u0001\u0000\u0000\u0000\u0264\u0265\u0005d\u0000"+ - "\u0000\u0265\u0266\u0005o\u0000\u0000\u0266\u008b\u0001\u0000\u0000\u0000"+ - "\u0267\u0268\u0005c\u0000\u0000\u0268\u0269\u0005o\u0000\u0000\u0269\u026a"+ - "\u0005n\u0000\u0000\u026a\u026b\u0005s\u0000\u0000\u026b\u026c\u0005t"+ - "\u0000\u0000\u026c\u008d\u0001\u0000\u0000\u0000\u026d\u026e\u0005s\u0000"+ - "\u0000\u026e\u026f\u0005w\u0000\u0000\u026f\u0270\u0005i\u0000\u0000\u0270"+ - "\u0271\u0005t\u0000\u0000\u0271\u0272\u0005c\u0000\u0000\u0272\u0273\u0005"+ - "h\u0000\u0000\u0273\u008f\u0001\u0000\u0000\u0000\u0274\u0275\u0005c\u0000"+ - "\u0000\u0275\u0276\u0005a\u0000\u0000\u0276\u0277\u0005s\u0000\u0000\u0277"+ - "\u0278\u0005e\u0000\u0000\u0278\u0091\u0001\u0000\u0000\u0000\u0279\u027a"+ - "\u0005i\u0000\u0000\u027a\u027b\u0005m\u0000\u0000\u027b\u027c\u0005p"+ - "\u0000\u0000\u027c\u027d\u0005o\u0000\u0000\u027d\u027e\u0005r\u0000\u0000"+ - "\u027e\u027f\u0005t\u0000\u0000\u027f\u0093\u0001\u0000\u0000\u0000\u0280"+ - "\u0281\u0005c\u0000\u0000\u0281\u0282\u0005l\u0000\u0000\u0282\u0283\u0005"+ - "a\u0000\u0000\u0283\u0284\u0005s\u0000\u0000\u0284\u0285\u0005s\u0000"+ - "\u0000\u0285\u0095\u0001\u0000\u0000\u0000\u0286\u0287\u0005s\u0000\u0000"+ - "\u0287\u0288\u0005u\u0000\u0000\u0288\u0289\u0005p\u0000\u0000\u0289\u028a"+ - "\u0005e\u0000\u0000\u028a\u028b\u0005r\u0000\u0000\u028b\u0097\u0001\u0000"+ - "\u0000\u0000\u028c\u028d\u0005d\u0000\u0000\u028d\u028e\u0005e\u0000\u0000"+ - "\u028e\u028f\u0005f\u0000\u0000\u028f\u0290\u0005a\u0000\u0000\u0290\u0291"+ - "\u0005u\u0000\u0000\u0291\u0292\u0005l\u0000\u0000\u0292\u0293\u0005t"+ - "\u0000\u0000\u0293\u0099\u0001\u0000\u0000\u0000\u0294\u0295\u0003F\""+ - "\u0000\u0295\u009b\u0001\u0000\u0000\u0000\u0296\u0298\u0003F\"\u0000"+ - "\u0297\u0299\u0003L%\u0000\u0298\u0297\u0001\u0000\u0000\u0000\u0298\u0299"+ - "\u0001\u0000\u0000\u0000\u0299\u029b\u0001\u0000\u0000\u0000\u029a\u029c"+ - "\u0003P\'\u0000\u029b\u029a\u0001\u0000\u0000\u0000\u029b\u029c\u0001"+ - "\u0000\u0000\u0000\u029c\u009d\u0001\u0000\u0000\u0000\u029d\u029e\u0003"+ - "<\u001d\u0000\u029e\u009f\u0001\u0000\u0000\u0000\u029f\u02a0\u00036\u001a"+ - "\u0000\u02a0\u00a1\u0001\u0000\u0000\u0000\u02a1\u02a2\u0005{\u0000\u0000"+ - "\u02a2\u00a3\u0001\u0000\u0000\u0000\u02a3\u02a4\u0005}\u0000\u0000\u02a4"+ - "\u00a5\u0001\u0000\u0000\u0000\u02a5\u02a6\u0005[\u0000\u0000\u02a6\u00a7"+ - "\u0001\u0000\u0000\u0000\u02a7\u02a8\u0005]\u0000\u0000\u02a8\u00a9\u0001"+ - "\u0000\u0000\u0000\u02a9\u02aa\u0005(\u0000\u0000\u02aa\u00ab\u0001\u0000"+ - "\u0000\u0000\u02ab\u02ac\u0005)\u0000\u0000\u02ac\u00ad\u0001\u0000\u0000"+ - "\u0000\u02ad\u02ae\u0005;\u0000\u0000\u02ae\u00af\u0001\u0000\u0000\u0000"+ - "\u02af\u02b0\u0005,\u0000\u0000\u02b0\u00b1\u0001\u0000\u0000\u0000\u02b1"+ - "\u02b2\u0005.\u0000\u0000\u02b2\u00b3\u0001\u0000\u0000\u0000\u02b3\u02b4"+ - "\u0005:\u0000\u0000\u02b4\u00b5\u0001\u0000\u0000\u0000\u02b5\u02b6\u0005"+ - ".\u0000\u0000\u02b6\u02b7\u0005.\u0000\u0000\u02b7\u00b7\u0001\u0000\u0000"+ - "\u0000\u02b8\u02b9\u0005.\u0000\u0000\u02b9\u02ba\u0005.\u0000\u0000\u02ba"+ - "\u02bb\u0005.\u0000\u0000\u02bb\u00b9\u0001\u0000\u0000\u0000\u02bc\u02bd"+ - "\u0005=\u0000\u0000\u02bd\u00bb\u0001\u0000\u0000\u0000\u02be\u02bf\u0005"+ - "+\u0000\u0000\u02bf\u02c0\u0005+\u0000\u0000\u02c0\u00bd\u0001\u0000\u0000"+ - "\u0000\u02c1\u02c2\u0005-\u0000\u0000\u02c2\u02c3\u0005-\u0000\u0000\u02c3"+ - "\u00bf\u0001\u0000\u0000\u0000\u02c4\u02c5\u0005+\u0000\u0000\u02c5\u00c1"+ - "\u0001\u0000\u0000\u0000\u02c6\u02c7\u0005-\u0000\u0000\u02c7\u00c3\u0001"+ - "\u0000\u0000\u0000\u02c8\u02c9\u0005*\u0000\u0000\u02c9\u00c5\u0001\u0000"+ - "\u0000\u0000\u02ca\u02cb\u0005/\u0000\u0000\u02cb\u00c7\u0001\u0000\u0000"+ - "\u0000\u02cc\u02cd\u0005>\u0000\u0000\u02cd\u00c9\u0001\u0000\u0000\u0000"+ - "\u02ce\u02cf\u0005<\u0000\u0000\u02cf\u00cb\u0001\u0000\u0000\u0000\u02d0"+ - "\u02d1\u0005<\u0000\u0000\u02d1\u02d2\u0005=\u0000\u0000\u02d2\u00cd\u0001"+ - "\u0000\u0000\u0000\u02d3\u02d4\u0005>\u0000\u0000\u02d4\u02d5\u0005=\u0000"+ - "\u0000\u02d5\u00cf\u0001\u0000\u0000\u0000\u02d6\u02d7\u0005=\u0000\u0000"+ - "\u02d7\u02d8\u0005=\u0000\u0000\u02d8\u00d1\u0001\u0000\u0000\u0000\u02d9"+ - "\u02da\u0005!\u0000\u0000\u02da\u02db\u0005=\u0000\u0000\u02db\u00d3\u0001"+ - "\u0000\u0000\u0000\u02dc\u02dd\u0005!\u0000\u0000\u02dd\u00d5\u0001\u0000"+ - "\u0000\u0000\u02de\u02df\u0005&\u0000\u0000\u02df\u02e0\u0005&\u0000\u0000"+ - "\u02e0\u00d7\u0001\u0000\u0000\u0000\u02e1\u02e2\u0005|\u0000\u0000\u02e2"+ - "\u02e3\u0005|\u0000\u0000\u02e3\u00d9\u0001\u0000\u0000\u0000\u02e4\u02e5"+ - "\u0005%\u0000\u0000\u02e5\u02e6\u0005d\u0000\u0000\u02e6\u02e7\u0005e"+ - "\u0000\u0000\u02e7\u02e8\u0005f\u0000\u0000\u02e8\u02e9\u0005i\u0000\u0000"+ - "\u02e9\u02ea\u0005n\u0000\u0000\u02ea\u02eb\u0005e\u0000\u0000\u02eb\u02ec"+ - "\u0001\u0000\u0000\u0000\u02ec\u02ed\u0006l\u0002\u0000\u02ed\u02ee\u0006"+ - "l\u0003\u0000\u02ee\u00db\u0001\u0000\u0000\u0000\u02ef\u02f0\u0005%\u0000"+ - "\u0000\u02f0\u02f1\u0005s\u0000\u0000\u02f1\u02f2\u0005c\u0000\u0000\u02f2"+ - "\u02f3\u0005h\u0000\u0000\u02f3\u02f4\u0005e\u0000\u0000\u02f4\u02f5\u0005"+ - "m\u0000\u0000\u02f5\u02f6\u0005a\u0000\u0000\u02f6\u02f7\u0001\u0000\u0000"+ - "\u0000\u02f7\u02f8\u0006m\u0004\u0000\u02f8\u02f9\u0006m\u0003\u0000\u02f9"+ - "\u00dd\u0001\u0000\u0000\u0000\u02fa\u02fb\u0005%\u0000\u0000\u02fb\u02fc"+ - "\u0005s\u0000\u0000\u02fc\u02fd\u0005c\u0000\u0000\u02fd\u02fe\u0005r"+ - "\u0000\u0000\u02fe\u02ff\u0005i\u0000\u0000\u02ff\u0300\u0005p\u0000\u0000"+ - "\u0300\u0301\u0005t\u0000\u0000\u0301\u0302\u0001\u0000\u0000\u0000\u0302"+ - "\u0303\u0006n\u0005\u0000\u0303\u0304\u0006n\u0003\u0000\u0304\u00df\u0001"+ - "\u0000\u0000\u0000\u0305\u0306\u0003T)\u0000\u0306\u0307\u0001\u0000\u0000"+ - "\u0000\u0307\u0308\u0006o\u0001\u0000\u0308\u00e1\u0001\u0000\u0000\u0000"+ - "\u0309\u030a\u0003V*\u0000\u030a\u030b\u0001\u0000\u0000\u0000\u030b\u030c"+ - "\u0006p\u0001\u0000\u030c\u00e3\u0001\u0000\u0000\u0000\u030d\u030e\u0003"+ - "X+\u0000\u030e\u030f\u0001\u0000\u0000\u0000\u030f\u0310\u0006q\u0001"+ - "\u0000\u0310\u00e5\u0001\u0000\u0000\u0000\u0014\u0000\u0001\u014b\u0155"+ + "n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001n\u0001o\u0001"+ + "o\u0001o\u0001o\u0001p\u0001p\u0001p\u0001p\u0001q\u0001q\u0001q\u0001"+ + "q\u0001\u01b7\u0000r\u0002\u0001\u0004\u0002\u0006\u0003\b\u0004\n\u0005"+ + "\f\u0006\u000e\u0007\u0010\b\u0012\t\u0014\n\u0016\u000b\u0018\f\u001a"+ + "\r\u001c\u000e\u001e\u000f \u0010\"\u0011$\u0012&\u0013(\u0014*\u0015"+ + ",\u0016.\u00170\u00182\u00194\u001a6\u00008\u0000:\u0000<\u001b>\u0000"+ + "@\u0000B\u0000D\u0000F\u001cH\u001dJ\u001eL\u0000N\u0000P\u0000R\u0000"+ + "T\u001fV X!Z\"\\#^$`%b&d\'f(h)j*l+n,p-r.t/v0x1z2|3~4\u00805\u00826\u0084"+ + "7\u00868\u00889\u008a:\u008c;\u008e<\u0090=\u0092>\u0094?\u0096@\u0098"+ + "A\u009aB\u009cC\u009eD\u00a0E\u00a2F\u00a4G\u00a6H\u00a8I\u00aaJ\u00ac"+ + "K\u00aeL\u00b0M\u00b2N\u00b4O\u00b6P\u00b8Q\u00baR\u00bcS\u00beT\u00c0"+ + "U\u00c2V\u00c4W\u00c6X\u00c8Y\u00caZ\u00cc[\u00ce\\\u00d0]\u00d2^\u00d4"+ + "_\u00d6`\u00d8a\u00da\u0000\u00dc\u0000\u00de\u0000\u00e0b\u00e2c\u00e4"+ + "d\u0002\u0000\u0001\u000b\u0003\u0000AZ__az\u0004\u000009AZ__az\b\u0000"+ + "\"\"//\\\\bbffnnrrtt\u0003\u000009AFaf\u0003\u0000\u0000\u001f\"\"\\\\"+ + "\u0001\u000019\u0002\u0000EEee\u0002\u0000++--\u0001\u000009\u0003\u0000"+ + "\t\n\r\r \u0002\u0000\n\n\r\r\u0315\u0000\u0002\u0001\u0000\u0000\u0000"+ + "\u0000\u0004\u0001\u0000\u0000\u0000\u0000\u0006\u0001\u0000\u0000\u0000"+ + "\u0000\b\u0001\u0000\u0000\u0000\u0000\n\u0001\u0000\u0000\u0000\u0000"+ + "\f\u0001\u0000\u0000\u0000\u0000\u000e\u0001\u0000\u0000\u0000\u0000\u0010"+ + "\u0001\u0000\u0000\u0000\u0000\u0012\u0001\u0000\u0000\u0000\u0000\u0014"+ + "\u0001\u0000\u0000\u0000\u0000\u0016\u0001\u0000\u0000\u0000\u0000\u0018"+ + "\u0001\u0000\u0000\u0000\u0000\u001a\u0001\u0000\u0000\u0000\u0000\u001c"+ + "\u0001\u0000\u0000\u0000\u0000\u001e\u0001\u0000\u0000\u0000\u0000 \u0001"+ + "\u0000\u0000\u0000\u0000\"\u0001\u0000\u0000\u0000\u0000$\u0001\u0000"+ + "\u0000\u0000\u0000&\u0001\u0000\u0000\u0000\u0000(\u0001\u0000\u0000\u0000"+ + "\u0000*\u0001\u0000\u0000\u0000\u0000,\u0001\u0000\u0000\u0000\u0000."+ + "\u0001\u0000\u0000\u0000\u00000\u0001\u0000\u0000\u0000\u00002\u0001\u0000"+ + "\u0000\u0000\u00004\u0001\u0000\u0000\u0000\u0000<\u0001\u0000\u0000\u0000"+ + "\u0000F\u0001\u0000\u0000\u0000\u0000H\u0001\u0000\u0000\u0000\u0000J"+ + "\u0001\u0000\u0000\u0000\u0000T\u0001\u0000\u0000\u0000\u0000V\u0001\u0000"+ + "\u0000\u0000\u0000X\u0001\u0000\u0000\u0000\u0001Z\u0001\u0000\u0000\u0000"+ + "\u0001\\\u0001\u0000\u0000\u0000\u0001^\u0001\u0000\u0000\u0000\u0001"+ + "`\u0001\u0000\u0000\u0000\u0001b\u0001\u0000\u0000\u0000\u0001d\u0001"+ + "\u0000\u0000\u0000\u0001f\u0001\u0000\u0000\u0000\u0001h\u0001\u0000\u0000"+ + "\u0000\u0001j\u0001\u0000\u0000\u0000\u0001l\u0001\u0000\u0000\u0000\u0001"+ + "n\u0001\u0000\u0000\u0000\u0001p\u0001\u0000\u0000\u0000\u0001r\u0001"+ + "\u0000\u0000\u0000\u0001t\u0001\u0000\u0000\u0000\u0001v\u0001\u0000\u0000"+ + "\u0000\u0001x\u0001\u0000\u0000\u0000\u0001z\u0001\u0000\u0000\u0000\u0001"+ + "|\u0001\u0000\u0000\u0000\u0001~\u0001\u0000\u0000\u0000\u0001\u0080\u0001"+ + "\u0000\u0000\u0000\u0001\u0082\u0001\u0000\u0000\u0000\u0001\u0084\u0001"+ + "\u0000\u0000\u0000\u0001\u0086\u0001\u0000\u0000\u0000\u0001\u0088\u0001"+ + "\u0000\u0000\u0000\u0001\u008a\u0001\u0000\u0000\u0000\u0001\u008c\u0001"+ + "\u0000\u0000\u0000\u0001\u008e\u0001\u0000\u0000\u0000\u0001\u0090\u0001"+ + "\u0000\u0000\u0000\u0001\u0092\u0001\u0000\u0000\u0000\u0001\u0094\u0001"+ + "\u0000\u0000\u0000\u0001\u0096\u0001\u0000\u0000\u0000\u0001\u0098\u0001"+ + "\u0000\u0000\u0000\u0001\u009a\u0001\u0000\u0000\u0000\u0001\u009c\u0001"+ + "\u0000\u0000\u0000\u0001\u009e\u0001\u0000\u0000\u0000\u0001\u00a0\u0001"+ + "\u0000\u0000\u0000\u0001\u00a2\u0001\u0000\u0000\u0000\u0001\u00a4\u0001"+ + "\u0000\u0000\u0000\u0001\u00a6\u0001\u0000\u0000\u0000\u0001\u00a8\u0001"+ + "\u0000\u0000\u0000\u0001\u00aa\u0001\u0000\u0000\u0000\u0001\u00ac\u0001"+ + "\u0000\u0000\u0000\u0001\u00ae\u0001\u0000\u0000\u0000\u0001\u00b0\u0001"+ + "\u0000\u0000\u0000\u0001\u00b2\u0001\u0000\u0000\u0000\u0001\u00b4\u0001"+ + "\u0000\u0000\u0000\u0001\u00b6\u0001\u0000\u0000\u0000\u0001\u00b8\u0001"+ + "\u0000\u0000\u0000\u0001\u00ba\u0001\u0000\u0000\u0000\u0001\u00bc\u0001"+ + "\u0000\u0000\u0000\u0001\u00be\u0001\u0000\u0000\u0000\u0001\u00c0\u0001"+ + "\u0000\u0000\u0000\u0001\u00c2\u0001\u0000\u0000\u0000\u0001\u00c4\u0001"+ + "\u0000\u0000\u0000\u0001\u00c6\u0001\u0000\u0000\u0000\u0001\u00c8\u0001"+ + "\u0000\u0000\u0000\u0001\u00ca\u0001\u0000\u0000\u0000\u0001\u00cc\u0001"+ + "\u0000\u0000\u0000\u0001\u00ce\u0001\u0000\u0000\u0000\u0001\u00d0\u0001"+ + "\u0000\u0000\u0000\u0001\u00d2\u0001\u0000\u0000\u0000\u0001\u00d4\u0001"+ + "\u0000\u0000\u0000\u0001\u00d6\u0001\u0000\u0000\u0000\u0001\u00d8\u0001"+ + "\u0000\u0000\u0000\u0001\u00da\u0001\u0000\u0000\u0000\u0001\u00dc\u0001"+ + "\u0000\u0000\u0000\u0001\u00de\u0001\u0000\u0000\u0000\u0001\u00e0\u0001"+ + "\u0000\u0000\u0000\u0001\u00e2\u0001\u0000\u0000\u0000\u0001\u00e4\u0001"+ + "\u0000\u0000\u0000\u0002\u00e6\u0001\u0000\u0000\u0000\u0004\u00ed\u0001"+ + "\u0000\u0000\u0000\u0006\u00f6\u0001\u0000\u0000\u0000\b\u00fe\u0001\u0000"+ + "\u0000\u0000\n\u0106\u0001\u0000\u0000\u0000\f\u010e\u0001\u0000\u0000"+ + "\u0000\u000e\u0116\u0001\u0000\u0000\u0000\u0010\u0120\u0001\u0000\u0000"+ + "\u0000\u0012\u0125\u0001\u0000\u0000\u0000\u0014\u012b\u0001\u0000\u0000"+ + "\u0000\u0016\u0130\u0001\u0000\u0000\u0000\u0018\u0132\u0001\u0000\u0000"+ + "\u0000\u001a\u0134\u0001\u0000\u0000\u0000\u001c\u0136\u0001\u0000\u0000"+ + "\u0000\u001e\u0138\u0001\u0000\u0000\u0000 \u013a\u0001\u0000\u0000\u0000"+ + "\"\u013c\u0001\u0000\u0000\u0000$\u013e\u0001\u0000\u0000\u0000&\u0140"+ + "\u0001\u0000\u0000\u0000(\u0142\u0001\u0000\u0000\u0000*\u0144\u0001\u0000"+ + "\u0000\u0000,\u0146\u0001\u0000\u0000\u0000.\u014e\u0001\u0000\u0000\u0000"+ + "0\u0151\u0001\u0000\u0000\u00002\u0157\u0001\u0000\u0000\u00004\u015a"+ + "\u0001\u0000\u0000\u00006\u015d\u0001\u0000\u0000\u00008\u0164\u0001\u0000"+ + "\u0000\u0000:\u0166\u0001\u0000\u0000\u0000<\u0168\u0001\u0000\u0000\u0000"+ + ">\u0172\u0001\u0000\u0000\u0000@\u0177\u0001\u0000\u0000\u0000B\u017d"+ + "\u0001\u0000\u0000\u0000D\u017f\u0001\u0000\u0000\u0000F\u0182\u0001\u0000"+ + "\u0000\u0000H\u0186\u0001\u0000\u0000\u0000J\u0189\u0001\u0000\u0000\u0000"+ + "L\u018f\u0001\u0000\u0000\u0000N\u019d\u0001\u0000\u0000\u0000P\u019f"+ + "\u0001\u0000\u0000\u0000R\u01a8\u0001\u0000\u0000\u0000T\u01ab\u0001\u0000"+ + "\u0000\u0000V\u01b1\u0001\u0000\u0000\u0000X\u01bf\u0001\u0000\u0000\u0000"+ + "Z\u01ca\u0001\u0000\u0000\u0000\\\u01ce\u0001\u0000\u0000\u0000^\u01d1"+ + "\u0001\u0000\u0000\u0000`\u01d6\u0001\u0000\u0000\u0000b\u01dc\u0001\u0000"+ + "\u0000\u0000d\u01e0\u0001\u0000\u0000\u0000f\u01e8\u0001\u0000\u0000\u0000"+ + "h\u01eb\u0001\u0000\u0000\u0000j\u01f1\u0001\u0000\u0000\u0000l\u01fc"+ + "\u0001\u0000\u0000\u0000n\u0203\u0001\u0000\u0000\u0000p\u020a\u0001\u0000"+ + "\u0000\u0000r\u0215\u0001\u0000\u0000\u0000t\u021b\u0001\u0000\u0000\u0000"+ + "v\u0221\u0001\u0000\u0000\u0000x\u022a\u0001\u0000\u0000\u0000z\u0231"+ + "\u0001\u0000\u0000\u0000|\u0238\u0001\u0000\u0000\u0000~\u023d\u0001\u0000"+ + "\u0000\u0000\u0080\u0243\u0001\u0000\u0000\u0000\u0082\u0248\u0001\u0000"+ + "\u0000\u0000\u0084\u0252\u0001\u0000\u0000\u0000\u0086\u0257\u0001\u0000"+ + "\u0000\u0000\u0088\u025b\u0001\u0000\u0000\u0000\u008a\u0264\u0001\u0000"+ + "\u0000\u0000\u008c\u0267\u0001\u0000\u0000\u0000\u008e\u026d\u0001\u0000"+ + "\u0000\u0000\u0090\u0274\u0001\u0000\u0000\u0000\u0092\u0279\u0001\u0000"+ + "\u0000\u0000\u0094\u0280\u0001\u0000\u0000\u0000\u0096\u0286\u0001\u0000"+ + "\u0000\u0000\u0098\u028c\u0001\u0000\u0000\u0000\u009a\u0294\u0001\u0000"+ + "\u0000\u0000\u009c\u0296\u0001\u0000\u0000\u0000\u009e\u029d\u0001\u0000"+ + "\u0000\u0000\u00a0\u029f\u0001\u0000\u0000\u0000\u00a2\u02a1\u0001\u0000"+ + "\u0000\u0000\u00a4\u02a3\u0001\u0000\u0000\u0000\u00a6\u02a5\u0001\u0000"+ + "\u0000\u0000\u00a8\u02a7\u0001\u0000\u0000\u0000\u00aa\u02a9\u0001\u0000"+ + "\u0000\u0000\u00ac\u02ab\u0001\u0000\u0000\u0000\u00ae\u02ad\u0001\u0000"+ + "\u0000\u0000\u00b0\u02af\u0001\u0000\u0000\u0000\u00b2\u02b1\u0001\u0000"+ + "\u0000\u0000\u00b4\u02b3\u0001\u0000\u0000\u0000\u00b6\u02b5\u0001\u0000"+ + "\u0000\u0000\u00b8\u02b8\u0001\u0000\u0000\u0000\u00ba\u02bc\u0001\u0000"+ + "\u0000\u0000\u00bc\u02be\u0001\u0000\u0000\u0000\u00be\u02c1\u0001\u0000"+ + "\u0000\u0000\u00c0\u02c4\u0001\u0000\u0000\u0000\u00c2\u02c6\u0001\u0000"+ + "\u0000\u0000\u00c4\u02c8\u0001\u0000\u0000\u0000\u00c6\u02ca\u0001\u0000"+ + "\u0000\u0000\u00c8\u02cc\u0001\u0000\u0000\u0000\u00ca\u02ce\u0001\u0000"+ + "\u0000\u0000\u00cc\u02d0\u0001\u0000\u0000\u0000\u00ce\u02d3\u0001\u0000"+ + "\u0000\u0000\u00d0\u02d6\u0001\u0000\u0000\u0000\u00d2\u02d9\u0001\u0000"+ + "\u0000\u0000\u00d4\u02dc\u0001\u0000\u0000\u0000\u00d6\u02de\u0001\u0000"+ + "\u0000\u0000\u00d8\u02e1\u0001\u0000\u0000\u0000\u00da\u02e4\u0001\u0000"+ + "\u0000\u0000\u00dc\u02ef\u0001\u0000\u0000\u0000\u00de\u02fa\u0001\u0000"+ + "\u0000\u0000\u00e0\u0304\u0001\u0000\u0000\u0000\u00e2\u0308\u0001\u0000"+ + "\u0000\u0000\u00e4\u030c\u0001\u0000\u0000\u0000\u00e6\u00e7\u0005%\u0000"+ + "\u0000\u00e7\u00e8\u0005t\u0000\u0000\u00e8\u00e9\u0005i\u0000\u0000\u00e9"+ + "\u00ea\u0005t\u0000\u0000\u00ea\u00eb\u0005l\u0000\u0000\u00eb\u00ec\u0005"+ + "e\u0000\u0000\u00ec\u0003\u0001\u0000\u0000\u0000\u00ed\u00ee\u0005%\u0000"+ + "\u0000\u00ee\u00ef\u0005v\u0000\u0000\u00ef\u00f0\u0005e\u0000\u0000\u00f0"+ + "\u00f1\u0005r\u0000\u0000\u00f1\u00f2\u0005s\u0000\u0000\u00f2\u00f3\u0005"+ + "i\u0000\u0000\u00f3\u00f4\u0005o\u0000\u0000\u00f4\u00f5\u0005n\u0000"+ + "\u0000\u00f5\u0005\u0001\u0000\u0000\u0000\u00f6\u00f7\u0005%\u0000\u0000"+ + "\u00f7\u00f8\u0005i\u0000\u0000\u00f8\u00f9\u0005m\u0000\u0000\u00f9\u00fa"+ + "\u0005p\u0000\u0000\u00fa\u00fb\u0005o\u0000\u0000\u00fb\u00fc\u0005r"+ + "\u0000\u0000\u00fc\u00fd\u0005t\u0000\u0000\u00fd\u0007\u0001\u0000\u0000"+ + "\u0000\u00fe\u00ff\u0005%\u0000\u0000\u00ff\u0100\u0005p\u0000\u0000\u0100"+ + "\u0101\u0005r\u0000\u0000\u0101\u0102\u0005a\u0000\u0000\u0102\u0103\u0005"+ + "g\u0000\u0000\u0103\u0104\u0005m\u0000\u0000\u0104\u0105\u0005a\u0000"+ + "\u0000\u0105\t\u0001\u0000\u0000\u0000\u0106\u0107\u0005%\u0000\u0000"+ + "\u0107\u0108\u0005d\u0000\u0000\u0108\u0109\u0005e\u0000\u0000\u0109\u010a"+ + "\u0005f\u0000\u0000\u010a\u010b\u0005i\u0000\u0000\u010b\u010c\u0005n"+ + "\u0000\u0000\u010c\u010d\u0005e\u0000\u0000\u010d\u000b\u0001\u0000\u0000"+ + "\u0000\u010e\u010f\u0005%\u0000\u0000\u010f\u0110\u0005s\u0000\u0000\u0110"+ + "\u0111\u0005c\u0000\u0000\u0111\u0112\u0005h\u0000\u0000\u0112\u0113\u0005"+ + "e\u0000\u0000\u0113\u0114\u0005m\u0000\u0000\u0114\u0115\u0005a\u0000"+ + "\u0000\u0115\r\u0001\u0000\u0000\u0000\u0116\u0117\u0005%\u0000\u0000"+ + "\u0117\u0118\u0005s\u0000\u0000\u0118\u0119\u0005c\u0000\u0000\u0119\u011a"+ + "\u0005r\u0000\u0000\u011a\u011b\u0005i\u0000\u0000\u011b\u011c\u0005p"+ + "\u0000\u0000\u011c\u011d\u0005t\u0000\u0000\u011d\u011e\u0001\u0000\u0000"+ + "\u0000\u011e\u011f\u0006\u0006\u0000\u0000\u011f\u000f\u0001\u0000\u0000"+ + "\u0000\u0120\u0121\u0005t\u0000\u0000\u0121\u0122\u0005r\u0000\u0000\u0122"+ + "\u0123\u0005u\u0000\u0000\u0123\u0124\u0005e\u0000\u0000\u0124\u0011\u0001"+ + "\u0000\u0000\u0000\u0125\u0126\u0005f\u0000\u0000\u0126\u0127\u0005a\u0000"+ + "\u0000\u0127\u0128\u0005l\u0000\u0000\u0128\u0129\u0005s\u0000\u0000\u0129"+ + "\u012a\u0005e\u0000\u0000\u012a\u0013\u0001\u0000\u0000\u0000\u012b\u012c"+ + "\u0005n\u0000\u0000\u012c\u012d\u0005u\u0000\u0000\u012d\u012e\u0005l"+ + "\u0000\u0000\u012e\u012f\u0005l\u0000\u0000\u012f\u0015\u0001\u0000\u0000"+ + "\u0000\u0130\u0131\u0005:\u0000\u0000\u0131\u0017\u0001\u0000\u0000\u0000"+ + "\u0132\u0133\u0005,\u0000\u0000\u0133\u0019\u0001\u0000\u0000\u0000\u0134"+ + "\u0135\u0005*\u0000\u0000\u0135\u001b\u0001\u0000\u0000\u0000\u0136\u0137"+ + "\u0005{\u0000\u0000\u0137\u001d\u0001\u0000\u0000\u0000\u0138\u0139\u0005"+ + "}\u0000\u0000\u0139\u001f\u0001\u0000\u0000\u0000\u013a\u013b\u0005[\u0000"+ + "\u0000\u013b!\u0001\u0000\u0000\u0000\u013c\u013d\u0005]\u0000\u0000\u013d"+ + "#\u0001\u0000\u0000\u0000\u013e\u013f\u0005(\u0000\u0000\u013f%\u0001"+ + "\u0000\u0000\u0000\u0140\u0141\u0005)\u0000\u0000\u0141\'\u0001\u0000"+ + "\u0000\u0000\u0142\u0143\u0005?\u0000\u0000\u0143)\u0001\u0000\u0000\u0000"+ + "\u0144\u0145\u0005!\u0000\u0000\u0145+\u0001\u0000\u0000\u0000\u0146\u014b"+ + "\u00036\u001a\u0000\u0147\u0148\u0005.\u0000\u0000\u0148\u014a\u00036"+ + "\u001a\u0000\u0149\u0147\u0001\u0000\u0000\u0000\u014a\u014d\u0001\u0000"+ + "\u0000\u0000\u014b\u0149\u0001\u0000\u0000\u0000\u014b\u014c\u0001\u0000"+ + "\u0000\u0000\u014c-\u0001\u0000\u0000\u0000\u014d\u014b\u0001\u0000\u0000"+ + "\u0000\u014e\u014f\u0005$\u0000\u0000\u014f\u0150\u00036\u001a\u0000\u0150"+ + "/\u0001\u0000\u0000\u0000\u0151\u0153\u0005#\u0000\u0000\u0152\u0154\u0003"+ + "8\u001b\u0000\u0153\u0152\u0001\u0000\u0000\u0000\u0154\u0155\u0001\u0000"+ + "\u0000\u0000\u0155\u0153\u0001\u0000\u0000\u0000\u0155\u0156\u0001\u0000"+ + "\u0000\u0000\u01561\u0001\u0000\u0000\u0000\u0157\u0158\u0005@\u0000\u0000"+ + "\u0158\u0159\u00036\u001a\u0000\u01593\u0001\u0000\u0000\u0000\u015a\u015b"+ + "\u0005&\u0000\u0000\u015b\u015c\u00036\u001a\u0000\u015c5\u0001\u0000"+ + "\u0000\u0000\u015d\u0161\u00038\u001b\u0000\u015e\u0160\u0003:\u001c\u0000"+ + "\u015f\u015e\u0001\u0000\u0000\u0000\u0160\u0163\u0001\u0000\u0000\u0000"+ + "\u0161\u015f\u0001\u0000\u0000\u0000\u0161\u0162\u0001\u0000\u0000\u0000"+ + "\u01627\u0001\u0000\u0000\u0000\u0163\u0161\u0001\u0000\u0000\u0000\u0164"+ + "\u0165\u0007\u0000\u0000\u0000\u01659\u0001\u0000\u0000\u0000\u0166\u0167"+ + "\u0007\u0001\u0000\u0000\u0167;\u0001\u0000\u0000\u0000\u0168\u016d\u0005"+ + "\"\u0000\u0000\u0169\u016c\u0003>\u001e\u0000\u016a\u016c\u0003D!\u0000"+ + "\u016b\u0169\u0001\u0000\u0000\u0000\u016b\u016a\u0001\u0000\u0000\u0000"+ + "\u016c\u016f\u0001\u0000\u0000\u0000\u016d\u016b\u0001\u0000\u0000\u0000"+ + "\u016d\u016e\u0001\u0000\u0000\u0000\u016e\u0170\u0001\u0000\u0000\u0000"+ + "\u016f\u016d\u0001\u0000\u0000\u0000\u0170\u0171\u0005\"\u0000\u0000\u0171"+ + "=\u0001\u0000\u0000\u0000\u0172\u0175\u0005\\\u0000\u0000\u0173\u0176"+ + "\u0007\u0002\u0000\u0000\u0174\u0176\u0003@\u001f\u0000\u0175\u0173\u0001"+ + "\u0000\u0000\u0000\u0175\u0174\u0001\u0000\u0000\u0000\u0176?\u0001\u0000"+ + "\u0000\u0000\u0177\u0178\u0005u\u0000\u0000\u0178\u0179\u0003B \u0000"+ + "\u0179\u017a\u0003B \u0000\u017a\u017b\u0003B \u0000\u017b\u017c\u0003"+ + "B \u0000\u017cA\u0001\u0000\u0000\u0000\u017d\u017e\u0007\u0003\u0000"+ + "\u0000\u017eC\u0001\u0000\u0000\u0000\u017f\u0180\b\u0004\u0000\u0000"+ + "\u0180E\u0001\u0000\u0000\u0000\u0181\u0183\u0005-\u0000\u0000\u0182\u0181"+ + "\u0001\u0000\u0000\u0000\u0182\u0183\u0001\u0000\u0000\u0000\u0183\u0184"+ + "\u0001\u0000\u0000\u0000\u0184\u0185\u0003N&\u0000\u0185G\u0001\u0000"+ + "\u0000\u0000\u0186\u0187\u0003F\"\u0000\u0187\u0188\u0003L%\u0000\u0188"+ + "I\u0001\u0000\u0000\u0000\u0189\u018b\u0003F\"\u0000\u018a\u018c\u0003"+ + "L%\u0000\u018b\u018a\u0001\u0000\u0000\u0000\u018b\u018c\u0001\u0000\u0000"+ + "\u0000\u018c\u018d\u0001\u0000\u0000\u0000\u018d\u018e\u0003P\'\u0000"+ + "\u018eK\u0001\u0000\u0000\u0000\u018f\u0191\u0005.\u0000\u0000\u0190\u0192"+ + "\u0003R(\u0000\u0191\u0190\u0001\u0000\u0000\u0000\u0192\u0193\u0001\u0000"+ + "\u0000\u0000\u0193\u0191\u0001\u0000\u0000\u0000\u0193\u0194\u0001\u0000"+ + "\u0000\u0000\u0194M\u0001\u0000\u0000\u0000\u0195\u019e\u00050\u0000\u0000"+ + "\u0196\u019a\u0007\u0005\u0000\u0000\u0197\u0199\u0003R(\u0000\u0198\u0197"+ + "\u0001\u0000\u0000\u0000\u0199\u019c\u0001\u0000\u0000\u0000\u019a\u0198"+ + "\u0001\u0000\u0000\u0000\u019a\u019b\u0001\u0000\u0000\u0000\u019b\u019e"+ + "\u0001\u0000\u0000\u0000\u019c\u019a\u0001\u0000\u0000\u0000\u019d\u0195"+ + "\u0001\u0000\u0000\u0000\u019d\u0196\u0001\u0000\u0000\u0000\u019eO\u0001"+ + "\u0000\u0000\u0000\u019f\u01a1\u0007\u0006\u0000\u0000\u01a0\u01a2\u0007"+ + "\u0007\u0000\u0000\u01a1\u01a0\u0001\u0000\u0000\u0000\u01a1\u01a2\u0001"+ + "\u0000\u0000\u0000\u01a2\u01a4\u0001\u0000\u0000\u0000\u01a3\u01a5\u0003"+ + "R(\u0000\u01a4\u01a3\u0001\u0000\u0000\u0000\u01a5\u01a6\u0001\u0000\u0000"+ + "\u0000\u01a6\u01a4\u0001\u0000\u0000\u0000\u01a6\u01a7\u0001\u0000\u0000"+ + "\u0000\u01a7Q\u0001\u0000\u0000\u0000\u01a8\u01a9\u0007\b\u0000\u0000"+ + "\u01a9S\u0001\u0000\u0000\u0000\u01aa\u01ac\u0007\t\u0000\u0000\u01ab"+ + "\u01aa\u0001\u0000\u0000\u0000\u01ac\u01ad\u0001\u0000\u0000\u0000\u01ad"+ + "\u01ab\u0001\u0000\u0000\u0000\u01ad\u01ae\u0001\u0000\u0000\u0000\u01ae"+ + "\u01af\u0001\u0000\u0000\u0000\u01af\u01b0\u0006)\u0001\u0000\u01b0U\u0001"+ + "\u0000\u0000\u0000\u01b1\u01b2\u0005/\u0000\u0000\u01b2\u01b3\u0005*\u0000"+ + "\u0000\u01b3\u01b7\u0001\u0000\u0000\u0000\u01b4\u01b6\t\u0000\u0000\u0000"+ + "\u01b5\u01b4\u0001\u0000\u0000\u0000\u01b6\u01b9\u0001\u0000\u0000\u0000"+ + "\u01b7\u01b8\u0001\u0000\u0000\u0000\u01b7\u01b5\u0001\u0000\u0000\u0000"+ + "\u01b8\u01ba\u0001\u0000\u0000\u0000\u01b9\u01b7\u0001\u0000\u0000\u0000"+ + "\u01ba\u01bb\u0005*\u0000\u0000\u01bb\u01bc\u0005/\u0000\u0000\u01bc\u01bd"+ + "\u0001\u0000\u0000\u0000\u01bd\u01be\u0006*\u0001\u0000\u01beW\u0001\u0000"+ + "\u0000\u0000\u01bf\u01c0\u0005/\u0000\u0000\u01c0\u01c1\u0005/\u0000\u0000"+ + "\u01c1\u01c5\u0001\u0000\u0000\u0000\u01c2\u01c4\b\n\u0000\u0000\u01c3"+ + "\u01c2\u0001\u0000\u0000\u0000\u01c4\u01c7\u0001\u0000\u0000\u0000\u01c5"+ + "\u01c3\u0001\u0000\u0000\u0000\u01c5\u01c6\u0001\u0000\u0000\u0000\u01c6"+ + "\u01c8\u0001\u0000\u0000\u0000\u01c7\u01c5\u0001\u0000\u0000\u0000\u01c8"+ + "\u01c9\u0006+\u0001\u0000\u01c9Y\u0001\u0000\u0000\u0000\u01ca\u01cb\u0005"+ + "v\u0000\u0000\u01cb\u01cc\u0005a\u0000\u0000\u01cc\u01cd\u0005r\u0000"+ + "\u0000\u01cd[\u0001\u0000\u0000\u0000\u01ce\u01cf\u0005i\u0000\u0000\u01cf"+ + "\u01d0\u0005f\u0000\u0000\u01d0]\u0001\u0000\u0000\u0000\u01d1\u01d2\u0005"+ + "e\u0000\u0000\u01d2\u01d3\u0005l\u0000\u0000\u01d3\u01d4\u0005s\u0000"+ + "\u0000\u01d4\u01d5\u0005e\u0000\u0000\u01d5_\u0001\u0000\u0000\u0000\u01d6"+ + "\u01d7\u0005w\u0000\u0000\u01d7\u01d8\u0005h\u0000\u0000\u01d8\u01d9\u0005"+ + "i\u0000\u0000\u01d9\u01da\u0005l\u0000\u0000\u01da\u01db\u0005e\u0000"+ + "\u0000\u01dba\u0001\u0000\u0000\u0000\u01dc\u01dd\u0005f\u0000\u0000\u01dd"+ + "\u01de\u0005o\u0000\u0000\u01de\u01df\u0005r\u0000\u0000\u01dfc\u0001"+ + "\u0000\u0000\u0000\u01e0\u01e1\u0005f\u0000\u0000\u01e1\u01e2\u0005o\u0000"+ + "\u0000\u01e2\u01e3\u0005r\u0000\u0000\u01e3\u01e4\u0005e\u0000\u0000\u01e4"+ + "\u01e5\u0005a\u0000\u0000\u01e5\u01e6\u0005c\u0000\u0000\u01e6\u01e7\u0005"+ + "h\u0000\u0000\u01e7e\u0001\u0000\u0000\u0000\u01e8\u01e9\u0005i\u0000"+ + "\u0000\u01e9\u01ea\u0005n\u0000\u0000\u01eag\u0001\u0000\u0000\u0000\u01eb"+ + "\u01ec\u0005b\u0000\u0000\u01ec\u01ed\u0005r\u0000\u0000\u01ed\u01ee\u0005"+ + "e\u0000\u0000\u01ee\u01ef\u0005a\u0000\u0000\u01ef\u01f0\u0005k\u0000"+ + "\u0000\u01f0i\u0001\u0000\u0000\u0000\u01f1\u01f2\u0005c\u0000\u0000\u01f2"+ + "\u01f3\u0005o\u0000\u0000\u01f3\u01f4\u0005n\u0000\u0000\u01f4\u01f5\u0005"+ + "s\u0000\u0000\u01f5\u01f6\u0005t\u0000\u0000\u01f6\u01f7\u0005r\u0000"+ + "\u0000\u01f7\u01f8\u0005a\u0000\u0000\u01f8\u01f9\u0005i\u0000\u0000\u01f9"+ + "\u01fa\u0005n\u0000\u0000\u01fa\u01fb\u0005t\u0000\u0000\u01fbk\u0001"+ + "\u0000\u0000\u0000\u01fc\u01fd\u0005t\u0000\u0000\u01fd\u01fe\u0005a\u0000"+ + "\u0000\u01fe\u01ff\u0005r\u0000\u0000\u01ff\u0200\u0005g\u0000\u0000\u0200"+ + "\u0201\u0005e\u0000\u0000\u0201\u0202\u0005t\u0000\u0000\u0202m\u0001"+ + "\u0000\u0000\u0000\u0203\u0204\u0005c\u0000\u0000\u0204\u0205\u0005a\u0000"+ + "\u0000\u0205\u0206\u0005l\u0000\u0000\u0206\u0207\u0005l\u0000\u0000\u0207"+ + "\u0208\u0005e\u0000\u0000\u0208\u0209\u0005r\u0000\u0000\u0209o\u0001"+ + "\u0000\u0000\u0000\u020a\u020b\u0005s\u0000\u0000\u020b\u020c\u0005u\u0000"+ + "\u0000\u020c\u020d\u0005b\u0000\u0000\u020d\u020e\u0005r\u0000\u0000\u020e"+ + "\u020f\u0005o\u0000\u0000\u020f\u0210\u0005u\u0000\u0000\u0210\u0211\u0005"+ + "t\u0000\u0000\u0211\u0212\u0005i\u0000\u0000\u0212\u0213\u0005n\u0000"+ + "\u0000\u0213\u0214\u0005e\u0000\u0000\u0214q\u0001\u0000\u0000\u0000\u0215"+ + "\u0216\u0005t\u0000\u0000\u0216\u0217\u0005r\u0000\u0000\u0217\u0218\u0005"+ + "y\u0000\u0000\u0218\u0219\u0005o\u0000\u0000\u0219\u021a\u0005f\u0000"+ + "\u0000\u021as\u0001\u0000\u0000\u0000\u021b\u021c\u0005t\u0000\u0000\u021c"+ + "\u021d\u0005h\u0000\u0000\u021d\u021e\u0005r\u0000\u0000\u021e\u021f\u0005"+ + "o\u0000\u0000\u021f\u0220\u0005w\u0000\u0000\u0220u\u0001\u0000\u0000"+ + "\u0000\u0221\u0222\u0005f\u0000\u0000\u0222\u0223\u0005u\u0000\u0000\u0223"+ + "\u0224\u0005n\u0000\u0000\u0224\u0225\u0005c\u0000\u0000\u0225\u0226\u0005"+ + "t\u0000\u0000\u0226\u0227\u0005i\u0000\u0000\u0227\u0228\u0005o\u0000"+ + "\u0000\u0228\u0229\u0005n\u0000\u0000\u0229w\u0001\u0000\u0000\u0000\u022a"+ + "\u022b\u0005r\u0000\u0000\u022b\u022c\u0005e\u0000\u0000\u022c\u022d\u0005"+ + "t\u0000\u0000\u022d\u022e\u0005u\u0000\u0000\u022e\u022f\u0005r\u0000"+ + "\u0000\u022f\u0230\u0005n\u0000\u0000\u0230y\u0001\u0000\u0000\u0000\u0231"+ + "\u0232\u0005f\u0000\u0000\u0232\u0233\u0005u\u0000\u0000\u0233\u0234\u0005"+ + "t\u0000\u0000\u0234\u0235\u0005u\u0000\u0000\u0235\u0236\u0005r\u0000"+ + "\u0000\u0236\u0237\u0005e\u0000\u0000\u0237{\u0001\u0000\u0000\u0000\u0238"+ + "\u0239\u0005t\u0000\u0000\u0239\u023a\u0005r\u0000\u0000\u023a\u023b\u0005"+ + "u\u0000\u0000\u023b\u023c\u0005e\u0000\u0000\u023c}\u0001\u0000\u0000"+ + "\u0000\u023d\u023e\u0005f\u0000\u0000\u023e\u023f\u0005a\u0000\u0000\u023f"+ + "\u0240\u0005l\u0000\u0000\u0240\u0241\u0005s\u0000\u0000\u0241\u0242\u0005"+ + "e\u0000\u0000\u0242\u007f\u0001\u0000\u0000\u0000\u0243\u0244\u0005n\u0000"+ + "\u0000\u0244\u0245\u0005u\u0000\u0000\u0245\u0246\u0005l\u0000\u0000\u0246"+ + "\u0247\u0005l\u0000\u0000\u0247\u0081\u0001\u0000\u0000\u0000\u0248\u0249"+ + "\u0005u\u0000\u0000\u0249\u024a\u0005n\u0000\u0000\u024a\u024b\u0005d"+ + "\u0000\u0000\u024b\u024c\u0005e\u0000\u0000\u024c\u024d\u0005f\u0000\u0000"+ + "\u024d\u024e\u0005i\u0000\u0000\u024e\u024f\u0005n\u0000\u0000\u024f\u0250"+ + "\u0005e\u0000\u0000\u0250\u0251\u0005d\u0000\u0000\u0251\u0083\u0001\u0000"+ + "\u0000\u0000\u0252\u0253\u0005t\u0000\u0000\u0253\u0254\u0005h\u0000\u0000"+ + "\u0254\u0255\u0005i\u0000\u0000\u0255\u0256\u0005s\u0000\u0000\u0256\u0085"+ + "\u0001\u0000\u0000\u0000\u0257\u0258\u0005n\u0000\u0000\u0258\u0259\u0005"+ + "e\u0000\u0000\u0259\u025a\u0005w\u0000\u0000\u025a\u0087\u0001\u0000\u0000"+ + "\u0000\u025b\u025c\u0005c\u0000\u0000\u025c\u025d\u0005o\u0000\u0000\u025d"+ + "\u025e\u0005n\u0000\u0000\u025e\u025f\u0005t\u0000\u0000\u025f\u0260\u0005"+ + "i\u0000\u0000\u0260\u0261\u0005n\u0000\u0000\u0261\u0262\u0005u\u0000"+ + "\u0000\u0262\u0263\u0005e\u0000\u0000\u0263\u0089\u0001\u0000\u0000\u0000"+ + "\u0264\u0265\u0005d\u0000\u0000\u0265\u0266\u0005o\u0000\u0000\u0266\u008b"+ + "\u0001\u0000\u0000\u0000\u0267\u0268\u0005c\u0000\u0000\u0268\u0269\u0005"+ + "o\u0000\u0000\u0269\u026a\u0005n\u0000\u0000\u026a\u026b\u0005s\u0000"+ + "\u0000\u026b\u026c\u0005t\u0000\u0000\u026c\u008d\u0001\u0000\u0000\u0000"+ + "\u026d\u026e\u0005s\u0000\u0000\u026e\u026f\u0005w\u0000\u0000\u026f\u0270"+ + "\u0005i\u0000\u0000\u0270\u0271\u0005t\u0000\u0000\u0271\u0272\u0005c"+ + "\u0000\u0000\u0272\u0273\u0005h\u0000\u0000\u0273\u008f\u0001\u0000\u0000"+ + "\u0000\u0274\u0275\u0005c\u0000\u0000\u0275\u0276\u0005a\u0000\u0000\u0276"+ + "\u0277\u0005s\u0000\u0000\u0277\u0278\u0005e\u0000\u0000\u0278\u0091\u0001"+ + "\u0000\u0000\u0000\u0279\u027a\u0005i\u0000\u0000\u027a\u027b\u0005m\u0000"+ + "\u0000\u027b\u027c\u0005p\u0000\u0000\u027c\u027d\u0005o\u0000\u0000\u027d"+ + "\u027e\u0005r\u0000\u0000\u027e\u027f\u0005t\u0000\u0000\u027f\u0093\u0001"+ + "\u0000\u0000\u0000\u0280\u0281\u0005c\u0000\u0000\u0281\u0282\u0005l\u0000"+ + "\u0000\u0282\u0283\u0005a\u0000\u0000\u0283\u0284\u0005s\u0000\u0000\u0284"+ + "\u0285\u0005s\u0000\u0000\u0285\u0095\u0001\u0000\u0000\u0000\u0286\u0287"+ + "\u0005s\u0000\u0000\u0287\u0288\u0005u\u0000\u0000\u0288\u0289\u0005p"+ + "\u0000\u0000\u0289\u028a\u0005e\u0000\u0000\u028a\u028b\u0005r\u0000\u0000"+ + "\u028b\u0097\u0001\u0000\u0000\u0000\u028c\u028d\u0005d\u0000\u0000\u028d"+ + "\u028e\u0005e\u0000\u0000\u028e\u028f\u0005f\u0000\u0000\u028f\u0290\u0005"+ + "a\u0000\u0000\u0290\u0291\u0005u\u0000\u0000\u0291\u0292\u0005l\u0000"+ + "\u0000\u0292\u0293\u0005t\u0000\u0000\u0293\u0099\u0001\u0000\u0000\u0000"+ + "\u0294\u0295\u0003F\"\u0000\u0295\u009b\u0001\u0000\u0000\u0000\u0296"+ + "\u0298\u0003F\"\u0000\u0297\u0299\u0003L%\u0000\u0298\u0297\u0001\u0000"+ + "\u0000\u0000\u0298\u0299\u0001\u0000\u0000\u0000\u0299\u029b\u0001\u0000"+ + "\u0000\u0000\u029a\u029c\u0003P\'\u0000\u029b\u029a\u0001\u0000\u0000"+ + "\u0000\u029b\u029c\u0001\u0000\u0000\u0000\u029c\u009d\u0001\u0000\u0000"+ + "\u0000\u029d\u029e\u0003<\u001d\u0000\u029e\u009f\u0001\u0000\u0000\u0000"+ + "\u029f\u02a0\u00036\u001a\u0000\u02a0\u00a1\u0001\u0000\u0000\u0000\u02a1"+ + "\u02a2\u0005{\u0000\u0000\u02a2\u00a3\u0001\u0000\u0000\u0000\u02a3\u02a4"+ + "\u0005}\u0000\u0000\u02a4\u00a5\u0001\u0000\u0000\u0000\u02a5\u02a6\u0005"+ + "[\u0000\u0000\u02a6\u00a7\u0001\u0000\u0000\u0000\u02a7\u02a8\u0005]\u0000"+ + "\u0000\u02a8\u00a9\u0001\u0000\u0000\u0000\u02a9\u02aa\u0005(\u0000\u0000"+ + "\u02aa\u00ab\u0001\u0000\u0000\u0000\u02ab\u02ac\u0005)\u0000\u0000\u02ac"+ + "\u00ad\u0001\u0000\u0000\u0000\u02ad\u02ae\u0005;\u0000\u0000\u02ae\u00af"+ + "\u0001\u0000\u0000\u0000\u02af\u02b0\u0005,\u0000\u0000\u02b0\u00b1\u0001"+ + "\u0000\u0000\u0000\u02b1\u02b2\u0005.\u0000\u0000\u02b2\u00b3\u0001\u0000"+ + "\u0000\u0000\u02b3\u02b4\u0005:\u0000\u0000\u02b4\u00b5\u0001\u0000\u0000"+ + "\u0000\u02b5\u02b6\u0005.\u0000\u0000\u02b6\u02b7\u0005.\u0000\u0000\u02b7"+ + "\u00b7\u0001\u0000\u0000\u0000\u02b8\u02b9\u0005.\u0000\u0000\u02b9\u02ba"+ + "\u0005.\u0000\u0000\u02ba\u02bb\u0005.\u0000\u0000\u02bb\u00b9\u0001\u0000"+ + "\u0000\u0000\u02bc\u02bd\u0005=\u0000\u0000\u02bd\u00bb\u0001\u0000\u0000"+ + "\u0000\u02be\u02bf\u0005+\u0000\u0000\u02bf\u02c0\u0005+\u0000\u0000\u02c0"+ + "\u00bd\u0001\u0000\u0000\u0000\u02c1\u02c2\u0005-\u0000\u0000\u02c2\u02c3"+ + "\u0005-\u0000\u0000\u02c3\u00bf\u0001\u0000\u0000\u0000\u02c4\u02c5\u0005"+ + "+\u0000\u0000\u02c5\u00c1\u0001\u0000\u0000\u0000\u02c6\u02c7\u0005-\u0000"+ + "\u0000\u02c7\u00c3\u0001\u0000\u0000\u0000\u02c8\u02c9\u0005*\u0000\u0000"+ + "\u02c9\u00c5\u0001\u0000\u0000\u0000\u02ca\u02cb\u0005/\u0000\u0000\u02cb"+ + "\u00c7\u0001\u0000\u0000\u0000\u02cc\u02cd\u0005>\u0000\u0000\u02cd\u00c9"+ + "\u0001\u0000\u0000\u0000\u02ce\u02cf\u0005<\u0000\u0000\u02cf\u00cb\u0001"+ + "\u0000\u0000\u0000\u02d0\u02d1\u0005<\u0000\u0000\u02d1\u02d2\u0005=\u0000"+ + "\u0000\u02d2\u00cd\u0001\u0000\u0000\u0000\u02d3\u02d4\u0005>\u0000\u0000"+ + "\u02d4\u02d5\u0005=\u0000\u0000\u02d5\u00cf\u0001\u0000\u0000\u0000\u02d6"+ + "\u02d7\u0005=\u0000\u0000\u02d7\u02d8\u0005=\u0000\u0000\u02d8\u00d1\u0001"+ + "\u0000\u0000\u0000\u02d9\u02da\u0005!\u0000\u0000\u02da\u02db\u0005=\u0000"+ + "\u0000\u02db\u00d3\u0001\u0000\u0000\u0000\u02dc\u02dd\u0005!\u0000\u0000"+ + "\u02dd\u00d5\u0001\u0000\u0000\u0000\u02de\u02df\u0005&\u0000\u0000\u02df"+ + "\u02e0\u0005&\u0000\u0000\u02e0\u00d7\u0001\u0000\u0000\u0000\u02e1\u02e2"+ + "\u0005|\u0000\u0000\u02e2\u02e3\u0005|\u0000\u0000\u02e3\u00d9\u0001\u0000"+ + "\u0000\u0000\u02e4\u02e5\u0005%\u0000\u0000\u02e5\u02e6\u0005d\u0000\u0000"+ + "\u02e6\u02e7\u0005e\u0000\u0000\u02e7\u02e8\u0005f\u0000\u0000\u02e8\u02e9"+ + "\u0005i\u0000\u0000\u02e9\u02ea\u0005n\u0000\u0000\u02ea\u02eb\u0005e"+ + "\u0000\u0000\u02eb\u02ec\u0001\u0000\u0000\u0000\u02ec\u02ed\u0006l\u0002"+ + "\u0000\u02ed\u02ee\u0006l\u0003\u0000\u02ee\u00db\u0001\u0000\u0000\u0000"+ + "\u02ef\u02f0\u0005%\u0000\u0000\u02f0\u02f1\u0005s\u0000\u0000\u02f1\u02f2"+ + "\u0005c\u0000\u0000\u02f2\u02f3\u0005h\u0000\u0000\u02f3\u02f4\u0005e"+ + "\u0000\u0000\u02f4\u02f5\u0005m\u0000\u0000\u02f5\u02f6\u0005a\u0000\u0000"+ + "\u02f6\u02f7\u0001\u0000\u0000\u0000\u02f7\u02f8\u0006m\u0004\u0000\u02f8"+ + "\u02f9\u0006m\u0003\u0000\u02f9\u00dd\u0001\u0000\u0000\u0000\u02fa\u02fb"+ + "\u0005%\u0000\u0000\u02fb\u02fc\u0005s\u0000\u0000\u02fc\u02fd\u0005c"+ + "\u0000\u0000\u02fd\u02fe\u0005r\u0000\u0000\u02fe\u02ff\u0005i\u0000\u0000"+ + "\u02ff\u0300\u0005p\u0000\u0000\u0300\u0301\u0005t\u0000\u0000\u0301\u0302"+ + "\u0001\u0000\u0000\u0000\u0302\u0303\u0006n\u0005\u0000\u0303\u00df\u0001"+ + "\u0000\u0000\u0000\u0304\u0305\u0003T)\u0000\u0305\u0306\u0001\u0000\u0000"+ + "\u0000\u0306\u0307\u0006o\u0001\u0000\u0307\u00e1\u0001\u0000\u0000\u0000"+ + "\u0308\u0309\u0003V*\u0000\u0309\u030a\u0001\u0000\u0000\u0000\u030a\u030b"+ + "\u0006p\u0001\u0000\u030b\u00e3\u0001\u0000\u0000\u0000\u030c\u030d\u0003"+ + "X+\u0000\u030d\u030e\u0001\u0000\u0000\u0000\u030e\u030f\u0006q\u0001"+ + "\u0000\u030f\u00e5\u0001\u0000\u0000\u0000\u0014\u0000\u0001\u014b\u0155"+ "\u0161\u016b\u016d\u0175\u0182\u018b\u0193\u019a\u019d\u01a1\u01a6\u01ad"+ "\u01b7\u01c5\u0298\u029b\u0006\u0005\u0001\u0000\u0000\u0001\u0000\u0007"+ "\u0005\u0000\u0004\u0000\u0000\u0007\u0006\u0000\u0007\u0007\u0000"; diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.interp b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.interp index 4dca097..6ee65b1 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.interp +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.interp @@ -245,4 +245,4 @@ literal atn: -[4, 1, 100, 567, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 1, 0, 3, 0, 76, 8, 0, 1, 0, 3, 0, 79, 8, 0, 1, 0, 1, 0, 5, 0, 83, 8, 0, 10, 0, 12, 0, 86, 9, 0, 1, 0, 1, 0, 5, 0, 90, 8, 0, 10, 0, 12, 0, 93, 9, 0, 1, 0, 1, 0, 1, 0, 5, 0, 98, 8, 0, 10, 0, 12, 0, 101, 9, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 108, 8, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 127, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 5, 8, 143, 8, 8, 10, 8, 12, 8, 146, 9, 8, 1, 8, 5, 8, 149, 8, 8, 10, 8, 12, 8, 152, 9, 8, 1, 8, 5, 8, 155, 8, 8, 10, 8, 12, 8, 158, 9, 8, 1, 8, 3, 8, 161, 8, 8, 1, 8, 4, 8, 164, 8, 8, 11, 8, 12, 8, 165, 1, 8, 5, 8, 169, 8, 8, 10, 8, 12, 8, 172, 9, 8, 1, 8, 5, 8, 175, 8, 8, 10, 8, 12, 8, 178, 9, 8, 1, 8, 3, 8, 181, 8, 8, 1, 8, 4, 8, 184, 8, 8, 11, 8, 12, 8, 185, 1, 8, 5, 8, 189, 8, 8, 10, 8, 12, 8, 192, 9, 8, 1, 8, 3, 8, 195, 8, 8, 3, 8, 197, 8, 8, 1, 9, 1, 9, 3, 9, 201, 8, 9, 1, 10, 1, 10, 1, 10, 3, 10, 206, 8, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 5, 12, 214, 8, 12, 10, 12, 12, 12, 217, 9, 12, 3, 12, 219, 8, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 5, 14, 231, 8, 14, 10, 14, 12, 14, 234, 9, 14, 3, 14, 236, 8, 14, 1, 14, 1, 14, 1, 15, 1, 15, 3, 15, 242, 8, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 248, 8, 15, 1, 16, 1, 16, 3, 16, 252, 8, 16, 1, 16, 1, 16, 1, 16, 1, 16, 5, 16, 258, 8, 16, 10, 16, 12, 16, 261, 9, 16, 3, 16, 263, 8, 16, 1, 16, 3, 16, 266, 8, 16, 1, 17, 1, 17, 3, 17, 270, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 280, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 4, 19, 286, 8, 19, 11, 19, 12, 19, 287, 1, 19, 1, 19, 1, 20, 1, 20, 3, 20, 294, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 305, 8, 21, 1, 22, 1, 22, 3, 22, 309, 8, 22, 1, 22, 1, 22, 3, 22, 313, 8, 22, 1, 22, 3, 22, 316, 8, 22, 1, 22, 1, 22, 3, 22, 320, 8, 22, 3, 22, 322, 8, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 5, 22, 329, 8, 22, 10, 22, 12, 22, 332, 9, 22, 1, 22, 3, 22, 335, 8, 22, 3, 22, 337, 8, 22, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 5, 23, 346, 8, 23, 10, 23, 12, 23, 349, 9, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 3, 24, 356, 8, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 3, 26, 368, 8, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 3, 28, 382, 8, 28, 1, 28, 3, 28, 385, 8, 28, 1, 28, 1, 28, 3, 28, 389, 8, 28, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 5, 29, 397, 8, 29, 10, 29, 12, 29, 400, 9, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 5, 33, 420, 8, 33, 10, 33, 12, 33, 423, 9, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 3, 34, 464, 8, 34, 1, 34, 1, 34, 3, 34, 468, 8, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 3, 34, 491, 8, 34, 5, 34, 493, 8, 34, 10, 34, 12, 34, 496, 9, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 504, 8, 35, 10, 35, 12, 35, 507, 9, 35, 3, 35, 509, 8, 35, 1, 35, 1, 35, 1, 35, 1, 35, 3, 35, 515, 8, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 525, 8, 35, 10, 35, 12, 35, 528, 9, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 539, 8, 36, 10, 36, 12, 36, 542, 9, 36, 3, 36, 544, 8, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 555, 8, 36, 10, 36, 12, 36, 558, 9, 36, 3, 36, 560, 8, 36, 1, 36, 1, 36, 1, 36, 3, 36, 565, 8, 36, 1, 36, 0, 2, 68, 70, 37, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 0, 5, 1, 0, 87, 88, 1, 0, 85, 86, 1, 0, 89, 92, 1, 0, 93, 94, 1, 0, 68, 69, 641, 0, 107, 1, 0, 0, 0, 2, 109, 1, 0, 0, 0, 4, 113, 1, 0, 0, 0, 6, 117, 1, 0, 0, 0, 8, 121, 1, 0, 0, 0, 10, 128, 1, 0, 0, 0, 12, 133, 1, 0, 0, 0, 14, 138, 1, 0, 0, 0, 16, 196, 1, 0, 0, 0, 18, 200, 1, 0, 0, 0, 20, 205, 1, 0, 0, 0, 22, 207, 1, 0, 0, 0, 24, 209, 1, 0, 0, 0, 26, 222, 1, 0, 0, 0, 28, 226, 1, 0, 0, 0, 30, 239, 1, 0, 0, 0, 32, 249, 1, 0, 0, 0, 34, 269, 1, 0, 0, 0, 36, 279, 1, 0, 0, 0, 38, 281, 1, 0, 0, 0, 40, 293, 1, 0, 0, 0, 42, 304, 1, 0, 0, 0, 44, 321, 1, 0, 0, 0, 46, 341, 1, 0, 0, 0, 48, 352, 1, 0, 0, 0, 50, 357, 1, 0, 0, 0, 52, 360, 1, 0, 0, 0, 54, 369, 1, 0, 0, 0, 56, 375, 1, 0, 0, 0, 58, 393, 1, 0, 0, 0, 60, 401, 1, 0, 0, 0, 62, 410, 1, 0, 0, 0, 64, 414, 1, 0, 0, 0, 66, 417, 1, 0, 0, 0, 68, 467, 1, 0, 0, 0, 70, 514, 1, 0, 0, 0, 72, 564, 1, 0, 0, 0, 74, 76, 3, 4, 2, 0, 75, 74, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 78, 1, 0, 0, 0, 77, 79, 3, 6, 3, 0, 78, 77, 1, 0, 0, 0, 78, 79, 1, 0, 0, 0, 79, 84, 1, 0, 0, 0, 80, 83, 3, 8, 4, 0, 81, 83, 3, 10, 5, 0, 82, 80, 1, 0, 0, 0, 82, 81, 1, 0, 0, 0, 83, 86, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 85, 1, 0, 0, 0, 85, 91, 1, 0, 0, 0, 86, 84, 1, 0, 0, 0, 87, 90, 3, 12, 6, 0, 88, 90, 3, 38, 19, 0, 89, 87, 1, 0, 0, 0, 89, 88, 1, 0, 0, 0, 90, 93, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 94, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 94, 99, 3, 2, 1, 0, 95, 98, 3, 12, 6, 0, 96, 98, 3, 38, 19, 0, 97, 95, 1, 0, 0, 0, 97, 96, 1, 0, 0, 0, 98, 101, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 99, 100, 1, 0, 0, 0, 100, 102, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 102, 103, 5, 0, 0, 1, 103, 108, 1, 0, 0, 0, 104, 105, 3, 18, 9, 0, 105, 106, 5, 0, 0, 1, 106, 108, 1, 0, 0, 0, 107, 75, 1, 0, 0, 0, 107, 104, 1, 0, 0, 0, 108, 1, 1, 0, 0, 0, 109, 110, 5, 6, 0, 0, 110, 111, 5, 11, 0, 0, 111, 112, 3, 18, 9, 0, 112, 3, 1, 0, 0, 0, 113, 114, 5, 1, 0, 0, 114, 115, 5, 11, 0, 0, 115, 116, 5, 27, 0, 0, 116, 5, 1, 0, 0, 0, 117, 118, 5, 2, 0, 0, 118, 119, 5, 11, 0, 0, 119, 120, 5, 27, 0, 0, 120, 7, 1, 0, 0, 0, 121, 122, 5, 3, 0, 0, 122, 123, 5, 11, 0, 0, 123, 126, 5, 22, 0, 0, 124, 125, 5, 12, 0, 0, 125, 127, 5, 22, 0, 0, 126, 124, 1, 0, 0, 0, 126, 127, 1, 0, 0, 0, 127, 9, 1, 0, 0, 0, 128, 129, 5, 4, 0, 0, 129, 130, 5, 22, 0, 0, 130, 131, 5, 11, 0, 0, 131, 132, 3, 36, 18, 0, 132, 11, 1, 0, 0, 0, 133, 134, 5, 5, 0, 0, 134, 135, 3, 14, 7, 0, 135, 136, 5, 11, 0, 0, 136, 137, 3, 16, 8, 0, 137, 13, 1, 0, 0, 0, 138, 139, 5, 23, 0, 0, 139, 15, 1, 0, 0, 0, 140, 144, 3, 20, 10, 0, 141, 143, 3, 32, 16, 0, 142, 141, 1, 0, 0, 0, 143, 146, 1, 0, 0, 0, 144, 142, 1, 0, 0, 0, 144, 145, 1, 0, 0, 0, 145, 150, 1, 0, 0, 0, 146, 144, 1, 0, 0, 0, 147, 149, 3, 30, 15, 0, 148, 147, 1, 0, 0, 0, 149, 152, 1, 0, 0, 0, 150, 148, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 156, 1, 0, 0, 0, 152, 150, 1, 0, 0, 0, 153, 155, 3, 22, 11, 0, 154, 153, 1, 0, 0, 0, 155, 158, 1, 0, 0, 0, 156, 154, 1, 0, 0, 0, 156, 157, 1, 0, 0, 0, 157, 160, 1, 0, 0, 0, 158, 156, 1, 0, 0, 0, 159, 161, 5, 20, 0, 0, 160, 159, 1, 0, 0, 0, 160, 161, 1, 0, 0, 0, 161, 197, 1, 0, 0, 0, 162, 164, 3, 32, 16, 0, 163, 162, 1, 0, 0, 0, 164, 165, 1, 0, 0, 0, 165, 163, 1, 0, 0, 0, 165, 166, 1, 0, 0, 0, 166, 170, 1, 0, 0, 0, 167, 169, 3, 30, 15, 0, 168, 167, 1, 0, 0, 0, 169, 172, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 170, 171, 1, 0, 0, 0, 171, 176, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 173, 175, 3, 22, 11, 0, 174, 173, 1, 0, 0, 0, 175, 178, 1, 0, 0, 0, 176, 174, 1, 0, 0, 0, 176, 177, 1, 0, 0, 0, 177, 180, 1, 0, 0, 0, 178, 176, 1, 0, 0, 0, 179, 181, 5, 20, 0, 0, 180, 179, 1, 0, 0, 0, 180, 181, 1, 0, 0, 0, 181, 197, 1, 0, 0, 0, 182, 184, 3, 30, 15, 0, 183, 182, 1, 0, 0, 0, 184, 185, 1, 0, 0, 0, 185, 183, 1, 0, 0, 0, 185, 186, 1, 0, 0, 0, 186, 190, 1, 0, 0, 0, 187, 189, 3, 22, 11, 0, 188, 187, 1, 0, 0, 0, 189, 192, 1, 0, 0, 0, 190, 188, 1, 0, 0, 0, 190, 191, 1, 0, 0, 0, 191, 194, 1, 0, 0, 0, 192, 190, 1, 0, 0, 0, 193, 195, 5, 20, 0, 0, 194, 193, 1, 0, 0, 0, 194, 195, 1, 0, 0, 0, 195, 197, 1, 0, 0, 0, 196, 140, 1, 0, 0, 0, 196, 163, 1, 0, 0, 0, 196, 183, 1, 0, 0, 0, 197, 17, 1, 0, 0, 0, 198, 201, 3, 16, 8, 0, 199, 201, 3, 14, 7, 0, 200, 198, 1, 0, 0, 0, 200, 199, 1, 0, 0, 0, 201, 19, 1, 0, 0, 0, 202, 206, 3, 36, 18, 0, 203, 206, 3, 24, 12, 0, 204, 206, 3, 28, 14, 0, 205, 202, 1, 0, 0, 0, 205, 203, 1, 0, 0, 0, 205, 204, 1, 0, 0, 0, 206, 21, 1, 0, 0, 0, 207, 208, 5, 26, 0, 0, 208, 23, 1, 0, 0, 0, 209, 218, 5, 14, 0, 0, 210, 215, 3, 26, 13, 0, 211, 212, 5, 12, 0, 0, 212, 214, 3, 26, 13, 0, 213, 211, 1, 0, 0, 0, 214, 217, 1, 0, 0, 0, 215, 213, 1, 0, 0, 0, 215, 216, 1, 0, 0, 0, 216, 219, 1, 0, 0, 0, 217, 215, 1, 0, 0, 0, 218, 210, 1, 0, 0, 0, 218, 219, 1, 0, 0, 0, 219, 220, 1, 0, 0, 0, 220, 221, 5, 15, 0, 0, 221, 25, 1, 0, 0, 0, 222, 223, 5, 27, 0, 0, 223, 224, 5, 11, 0, 0, 224, 225, 3, 18, 9, 0, 225, 27, 1, 0, 0, 0, 226, 235, 5, 16, 0, 0, 227, 232, 3, 18, 9, 0, 228, 229, 5, 12, 0, 0, 229, 231, 3, 18, 9, 0, 230, 228, 1, 0, 0, 0, 231, 234, 1, 0, 0, 0, 232, 230, 1, 0, 0, 0, 232, 233, 1, 0, 0, 0, 233, 236, 1, 0, 0, 0, 234, 232, 1, 0, 0, 0, 235, 227, 1, 0, 0, 0, 235, 236, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 238, 5, 17, 0, 0, 238, 29, 1, 0, 0, 0, 239, 241, 5, 24, 0, 0, 240, 242, 5, 13, 0, 0, 241, 240, 1, 0, 0, 0, 241, 242, 1, 0, 0, 0, 242, 247, 1, 0, 0, 0, 243, 244, 5, 18, 0, 0, 244, 245, 3, 14, 7, 0, 245, 246, 5, 19, 0, 0, 246, 248, 1, 0, 0, 0, 247, 243, 1, 0, 0, 0, 247, 248, 1, 0, 0, 0, 248, 31, 1, 0, 0, 0, 249, 251, 5, 25, 0, 0, 250, 252, 5, 13, 0, 0, 251, 250, 1, 0, 0, 0, 251, 252, 1, 0, 0, 0, 252, 265, 1, 0, 0, 0, 253, 262, 5, 18, 0, 0, 254, 259, 3, 34, 17, 0, 255, 256, 5, 12, 0, 0, 256, 258, 3, 34, 17, 0, 257, 255, 1, 0, 0, 0, 258, 261, 1, 0, 0, 0, 259, 257, 1, 0, 0, 0, 259, 260, 1, 0, 0, 0, 260, 263, 1, 0, 0, 0, 261, 259, 1, 0, 0, 0, 262, 254, 1, 0, 0, 0, 262, 263, 1, 0, 0, 0, 263, 264, 1, 0, 0, 0, 264, 266, 5, 19, 0, 0, 265, 253, 1, 0, 0, 0, 265, 266, 1, 0, 0, 0, 266, 33, 1, 0, 0, 0, 267, 270, 3, 20, 10, 0, 268, 270, 3, 22, 11, 0, 269, 267, 1, 0, 0, 0, 269, 268, 1, 0, 0, 0, 270, 35, 1, 0, 0, 0, 271, 280, 5, 8, 0, 0, 272, 280, 5, 9, 0, 0, 273, 280, 5, 27, 0, 0, 274, 280, 5, 28, 0, 0, 275, 280, 5, 29, 0, 0, 276, 280, 5, 30, 0, 0, 277, 280, 5, 10, 0, 0, 278, 280, 5, 21, 0, 0, 279, 271, 1, 0, 0, 0, 279, 272, 1, 0, 0, 0, 279, 273, 1, 0, 0, 0, 279, 274, 1, 0, 0, 0, 279, 275, 1, 0, 0, 0, 279, 276, 1, 0, 0, 0, 279, 277, 1, 0, 0, 0, 279, 278, 1, 0, 0, 0, 280, 37, 1, 0, 0, 0, 281, 282, 5, 7, 0, 0, 282, 283, 5, 79, 0, 0, 283, 285, 5, 70, 0, 0, 284, 286, 3, 40, 20, 0, 285, 284, 1, 0, 0, 0, 286, 287, 1, 0, 0, 0, 287, 285, 1, 0, 0, 0, 287, 288, 1, 0, 0, 0, 288, 289, 1, 0, 0, 0, 289, 290, 5, 71, 0, 0, 290, 39, 1, 0, 0, 0, 291, 294, 3, 44, 22, 0, 292, 294, 3, 46, 23, 0, 293, 291, 1, 0, 0, 0, 293, 292, 1, 0, 0, 0, 294, 41, 1, 0, 0, 0, 295, 305, 3, 46, 23, 0, 296, 305, 3, 50, 25, 0, 297, 305, 3, 52, 26, 0, 298, 305, 3, 54, 27, 0, 299, 305, 3, 56, 28, 0, 300, 305, 3, 60, 30, 0, 301, 305, 3, 62, 31, 0, 302, 305, 3, 64, 32, 0, 303, 305, 3, 66, 33, 0, 304, 295, 1, 0, 0, 0, 304, 296, 1, 0, 0, 0, 304, 297, 1, 0, 0, 0, 304, 298, 1, 0, 0, 0, 304, 299, 1, 0, 0, 0, 304, 300, 1, 0, 0, 0, 304, 301, 1, 0, 0, 0, 304, 302, 1, 0, 0, 0, 304, 303, 1, 0, 0, 0, 305, 43, 1, 0, 0, 0, 306, 308, 5, 42, 0, 0, 307, 309, 5, 48, 0, 0, 308, 307, 1, 0, 0, 0, 308, 309, 1, 0, 0, 0, 309, 322, 1, 0, 0, 0, 310, 312, 5, 50, 0, 0, 311, 313, 5, 42, 0, 0, 312, 311, 1, 0, 0, 0, 312, 313, 1, 0, 0, 0, 313, 315, 1, 0, 0, 0, 314, 316, 5, 48, 0, 0, 315, 314, 1, 0, 0, 0, 315, 316, 1, 0, 0, 0, 316, 322, 1, 0, 0, 0, 317, 319, 5, 45, 0, 0, 318, 320, 5, 48, 0, 0, 319, 318, 1, 0, 0, 0, 319, 320, 1, 0, 0, 0, 320, 322, 1, 0, 0, 0, 321, 306, 1, 0, 0, 0, 321, 310, 1, 0, 0, 0, 321, 317, 1, 0, 0, 0, 322, 323, 1, 0, 0, 0, 323, 324, 5, 69, 0, 0, 324, 336, 5, 74, 0, 0, 325, 330, 5, 69, 0, 0, 326, 327, 5, 77, 0, 0, 327, 329, 5, 69, 0, 0, 328, 326, 1, 0, 0, 0, 329, 332, 1, 0, 0, 0, 330, 328, 1, 0, 0, 0, 330, 331, 1, 0, 0, 0, 331, 334, 1, 0, 0, 0, 332, 330, 1, 0, 0, 0, 333, 335, 5, 81, 0, 0, 334, 333, 1, 0, 0, 0, 334, 335, 1, 0, 0, 0, 335, 337, 1, 0, 0, 0, 336, 325, 1, 0, 0, 0, 336, 337, 1, 0, 0, 0, 337, 338, 1, 0, 0, 0, 338, 339, 5, 75, 0, 0, 339, 340, 3, 66, 33, 0, 340, 45, 1, 0, 0, 0, 341, 342, 5, 34, 0, 0, 342, 347, 3, 48, 24, 0, 343, 344, 5, 77, 0, 0, 344, 346, 3, 48, 24, 0, 345, 343, 1, 0, 0, 0, 346, 349, 1, 0, 0, 0, 347, 345, 1, 0, 0, 0, 347, 348, 1, 0, 0, 0, 348, 350, 1, 0, 0, 0, 349, 347, 1, 0, 0, 0, 350, 351, 5, 76, 0, 0, 351, 47, 1, 0, 0, 0, 352, 355, 5, 69, 0, 0, 353, 354, 5, 82, 0, 0, 354, 356, 3, 68, 34, 0, 355, 353, 1, 0, 0, 0, 355, 356, 1, 0, 0, 0, 356, 49, 1, 0, 0, 0, 357, 358, 3, 68, 34, 0, 358, 359, 5, 76, 0, 0, 359, 51, 1, 0, 0, 0, 360, 361, 5, 35, 0, 0, 361, 362, 5, 74, 0, 0, 362, 363, 3, 68, 34, 0, 363, 364, 5, 75, 0, 0, 364, 367, 3, 42, 21, 0, 365, 366, 5, 36, 0, 0, 366, 368, 3, 42, 21, 0, 367, 365, 1, 0, 0, 0, 367, 368, 1, 0, 0, 0, 368, 53, 1, 0, 0, 0, 369, 370, 5, 37, 0, 0, 370, 371, 5, 74, 0, 0, 371, 372, 3, 68, 34, 0, 372, 373, 5, 75, 0, 0, 373, 374, 3, 42, 21, 0, 374, 55, 1, 0, 0, 0, 375, 376, 5, 38, 0, 0, 376, 381, 5, 74, 0, 0, 377, 382, 3, 46, 23, 0, 378, 379, 3, 58, 29, 0, 379, 380, 5, 76, 0, 0, 380, 382, 1, 0, 0, 0, 381, 377, 1, 0, 0, 0, 381, 378, 1, 0, 0, 0, 381, 382, 1, 0, 0, 0, 382, 384, 1, 0, 0, 0, 383, 385, 3, 68, 34, 0, 384, 383, 1, 0, 0, 0, 384, 385, 1, 0, 0, 0, 385, 386, 1, 0, 0, 0, 386, 388, 5, 76, 0, 0, 387, 389, 3, 58, 29, 0, 388, 387, 1, 0, 0, 0, 388, 389, 1, 0, 0, 0, 389, 390, 1, 0, 0, 0, 390, 391, 5, 75, 0, 0, 391, 392, 3, 42, 21, 0, 392, 57, 1, 0, 0, 0, 393, 398, 3, 68, 34, 0, 394, 395, 5, 77, 0, 0, 395, 397, 3, 68, 34, 0, 396, 394, 1, 0, 0, 0, 397, 400, 1, 0, 0, 0, 398, 396, 1, 0, 0, 0, 398, 399, 1, 0, 0, 0, 399, 59, 1, 0, 0, 0, 400, 398, 1, 0, 0, 0, 401, 402, 5, 39, 0, 0, 402, 403, 5, 74, 0, 0, 403, 404, 5, 34, 0, 0, 404, 405, 5, 69, 0, 0, 405, 406, 5, 40, 0, 0, 406, 407, 3, 68, 34, 0, 407, 408, 5, 75, 0, 0, 408, 409, 3, 42, 21, 0, 409, 61, 1, 0, 0, 0, 410, 411, 5, 49, 0, 0, 411, 412, 3, 68, 34, 0, 412, 413, 5, 76, 0, 0, 413, 63, 1, 0, 0, 0, 414, 415, 5, 41, 0, 0, 415, 416, 5, 76, 0, 0, 416, 65, 1, 0, 0, 0, 417, 421, 5, 70, 0, 0, 418, 420, 3, 42, 21, 0, 419, 418, 1, 0, 0, 0, 420, 423, 1, 0, 0, 0, 421, 419, 1, 0, 0, 0, 421, 422, 1, 0, 0, 0, 422, 424, 1, 0, 0, 0, 423, 421, 1, 0, 0, 0, 424, 425, 5, 71, 0, 0, 425, 67, 1, 0, 0, 0, 426, 427, 6, 34, -1, 0, 427, 468, 3, 70, 35, 0, 428, 429, 5, 86, 0, 0, 429, 468, 3, 68, 34, 19, 430, 431, 5, 95, 0, 0, 431, 468, 3, 68, 34, 18, 432, 433, 3, 70, 35, 0, 433, 434, 5, 83, 0, 0, 434, 468, 1, 0, 0, 0, 435, 436, 3, 70, 35, 0, 436, 437, 5, 84, 0, 0, 437, 468, 1, 0, 0, 0, 438, 439, 5, 83, 0, 0, 439, 468, 3, 70, 35, 0, 440, 441, 5, 84, 0, 0, 441, 468, 3, 70, 35, 0, 442, 443, 5, 80, 0, 0, 443, 468, 3, 68, 34, 10, 444, 445, 3, 70, 35, 0, 445, 446, 5, 82, 0, 0, 446, 447, 3, 68, 34, 5, 447, 468, 1, 0, 0, 0, 448, 468, 3, 72, 36, 0, 449, 450, 5, 74, 0, 0, 450, 451, 3, 68, 34, 0, 451, 452, 5, 75, 0, 0, 452, 468, 1, 0, 0, 0, 453, 454, 5, 46, 0, 0, 454, 455, 5, 74, 0, 0, 455, 456, 3, 68, 34, 0, 456, 457, 5, 75, 0, 0, 457, 468, 1, 0, 0, 0, 458, 459, 5, 47, 0, 0, 459, 460, 5, 74, 0, 0, 460, 463, 3, 68, 34, 0, 461, 462, 5, 77, 0, 0, 462, 464, 3, 68, 34, 0, 463, 461, 1, 0, 0, 0, 463, 464, 1, 0, 0, 0, 464, 465, 1, 0, 0, 0, 465, 466, 5, 75, 0, 0, 466, 468, 1, 0, 0, 0, 467, 426, 1, 0, 0, 0, 467, 428, 1, 0, 0, 0, 467, 430, 1, 0, 0, 0, 467, 432, 1, 0, 0, 0, 467, 435, 1, 0, 0, 0, 467, 438, 1, 0, 0, 0, 467, 440, 1, 0, 0, 0, 467, 442, 1, 0, 0, 0, 467, 444, 1, 0, 0, 0, 467, 448, 1, 0, 0, 0, 467, 449, 1, 0, 0, 0, 467, 453, 1, 0, 0, 0, 467, 458, 1, 0, 0, 0, 468, 494, 1, 0, 0, 0, 469, 470, 10, 13, 0, 0, 470, 471, 7, 0, 0, 0, 471, 493, 3, 68, 34, 14, 472, 473, 10, 12, 0, 0, 473, 474, 7, 1, 0, 0, 474, 493, 3, 68, 34, 13, 475, 476, 10, 9, 0, 0, 476, 477, 7, 2, 0, 0, 477, 493, 3, 68, 34, 10, 478, 479, 10, 8, 0, 0, 479, 480, 7, 3, 0, 0, 480, 493, 3, 68, 34, 9, 481, 482, 10, 7, 0, 0, 482, 483, 5, 96, 0, 0, 483, 493, 3, 68, 34, 8, 484, 485, 10, 6, 0, 0, 485, 486, 5, 97, 0, 0, 486, 493, 3, 68, 34, 7, 487, 488, 10, 11, 0, 0, 488, 490, 5, 80, 0, 0, 489, 491, 3, 68, 34, 0, 490, 489, 1, 0, 0, 0, 490, 491, 1, 0, 0, 0, 491, 493, 1, 0, 0, 0, 492, 469, 1, 0, 0, 0, 492, 472, 1, 0, 0, 0, 492, 475, 1, 0, 0, 0, 492, 478, 1, 0, 0, 0, 492, 481, 1, 0, 0, 0, 492, 484, 1, 0, 0, 0, 492, 487, 1, 0, 0, 0, 493, 496, 1, 0, 0, 0, 494, 492, 1, 0, 0, 0, 494, 495, 1, 0, 0, 0, 495, 69, 1, 0, 0, 0, 496, 494, 1, 0, 0, 0, 497, 498, 6, 35, -1, 0, 498, 499, 5, 69, 0, 0, 499, 508, 5, 74, 0, 0, 500, 505, 3, 68, 34, 0, 501, 502, 5, 77, 0, 0, 502, 504, 3, 68, 34, 0, 503, 501, 1, 0, 0, 0, 504, 507, 1, 0, 0, 0, 505, 503, 1, 0, 0, 0, 505, 506, 1, 0, 0, 0, 506, 509, 1, 0, 0, 0, 507, 505, 1, 0, 0, 0, 508, 500, 1, 0, 0, 0, 508, 509, 1, 0, 0, 0, 509, 510, 1, 0, 0, 0, 510, 515, 5, 75, 0, 0, 511, 515, 5, 43, 0, 0, 512, 515, 5, 44, 0, 0, 513, 515, 5, 69, 0, 0, 514, 497, 1, 0, 0, 0, 514, 511, 1, 0, 0, 0, 514, 512, 1, 0, 0, 0, 514, 513, 1, 0, 0, 0, 515, 526, 1, 0, 0, 0, 516, 517, 10, 6, 0, 0, 517, 518, 5, 78, 0, 0, 518, 525, 5, 69, 0, 0, 519, 520, 10, 5, 0, 0, 520, 521, 5, 72, 0, 0, 521, 522, 3, 68, 34, 0, 522, 523, 5, 73, 0, 0, 523, 525, 1, 0, 0, 0, 524, 516, 1, 0, 0, 0, 524, 519, 1, 0, 0, 0, 525, 528, 1, 0, 0, 0, 526, 524, 1, 0, 0, 0, 526, 527, 1, 0, 0, 0, 527, 71, 1, 0, 0, 0, 528, 526, 1, 0, 0, 0, 529, 565, 5, 51, 0, 0, 530, 565, 5, 52, 0, 0, 531, 565, 5, 66, 0, 0, 532, 565, 5, 67, 0, 0, 533, 565, 5, 68, 0, 0, 534, 543, 5, 72, 0, 0, 535, 540, 3, 68, 34, 0, 536, 537, 5, 77, 0, 0, 537, 539, 3, 68, 34, 0, 538, 536, 1, 0, 0, 0, 539, 542, 1, 0, 0, 0, 540, 538, 1, 0, 0, 0, 540, 541, 1, 0, 0, 0, 541, 544, 1, 0, 0, 0, 542, 540, 1, 0, 0, 0, 543, 535, 1, 0, 0, 0, 543, 544, 1, 0, 0, 0, 544, 545, 1, 0, 0, 0, 545, 565, 5, 73, 0, 0, 546, 559, 5, 70, 0, 0, 547, 548, 7, 4, 0, 0, 548, 549, 5, 79, 0, 0, 549, 556, 3, 68, 34, 0, 550, 551, 5, 77, 0, 0, 551, 552, 7, 4, 0, 0, 552, 553, 5, 79, 0, 0, 553, 555, 3, 68, 34, 0, 554, 550, 1, 0, 0, 0, 555, 558, 1, 0, 0, 0, 556, 554, 1, 0, 0, 0, 556, 557, 1, 0, 0, 0, 557, 560, 1, 0, 0, 0, 558, 556, 1, 0, 0, 0, 559, 547, 1, 0, 0, 0, 559, 560, 1, 0, 0, 0, 560, 561, 1, 0, 0, 0, 561, 565, 5, 71, 0, 0, 562, 565, 5, 53, 0, 0, 563, 565, 5, 54, 0, 0, 564, 529, 1, 0, 0, 0, 564, 530, 1, 0, 0, 0, 564, 531, 1, 0, 0, 0, 564, 532, 1, 0, 0, 0, 564, 533, 1, 0, 0, 0, 564, 534, 1, 0, 0, 0, 564, 546, 1, 0, 0, 0, 564, 562, 1, 0, 0, 0, 564, 563, 1, 0, 0, 0, 565, 73, 1, 0, 0, 0, 70, 75, 78, 82, 84, 89, 91, 97, 99, 107, 126, 144, 150, 156, 160, 165, 170, 176, 180, 185, 190, 194, 196, 200, 205, 215, 218, 232, 235, 241, 247, 251, 259, 262, 265, 269, 279, 287, 293, 304, 308, 312, 315, 319, 321, 330, 334, 336, 347, 355, 367, 381, 384, 388, 398, 421, 463, 467, 490, 492, 494, 505, 508, 514, 524, 526, 540, 543, 556, 559, 564] \ No newline at end of file +[4, 1, 100, 568, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 1, 0, 3, 0, 76, 8, 0, 1, 0, 3, 0, 79, 8, 0, 1, 0, 1, 0, 5, 0, 83, 8, 0, 10, 0, 12, 0, 86, 9, 0, 1, 0, 1, 0, 5, 0, 90, 8, 0, 10, 0, 12, 0, 93, 9, 0, 1, 0, 1, 0, 1, 0, 5, 0, 98, 8, 0, 10, 0, 12, 0, 101, 9, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 108, 8, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 127, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 5, 8, 143, 8, 8, 10, 8, 12, 8, 146, 9, 8, 1, 8, 5, 8, 149, 8, 8, 10, 8, 12, 8, 152, 9, 8, 1, 8, 5, 8, 155, 8, 8, 10, 8, 12, 8, 158, 9, 8, 1, 8, 3, 8, 161, 8, 8, 1, 8, 4, 8, 164, 8, 8, 11, 8, 12, 8, 165, 1, 8, 5, 8, 169, 8, 8, 10, 8, 12, 8, 172, 9, 8, 1, 8, 5, 8, 175, 8, 8, 10, 8, 12, 8, 178, 9, 8, 1, 8, 3, 8, 181, 8, 8, 1, 8, 4, 8, 184, 8, 8, 11, 8, 12, 8, 185, 1, 8, 5, 8, 189, 8, 8, 10, 8, 12, 8, 192, 9, 8, 1, 8, 3, 8, 195, 8, 8, 3, 8, 197, 8, 8, 1, 9, 1, 9, 3, 9, 201, 8, 9, 1, 10, 1, 10, 1, 10, 3, 10, 206, 8, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 5, 12, 214, 8, 12, 10, 12, 12, 12, 217, 9, 12, 3, 12, 219, 8, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 5, 14, 231, 8, 14, 10, 14, 12, 14, 234, 9, 14, 3, 14, 236, 8, 14, 1, 14, 1, 14, 1, 15, 1, 15, 3, 15, 242, 8, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 248, 8, 15, 1, 16, 1, 16, 3, 16, 252, 8, 16, 1, 16, 1, 16, 1, 16, 1, 16, 5, 16, 258, 8, 16, 10, 16, 12, 16, 261, 9, 16, 3, 16, 263, 8, 16, 1, 16, 3, 16, 266, 8, 16, 1, 17, 1, 17, 3, 17, 270, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 280, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 4, 19, 286, 8, 19, 11, 19, 12, 19, 287, 1, 19, 1, 19, 1, 20, 1, 20, 3, 20, 294, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 305, 8, 21, 1, 22, 1, 22, 3, 22, 309, 8, 22, 1, 22, 1, 22, 3, 22, 313, 8, 22, 1, 22, 3, 22, 316, 8, 22, 1, 22, 1, 22, 3, 22, 320, 8, 22, 3, 22, 322, 8, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 5, 22, 329, 8, 22, 10, 22, 12, 22, 332, 9, 22, 1, 22, 3, 22, 335, 8, 22, 3, 22, 337, 8, 22, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 5, 23, 346, 8, 23, 10, 23, 12, 23, 349, 9, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 3, 24, 356, 8, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 3, 26, 368, 8, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 3, 28, 383, 8, 28, 1, 28, 3, 28, 386, 8, 28, 1, 28, 1, 28, 3, 28, 390, 8, 28, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 5, 29, 398, 8, 29, 10, 29, 12, 29, 401, 9, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 5, 33, 421, 8, 33, 10, 33, 12, 33, 424, 9, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 3, 34, 465, 8, 34, 1, 34, 1, 34, 3, 34, 469, 8, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 3, 34, 492, 8, 34, 5, 34, 494, 8, 34, 10, 34, 12, 34, 497, 9, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 505, 8, 35, 10, 35, 12, 35, 508, 9, 35, 3, 35, 510, 8, 35, 1, 35, 1, 35, 1, 35, 1, 35, 3, 35, 516, 8, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 526, 8, 35, 10, 35, 12, 35, 529, 9, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 540, 8, 36, 10, 36, 12, 36, 543, 9, 36, 3, 36, 545, 8, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 556, 8, 36, 10, 36, 12, 36, 559, 9, 36, 3, 36, 561, 8, 36, 1, 36, 1, 36, 1, 36, 3, 36, 566, 8, 36, 1, 36, 0, 2, 68, 70, 37, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 0, 5, 1, 0, 87, 88, 1, 0, 85, 86, 1, 0, 89, 92, 1, 0, 93, 94, 1, 0, 68, 69, 642, 0, 107, 1, 0, 0, 0, 2, 109, 1, 0, 0, 0, 4, 113, 1, 0, 0, 0, 6, 117, 1, 0, 0, 0, 8, 121, 1, 0, 0, 0, 10, 128, 1, 0, 0, 0, 12, 133, 1, 0, 0, 0, 14, 138, 1, 0, 0, 0, 16, 196, 1, 0, 0, 0, 18, 200, 1, 0, 0, 0, 20, 205, 1, 0, 0, 0, 22, 207, 1, 0, 0, 0, 24, 209, 1, 0, 0, 0, 26, 222, 1, 0, 0, 0, 28, 226, 1, 0, 0, 0, 30, 239, 1, 0, 0, 0, 32, 249, 1, 0, 0, 0, 34, 269, 1, 0, 0, 0, 36, 279, 1, 0, 0, 0, 38, 281, 1, 0, 0, 0, 40, 293, 1, 0, 0, 0, 42, 304, 1, 0, 0, 0, 44, 321, 1, 0, 0, 0, 46, 341, 1, 0, 0, 0, 48, 352, 1, 0, 0, 0, 50, 357, 1, 0, 0, 0, 52, 360, 1, 0, 0, 0, 54, 369, 1, 0, 0, 0, 56, 375, 1, 0, 0, 0, 58, 394, 1, 0, 0, 0, 60, 402, 1, 0, 0, 0, 62, 411, 1, 0, 0, 0, 64, 415, 1, 0, 0, 0, 66, 418, 1, 0, 0, 0, 68, 468, 1, 0, 0, 0, 70, 515, 1, 0, 0, 0, 72, 565, 1, 0, 0, 0, 74, 76, 3, 4, 2, 0, 75, 74, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 78, 1, 0, 0, 0, 77, 79, 3, 6, 3, 0, 78, 77, 1, 0, 0, 0, 78, 79, 1, 0, 0, 0, 79, 84, 1, 0, 0, 0, 80, 83, 3, 8, 4, 0, 81, 83, 3, 10, 5, 0, 82, 80, 1, 0, 0, 0, 82, 81, 1, 0, 0, 0, 83, 86, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 85, 1, 0, 0, 0, 85, 91, 1, 0, 0, 0, 86, 84, 1, 0, 0, 0, 87, 90, 3, 12, 6, 0, 88, 90, 3, 38, 19, 0, 89, 87, 1, 0, 0, 0, 89, 88, 1, 0, 0, 0, 90, 93, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 94, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 94, 99, 3, 2, 1, 0, 95, 98, 3, 12, 6, 0, 96, 98, 3, 38, 19, 0, 97, 95, 1, 0, 0, 0, 97, 96, 1, 0, 0, 0, 98, 101, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 99, 100, 1, 0, 0, 0, 100, 102, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 102, 103, 5, 0, 0, 1, 103, 108, 1, 0, 0, 0, 104, 105, 3, 18, 9, 0, 105, 106, 5, 0, 0, 1, 106, 108, 1, 0, 0, 0, 107, 75, 1, 0, 0, 0, 107, 104, 1, 0, 0, 0, 108, 1, 1, 0, 0, 0, 109, 110, 5, 6, 0, 0, 110, 111, 5, 11, 0, 0, 111, 112, 3, 18, 9, 0, 112, 3, 1, 0, 0, 0, 113, 114, 5, 1, 0, 0, 114, 115, 5, 11, 0, 0, 115, 116, 5, 27, 0, 0, 116, 5, 1, 0, 0, 0, 117, 118, 5, 2, 0, 0, 118, 119, 5, 11, 0, 0, 119, 120, 5, 27, 0, 0, 120, 7, 1, 0, 0, 0, 121, 122, 5, 3, 0, 0, 122, 123, 5, 11, 0, 0, 123, 126, 5, 22, 0, 0, 124, 125, 5, 12, 0, 0, 125, 127, 5, 22, 0, 0, 126, 124, 1, 0, 0, 0, 126, 127, 1, 0, 0, 0, 127, 9, 1, 0, 0, 0, 128, 129, 5, 4, 0, 0, 129, 130, 5, 22, 0, 0, 130, 131, 5, 11, 0, 0, 131, 132, 3, 36, 18, 0, 132, 11, 1, 0, 0, 0, 133, 134, 5, 5, 0, 0, 134, 135, 3, 14, 7, 0, 135, 136, 5, 11, 0, 0, 136, 137, 3, 16, 8, 0, 137, 13, 1, 0, 0, 0, 138, 139, 5, 23, 0, 0, 139, 15, 1, 0, 0, 0, 140, 144, 3, 20, 10, 0, 141, 143, 3, 32, 16, 0, 142, 141, 1, 0, 0, 0, 143, 146, 1, 0, 0, 0, 144, 142, 1, 0, 0, 0, 144, 145, 1, 0, 0, 0, 145, 150, 1, 0, 0, 0, 146, 144, 1, 0, 0, 0, 147, 149, 3, 30, 15, 0, 148, 147, 1, 0, 0, 0, 149, 152, 1, 0, 0, 0, 150, 148, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 156, 1, 0, 0, 0, 152, 150, 1, 0, 0, 0, 153, 155, 3, 22, 11, 0, 154, 153, 1, 0, 0, 0, 155, 158, 1, 0, 0, 0, 156, 154, 1, 0, 0, 0, 156, 157, 1, 0, 0, 0, 157, 160, 1, 0, 0, 0, 158, 156, 1, 0, 0, 0, 159, 161, 5, 20, 0, 0, 160, 159, 1, 0, 0, 0, 160, 161, 1, 0, 0, 0, 161, 197, 1, 0, 0, 0, 162, 164, 3, 32, 16, 0, 163, 162, 1, 0, 0, 0, 164, 165, 1, 0, 0, 0, 165, 163, 1, 0, 0, 0, 165, 166, 1, 0, 0, 0, 166, 170, 1, 0, 0, 0, 167, 169, 3, 30, 15, 0, 168, 167, 1, 0, 0, 0, 169, 172, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 170, 171, 1, 0, 0, 0, 171, 176, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 173, 175, 3, 22, 11, 0, 174, 173, 1, 0, 0, 0, 175, 178, 1, 0, 0, 0, 176, 174, 1, 0, 0, 0, 176, 177, 1, 0, 0, 0, 177, 180, 1, 0, 0, 0, 178, 176, 1, 0, 0, 0, 179, 181, 5, 20, 0, 0, 180, 179, 1, 0, 0, 0, 180, 181, 1, 0, 0, 0, 181, 197, 1, 0, 0, 0, 182, 184, 3, 30, 15, 0, 183, 182, 1, 0, 0, 0, 184, 185, 1, 0, 0, 0, 185, 183, 1, 0, 0, 0, 185, 186, 1, 0, 0, 0, 186, 190, 1, 0, 0, 0, 187, 189, 3, 22, 11, 0, 188, 187, 1, 0, 0, 0, 189, 192, 1, 0, 0, 0, 190, 188, 1, 0, 0, 0, 190, 191, 1, 0, 0, 0, 191, 194, 1, 0, 0, 0, 192, 190, 1, 0, 0, 0, 193, 195, 5, 20, 0, 0, 194, 193, 1, 0, 0, 0, 194, 195, 1, 0, 0, 0, 195, 197, 1, 0, 0, 0, 196, 140, 1, 0, 0, 0, 196, 163, 1, 0, 0, 0, 196, 183, 1, 0, 0, 0, 197, 17, 1, 0, 0, 0, 198, 201, 3, 16, 8, 0, 199, 201, 3, 14, 7, 0, 200, 198, 1, 0, 0, 0, 200, 199, 1, 0, 0, 0, 201, 19, 1, 0, 0, 0, 202, 206, 3, 36, 18, 0, 203, 206, 3, 24, 12, 0, 204, 206, 3, 28, 14, 0, 205, 202, 1, 0, 0, 0, 205, 203, 1, 0, 0, 0, 205, 204, 1, 0, 0, 0, 206, 21, 1, 0, 0, 0, 207, 208, 5, 26, 0, 0, 208, 23, 1, 0, 0, 0, 209, 218, 5, 14, 0, 0, 210, 215, 3, 26, 13, 0, 211, 212, 5, 12, 0, 0, 212, 214, 3, 26, 13, 0, 213, 211, 1, 0, 0, 0, 214, 217, 1, 0, 0, 0, 215, 213, 1, 0, 0, 0, 215, 216, 1, 0, 0, 0, 216, 219, 1, 0, 0, 0, 217, 215, 1, 0, 0, 0, 218, 210, 1, 0, 0, 0, 218, 219, 1, 0, 0, 0, 219, 220, 1, 0, 0, 0, 220, 221, 5, 15, 0, 0, 221, 25, 1, 0, 0, 0, 222, 223, 5, 27, 0, 0, 223, 224, 5, 11, 0, 0, 224, 225, 3, 18, 9, 0, 225, 27, 1, 0, 0, 0, 226, 235, 5, 16, 0, 0, 227, 232, 3, 18, 9, 0, 228, 229, 5, 12, 0, 0, 229, 231, 3, 18, 9, 0, 230, 228, 1, 0, 0, 0, 231, 234, 1, 0, 0, 0, 232, 230, 1, 0, 0, 0, 232, 233, 1, 0, 0, 0, 233, 236, 1, 0, 0, 0, 234, 232, 1, 0, 0, 0, 235, 227, 1, 0, 0, 0, 235, 236, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 238, 5, 17, 0, 0, 238, 29, 1, 0, 0, 0, 239, 241, 5, 24, 0, 0, 240, 242, 5, 13, 0, 0, 241, 240, 1, 0, 0, 0, 241, 242, 1, 0, 0, 0, 242, 247, 1, 0, 0, 0, 243, 244, 5, 18, 0, 0, 244, 245, 3, 14, 7, 0, 245, 246, 5, 19, 0, 0, 246, 248, 1, 0, 0, 0, 247, 243, 1, 0, 0, 0, 247, 248, 1, 0, 0, 0, 248, 31, 1, 0, 0, 0, 249, 251, 5, 25, 0, 0, 250, 252, 5, 13, 0, 0, 251, 250, 1, 0, 0, 0, 251, 252, 1, 0, 0, 0, 252, 265, 1, 0, 0, 0, 253, 262, 5, 18, 0, 0, 254, 259, 3, 34, 17, 0, 255, 256, 5, 12, 0, 0, 256, 258, 3, 34, 17, 0, 257, 255, 1, 0, 0, 0, 258, 261, 1, 0, 0, 0, 259, 257, 1, 0, 0, 0, 259, 260, 1, 0, 0, 0, 260, 263, 1, 0, 0, 0, 261, 259, 1, 0, 0, 0, 262, 254, 1, 0, 0, 0, 262, 263, 1, 0, 0, 0, 263, 264, 1, 0, 0, 0, 264, 266, 5, 19, 0, 0, 265, 253, 1, 0, 0, 0, 265, 266, 1, 0, 0, 0, 266, 33, 1, 0, 0, 0, 267, 270, 3, 20, 10, 0, 268, 270, 3, 22, 11, 0, 269, 267, 1, 0, 0, 0, 269, 268, 1, 0, 0, 0, 270, 35, 1, 0, 0, 0, 271, 280, 5, 8, 0, 0, 272, 280, 5, 9, 0, 0, 273, 280, 5, 27, 0, 0, 274, 280, 5, 28, 0, 0, 275, 280, 5, 29, 0, 0, 276, 280, 5, 30, 0, 0, 277, 280, 5, 10, 0, 0, 278, 280, 5, 21, 0, 0, 279, 271, 1, 0, 0, 0, 279, 272, 1, 0, 0, 0, 279, 273, 1, 0, 0, 0, 279, 274, 1, 0, 0, 0, 279, 275, 1, 0, 0, 0, 279, 276, 1, 0, 0, 0, 279, 277, 1, 0, 0, 0, 279, 278, 1, 0, 0, 0, 280, 37, 1, 0, 0, 0, 281, 282, 5, 7, 0, 0, 282, 283, 5, 79, 0, 0, 283, 285, 5, 70, 0, 0, 284, 286, 3, 40, 20, 0, 285, 284, 1, 0, 0, 0, 286, 287, 1, 0, 0, 0, 287, 285, 1, 0, 0, 0, 287, 288, 1, 0, 0, 0, 288, 289, 1, 0, 0, 0, 289, 290, 5, 71, 0, 0, 290, 39, 1, 0, 0, 0, 291, 294, 3, 44, 22, 0, 292, 294, 3, 46, 23, 0, 293, 291, 1, 0, 0, 0, 293, 292, 1, 0, 0, 0, 294, 41, 1, 0, 0, 0, 295, 305, 3, 46, 23, 0, 296, 305, 3, 50, 25, 0, 297, 305, 3, 52, 26, 0, 298, 305, 3, 54, 27, 0, 299, 305, 3, 56, 28, 0, 300, 305, 3, 60, 30, 0, 301, 305, 3, 62, 31, 0, 302, 305, 3, 64, 32, 0, 303, 305, 3, 66, 33, 0, 304, 295, 1, 0, 0, 0, 304, 296, 1, 0, 0, 0, 304, 297, 1, 0, 0, 0, 304, 298, 1, 0, 0, 0, 304, 299, 1, 0, 0, 0, 304, 300, 1, 0, 0, 0, 304, 301, 1, 0, 0, 0, 304, 302, 1, 0, 0, 0, 304, 303, 1, 0, 0, 0, 305, 43, 1, 0, 0, 0, 306, 308, 5, 42, 0, 0, 307, 309, 5, 48, 0, 0, 308, 307, 1, 0, 0, 0, 308, 309, 1, 0, 0, 0, 309, 322, 1, 0, 0, 0, 310, 312, 5, 50, 0, 0, 311, 313, 5, 42, 0, 0, 312, 311, 1, 0, 0, 0, 312, 313, 1, 0, 0, 0, 313, 315, 1, 0, 0, 0, 314, 316, 5, 48, 0, 0, 315, 314, 1, 0, 0, 0, 315, 316, 1, 0, 0, 0, 316, 322, 1, 0, 0, 0, 317, 319, 5, 45, 0, 0, 318, 320, 5, 48, 0, 0, 319, 318, 1, 0, 0, 0, 319, 320, 1, 0, 0, 0, 320, 322, 1, 0, 0, 0, 321, 306, 1, 0, 0, 0, 321, 310, 1, 0, 0, 0, 321, 317, 1, 0, 0, 0, 322, 323, 1, 0, 0, 0, 323, 324, 5, 69, 0, 0, 324, 336, 5, 74, 0, 0, 325, 330, 5, 69, 0, 0, 326, 327, 5, 77, 0, 0, 327, 329, 5, 69, 0, 0, 328, 326, 1, 0, 0, 0, 329, 332, 1, 0, 0, 0, 330, 328, 1, 0, 0, 0, 330, 331, 1, 0, 0, 0, 331, 334, 1, 0, 0, 0, 332, 330, 1, 0, 0, 0, 333, 335, 5, 81, 0, 0, 334, 333, 1, 0, 0, 0, 334, 335, 1, 0, 0, 0, 335, 337, 1, 0, 0, 0, 336, 325, 1, 0, 0, 0, 336, 337, 1, 0, 0, 0, 337, 338, 1, 0, 0, 0, 338, 339, 5, 75, 0, 0, 339, 340, 3, 66, 33, 0, 340, 45, 1, 0, 0, 0, 341, 342, 5, 34, 0, 0, 342, 347, 3, 48, 24, 0, 343, 344, 5, 77, 0, 0, 344, 346, 3, 48, 24, 0, 345, 343, 1, 0, 0, 0, 346, 349, 1, 0, 0, 0, 347, 345, 1, 0, 0, 0, 347, 348, 1, 0, 0, 0, 348, 350, 1, 0, 0, 0, 349, 347, 1, 0, 0, 0, 350, 351, 5, 76, 0, 0, 351, 47, 1, 0, 0, 0, 352, 355, 5, 69, 0, 0, 353, 354, 5, 82, 0, 0, 354, 356, 3, 68, 34, 0, 355, 353, 1, 0, 0, 0, 355, 356, 1, 0, 0, 0, 356, 49, 1, 0, 0, 0, 357, 358, 3, 68, 34, 0, 358, 359, 5, 76, 0, 0, 359, 51, 1, 0, 0, 0, 360, 361, 5, 35, 0, 0, 361, 362, 5, 74, 0, 0, 362, 363, 3, 68, 34, 0, 363, 364, 5, 75, 0, 0, 364, 367, 3, 42, 21, 0, 365, 366, 5, 36, 0, 0, 366, 368, 3, 42, 21, 0, 367, 365, 1, 0, 0, 0, 367, 368, 1, 0, 0, 0, 368, 53, 1, 0, 0, 0, 369, 370, 5, 37, 0, 0, 370, 371, 5, 74, 0, 0, 371, 372, 3, 68, 34, 0, 372, 373, 5, 75, 0, 0, 373, 374, 3, 42, 21, 0, 374, 55, 1, 0, 0, 0, 375, 376, 5, 38, 0, 0, 376, 382, 5, 74, 0, 0, 377, 383, 3, 46, 23, 0, 378, 379, 3, 58, 29, 0, 379, 380, 5, 76, 0, 0, 380, 383, 1, 0, 0, 0, 381, 383, 5, 76, 0, 0, 382, 377, 1, 0, 0, 0, 382, 378, 1, 0, 0, 0, 382, 381, 1, 0, 0, 0, 383, 385, 1, 0, 0, 0, 384, 386, 3, 68, 34, 0, 385, 384, 1, 0, 0, 0, 385, 386, 1, 0, 0, 0, 386, 387, 1, 0, 0, 0, 387, 389, 5, 76, 0, 0, 388, 390, 3, 58, 29, 0, 389, 388, 1, 0, 0, 0, 389, 390, 1, 0, 0, 0, 390, 391, 1, 0, 0, 0, 391, 392, 5, 75, 0, 0, 392, 393, 3, 42, 21, 0, 393, 57, 1, 0, 0, 0, 394, 399, 3, 68, 34, 0, 395, 396, 5, 77, 0, 0, 396, 398, 3, 68, 34, 0, 397, 395, 1, 0, 0, 0, 398, 401, 1, 0, 0, 0, 399, 397, 1, 0, 0, 0, 399, 400, 1, 0, 0, 0, 400, 59, 1, 0, 0, 0, 401, 399, 1, 0, 0, 0, 402, 403, 5, 39, 0, 0, 403, 404, 5, 74, 0, 0, 404, 405, 5, 34, 0, 0, 405, 406, 5, 69, 0, 0, 406, 407, 5, 40, 0, 0, 407, 408, 3, 68, 34, 0, 408, 409, 5, 75, 0, 0, 409, 410, 3, 42, 21, 0, 410, 61, 1, 0, 0, 0, 411, 412, 5, 49, 0, 0, 412, 413, 3, 68, 34, 0, 413, 414, 5, 76, 0, 0, 414, 63, 1, 0, 0, 0, 415, 416, 5, 41, 0, 0, 416, 417, 5, 76, 0, 0, 417, 65, 1, 0, 0, 0, 418, 422, 5, 70, 0, 0, 419, 421, 3, 42, 21, 0, 420, 419, 1, 0, 0, 0, 421, 424, 1, 0, 0, 0, 422, 420, 1, 0, 0, 0, 422, 423, 1, 0, 0, 0, 423, 425, 1, 0, 0, 0, 424, 422, 1, 0, 0, 0, 425, 426, 5, 71, 0, 0, 426, 67, 1, 0, 0, 0, 427, 428, 6, 34, -1, 0, 428, 469, 3, 70, 35, 0, 429, 430, 5, 86, 0, 0, 430, 469, 3, 68, 34, 19, 431, 432, 5, 95, 0, 0, 432, 469, 3, 68, 34, 18, 433, 434, 3, 70, 35, 0, 434, 435, 5, 83, 0, 0, 435, 469, 1, 0, 0, 0, 436, 437, 3, 70, 35, 0, 437, 438, 5, 84, 0, 0, 438, 469, 1, 0, 0, 0, 439, 440, 5, 83, 0, 0, 440, 469, 3, 70, 35, 0, 441, 442, 5, 84, 0, 0, 442, 469, 3, 70, 35, 0, 443, 444, 5, 80, 0, 0, 444, 469, 3, 68, 34, 10, 445, 446, 3, 70, 35, 0, 446, 447, 5, 82, 0, 0, 447, 448, 3, 68, 34, 5, 448, 469, 1, 0, 0, 0, 449, 469, 3, 72, 36, 0, 450, 451, 5, 74, 0, 0, 451, 452, 3, 68, 34, 0, 452, 453, 5, 75, 0, 0, 453, 469, 1, 0, 0, 0, 454, 455, 5, 46, 0, 0, 455, 456, 5, 74, 0, 0, 456, 457, 3, 68, 34, 0, 457, 458, 5, 75, 0, 0, 458, 469, 1, 0, 0, 0, 459, 460, 5, 47, 0, 0, 460, 461, 5, 74, 0, 0, 461, 464, 3, 68, 34, 0, 462, 463, 5, 77, 0, 0, 463, 465, 3, 68, 34, 0, 464, 462, 1, 0, 0, 0, 464, 465, 1, 0, 0, 0, 465, 466, 1, 0, 0, 0, 466, 467, 5, 75, 0, 0, 467, 469, 1, 0, 0, 0, 468, 427, 1, 0, 0, 0, 468, 429, 1, 0, 0, 0, 468, 431, 1, 0, 0, 0, 468, 433, 1, 0, 0, 0, 468, 436, 1, 0, 0, 0, 468, 439, 1, 0, 0, 0, 468, 441, 1, 0, 0, 0, 468, 443, 1, 0, 0, 0, 468, 445, 1, 0, 0, 0, 468, 449, 1, 0, 0, 0, 468, 450, 1, 0, 0, 0, 468, 454, 1, 0, 0, 0, 468, 459, 1, 0, 0, 0, 469, 495, 1, 0, 0, 0, 470, 471, 10, 13, 0, 0, 471, 472, 7, 0, 0, 0, 472, 494, 3, 68, 34, 14, 473, 474, 10, 12, 0, 0, 474, 475, 7, 1, 0, 0, 475, 494, 3, 68, 34, 13, 476, 477, 10, 9, 0, 0, 477, 478, 7, 2, 0, 0, 478, 494, 3, 68, 34, 10, 479, 480, 10, 8, 0, 0, 480, 481, 7, 3, 0, 0, 481, 494, 3, 68, 34, 9, 482, 483, 10, 7, 0, 0, 483, 484, 5, 96, 0, 0, 484, 494, 3, 68, 34, 8, 485, 486, 10, 6, 0, 0, 486, 487, 5, 97, 0, 0, 487, 494, 3, 68, 34, 7, 488, 489, 10, 11, 0, 0, 489, 491, 5, 80, 0, 0, 490, 492, 3, 68, 34, 0, 491, 490, 1, 0, 0, 0, 491, 492, 1, 0, 0, 0, 492, 494, 1, 0, 0, 0, 493, 470, 1, 0, 0, 0, 493, 473, 1, 0, 0, 0, 493, 476, 1, 0, 0, 0, 493, 479, 1, 0, 0, 0, 493, 482, 1, 0, 0, 0, 493, 485, 1, 0, 0, 0, 493, 488, 1, 0, 0, 0, 494, 497, 1, 0, 0, 0, 495, 493, 1, 0, 0, 0, 495, 496, 1, 0, 0, 0, 496, 69, 1, 0, 0, 0, 497, 495, 1, 0, 0, 0, 498, 499, 6, 35, -1, 0, 499, 500, 5, 69, 0, 0, 500, 509, 5, 74, 0, 0, 501, 506, 3, 68, 34, 0, 502, 503, 5, 77, 0, 0, 503, 505, 3, 68, 34, 0, 504, 502, 1, 0, 0, 0, 505, 508, 1, 0, 0, 0, 506, 504, 1, 0, 0, 0, 506, 507, 1, 0, 0, 0, 507, 510, 1, 0, 0, 0, 508, 506, 1, 0, 0, 0, 509, 501, 1, 0, 0, 0, 509, 510, 1, 0, 0, 0, 510, 511, 1, 0, 0, 0, 511, 516, 5, 75, 0, 0, 512, 516, 5, 43, 0, 0, 513, 516, 5, 44, 0, 0, 514, 516, 5, 69, 0, 0, 515, 498, 1, 0, 0, 0, 515, 512, 1, 0, 0, 0, 515, 513, 1, 0, 0, 0, 515, 514, 1, 0, 0, 0, 516, 527, 1, 0, 0, 0, 517, 518, 10, 6, 0, 0, 518, 519, 5, 78, 0, 0, 519, 526, 5, 69, 0, 0, 520, 521, 10, 5, 0, 0, 521, 522, 5, 72, 0, 0, 522, 523, 3, 68, 34, 0, 523, 524, 5, 73, 0, 0, 524, 526, 1, 0, 0, 0, 525, 517, 1, 0, 0, 0, 525, 520, 1, 0, 0, 0, 526, 529, 1, 0, 0, 0, 527, 525, 1, 0, 0, 0, 527, 528, 1, 0, 0, 0, 528, 71, 1, 0, 0, 0, 529, 527, 1, 0, 0, 0, 530, 566, 5, 51, 0, 0, 531, 566, 5, 52, 0, 0, 532, 566, 5, 66, 0, 0, 533, 566, 5, 67, 0, 0, 534, 566, 5, 68, 0, 0, 535, 544, 5, 72, 0, 0, 536, 541, 3, 68, 34, 0, 537, 538, 5, 77, 0, 0, 538, 540, 3, 68, 34, 0, 539, 537, 1, 0, 0, 0, 540, 543, 1, 0, 0, 0, 541, 539, 1, 0, 0, 0, 541, 542, 1, 0, 0, 0, 542, 545, 1, 0, 0, 0, 543, 541, 1, 0, 0, 0, 544, 536, 1, 0, 0, 0, 544, 545, 1, 0, 0, 0, 545, 546, 1, 0, 0, 0, 546, 566, 5, 73, 0, 0, 547, 560, 5, 70, 0, 0, 548, 549, 7, 4, 0, 0, 549, 550, 5, 79, 0, 0, 550, 557, 3, 68, 34, 0, 551, 552, 5, 77, 0, 0, 552, 553, 7, 4, 0, 0, 553, 554, 5, 79, 0, 0, 554, 556, 3, 68, 34, 0, 555, 551, 1, 0, 0, 0, 556, 559, 1, 0, 0, 0, 557, 555, 1, 0, 0, 0, 557, 558, 1, 0, 0, 0, 558, 561, 1, 0, 0, 0, 559, 557, 1, 0, 0, 0, 560, 548, 1, 0, 0, 0, 560, 561, 1, 0, 0, 0, 561, 562, 1, 0, 0, 0, 562, 566, 5, 71, 0, 0, 563, 566, 5, 53, 0, 0, 564, 566, 5, 54, 0, 0, 565, 530, 1, 0, 0, 0, 565, 531, 1, 0, 0, 0, 565, 532, 1, 0, 0, 0, 565, 533, 1, 0, 0, 0, 565, 534, 1, 0, 0, 0, 565, 535, 1, 0, 0, 0, 565, 547, 1, 0, 0, 0, 565, 563, 1, 0, 0, 0, 565, 564, 1, 0, 0, 0, 566, 73, 1, 0, 0, 0, 70, 75, 78, 82, 84, 89, 91, 97, 99, 107, 126, 144, 150, 156, 160, 165, 170, 176, 180, 185, 190, 194, 196, 200, 205, 215, 218, 232, 235, 241, 247, 251, 259, 262, 265, 269, 279, 287, 293, 304, 308, 312, 315, 319, 321, 330, 334, 336, 347, 355, 367, 382, 385, 389, 399, 422, 464, 468, 491, 493, 495, 506, 509, 515, 525, 527, 541, 544, 557, 560, 565] \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.java b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.java index 9e003ca..82836b6 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.java +++ b/src/main/java/com/relogiclabs/jschema/internal/antlr/SchemaParser.java @@ -2433,16 +2433,35 @@ public final ForStatementContext forStatement() throws RecognitionException { match(G_FOR); setState(376); match(G_LPAREN); - setState(381); + setState(382); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,50,_ctx) ) { - case 1: + switch (_input.LA(1)) { + case G_VAR: { setState(377); varStatement(); } break; - case 2: + case G_TARGET: + case G_CALLER: + case G_TRYOF: + case G_THROW: + case G_TRUE: + case G_FALSE: + case G_NULL: + case G_UNDEFINED: + case G_INTEGER: + case G_DOUBLE: + case G_STRING: + case G_IDENTIFIER: + case G_LBRACE: + case G_LBRACKET: + case G_LPAREN: + case G_RANGE: + case G_INC: + case G_DEC: + case G_MINUS: + case G_NOT: { setState(378); ((ForStatementContext)_localctx).initialization = expressionList(); @@ -2450,32 +2469,40 @@ public final ForStatementContext forStatement() throws RecognitionException { match(G_SEMI); } break; + case G_SEMI: + { + setState(381); + match(G_SEMI); + } + break; + default: + throw new NoViableAltException(this); } - setState(384); + setState(385); _errHandler.sync(this); _la = _input.LA(1); if (((((_la - 43)) & ~0x3f) == 0 && ((1L << (_la - 43)) & 4515834638634779L) != 0)) { { - setState(383); + setState(384); ((ForStatementContext)_localctx).condition = expression(0); } } - setState(386); + setState(387); match(G_SEMI); - setState(388); + setState(389); _errHandler.sync(this); _la = _input.LA(1); if (((((_la - 43)) & ~0x3f) == 0 && ((1L << (_la - 43)) & 4515834638634779L) != 0)) { { - setState(387); + setState(388); ((ForStatementContext)_localctx).updation = expressionList(); } } - setState(390); - match(G_RPAREN); setState(391); + match(G_RPAREN); + setState(392); statement(); } } @@ -2520,21 +2547,21 @@ public final ExpressionListContext expressionList() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(393); + setState(394); expression(0); - setState(398); + setState(399); _errHandler.sync(this); _la = _input.LA(1); while (_la==G_COMMA) { { { - setState(394); - match(G_COMMA); setState(395); + match(G_COMMA); + setState(396); expression(0); } } - setState(400); + setState(401); _errHandler.sync(this); _la = _input.LA(1); } @@ -2582,21 +2609,21 @@ public final ForeachStatementContext foreachStatement() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(401); - match(G_FOREACH); setState(402); - match(G_LPAREN); + match(G_FOREACH); setState(403); - match(G_VAR); + match(G_LPAREN); setState(404); - match(G_IDENTIFIER); + match(G_VAR); setState(405); - match(G_IN); + match(G_IDENTIFIER); setState(406); - expression(0); + match(G_IN); setState(407); - match(G_RPAREN); + expression(0); setState(408); + match(G_RPAREN); + setState(409); statement(); } } @@ -2635,11 +2662,11 @@ public final ReturnStatementContext returnStatement() throws RecognitionExceptio try { enterOuterAlt(_localctx, 1); { - setState(410); - match(G_RETURN); setState(411); - expression(0); + match(G_RETURN); setState(412); + expression(0); + setState(413); match(G_SEMI); } } @@ -2675,9 +2702,9 @@ public final BreakStatementContext breakStatement() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(414); - match(G_BREAK); setState(415); + match(G_BREAK); + setState(416); match(G_SEMI); } } @@ -2720,23 +2747,23 @@ public final BlockStatementContext blockStatement() throws RecognitionException try { enterOuterAlt(_localctx, 1); { - setState(417); + setState(418); match(G_LBRACE); - setState(421); + setState(422); _errHandler.sync(this); _la = _input.LA(1); while (((((_la - 34)) & ~0x3f) == 0 && ((1L << (_la - 34)) & 2312107334981039803L) != 0)) { { { - setState(418); + setState(419); statement(); } } - setState(423); + setState(424); _errHandler.sync(this); _la = _input.LA(1); } - setState(424); + setState(425); match(G_RBRACE); } } @@ -3077,7 +3104,7 @@ private ExpressionContext expression(int _p) throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(467); + setState(468); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,56,_ctx) ) { case 1: @@ -3086,7 +3113,7 @@ private ExpressionContext expression(int _p) throws RecognitionException { _ctx = _localctx; _prevctx = _localctx; - setState(427); + setState(428); refExpression(0); } break; @@ -3095,9 +3122,9 @@ private ExpressionContext expression(int _p) throws RecognitionException { _localctx = new UnaryMinusExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(428); - match(G_MINUS); setState(429); + match(G_MINUS); + setState(430); expression(19); } break; @@ -3106,9 +3133,9 @@ private ExpressionContext expression(int _p) throws RecognitionException { _localctx = new LogicalNotExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(430); - match(G_NOT); setState(431); + match(G_NOT); + setState(432); expression(18); } break; @@ -3117,9 +3144,9 @@ private ExpressionContext expression(int _p) throws RecognitionException { _localctx = new PostIncrementExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(432); - refExpression(0); setState(433); + refExpression(0); + setState(434); match(G_INC); } break; @@ -3128,9 +3155,9 @@ private ExpressionContext expression(int _p) throws RecognitionException { _localctx = new PostDecrementExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(435); - refExpression(0); setState(436); + refExpression(0); + setState(437); match(G_DEC); } break; @@ -3139,9 +3166,9 @@ private ExpressionContext expression(int _p) throws RecognitionException { _localctx = new PreIncrementExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(438); - match(G_INC); setState(439); + match(G_INC); + setState(440); refExpression(0); } break; @@ -3150,9 +3177,9 @@ private ExpressionContext expression(int _p) throws RecognitionException { _localctx = new PreDecrementExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(440); - match(G_DEC); setState(441); + match(G_DEC); + setState(442); refExpression(0); } break; @@ -3161,9 +3188,9 @@ private ExpressionContext expression(int _p) throws RecognitionException { _localctx = new RangeEndExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(442); - match(G_RANGE); setState(443); + match(G_RANGE); + setState(444); expression(10); } break; @@ -3172,11 +3199,11 @@ private ExpressionContext expression(int _p) throws RecognitionException { _localctx = new AssignmentExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(444); - refExpression(0); setState(445); - match(G_ASSIGN); + refExpression(0); setState(446); + match(G_ASSIGN); + setState(447); expression(5); } break; @@ -3185,7 +3212,7 @@ private ExpressionContext expression(int _p) throws RecognitionException { _localctx = new LiteralExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(448); + setState(449); literal(); } break; @@ -3194,11 +3221,11 @@ private ExpressionContext expression(int _p) throws RecognitionException { _localctx = new ParenthesizedExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(449); - match(G_LPAREN); setState(450); - expression(0); + match(G_LPAREN); setState(451); + expression(0); + setState(452); match(G_RPAREN); } break; @@ -3207,13 +3234,13 @@ private ExpressionContext expression(int _p) throws RecognitionException { _localctx = new TryofExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(453); - match(G_TRYOF); setState(454); - match(G_LPAREN); + match(G_TRYOF); setState(455); - expression(0); + match(G_LPAREN); setState(456); + expression(0); + setState(457); match(G_RPAREN); } break; @@ -3222,31 +3249,31 @@ private ExpressionContext expression(int _p) throws RecognitionException { _localctx = new ThrowExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(458); - match(G_THROW); setState(459); - match(G_LPAREN); + match(G_THROW); setState(460); + match(G_LPAREN); + setState(461); expression(0); - setState(463); + setState(464); _errHandler.sync(this); _la = _input.LA(1); if (_la==G_COMMA) { { - setState(461); - match(G_COMMA); setState(462); + match(G_COMMA); + setState(463); expression(0); } } - setState(465); + setState(466); match(G_RPAREN); } break; } _ctx.stop = _input.LT(-1); - setState(494); + setState(495); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,59,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { @@ -3254,16 +3281,16 @@ private ExpressionContext expression(int _p) throws RecognitionException { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; { - setState(492); + setState(493); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,58,_ctx) ) { case 1: { _localctx = new MultiplicativeExpressionContext(new ExpressionContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(469); - if (!(precpred(_ctx, 13))) throw new FailedPredicateException(this, "precpred(_ctx, 13)"); setState(470); + if (!(precpred(_ctx, 13))) throw new FailedPredicateException(this, "precpred(_ctx, 13)"); + setState(471); _la = _input.LA(1); if ( !(_la==G_MUL || _la==G_DIV) ) { _errHandler.recoverInline(this); @@ -3273,7 +3300,7 @@ private ExpressionContext expression(int _p) throws RecognitionException { _errHandler.reportMatch(this); consume(); } - setState(471); + setState(472); expression(14); } break; @@ -3281,9 +3308,9 @@ private ExpressionContext expression(int _p) throws RecognitionException { { _localctx = new AdditiveExpressionContext(new ExpressionContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(472); - if (!(precpred(_ctx, 12))) throw new FailedPredicateException(this, "precpred(_ctx, 12)"); setState(473); + if (!(precpred(_ctx, 12))) throw new FailedPredicateException(this, "precpred(_ctx, 12)"); + setState(474); _la = _input.LA(1); if ( !(_la==G_PLUS || _la==G_MINUS) ) { _errHandler.recoverInline(this); @@ -3293,7 +3320,7 @@ private ExpressionContext expression(int _p) throws RecognitionException { _errHandler.reportMatch(this); consume(); } - setState(474); + setState(475); expression(13); } break; @@ -3301,9 +3328,9 @@ private ExpressionContext expression(int _p) throws RecognitionException { { _localctx = new RelationalExpressionContext(new ExpressionContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(475); - if (!(precpred(_ctx, 9))) throw new FailedPredicateException(this, "precpred(_ctx, 9)"); setState(476); + if (!(precpred(_ctx, 9))) throw new FailedPredicateException(this, "precpred(_ctx, 9)"); + setState(477); _la = _input.LA(1); if ( !(((((_la - 89)) & ~0x3f) == 0 && ((1L << (_la - 89)) & 15L) != 0)) ) { _errHandler.recoverInline(this); @@ -3313,7 +3340,7 @@ private ExpressionContext expression(int _p) throws RecognitionException { _errHandler.reportMatch(this); consume(); } - setState(477); + setState(478); expression(10); } break; @@ -3321,9 +3348,9 @@ private ExpressionContext expression(int _p) throws RecognitionException { { _localctx = new EqualityExpressionContext(new ExpressionContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(478); - if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); setState(479); + if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); + setState(480); _la = _input.LA(1); if ( !(_la==G_EQ || _la==G_NE) ) { _errHandler.recoverInline(this); @@ -3333,7 +3360,7 @@ private ExpressionContext expression(int _p) throws RecognitionException { _errHandler.reportMatch(this); consume(); } - setState(480); + setState(481); expression(9); } break; @@ -3341,11 +3368,11 @@ private ExpressionContext expression(int _p) throws RecognitionException { { _localctx = new LogicalAndExpressionContext(new ExpressionContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(481); - if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); setState(482); - match(G_AND); + if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); setState(483); + match(G_AND); + setState(484); expression(8); } break; @@ -3353,11 +3380,11 @@ private ExpressionContext expression(int _p) throws RecognitionException { { _localctx = new LogicalOrExpressionContext(new ExpressionContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(484); - if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); setState(485); - match(G_OR); + if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); setState(486); + match(G_OR); + setState(487); expression(7); } break; @@ -3365,16 +3392,16 @@ private ExpressionContext expression(int _p) throws RecognitionException { { _localctx = new RangeBothExpressionContext(new ExpressionContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(487); - if (!(precpred(_ctx, 11))) throw new FailedPredicateException(this, "precpred(_ctx, 11)"); setState(488); + if (!(precpred(_ctx, 11))) throw new FailedPredicateException(this, "precpred(_ctx, 11)"); + setState(489); match(G_RANGE); - setState(490); + setState(491); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,57,_ctx) ) { case 1: { - setState(489); + setState(490); expression(0); } break; @@ -3384,7 +3411,7 @@ private ExpressionContext expression(int _p) throws RecognitionException { } } } - setState(496); + setState(497); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,59,_ctx); } @@ -3513,7 +3540,7 @@ private RefExpressionContext refExpression(int _p) throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(514); + setState(515); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,62,_ctx) ) { case 1: @@ -3522,37 +3549,37 @@ private RefExpressionContext refExpression(int _p) throws RecognitionException { _ctx = _localctx; _prevctx = _localctx; - setState(498); - match(G_IDENTIFIER); setState(499); + match(G_IDENTIFIER); + setState(500); match(G_LPAREN); - setState(508); + setState(509); _errHandler.sync(this); _la = _input.LA(1); if (((((_la - 43)) & ~0x3f) == 0 && ((1L << (_la - 43)) & 4515834638634779L) != 0)) { { - setState(500); + setState(501); expression(0); - setState(505); + setState(506); _errHandler.sync(this); _la = _input.LA(1); while (_la==G_COMMA) { { { - setState(501); - match(G_COMMA); setState(502); + match(G_COMMA); + setState(503); expression(0); } } - setState(507); + setState(508); _errHandler.sync(this); _la = _input.LA(1); } } } - setState(510); + setState(511); match(G_RPAREN); } break; @@ -3561,7 +3588,7 @@ private RefExpressionContext refExpression(int _p) throws RecognitionException { _localctx = new TargetExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(511); + setState(512); match(G_TARGET); } break; @@ -3570,7 +3597,7 @@ private RefExpressionContext refExpression(int _p) throws RecognitionException { _localctx = new CallerExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(512); + setState(513); match(G_CALLER); } break; @@ -3579,13 +3606,13 @@ private RefExpressionContext refExpression(int _p) throws RecognitionException { _localctx = new IdentifierExpressionContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(513); + setState(514); match(G_IDENTIFIER); } break; } _ctx.stop = _input.LT(-1); - setState(526); + setState(527); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,64,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { @@ -3593,18 +3620,18 @@ private RefExpressionContext refExpression(int _p) throws RecognitionException { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; { - setState(524); + setState(525); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,63,_ctx) ) { case 1: { _localctx = new DotExpressionContext(new RefExpressionContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_refExpression); - setState(516); - if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); setState(517); - match(G_DOT); + if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); setState(518); + match(G_DOT); + setState(519); match(G_IDENTIFIER); } break; @@ -3612,20 +3639,20 @@ private RefExpressionContext refExpression(int _p) throws RecognitionException { { _localctx = new IndexExpressionContext(new RefExpressionContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_refExpression); - setState(519); - if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); setState(520); - match(G_LBRACKET); + if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); setState(521); - expression(0); + match(G_LBRACKET); setState(522); + expression(0); + setState(523); match(G_RBRACKET); } break; } } } - setState(528); + setState(529); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,64,_ctx); } @@ -3659,10 +3686,10 @@ public static class ObjectLiteralContext extends LiteralContext { public Token G_IDENTIFIER; public List keys = new ArrayList(); public Token G_STRING; - public Token _tset1193; + public Token _tset1196; public ExpressionContext expression; public List values = new ArrayList(); - public Token _tset1215; + public Token _tset1218; public TerminalNode G_LBRACE() { return getToken(SchemaParser.G_LBRACE, 0); } public TerminalNode G_RBRACE() { return getToken(SchemaParser.G_RBRACE, 0); } public List G_COLON() { return getTokens(SchemaParser.G_COLON); } @@ -3791,14 +3818,14 @@ public final LiteralContext literal() throws RecognitionException { enterRule(_localctx, 72, RULE_literal); int _la; try { - setState(564); + setState(565); _errHandler.sync(this); switch (_input.LA(1)) { case G_TRUE: _localctx = new TrueLiteralContext(_localctx); enterOuterAlt(_localctx, 1); { - setState(529); + setState(530); match(G_TRUE); } break; @@ -3806,7 +3833,7 @@ public final LiteralContext literal() throws RecognitionException { _localctx = new FalseLiteralContext(_localctx); enterOuterAlt(_localctx, 2); { - setState(530); + setState(531); match(G_FALSE); } break; @@ -3814,7 +3841,7 @@ public final LiteralContext literal() throws RecognitionException { _localctx = new IntegerLiteralContext(_localctx); enterOuterAlt(_localctx, 3); { - setState(531); + setState(532); match(G_INTEGER); } break; @@ -3822,7 +3849,7 @@ public final LiteralContext literal() throws RecognitionException { _localctx = new DoubleLiteralContext(_localctx); enterOuterAlt(_localctx, 4); { - setState(532); + setState(533); match(G_DOUBLE); } break; @@ -3830,7 +3857,7 @@ public final LiteralContext literal() throws RecognitionException { _localctx = new StringLiteralContext(_localctx); enterOuterAlt(_localctx, 5); { - setState(533); + setState(534); match(G_STRING); } break; @@ -3838,35 +3865,35 @@ public final LiteralContext literal() throws RecognitionException { _localctx = new ArrayLiteralContext(_localctx); enterOuterAlt(_localctx, 6); { - setState(534); + setState(535); match(G_LBRACKET); - setState(543); + setState(544); _errHandler.sync(this); _la = _input.LA(1); if (((((_la - 43)) & ~0x3f) == 0 && ((1L << (_la - 43)) & 4515834638634779L) != 0)) { { - setState(535); + setState(536); expression(0); - setState(540); + setState(541); _errHandler.sync(this); _la = _input.LA(1); while (_la==G_COMMA) { { { - setState(536); - match(G_COMMA); setState(537); + match(G_COMMA); + setState(538); expression(0); } } - setState(542); + setState(543); _errHandler.sync(this); _la = _input.LA(1); } } } - setState(545); + setState(546); match(G_RBRACKET); } break; @@ -3874,65 +3901,65 @@ public final LiteralContext literal() throws RecognitionException { _localctx = new ObjectLiteralContext(_localctx); enterOuterAlt(_localctx, 7); { - setState(546); + setState(547); match(G_LBRACE); - setState(559); + setState(560); _errHandler.sync(this); _la = _input.LA(1); if (_la==G_STRING || _la==G_IDENTIFIER) { { - setState(547); - ((ObjectLiteralContext)_localctx)._tset1193 = _input.LT(1); + setState(548); + ((ObjectLiteralContext)_localctx)._tset1196 = _input.LT(1); _la = _input.LA(1); if ( !(_la==G_STRING || _la==G_IDENTIFIER) ) { - ((ObjectLiteralContext)_localctx)._tset1193 = (Token)_errHandler.recoverInline(this); + ((ObjectLiteralContext)_localctx)._tset1196 = (Token)_errHandler.recoverInline(this); } else { if ( _input.LA(1)==Token.EOF ) matchedEOF = true; _errHandler.reportMatch(this); consume(); } - ((ObjectLiteralContext)_localctx).keys.add(((ObjectLiteralContext)_localctx)._tset1193); - setState(548); - match(G_COLON); + ((ObjectLiteralContext)_localctx).keys.add(((ObjectLiteralContext)_localctx)._tset1196); setState(549); + match(G_COLON); + setState(550); ((ObjectLiteralContext)_localctx).expression = expression(0); ((ObjectLiteralContext)_localctx).values.add(((ObjectLiteralContext)_localctx).expression); - setState(556); + setState(557); _errHandler.sync(this); _la = _input.LA(1); while (_la==G_COMMA) { { { - setState(550); - match(G_COMMA); setState(551); - ((ObjectLiteralContext)_localctx)._tset1215 = _input.LT(1); + match(G_COMMA); + setState(552); + ((ObjectLiteralContext)_localctx)._tset1218 = _input.LT(1); _la = _input.LA(1); if ( !(_la==G_STRING || _la==G_IDENTIFIER) ) { - ((ObjectLiteralContext)_localctx)._tset1215 = (Token)_errHandler.recoverInline(this); + ((ObjectLiteralContext)_localctx)._tset1218 = (Token)_errHandler.recoverInline(this); } else { if ( _input.LA(1)==Token.EOF ) matchedEOF = true; _errHandler.reportMatch(this); consume(); } - ((ObjectLiteralContext)_localctx).keys.add(((ObjectLiteralContext)_localctx)._tset1215); - setState(552); - match(G_COLON); + ((ObjectLiteralContext)_localctx).keys.add(((ObjectLiteralContext)_localctx)._tset1218); setState(553); + match(G_COLON); + setState(554); ((ObjectLiteralContext)_localctx).expression = expression(0); ((ObjectLiteralContext)_localctx).values.add(((ObjectLiteralContext)_localctx).expression); } } - setState(558); + setState(559); _errHandler.sync(this); _la = _input.LA(1); } } } - setState(561); + setState(562); match(G_RBRACE); } break; @@ -3940,7 +3967,7 @@ public final LiteralContext literal() throws RecognitionException { _localctx = new NullLiteralContext(_localctx); enterOuterAlt(_localctx, 8); { - setState(562); + setState(563); match(G_NULL); } break; @@ -3948,7 +3975,7 @@ public final LiteralContext literal() throws RecognitionException { _localctx = new UndefinedLiteralContext(_localctx); enterOuterAlt(_localctx, 9); { - setState(563); + setState(564); match(G_UNDEFINED); } break; @@ -4006,7 +4033,7 @@ private boolean refExpression_sempred(RefExpressionContext _localctx, int predIn } public static final String _serializedATN = - "\u0004\u0001d\u0237\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ + "\u0004\u0001d\u0238\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ "\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+ "\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007\u0002"+ "\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b\u0007\u000b\u0002"+ @@ -4063,330 +4090,331 @@ private boolean refExpression_sempred(RefExpressionContext _localctx, int predIn "\u0019\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001a\u0001"+ "\u001a\u0001\u001a\u0003\u001a\u0170\b\u001a\u0001\u001b\u0001\u001b\u0001"+ "\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001c\u0001\u001c\u0001"+ - "\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0003\u001c\u017e\b\u001c\u0001"+ - "\u001c\u0003\u001c\u0181\b\u001c\u0001\u001c\u0001\u001c\u0003\u001c\u0185"+ - "\b\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001d\u0001\u001d\u0001"+ - "\u001d\u0005\u001d\u018d\b\u001d\n\u001d\f\u001d\u0190\t\u001d\u0001\u001e"+ - "\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e"+ - "\u0001\u001e\u0001\u001e\u0001\u001f\u0001\u001f\u0001\u001f\u0001\u001f"+ - "\u0001 \u0001 \u0001 \u0001!\u0001!\u0005!\u01a4\b!\n!\f!\u01a7\t!\u0001"+ - "!\u0001!\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ - "\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ + "\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0003\u001c\u017f"+ + "\b\u001c\u0001\u001c\u0003\u001c\u0182\b\u001c\u0001\u001c\u0001\u001c"+ + "\u0003\u001c\u0186\b\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001d"+ + "\u0001\u001d\u0001\u001d\u0005\u001d\u018e\b\u001d\n\u001d\f\u001d\u0191"+ + "\t\u001d\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001"+ + "\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001f\u0001\u001f\u0001"+ + "\u001f\u0001\u001f\u0001 \u0001 \u0001 \u0001!\u0001!\u0005!\u01a5\b!"+ + "\n!\f!\u01a8\t!\u0001!\u0001!\u0001\"\u0001\"\u0001\"\u0001\"\u0001\""+ + "\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ "\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ "\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ - "\"\u0001\"\u0001\"\u0003\"\u01d0\b\"\u0001\"\u0001\"\u0003\"\u01d4\b\""+ - "\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ + "\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0003\"\u01d1\b\"\u0001\"\u0001"+ + "\"\u0003\"\u01d5\b\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ "\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001"+ - "\"\u0001\"\u0001\"\u0001\"\u0003\"\u01eb\b\"\u0005\"\u01ed\b\"\n\"\f\""+ - "\u01f0\t\"\u0001#\u0001#\u0001#\u0001#\u0001#\u0001#\u0005#\u01f8\b#\n"+ - "#\f#\u01fb\t#\u0003#\u01fd\b#\u0001#\u0001#\u0001#\u0001#\u0003#\u0203"+ - "\b#\u0001#\u0001#\u0001#\u0001#\u0001#\u0001#\u0001#\u0001#\u0005#\u020d"+ - "\b#\n#\f#\u0210\t#\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0001"+ - "$\u0001$\u0005$\u021b\b$\n$\f$\u021e\t$\u0003$\u0220\b$\u0001$\u0001$"+ - "\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0005$\u022b\b$\n$\f"+ - "$\u022e\t$\u0003$\u0230\b$\u0001$\u0001$\u0001$\u0003$\u0235\b$\u0001"+ - "$\u0000\u0002DF%\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014"+ - "\u0016\u0018\u001a\u001c\u001e \"$&(*,.02468:<>@BDFH\u0000\u0005\u0001"+ - "\u0000WX\u0001\u0000UV\u0001\u0000Y\\\u0001\u0000]^\u0001\u0000DE\u0281"+ - "\u0000k\u0001\u0000\u0000\u0000\u0002m\u0001\u0000\u0000\u0000\u0004q"+ - "\u0001\u0000\u0000\u0000\u0006u\u0001\u0000\u0000\u0000\by\u0001\u0000"+ - "\u0000\u0000\n\u0080\u0001\u0000\u0000\u0000\f\u0085\u0001\u0000\u0000"+ - "\u0000\u000e\u008a\u0001\u0000\u0000\u0000\u0010\u00c4\u0001\u0000\u0000"+ - "\u0000\u0012\u00c8\u0001\u0000\u0000\u0000\u0014\u00cd\u0001\u0000\u0000"+ - "\u0000\u0016\u00cf\u0001\u0000\u0000\u0000\u0018\u00d1\u0001\u0000\u0000"+ - "\u0000\u001a\u00de\u0001\u0000\u0000\u0000\u001c\u00e2\u0001\u0000\u0000"+ - "\u0000\u001e\u00ef\u0001\u0000\u0000\u0000 \u00f9\u0001\u0000\u0000\u0000"+ - "\"\u010d\u0001\u0000\u0000\u0000$\u0117\u0001\u0000\u0000\u0000&\u0119"+ - "\u0001\u0000\u0000\u0000(\u0125\u0001\u0000\u0000\u0000*\u0130\u0001\u0000"+ - "\u0000\u0000,\u0141\u0001\u0000\u0000\u0000.\u0155\u0001\u0000\u0000\u0000"+ - "0\u0160\u0001\u0000\u0000\u00002\u0165\u0001\u0000\u0000\u00004\u0168"+ - "\u0001\u0000\u0000\u00006\u0171\u0001\u0000\u0000\u00008\u0177\u0001\u0000"+ - "\u0000\u0000:\u0189\u0001\u0000\u0000\u0000<\u0191\u0001\u0000\u0000\u0000"+ - ">\u019a\u0001\u0000\u0000\u0000@\u019e\u0001\u0000\u0000\u0000B\u01a1"+ - "\u0001\u0000\u0000\u0000D\u01d3\u0001\u0000\u0000\u0000F\u0202\u0001\u0000"+ - "\u0000\u0000H\u0234\u0001\u0000\u0000\u0000JL\u0003\u0004\u0002\u0000"+ - "KJ\u0001\u0000\u0000\u0000KL\u0001\u0000\u0000\u0000LN\u0001\u0000\u0000"+ - "\u0000MO\u0003\u0006\u0003\u0000NM\u0001\u0000\u0000\u0000NO\u0001\u0000"+ - "\u0000\u0000OT\u0001\u0000\u0000\u0000PS\u0003\b\u0004\u0000QS\u0003\n"+ - "\u0005\u0000RP\u0001\u0000\u0000\u0000RQ\u0001\u0000\u0000\u0000SV\u0001"+ - "\u0000\u0000\u0000TR\u0001\u0000\u0000\u0000TU\u0001\u0000\u0000\u0000"+ - "U[\u0001\u0000\u0000\u0000VT\u0001\u0000\u0000\u0000WZ\u0003\f\u0006\u0000"+ - "XZ\u0003&\u0013\u0000YW\u0001\u0000\u0000\u0000YX\u0001\u0000\u0000\u0000"+ - "Z]\u0001\u0000\u0000\u0000[Y\u0001\u0000\u0000\u0000[\\\u0001\u0000\u0000"+ - "\u0000\\^\u0001\u0000\u0000\u0000][\u0001\u0000\u0000\u0000^c\u0003\u0002"+ - "\u0001\u0000_b\u0003\f\u0006\u0000`b\u0003&\u0013\u0000a_\u0001\u0000"+ - "\u0000\u0000a`\u0001\u0000\u0000\u0000be\u0001\u0000\u0000\u0000ca\u0001"+ - "\u0000\u0000\u0000cd\u0001\u0000\u0000\u0000df\u0001\u0000\u0000\u0000"+ - "ec\u0001\u0000\u0000\u0000fg\u0005\u0000\u0000\u0001gl\u0001\u0000\u0000"+ - "\u0000hi\u0003\u0012\t\u0000ij\u0005\u0000\u0000\u0001jl\u0001\u0000\u0000"+ - "\u0000kK\u0001\u0000\u0000\u0000kh\u0001\u0000\u0000\u0000l\u0001\u0001"+ - "\u0000\u0000\u0000mn\u0005\u0006\u0000\u0000no\u0005\u000b\u0000\u0000"+ - "op\u0003\u0012\t\u0000p\u0003\u0001\u0000\u0000\u0000qr\u0005\u0001\u0000"+ - "\u0000rs\u0005\u000b\u0000\u0000st\u0005\u001b\u0000\u0000t\u0005\u0001"+ - "\u0000\u0000\u0000uv\u0005\u0002\u0000\u0000vw\u0005\u000b\u0000\u0000"+ - "wx\u0005\u001b\u0000\u0000x\u0007\u0001\u0000\u0000\u0000yz\u0005\u0003"+ - "\u0000\u0000z{\u0005\u000b\u0000\u0000{~\u0005\u0016\u0000\u0000|}\u0005"+ - "\f\u0000\u0000}\u007f\u0005\u0016\u0000\u0000~|\u0001\u0000\u0000\u0000"+ - "~\u007f\u0001\u0000\u0000\u0000\u007f\t\u0001\u0000\u0000\u0000\u0080"+ - "\u0081\u0005\u0004\u0000\u0000\u0081\u0082\u0005\u0016\u0000\u0000\u0082"+ - "\u0083\u0005\u000b\u0000\u0000\u0083\u0084\u0003$\u0012\u0000\u0084\u000b"+ - "\u0001\u0000\u0000\u0000\u0085\u0086\u0005\u0005\u0000\u0000\u0086\u0087"+ - "\u0003\u000e\u0007\u0000\u0087\u0088\u0005\u000b\u0000\u0000\u0088\u0089"+ - "\u0003\u0010\b\u0000\u0089\r\u0001\u0000\u0000\u0000\u008a\u008b\u0005"+ - "\u0017\u0000\u0000\u008b\u000f\u0001\u0000\u0000\u0000\u008c\u0090\u0003"+ - "\u0014\n\u0000\u008d\u008f\u0003 \u0010\u0000\u008e\u008d\u0001\u0000"+ - "\u0000\u0000\u008f\u0092\u0001\u0000\u0000\u0000\u0090\u008e\u0001\u0000"+ - "\u0000\u0000\u0090\u0091\u0001\u0000\u0000\u0000\u0091\u0096\u0001\u0000"+ - "\u0000\u0000\u0092\u0090\u0001\u0000\u0000\u0000\u0093\u0095\u0003\u001e"+ - "\u000f\u0000\u0094\u0093\u0001\u0000\u0000\u0000\u0095\u0098\u0001\u0000"+ - "\u0000\u0000\u0096\u0094\u0001\u0000\u0000\u0000\u0096\u0097\u0001\u0000"+ - "\u0000\u0000\u0097\u009c\u0001\u0000\u0000\u0000\u0098\u0096\u0001\u0000"+ - "\u0000\u0000\u0099\u009b\u0003\u0016\u000b\u0000\u009a\u0099\u0001\u0000"+ - "\u0000\u0000\u009b\u009e\u0001\u0000\u0000\u0000\u009c\u009a\u0001\u0000"+ - "\u0000\u0000\u009c\u009d\u0001\u0000\u0000\u0000\u009d\u00a0\u0001\u0000"+ - "\u0000\u0000\u009e\u009c\u0001\u0000\u0000\u0000\u009f\u00a1\u0005\u0014"+ - "\u0000\u0000\u00a0\u009f\u0001\u0000\u0000\u0000\u00a0\u00a1\u0001\u0000"+ - "\u0000\u0000\u00a1\u00c5\u0001\u0000\u0000\u0000\u00a2\u00a4\u0003 \u0010"+ - "\u0000\u00a3\u00a2\u0001\u0000\u0000\u0000\u00a4\u00a5\u0001\u0000\u0000"+ - "\u0000\u00a5\u00a3\u0001\u0000\u0000\u0000\u00a5\u00a6\u0001\u0000\u0000"+ - "\u0000\u00a6\u00aa\u0001\u0000\u0000\u0000\u00a7\u00a9\u0003\u001e\u000f"+ - "\u0000\u00a8\u00a7\u0001\u0000\u0000\u0000\u00a9\u00ac\u0001\u0000\u0000"+ - "\u0000\u00aa\u00a8\u0001\u0000\u0000\u0000\u00aa\u00ab\u0001\u0000\u0000"+ - "\u0000\u00ab\u00b0\u0001\u0000\u0000\u0000\u00ac\u00aa\u0001\u0000\u0000"+ - "\u0000\u00ad\u00af\u0003\u0016\u000b\u0000\u00ae\u00ad\u0001\u0000\u0000"+ - "\u0000\u00af\u00b2\u0001\u0000\u0000\u0000\u00b0\u00ae\u0001\u0000\u0000"+ - "\u0000\u00b0\u00b1\u0001\u0000\u0000\u0000\u00b1\u00b4\u0001\u0000\u0000"+ - "\u0000\u00b2\u00b0\u0001\u0000\u0000\u0000\u00b3\u00b5\u0005\u0014\u0000"+ - "\u0000\u00b4\u00b3\u0001\u0000\u0000\u0000\u00b4\u00b5\u0001\u0000\u0000"+ - "\u0000\u00b5\u00c5\u0001\u0000\u0000\u0000\u00b6\u00b8\u0003\u001e\u000f"+ - "\u0000\u00b7\u00b6\u0001\u0000\u0000\u0000\u00b8\u00b9\u0001\u0000\u0000"+ - "\u0000\u00b9\u00b7\u0001\u0000\u0000\u0000\u00b9\u00ba\u0001\u0000\u0000"+ - "\u0000\u00ba\u00be\u0001\u0000\u0000\u0000\u00bb\u00bd\u0003\u0016\u000b"+ - "\u0000\u00bc\u00bb\u0001\u0000\u0000\u0000\u00bd\u00c0\u0001\u0000\u0000"+ - "\u0000\u00be\u00bc\u0001\u0000\u0000\u0000\u00be\u00bf\u0001\u0000\u0000"+ - "\u0000\u00bf\u00c2\u0001\u0000\u0000\u0000\u00c0\u00be\u0001\u0000\u0000"+ - "\u0000\u00c1\u00c3\u0005\u0014\u0000\u0000\u00c2\u00c1\u0001\u0000\u0000"+ - "\u0000\u00c2\u00c3\u0001\u0000\u0000\u0000\u00c3\u00c5\u0001\u0000\u0000"+ - "\u0000\u00c4\u008c\u0001\u0000\u0000\u0000\u00c4\u00a3\u0001\u0000\u0000"+ - "\u0000\u00c4\u00b7\u0001\u0000\u0000\u0000\u00c5\u0011\u0001\u0000\u0000"+ - "\u0000\u00c6\u00c9\u0003\u0010\b\u0000\u00c7\u00c9\u0003\u000e\u0007\u0000"+ - "\u00c8\u00c6\u0001\u0000\u0000\u0000\u00c8\u00c7\u0001\u0000\u0000\u0000"+ - "\u00c9\u0013\u0001\u0000\u0000\u0000\u00ca\u00ce\u0003$\u0012\u0000\u00cb"+ - "\u00ce\u0003\u0018\f\u0000\u00cc\u00ce\u0003\u001c\u000e\u0000\u00cd\u00ca"+ - "\u0001\u0000\u0000\u0000\u00cd\u00cb\u0001\u0000\u0000\u0000\u00cd\u00cc"+ - "\u0001\u0000\u0000\u0000\u00ce\u0015\u0001\u0000\u0000\u0000\u00cf\u00d0"+ - "\u0005\u001a\u0000\u0000\u00d0\u0017\u0001\u0000\u0000\u0000\u00d1\u00da"+ - "\u0005\u000e\u0000\u0000\u00d2\u00d7\u0003\u001a\r\u0000\u00d3\u00d4\u0005"+ - "\f\u0000\u0000\u00d4\u00d6\u0003\u001a\r\u0000\u00d5\u00d3\u0001\u0000"+ - "\u0000\u0000\u00d6\u00d9\u0001\u0000\u0000\u0000\u00d7\u00d5\u0001\u0000"+ - "\u0000\u0000\u00d7\u00d8\u0001\u0000\u0000\u0000\u00d8\u00db\u0001\u0000"+ - "\u0000\u0000\u00d9\u00d7\u0001\u0000\u0000\u0000\u00da\u00d2\u0001\u0000"+ - "\u0000\u0000\u00da\u00db\u0001\u0000\u0000\u0000\u00db\u00dc\u0001\u0000"+ - "\u0000\u0000\u00dc\u00dd\u0005\u000f\u0000\u0000\u00dd\u0019\u0001\u0000"+ - "\u0000\u0000\u00de\u00df\u0005\u001b\u0000\u0000\u00df\u00e0\u0005\u000b"+ - "\u0000\u0000\u00e0\u00e1\u0003\u0012\t\u0000\u00e1\u001b\u0001\u0000\u0000"+ - "\u0000\u00e2\u00eb\u0005\u0010\u0000\u0000\u00e3\u00e8\u0003\u0012\t\u0000"+ - "\u00e4\u00e5\u0005\f\u0000\u0000\u00e5\u00e7\u0003\u0012\t\u0000\u00e6"+ - "\u00e4\u0001\u0000\u0000\u0000\u00e7\u00ea\u0001\u0000\u0000\u0000\u00e8"+ - "\u00e6\u0001\u0000\u0000\u0000\u00e8\u00e9\u0001\u0000\u0000\u0000\u00e9"+ - "\u00ec\u0001\u0000\u0000\u0000\u00ea\u00e8\u0001\u0000\u0000\u0000\u00eb"+ - "\u00e3\u0001\u0000\u0000\u0000\u00eb\u00ec\u0001\u0000\u0000\u0000\u00ec"+ - "\u00ed\u0001\u0000\u0000\u0000\u00ed\u00ee\u0005\u0011\u0000\u0000\u00ee"+ - "\u001d\u0001\u0000\u0000\u0000\u00ef\u00f1\u0005\u0018\u0000\u0000\u00f0"+ - "\u00f2\u0005\r\u0000\u0000\u00f1\u00f0\u0001\u0000\u0000\u0000\u00f1\u00f2"+ - "\u0001\u0000\u0000\u0000\u00f2\u00f7\u0001\u0000\u0000\u0000\u00f3\u00f4"+ - "\u0005\u0012\u0000\u0000\u00f4\u00f5\u0003\u000e\u0007\u0000\u00f5\u00f6"+ - "\u0005\u0013\u0000\u0000\u00f6\u00f8\u0001\u0000\u0000\u0000\u00f7\u00f3"+ - "\u0001\u0000\u0000\u0000\u00f7\u00f8\u0001\u0000\u0000\u0000\u00f8\u001f"+ - "\u0001\u0000\u0000\u0000\u00f9\u00fb\u0005\u0019\u0000\u0000\u00fa\u00fc"+ - "\u0005\r\u0000\u0000\u00fb\u00fa\u0001\u0000\u0000\u0000\u00fb\u00fc\u0001"+ - "\u0000\u0000\u0000\u00fc\u0109\u0001\u0000\u0000\u0000\u00fd\u0106\u0005"+ - "\u0012\u0000\u0000\u00fe\u0103\u0003\"\u0011\u0000\u00ff\u0100\u0005\f"+ - "\u0000\u0000\u0100\u0102\u0003\"\u0011\u0000\u0101\u00ff\u0001\u0000\u0000"+ - "\u0000\u0102\u0105\u0001\u0000\u0000\u0000\u0103\u0101\u0001\u0000\u0000"+ - "\u0000\u0103\u0104\u0001\u0000\u0000\u0000\u0104\u0107\u0001\u0000\u0000"+ - "\u0000\u0105\u0103\u0001\u0000\u0000\u0000\u0106\u00fe\u0001\u0000\u0000"+ - "\u0000\u0106\u0107\u0001\u0000\u0000\u0000\u0107\u0108\u0001\u0000\u0000"+ - "\u0000\u0108\u010a\u0005\u0013\u0000\u0000\u0109\u00fd\u0001\u0000\u0000"+ - "\u0000\u0109\u010a\u0001\u0000\u0000\u0000\u010a!\u0001\u0000\u0000\u0000"+ - "\u010b\u010e\u0003\u0014\n\u0000\u010c\u010e\u0003\u0016\u000b\u0000\u010d"+ - "\u010b\u0001\u0000\u0000\u0000\u010d\u010c\u0001\u0000\u0000\u0000\u010e"+ - "#\u0001\u0000\u0000\u0000\u010f\u0118\u0005\b\u0000\u0000\u0110\u0118"+ - "\u0005\t\u0000\u0000\u0111\u0118\u0005\u001b\u0000\u0000\u0112\u0118\u0005"+ - "\u001c\u0000\u0000\u0113\u0118\u0005\u001d\u0000\u0000\u0114\u0118\u0005"+ - "\u001e\u0000\u0000\u0115\u0118\u0005\n\u0000\u0000\u0116\u0118\u0005\u0015"+ - "\u0000\u0000\u0117\u010f\u0001\u0000\u0000\u0000\u0117\u0110\u0001\u0000"+ - "\u0000\u0000\u0117\u0111\u0001\u0000\u0000\u0000\u0117\u0112\u0001\u0000"+ - "\u0000\u0000\u0117\u0113\u0001\u0000\u0000\u0000\u0117\u0114\u0001\u0000"+ - "\u0000\u0000\u0117\u0115\u0001\u0000\u0000\u0000\u0117\u0116\u0001\u0000"+ - "\u0000\u0000\u0118%\u0001\u0000\u0000\u0000\u0119\u011a\u0005\u0007\u0000"+ - "\u0000\u011a\u011b\u0005O\u0000\u0000\u011b\u011d\u0005F\u0000\u0000\u011c"+ - "\u011e\u0003(\u0014\u0000\u011d\u011c\u0001\u0000\u0000\u0000\u011e\u011f"+ - "\u0001\u0000\u0000\u0000\u011f\u011d\u0001\u0000\u0000\u0000\u011f\u0120"+ - "\u0001\u0000\u0000\u0000\u0120\u0121\u0001\u0000\u0000\u0000\u0121\u0122"+ - "\u0005G\u0000\u0000\u0122\'\u0001\u0000\u0000\u0000\u0123\u0126\u0003"+ - ",\u0016\u0000\u0124\u0126\u0003.\u0017\u0000\u0125\u0123\u0001\u0000\u0000"+ - "\u0000\u0125\u0124\u0001\u0000\u0000\u0000\u0126)\u0001\u0000\u0000\u0000"+ - "\u0127\u0131\u0003.\u0017\u0000\u0128\u0131\u00032\u0019\u0000\u0129\u0131"+ - "\u00034\u001a\u0000\u012a\u0131\u00036\u001b\u0000\u012b\u0131\u00038"+ - "\u001c\u0000\u012c\u0131\u0003<\u001e\u0000\u012d\u0131\u0003>\u001f\u0000"+ - "\u012e\u0131\u0003@ \u0000\u012f\u0131\u0003B!\u0000\u0130\u0127\u0001"+ - "\u0000\u0000\u0000\u0130\u0128\u0001\u0000\u0000\u0000\u0130\u0129\u0001"+ - "\u0000\u0000\u0000\u0130\u012a\u0001\u0000\u0000\u0000\u0130\u012b\u0001"+ - "\u0000\u0000\u0000\u0130\u012c\u0001\u0000\u0000\u0000\u0130\u012d\u0001"+ - "\u0000\u0000\u0000\u0130\u012e\u0001\u0000\u0000\u0000\u0130\u012f\u0001"+ - "\u0000\u0000\u0000\u0131+\u0001\u0000\u0000\u0000\u0132\u0134\u0005*\u0000"+ - "\u0000\u0133\u0135\u00050\u0000\u0000\u0134\u0133\u0001\u0000\u0000\u0000"+ - "\u0134\u0135\u0001\u0000\u0000\u0000\u0135\u0142\u0001\u0000\u0000\u0000"+ - "\u0136\u0138\u00052\u0000\u0000\u0137\u0139\u0005*\u0000\u0000\u0138\u0137"+ - "\u0001\u0000\u0000\u0000\u0138\u0139\u0001\u0000\u0000\u0000\u0139\u013b"+ - "\u0001\u0000\u0000\u0000\u013a\u013c\u00050\u0000\u0000\u013b\u013a\u0001"+ - "\u0000\u0000\u0000\u013b\u013c\u0001\u0000\u0000\u0000\u013c\u0142\u0001"+ - "\u0000\u0000\u0000\u013d\u013f\u0005-\u0000\u0000\u013e\u0140\u00050\u0000"+ - "\u0000\u013f\u013e\u0001\u0000\u0000\u0000\u013f\u0140\u0001\u0000\u0000"+ - "\u0000\u0140\u0142\u0001\u0000\u0000\u0000\u0141\u0132\u0001\u0000\u0000"+ - "\u0000\u0141\u0136\u0001\u0000\u0000\u0000\u0141\u013d\u0001\u0000\u0000"+ - "\u0000\u0142\u0143\u0001\u0000\u0000\u0000\u0143\u0144\u0005E\u0000\u0000"+ - "\u0144\u0150\u0005J\u0000\u0000\u0145\u014a\u0005E\u0000\u0000\u0146\u0147"+ - "\u0005M\u0000\u0000\u0147\u0149\u0005E\u0000\u0000\u0148\u0146\u0001\u0000"+ - "\u0000\u0000\u0149\u014c\u0001\u0000\u0000\u0000\u014a\u0148\u0001\u0000"+ - "\u0000\u0000\u014a\u014b\u0001\u0000\u0000\u0000\u014b\u014e\u0001\u0000"+ - "\u0000\u0000\u014c\u014a\u0001\u0000\u0000\u0000\u014d\u014f\u0005Q\u0000"+ - "\u0000\u014e\u014d\u0001\u0000\u0000\u0000\u014e\u014f\u0001\u0000\u0000"+ - "\u0000\u014f\u0151\u0001\u0000\u0000\u0000\u0150\u0145\u0001\u0000\u0000"+ - "\u0000\u0150\u0151\u0001\u0000\u0000\u0000\u0151\u0152\u0001\u0000\u0000"+ - "\u0000\u0152\u0153\u0005K\u0000\u0000\u0153\u0154\u0003B!\u0000\u0154"+ - "-\u0001\u0000\u0000\u0000\u0155\u0156\u0005\"\u0000\u0000\u0156\u015b"+ - "\u00030\u0018\u0000\u0157\u0158\u0005M\u0000\u0000\u0158\u015a\u00030"+ - "\u0018\u0000\u0159\u0157\u0001\u0000\u0000\u0000\u015a\u015d\u0001\u0000"+ - "\u0000\u0000\u015b\u0159\u0001\u0000\u0000\u0000\u015b\u015c\u0001\u0000"+ - "\u0000\u0000\u015c\u015e\u0001\u0000\u0000\u0000\u015d\u015b\u0001\u0000"+ - "\u0000\u0000\u015e\u015f\u0005L\u0000\u0000\u015f/\u0001\u0000\u0000\u0000"+ - "\u0160\u0163\u0005E\u0000\u0000\u0161\u0162\u0005R\u0000\u0000\u0162\u0164"+ - "\u0003D\"\u0000\u0163\u0161\u0001\u0000\u0000\u0000\u0163\u0164\u0001"+ - "\u0000\u0000\u0000\u01641\u0001\u0000\u0000\u0000\u0165\u0166\u0003D\""+ - "\u0000\u0166\u0167\u0005L\u0000\u0000\u01673\u0001\u0000\u0000\u0000\u0168"+ - "\u0169\u0005#\u0000\u0000\u0169\u016a\u0005J\u0000\u0000\u016a\u016b\u0003"+ - "D\"\u0000\u016b\u016c\u0005K\u0000\u0000\u016c\u016f\u0003*\u0015\u0000"+ - "\u016d\u016e\u0005$\u0000\u0000\u016e\u0170\u0003*\u0015\u0000\u016f\u016d"+ - "\u0001\u0000\u0000\u0000\u016f\u0170\u0001\u0000\u0000\u0000\u01705\u0001"+ - "\u0000\u0000\u0000\u0171\u0172\u0005%\u0000\u0000\u0172\u0173\u0005J\u0000"+ - "\u0000\u0173\u0174\u0003D\"\u0000\u0174\u0175\u0005K\u0000\u0000\u0175"+ - "\u0176\u0003*\u0015\u0000\u01767\u0001\u0000\u0000\u0000\u0177\u0178\u0005"+ - "&\u0000\u0000\u0178\u017d\u0005J\u0000\u0000\u0179\u017e\u0003.\u0017"+ - "\u0000\u017a\u017b\u0003:\u001d\u0000\u017b\u017c\u0005L\u0000\u0000\u017c"+ - "\u017e\u0001\u0000\u0000\u0000\u017d\u0179\u0001\u0000\u0000\u0000\u017d"+ - "\u017a\u0001\u0000\u0000\u0000\u017d\u017e\u0001\u0000\u0000\u0000\u017e"+ - "\u0180\u0001\u0000\u0000\u0000\u017f\u0181\u0003D\"\u0000\u0180\u017f"+ - "\u0001\u0000\u0000\u0000\u0180\u0181\u0001\u0000\u0000\u0000\u0181\u0182"+ - "\u0001\u0000\u0000\u0000\u0182\u0184\u0005L\u0000\u0000\u0183\u0185\u0003"+ - ":\u001d\u0000\u0184\u0183\u0001\u0000\u0000\u0000\u0184\u0185\u0001\u0000"+ - "\u0000\u0000\u0185\u0186\u0001\u0000\u0000\u0000\u0186\u0187\u0005K\u0000"+ - "\u0000\u0187\u0188\u0003*\u0015\u0000\u01889\u0001\u0000\u0000\u0000\u0189"+ - "\u018e\u0003D\"\u0000\u018a\u018b\u0005M\u0000\u0000\u018b\u018d\u0003"+ - "D\"\u0000\u018c\u018a\u0001\u0000\u0000\u0000\u018d\u0190\u0001\u0000"+ - "\u0000\u0000\u018e\u018c\u0001\u0000\u0000\u0000\u018e\u018f\u0001\u0000"+ - "\u0000\u0000\u018f;\u0001\u0000\u0000\u0000\u0190\u018e\u0001\u0000\u0000"+ - "\u0000\u0191\u0192\u0005\'\u0000\u0000\u0192\u0193\u0005J\u0000\u0000"+ - "\u0193\u0194\u0005\"\u0000\u0000\u0194\u0195\u0005E\u0000\u0000\u0195"+ - "\u0196\u0005(\u0000\u0000\u0196\u0197\u0003D\"\u0000\u0197\u0198\u0005"+ - "K\u0000\u0000\u0198\u0199\u0003*\u0015\u0000\u0199=\u0001\u0000\u0000"+ - "\u0000\u019a\u019b\u00051\u0000\u0000\u019b\u019c\u0003D\"\u0000\u019c"+ - "\u019d\u0005L\u0000\u0000\u019d?\u0001\u0000\u0000\u0000\u019e\u019f\u0005"+ - ")\u0000\u0000\u019f\u01a0\u0005L\u0000\u0000\u01a0A\u0001\u0000\u0000"+ - "\u0000\u01a1\u01a5\u0005F\u0000\u0000\u01a2\u01a4\u0003*\u0015\u0000\u01a3"+ - "\u01a2\u0001\u0000\u0000\u0000\u01a4\u01a7\u0001\u0000\u0000\u0000\u01a5"+ - "\u01a3\u0001\u0000\u0000\u0000\u01a5\u01a6\u0001\u0000\u0000\u0000\u01a6"+ - "\u01a8\u0001\u0000\u0000\u0000\u01a7\u01a5\u0001\u0000\u0000\u0000\u01a8"+ - "\u01a9\u0005G\u0000\u0000\u01a9C\u0001\u0000\u0000\u0000\u01aa\u01ab\u0006"+ - "\"\uffff\uffff\u0000\u01ab\u01d4\u0003F#\u0000\u01ac\u01ad\u0005V\u0000"+ - "\u0000\u01ad\u01d4\u0003D\"\u0013\u01ae\u01af\u0005_\u0000\u0000\u01af"+ - "\u01d4\u0003D\"\u0012\u01b0\u01b1\u0003F#\u0000\u01b1\u01b2\u0005S\u0000"+ - "\u0000\u01b2\u01d4\u0001\u0000\u0000\u0000\u01b3\u01b4\u0003F#\u0000\u01b4"+ - "\u01b5\u0005T\u0000\u0000\u01b5\u01d4\u0001\u0000\u0000\u0000\u01b6\u01b7"+ - "\u0005S\u0000\u0000\u01b7\u01d4\u0003F#\u0000\u01b8\u01b9\u0005T\u0000"+ - "\u0000\u01b9\u01d4\u0003F#\u0000\u01ba\u01bb\u0005P\u0000\u0000\u01bb"+ - "\u01d4\u0003D\"\n\u01bc\u01bd\u0003F#\u0000\u01bd\u01be\u0005R\u0000\u0000"+ - "\u01be\u01bf\u0003D\"\u0005\u01bf\u01d4\u0001\u0000\u0000\u0000\u01c0"+ - "\u01d4\u0003H$\u0000\u01c1\u01c2\u0005J\u0000\u0000\u01c2\u01c3\u0003"+ - "D\"\u0000\u01c3\u01c4\u0005K\u0000\u0000\u01c4\u01d4\u0001\u0000\u0000"+ - "\u0000\u01c5\u01c6\u0005.\u0000\u0000\u01c6\u01c7\u0005J\u0000\u0000\u01c7"+ - "\u01c8\u0003D\"\u0000\u01c8\u01c9\u0005K\u0000\u0000\u01c9\u01d4\u0001"+ - "\u0000\u0000\u0000\u01ca\u01cb\u0005/\u0000\u0000\u01cb\u01cc\u0005J\u0000"+ - "\u0000\u01cc\u01cf\u0003D\"\u0000\u01cd\u01ce\u0005M\u0000\u0000\u01ce"+ - "\u01d0\u0003D\"\u0000\u01cf\u01cd\u0001\u0000\u0000\u0000\u01cf\u01d0"+ - "\u0001\u0000\u0000\u0000\u01d0\u01d1\u0001\u0000\u0000\u0000\u01d1\u01d2"+ - "\u0005K\u0000\u0000\u01d2\u01d4\u0001\u0000\u0000\u0000\u01d3\u01aa\u0001"+ - "\u0000\u0000\u0000\u01d3\u01ac\u0001\u0000\u0000\u0000\u01d3\u01ae\u0001"+ - "\u0000\u0000\u0000\u01d3\u01b0\u0001\u0000\u0000\u0000\u01d3\u01b3\u0001"+ - "\u0000\u0000\u0000\u01d3\u01b6\u0001\u0000\u0000\u0000\u01d3\u01b8\u0001"+ - "\u0000\u0000\u0000\u01d3\u01ba\u0001\u0000\u0000\u0000\u01d3\u01bc\u0001"+ - "\u0000\u0000\u0000\u01d3\u01c0\u0001\u0000\u0000\u0000\u01d3\u01c1\u0001"+ - "\u0000\u0000\u0000\u01d3\u01c5\u0001\u0000\u0000\u0000\u01d3\u01ca\u0001"+ - "\u0000\u0000\u0000\u01d4\u01ee\u0001\u0000\u0000\u0000\u01d5\u01d6\n\r"+ - "\u0000\u0000\u01d6\u01d7\u0007\u0000\u0000\u0000\u01d7\u01ed\u0003D\""+ - "\u000e\u01d8\u01d9\n\f\u0000\u0000\u01d9\u01da\u0007\u0001\u0000\u0000"+ - "\u01da\u01ed\u0003D\"\r\u01db\u01dc\n\t\u0000\u0000\u01dc\u01dd\u0007"+ - "\u0002\u0000\u0000\u01dd\u01ed\u0003D\"\n\u01de\u01df\n\b\u0000\u0000"+ - "\u01df\u01e0\u0007\u0003\u0000\u0000\u01e0\u01ed\u0003D\"\t\u01e1\u01e2"+ - "\n\u0007\u0000\u0000\u01e2\u01e3\u0005`\u0000\u0000\u01e3\u01ed\u0003"+ - "D\"\b\u01e4\u01e5\n\u0006\u0000\u0000\u01e5\u01e6\u0005a\u0000\u0000\u01e6"+ - "\u01ed\u0003D\"\u0007\u01e7\u01e8\n\u000b\u0000\u0000\u01e8\u01ea\u0005"+ - "P\u0000\u0000\u01e9\u01eb\u0003D\"\u0000\u01ea\u01e9\u0001\u0000\u0000"+ - "\u0000\u01ea\u01eb\u0001\u0000\u0000\u0000\u01eb\u01ed\u0001\u0000\u0000"+ - "\u0000\u01ec\u01d5\u0001\u0000\u0000\u0000\u01ec\u01d8\u0001\u0000\u0000"+ - "\u0000\u01ec\u01db\u0001\u0000\u0000\u0000\u01ec\u01de\u0001\u0000\u0000"+ - "\u0000\u01ec\u01e1\u0001\u0000\u0000\u0000\u01ec\u01e4\u0001\u0000\u0000"+ - "\u0000\u01ec\u01e7\u0001\u0000\u0000\u0000\u01ed\u01f0\u0001\u0000\u0000"+ - "\u0000\u01ee\u01ec\u0001\u0000\u0000\u0000\u01ee\u01ef\u0001\u0000\u0000"+ - "\u0000\u01efE\u0001\u0000\u0000\u0000\u01f0\u01ee\u0001\u0000\u0000\u0000"+ - "\u01f1\u01f2\u0006#\uffff\uffff\u0000\u01f2\u01f3\u0005E\u0000\u0000\u01f3"+ - "\u01fc\u0005J\u0000\u0000\u01f4\u01f9\u0003D\"\u0000\u01f5\u01f6\u0005"+ - "M\u0000\u0000\u01f6\u01f8\u0003D\"\u0000\u01f7\u01f5\u0001\u0000\u0000"+ - "\u0000\u01f8\u01fb\u0001\u0000\u0000\u0000\u01f9\u01f7\u0001\u0000\u0000"+ - "\u0000\u01f9\u01fa\u0001\u0000\u0000\u0000\u01fa\u01fd\u0001\u0000\u0000"+ - "\u0000\u01fb\u01f9\u0001\u0000\u0000\u0000\u01fc\u01f4\u0001\u0000\u0000"+ - "\u0000\u01fc\u01fd\u0001\u0000\u0000\u0000\u01fd\u01fe\u0001\u0000\u0000"+ - "\u0000\u01fe\u0203\u0005K\u0000\u0000\u01ff\u0203\u0005+\u0000\u0000\u0200"+ - "\u0203\u0005,\u0000\u0000\u0201\u0203\u0005E\u0000\u0000\u0202\u01f1\u0001"+ - "\u0000\u0000\u0000\u0202\u01ff\u0001\u0000\u0000\u0000\u0202\u0200\u0001"+ - "\u0000\u0000\u0000\u0202\u0201\u0001\u0000\u0000\u0000\u0203\u020e\u0001"+ - "\u0000\u0000\u0000\u0204\u0205\n\u0006\u0000\u0000\u0205\u0206\u0005N"+ - "\u0000\u0000\u0206\u020d\u0005E\u0000\u0000\u0207\u0208\n\u0005\u0000"+ - "\u0000\u0208\u0209\u0005H\u0000\u0000\u0209\u020a\u0003D\"\u0000\u020a"+ - "\u020b\u0005I\u0000\u0000\u020b\u020d\u0001\u0000\u0000\u0000\u020c\u0204"+ - "\u0001\u0000\u0000\u0000\u020c\u0207\u0001\u0000\u0000\u0000\u020d\u0210"+ - "\u0001\u0000\u0000\u0000\u020e\u020c\u0001\u0000\u0000\u0000\u020e\u020f"+ - "\u0001\u0000\u0000\u0000\u020fG\u0001\u0000\u0000\u0000\u0210\u020e\u0001"+ - "\u0000\u0000\u0000\u0211\u0235\u00053\u0000\u0000\u0212\u0235\u00054\u0000"+ - "\u0000\u0213\u0235\u0005B\u0000\u0000\u0214\u0235\u0005C\u0000\u0000\u0215"+ - "\u0235\u0005D\u0000\u0000\u0216\u021f\u0005H\u0000\u0000\u0217\u021c\u0003"+ - "D\"\u0000\u0218\u0219\u0005M\u0000\u0000\u0219\u021b\u0003D\"\u0000\u021a"+ - "\u0218\u0001\u0000\u0000\u0000\u021b\u021e\u0001\u0000\u0000\u0000\u021c"+ - "\u021a\u0001\u0000\u0000\u0000\u021c\u021d\u0001\u0000\u0000\u0000\u021d"+ - "\u0220\u0001\u0000\u0000\u0000\u021e\u021c\u0001\u0000\u0000\u0000\u021f"+ - "\u0217\u0001\u0000\u0000\u0000\u021f\u0220\u0001\u0000\u0000\u0000\u0220"+ - "\u0221\u0001\u0000\u0000\u0000\u0221\u0235\u0005I\u0000\u0000\u0222\u022f"+ - "\u0005F\u0000\u0000\u0223\u0224\u0007\u0004\u0000\u0000\u0224\u0225\u0005"+ - "O\u0000\u0000\u0225\u022c\u0003D\"\u0000\u0226\u0227\u0005M\u0000\u0000"+ - "\u0227\u0228\u0007\u0004\u0000\u0000\u0228\u0229\u0005O\u0000\u0000\u0229"+ - "\u022b\u0003D\"\u0000\u022a\u0226\u0001\u0000\u0000\u0000\u022b\u022e"+ - "\u0001\u0000\u0000\u0000\u022c\u022a\u0001\u0000\u0000\u0000\u022c\u022d"+ - "\u0001\u0000\u0000\u0000\u022d\u0230\u0001\u0000\u0000\u0000\u022e\u022c"+ - "\u0001\u0000\u0000\u0000\u022f\u0223\u0001\u0000\u0000\u0000\u022f\u0230"+ - "\u0001\u0000\u0000\u0000\u0230\u0231\u0001\u0000\u0000\u0000\u0231\u0235"+ - "\u0005G\u0000\u0000\u0232\u0235\u00055\u0000\u0000\u0233\u0235\u00056"+ - "\u0000\u0000\u0234\u0211\u0001\u0000\u0000\u0000\u0234\u0212\u0001\u0000"+ - "\u0000\u0000\u0234\u0213\u0001\u0000\u0000\u0000\u0234\u0214\u0001\u0000"+ - "\u0000\u0000\u0234\u0215\u0001\u0000\u0000\u0000\u0234\u0216\u0001\u0000"+ - "\u0000\u0000\u0234\u0222\u0001\u0000\u0000\u0000\u0234\u0232\u0001\u0000"+ - "\u0000\u0000\u0234\u0233\u0001\u0000\u0000\u0000\u0235I\u0001\u0000\u0000"+ - "\u0000FKNRTY[ack~\u0090\u0096\u009c\u00a0\u00a5\u00aa\u00b0\u00b4\u00b9"+ - "\u00be\u00c2\u00c4\u00c8\u00cd\u00d7\u00da\u00e8\u00eb\u00f1\u00f7\u00fb"+ - "\u0103\u0106\u0109\u010d\u0117\u011f\u0125\u0130\u0134\u0138\u013b\u013f"+ - "\u0141\u014a\u014e\u0150\u015b\u0163\u016f\u017d\u0180\u0184\u018e\u01a5"+ - "\u01cf\u01d3\u01ea\u01ec\u01ee\u01f9\u01fc\u0202\u020c\u020e\u021c\u021f"+ - "\u022c\u022f\u0234"; + "\"\u0001\"\u0001\"\u0001\"\u0001\"\u0001\"\u0003\"\u01ec\b\"\u0005\"\u01ee"+ + "\b\"\n\"\f\"\u01f1\t\"\u0001#\u0001#\u0001#\u0001#\u0001#\u0001#\u0005"+ + "#\u01f9\b#\n#\f#\u01fc\t#\u0003#\u01fe\b#\u0001#\u0001#\u0001#\u0001#"+ + "\u0003#\u0204\b#\u0001#\u0001#\u0001#\u0001#\u0001#\u0001#\u0001#\u0001"+ + "#\u0005#\u020e\b#\n#\f#\u0211\t#\u0001$\u0001$\u0001$\u0001$\u0001$\u0001"+ + "$\u0001$\u0001$\u0001$\u0005$\u021c\b$\n$\f$\u021f\t$\u0003$\u0221\b$"+ + "\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0001$\u0005"+ + "$\u022c\b$\n$\f$\u022f\t$\u0003$\u0231\b$\u0001$\u0001$\u0001$\u0003$"+ + "\u0236\b$\u0001$\u0000\u0002DF%\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010"+ + "\u0012\u0014\u0016\u0018\u001a\u001c\u001e \"$&(*,.02468:<>@BDFH\u0000"+ + "\u0005\u0001\u0000WX\u0001\u0000UV\u0001\u0000Y\\\u0001\u0000]^\u0001"+ + "\u0000DE\u0282\u0000k\u0001\u0000\u0000\u0000\u0002m\u0001\u0000\u0000"+ + "\u0000\u0004q\u0001\u0000\u0000\u0000\u0006u\u0001\u0000\u0000\u0000\b"+ + "y\u0001\u0000\u0000\u0000\n\u0080\u0001\u0000\u0000\u0000\f\u0085\u0001"+ + "\u0000\u0000\u0000\u000e\u008a\u0001\u0000\u0000\u0000\u0010\u00c4\u0001"+ + "\u0000\u0000\u0000\u0012\u00c8\u0001\u0000\u0000\u0000\u0014\u00cd\u0001"+ + "\u0000\u0000\u0000\u0016\u00cf\u0001\u0000\u0000\u0000\u0018\u00d1\u0001"+ + "\u0000\u0000\u0000\u001a\u00de\u0001\u0000\u0000\u0000\u001c\u00e2\u0001"+ + "\u0000\u0000\u0000\u001e\u00ef\u0001\u0000\u0000\u0000 \u00f9\u0001\u0000"+ + "\u0000\u0000\"\u010d\u0001\u0000\u0000\u0000$\u0117\u0001\u0000\u0000"+ + "\u0000&\u0119\u0001\u0000\u0000\u0000(\u0125\u0001\u0000\u0000\u0000*"+ + "\u0130\u0001\u0000\u0000\u0000,\u0141\u0001\u0000\u0000\u0000.\u0155\u0001"+ + "\u0000\u0000\u00000\u0160\u0001\u0000\u0000\u00002\u0165\u0001\u0000\u0000"+ + "\u00004\u0168\u0001\u0000\u0000\u00006\u0171\u0001\u0000\u0000\u00008"+ + "\u0177\u0001\u0000\u0000\u0000:\u018a\u0001\u0000\u0000\u0000<\u0192\u0001"+ + "\u0000\u0000\u0000>\u019b\u0001\u0000\u0000\u0000@\u019f\u0001\u0000\u0000"+ + "\u0000B\u01a2\u0001\u0000\u0000\u0000D\u01d4\u0001\u0000\u0000\u0000F"+ + "\u0203\u0001\u0000\u0000\u0000H\u0235\u0001\u0000\u0000\u0000JL\u0003"+ + "\u0004\u0002\u0000KJ\u0001\u0000\u0000\u0000KL\u0001\u0000\u0000\u0000"+ + "LN\u0001\u0000\u0000\u0000MO\u0003\u0006\u0003\u0000NM\u0001\u0000\u0000"+ + "\u0000NO\u0001\u0000\u0000\u0000OT\u0001\u0000\u0000\u0000PS\u0003\b\u0004"+ + "\u0000QS\u0003\n\u0005\u0000RP\u0001\u0000\u0000\u0000RQ\u0001\u0000\u0000"+ + "\u0000SV\u0001\u0000\u0000\u0000TR\u0001\u0000\u0000\u0000TU\u0001\u0000"+ + "\u0000\u0000U[\u0001\u0000\u0000\u0000VT\u0001\u0000\u0000\u0000WZ\u0003"+ + "\f\u0006\u0000XZ\u0003&\u0013\u0000YW\u0001\u0000\u0000\u0000YX\u0001"+ + "\u0000\u0000\u0000Z]\u0001\u0000\u0000\u0000[Y\u0001\u0000\u0000\u0000"+ + "[\\\u0001\u0000\u0000\u0000\\^\u0001\u0000\u0000\u0000][\u0001\u0000\u0000"+ + "\u0000^c\u0003\u0002\u0001\u0000_b\u0003\f\u0006\u0000`b\u0003&\u0013"+ + "\u0000a_\u0001\u0000\u0000\u0000a`\u0001\u0000\u0000\u0000be\u0001\u0000"+ + "\u0000\u0000ca\u0001\u0000\u0000\u0000cd\u0001\u0000\u0000\u0000df\u0001"+ + "\u0000\u0000\u0000ec\u0001\u0000\u0000\u0000fg\u0005\u0000\u0000\u0001"+ + "gl\u0001\u0000\u0000\u0000hi\u0003\u0012\t\u0000ij\u0005\u0000\u0000\u0001"+ + "jl\u0001\u0000\u0000\u0000kK\u0001\u0000\u0000\u0000kh\u0001\u0000\u0000"+ + "\u0000l\u0001\u0001\u0000\u0000\u0000mn\u0005\u0006\u0000\u0000no\u0005"+ + "\u000b\u0000\u0000op\u0003\u0012\t\u0000p\u0003\u0001\u0000\u0000\u0000"+ + "qr\u0005\u0001\u0000\u0000rs\u0005\u000b\u0000\u0000st\u0005\u001b\u0000"+ + "\u0000t\u0005\u0001\u0000\u0000\u0000uv\u0005\u0002\u0000\u0000vw\u0005"+ + "\u000b\u0000\u0000wx\u0005\u001b\u0000\u0000x\u0007\u0001\u0000\u0000"+ + "\u0000yz\u0005\u0003\u0000\u0000z{\u0005\u000b\u0000\u0000{~\u0005\u0016"+ + "\u0000\u0000|}\u0005\f\u0000\u0000}\u007f\u0005\u0016\u0000\u0000~|\u0001"+ + "\u0000\u0000\u0000~\u007f\u0001\u0000\u0000\u0000\u007f\t\u0001\u0000"+ + "\u0000\u0000\u0080\u0081\u0005\u0004\u0000\u0000\u0081\u0082\u0005\u0016"+ + "\u0000\u0000\u0082\u0083\u0005\u000b\u0000\u0000\u0083\u0084\u0003$\u0012"+ + "\u0000\u0084\u000b\u0001\u0000\u0000\u0000\u0085\u0086\u0005\u0005\u0000"+ + "\u0000\u0086\u0087\u0003\u000e\u0007\u0000\u0087\u0088\u0005\u000b\u0000"+ + "\u0000\u0088\u0089\u0003\u0010\b\u0000\u0089\r\u0001\u0000\u0000\u0000"+ + "\u008a\u008b\u0005\u0017\u0000\u0000\u008b\u000f\u0001\u0000\u0000\u0000"+ + "\u008c\u0090\u0003\u0014\n\u0000\u008d\u008f\u0003 \u0010\u0000\u008e"+ + "\u008d\u0001\u0000\u0000\u0000\u008f\u0092\u0001\u0000\u0000\u0000\u0090"+ + "\u008e\u0001\u0000\u0000\u0000\u0090\u0091\u0001\u0000\u0000\u0000\u0091"+ + "\u0096\u0001\u0000\u0000\u0000\u0092\u0090\u0001\u0000\u0000\u0000\u0093"+ + "\u0095\u0003\u001e\u000f\u0000\u0094\u0093\u0001\u0000\u0000\u0000\u0095"+ + "\u0098\u0001\u0000\u0000\u0000\u0096\u0094\u0001\u0000\u0000\u0000\u0096"+ + "\u0097\u0001\u0000\u0000\u0000\u0097\u009c\u0001\u0000\u0000\u0000\u0098"+ + "\u0096\u0001\u0000\u0000\u0000\u0099\u009b\u0003\u0016\u000b\u0000\u009a"+ + "\u0099\u0001\u0000\u0000\u0000\u009b\u009e\u0001\u0000\u0000\u0000\u009c"+ + "\u009a\u0001\u0000\u0000\u0000\u009c\u009d\u0001\u0000\u0000\u0000\u009d"+ + "\u00a0\u0001\u0000\u0000\u0000\u009e\u009c\u0001\u0000\u0000\u0000\u009f"+ + "\u00a1\u0005\u0014\u0000\u0000\u00a0\u009f\u0001\u0000\u0000\u0000\u00a0"+ + "\u00a1\u0001\u0000\u0000\u0000\u00a1\u00c5\u0001\u0000\u0000\u0000\u00a2"+ + "\u00a4\u0003 \u0010\u0000\u00a3\u00a2\u0001\u0000\u0000\u0000\u00a4\u00a5"+ + "\u0001\u0000\u0000\u0000\u00a5\u00a3\u0001\u0000\u0000\u0000\u00a5\u00a6"+ + "\u0001\u0000\u0000\u0000\u00a6\u00aa\u0001\u0000\u0000\u0000\u00a7\u00a9"+ + "\u0003\u001e\u000f\u0000\u00a8\u00a7\u0001\u0000\u0000\u0000\u00a9\u00ac"+ + "\u0001\u0000\u0000\u0000\u00aa\u00a8\u0001\u0000\u0000\u0000\u00aa\u00ab"+ + "\u0001\u0000\u0000\u0000\u00ab\u00b0\u0001\u0000\u0000\u0000\u00ac\u00aa"+ + "\u0001\u0000\u0000\u0000\u00ad\u00af\u0003\u0016\u000b\u0000\u00ae\u00ad"+ + "\u0001\u0000\u0000\u0000\u00af\u00b2\u0001\u0000\u0000\u0000\u00b0\u00ae"+ + "\u0001\u0000\u0000\u0000\u00b0\u00b1\u0001\u0000\u0000\u0000\u00b1\u00b4"+ + "\u0001\u0000\u0000\u0000\u00b2\u00b0\u0001\u0000\u0000\u0000\u00b3\u00b5"+ + "\u0005\u0014\u0000\u0000\u00b4\u00b3\u0001\u0000\u0000\u0000\u00b4\u00b5"+ + "\u0001\u0000\u0000\u0000\u00b5\u00c5\u0001\u0000\u0000\u0000\u00b6\u00b8"+ + "\u0003\u001e\u000f\u0000\u00b7\u00b6\u0001\u0000\u0000\u0000\u00b8\u00b9"+ + "\u0001\u0000\u0000\u0000\u00b9\u00b7\u0001\u0000\u0000\u0000\u00b9\u00ba"+ + "\u0001\u0000\u0000\u0000\u00ba\u00be\u0001\u0000\u0000\u0000\u00bb\u00bd"+ + "\u0003\u0016\u000b\u0000\u00bc\u00bb\u0001\u0000\u0000\u0000\u00bd\u00c0"+ + "\u0001\u0000\u0000\u0000\u00be\u00bc\u0001\u0000\u0000\u0000\u00be\u00bf"+ + "\u0001\u0000\u0000\u0000\u00bf\u00c2\u0001\u0000\u0000\u0000\u00c0\u00be"+ + "\u0001\u0000\u0000\u0000\u00c1\u00c3\u0005\u0014\u0000\u0000\u00c2\u00c1"+ + "\u0001\u0000\u0000\u0000\u00c2\u00c3\u0001\u0000\u0000\u0000\u00c3\u00c5"+ + "\u0001\u0000\u0000\u0000\u00c4\u008c\u0001\u0000\u0000\u0000\u00c4\u00a3"+ + "\u0001\u0000\u0000\u0000\u00c4\u00b7\u0001\u0000\u0000\u0000\u00c5\u0011"+ + "\u0001\u0000\u0000\u0000\u00c6\u00c9\u0003\u0010\b\u0000\u00c7\u00c9\u0003"+ + "\u000e\u0007\u0000\u00c8\u00c6\u0001\u0000\u0000\u0000\u00c8\u00c7\u0001"+ + "\u0000\u0000\u0000\u00c9\u0013\u0001\u0000\u0000\u0000\u00ca\u00ce\u0003"+ + "$\u0012\u0000\u00cb\u00ce\u0003\u0018\f\u0000\u00cc\u00ce\u0003\u001c"+ + "\u000e\u0000\u00cd\u00ca\u0001\u0000\u0000\u0000\u00cd\u00cb\u0001\u0000"+ + "\u0000\u0000\u00cd\u00cc\u0001\u0000\u0000\u0000\u00ce\u0015\u0001\u0000"+ + "\u0000\u0000\u00cf\u00d0\u0005\u001a\u0000\u0000\u00d0\u0017\u0001\u0000"+ + "\u0000\u0000\u00d1\u00da\u0005\u000e\u0000\u0000\u00d2\u00d7\u0003\u001a"+ + "\r\u0000\u00d3\u00d4\u0005\f\u0000\u0000\u00d4\u00d6\u0003\u001a\r\u0000"+ + "\u00d5\u00d3\u0001\u0000\u0000\u0000\u00d6\u00d9\u0001\u0000\u0000\u0000"+ + "\u00d7\u00d5\u0001\u0000\u0000\u0000\u00d7\u00d8\u0001\u0000\u0000\u0000"+ + "\u00d8\u00db\u0001\u0000\u0000\u0000\u00d9\u00d7\u0001\u0000\u0000\u0000"+ + "\u00da\u00d2\u0001\u0000\u0000\u0000\u00da\u00db\u0001\u0000\u0000\u0000"+ + "\u00db\u00dc\u0001\u0000\u0000\u0000\u00dc\u00dd\u0005\u000f\u0000\u0000"+ + "\u00dd\u0019\u0001\u0000\u0000\u0000\u00de\u00df\u0005\u001b\u0000\u0000"+ + "\u00df\u00e0\u0005\u000b\u0000\u0000\u00e0\u00e1\u0003\u0012\t\u0000\u00e1"+ + "\u001b\u0001\u0000\u0000\u0000\u00e2\u00eb\u0005\u0010\u0000\u0000\u00e3"+ + "\u00e8\u0003\u0012\t\u0000\u00e4\u00e5\u0005\f\u0000\u0000\u00e5\u00e7"+ + "\u0003\u0012\t\u0000\u00e6\u00e4\u0001\u0000\u0000\u0000\u00e7\u00ea\u0001"+ + "\u0000\u0000\u0000\u00e8\u00e6\u0001\u0000\u0000\u0000\u00e8\u00e9\u0001"+ + "\u0000\u0000\u0000\u00e9\u00ec\u0001\u0000\u0000\u0000\u00ea\u00e8\u0001"+ + "\u0000\u0000\u0000\u00eb\u00e3\u0001\u0000\u0000\u0000\u00eb\u00ec\u0001"+ + "\u0000\u0000\u0000\u00ec\u00ed\u0001\u0000\u0000\u0000\u00ed\u00ee\u0005"+ + "\u0011\u0000\u0000\u00ee\u001d\u0001\u0000\u0000\u0000\u00ef\u00f1\u0005"+ + "\u0018\u0000\u0000\u00f0\u00f2\u0005\r\u0000\u0000\u00f1\u00f0\u0001\u0000"+ + "\u0000\u0000\u00f1\u00f2\u0001\u0000\u0000\u0000\u00f2\u00f7\u0001\u0000"+ + "\u0000\u0000\u00f3\u00f4\u0005\u0012\u0000\u0000\u00f4\u00f5\u0003\u000e"+ + "\u0007\u0000\u00f5\u00f6\u0005\u0013\u0000\u0000\u00f6\u00f8\u0001\u0000"+ + "\u0000\u0000\u00f7\u00f3\u0001\u0000\u0000\u0000\u00f7\u00f8\u0001\u0000"+ + "\u0000\u0000\u00f8\u001f\u0001\u0000\u0000\u0000\u00f9\u00fb\u0005\u0019"+ + "\u0000\u0000\u00fa\u00fc\u0005\r\u0000\u0000\u00fb\u00fa\u0001\u0000\u0000"+ + "\u0000\u00fb\u00fc\u0001\u0000\u0000\u0000\u00fc\u0109\u0001\u0000\u0000"+ + "\u0000\u00fd\u0106\u0005\u0012\u0000\u0000\u00fe\u0103\u0003\"\u0011\u0000"+ + "\u00ff\u0100\u0005\f\u0000\u0000\u0100\u0102\u0003\"\u0011\u0000\u0101"+ + "\u00ff\u0001\u0000\u0000\u0000\u0102\u0105\u0001\u0000\u0000\u0000\u0103"+ + "\u0101\u0001\u0000\u0000\u0000\u0103\u0104\u0001\u0000\u0000\u0000\u0104"+ + "\u0107\u0001\u0000\u0000\u0000\u0105\u0103\u0001\u0000\u0000\u0000\u0106"+ + "\u00fe\u0001\u0000\u0000\u0000\u0106\u0107\u0001\u0000\u0000\u0000\u0107"+ + "\u0108\u0001\u0000\u0000\u0000\u0108\u010a\u0005\u0013\u0000\u0000\u0109"+ + "\u00fd\u0001\u0000\u0000\u0000\u0109\u010a\u0001\u0000\u0000\u0000\u010a"+ + "!\u0001\u0000\u0000\u0000\u010b\u010e\u0003\u0014\n\u0000\u010c\u010e"+ + "\u0003\u0016\u000b\u0000\u010d\u010b\u0001\u0000\u0000\u0000\u010d\u010c"+ + "\u0001\u0000\u0000\u0000\u010e#\u0001\u0000\u0000\u0000\u010f\u0118\u0005"+ + "\b\u0000\u0000\u0110\u0118\u0005\t\u0000\u0000\u0111\u0118\u0005\u001b"+ + "\u0000\u0000\u0112\u0118\u0005\u001c\u0000\u0000\u0113\u0118\u0005\u001d"+ + "\u0000\u0000\u0114\u0118\u0005\u001e\u0000\u0000\u0115\u0118\u0005\n\u0000"+ + "\u0000\u0116\u0118\u0005\u0015\u0000\u0000\u0117\u010f\u0001\u0000\u0000"+ + "\u0000\u0117\u0110\u0001\u0000\u0000\u0000\u0117\u0111\u0001\u0000\u0000"+ + "\u0000\u0117\u0112\u0001\u0000\u0000\u0000\u0117\u0113\u0001\u0000\u0000"+ + "\u0000\u0117\u0114\u0001\u0000\u0000\u0000\u0117\u0115\u0001\u0000\u0000"+ + "\u0000\u0117\u0116\u0001\u0000\u0000\u0000\u0118%\u0001\u0000\u0000\u0000"+ + "\u0119\u011a\u0005\u0007\u0000\u0000\u011a\u011b\u0005O\u0000\u0000\u011b"+ + "\u011d\u0005F\u0000\u0000\u011c\u011e\u0003(\u0014\u0000\u011d\u011c\u0001"+ + "\u0000\u0000\u0000\u011e\u011f\u0001\u0000\u0000\u0000\u011f\u011d\u0001"+ + "\u0000\u0000\u0000\u011f\u0120\u0001\u0000\u0000\u0000\u0120\u0121\u0001"+ + "\u0000\u0000\u0000\u0121\u0122\u0005G\u0000\u0000\u0122\'\u0001\u0000"+ + "\u0000\u0000\u0123\u0126\u0003,\u0016\u0000\u0124\u0126\u0003.\u0017\u0000"+ + "\u0125\u0123\u0001\u0000\u0000\u0000\u0125\u0124\u0001\u0000\u0000\u0000"+ + "\u0126)\u0001\u0000\u0000\u0000\u0127\u0131\u0003.\u0017\u0000\u0128\u0131"+ + "\u00032\u0019\u0000\u0129\u0131\u00034\u001a\u0000\u012a\u0131\u00036"+ + "\u001b\u0000\u012b\u0131\u00038\u001c\u0000\u012c\u0131\u0003<\u001e\u0000"+ + "\u012d\u0131\u0003>\u001f\u0000\u012e\u0131\u0003@ \u0000\u012f\u0131"+ + "\u0003B!\u0000\u0130\u0127\u0001\u0000\u0000\u0000\u0130\u0128\u0001\u0000"+ + "\u0000\u0000\u0130\u0129\u0001\u0000\u0000\u0000\u0130\u012a\u0001\u0000"+ + "\u0000\u0000\u0130\u012b\u0001\u0000\u0000\u0000\u0130\u012c\u0001\u0000"+ + "\u0000\u0000\u0130\u012d\u0001\u0000\u0000\u0000\u0130\u012e\u0001\u0000"+ + "\u0000\u0000\u0130\u012f\u0001\u0000\u0000\u0000\u0131+\u0001\u0000\u0000"+ + "\u0000\u0132\u0134\u0005*\u0000\u0000\u0133\u0135\u00050\u0000\u0000\u0134"+ + "\u0133\u0001\u0000\u0000\u0000\u0134\u0135\u0001\u0000\u0000\u0000\u0135"+ + "\u0142\u0001\u0000\u0000\u0000\u0136\u0138\u00052\u0000\u0000\u0137\u0139"+ + "\u0005*\u0000\u0000\u0138\u0137\u0001\u0000\u0000\u0000\u0138\u0139\u0001"+ + "\u0000\u0000\u0000\u0139\u013b\u0001\u0000\u0000\u0000\u013a\u013c\u0005"+ + "0\u0000\u0000\u013b\u013a\u0001\u0000\u0000\u0000\u013b\u013c\u0001\u0000"+ + "\u0000\u0000\u013c\u0142\u0001\u0000\u0000\u0000\u013d\u013f\u0005-\u0000"+ + "\u0000\u013e\u0140\u00050\u0000\u0000\u013f\u013e\u0001\u0000\u0000\u0000"+ + "\u013f\u0140\u0001\u0000\u0000\u0000\u0140\u0142\u0001\u0000\u0000\u0000"+ + "\u0141\u0132\u0001\u0000\u0000\u0000\u0141\u0136\u0001\u0000\u0000\u0000"+ + "\u0141\u013d\u0001\u0000\u0000\u0000\u0142\u0143\u0001\u0000\u0000\u0000"+ + "\u0143\u0144\u0005E\u0000\u0000\u0144\u0150\u0005J\u0000\u0000\u0145\u014a"+ + "\u0005E\u0000\u0000\u0146\u0147\u0005M\u0000\u0000\u0147\u0149\u0005E"+ + "\u0000\u0000\u0148\u0146\u0001\u0000\u0000\u0000\u0149\u014c\u0001\u0000"+ + "\u0000\u0000\u014a\u0148\u0001\u0000\u0000\u0000\u014a\u014b\u0001\u0000"+ + "\u0000\u0000\u014b\u014e\u0001\u0000\u0000\u0000\u014c\u014a\u0001\u0000"+ + "\u0000\u0000\u014d\u014f\u0005Q\u0000\u0000\u014e\u014d\u0001\u0000\u0000"+ + "\u0000\u014e\u014f\u0001\u0000\u0000\u0000\u014f\u0151\u0001\u0000\u0000"+ + "\u0000\u0150\u0145\u0001\u0000\u0000\u0000\u0150\u0151\u0001\u0000\u0000"+ + "\u0000\u0151\u0152\u0001\u0000\u0000\u0000\u0152\u0153\u0005K\u0000\u0000"+ + "\u0153\u0154\u0003B!\u0000\u0154-\u0001\u0000\u0000\u0000\u0155\u0156"+ + "\u0005\"\u0000\u0000\u0156\u015b\u00030\u0018\u0000\u0157\u0158\u0005"+ + "M\u0000\u0000\u0158\u015a\u00030\u0018\u0000\u0159\u0157\u0001\u0000\u0000"+ + "\u0000\u015a\u015d\u0001\u0000\u0000\u0000\u015b\u0159\u0001\u0000\u0000"+ + "\u0000\u015b\u015c\u0001\u0000\u0000\u0000\u015c\u015e\u0001\u0000\u0000"+ + "\u0000\u015d\u015b\u0001\u0000\u0000\u0000\u015e\u015f\u0005L\u0000\u0000"+ + "\u015f/\u0001\u0000\u0000\u0000\u0160\u0163\u0005E\u0000\u0000\u0161\u0162"+ + "\u0005R\u0000\u0000\u0162\u0164\u0003D\"\u0000\u0163\u0161\u0001\u0000"+ + "\u0000\u0000\u0163\u0164\u0001\u0000\u0000\u0000\u01641\u0001\u0000\u0000"+ + "\u0000\u0165\u0166\u0003D\"\u0000\u0166\u0167\u0005L\u0000\u0000\u0167"+ + "3\u0001\u0000\u0000\u0000\u0168\u0169\u0005#\u0000\u0000\u0169\u016a\u0005"+ + "J\u0000\u0000\u016a\u016b\u0003D\"\u0000\u016b\u016c\u0005K\u0000\u0000"+ + "\u016c\u016f\u0003*\u0015\u0000\u016d\u016e\u0005$\u0000\u0000\u016e\u0170"+ + "\u0003*\u0015\u0000\u016f\u016d\u0001\u0000\u0000\u0000\u016f\u0170\u0001"+ + "\u0000\u0000\u0000\u01705\u0001\u0000\u0000\u0000\u0171\u0172\u0005%\u0000"+ + "\u0000\u0172\u0173\u0005J\u0000\u0000\u0173\u0174\u0003D\"\u0000\u0174"+ + "\u0175\u0005K\u0000\u0000\u0175\u0176\u0003*\u0015\u0000\u01767\u0001"+ + "\u0000\u0000\u0000\u0177\u0178\u0005&\u0000\u0000\u0178\u017e\u0005J\u0000"+ + "\u0000\u0179\u017f\u0003.\u0017\u0000\u017a\u017b\u0003:\u001d\u0000\u017b"+ + "\u017c\u0005L\u0000\u0000\u017c\u017f\u0001\u0000\u0000\u0000\u017d\u017f"+ + "\u0005L\u0000\u0000\u017e\u0179\u0001\u0000\u0000\u0000\u017e\u017a\u0001"+ + "\u0000\u0000\u0000\u017e\u017d\u0001\u0000\u0000\u0000\u017f\u0181\u0001"+ + "\u0000\u0000\u0000\u0180\u0182\u0003D\"\u0000\u0181\u0180\u0001\u0000"+ + "\u0000\u0000\u0181\u0182\u0001\u0000\u0000\u0000\u0182\u0183\u0001\u0000"+ + "\u0000\u0000\u0183\u0185\u0005L\u0000\u0000\u0184\u0186\u0003:\u001d\u0000"+ + "\u0185\u0184\u0001\u0000\u0000\u0000\u0185\u0186\u0001\u0000\u0000\u0000"+ + "\u0186\u0187\u0001\u0000\u0000\u0000\u0187\u0188\u0005K\u0000\u0000\u0188"+ + "\u0189\u0003*\u0015\u0000\u01899\u0001\u0000\u0000\u0000\u018a\u018f\u0003"+ + "D\"\u0000\u018b\u018c\u0005M\u0000\u0000\u018c\u018e\u0003D\"\u0000\u018d"+ + "\u018b\u0001\u0000\u0000\u0000\u018e\u0191\u0001\u0000\u0000\u0000\u018f"+ + "\u018d\u0001\u0000\u0000\u0000\u018f\u0190\u0001\u0000\u0000\u0000\u0190"+ + ";\u0001\u0000\u0000\u0000\u0191\u018f\u0001\u0000\u0000\u0000\u0192\u0193"+ + "\u0005\'\u0000\u0000\u0193\u0194\u0005J\u0000\u0000\u0194\u0195\u0005"+ + "\"\u0000\u0000\u0195\u0196\u0005E\u0000\u0000\u0196\u0197\u0005(\u0000"+ + "\u0000\u0197\u0198\u0003D\"\u0000\u0198\u0199\u0005K\u0000\u0000\u0199"+ + "\u019a\u0003*\u0015\u0000\u019a=\u0001\u0000\u0000\u0000\u019b\u019c\u0005"+ + "1\u0000\u0000\u019c\u019d\u0003D\"\u0000\u019d\u019e\u0005L\u0000\u0000"+ + "\u019e?\u0001\u0000\u0000\u0000\u019f\u01a0\u0005)\u0000\u0000\u01a0\u01a1"+ + "\u0005L\u0000\u0000\u01a1A\u0001\u0000\u0000\u0000\u01a2\u01a6\u0005F"+ + "\u0000\u0000\u01a3\u01a5\u0003*\u0015\u0000\u01a4\u01a3\u0001\u0000\u0000"+ + "\u0000\u01a5\u01a8\u0001\u0000\u0000\u0000\u01a6\u01a4\u0001\u0000\u0000"+ + "\u0000\u01a6\u01a7\u0001\u0000\u0000\u0000\u01a7\u01a9\u0001\u0000\u0000"+ + "\u0000\u01a8\u01a6\u0001\u0000\u0000\u0000\u01a9\u01aa\u0005G\u0000\u0000"+ + "\u01aaC\u0001\u0000\u0000\u0000\u01ab\u01ac\u0006\"\uffff\uffff\u0000"+ + "\u01ac\u01d5\u0003F#\u0000\u01ad\u01ae\u0005V\u0000\u0000\u01ae\u01d5"+ + "\u0003D\"\u0013\u01af\u01b0\u0005_\u0000\u0000\u01b0\u01d5\u0003D\"\u0012"+ + "\u01b1\u01b2\u0003F#\u0000\u01b2\u01b3\u0005S\u0000\u0000\u01b3\u01d5"+ + "\u0001\u0000\u0000\u0000\u01b4\u01b5\u0003F#\u0000\u01b5\u01b6\u0005T"+ + "\u0000\u0000\u01b6\u01d5\u0001\u0000\u0000\u0000\u01b7\u01b8\u0005S\u0000"+ + "\u0000\u01b8\u01d5\u0003F#\u0000\u01b9\u01ba\u0005T\u0000\u0000\u01ba"+ + "\u01d5\u0003F#\u0000\u01bb\u01bc\u0005P\u0000\u0000\u01bc\u01d5\u0003"+ + "D\"\n\u01bd\u01be\u0003F#\u0000\u01be\u01bf\u0005R\u0000\u0000\u01bf\u01c0"+ + "\u0003D\"\u0005\u01c0\u01d5\u0001\u0000\u0000\u0000\u01c1\u01d5\u0003"+ + "H$\u0000\u01c2\u01c3\u0005J\u0000\u0000\u01c3\u01c4\u0003D\"\u0000\u01c4"+ + "\u01c5\u0005K\u0000\u0000\u01c5\u01d5\u0001\u0000\u0000\u0000\u01c6\u01c7"+ + "\u0005.\u0000\u0000\u01c7\u01c8\u0005J\u0000\u0000\u01c8\u01c9\u0003D"+ + "\"\u0000\u01c9\u01ca\u0005K\u0000\u0000\u01ca\u01d5\u0001\u0000\u0000"+ + "\u0000\u01cb\u01cc\u0005/\u0000\u0000\u01cc\u01cd\u0005J\u0000\u0000\u01cd"+ + "\u01d0\u0003D\"\u0000\u01ce\u01cf\u0005M\u0000\u0000\u01cf\u01d1\u0003"+ + "D\"\u0000\u01d0\u01ce\u0001\u0000\u0000\u0000\u01d0\u01d1\u0001\u0000"+ + "\u0000\u0000\u01d1\u01d2\u0001\u0000\u0000\u0000\u01d2\u01d3\u0005K\u0000"+ + "\u0000\u01d3\u01d5\u0001\u0000\u0000\u0000\u01d4\u01ab\u0001\u0000\u0000"+ + "\u0000\u01d4\u01ad\u0001\u0000\u0000\u0000\u01d4\u01af\u0001\u0000\u0000"+ + "\u0000\u01d4\u01b1\u0001\u0000\u0000\u0000\u01d4\u01b4\u0001\u0000\u0000"+ + "\u0000\u01d4\u01b7\u0001\u0000\u0000\u0000\u01d4\u01b9\u0001\u0000\u0000"+ + "\u0000\u01d4\u01bb\u0001\u0000\u0000\u0000\u01d4\u01bd\u0001\u0000\u0000"+ + "\u0000\u01d4\u01c1\u0001\u0000\u0000\u0000\u01d4\u01c2\u0001\u0000\u0000"+ + "\u0000\u01d4\u01c6\u0001\u0000\u0000\u0000\u01d4\u01cb\u0001\u0000\u0000"+ + "\u0000\u01d5\u01ef\u0001\u0000\u0000\u0000\u01d6\u01d7\n\r\u0000\u0000"+ + "\u01d7\u01d8\u0007\u0000\u0000\u0000\u01d8\u01ee\u0003D\"\u000e\u01d9"+ + "\u01da\n\f\u0000\u0000\u01da\u01db\u0007\u0001\u0000\u0000\u01db\u01ee"+ + "\u0003D\"\r\u01dc\u01dd\n\t\u0000\u0000\u01dd\u01de\u0007\u0002\u0000"+ + "\u0000\u01de\u01ee\u0003D\"\n\u01df\u01e0\n\b\u0000\u0000\u01e0\u01e1"+ + "\u0007\u0003\u0000\u0000\u01e1\u01ee\u0003D\"\t\u01e2\u01e3\n\u0007\u0000"+ + "\u0000\u01e3\u01e4\u0005`\u0000\u0000\u01e4\u01ee\u0003D\"\b\u01e5\u01e6"+ + "\n\u0006\u0000\u0000\u01e6\u01e7\u0005a\u0000\u0000\u01e7\u01ee\u0003"+ + "D\"\u0007\u01e8\u01e9\n\u000b\u0000\u0000\u01e9\u01eb\u0005P\u0000\u0000"+ + "\u01ea\u01ec\u0003D\"\u0000\u01eb\u01ea\u0001\u0000\u0000\u0000\u01eb"+ + "\u01ec\u0001\u0000\u0000\u0000\u01ec\u01ee\u0001\u0000\u0000\u0000\u01ed"+ + "\u01d6\u0001\u0000\u0000\u0000\u01ed\u01d9\u0001\u0000\u0000\u0000\u01ed"+ + "\u01dc\u0001\u0000\u0000\u0000\u01ed\u01df\u0001\u0000\u0000\u0000\u01ed"+ + "\u01e2\u0001\u0000\u0000\u0000\u01ed\u01e5\u0001\u0000\u0000\u0000\u01ed"+ + "\u01e8\u0001\u0000\u0000\u0000\u01ee\u01f1\u0001\u0000\u0000\u0000\u01ef"+ + "\u01ed\u0001\u0000\u0000\u0000\u01ef\u01f0\u0001\u0000\u0000\u0000\u01f0"+ + "E\u0001\u0000\u0000\u0000\u01f1\u01ef\u0001\u0000\u0000\u0000\u01f2\u01f3"+ + "\u0006#\uffff\uffff\u0000\u01f3\u01f4\u0005E\u0000\u0000\u01f4\u01fd\u0005"+ + "J\u0000\u0000\u01f5\u01fa\u0003D\"\u0000\u01f6\u01f7\u0005M\u0000\u0000"+ + "\u01f7\u01f9\u0003D\"\u0000\u01f8\u01f6\u0001\u0000\u0000\u0000\u01f9"+ + "\u01fc\u0001\u0000\u0000\u0000\u01fa\u01f8\u0001\u0000\u0000\u0000\u01fa"+ + "\u01fb\u0001\u0000\u0000\u0000\u01fb\u01fe\u0001\u0000\u0000\u0000\u01fc"+ + "\u01fa\u0001\u0000\u0000\u0000\u01fd\u01f5\u0001\u0000\u0000\u0000\u01fd"+ + "\u01fe\u0001\u0000\u0000\u0000\u01fe\u01ff\u0001\u0000\u0000\u0000\u01ff"+ + "\u0204\u0005K\u0000\u0000\u0200\u0204\u0005+\u0000\u0000\u0201\u0204\u0005"+ + ",\u0000\u0000\u0202\u0204\u0005E\u0000\u0000\u0203\u01f2\u0001\u0000\u0000"+ + "\u0000\u0203\u0200\u0001\u0000\u0000\u0000\u0203\u0201\u0001\u0000\u0000"+ + "\u0000\u0203\u0202\u0001\u0000\u0000\u0000\u0204\u020f\u0001\u0000\u0000"+ + "\u0000\u0205\u0206\n\u0006\u0000\u0000\u0206\u0207\u0005N\u0000\u0000"+ + "\u0207\u020e\u0005E\u0000\u0000\u0208\u0209\n\u0005\u0000\u0000\u0209"+ + "\u020a\u0005H\u0000\u0000\u020a\u020b\u0003D\"\u0000\u020b\u020c\u0005"+ + "I\u0000\u0000\u020c\u020e\u0001\u0000\u0000\u0000\u020d\u0205\u0001\u0000"+ + "\u0000\u0000\u020d\u0208\u0001\u0000\u0000\u0000\u020e\u0211\u0001\u0000"+ + "\u0000\u0000\u020f\u020d\u0001\u0000\u0000\u0000\u020f\u0210\u0001\u0000"+ + "\u0000\u0000\u0210G\u0001\u0000\u0000\u0000\u0211\u020f\u0001\u0000\u0000"+ + "\u0000\u0212\u0236\u00053\u0000\u0000\u0213\u0236\u00054\u0000\u0000\u0214"+ + "\u0236\u0005B\u0000\u0000\u0215\u0236\u0005C\u0000\u0000\u0216\u0236\u0005"+ + "D\u0000\u0000\u0217\u0220\u0005H\u0000\u0000\u0218\u021d\u0003D\"\u0000"+ + "\u0219\u021a\u0005M\u0000\u0000\u021a\u021c\u0003D\"\u0000\u021b\u0219"+ + "\u0001\u0000\u0000\u0000\u021c\u021f\u0001\u0000\u0000\u0000\u021d\u021b"+ + "\u0001\u0000\u0000\u0000\u021d\u021e\u0001\u0000\u0000\u0000\u021e\u0221"+ + "\u0001\u0000\u0000\u0000\u021f\u021d\u0001\u0000\u0000\u0000\u0220\u0218"+ + "\u0001\u0000\u0000\u0000\u0220\u0221\u0001\u0000\u0000\u0000\u0221\u0222"+ + "\u0001\u0000\u0000\u0000\u0222\u0236\u0005I\u0000\u0000\u0223\u0230\u0005"+ + "F\u0000\u0000\u0224\u0225\u0007\u0004\u0000\u0000\u0225\u0226\u0005O\u0000"+ + "\u0000\u0226\u022d\u0003D\"\u0000\u0227\u0228\u0005M\u0000\u0000\u0228"+ + "\u0229\u0007\u0004\u0000\u0000\u0229\u022a\u0005O\u0000\u0000\u022a\u022c"+ + "\u0003D\"\u0000\u022b\u0227\u0001\u0000\u0000\u0000\u022c\u022f\u0001"+ + "\u0000\u0000\u0000\u022d\u022b\u0001\u0000\u0000\u0000\u022d\u022e\u0001"+ + "\u0000\u0000\u0000\u022e\u0231\u0001\u0000\u0000\u0000\u022f\u022d\u0001"+ + "\u0000\u0000\u0000\u0230\u0224\u0001\u0000\u0000\u0000\u0230\u0231\u0001"+ + "\u0000\u0000\u0000\u0231\u0232\u0001\u0000\u0000\u0000\u0232\u0236\u0005"+ + "G\u0000\u0000\u0233\u0236\u00055\u0000\u0000\u0234\u0236\u00056\u0000"+ + "\u0000\u0235\u0212\u0001\u0000\u0000\u0000\u0235\u0213\u0001\u0000\u0000"+ + "\u0000\u0235\u0214\u0001\u0000\u0000\u0000\u0235\u0215\u0001\u0000\u0000"+ + "\u0000\u0235\u0216\u0001\u0000\u0000\u0000\u0235\u0217\u0001\u0000\u0000"+ + "\u0000\u0235\u0223\u0001\u0000\u0000\u0000\u0235\u0233\u0001\u0000\u0000"+ + "\u0000\u0235\u0234\u0001\u0000\u0000\u0000\u0236I\u0001\u0000\u0000\u0000"+ + "FKNRTY[ack~\u0090\u0096\u009c\u00a0\u00a5\u00aa\u00b0\u00b4\u00b9\u00be"+ + "\u00c2\u00c4\u00c8\u00cd\u00d7\u00da\u00e8\u00eb\u00f1\u00f7\u00fb\u0103"+ + "\u0106\u0109\u010d\u0117\u011f\u0125\u0130\u0134\u0138\u013b\u013f\u0141"+ + "\u014a\u014e\u0150\u015b\u0163\u016f\u017e\u0181\u0185\u018f\u01a6\u01d0"+ + "\u01d4\u01eb\u01ed\u01ef\u01fa\u01fd\u0203\u020d\u020f\u021d\u0220\u022d"+ + "\u0230\u0235"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/src/main/java/com/relogiclabs/json/schema/internal/collection/IndexHashMap.java b/src/main/java/com/relogiclabs/jschema/internal/collection/IndexHashMap.java similarity index 94% rename from src/main/java/com/relogiclabs/json/schema/internal/collection/IndexHashMap.java rename to src/main/java/com/relogiclabs/jschema/internal/collection/IndexHashMap.java index 0b5ae82..0b5280f 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/collection/IndexHashMap.java +++ b/src/main/java/com/relogiclabs/jschema/internal/collection/IndexHashMap.java @@ -1,7 +1,7 @@ -package com.relogiclabs.json.schema.internal.collection; +package com.relogiclabs.jschema.internal.collection; -import com.relogiclabs.json.schema.collection.IndexMap; -import com.relogiclabs.json.schema.collection.Keyable; +import com.relogiclabs.jschema.collection.IndexMap; +import com.relogiclabs.jschema.collection.Keyable; import java.util.ArrayList; import java.util.Collection; diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScopeContext.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScopeContext.java index 7e8d828..d2d2c08 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/engine/ScopeContext.java +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScopeContext.java @@ -12,7 +12,7 @@ import java.util.Map; import static com.relogiclabs.jschema.internal.library.ScriptLibrary.resolveStatic; -import static com.relogiclabs.jschema.internal.script.GFunction.CONSTRAINT_MARKER; +import static com.relogiclabs.jschema.internal.script.GFunction.CONSTRAINT_PREFIX; import static com.relogiclabs.jschema.internal.util.StringHelper.concat; import static com.relogiclabs.jschema.message.ErrorCode.FUNS02; import static com.relogiclabs.jschema.message.ErrorCode.FUNS03; @@ -38,7 +38,7 @@ public GReference addVariable(String name, EValue value) { public void addFunction(String name, GFunction function) { if(symbols.containsKey(name)) { - if(name.startsWith(CONSTRAINT_MARKER)) + if(name.startsWith(CONSTRAINT_PREFIX)) throw failOnDuplicateDefinition(FUNS02, "Constraint", name); else throw failOnDuplicateDefinition(FUNS03, "Subroutine", name); } diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptErrorHelper.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptErrorHelper.java index 2a8e33b..862350a 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptErrorHelper.java +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptErrorHelper.java @@ -33,8 +33,8 @@ import static com.relogiclabs.jschema.message.ErrorCode.RNGS09; import static com.relogiclabs.jschema.message.ErrorCode.TRGT01; import static com.relogiclabs.jschema.message.ErrorCode.VARD02; -import static com.relogiclabs.jschema.message.MessageFormatter.createOutline; import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; +import static com.relogiclabs.jschema.message.OutlineFormatter.createOutline; public final class ScriptErrorHelper { diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeHelper.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeHelper.java index 454ef52..c48ba92 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeHelper.java +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeHelper.java @@ -29,7 +29,8 @@ import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnDuplicateParameterName; import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnFixedArgument; import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnVariadicArgument; -import static com.relogiclabs.jschema.internal.script.GFunction.CONSTRAINT_MARKER; +import static com.relogiclabs.jschema.internal.script.GFunction.CONSTRAINT_PREFIX; +import static com.relogiclabs.jschema.internal.script.RFunction.hasVariadic; import static com.relogiclabs.jschema.internal.util.StreamHelper.halt; import static java.util.stream.Collectors.toMap; @@ -41,11 +42,11 @@ private ScriptTreeHelper() { throw new UnsupportedOperationException(); } - public static boolean areEqual(EValue v1, EValue v2, RuntimeContext rc) { + public static boolean areEqual(EValue v1, EValue v2, RuntimeContext runtime) { v1 = dereference(v1); v2 = dereference(v2); if(v1 instanceof ENumber n1 && v2 instanceof ENumber n2) - return rc.areEqual(n1.toDouble(), n2.toDouble()); + return runtime.areEqual(n1.toDouble(), n2.toDouble()); if(v1 instanceof EBoolean b1 && v2 instanceof EBoolean b2) return b1.getValue() == b2.getValue(); if(v1 instanceof EString s1 && v2 instanceof EString s2) @@ -55,13 +56,13 @@ public static boolean areEqual(EValue v1, EValue v2, RuntimeContext rc) { if(v1 instanceof EArray a1 && v2 instanceof EArray a2) { if(a1.size() != a2.size()) return false; for(int i = 0; i < a1.size(); i++) - if(!areEqual(a1.get(i), a2.get(i), rc)) return false; + if(!areEqual(a1.get(i), a2.get(i), runtime)) return false; return true; } if(v1 instanceof EObject o1 && v2 instanceof EObject o2) { if(o1.size() != o2.size()) return false; for(var k : o1.keySet()) - if(!areEqual(o1.get(k), o2.get(k), rc)) return false; + if(!areEqual(o1.get(k), o2.get(k), runtime)) return false; return true; } if(v1 instanceof GRange r1 && v2 instanceof GRange r2) @@ -105,7 +106,7 @@ static String formatFunctionName(String baseName, GParameter[] parameters) { } static String toConstraintName(String functionName) { - return CONSTRAINT_MARKER.concat(functionName); + return CONSTRAINT_PREFIX.concat(functionName); } static GParameter[] toParameters(List identifiers, @@ -141,9 +142,4 @@ private static void updateLast(List list, String suffix) { var last = list.size() - 1; list.set(last, list.get(last).concat(suffix)); } - - private static boolean hasVariadic(GParameter[] parameters) { - if(parameters.length == 0) return false; - return parameters[parameters.length - 1].isVariadic(); - } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor1.java b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor1.java index 48995e0..dadada4 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor1.java +++ b/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptTreeVisitor1.java @@ -13,6 +13,7 @@ import com.relogiclabs.jschema.internal.script.GIterator; import com.relogiclabs.jschema.internal.script.GObject; import com.relogiclabs.jschema.internal.script.GString; +import com.relogiclabs.jschema.internal.tree.ScriptFunction; import com.relogiclabs.jschema.tree.RuntimeContext; import com.relogiclabs.jschema.type.EBoolean; import lombok.Getter; @@ -24,7 +25,6 @@ import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnInvalidReturnType; import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnRuntime; import static com.relogiclabs.jschema.internal.engine.ScriptErrorHelper.failOnSystemException; -import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.dereference; import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.formatFunctionName; import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.getFunctionMode; import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.toConstraintName; diff --git a/src/main/java/com/relogiclabs/jschema/internal/function/DateTimeAgent.java b/src/main/java/com/relogiclabs/jschema/internal/function/DateTimeAgent.java index 2bd6539..18b1b4b 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/function/DateTimeAgent.java +++ b/src/main/java/com/relogiclabs/jschema/internal/function/DateTimeAgent.java @@ -28,24 +28,27 @@ public DateTimeAgent(DateTimeParser parser) { this.parser = parser; } - public JsonDateTime parse(JFunction function, JString dateTime) { - var exceptions = function.getRuntime().getExceptions(); + public JsonDateTime parse(JFunction caller, JString dateTime) { try { if(parser == null) parser = new DateTimeParser(pattern, type); return parser.parse(dateTime.getValue()); } catch(DateTimeLexerException ex) { - exceptions.fail(new JsonSchemaException( + fail(caller, new JsonSchemaException( new ErrorDetail(ex.getCode(), ex.getMessage()), - new ExpectedDetail(function, "a valid ", type, " pattern"), + new ExpectedDetail(caller, "a valid ", type, " pattern"), new ActualDetail(dateTime, "found ", pattern, " that is invalid"), ex)); } catch(InvalidDateTimeException ex) { - exceptions.fail(new JsonSchemaException( + fail(caller, new JsonSchemaException( new ErrorDetail(ex.getCode(), ex.getMessage()), - new ExpectedDetail(function, "a valid ", type, " formatted as ", pattern), + new ExpectedDetail(caller, "a valid ", type, " formatted as ", pattern), new ActualDetail(dateTime, "found ", dateTime, " that is invalid or malformatted"), ex)); } return null; } + + private static void fail(JFunction caller, RuntimeException exception) { + caller.getRuntime().getExceptions().fail(exception); + } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaLexer.g4 b/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaLexer.g4 index 2d8bca0..e3c329f 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaLexer.g4 +++ b/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaLexer.g4 @@ -140,7 +140,7 @@ G_OR : '||'; // Next Sections DEFINE1 : '%define' -> type(DEFINE), popMode; SCHEMA1 : '%schema' -> type(SCHEMA), popMode; -SCRIPT1 : '%script' -> type(SCRIPT), popMode; +SCRIPT1 : '%script' -> type(SCRIPT); // Hidden Tokens WHITE_SPACE1 : WHITE_SPACE -> channel(HIDDEN); diff --git a/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaParser.g4 b/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaParser.g4 index 0fb1546..896db9c 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaParser.g4 +++ b/src/main/java/com/relogiclabs/jschema/internal/grammar/SchemaParser.g4 @@ -147,7 +147,7 @@ whileStatement ; forStatement - : G_FOR G_LPAREN ( varStatement | initialization=expressionList G_SEMI )? + : G_FOR G_LPAREN ( varStatement | initialization=expressionList G_SEMI | G_SEMI ) condition=expression? G_SEMI updation=expressionList? G_RPAREN statement ; diff --git a/src/main/java/com/relogiclabs/jschema/internal/library/NFunction.java b/src/main/java/com/relogiclabs/jschema/internal/library/NFunction.java index 3bed946..fd59218 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/library/NFunction.java +++ b/src/main/java/com/relogiclabs/jschema/internal/library/NFunction.java @@ -10,17 +10,19 @@ import java.util.List; import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.areCompatible; -import static com.relogiclabs.jschema.internal.util.CollectionHelper.getLast; +import static com.relogiclabs.jschema.internal.script.RFunction.hasVariadic; import static com.relogiclabs.jschema.message.ErrorCode.FUNS06; @Getter public class NFunction implements RFunction { private final NHandler handler; private final GParameter[] parameters; + private final boolean variadic; public NFunction(NHandler handler, String... parameters) { this.handler = handler; this.parameters = toParameters(parameters); + this.variadic = hasVariadic(this.parameters); } private static GParameter[] toParameters(String... names) { @@ -37,10 +39,4 @@ public ScopeContext bind(ScopeContext parentScope, List arguments) { areCompatible(parameters, arguments, FUNS06); return parentScope; } - - @Override - public boolean isVariadic() { - if(parameters.length == 0) return false; - return getLast(parameters).isVariadic(); - } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/library/ScriptLibrary.java b/src/main/java/com/relogiclabs/jschema/internal/library/ScriptLibrary.java index 9cd34f5..2be1f93 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/library/ScriptLibrary.java +++ b/src/main/java/com/relogiclabs/jschema/internal/library/ScriptLibrary.java @@ -3,6 +3,7 @@ import com.relogiclabs.jschema.exception.JsonSchemaException; import com.relogiclabs.jschema.exception.ScriptArgumentException; import com.relogiclabs.jschema.exception.ScriptInitiatedException; +import com.relogiclabs.jschema.internal.engine.ScopeContext; import com.relogiclabs.jschema.internal.engine.ScriptTreeHelper; import com.relogiclabs.jschema.internal.script.GArray; import com.relogiclabs.jschema.internal.script.GDouble; @@ -103,8 +104,8 @@ import static com.relogiclabs.jschema.message.ErrorCode.POWR01; import static com.relogiclabs.jschema.message.ErrorCode.POWR02; import static com.relogiclabs.jschema.message.ErrorCode.SIZE01; -import static com.relogiclabs.jschema.message.MessageFormatter.createOutline; -import static com.relogiclabs.jschema.message.MessageFormatter.formatOfSchema; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; +import static com.relogiclabs.jschema.message.OutlineFormatter.createOutline; import static com.relogiclabs.jschema.type.EValue.VOID; public class ScriptLibrary { @@ -143,7 +144,7 @@ public static EValue resolveStatic(String name) { } private void scriptPrintFunction() { - var handler = (NHandler) (scope, arguments) -> { + NHandler handler = (scope, arguments) -> { System.out.println(arguments.stream().map(ScriptTreeHelper::stringify) .collect(Collectors.joining(" "))); return VOID; @@ -153,14 +154,14 @@ private void scriptPrintFunction() { } private void scriptTypeFunction() { - var handler = (NHandler) (scope, arguments) + NHandler handler = (scope, arguments) -> GString.of(arguments.get(0).getType().getName()); var function = new NFunction(handler, VALUE_ID); symbols.put(TYPE_FN1, function); } private void scriptSizeFunction() { - var handler = (NHandler) (scope, arguments) -> { + NHandler handler = (scope, arguments) -> { var value = arguments.get(0); if(value instanceof EArray a) return GInteger.of(a.size()); if(value instanceof EObject o) return GInteger.of(o.size()); @@ -172,20 +173,20 @@ private void scriptSizeFunction() { } private void scriptStringifyFunction() { - var handler = (NHandler) (scope, arguments) + NHandler handler = (scope, arguments) -> GString.of(stringify(arguments.get(0))); var function = new NFunction(handler, VALUE_ID); symbols.put(STRINGIFY_FN1, function); } private void scriptFindFunction1() { - var handler = (NHandler) (scope, arguments) -> { + NHandler handler = (scope, arguments) -> { var group = arguments.get(0); var item = arguments.get(1); - var rc = scope.getRuntime(); + var rt = scope.getRuntime(); if(group instanceof EArray g) { var s = g.size(); - for(int i = 0; i < s; i++) if(areEqual(g.get(i), item, rc)) return GInteger.of(i); + for(int i = 0; i < s; i++) if(areEqual(g.get(i), item, rt)) return GInteger.of(i); return GInteger.of(-1); } else if(group instanceof EString g) { return GInteger.of(g.getValue().indexOf(getString(item, ITEM_ID, FIND01))); @@ -196,15 +197,15 @@ private void scriptFindFunction1() { } private void scriptFindFunction2() { - var handler = (NHandler) (scope, arguments) -> { + NHandler handler = (scope, arguments) -> { var group = arguments.get(0); var item = arguments.get(1); var from = arguments.get(2); - var rc = scope.getRuntime(); + var rt = scope.getRuntime(); if(group instanceof EArray g) { var s = g.size(); for(int i = (int) getInteger(from, FROM_ID, FIND03); i < s; i++) - if(areEqual(g.get(i), item, rc)) return GInteger.of(i); + if(areEqual(g.get(i), item, rt)) return GInteger.of(i); return GInteger.of(-1); } else if(group instanceof EString g) { return GInteger.of(g.getValue().indexOf(getString(item, ITEM_ID, FIND04), @@ -216,7 +217,7 @@ private void scriptFindFunction2() { } private void scriptRegularFunction() { - var handler = (NHandler) (scope, arguments) -> { + NHandler handler = (scope, arguments) -> { var value = arguments.get(0); if(value instanceof ENull) return FALSE; if(value instanceof EUndefined) return FALSE; @@ -228,13 +229,11 @@ private void scriptRegularFunction() { } private void scriptFailFunction1() { - var handler = (NHandler) (scope, arguments) -> { - var runtime = scope.getRuntime(); + NHandler handler = (scope, arguments) -> { var caller = scope.resolve(CALLER_HVAR); if(caller == VOID) caller = null; - runtime.getExceptions().fail(new ScriptInitiatedException(FAIL01, - formatOfSchema(FAIL01, getString(arguments.get(0), MESSAGE_ID, FAIL02), - (JNode) caller))); + fail(scope, new ScriptInitiatedException(formatForSchema(FAIL01, + getString(arguments.get(0), MESSAGE_ID, FAIL02), (JNode) caller))); return FALSE; }; var function = new NFunction(handler, MESSAGE_ID); @@ -242,14 +241,12 @@ private void scriptFailFunction1() { } private void scriptFailFunction2() { - var handler = (NHandler) (scope, arguments) -> { - var runtime = scope.getRuntime(); + NHandler handler = (scope, arguments) -> { var caller = scope.resolve(CALLER_HVAR); if(caller == VOID) caller = null; var code = getString(arguments.get(0), CODE_ID, FAIL03); - runtime.getExceptions().fail(new ScriptInitiatedException(code, - formatOfSchema(code, getString(arguments.get(1), MESSAGE_ID, FAIL04), - (JNode) caller))); + fail(scope, new ScriptInitiatedException(formatForSchema(code, + getString(arguments.get(1), MESSAGE_ID, FAIL04), (JNode) caller))); return FALSE; }; var function = new NFunction(handler, CODE_ID, MESSAGE_ID); @@ -257,15 +254,12 @@ private void scriptFailFunction2() { } private void scriptFailFunction3() { - var handler = (NHandler) (scope, arguments) -> { + NHandler handler = (scope, arguments) -> { var code = getString(arguments.get(0), CODE_ID, FAIL05); var message = getString(arguments.get(1), MESSAGE_ID, FAIL06); var expected = castObject(arguments.get(2), EXPECTED_ID, FAIL07); var actual = castObject(arguments.get(3), ACTUAL_ID, FAIL08); - var runtime = scope.getRuntime(); - - runtime.getExceptions().fail(new JsonSchemaException( - new ErrorDetail(code, message), + fail(scope, new JsonSchemaException(new ErrorDetail(code, message), new ExpectedDetail(getNode(expected, NODE_ID, EXPECTED_ID, FAIL09), getString(expected, MESSAGE_ID, EXPECTED_ID, FAIL10)), new ActualDetail(getNode(actual, NODE_ID, ACTUAL_ID, FAIL11), @@ -291,7 +285,7 @@ private static String getString(EObject object, String key, String parameter, St } private void scriptExpectedFunction1() { - var handler = (NHandler) (scope, arguments) -> { + NHandler handler = (scope, arguments) -> { var object = new GObject(2); object.set(NODE_ID, scope.resolve(CALLER_HVAR)); object.set(MESSAGE_ID, castString(arguments.get(0), MESSAGE_ID, EXPC01)); @@ -302,7 +296,7 @@ private void scriptExpectedFunction1() { } private void scriptExpectedFunction2() { - var handler = (NHandler) (scope, arguments) -> { + NHandler handler = (scope, arguments) -> { var object = new GObject(2); object.set(NODE_ID, getNode(arguments.get(0), NODE_ID, EXPC02)); object.set(MESSAGE_ID, castString(arguments.get(1), MESSAGE_ID, EXPC03)); @@ -313,7 +307,7 @@ private void scriptExpectedFunction2() { } private void scriptActualFunction1() { - var handler = (NHandler) (scope, arguments) -> { + NHandler handler = (scope, arguments) -> { var object = new GObject(2); object.set(NODE_ID, scope.resolve(TARGET_HVAR)); object.set(MESSAGE_ID, castString(arguments.get(0), MESSAGE_ID, ACTL01)); @@ -324,7 +318,7 @@ private void scriptActualFunction1() { } private void scriptActualFunction2() { - var handler = (NHandler) (scope, arguments) -> { + NHandler handler = (scope, arguments) -> { var object = new GObject(2); object.set(NODE_ID, getNode(arguments.get(0), NODE_ID, ACTL02)); object.set(MESSAGE_ID, castString(arguments.get(1), MESSAGE_ID, ACTL03)); @@ -335,7 +329,7 @@ private void scriptActualFunction2() { } private void scriptCopyFunction() { - var handler = (NHandler) (scope, arguments) -> { + NHandler handler = (scope, arguments) -> { var value = arguments.get(0); if(value instanceof EArray a) return new GArray(a.elements()); if(value instanceof EObject o) return new GObject(o); @@ -349,28 +343,28 @@ private void scriptCopyFunction() { } private void scriptFillFunction() { - var handler = (NHandler) (scope, arguments) -> GArray.filledFrom( + NHandler handler = (scope, arguments) -> GArray.filledFrom( arguments.get(0), (int) getInteger(arguments.get(1), SIZE_ID, FILL01)); var function = new NFunction(handler, VALUE_ID, SIZE_ID); symbols.put(FILL_FN2, function); } private void scriptCeilFunction() { - var handler = (NHandler) (scope, arguments) -> GInteger.of((long) Math.ceil( + NHandler handler = (scope, arguments) -> GInteger.of((long) Math.ceil( getNumber(arguments.get(0), VALUE_ID, CEIL01))); var function = new NFunction(handler, VALUE_ID); symbols.put(CEIL_FN1, function); } private void scriptFloorFunction() { - var handler = (NHandler) (scope, arguments) -> GInteger.of((long) Math.floor( + NHandler handler = (scope, arguments) -> GInteger.of((long) Math.floor( getNumber(arguments.get(0), VALUE_ID, FLOR01))); var function = new NFunction(handler, VALUE_ID); symbols.put(FLOOR_FN1, function); } private void scriptModFunction() { - var handler = (NHandler) (scope, arguments) -> { + NHandler handler = (scope, arguments) -> { var val1 = arguments.get(0); var val2 = arguments.get(1); var num1 = getNumber(val1, VALUE1_ID, MODU01); @@ -384,7 +378,7 @@ private void scriptModFunction() { } private void scriptPowFunction() { - var handler = (NHandler) (scope, arguments) -> GDouble.of(Math.pow( + NHandler handler = (scope, arguments) -> GDouble.of(Math.pow( getNumber(arguments.get(0), VALUE1_ID, POWR01), getNumber(arguments.get(1), VALUE2_ID, POWR02) )); @@ -393,16 +387,14 @@ private void scriptPowFunction() { } private void scriptLogFunction() { - var handler = (NHandler) (scope, arguments) -> { - var value = getNumber(arguments.get(0), VALUE_ID, LOGA01); - return GDouble.of(Math.log(value)); - }; + NHandler handler = (scope, arguments) -> GDouble.of(Math.log( + getNumber(arguments.get(0), VALUE_ID, LOGA01))); var function = new NFunction(handler, VALUE_ID); symbols.put(LOG_FN1, function); } private void scriptTicksFunction() { - var handler = (NHandler) (scope, arguments) -> GInteger.of(System.nanoTime()); + NHandler handler = (scope, arguments) -> GInteger.of(System.nanoTime()); var function = new NFunction(handler); symbols.put(TICKS_FN0, function); } @@ -449,4 +441,8 @@ private static ScriptArgumentException failOnInvalidArgumentValue(String code, createOutline(value), " for parameter '", parameter, "' of function '%s'")); } + + private static void fail(ScopeContext scope, RuntimeException exception) { + scope.getRuntime().getExceptions().fail(exception); + } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/message/ActualHelper.java b/src/main/java/com/relogiclabs/jschema/internal/message/ActualHelper.java similarity index 82% rename from src/main/java/com/relogiclabs/json/schema/internal/message/ActualHelper.java rename to src/main/java/com/relogiclabs/jschema/internal/message/ActualHelper.java index 53c068e..a32d237 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/message/ActualHelper.java +++ b/src/main/java/com/relogiclabs/jschema/internal/message/ActualHelper.java @@ -1,12 +1,12 @@ -package com.relogiclabs.json.schema.internal.message; +package com.relogiclabs.jschema.internal.message; -import com.relogiclabs.json.schema.message.ActualDetail; -import com.relogiclabs.json.schema.type.JArray; -import com.relogiclabs.json.schema.type.JNode; -import com.relogiclabs.json.schema.type.JProperty; +import com.relogiclabs.jschema.message.ActualDetail; +import com.relogiclabs.jschema.node.JArray; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JProperty; -import static com.relogiclabs.json.schema.internal.message.MessageHelper.getTypeName; -import static com.relogiclabs.json.schema.internal.util.StringHelper.quote; +import static com.relogiclabs.jschema.internal.message.MessageHelper.getTypeName; +import static com.relogiclabs.jschema.internal.util.StringHelper.quote; public final class ActualHelper { diff --git a/src/main/java/com/relogiclabs/json/schema/internal/message/ExpectedHelper.java b/src/main/java/com/relogiclabs/jschema/internal/message/ExpectedHelper.java similarity index 79% rename from src/main/java/com/relogiclabs/json/schema/internal/message/ExpectedHelper.java rename to src/main/java/com/relogiclabs/jschema/internal/message/ExpectedHelper.java index 6ae1b84..4f0aa56 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/message/ExpectedHelper.java +++ b/src/main/java/com/relogiclabs/jschema/internal/message/ExpectedHelper.java @@ -1,14 +1,14 @@ -package com.relogiclabs.json.schema.internal.message; +package com.relogiclabs.jschema.internal.message; -import com.relogiclabs.json.schema.message.ExpectedDetail; -import com.relogiclabs.json.schema.type.JDataType; -import com.relogiclabs.json.schema.type.JFunction; -import com.relogiclabs.json.schema.type.JNode; -import com.relogiclabs.json.schema.type.JObject; -import com.relogiclabs.json.schema.type.JProperty; +import com.relogiclabs.jschema.message.ExpectedDetail; +import com.relogiclabs.jschema.node.JDataType; +import com.relogiclabs.jschema.node.JFunction; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JObject; +import com.relogiclabs.jschema.node.JProperty; -import static com.relogiclabs.json.schema.internal.message.MessageHelper.getTypeName; -import static com.relogiclabs.json.schema.internal.util.StringHelper.quote; +import static com.relogiclabs.jschema.internal.message.MessageHelper.getTypeName; +import static com.relogiclabs.jschema.internal.util.StringHelper.quote; public final class ExpectedHelper { diff --git a/src/main/java/com/relogiclabs/json/schema/internal/message/MessageHelper.java b/src/main/java/com/relogiclabs/jschema/internal/message/MessageHelper.java similarity index 78% rename from src/main/java/com/relogiclabs/json/schema/internal/message/MessageHelper.java rename to src/main/java/com/relogiclabs/jschema/internal/message/MessageHelper.java index 49a826e..7853774 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/message/MessageHelper.java +++ b/src/main/java/com/relogiclabs/jschema/internal/message/MessageHelper.java @@ -1,8 +1,9 @@ -package com.relogiclabs.json.schema.internal.message; +package com.relogiclabs.jschema.internal.message; -import com.relogiclabs.json.schema.type.JNode; -import com.relogiclabs.json.schema.type.JsonTypable; -import com.relogiclabs.json.schema.type.JsonType; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JsonTypable; +import com.relogiclabs.jschema.node.JsonType; +import com.relogiclabs.jschema.type.EType; public final class MessageHelper { @@ -24,13 +25,13 @@ private MessageHelper() { } public static String getTypeName(JNode node) { - return node instanceof JsonTypable jsonNode - ? jsonNode.getType().getName() + return node instanceof JsonTypable jsonTypable + ? jsonTypable.getType().getName() : node.getClass().getName(); } public static String getTypeName(Class type) { - JsonType t = JsonType.from(type); + EType t = JsonType.getType(type); if(t != null) return t.getName(); else return type.getSimpleName(); } diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GArray.java b/src/main/java/com/relogiclabs/jschema/internal/script/GArray.java index d6ad114..dba35fa 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/script/GArray.java +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GArray.java @@ -48,9 +48,9 @@ public EValue get(int index) { if(index > MAX_LIMIT) throw new ScriptCommonException(INDX01, concat("Array index ", index, " exceeds maximum size limit")); if(index > size) throw new ArrayIndexOutOfBoundsException(index); - var element = new GReference(VOID); - elements.add(element); - return element; + var reference = new GReference(VOID); + elements.add(reference); + return reference; } @Override diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GFunction.java b/src/main/java/com/relogiclabs/jschema/internal/script/GFunction.java index 0033781..7c86f2e 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/script/GFunction.java +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GFunction.java @@ -9,7 +9,7 @@ import java.util.List; import static com.relogiclabs.jschema.internal.engine.ScriptTreeHelper.areCompatible; -import static com.relogiclabs.jschema.internal.util.CollectionHelper.getLast; +import static com.relogiclabs.jschema.internal.script.RFunction.hasVariadic; import static com.relogiclabs.jschema.internal.util.CollectionHelper.subList; import static com.relogiclabs.jschema.internal.util.MiscellaneousHelper.hasFlag; import static com.relogiclabs.jschema.message.ErrorCode.FUNS05; @@ -17,7 +17,7 @@ @Getter @RequiredArgsConstructor public final class GFunction implements RFunction { - public static final String CONSTRAINT_MARKER = "@"; + public static final String CONSTRAINT_PREFIX = "@"; public static final int CONSTRAINT_MODE = 1; public static final int FUTURE_MODE = 3; public static final int SUBROUTINE_MODE = 4; @@ -31,7 +31,7 @@ public GFunction(GParameter[] parameters, Evaluator body, int mode) { this.parameters = parameters; this.body = body; this.mode = mode; - this.variadic = parameters.length != 0 && getLast(parameters).isVariadic(); + this.variadic = hasVariadic(parameters); } @Override @@ -40,8 +40,8 @@ public EValue invoke(ScopeContext functionScope, List arguments) { } public EValue invoke(ScopeContext functionScope) { - var v1 = getBody().evaluate(functionScope); - if(v1 instanceof GControl ctrl) return ctrl.getValue(); + var result = getBody().evaluate(functionScope); + if(result instanceof GControl ctrl) return ctrl.getValue(); return VOID; } diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GInteger.java b/src/main/java/com/relogiclabs/jschema/internal/script/GInteger.java index 09be8d5..70357d6 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/script/GInteger.java +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GInteger.java @@ -11,12 +11,14 @@ @EqualsAndHashCode @RequiredArgsConstructor(access = PRIVATE) public final class GInteger implements EInteger { - private static final int CACHE_SIZE = 256; - private static final GInteger[] CACHE = createCache(CACHE_SIZE); + private static final int CACHE_START = -1; + private static final int CACHE_END = 256; + private static final GInteger[] CACHE = createCache(); private final long value; public static GInteger of(long value) { - if(value >= 0 && value < CACHE_SIZE) return CACHE[(int) value]; + if(value >= CACHE_START && value <= CACHE_END) + return CACHE[(int) value - CACHE_START]; return new GInteger(value); } @@ -25,9 +27,11 @@ public String toString() { return String.valueOf(value); } - private static GInteger[] createCache(int size) { + private static GInteger[] createCache() { + var size = CACHE_END - CACHE_START + 1; GInteger[] cache = new GInteger[size]; - for(int i = 0; i < size; i++) cache[i] = new GInteger(i); + var value = CACHE_START; + for(int i = 0; i < size; i++) cache[i] = new GInteger(value++); return cache; } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GParameter.java b/src/main/java/com/relogiclabs/jschema/internal/script/GParameter.java index 6f5d11c..1995b73 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/script/GParameter.java +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GParameter.java @@ -8,17 +8,17 @@ @Getter @EqualsAndHashCode public final class GParameter { - private static final String VARIADIC_MARKER = "..."; + private static final String VARIADIC_SUFFIX = "..."; private final String name; private final boolean variadic; public GParameter(String name) { - this.variadic = name.endsWith(VARIADIC_MARKER); - this.name = removeEnd(name, VARIADIC_MARKER); + this.variadic = name.endsWith(VARIADIC_SUFFIX); + this.name = removeEnd(name, VARIADIC_SUFFIX); } @Override public String toString() { - return variadic ? name + VARIADIC_MARKER : name; + return variadic ? name.concat(VARIADIC_SUFFIX) : name; } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GRange.java b/src/main/java/com/relogiclabs/jschema/internal/script/GRange.java index c6f5fcd..a5fbfb0 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/script/GRange.java +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GRange.java @@ -12,14 +12,14 @@ @EqualsAndHashCode @RequiredArgsConstructor(access = PRIVATE) public final class GRange implements EValue { - public static final String RANGE_MARKER = ".."; + public static final String RANGE_OPERATOR = ".."; private final int start; private final int end; public static GRange of(EInteger start, EInteger end) { - var v1 = start == null ? Integer.MIN_VALUE : (int) start.getValue(); - var v2 = end == null ? Integer.MIN_VALUE : (int) end.getValue(); - return new GRange(v1, v2); + var vStart = start == null ? Integer.MIN_VALUE : (int) start.getValue(); + var vEnd = end == null ? Integer.MIN_VALUE : (int) end.getValue(); + return new GRange(vStart, vEnd); } public int getStart(int size) { @@ -39,8 +39,8 @@ public EType getType() { @Override public String toString() { - var pStart = start != Integer.MIN_VALUE ? start : EMPTY; - var pEnd = end != Integer.MIN_VALUE ? end : EMPTY; - return pStart + RANGE_MARKER + pEnd; + var sStart = start != Integer.MIN_VALUE ? start : EMPTY; + var sEnd = end != Integer.MIN_VALUE ? end : EMPTY; + return sStart + RANGE_OPERATOR + sEnd; } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/GReference.java b/src/main/java/com/relogiclabs/jschema/internal/script/GReference.java index 8da2537..863c438 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/script/GReference.java +++ b/src/main/java/com/relogiclabs/jschema/internal/script/GReference.java @@ -27,9 +27,8 @@ public EType getType() { @Override public boolean equals(Object o) { - if(this == o) return true; - if(!(o instanceof EValue)) return false; - return Objects.equals(value, o); + if(!(o instanceof EValue v)) return false; + return Objects.equals(value, dereference(v)); } @Override diff --git a/src/main/java/com/relogiclabs/jschema/internal/script/RFunction.java b/src/main/java/com/relogiclabs/jschema/internal/script/RFunction.java index 351346c..68de29a 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/script/RFunction.java +++ b/src/main/java/com/relogiclabs/jschema/internal/script/RFunction.java @@ -10,4 +10,9 @@ public interface RFunction extends EValue { EValue invoke(ScopeContext functionScope, List arguments); GParameter[] getParameters(); boolean isVariadic(); + + static boolean hasVariadic(GParameter[] parameters) { + if(parameters.length == 0) return false; + return parameters[parameters.length - 1].isVariadic(); + } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/time/DateTimeContext.java b/src/main/java/com/relogiclabs/jschema/internal/time/DateTimeContext.java similarity index 85% rename from src/main/java/com/relogiclabs/json/schema/internal/time/DateTimeContext.java rename to src/main/java/com/relogiclabs/jschema/internal/time/DateTimeContext.java index 1968f53..921a9e3 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/time/DateTimeContext.java +++ b/src/main/java/com/relogiclabs/jschema/internal/time/DateTimeContext.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.internal.time; +package com.relogiclabs.jschema.internal.time; -import com.relogiclabs.json.schema.exception.InvalidDateTimeException; -import com.relogiclabs.json.schema.time.DateTimeType; -import com.relogiclabs.json.schema.time.JsonDateTime; -import com.relogiclabs.json.schema.time.JsonUtcOffset; +import com.relogiclabs.jschema.exception.InvalidDateTimeException; +import com.relogiclabs.jschema.time.DateTimeType; +import com.relogiclabs.jschema.time.JsonDateTime; +import com.relogiclabs.jschema.time.JsonUtcOffset; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -12,25 +12,25 @@ import java.util.HashMap; import java.util.Map; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static com.relogiclabs.json.schema.message.ErrorCode.DCNF01; -import static com.relogiclabs.json.schema.message.ErrorCode.DDAY03; -import static com.relogiclabs.json.schema.message.ErrorCode.DDAY04; -import static com.relogiclabs.json.schema.message.ErrorCode.DERA02; -import static com.relogiclabs.json.schema.message.ErrorCode.DHUR03; -import static com.relogiclabs.json.schema.message.ErrorCode.DHUR04; -import static com.relogiclabs.json.schema.message.ErrorCode.DHUR05; -import static com.relogiclabs.json.schema.message.ErrorCode.DHUR06; -import static com.relogiclabs.json.schema.message.ErrorCode.DINV01; -import static com.relogiclabs.json.schema.message.ErrorCode.DMIN03; -import static com.relogiclabs.json.schema.message.ErrorCode.DMON05; -import static com.relogiclabs.json.schema.message.ErrorCode.DSEC03; -import static com.relogiclabs.json.schema.message.ErrorCode.DTAP02; -import static com.relogiclabs.json.schema.message.ErrorCode.DUTC04; -import static com.relogiclabs.json.schema.message.ErrorCode.DUTC05; -import static com.relogiclabs.json.schema.message.ErrorCode.DWKD03; -import static com.relogiclabs.json.schema.message.ErrorCode.DYAR03; -import static com.relogiclabs.json.schema.time.JsonDateTime.UNSET; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.DCNF01; +import static com.relogiclabs.jschema.message.ErrorCode.DDAY03; +import static com.relogiclabs.jschema.message.ErrorCode.DDAY04; +import static com.relogiclabs.jschema.message.ErrorCode.DERA02; +import static com.relogiclabs.jschema.message.ErrorCode.DHUR03; +import static com.relogiclabs.jschema.message.ErrorCode.DHUR04; +import static com.relogiclabs.jschema.message.ErrorCode.DHUR05; +import static com.relogiclabs.jschema.message.ErrorCode.DHUR06; +import static com.relogiclabs.jschema.message.ErrorCode.DINV01; +import static com.relogiclabs.jschema.message.ErrorCode.DMIN03; +import static com.relogiclabs.jschema.message.ErrorCode.DMON05; +import static com.relogiclabs.jschema.message.ErrorCode.DSEC03; +import static com.relogiclabs.jschema.message.ErrorCode.DTAP02; +import static com.relogiclabs.jschema.message.ErrorCode.DUTC04; +import static com.relogiclabs.jschema.message.ErrorCode.DUTC05; +import static com.relogiclabs.jschema.message.ErrorCode.DWKD03; +import static com.relogiclabs.jschema.message.ErrorCode.DYAR03; +import static com.relogiclabs.jschema.time.JsonDateTime.UNSET; import static java.time.DayOfWeek.FRIDAY; import static java.time.DayOfWeek.MONDAY; import static java.time.DayOfWeek.SATURDAY; diff --git a/src/main/java/com/relogiclabs/jschema/internal/time/DateTimeParser.java b/src/main/java/com/relogiclabs/jschema/internal/time/DateTimeParser.java new file mode 100644 index 0000000..bd9af0d --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/time/DateTimeParser.java @@ -0,0 +1,166 @@ +package com.relogiclabs.jschema.internal.time; + +import com.relogiclabs.jschema.exception.InvalidDateTimeException; +import com.relogiclabs.jschema.internal.antlr.DateTimeLexer; +import com.relogiclabs.jschema.internal.util.LexerErrorListener; +import com.relogiclabs.jschema.internal.util.LogHelper; +import com.relogiclabs.jschema.time.DateTimeType; +import com.relogiclabs.jschema.time.JsonDateTime; +import com.relogiclabs.jschema.util.Reference; +import lombok.Getter; +import org.antlr.v4.runtime.CharStreams; +import org.antlr.v4.runtime.Token; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.CLOCK_AM_PM; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.DAY_NUMBER; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.DAY_NUMBER2; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.ERA; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.FRACTION_NUMBER; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.FRACTION_NUMBER1; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.FRACTION_NUMBER2; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.FRACTION_NUMBER3; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.FRACTION_NUMBER4; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.FRACTION_NUMBER5; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.FRACTION_NUMBER6; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.HOUR_NUMBER; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.HOUR_NUMBER2; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.MINUTE_NUMBER; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.MINUTE_NUMBER2; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.MONTH_NAME; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.MONTH_NUMBER; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.MONTH_NUMBER2; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.MONTH_SHORT_NAME; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.SECOND_NUMBER; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.SECOND_NUMBER2; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.SYMBOL; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.TEXT; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.UTC_OFFSET_HOUR; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.UTC_OFFSET_TIME1; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.UTC_OFFSET_TIME2; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.WEEKDAY_NAME; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.WEEKDAY_SHORT_NAME; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.WHITESPACE; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.YEAR_NUMBER2; +import static com.relogiclabs.jschema.internal.antlr.DateTimeLexer.YEAR_NUMBER4; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.ClockAmPm; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.DayNumber; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.DayNumber2; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.Era; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.FractionNumber; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.FractionNumber1; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.FractionNumber2; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.FractionNumber3; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.FractionNumber4; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.FractionNumber5; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.FractionNumber6; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.HourNumber; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.HourNumber2; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.MinuteNumber; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.MinuteNumber2; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.MonthName; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.MonthNumber; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.MonthNumber2; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.MonthShortName; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.SecondNumber; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.SecondNumber2; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.Symbol; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.Text; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.UtcOffsetHour; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.UtcOffsetTime1; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.UtcOffsetTime2; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.WeekdayName; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.WeekdayShortName; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.Whitespace; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.YearNumber2; +import static com.relogiclabs.jschema.internal.time.SegmentProcessor.YearNumber4; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.DINV02; + +public final class DateTimeParser { + private static final Map PROCESSORS; + private final DateTimeLexer dateTimeLexer; + private final List lexerTokens; + + @Getter private final String pattern; + @Getter private final DateTimeType type; + + static { + PROCESSORS = new HashMap<>(50); + addProcessor(TEXT, Text); + addProcessor(SYMBOL, Symbol); + addProcessor(WHITESPACE, Whitespace); + addProcessor(ERA, Era); + addProcessor(YEAR_NUMBER4, YearNumber4); + addProcessor(YEAR_NUMBER2, YearNumber2); + addProcessor(MONTH_NAME, MonthName); + addProcessor(MONTH_SHORT_NAME, MonthShortName); + addProcessor(MONTH_NUMBER2, MonthNumber2); + addProcessor(MONTH_NUMBER, MonthNumber); + addProcessor(WEEKDAY_NAME, WeekdayName); + addProcessor(WEEKDAY_SHORT_NAME, WeekdayShortName); + addProcessor(DAY_NUMBER2, DayNumber2); + addProcessor(DAY_NUMBER, DayNumber); + addProcessor(CLOCK_AM_PM, ClockAmPm); + addProcessor(HOUR_NUMBER2, HourNumber2); + addProcessor(HOUR_NUMBER, HourNumber); + addProcessor(MINUTE_NUMBER2, MinuteNumber2); + addProcessor(MINUTE_NUMBER, MinuteNumber); + addProcessor(SECOND_NUMBER2, SecondNumber2); + addProcessor(SECOND_NUMBER, SecondNumber); + addProcessor(FRACTION_NUMBER, FractionNumber); + addProcessor(FRACTION_NUMBER1, FractionNumber1); + addProcessor(FRACTION_NUMBER2, FractionNumber2); + addProcessor(FRACTION_NUMBER3, FractionNumber3); + addProcessor(FRACTION_NUMBER4, FractionNumber4); + addProcessor(FRACTION_NUMBER5, FractionNumber5); + addProcessor(FRACTION_NUMBER6, FractionNumber6); + addProcessor(UTC_OFFSET_HOUR, UtcOffsetHour); + addProcessor(UTC_OFFSET_TIME1, UtcOffsetTime1); + addProcessor(UTC_OFFSET_TIME2, UtcOffsetTime2); + } + + private static void addProcessor(int index, SegmentProcessor processor) { + PROCESSORS.put(DateTimeLexer.ruleNames[index - 1], processor); + } + + @SuppressWarnings("unchecked") + public DateTimeParser(String pattern, DateTimeType type) { + this.pattern = pattern; + this.type = type; + this.dateTimeLexer = new DateTimeLexer(CharStreams.fromString(pattern)); + this.dateTimeLexer.removeErrorListeners(); + this.dateTimeLexer.addErrorListener(LexerErrorListener.DATE_TIME); + this.lexerTokens = (List) dateTimeLexer.getAllTokens(); + } + + private JsonDateTime parse(String input, DateTimeContext context) { + for(var token : lexerTokens) { + var processor = PROCESSORS.get(dateTimeLexer.getVocabulary().getSymbolicName(token.getType())); + input = processor.process(input, token, context); + } + if(input.length() != 0) throw new InvalidDateTimeException(DINV02, + concat("Invalid ", context.getType(), " input format")); + + var dateTime = context.validate(); + LogHelper.debug(context); + return dateTime; + } + + public JsonDateTime parse(String input) { + return parse(input, new DateTimeContext(type)); + } + + public JsonDateTime tryParse(String input, Reference error) { + try { + return parse(input); + } catch(InvalidDateTimeException e) { + LogHelper.debug(e); + error.setValue(e.getMessage()); + return null; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/time/SegmentProcessor.java b/src/main/java/com/relogiclabs/jschema/internal/time/SegmentProcessor.java similarity index 72% rename from src/main/java/com/relogiclabs/json/schema/internal/time/SegmentProcessor.java rename to src/main/java/com/relogiclabs/jschema/internal/time/SegmentProcessor.java index 0e93fb1..1516e45 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/time/SegmentProcessor.java +++ b/src/main/java/com/relogiclabs/jschema/internal/time/SegmentProcessor.java @@ -1,43 +1,43 @@ -package com.relogiclabs.json.schema.internal.time; +package com.relogiclabs.jschema.internal.time; -import com.relogiclabs.json.schema.exception.InvalidDateTimeException; +import com.relogiclabs.jschema.exception.InvalidDateTimeException; import org.antlr.v4.runtime.Token; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static com.relogiclabs.json.schema.message.ErrorCode.DDAY01; -import static com.relogiclabs.json.schema.message.ErrorCode.DDAY02; -import static com.relogiclabs.json.schema.message.ErrorCode.DERA01; -import static com.relogiclabs.json.schema.message.ErrorCode.DFRC01; -import static com.relogiclabs.json.schema.message.ErrorCode.DFRC02; -import static com.relogiclabs.json.schema.message.ErrorCode.DFRC03; -import static com.relogiclabs.json.schema.message.ErrorCode.DFRC04; -import static com.relogiclabs.json.schema.message.ErrorCode.DFRC05; -import static com.relogiclabs.json.schema.message.ErrorCode.DFRC06; -import static com.relogiclabs.json.schema.message.ErrorCode.DFRC07; -import static com.relogiclabs.json.schema.message.ErrorCode.DHUR01; -import static com.relogiclabs.json.schema.message.ErrorCode.DHUR02; -import static com.relogiclabs.json.schema.message.ErrorCode.DMIN01; -import static com.relogiclabs.json.schema.message.ErrorCode.DMIN02; -import static com.relogiclabs.json.schema.message.ErrorCode.DMON01; -import static com.relogiclabs.json.schema.message.ErrorCode.DMON02; -import static com.relogiclabs.json.schema.message.ErrorCode.DMON03; -import static com.relogiclabs.json.schema.message.ErrorCode.DMON04; -import static com.relogiclabs.json.schema.message.ErrorCode.DSEC01; -import static com.relogiclabs.json.schema.message.ErrorCode.DSEC02; -import static com.relogiclabs.json.schema.message.ErrorCode.DSYM01; -import static com.relogiclabs.json.schema.message.ErrorCode.DTAP01; -import static com.relogiclabs.json.schema.message.ErrorCode.DTXT01; -import static com.relogiclabs.json.schema.message.ErrorCode.DUTC01; -import static com.relogiclabs.json.schema.message.ErrorCode.DUTC02; -import static com.relogiclabs.json.schema.message.ErrorCode.DUTC03; -import static com.relogiclabs.json.schema.message.ErrorCode.DWKD01; -import static com.relogiclabs.json.schema.message.ErrorCode.DWKD02; -import static com.relogiclabs.json.schema.message.ErrorCode.DWTS01; -import static com.relogiclabs.json.schema.message.ErrorCode.DYAR01; -import static com.relogiclabs.json.schema.message.ErrorCode.DYAR02; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.DDAY01; +import static com.relogiclabs.jschema.message.ErrorCode.DDAY02; +import static com.relogiclabs.jschema.message.ErrorCode.DERA01; +import static com.relogiclabs.jschema.message.ErrorCode.DFRC01; +import static com.relogiclabs.jschema.message.ErrorCode.DFRC02; +import static com.relogiclabs.jschema.message.ErrorCode.DFRC03; +import static com.relogiclabs.jschema.message.ErrorCode.DFRC04; +import static com.relogiclabs.jschema.message.ErrorCode.DFRC05; +import static com.relogiclabs.jschema.message.ErrorCode.DFRC06; +import static com.relogiclabs.jschema.message.ErrorCode.DFRC07; +import static com.relogiclabs.jschema.message.ErrorCode.DHUR01; +import static com.relogiclabs.jschema.message.ErrorCode.DHUR02; +import static com.relogiclabs.jschema.message.ErrorCode.DMIN01; +import static com.relogiclabs.jschema.message.ErrorCode.DMIN02; +import static com.relogiclabs.jschema.message.ErrorCode.DMON01; +import static com.relogiclabs.jschema.message.ErrorCode.DMON02; +import static com.relogiclabs.jschema.message.ErrorCode.DMON03; +import static com.relogiclabs.jschema.message.ErrorCode.DMON04; +import static com.relogiclabs.jschema.message.ErrorCode.DSEC01; +import static com.relogiclabs.jschema.message.ErrorCode.DSEC02; +import static com.relogiclabs.jschema.message.ErrorCode.DSYM01; +import static com.relogiclabs.jschema.message.ErrorCode.DTAP01; +import static com.relogiclabs.jschema.message.ErrorCode.DTXT01; +import static com.relogiclabs.jschema.message.ErrorCode.DUTC01; +import static com.relogiclabs.jschema.message.ErrorCode.DUTC02; +import static com.relogiclabs.jschema.message.ErrorCode.DUTC03; +import static com.relogiclabs.jschema.message.ErrorCode.DWKD01; +import static com.relogiclabs.jschema.message.ErrorCode.DWKD02; +import static com.relogiclabs.jschema.message.ErrorCode.DWTS01; +import static com.relogiclabs.jschema.message.ErrorCode.DYAR01; +import static com.relogiclabs.jschema.message.ErrorCode.DYAR02; import static java.util.regex.Pattern.CASE_INSENSITIVE; import static java.util.regex.Pattern.compile; import static org.apache.commons.lang3.StringUtils.replaceChars; @@ -130,8 +130,8 @@ private static final class TextProcessor extends SegmentProcessor { @Override public String process(String input, Token token, DateTimeContext context) { var text = replaceChars(substring(token.getText(), 1, -1), "''", "'"); - if(!input.startsWith(text)) throw new InvalidDateTimeException(DTXT01, - concat("Invalid ", context.getType(), " text mismatch or input format")); + if(!input.startsWith(text)) throw failOnInvalidDateTime(context, DTXT01, + " text mismatch or input format"); return input.substring(text.length()); } } @@ -139,8 +139,8 @@ public String process(String input, Token token, DateTimeContext context) { private static final class SymbolProcessor extends SegmentProcessor { @Override public String process(String input, Token token, DateTimeContext context) { - if(!input.startsWith(token.getText())) throw new InvalidDateTimeException(DSYM01, - concat("Invalid ", context.getType(), " symbol mismatch or input format")); + if(!input.startsWith(token.getText())) throw failOnInvalidDateTime(context, DSYM01, + " symbol mismatch or input format"); return input.substring(token.getText().length()); } } @@ -148,8 +148,8 @@ public String process(String input, Token token, DateTimeContext context) { private static final class WhitespaceProcessor extends SegmentProcessor { @Override public String process(String input, Token token, DateTimeContext context) { - if(!input.startsWith(token.getText())) throw new InvalidDateTimeException(DWTS01, - concat("Invalid ", context.getType(), " whitespace mismatch or input format")); + if(!input.startsWith(token.getText())) throw failOnInvalidDateTime(context, DWTS01, + " whitespace mismatch or input format"); return input.substring(token.getText().length()); } } @@ -180,8 +180,7 @@ private EraProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " era input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, " era input"); context.setEra(matcher.group(1)); } } @@ -193,8 +192,7 @@ private YearNumberProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " year input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, " year input"); var year = matcher.group(1); context.setYear(Integer.parseInt(year), year.length()); } @@ -207,8 +205,8 @@ private MonthNameProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " month name input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, + " month name input"); context.setMonth(matcher.group(1)); } } @@ -220,8 +218,8 @@ private MonthNumberProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " month number input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, + " month number input"); context.setMonth(Integer.parseInt(matcher.group(1))); } } @@ -233,8 +231,7 @@ private WeekdayProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " weekday input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, " weekday input"); context.setWeekday(matcher.group(1)); } } @@ -246,8 +243,7 @@ private DayNumberProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " day input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, " day input"); context.setDay(Integer.parseInt(matcher.group(1))); } } @@ -259,8 +255,7 @@ private ClockAmPmProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " AM/PM input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, " AM/PM input"); context.setAmPm(matcher.group(1)); } } @@ -272,8 +267,7 @@ private HourNumberProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " hour input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, " hour input"); context.setHour(Integer.parseInt(matcher.group(1))); } } @@ -285,8 +279,7 @@ private MinuteNumberProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " minute input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, " minute input"); context.setMinute(Integer.parseInt(matcher.group(1))); } } @@ -298,8 +291,7 @@ private SecondNumberProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " second input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, " second input"); context.setSecond(Integer.parseInt(matcher.group(1))); } } @@ -311,8 +303,8 @@ private FractionNumberProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " second faction input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, + " second faction input"); context.setFraction(Integer.parseInt(matcher.group(1))); } } @@ -324,8 +316,8 @@ private UtcOffsetHourProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " UTC offset hour input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, + " UTC offset hour input"); context.setUtcOffset("Z".equals(matcher.group()) ? 0 : Integer.parseInt(matcher.group(1)), 0); } @@ -338,11 +330,17 @@ private UtcOffsetTimeProcessor(Pattern regex, String code) { @Override protected void process(Matcher matcher, DateTimeContext context) { - if(!matcher.lookingAt()) throw new InvalidDateTimeException(code, - concat("Invalid ", context.getType(), " UTC offset input")); + if(!matcher.lookingAt()) throw failOnInvalidDateTime(context, code, + " UTC offset input"); if("Z".equals(matcher.group())) context.setUtcOffset(0, 0); else context.setUtcOffset(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2))); } } + + private static InvalidDateTimeException failOnInvalidDateTime(DateTimeContext context, + String code, String message) { + return new InvalidDateTimeException(code, concat("Invalid ", + context.getType(), message)); + } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/tree/EFunction.java b/src/main/java/com/relogiclabs/jschema/internal/tree/EFunction.java new file mode 100644 index 0000000..29561b2 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/tree/EFunction.java @@ -0,0 +1,14 @@ +package com.relogiclabs.jschema.internal.tree; + +import com.relogiclabs.jschema.node.JFunction; +import com.relogiclabs.jschema.type.EValue; + +import java.util.List; + +public interface EFunction { + String getName(); + int getArity(); + Class getTargetType(); + List prebind(List arguments); + Object invoke(JFunction caller, Object[] arguments); +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/tree/FunctionCache.java b/src/main/java/com/relogiclabs/jschema/internal/tree/FunctionCache.java new file mode 100644 index 0000000..b917e35 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/tree/FunctionCache.java @@ -0,0 +1,44 @@ +package com.relogiclabs.jschema.internal.tree; + +import com.relogiclabs.jschema.node.JFunction; +import com.relogiclabs.jschema.node.JNode; +import lombok.Getter; +import lombok.Setter; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import static com.relogiclabs.jschema.internal.util.MiscellaneousHelper.getDerived; + +public class FunctionCache implements Iterable { + public record Entry(EFunction function, Object[] arguments) { + public boolean isTargetMatch(JNode target) { + return function.getTargetType().isInstance(getDerived(target)); + } + + public Object invoke(JFunction caller, JNode target) { + arguments[0] = getDerived(target); + return function.invoke(caller, arguments); + } + } + + @Getter @Setter + private static int sizeLimit = 10; + private final List cache; + + public FunctionCache() { + this.cache = new ArrayList<>(sizeLimit); + } + + public void add(EFunction function, Object[] arguments) { + if(cache.size() > sizeLimit) cache.remove(0); + arguments[0] = null; + cache.add(new Entry(function, arguments)); + } + + @Override + public Iterator iterator() { + return cache.iterator(); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/tree/FunctionKey.java b/src/main/java/com/relogiclabs/jschema/internal/tree/FunctionKey.java similarity index 50% rename from src/main/java/com/relogiclabs/json/schema/internal/tree/FunctionKey.java rename to src/main/java/com/relogiclabs/jschema/internal/tree/FunctionKey.java index 56e40e1..2c2c84f 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/tree/FunctionKey.java +++ b/src/main/java/com/relogiclabs/jschema/internal/tree/FunctionKey.java @@ -1,8 +1,6 @@ -package com.relogiclabs.json.schema.internal.tree; +package com.relogiclabs.jschema.internal.tree; -import com.relogiclabs.json.schema.type.JFunction; - -import java.lang.reflect.Method; +import com.relogiclabs.jschema.node.JFunction; import static org.apache.commons.lang3.StringUtils.removeStart; import static org.apache.commons.lang3.StringUtils.uncapitalize; @@ -10,15 +8,15 @@ public record FunctionKey(String functionName, int parameterCount) { private static final String ESCAPED_PREFIX = "_"; - public FunctionKey(Method method, int parameterCount) { - this(toFunctionName(method), parameterCount); + public FunctionKey(EFunction function) { + this(formatName(function.getName()), function.getArity()); } public FunctionKey(JFunction function) { this(function.getName(), function.getArguments().size() + 1); } - private static String toFunctionName(Method method) { - return "@" + uncapitalize(removeStart(method.getName(), ESCAPED_PREFIX)); + private static String formatName(String name) { + return "@" + uncapitalize(removeStart(name, ESCAPED_PREFIX)); } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/tree/JsonTreeVisitor.java b/src/main/java/com/relogiclabs/jschema/internal/tree/JsonTreeVisitor.java similarity index 60% rename from src/main/java/com/relogiclabs/json/schema/internal/tree/JsonTreeVisitor.java rename to src/main/java/com/relogiclabs/jschema/internal/tree/JsonTreeVisitor.java index 7896c5b..27a8a9f 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/tree/JsonTreeVisitor.java +++ b/src/main/java/com/relogiclabs/jschema/internal/tree/JsonTreeVisitor.java @@ -1,29 +1,29 @@ -package com.relogiclabs.json.schema.internal.tree; - -import com.relogiclabs.json.schema.internal.antlr.JsonParser; -import com.relogiclabs.json.schema.internal.antlr.JsonParserBaseVisitor; -import com.relogiclabs.json.schema.internal.builder.JArrayBuilder; -import com.relogiclabs.json.schema.internal.builder.JBooleanBuilder; -import com.relogiclabs.json.schema.internal.builder.JDoubleBuilder; -import com.relogiclabs.json.schema.internal.builder.JFloatBuilder; -import com.relogiclabs.json.schema.internal.builder.JIntegerBuilder; -import com.relogiclabs.json.schema.internal.builder.JNullBuilder; -import com.relogiclabs.json.schema.internal.builder.JObjectBuilder; -import com.relogiclabs.json.schema.internal.builder.JPropertyBuilder; -import com.relogiclabs.json.schema.internal.builder.JRootBuilder; -import com.relogiclabs.json.schema.internal.builder.JStringBuilder; -import com.relogiclabs.json.schema.tree.Context; -import com.relogiclabs.json.schema.tree.RuntimeContext; -import com.relogiclabs.json.schema.type.JNode; -import com.relogiclabs.json.schema.type.JProperty; +package com.relogiclabs.jschema.internal.tree; + +import com.relogiclabs.jschema.internal.antlr.JsonParser; +import com.relogiclabs.jschema.internal.antlr.JsonParserBaseVisitor; +import com.relogiclabs.jschema.internal.builder.JArrayBuilder; +import com.relogiclabs.jschema.internal.builder.JBooleanBuilder; +import com.relogiclabs.jschema.internal.builder.JDoubleBuilder; +import com.relogiclabs.jschema.internal.builder.JFloatBuilder; +import com.relogiclabs.jschema.internal.builder.JIntegerBuilder; +import com.relogiclabs.jschema.internal.builder.JNullBuilder; +import com.relogiclabs.jschema.internal.builder.JObjectBuilder; +import com.relogiclabs.jschema.internal.builder.JPropertyBuilder; +import com.relogiclabs.jschema.internal.builder.JRootBuilder; +import com.relogiclabs.jschema.internal.builder.JStringBuilder; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JProperty; +import com.relogiclabs.jschema.tree.Context; +import com.relogiclabs.jschema.tree.RuntimeContext; import java.util.HashMap; import java.util.Map; -import static com.relogiclabs.json.schema.internal.tree.TreeHelper.requireUniqueness; -import static com.relogiclabs.json.schema.internal.util.StringHelper.toEncoded; -import static com.relogiclabs.json.schema.internal.util.StringHelper.unquote; -import static com.relogiclabs.json.schema.message.ErrorCode.PROP03; +import static com.relogiclabs.jschema.internal.tree.TreeHelper.requireUniqueness; +import static com.relogiclabs.jschema.internal.util.StringHelper.toEncoded; +import static com.relogiclabs.jschema.internal.util.StringHelper.unquote; +import static com.relogiclabs.jschema.tree.TreeType.JSON_TREE; public final class JsonTreeVisitor extends JsonParserBaseVisitor { private final Map relations; @@ -39,44 +39,36 @@ public JNode visitJson(JsonParser.JsonContext ctx) { return new JRootBuilder() .relations(relations) .context(new Context(ctx, runtime)) - .value(visit(ctx.value())) + .value(visit(ctx.valueNode())) .build(); } @Override - public JNode visitValue(JsonParser.ValueContext ctx) { - if(ctx.primitive() != null) return visit(ctx.primitive()); - if(ctx.array() != null) return visit(ctx.array()); - if(ctx.object() != null) return visit(ctx.object()); - throw new IllegalStateException("Invalid parser state"); - } - - @Override - public JNode visitObject(JsonParser.ObjectContext ctx) { + public JNode visitObjectNode(JsonParser.ObjectNodeContext ctx) { return new JObjectBuilder() .relations(relations) .context(new Context(ctx, runtime)) - .properties(requireUniqueness(ctx.property().stream() - .map(p -> (JProperty) visit(p)).toList(), PROP03)) + .properties(requireUniqueness(ctx.propertyNode().stream() + .map(p -> (JProperty) visit(p)).toList(), JSON_TREE)) .build(); } @Override - public JNode visitProperty(JsonParser.PropertyContext ctx) { + public JNode visitPropertyNode(JsonParser.PropertyNodeContext ctx) { return new JPropertyBuilder() .relations(relations) .context(new Context(ctx, runtime)) .key(unquote(ctx.STRING().getText())) - .value(visit(ctx.value())) + .value(visit(ctx.valueNode())) .build(); } @Override - public JNode visitArray(JsonParser.ArrayContext ctx) { + public JNode visitArrayNode(JsonParser.ArrayNodeContext ctx) { return new JArrayBuilder() .relations(relations) .context(new Context(ctx, runtime)) - .elements(ctx.value().stream().map(this::visit).toList()) + .elements(ctx.valueNode().stream().map(this::visit).toList()) .build(); } diff --git a/src/main/java/com/relogiclabs/jschema/internal/tree/NativeFunction.java b/src/main/java/com/relogiclabs/jschema/internal/tree/NativeFunction.java new file mode 100644 index 0000000..792e542 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/tree/NativeFunction.java @@ -0,0 +1,117 @@ +package com.relogiclabs.jschema.internal.tree; + +import com.relogiclabs.jschema.exception.InvalidFunctionException; +import com.relogiclabs.jschema.exception.TargetInvocationException; +import com.relogiclabs.jschema.function.FunctionProvider; +import com.relogiclabs.jschema.node.JFunction; +import com.relogiclabs.jschema.type.EValue; +import lombok.Getter; + +import java.lang.reflect.Array; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static com.relogiclabs.jschema.internal.util.CollectionHelper.subList; +import static com.relogiclabs.jschema.internal.util.MiscellaneousHelper.getDerived; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC07; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC08; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC09; +import static java.util.stream.Collectors.joining; + +@Getter +public final class NativeFunction implements EFunction { + private final Method method; + private final List parameters; + private final FunctionProvider instance; + + public NativeFunction(Method method, Parameter[] parameters, FunctionProvider instance) { + this.method = method; + this.parameters = List.of(parameters); + this.instance = instance; + } + + @Override + public String getName() { + return method.getName(); + } + + @Override + public int getArity() { + var size = parameters.size(); + return parameters.get(size - 1).isVarArgs() ? -1 : size; + } + + @Override + public Class getTargetType() { + return parameters.get(0).getType(); + } + + @Override + public Object invoke(JFunction caller, Object[] arguments) { + try { + instance.setCaller(caller); + Object result = method.invoke(instance, arguments); + if(result == null) throw new InvalidFunctionException(FUNC09, + concat("Function ", method.getName(), " must not return null")); + return result; + } catch (InvocationTargetException e) { + throw new TargetInvocationException(FUNC07, + "Target invocation exception occurred", e.getCause()); + } catch (IllegalAccessException e) { + throw new TargetInvocationException(FUNC08, + "Illegal access exception occurred", e); + } + } + + @Override + public List prebind(List arguments) { + var size = parameters.size(); + if(parameters.get(size - 1).isVarArgs() && size - 2 > arguments.size()) return null; + var result = new ArrayList<>(size + 1); + for(int i = 1; i < size; i++) { + if(parameters.get(i).isVarArgs()) { + var varArgs = processVarArgs(parameters.get(i), subList(arguments, i - 1)); + if(varArgs == null) return null; + result.add(varArgs); + break; + } + if(!isMatch(arguments.get(i - 1), parameters.get(i))) return null; + result.add(arguments.get(i - 1)); + } + return result; + } + + private static Object processVarArgs(Parameter parameter, List arguments) { + var componentType = parameter.getType().getComponentType(); + if(componentType == null) throw new IllegalStateException("Invalid function parameter"); + var result = Array.newInstance(componentType, arguments.size()); + for(var i = 0; i < arguments.size(); i++) { + var arg = arguments.get(i); + if(!componentType.isInstance(arg)) return null; + Array.set(result, i, arg); + } + return result; + } + + private static boolean isMatch(Object argument, Parameter parameter) { + return parameter.getType().isInstance(getDerived(argument)); + } + + public static String getSignature(Method method) { + String typeName = method.getDeclaringClass().getName(); + String methodName = method.getName(); + String parameters = Arrays.stream(method.getParameters()) + .map(NativeFunction::stringOf).collect(joining(", ")); + String returnType = method.getReturnType().getName(); + return concat(returnType, " ", typeName, ".", methodName, "(", parameters, ")"); + } + + private static String stringOf(Parameter parameter) { + return parameter.getType().getSimpleName() + " " + parameter.getName(); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/tree/PragmaDescriptor.java b/src/main/java/com/relogiclabs/jschema/internal/tree/PragmaDescriptor.java similarity index 89% rename from src/main/java/com/relogiclabs/json/schema/internal/tree/PragmaDescriptor.java rename to src/main/java/com/relogiclabs/jschema/internal/tree/PragmaDescriptor.java index a62b5ea..2f2709e 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/tree/PragmaDescriptor.java +++ b/src/main/java/com/relogiclabs/jschema/internal/tree/PragmaDescriptor.java @@ -1,8 +1,8 @@ -package com.relogiclabs.json.schema.internal.tree; +package com.relogiclabs.jschema.internal.tree; -import com.relogiclabs.json.schema.type.JBoolean; -import com.relogiclabs.json.schema.type.JNumber; -import com.relogiclabs.json.schema.type.JString; +import com.relogiclabs.jschema.node.JBoolean; +import com.relogiclabs.jschema.node.JNumber; +import com.relogiclabs.jschema.node.JString; import lombok.Getter; import java.util.HashMap; diff --git a/src/main/java/com/relogiclabs/jschema/internal/tree/SchemaTreeVisitor.java b/src/main/java/com/relogiclabs/jschema/internal/tree/SchemaTreeVisitor.java new file mode 100644 index 0000000..834c6a8 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/tree/SchemaTreeVisitor.java @@ -0,0 +1,319 @@ +package com.relogiclabs.jschema.internal.tree; + +import com.relogiclabs.jschema.function.CoreFunctions4; +import com.relogiclabs.jschema.internal.antlr.SchemaParser; +import com.relogiclabs.jschema.internal.antlr.SchemaParserBaseVisitor; +import com.relogiclabs.jschema.internal.builder.JAliasBuilder; +import com.relogiclabs.jschema.internal.builder.JArrayBuilder; +import com.relogiclabs.jschema.internal.builder.JBooleanBuilder; +import com.relogiclabs.jschema.internal.builder.JDataTypeBuilder; +import com.relogiclabs.jschema.internal.builder.JDefinitionBuilder; +import com.relogiclabs.jschema.internal.builder.JDoubleBuilder; +import com.relogiclabs.jschema.internal.builder.JFloatBuilder; +import com.relogiclabs.jschema.internal.builder.JFunctionBuilder; +import com.relogiclabs.jschema.internal.builder.JImportBuilder; +import com.relogiclabs.jschema.internal.builder.JIntegerBuilder; +import com.relogiclabs.jschema.internal.builder.JNullBuilder; +import com.relogiclabs.jschema.internal.builder.JObjectBuilder; +import com.relogiclabs.jschema.internal.builder.JPragmaBuilder; +import com.relogiclabs.jschema.internal.builder.JPropertyBuilder; +import com.relogiclabs.jschema.internal.builder.JReceiverBuilder; +import com.relogiclabs.jschema.internal.builder.JRootBuilder; +import com.relogiclabs.jschema.internal.builder.JScriptBuilder; +import com.relogiclabs.jschema.internal.builder.JStringBuilder; +import com.relogiclabs.jschema.internal.builder.JTitleBuilder; +import com.relogiclabs.jschema.internal.builder.JUndefinedBuilder; +import com.relogiclabs.jschema.internal.builder.JValidatorBuilder; +import com.relogiclabs.jschema.internal.builder.JVersionBuilder; +import com.relogiclabs.jschema.internal.engine.Evaluator; +import com.relogiclabs.jschema.internal.engine.ScriptTreeVisitor; +import com.relogiclabs.jschema.node.JAlias; +import com.relogiclabs.jschema.node.JDataType; +import com.relogiclabs.jschema.node.JDefinition; +import com.relogiclabs.jschema.node.JFunction; +import com.relogiclabs.jschema.node.JImport; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JPragma; +import com.relogiclabs.jschema.node.JProperty; +import com.relogiclabs.jschema.node.JReceiver; +import com.relogiclabs.jschema.node.JScript; +import com.relogiclabs.jschema.node.JTitle; +import com.relogiclabs.jschema.node.JValidator; +import com.relogiclabs.jschema.node.JVersion; +import com.relogiclabs.jschema.node.JsonType; +import com.relogiclabs.jschema.tree.Context; +import com.relogiclabs.jschema.tree.RuntimeContext; +import org.antlr.v4.runtime.misc.Interval; +import org.antlr.v4.runtime.tree.ParseTree; +import org.antlr.v4.runtime.tree.ParseTreeProperty; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.relogiclabs.jschema.internal.tree.TreeHelper.requireUniqueness; +import static com.relogiclabs.jschema.internal.util.StringHelper.toEncoded; +import static com.relogiclabs.jschema.internal.util.StringHelper.unquote; +import static com.relogiclabs.jschema.tree.TreeType.SCHEMA_TREE; +import static java.util.stream.Collectors.joining; + +public final class SchemaTreeVisitor extends SchemaParserBaseVisitor { + private final Map relations; + private final RuntimeContext runtime; + private final ParseTreeProperty scripts; + + public SchemaTreeVisitor(ScriptTreeVisitor scriptVisitor) { + this.runtime = scriptVisitor.getRuntime(); + this.scripts = scriptVisitor.getScripts(); + this.relations = new HashMap<>(); + } + + @Override + public JNode visitCompleteSchema(SchemaParser.CompleteSchemaContext ctx) { + return new JRootBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .title((JTitle) visit(ctx.titleNode())) + .version((JVersion) visit(ctx.versionNode())) + .imports(processImports(ctx.importNode())) + .pragmas(ctx.pragmaNode().stream().map(c -> (JPragma) visit(c)).toList()) + .definitions(ctx.defineNode().stream().map(c -> (JDefinition) visit(c)).toList()) + .scripts(ctx.scriptNode().stream().map(s -> (JScript) visit(s)).toList()) + .value(visit(ctx.schemaMain())) + .build(); + } + + @Override + public JNode visitShortSchema(SchemaParser.ShortSchemaContext ctx) { + return new JRootBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .imports(processImports(Collections.emptyList())) + .value(visit(ctx.validatorNode())) + .build(); + } + + private List processImports(List contexts) { + runtime.getFunctions().addClass(CoreFunctions4.class.getName(), null); + return contexts.stream().map(c -> (JImport) visit(c)).toList(); + } + + @Override + public JNode visitTitleNode(SchemaParser.TitleNodeContext ctx) { + return new JTitleBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .title(ctx.STRING().getText()) + .build(); + } + + @Override + public JNode visitVersionNode(SchemaParser.VersionNodeContext ctx) { + return new JVersionBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .version(ctx.STRING().getText()) + .build(); + } + + @Override + public JNode visitImportNode(SchemaParser.ImportNodeContext ctx) { + var importNode = new JImportBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .className(ctx.FULL_IDENTIFIER().stream().map(ParseTree::getText) + .collect(joining(","))) + .build(); + return runtime.getFunctions().addClass(importNode); + } + + @Override + public JNode visitPragmaNode(SchemaParser.PragmaNodeContext ctx) { + var pragma = new JPragmaBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .name(ctx.FULL_IDENTIFIER().getText()) + .value(visit(ctx.primitiveNode())).build(); + return runtime.getPragmas().addPragma(pragma); + } + + @Override + public JNode visitDefineNode(SchemaParser.DefineNodeContext ctx) { + var definition = new JDefinitionBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .alias((JAlias) visit(ctx.aliasNode())) + .validator((JValidator) visit(ctx.validatorMain())) + .build(); + return runtime.addDefinition(definition); + } + + @Override + public JNode visitScriptNode(SchemaParser.ScriptNodeContext ctx) { + var source = ctx.start.getInputStream().getText(new Interval( + ctx.start.getStartIndex(), + ctx.stop.getStopIndex())); + return new JScriptBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .evaluator(scripts.get(ctx)) + .source(source) + .build(); + } + + @Override + public JNode visitAliasNode(SchemaParser.AliasNodeContext ctx) { + return new JAliasBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .name(ctx.ALIAS().getText()) + .build(); + } + + @Override + public JNode visitValidatorMain(SchemaParser.ValidatorMainContext ctx) { + return new JValidatorBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .value(visit(ctx.valueNode())) + .functions(ctx.functionNode().stream().map(c -> (JFunction) visit(c)).toList()) + .dataTypes(ctx.datatypeNode().stream().map(c -> (JDataType) visit(c)).toList()) + .receivers(ctx.receiverNode().stream().map(c -> (JReceiver) visit(c)).toList()) + .optional(ctx.OPTIONAL() != null) + .build(); + } + + @Override + public JNode visitObjectNode(SchemaParser.ObjectNodeContext ctx) { + return new JObjectBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .properties(requireUniqueness(ctx.propertyNode().stream() + .map(c -> (JProperty) visit(c)).toList(), SCHEMA_TREE)) + .build(); + } + + @Override + public JNode visitPropertyNode(SchemaParser.PropertyNodeContext ctx) { + return new JPropertyBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .key(unquote(ctx.STRING().getText())) + .value(visit(ctx.validatorNode())) + .build(); + } + + @Override + public JNode visitArrayNode(SchemaParser.ArrayNodeContext ctx) { + return new JArrayBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .elements(ctx.validatorNode().stream().map(this::visit).toList()) + .build(); + } + + @Override + public JNode visitDatatypeNode(SchemaParser.DatatypeNodeContext ctx) { + return new JDataTypeBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .jsonType(JsonType.from(ctx.DATATYPE())) + .alias((JAlias) visit(ctx.aliasNode())) + .nested(ctx.STAR() != null) + .build(); + } + + @Override + public JNode visitFunctionNode(SchemaParser.FunctionNodeContext ctx) { + return new JFunctionBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .name(ctx.FUNCTION().getText()) + .arguments(ctx.argumentNode().stream().map(this::visit).toList()) + .nested(ctx.STAR() != null) + .build(); + } + + @Override + public JNode visitReceiverNode(SchemaParser.ReceiverNodeContext ctx) { + return new JReceiverBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .name(ctx.RECEIVER().getText()).build(); + } + + @Override + public JNode visitPrimitiveTrue(SchemaParser.PrimitiveTrueContext ctx) { + return new JBooleanBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .value(true).build(); + } + + @Override + public JNode visitPrimitiveFalse(SchemaParser.PrimitiveFalseContext ctx) { + return new JBooleanBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .value(false).build(); + } + + @Override + public JNode visitPrimitiveString(SchemaParser.PrimitiveStringContext ctx) { + return new JStringBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .value(toEncoded(ctx.STRING().getText())) + .build(); + } + + @Override + public JNode visitPrimitiveInteger(SchemaParser.PrimitiveIntegerContext ctx) { + return new JIntegerBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .value(Long.valueOf(ctx.INTEGER().getText())) + .build(); + } + + @Override + public JNode visitPrimitiveFloat(SchemaParser.PrimitiveFloatContext ctx) { + return new JFloatBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .value(Double.valueOf(ctx.FLOAT().getText())) + .build(); + } + + @Override + public JNode visitPrimitiveDouble(SchemaParser.PrimitiveDoubleContext ctx) { + return new JDoubleBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .value(Double.valueOf(ctx.DOUBLE().getText())) + .build(); + } + + @Override + public JNode visitPrimitiveNull(SchemaParser.PrimitiveNullContext ctx) { + return new JNullBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .build(); + } + + @Override + public JNode visitPrimitiveUndefined(SchemaParser.PrimitiveUndefinedContext ctx) { + return new JUndefinedBuilder() + .relations(relations) + .context(new Context(ctx, runtime)) + .build(); + } + + @Override + public JNode visit(ParseTree tree) { + if(tree == null) return null; + return super.visit(tree); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptFunction.java b/src/main/java/com/relogiclabs/jschema/internal/tree/ScriptFunction.java similarity index 95% rename from src/main/java/com/relogiclabs/jschema/internal/engine/ScriptFunction.java rename to src/main/java/com/relogiclabs/jschema/internal/tree/ScriptFunction.java index a995329..4ef3cd7 100644 --- a/src/main/java/com/relogiclabs/jschema/internal/engine/ScriptFunction.java +++ b/src/main/java/com/relogiclabs/jschema/internal/tree/ScriptFunction.java @@ -1,13 +1,13 @@ -package com.relogiclabs.jschema.internal.engine; +package com.relogiclabs.jschema.internal.tree; import com.relogiclabs.jschema.exception.InvalidFunctionException; import com.relogiclabs.jschema.exception.JsonSchemaException; import com.relogiclabs.jschema.exception.ScriptCommonException; import com.relogiclabs.jschema.exception.ScriptInitiatedException; import com.relogiclabs.jschema.function.FutureFunction; +import com.relogiclabs.jschema.internal.engine.ScopeContext; import com.relogiclabs.jschema.internal.script.GArray; import com.relogiclabs.jschema.internal.script.GFunction; -import com.relogiclabs.jschema.internal.tree.EFunction; import com.relogiclabs.jschema.node.JFunction; import com.relogiclabs.jschema.node.JNode; import com.relogiclabs.jschema.type.EBoolean; @@ -31,6 +31,16 @@ public final class ScriptFunction implements EFunction { private final String name; private final GFunction function; + @Override + public int getArity() { + return function.isVariadic() ? -1 : function.getParameters().length + 1; + } + + @Override + public Class getTargetType() { + return JNode.class; + } + @Override public Object invoke(JFunction caller, Object[] arguments) { var parameters = function.getParameters(); @@ -64,21 +74,11 @@ public List prebind(List arguments) { var parameters = function.getParameters(); var minArgSize = function.isVariadic() ? parameters.length - 1 : parameters.length; if(arguments.size() < minArgSize) return null; - var result = new ArrayList<>(parameters.length); + var result = new ArrayList<>(parameters.length + 1); for(int i = 0; i < parameters.length; i++) { if(parameters[i].isVariadic()) result.add(new GArray(subList(arguments, i))); else result.add(arguments.get(i)); } return result; } - - @Override - public Class getTargetType() { - return JNode.class; - } - - @Override - public int getArity() { - return function.isVariadic() ? -1 : function.getParameters().length + 1; - } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/tree/TreeHelper.java b/src/main/java/com/relogiclabs/jschema/internal/tree/TreeHelper.java new file mode 100644 index 0000000..ad5cc4d --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/tree/TreeHelper.java @@ -0,0 +1,38 @@ +package com.relogiclabs.jschema.internal.tree; + +import com.relogiclabs.jschema.exception.DuplicatePropertyKeyException; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.node.JProperty; +import com.relogiclabs.jschema.tree.TreeType; + +import java.util.List; +import java.util.function.Function; + +import static com.relogiclabs.jschema.internal.util.StreamHelper.halt; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.PROP03; +import static com.relogiclabs.jschema.message.ErrorCode.PROP04; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForJson; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; +import static com.relogiclabs.jschema.tree.TreeType.JSON_TREE; +import static com.relogiclabs.jschema.tree.TreeType.SCHEMA_TREE; +import static java.util.stream.Collectors.toMap; + +public final class TreeHelper { + public static List requireUniqueness(List list, TreeType treeType) { + list.stream().collect(toMap(JProperty::getKey, Function.identity(), + (p1, p2) -> halt(new DuplicatePropertyKeyException(format(treeType, p2))) + )); + return list; + } + + private static ErrorDetail format(TreeType type, JProperty property) { + if(type == JSON_TREE) return formatForJson(PROP03, getMessage(property), property); + if(type == SCHEMA_TREE) return formatForSchema(PROP04, getMessage(property), property); + throw new IllegalStateException("Invalid parser state"); + } + + private static String getMessage(JProperty property) { + return concat("Multiple key with name '", property.getKey(), "' found"); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/util/CollectionHelper.java b/src/main/java/com/relogiclabs/jschema/internal/util/CollectionHelper.java similarity index 83% rename from src/main/java/com/relogiclabs/json/schema/internal/util/CollectionHelper.java rename to src/main/java/com/relogiclabs/jschema/internal/util/CollectionHelper.java index dd3d8ee..572ecf4 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/util/CollectionHelper.java +++ b/src/main/java/com/relogiclabs/jschema/internal/util/CollectionHelper.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.internal.util; +package com.relogiclabs.jschema.internal.util; -import com.relogiclabs.json.schema.collection.IndexMap; -import com.relogiclabs.json.schema.type.JNode; -import com.relogiclabs.json.schema.type.JProperty; -import com.relogiclabs.json.schema.type.JString; +import com.relogiclabs.jschema.collection.IndexMap; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JProperty; +import com.relogiclabs.jschema.node.JString; import java.util.ArrayList; import java.util.Arrays; @@ -57,4 +57,8 @@ public static void addToList(Collection source, Collection.. public static T tryGetLast(List list) { return list.isEmpty() ? null : list.get(list.size() - 1); } + + public static List subList(List list, int fromIndex) { + return list.subList(fromIndex, list.size()); + } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/util/LexerErrorListener.java b/src/main/java/com/relogiclabs/jschema/internal/util/LexerErrorListener.java similarity index 52% rename from src/main/java/com/relogiclabs/json/schema/internal/util/LexerErrorListener.java rename to src/main/java/com/relogiclabs/jschema/internal/util/LexerErrorListener.java index 47b5bc1..f6fa55e 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/util/LexerErrorListener.java +++ b/src/main/java/com/relogiclabs/jschema/internal/util/LexerErrorListener.java @@ -1,17 +1,17 @@ -package com.relogiclabs.json.schema.internal.util; +package com.relogiclabs.jschema.internal.util; -import com.relogiclabs.json.schema.exception.CommonException; -import com.relogiclabs.json.schema.exception.DateTimeLexerException; -import com.relogiclabs.json.schema.exception.JsonLexerException; -import com.relogiclabs.json.schema.exception.SchemaLexerException; +import com.relogiclabs.jschema.exception.CommonException; +import com.relogiclabs.jschema.exception.DateTimeLexerException; +import com.relogiclabs.jschema.exception.JsonLexerException; +import com.relogiclabs.jschema.exception.SchemaLexerException; import org.antlr.v4.runtime.BaseErrorListener; import org.antlr.v4.runtime.Lexer; import org.antlr.v4.runtime.RecognitionException; import org.antlr.v4.runtime.Recognizer; -import static com.relogiclabs.json.schema.message.ErrorCode.DLEX01; -import static com.relogiclabs.json.schema.message.ErrorCode.JLEX01; -import static com.relogiclabs.json.schema.message.ErrorCode.SLEX01; +import static com.relogiclabs.jschema.message.ErrorCode.DLEX01; +import static com.relogiclabs.jschema.message.ErrorCode.JLEX01; +import static com.relogiclabs.jschema.message.ErrorCode.SLEX01; public abstract class LexerErrorListener extends BaseErrorListener { @@ -19,39 +19,39 @@ public abstract class LexerErrorListener extends BaseErrorListener { public static final LexerErrorListener JSON = new JsonErrorListener(); public static final LexerErrorListener DATE_TIME = new DateTimeErrorListener(); - protected abstract CommonException createException(String message, Throwable cause); + protected abstract CommonException failOnSyntaxError(String message, Throwable cause); protected abstract String getMessageFormat(); private static final class SchemaErrorListener extends LexerErrorListener { @Override - protected CommonException createException(String message, Throwable cause) { + protected CommonException failOnSyntaxError(String message, Throwable cause) { return new SchemaLexerException(SLEX01, message, cause); } @Override protected String getMessageFormat() { - return "Schema (Line %d:%d) [" + SLEX01 + "]: %s (error on '%s')"; + return "Schema (Line %d:%d) [" + SLEX01 + "]: %s (Line: %s)"; } } private static final class JsonErrorListener extends LexerErrorListener { @Override - protected CommonException createException(String message, Throwable cause) { + protected CommonException failOnSyntaxError(String message, Throwable cause) { return new JsonLexerException(JLEX01, message, cause); } @Override protected String getMessageFormat() { - return "Json (Line %d:%d) [" + JLEX01 + "]: %s (error on '%s')"; + return "Json (Line %d:%d) [" + JLEX01 + "]: %s (Line: %s)"; } } private static final class DateTimeErrorListener extends LexerErrorListener { @Override - protected CommonException createException(String message, Throwable cause) { + protected CommonException failOnSyntaxError(String message, Throwable cause) { return new DateTimeLexerException(DLEX01, message, cause); } @@ -65,9 +65,13 @@ protected String getMessageFormat() { public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { var lexer = (Lexer) recognizer; - var message = this == DATE_TIME ? - getMessageFormat().formatted(msg, lexer.getText()) : - getMessageFormat().formatted(line, charPositionInLine, msg, lexer.getText()); - throw createException(message, e); + if(this == DATE_TIME) { + throw failOnSyntaxError(getMessageFormat().formatted(msg, lexer.getText()), e); + } else { + var errorLine = new StringBuilder(recognizer.getInputStream().toString() + .split("\\r?\\n")[line - 1]).insert(charPositionInLine, "<|>").toString().trim(); + throw failOnSyntaxError(getMessageFormat().formatted(line, charPositionInLine, + msg, errorLine), e); + } } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/util/LogHelper.java b/src/main/java/com/relogiclabs/jschema/internal/util/LogHelper.java new file mode 100644 index 0000000..0d85d0b --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/util/LogHelper.java @@ -0,0 +1,67 @@ +package com.relogiclabs.jschema.internal.util; + +import com.relogiclabs.jschema.exception.CommonException; +import com.relogiclabs.jschema.exception.ScriptRuntimeException; +import com.relogiclabs.jschema.internal.time.DateTimeContext; +import com.relogiclabs.jschema.tree.DataTree; +import org.antlr.v4.runtime.Parser; +import org.antlr.v4.runtime.Recognizer; +import org.antlr.v4.runtime.Token; + +import java.util.Collections; +import java.util.List; + +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.TRYS01; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; + +// Logging library may require +// Kept it lightweight for now +public final class LogHelper { + public static final int ERROR = 3; + public static final int INFO = 2; + public static final int DEBUG = 1; + + public static int level = ERROR; + + public static void debug(DataTree expected, DataTree actual) { + if(level > DEBUG) return; + System.out.println(concat("[DEBUG] Expected ", expected.getType(), + " tree interpretation:")); + System.out.println(expected.getRoot()); + System.out.println("---"); + System.out.println(concat("[DEBUG] Actual ", actual.getType(), + " tree interpretation:")); + System.out.println(actual.getRoot()); + System.out.println("---"); + } + + public static void debug(Recognizer recognizer) { + if(level > DEBUG) return; + List stack = ((Parser) recognizer).getRuleInvocationStack(); + Collections.reverse(stack); + System.err.println("[DEBUG] Rule stack: " + String.join(" > ", stack)); + } + + public static void debug(DateTimeContext context) { + if(level > DEBUG) return; + System.out.println("[DEBUG] Date and time interpretation: " + context); + } + + public static void debug(Exception e) { + if(level > DEBUG) return; + System.out.print("[DEBUG] Print of exception: "); + e.printStackTrace(System.out); + } + + public static void log(Exception exception, Token token) { + if(level > INFO) return; + System.out.println("[INFO] [TRYOF ERROR]: " + exception.getMessage()); + if(level > DEBUG) return; + Exception ex = exception instanceof CommonException ? exception + : new ScriptRuntimeException(formatForSchema( + TRYS01, exception.getMessage(), token)); + System.out.print("[DEBUG] [TRYOF ERROR]: "); + ex.printStackTrace(System.out); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/util/MiscellaneousHelper.java b/src/main/java/com/relogiclabs/jschema/internal/util/MiscellaneousHelper.java new file mode 100644 index 0000000..29e1529 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/util/MiscellaneousHelper.java @@ -0,0 +1,19 @@ +package com.relogiclabs.jschema.internal.util; + +import com.relogiclabs.jschema.node.Derivable; + +public final class MiscellaneousHelper { + public static T nonNullFrom(T value, T defaultValue) { + return value != null ? value : defaultValue; + } + + public static Object getDerived(Object target) { + if(target instanceof Derivable derivable) + return nonNullFrom(derivable.getDerived(), target); + return target; + } + + public static boolean hasFlag(int flagSet, int flag) { + return (flagSet & flag) == flag; + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/internal/util/ParserErrorListener.java b/src/main/java/com/relogiclabs/jschema/internal/util/ParserErrorListener.java new file mode 100644 index 0000000..0627153 --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/internal/util/ParserErrorListener.java @@ -0,0 +1,55 @@ +package com.relogiclabs.jschema.internal.util; + +import com.relogiclabs.jschema.exception.CommonException; +import com.relogiclabs.jschema.exception.JsonParserException; +import com.relogiclabs.jschema.exception.SchemaParserException; +import org.antlr.v4.runtime.BaseErrorListener; +import org.antlr.v4.runtime.CommonTokenStream; +import org.antlr.v4.runtime.RecognitionException; +import org.antlr.v4.runtime.Recognizer; + +import static com.relogiclabs.jschema.message.ErrorCode.JPRS01; +import static com.relogiclabs.jschema.message.ErrorCode.SPRS01; + +public abstract class ParserErrorListener extends BaseErrorListener { + public static final ParserErrorListener SCHEMA = new SchemaErrorListener(); + public static final ParserErrorListener JSON = new JsonErrorListener(); + + protected abstract CommonException failOnSyntaxError(String message, Throwable cause); + protected abstract String getMessageFormat(); + + private static final class SchemaErrorListener extends ParserErrorListener { + @Override + protected CommonException failOnSyntaxError(String message, Throwable cause) { + return new SchemaParserException(SPRS01, message, cause); + } + + @Override + protected String getMessageFormat() { + return "Schema (Line %d:%d) [" + SPRS01 + "]: %s (Line: %s)"; + } + } + + private static final class JsonErrorListener extends ParserErrorListener { + @Override + protected CommonException failOnSyntaxError(String message, Throwable cause) { + return new JsonParserException(JPRS01, message, cause); + } + + @Override + protected String getMessageFormat() { + return "Json (Line %d:%d) [" + JPRS01 + "]: %s (Line: %s)"; + } + } + + @Override + public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, + int charPositionInLine, String msg, RecognitionException e) { + LogHelper.debug(recognizer); + var errorLine = new StringBuilder(((CommonTokenStream) recognizer.getInputStream()) + .getTokenSource().getInputStream().toString().split("\\r?\\n")[line - 1]) + .insert(charPositionInLine, "<|>").toString().trim(); + throw failOnSyntaxError(getMessageFormat().formatted(line, charPositionInLine, + msg, errorLine), e); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/util/StreamHelper.java b/src/main/java/com/relogiclabs/jschema/internal/util/StreamHelper.java similarity index 93% rename from src/main/java/com/relogiclabs/json/schema/internal/util/StreamHelper.java rename to src/main/java/com/relogiclabs/jschema/internal/util/StreamHelper.java index f6398e3..cb1c426 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/util/StreamHelper.java +++ b/src/main/java/com/relogiclabs/jschema/internal/util/StreamHelper.java @@ -1,4 +1,4 @@ -package com.relogiclabs.json.schema.internal.util; +package com.relogiclabs.jschema.internal.util; import java.util.stream.Stream; diff --git a/src/main/java/com/relogiclabs/json/schema/internal/util/StringHelper.java b/src/main/java/com/relogiclabs/jschema/internal/util/StringHelper.java similarity index 75% rename from src/main/java/com/relogiclabs/json/schema/internal/util/StringHelper.java rename to src/main/java/com/relogiclabs/jschema/internal/util/StringHelper.java index ca4d90e..39a0994 100644 --- a/src/main/java/com/relogiclabs/json/schema/internal/util/StringHelper.java +++ b/src/main/java/com/relogiclabs/jschema/internal/util/StringHelper.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.internal.util; +package com.relogiclabs.jschema.internal.util; -import com.relogiclabs.json.schema.type.JNode; import org.apache.commons.lang3.StringUtils; import java.util.Collection; +import java.util.stream.Stream; import static java.util.stream.Collectors.joining; @@ -12,15 +12,15 @@ private StringHelper() { throw new UnsupportedOperationException(); } - public static String toEncoded(String target) + public static String toEncoded(String value) { var builder = new StringBuilder(); - target = unquote(target); + value = unquote(value); - for(int i = 0; i < target.length(); i++) { - char current = target.charAt(i); + for(int i = 0; i < value.length(); i++) { + char current = value.charAt(i); if(current == '\\') { - char next = target.charAt(i + 1); + char next = value.charAt(i + 1); switch(next) { case '"': builder.append('"'); i++; break; case '\\': builder.append('\\'); i++; break; @@ -31,7 +31,7 @@ public static String toEncoded(String target) case 'r': builder.append('\r'); i++; break; case 't': builder.append('\t'); i++; break; case 'u': builder.append((char) (int) Integer - .valueOf(target.substring(i + 2, i + 6), 16)); + .valueOf(value.substring(i + 2, i + 6), 16)); i += 5; break; } } else builder.append(current); @@ -49,24 +49,30 @@ public static String unquote(String target) { return target; } - public static String join(Collection list, String delimiter, + public static String join(Collection list, String delimiter, String prefix, String suffix) { - String result = list.stream().map(JNode::toString).collect(joining(delimiter)); + var result = list.stream().map(Object::toString).collect(joining(delimiter)); if(!result.isEmpty()) return prefix + result + suffix; return result; } - public static String joinWith(Collection list, String delimiter, - String prefix, String suffix) { - String result = list.stream().map(JNode::toString).collect(joining(delimiter)); + public static String joinWith(Collection list, String delimiter, + String prefix, String suffix) { + var result = list.stream().map(Object::toString).collect(joining(delimiter)); + return prefix + result + suffix; + } + + public static String joinWith(Stream stream, String delimiter, + String prefix, String suffix) { + var result = stream.map(Object::toString).collect(joining(delimiter)); return prefix + result + suffix; } - public static String join(Collection list, String delimiter, String prefix) { + public static String join(Collection list, String delimiter, String prefix) { return join(list, delimiter, prefix, ""); } - public static String join(Collection list, String delimiter) { + public static String join(Collection list, String delimiter) { return join(list, delimiter, "", ""); } diff --git a/src/main/java/com/relogiclabs/json/schema/message/ActualDetail.java b/src/main/java/com/relogiclabs/jschema/message/ActualDetail.java similarity index 77% rename from src/main/java/com/relogiclabs/json/schema/message/ActualDetail.java rename to src/main/java/com/relogiclabs/jschema/message/ActualDetail.java index fe411c5..3bdf761 100644 --- a/src/main/java/com/relogiclabs/json/schema/message/ActualDetail.java +++ b/src/main/java/com/relogiclabs/jschema/message/ActualDetail.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.message; +package com.relogiclabs.jschema.message; -import com.relogiclabs.json.schema.tree.Context; -import com.relogiclabs.json.schema.type.JNode; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.tree.Context; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; public final class ActualDetail extends ContextDetail { public ActualDetail(Context context, String message) { diff --git a/src/main/java/com/relogiclabs/json/schema/message/ContextDetail.java b/src/main/java/com/relogiclabs/jschema/message/ContextDetail.java similarity index 67% rename from src/main/java/com/relogiclabs/json/schema/message/ContextDetail.java rename to src/main/java/com/relogiclabs/jschema/message/ContextDetail.java index 2411dc3..3160885 100644 --- a/src/main/java/com/relogiclabs/json/schema/message/ContextDetail.java +++ b/src/main/java/com/relogiclabs/jschema/message/ContextDetail.java @@ -1,8 +1,8 @@ -package com.relogiclabs.json.schema.message; +package com.relogiclabs.jschema.message; -import com.relogiclabs.json.schema.tree.Context; -import com.relogiclabs.json.schema.tree.Location; -import com.relogiclabs.json.schema.type.JNode; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.tree.Context; +import com.relogiclabs.jschema.tree.Location; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/relogiclabs/json/schema/message/ErrorCode.java b/src/main/java/com/relogiclabs/jschema/message/ErrorCode.java similarity index 54% rename from src/main/java/com/relogiclabs/json/schema/message/ErrorCode.java rename to src/main/java/com/relogiclabs/jschema/message/ErrorCode.java index 8f678cb..12b0cbd 100644 --- a/src/main/java/com/relogiclabs/json/schema/message/ErrorCode.java +++ b/src/main/java/com/relogiclabs/jschema/message/ErrorCode.java @@ -1,6 +1,11 @@ -package com.relogiclabs.json.schema.message; +package com.relogiclabs.jschema.message; public interface ErrorCode { + String ACTL01 = "ACTL01"; + String ACTL02 = "ACTL02"; + String ACTL03 = "ACTL03"; + String ADDT01 = "ADDI01"; + String ADDT02 = "ADDT02"; String AFTR01 = "AFTR01"; String AFTR02 = "AFTR02"; String ALEN01 = "ALEN01"; @@ -8,11 +13,19 @@ public interface ErrorCode { String ALEN03 = "ALEN03"; String ALEN04 = "ALEN04"; String ALEN05 = "ALEN05"; + String ANDL01 = "ANDL01"; + String ARRL01 = "ARRL01"; String ARRY01 = "ARRY01"; String ARRY02 = "ARRY02"; + String ASIN01 = "ASIN01"; + String ASIN02 = "ASIN02"; String BFOR01 = "BFOR01"; String BFOR02 = "BFOR02"; + String BLOK01 = "BLOK01"; String BOOL01 = "BOOL01"; + String CALR01 = "CALR01"; + String CALR02 = "CALR02"; + String CEIL01 = "CEIL01"; String CLAS01 = "CLAS01"; String CLAS02 = "CLAS02"; String CLAS03 = "CLAS03"; @@ -25,6 +38,12 @@ public interface ErrorCode { String DDAY02 = "DDAY02"; String DDAY03 = "DDAY03"; String DDAY04 = "DDAY04"; + String DECR01 = "DECR01"; + String DECR02 = "DECR02"; + String DECR03 = "DECR03"; + String DECR04 = "DECR04"; + String DECR05 = "DECR05"; + String DECR06 = "DECR06"; String DEFI01 = "DEFI01"; String DEFI02 = "DEFI02"; String DEFI03 = "DEFI03"; @@ -46,6 +65,8 @@ public interface ErrorCode { String DHUR06 = "DHUR06"; String DINV01 = "DINV01"; String DINV02 = "DINV02"; + String DIVD01 = "DIVD01"; + String DIVD02 = "DIVD02"; String DLEX01 = "DLEX01"; String DMIN01 = "DMIN01"; String DMIN02 = "DMIN02"; @@ -96,7 +117,35 @@ public interface ErrorCode { String ENDE02 = "ENDE02"; String ENUM01 = "ENUM01"; String ENUM02 = "ENUM02"; + String EQUL01 = "EQUL01"; + String EXPC01 = "EXPC01"; + String EXPC02 = "EXPC02"; + String EXPC03 = "EXPC03"; + String EXPR01 = "EXPR01"; + String EXPR02 = "EXPR02"; + String FAIL01 = "FAIL01"; + String FAIL02 = "FAIL02"; + String FAIL03 = "FAIL03"; + String FAIL04 = "FAIL04"; + String FAIL05 = "FAIL05"; + String FAIL06 = "FAIL06"; + String FAIL07 = "FAIL07"; + String FAIL08 = "FAIL08"; + String FAIL09 = "FAIL09"; + String FAIL10 = "FAIL10"; + String FAIL11 = "FAIL11"; + String FAIL12 = "FAIL12"; + String FILL01 = "FILL01"; + String FIND01 = "FIND01"; + String FIND02 = "FIND02"; + String FIND03 = "FIND03"; + String FIND04 = "FIND04"; + String FIND05 = "FIND05"; + String FIND06 = "FIND06"; + String FLOR01 = "FLOR01"; String FLOT01 = "FLOT01"; + String FORS01 = "FORS01"; + String FREC01 = "FREC01"; String FUNC01 = "FUNC01"; String FUNC02 = "FUNC02"; String FUNC03 = "FUNC03"; @@ -105,29 +154,69 @@ public interface ErrorCode { String FUNC06 = "FUNC06"; String FUNC07 = "FUNC07"; String FUNC08 = "FUNC08"; + String FUNC09 = "FUNC09"; + String FUNC10 = "FUNC10"; + String FUNS01 = "FUNS01"; + String FUNS02 = "FUNS02"; + String FUNS03 = "FUNS03"; + String FUNS04 = "FUNS04"; + String FUNS05 = "FUNS05"; + String FUNS06 = "FUNS06"; + String FUNS07 = "FUNS07"; + String IFST01 = "IFST01"; + String IFST02 = "IFST02"; + String INCR01 = "INCR01"; + String INCR02 = "INCR02"; + String INCR03 = "INCR03"; + String INCR04 = "INCR04"; + String INCR05 = "INCR05"; + String INCR06 = "INCR06"; + String INDX01 = "INDX01"; + String INDX02 = "INDX02"; + String INDX03 = "INDX03"; + String INDX04 = "INDX04"; + String INDX05 = "INDX05"; + String INDX06 = "INDX06"; + String INDX07 = "INDX07"; + String INDX08 = "INDX08"; String INTE01 = "INTE01"; + String INVK01 = "INVK01"; + String ITER01 = "ITER01"; String JLEX01 = "JLEX01"; String JPRS01 = "JPRS01"; String KEYS01 = "KEYS01"; + String LOGA01 = "LOGA01"; String MAXI01 = "MAXI01"; String MAXI02 = "MAXI02"; String MAXI03 = "MAXI03"; String MINI01 = "MINI01"; String MINI02 = "MINI02"; String MINI03 = "MINI03"; + String MODU01 = "MODU01"; + String MODU02 = "MODU02"; + String MULT01 = "MULT01"; + String MULT02 = "MULT02"; String NEGI01 = "NEGI01"; String NEGI02 = "NEGI02"; + String NEGT01 = "NEGT01"; + String NEGT02 = "NEGT02"; String NEMT01 = "NEMT01"; String NEMT02 = "NEMT02"; String NEMT03 = "NEMT03"; + String NEQL01 = "NEQL01"; + String NOTL01 = "LNOT01"; + String OBJL01 = "OBJL01"; String OLEN01 = "OLEN01"; String OLEN02 = "OLEN02"; String OLEN03 = "OLEN03"; String OLEN04 = "OLEN04"; String OLEN05 = "OLEN05"; + String ORLG01 = "ORLG01"; String PHON01 = "PHON01"; String POSI01 = "POSI01"; String POSI02 = "POSI02"; + String POWR01 = "POWR01"; + String POWR02 = "POWR02"; String PRAG01 = "PRAG01"; String PRAG02 = "PRAG02"; String PRAG03 = "PRAG03"; @@ -138,6 +227,9 @@ public interface ErrorCode { String PROP05 = "PROP05"; String PROP06 = "PROP06"; String PROP07 = "PROP07"; + String PRPS01 = "PRPS01"; + String PRPS02 = "PRPS02"; + String PRPS03 = "PRPS03"; String RANG01 = "RANG01"; String RANG02 = "RANG02"; String RANG03 = "RANG03"; @@ -145,8 +237,32 @@ public interface ErrorCode { String RECV01 = "RECV01"; String RECV02 = "RECV02"; String RECV03 = "RECV03"; - String RECV04 = "RECV04"; String REGX01 = "REGX01"; + String RELA01 = "RELA01"; + String RELA02 = "RELA02"; + String RELA03 = "RELA03"; + String RELA04 = "RELA04"; + String RELA05 = "RELA05"; + String RELA06 = "RELA06"; + String RELA07 = "RELA07"; + String RELA08 = "RELA08"; + String RETN01 = "RETN01"; + String RETN02 = "RETN02"; + String RETN03 = "RETN03"; + String RNGS01 = "RNGS01"; + String RNGS02 = "RNGS02"; + String RNGS03 = "RNGS03"; + String RNGS04 = "RNGS04"; + String RNGS05 = "RNGS05"; + String RNGS06 = "RNGS06"; + String RNGS07 = "RNGS07"; + String RNGS08 = "RNGS08"; + String RNGS09 = "RNGS09"; + String RNGS10 = "RNGS10"; + String RNGS11 = "RNGS11"; + String RNGS12 = "RNGS12"; + String RNGS13 = "RNGS13"; + String SIZE01 = "SIZE01"; String SLEN01 = "SLEN01"; String SLEN02 = "SLEN02"; String SLEN03 = "SLEN03"; @@ -154,13 +270,28 @@ public interface ErrorCode { String SLEN05 = "SLEN05"; String SLEX01 = "SLEX01"; String SPRS01 = "SPRS01"; + String SRPT01 = "SRPT01"; + String SRPT02 = "SRPT02"; String STRN01 = "STRN01"; String STRT01 = "STRT01"; String STRT02 = "STRT02"; + String SUBT01 = "SUBT01"; + String SUBT02 = "SUBT02"; + String THRO01 = "THRO01"; + String THRO02 = "THRO02"; + String TRGT01 = "TRGT01"; + String TRGT02 = "TRGT02"; + String TRYS01 = "TRYS01"; String URLA01 = "URLA01"; String URLA02 = "URLA02"; String URLA03 = "URLA03"; String URLA04 = "URLA04"; String VALD01 = "VALD01"; String VALU01 = "VALU01"; + String VARD01 = "VARD01"; + String VARD02 = "VARD02"; + String VARD03 = "VARD03"; + String VARD04 = "VARD04"; + String VRIN01 = "VRIN01"; + String WHIL01 = "WHIL01"; } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/message/ErrorDetail.java b/src/main/java/com/relogiclabs/jschema/message/ErrorDetail.java similarity index 87% rename from src/main/java/com/relogiclabs/json/schema/message/ErrorDetail.java rename to src/main/java/com/relogiclabs/jschema/message/ErrorDetail.java index 7139092..c4f8154 100644 --- a/src/main/java/com/relogiclabs/json/schema/message/ErrorDetail.java +++ b/src/main/java/com/relogiclabs/jschema/message/ErrorDetail.java @@ -1,8 +1,8 @@ -package com.relogiclabs.json.schema.message; +package com.relogiclabs.jschema.message; import lombok.Getter; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; import static org.apache.commons.lang3.StringUtils.capitalize; @Getter diff --git a/src/main/java/com/relogiclabs/json/schema/message/ExpectedDetail.java b/src/main/java/com/relogiclabs/jschema/message/ExpectedDetail.java similarity index 77% rename from src/main/java/com/relogiclabs/json/schema/message/ExpectedDetail.java rename to src/main/java/com/relogiclabs/jschema/message/ExpectedDetail.java index 1fa5c8a..a6a7faa 100644 --- a/src/main/java/com/relogiclabs/json/schema/message/ExpectedDetail.java +++ b/src/main/java/com/relogiclabs/jschema/message/ExpectedDetail.java @@ -1,9 +1,9 @@ -package com.relogiclabs.json.schema.message; +package com.relogiclabs.jschema.message; -import com.relogiclabs.json.schema.tree.Context; -import com.relogiclabs.json.schema.type.JNode; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.tree.Context; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; public final class ExpectedDetail extends ContextDetail { public ExpectedDetail(Context context, String message) { diff --git a/src/main/java/com/relogiclabs/json/schema/message/MessageFormatter.java b/src/main/java/com/relogiclabs/jschema/message/MessageFormatter.java similarity index 71% rename from src/main/java/com/relogiclabs/json/schema/message/MessageFormatter.java rename to src/main/java/com/relogiclabs/jschema/message/MessageFormatter.java index b20e094..72014ed 100644 --- a/src/main/java/com/relogiclabs/json/schema/message/MessageFormatter.java +++ b/src/main/java/com/relogiclabs/jschema/message/MessageFormatter.java @@ -1,23 +1,21 @@ -package com.relogiclabs.json.schema.message; +package com.relogiclabs.jschema.message; -import com.relogiclabs.json.schema.tree.Context; -import com.relogiclabs.json.schema.tree.Location; -import com.relogiclabs.json.schema.type.JNode; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.tree.Context; +import com.relogiclabs.jschema.tree.Location; import lombok.Getter; -import lombok.Setter; +import org.antlr.v4.runtime.Token; import static org.apache.commons.lang3.StringUtils.capitalize; -import static org.apache.commons.lang3.StringUtils.left; -import static org.apache.commons.lang3.StringUtils.right; @Getter public abstract class MessageFormatter { private static final String NEWLINE = System.lineSeparator(); - private static final String SCHEMA_BASE_EXCEPTION = "Schema Input [%s]: %s"; - private static final String JSON_BASE_EXCEPTION = "Json Input [%s]: %s"; - private static final String SCHEMA_PARSE_EXCEPTION = "Schema (Line: %s) [%s]: %s"; - private static final String JSON_PARSE_EXCEPTION = "Json (Line: %s) [%s]: %s"; + private static final String SCHEMA_BASIC_FORMAT = "Schema Input [%s]: %s"; + private static final String JSON_BASIC_FORMAT = "Json Input [%s]: %s"; + private static final String SCHEMA_DETAIL_FORMAT = "Schema (Line: %s) [%s]: %s"; + private static final String JSON_DETAIL_FORMAT = "Json (Line: %s) [%s]: %s"; public static final MessageFormatter SCHEMA_VALIDATION = new ValidationFormatter( "Schema (Line: %s) Json (Line: %s) [%s]: %s.", @@ -38,9 +36,6 @@ public abstract class MessageFormatter { private final String expected; private final String actual; - @Setter - private int outlineLength = 200; - protected MessageFormatter(String summary, String expected, String actual) { this.summary = summary; this.expected = expected; @@ -49,13 +44,6 @@ protected MessageFormatter(String summary, String expected, String actual) { public abstract String format(ErrorDetail error, ExpectedDetail expected, ActualDetail actual); - public String createOutline(String target) { - int front = 2 * outlineLength / 3; - int back = 1 * outlineLength / 3; - if(front + back >= target.length()) return target; - return left(target, front) + "..." + right(target, back); - } - private static final class ValidationFormatter extends MessageFormatter { private ValidationFormatter(String summary, String expected, String actual) { super(summary, expected, actual); @@ -93,8 +81,14 @@ public static ErrorDetail formatForSchema(String code, String message, Context c public static ErrorDetail formatForSchema(String code, String message, Location location) { return location == null - ? createDetail(code, SCHEMA_BASE_EXCEPTION, message) - : createDetail(code, SCHEMA_PARSE_EXCEPTION, message, location); + ? createError(code, SCHEMA_BASIC_FORMAT, message) + : createError(code, SCHEMA_DETAIL_FORMAT, message, location); + } + + public static ErrorDetail formatForSchema(String code, String message, Token token) { + return token == null + ? createError(code, SCHEMA_BASIC_FORMAT, message) + : createError(code, SCHEMA_DETAIL_FORMAT, message, token); } public static ErrorDetail formatForJson(String code, String message, JNode node) { @@ -107,16 +101,22 @@ public static ErrorDetail formatForJson(String code, String message, Context con public static ErrorDetail formatForJson(String code, String message, Location location) { return location == null - ? createDetail(code, JSON_BASE_EXCEPTION, message) - : createDetail(code, JSON_PARSE_EXCEPTION, message, location); + ? createError(code, JSON_BASIC_FORMAT, message) + : createError(code, JSON_DETAIL_FORMAT, message, location); } - private static ErrorDetail createDetail(String code, String format, String message) { + private static ErrorDetail createError(String code, String format, String message) { return new ErrorDetail(code, format.formatted(code, message)); } - private static ErrorDetail createDetail(String code, String format, String message, + private static ErrorDetail createError(String code, String format, String message, Location location) { return new ErrorDetail(code, format.formatted(location, code, message)); } + + private static ErrorDetail createError(String code, String format, String message, + Token token) { + return new ErrorDetail(code, format.formatted(token.getLine() + ":" + + token.getCharPositionInLine(), code, message)); + } } \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/message/OutlineFormatter.java b/src/main/java/com/relogiclabs/jschema/message/OutlineFormatter.java new file mode 100644 index 0000000..83b7f4b --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/message/OutlineFormatter.java @@ -0,0 +1,22 @@ +package com.relogiclabs.jschema.message; + +import static org.apache.commons.lang3.StringUtils.left; +import static org.apache.commons.lang3.StringUtils.right; + +public class OutlineFormatter { + private static int outlineLength = 200; + private static int startLength = 2 * outlineLength / 3; + private static int endLength = outlineLength / 3; + + public static void setOutlineLength(int length) { + outlineLength = length; + startLength = 2 * length / 3; + endLength = length / 3; + } + + public static String createOutline(Object object) { + var string = object.toString(); + if(outlineLength >= string.length()) return string; + return left(string, startLength) + "..." + right(string, endLength); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/jschema/node/JNode.java b/src/main/java/com/relogiclabs/jschema/node/JNode.java index 6f57449..61d39cd 100644 --- a/src/main/java/com/relogiclabs/jschema/node/JNode.java +++ b/src/main/java/com/relogiclabs/jschema/node/JNode.java @@ -15,7 +15,7 @@ import static com.relogiclabs.jschema.internal.message.MessageHelper.DataTypeMismatch; import static com.relogiclabs.jschema.message.ErrorCode.DTYP02; -import static com.relogiclabs.jschema.message.MessageFormatter.createOutline; +import static com.relogiclabs.jschema.message.OutlineFormatter.createOutline; import static java.util.Collections.emptyList; import static java.util.Objects.requireNonNull; diff --git a/src/main/java/com/relogiclabs/jschema/node/JString.java b/src/main/java/com/relogiclabs/jschema/node/JString.java index 2d2ee40..10876f4 100644 --- a/src/main/java/com/relogiclabs/jschema/node/JString.java +++ b/src/main/java/com/relogiclabs/jschema/node/JString.java @@ -19,7 +19,7 @@ @EqualsAndHashCode public class JString extends JPrimitive implements EString, Derivable, PragmaValue { private final String value; - @Getter @Setter private JNode derived; + @Setter private JNode derived; private JString(JStringBuilder builder) { super(builder); diff --git a/src/main/java/com/relogiclabs/jschema/node/JsonType.java b/src/main/java/com/relogiclabs/jschema/node/JsonType.java index 1db91ac..94c7df4 100644 --- a/src/main/java/com/relogiclabs/jschema/node/JsonType.java +++ b/src/main/java/com/relogiclabs/jschema/node/JsonType.java @@ -4,6 +4,7 @@ import com.relogiclabs.jschema.tree.Location; import com.relogiclabs.jschema.type.EType; import com.relogiclabs.jschema.util.Reference; +import lombok.RequiredArgsConstructor; import org.antlr.v4.runtime.tree.TerminalNode; import java.util.HashMap; @@ -27,13 +28,13 @@ import static com.relogiclabs.jschema.type.EType.STRING; import static com.relogiclabs.jschema.type.EType.TIME; +@RequiredArgsConstructor public final class JsonType { private static final Map stringTypeMap = new HashMap<>(); private static final Map> typeClassMap = new HashMap<>(); private static final Map, EType> classTypeMap = new HashMap<>(); private final EType type; - private final Class nodeClass; static { mapType(BOOLEAN, JBoolean.class); @@ -52,11 +53,6 @@ public final class JsonType { mapType(ANY, JsonTypable.class); } - public JsonType(EType type) { - this.type = type; - this.nodeClass = typeClassMap.get(type); - } - private static void mapType(EType type, Class typeClass) { stringTypeMap.put(type.getName(), type); classTypeMap.putIfAbsent(typeClass, type); @@ -67,10 +63,6 @@ public static JsonType from(TerminalNode node) { return from(node.getText(), Location.from(node.getSymbol())); } - public static EType from(Class type) { - return classTypeMap.get(type); - } - private static JsonType from(String name, Location location) { var type = stringTypeMap.get(name); if(type == null) throw new InvalidDataTypeException(formatForSchema(DTYP01, @@ -79,7 +71,7 @@ private static JsonType from(String name, Location location) { } public boolean match(JNode node, Reference error) { - if(!nodeClass.isInstance(node)) return false; + if(!typeClassMap.get(type).isInstance(node)) return false; if(type == DATE) { var date = (JString) node; var dateTime = node.getRuntime().getPragmas().getDateTypeParser() @@ -100,6 +92,10 @@ boolean isNullType() { return type == NULL; } + public static EType getType(Class type) { + return classTypeMap.get(type); + } + @Override public String toString() { return type.getName(); diff --git a/src/main/java/com/relogiclabs/json/schema/time/DateTimeType.java b/src/main/java/com/relogiclabs/jschema/time/DateTimeType.java similarity index 52% rename from src/main/java/com/relogiclabs/json/schema/time/DateTimeType.java rename to src/main/java/com/relogiclabs/jschema/time/DateTimeType.java index 47fb79d..1c7089f 100644 --- a/src/main/java/com/relogiclabs/json/schema/time/DateTimeType.java +++ b/src/main/java/com/relogiclabs/jschema/time/DateTimeType.java @@ -1,11 +1,11 @@ -package com.relogiclabs.json.schema.time; +package com.relogiclabs.jschema.time; -import com.relogiclabs.json.schema.type.JsonType; +import com.relogiclabs.jschema.type.EType; import lombok.AllArgsConstructor; import lombok.Getter; -import static com.relogiclabs.json.schema.type.JsonType.DATE; -import static com.relogiclabs.json.schema.type.JsonType.TIME; +import static com.relogiclabs.jschema.type.EType.DATE; +import static com.relogiclabs.jschema.type.EType.TIME; @Getter @AllArgsConstructor @@ -14,7 +14,7 @@ public enum DateTimeType { TIME_TYPE("time", TIME); private final String name; - private final JsonType type; + private final EType type; @Override public String toString() { diff --git a/src/main/java/com/relogiclabs/json/schema/time/JsonDateTime.java b/src/main/java/com/relogiclabs/jschema/time/JsonDateTime.java similarity index 88% rename from src/main/java/com/relogiclabs/json/schema/time/JsonDateTime.java rename to src/main/java/com/relogiclabs/jschema/time/JsonDateTime.java index 9ad16da..b756218 100644 --- a/src/main/java/com/relogiclabs/json/schema/time/JsonDateTime.java +++ b/src/main/java/com/relogiclabs/jschema/time/JsonDateTime.java @@ -1,18 +1,18 @@ -package com.relogiclabs.json.schema.time; +package com.relogiclabs.jschema.time; -import com.relogiclabs.json.schema.type.JDate; -import com.relogiclabs.json.schema.type.JDateTime; -import com.relogiclabs.json.schema.type.JString; -import com.relogiclabs.json.schema.type.JTime; +import com.relogiclabs.jschema.node.JDate; +import com.relogiclabs.jschema.node.JDateTime; +import com.relogiclabs.jschema.node.JString; +import com.relogiclabs.jschema.node.JTime; import lombok.Getter; import java.time.DayOfWeek; import java.time.ZonedDateTime; import java.util.Arrays; -import static com.relogiclabs.json.schema.time.DateTimeType.DATE_TYPE; -import static com.relogiclabs.json.schema.time.DateTimeType.TIME_TYPE; -import static com.relogiclabs.json.schema.time.JsonUtcOffset.DEFAULT_UTC_OFFSET; +import static com.relogiclabs.jschema.time.DateTimeType.DATE_TYPE; +import static com.relogiclabs.jschema.time.DateTimeType.TIME_TYPE; +import static com.relogiclabs.jschema.time.JsonUtcOffset.DEFAULT_UTC_OFFSET; import static lombok.AccessLevel.PACKAGE; import static org.apache.commons.lang3.StringUtils.removeEnd; diff --git a/src/main/java/com/relogiclabs/json/schema/time/JsonUtcOffset.java b/src/main/java/com/relogiclabs/jschema/time/JsonUtcOffset.java similarity index 89% rename from src/main/java/com/relogiclabs/json/schema/time/JsonUtcOffset.java rename to src/main/java/com/relogiclabs/jschema/time/JsonUtcOffset.java index b54c3dc..f13514d 100644 --- a/src/main/java/com/relogiclabs/json/schema/time/JsonUtcOffset.java +++ b/src/main/java/com/relogiclabs/jschema/time/JsonUtcOffset.java @@ -1,11 +1,11 @@ -package com.relogiclabs.json.schema.time; +package com.relogiclabs.jschema.time; import lombok.Getter; import java.time.ZoneOffset; -import static com.relogiclabs.json.schema.time.JsonDateTime.UNSET; -import static com.relogiclabs.json.schema.time.JsonDateTime.defaultIfUnset; +import static com.relogiclabs.jschema.time.JsonDateTime.UNSET; +import static com.relogiclabs.jschema.time.JsonDateTime.defaultIfUnset; import static lombok.AccessLevel.PACKAGE; import static org.apache.commons.lang3.StringUtils.removeEnd; diff --git a/src/main/java/com/relogiclabs/json/schema/tree/Context.java b/src/main/java/com/relogiclabs/jschema/tree/Context.java similarity index 93% rename from src/main/java/com/relogiclabs/json/schema/tree/Context.java rename to src/main/java/com/relogiclabs/jschema/tree/Context.java index ea1e6b9..3a1f71e 100644 --- a/src/main/java/com/relogiclabs/json/schema/tree/Context.java +++ b/src/main/java/com/relogiclabs/jschema/tree/Context.java @@ -1,4 +1,4 @@ -package com.relogiclabs.json.schema.tree; +package com.relogiclabs.jschema.tree; import lombok.Getter; import org.antlr.v4.runtime.ParserRuleContext; diff --git a/src/main/java/com/relogiclabs/json/schema/tree/DataTree.java b/src/main/java/com/relogiclabs/jschema/tree/DataTree.java similarity index 62% rename from src/main/java/com/relogiclabs/json/schema/tree/DataTree.java rename to src/main/java/com/relogiclabs/jschema/tree/DataTree.java index bb11f8f..49e4226 100644 --- a/src/main/java/com/relogiclabs/json/schema/tree/DataTree.java +++ b/src/main/java/com/relogiclabs/jschema/tree/DataTree.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.tree; +package com.relogiclabs.jschema.tree; -import com.relogiclabs.json.schema.type.JRoot; +import com.relogiclabs.jschema.node.JRoot; public interface DataTree { boolean match(DataTree dataTree); diff --git a/src/main/java/com/relogiclabs/json/schema/tree/ExceptionRegistry.java b/src/main/java/com/relogiclabs/jschema/tree/ExceptionRegistry.java similarity index 81% rename from src/main/java/com/relogiclabs/json/schema/tree/ExceptionRegistry.java rename to src/main/java/com/relogiclabs/jschema/tree/ExceptionRegistry.java index 990105a..3653109 100644 --- a/src/main/java/com/relogiclabs/json/schema/tree/ExceptionRegistry.java +++ b/src/main/java/com/relogiclabs/jschema/tree/ExceptionRegistry.java @@ -1,4 +1,4 @@ -package com.relogiclabs.json.schema.tree; +package com.relogiclabs.jschema.tree; import lombok.Getter; import lombok.Setter; @@ -8,13 +8,16 @@ import java.util.List; import java.util.function.Supplier; +import static lombok.AccessLevel.NONE; + +@Getter public class ExceptionRegistry implements Iterable { - private int disableException; + @Getter(NONE) private int disableException; private final List exceptions; - @Getter private final List tryBuffer; - @Getter @Setter private boolean throwException; - @Getter @Setter private int cutoffLimit = 500; + private final List tryBuffer; + @Setter private boolean throwException; + @Setter private int cutoffLimit = 500; public ExceptionRegistry(boolean throwException) { this.throwException = throwException; @@ -27,7 +30,7 @@ private boolean addException(List list, Exception exception) { return false; } - public boolean failWith(RuntimeException exception) { + public boolean fail(RuntimeException exception) { exception.fillInStackTrace(); if(disableException > 0) return addException(tryBuffer, exception); if(throwException) throw exception; diff --git a/src/main/java/com/relogiclabs/jschema/tree/FunctionRegistry.java b/src/main/java/com/relogiclabs/jschema/tree/FunctionRegistry.java new file mode 100644 index 0000000..132e50f --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/tree/FunctionRegistry.java @@ -0,0 +1,205 @@ +package com.relogiclabs.jschema.tree; + +import com.relogiclabs.jschema.exception.ClassInstantiationException; +import com.relogiclabs.jschema.exception.CommonException; +import com.relogiclabs.jschema.exception.DuplicateImportException; +import com.relogiclabs.jschema.exception.FunctionNotFoundException; +import com.relogiclabs.jschema.exception.InvalidFunctionException; +import com.relogiclabs.jschema.exception.InvalidImportException; +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.exception.NotFoundClassException; +import com.relogiclabs.jschema.function.FunctionProvider; +import com.relogiclabs.jschema.function.FutureFunction; +import com.relogiclabs.jschema.internal.tree.EFunction; +import com.relogiclabs.jschema.internal.tree.FunctionKey; +import com.relogiclabs.jschema.internal.tree.NativeFunction; +import com.relogiclabs.jschema.internal.tree.ScriptFunction; +import com.relogiclabs.jschema.message.ActualDetail; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ExpectedDetail; +import com.relogiclabs.jschema.node.JFunction; +import com.relogiclabs.jschema.node.JImport; +import com.relogiclabs.jschema.node.JNode; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Parameter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static com.relogiclabs.jschema.internal.message.MessageHelper.getTypeName; +import static com.relogiclabs.jschema.internal.tree.NativeFunction.getSignature; +import static com.relogiclabs.jschema.internal.util.CollectionHelper.merge; +import static com.relogiclabs.jschema.internal.util.MiscellaneousHelper.getDerived; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.CLAS01; +import static com.relogiclabs.jschema.message.ErrorCode.CLAS02; +import static com.relogiclabs.jschema.message.ErrorCode.CLAS03; +import static com.relogiclabs.jschema.message.ErrorCode.CLAS04; +import static com.relogiclabs.jschema.message.ErrorCode.CLAS05; +import static com.relogiclabs.jschema.message.ErrorCode.CLAS06; +import static com.relogiclabs.jschema.message.ErrorCode.CLAS07; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC01; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC02; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC03; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC04; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC05; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; + +public final class FunctionRegistry { + private final Set imports; + private final Map> functions; + private final RuntimeContext runtime; + + public FunctionRegistry(RuntimeContext runtime) { + this.runtime = runtime; + this.imports = new HashSet<>(); + this.functions = new HashMap<>(); + } + + public JImport addClass(JImport importNode) { + addClass(importNode.getClassName(), importNode.getContext()); + return importNode; + } + + public void addClass(String className, Context context) { + if(!imports.contains(className)) imports.add(className); + else throw new DuplicateImportException(formatForSchema(CLAS01, + concat("Class already imported ", className), context)); + Class providerClass; + try { + providerClass = Class.forName(className); + } catch(ClassNotFoundException ex) { + throw new NotFoundClassException(formatForSchema(CLAS02, + concat("Not found ", className), context)); + } + var baseClass = FunctionProvider.class; + // if not FunctionProvider's subclass + if(!baseClass.isAssignableFrom(providerClass)) + throw new InvalidImportException(formatForSchema(CLAS03, concat(providerClass.getName(), + " needs to inherit ", baseClass.getName()), context)); + try { + merge(functions, extractMethods(providerClass, createInstance(providerClass, context))); + } catch(InvalidFunctionException ex) { + throw new InvalidFunctionException(formatForSchema(ex.getCode(), ex.getMessage(), context)); + } + } + + private static Map> extractMethods(Class providerClass, + FunctionProvider instance) { + var baseClass = FunctionProvider.class; + Map> functions = new HashMap<>(); + for(var m : providerClass.getMethods()) { + // Methods in super class or in base class + if(!baseClass.isAssignableFrom(m.getDeclaringClass()) + || baseClass == m.getDeclaringClass()) continue; + Parameter[] parameters = m.getParameters(); + if(!isValidReturnType(m.getReturnType())) throw new InvalidFunctionException(FUNC01, + concat("Function [", getSignature(m), "] requires valid return type")); + if(parameters.length == 0 || parameters[0].isVarArgs()) + throw new InvalidFunctionException(FUNC02, + concat("Function [", getSignature(m), "] requires valid target parameter")); + addFunction(new NativeFunction(m, parameters, instance), functions); + } + return functions; + } + + private static void addFunction(EFunction function, + Map> functions) { + var functionKey = new FunctionKey(function); + var functionList = functions.get(functionKey); + if(functionList == null) functionList = new ArrayList<>(); + functionList.add(function); + functions.put(functionKey, functionList); + } + + public void addFunction(ScriptFunction function) { + addFunction(function, functions); + } + + private static boolean isValidReturnType(Class type) { + if(type == boolean.class) return true; + if(type == Boolean.class) return true; + if(type == FutureFunction.class) return true; + return false; + } + + private FunctionProvider createInstance(Class type, Context context) { + try { + var constructor = type.getDeclaredConstructor(RuntimeContext.class); + return (FunctionProvider) constructor.newInstance(runtime); + } catch (NoSuchMethodException e) { + throw failOnCreateInstance(CLAS04, e, type, context); + } catch (InstantiationException e) { + throw failOnCreateInstance(CLAS05, e, type, context); + } catch (InvocationTargetException e) { + throw failOnCreateInstance(CLAS06, e, type, context); + } catch (IllegalAccessException e) { + throw failOnCreateInstance(CLAS07, e, type, context); + } + } + + private static CommonException failOnCreateInstance(String code, Exception ex, + Class type, Context context) { + return new ClassInstantiationException(formatForSchema(code, + concat("Fail to create instance of ", type.getName()), context), ex); + } + + private boolean processResult(Object result) { + return result instanceof FutureFunction future + ? runtime.addFuture(future) + : (boolean) result; + } + + public boolean invokeFunction(JFunction caller, JNode target) { + for(var e : caller.getCache()) if(e.isTargetMatch(target)) + return processResult(e.invoke(caller, target)); + Class mismatchTarget = null; + + for(var f : getFunctions(caller)) { + var schemaArgs = f.prebind(caller.getArguments()); + if(schemaArgs == null) continue; + var targetType = f.getTargetType(); + if(isMatch(target, targetType)) { + Object[] allArgs = addTarget(schemaArgs, target).toArray(); + var result = f.invoke(caller, allArgs); + caller.getCache().add(f, allArgs); + return processResult(result); + } + mismatchTarget = targetType; + } + if(mismatchTarget != null) + return fail(new JsonSchemaException(new ErrorDetail(FUNC03, + "Function ", caller.getOutline(), " is incompatible with the target data type"), + new ExpectedDetail(caller, "applying to a supported data type such as ", + getTypeName(mismatchTarget)), + new ActualDetail(target, "applied to an unsupported data type ", + getTypeName(target.getClass()), " of ", target.getOutline()))); + + return fail(new FunctionNotFoundException(formatForSchema(FUNC04, caller.getOutline(), caller))); + } + + private List getFunctions(JFunction caller) { + var list = functions.get(new FunctionKey(caller)); + if(list == null) list = functions.get(new FunctionKey(caller.getName(), -1)); + if(list == null) throw new FunctionNotFoundException(formatForSchema(FUNC05, + concat("Not found function ", caller.getOutline()), caller)); + return list; + } + + private static List addTarget(List arguments, JNode target) { + arguments.add(0, getDerived(target)); + return arguments; + } + + private static boolean isMatch(JNode value, Class type) { + return type.isInstance(getDerived(value)); + } + + private boolean fail(RuntimeException exception) { + return runtime.getExceptions().fail(exception); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/tree/JsonTree.java b/src/main/java/com/relogiclabs/jschema/tree/JsonTree.java similarity index 65% rename from src/main/java/com/relogiclabs/json/schema/tree/JsonTree.java rename to src/main/java/com/relogiclabs/jschema/tree/JsonTree.java index ad1d7a8..f6e73fc 100644 --- a/src/main/java/com/relogiclabs/json/schema/tree/JsonTree.java +++ b/src/main/java/com/relogiclabs/jschema/tree/JsonTree.java @@ -1,16 +1,16 @@ -package com.relogiclabs.json.schema.tree; +package com.relogiclabs.jschema.tree; -import com.relogiclabs.json.schema.internal.antlr.JsonLexer; -import com.relogiclabs.json.schema.internal.antlr.JsonParser; -import com.relogiclabs.json.schema.internal.tree.JsonTreeVisitor; -import com.relogiclabs.json.schema.internal.util.LexerErrorListener; -import com.relogiclabs.json.schema.internal.util.ParserErrorListener; -import com.relogiclabs.json.schema.type.JRoot; +import com.relogiclabs.jschema.internal.antlr.JsonLexer; +import com.relogiclabs.jschema.internal.antlr.JsonParser; +import com.relogiclabs.jschema.internal.tree.JsonTreeVisitor; +import com.relogiclabs.jschema.internal.util.LexerErrorListener; +import com.relogiclabs.jschema.internal.util.ParserErrorListener; +import com.relogiclabs.jschema.node.JRoot; import lombok.Getter; import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; -import static com.relogiclabs.json.schema.tree.TreeType.JSON_TREE; +import static com.relogiclabs.jschema.tree.TreeType.JSON_TREE; @Getter public final class JsonTree implements DataTree { @@ -31,7 +31,7 @@ public JsonTree(RuntimeContext runtime, String input) { @Override public boolean match(DataTree dataTree) { var result = root.match(dataTree.getRoot()); - result &= runtime.invokeValidators(); + result &= runtime.invokeFutures(); return result; } diff --git a/src/main/java/com/relogiclabs/json/schema/tree/Location.java b/src/main/java/com/relogiclabs/jschema/tree/Location.java similarity index 87% rename from src/main/java/com/relogiclabs/json/schema/tree/Location.java rename to src/main/java/com/relogiclabs/jschema/tree/Location.java index 3dcf5e4..17480fd 100644 --- a/src/main/java/com/relogiclabs/json/schema/tree/Location.java +++ b/src/main/java/com/relogiclabs/jschema/tree/Location.java @@ -1,4 +1,4 @@ -package com.relogiclabs.json.schema.tree; +package com.relogiclabs.jschema.tree; import org.antlr.v4.runtime.Token; diff --git a/src/main/java/com/relogiclabs/json/schema/tree/PragmaRegistry.java b/src/main/java/com/relogiclabs/jschema/tree/PragmaRegistry.java similarity index 79% rename from src/main/java/com/relogiclabs/json/schema/tree/PragmaRegistry.java rename to src/main/java/com/relogiclabs/jschema/tree/PragmaRegistry.java index 6c4f162..568e405 100644 --- a/src/main/java/com/relogiclabs/json/schema/tree/PragmaRegistry.java +++ b/src/main/java/com/relogiclabs/jschema/tree/PragmaRegistry.java @@ -1,19 +1,20 @@ -package com.relogiclabs.json.schema.tree; +package com.relogiclabs.jschema.tree; -import com.relogiclabs.json.schema.exception.DuplicatePragmaException; -import com.relogiclabs.json.schema.internal.time.DateTimeParser; -import com.relogiclabs.json.schema.internal.tree.PragmaDescriptor; -import com.relogiclabs.json.schema.type.JPragma; +import com.relogiclabs.jschema.exception.DuplicatePragmaException; +import com.relogiclabs.jschema.internal.time.DateTimeParser; +import com.relogiclabs.jschema.internal.tree.PragmaDescriptor; +import com.relogiclabs.jschema.node.JPragma; import lombok.Getter; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import static com.relogiclabs.json.schema.message.ErrorCode.PRAG03; -import static com.relogiclabs.json.schema.message.MessageFormatter.formatForSchema; -import static com.relogiclabs.json.schema.time.DateTimeType.DATE_TYPE; -import static com.relogiclabs.json.schema.time.DateTimeType.TIME_TYPE; +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.PRAG03; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; +import static com.relogiclabs.jschema.time.DateTimeType.DATE_TYPE; +import static com.relogiclabs.jschema.time.DateTimeType.TIME_TYPE; @Getter public final class PragmaRegistry implements Iterable> { @@ -47,9 +48,8 @@ public PragmaRegistry() { } public JPragma addPragma(JPragma pragma) { - if(pragmas.containsKey(pragma.getName())) - throw new DuplicatePragmaException(formatForSchema(PRAG03, - "Duplication found for " + pragma.getOutline(), pragma)); + if(pragmas.containsKey(pragma.getName())) throw new DuplicatePragmaException(formatForSchema( + PRAG03, concat("Duplication found for ", pragma.getOutline()), pragma)); pragmas.put(pragma.getName(), pragma); setPragmaValue(pragma.getName(), pragma.getValue().toNativeValue()); return pragma; diff --git a/src/main/java/com/relogiclabs/json/schema/tree/ReceiverRegistry.java b/src/main/java/com/relogiclabs/jschema/tree/ReceiverRegistry.java similarity index 86% rename from src/main/java/com/relogiclabs/json/schema/tree/ReceiverRegistry.java rename to src/main/java/com/relogiclabs/jschema/tree/ReceiverRegistry.java index a613212..61cdf27 100644 --- a/src/main/java/com/relogiclabs/json/schema/tree/ReceiverRegistry.java +++ b/src/main/java/com/relogiclabs/jschema/tree/ReceiverRegistry.java @@ -1,7 +1,7 @@ -package com.relogiclabs.json.schema.tree; +package com.relogiclabs.jschema.tree; -import com.relogiclabs.json.schema.type.JNode; -import com.relogiclabs.json.schema.type.JReceiver; +import com.relogiclabs.jschema.node.JNode; +import com.relogiclabs.jschema.node.JReceiver; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/com/relogiclabs/jschema/tree/RuntimeContext.java b/src/main/java/com/relogiclabs/jschema/tree/RuntimeContext.java new file mode 100644 index 0000000..8fbda5b --- /dev/null +++ b/src/main/java/com/relogiclabs/jschema/tree/RuntimeContext.java @@ -0,0 +1,73 @@ +package com.relogiclabs.jschema.tree; + +import com.relogiclabs.jschema.exception.DuplicateDefinitionException; +import com.relogiclabs.jschema.function.FutureFunction; +import com.relogiclabs.jschema.internal.engine.ScriptContext; +import com.relogiclabs.jschema.message.MessageFormatter; +import com.relogiclabs.jschema.node.JAlias; +import com.relogiclabs.jschema.node.JDefinition; +import com.relogiclabs.jschema.node.JValidator; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import static com.relogiclabs.jschema.internal.util.StringHelper.concat; +import static com.relogiclabs.jschema.message.ErrorCode.DEFI01; +import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema; + +@Getter +public final class RuntimeContext { + private final FunctionRegistry functions; + private final PragmaRegistry pragmas; + private final Map definitions; + private final ExceptionRegistry exceptions; + private final Map futures; + private final ReceiverRegistry receivers; + private final Map storage; + private final MessageFormatter messageFormatter; + private final ScriptContext scriptContext; + + public RuntimeContext(MessageFormatter messageFormatter, boolean throwException) { + this.messageFormatter = messageFormatter; + this.definitions = new HashMap<>(); + this.functions = new FunctionRegistry(this); + this.pragmas = new PragmaRegistry(); + this.exceptions = new ExceptionRegistry(throwException); + this.receivers = new ReceiverRegistry(); + this.storage = new HashMap<>(); + this.futures = new HashMap<>(); + this.scriptContext = new ScriptContext(this); + } + + public JDefinition addDefinition(JDefinition definition) { + var previous = definitions.get(definition.getAlias()); + if(previous != null) throw new DuplicateDefinitionException(formatForSchema(DEFI01, + concat("Duplicate definition of '", definition.getAlias(), + "' is found and already defined as ", previous.getOutline()), + definition.getContext())); + definitions.put(definition.getAlias(), definition.getValidator()); + return definition; + } + + public boolean areEqual(double value1, double value2) { + return Math.abs(value1 - value2) < pragmas.getFloatingPointTolerance(); + } + + public boolean addFuture(FutureFunction future) { + return futures.put(UUID.randomUUID().toString(), future) == null; + } + + public boolean invokeFutures() { + var result = true; + for(var f : futures.values()) result &= f.invoke(); + return result; + } + + public void clear() { + exceptions.clear(); + storage.clear(); + receivers.clear(); + } +} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/tree/SchemaTree.java b/src/main/java/com/relogiclabs/jschema/tree/SchemaTree.java similarity index 51% rename from src/main/java/com/relogiclabs/json/schema/tree/SchemaTree.java rename to src/main/java/com/relogiclabs/jschema/tree/SchemaTree.java index 1f73a2d..6fb6417 100644 --- a/src/main/java/com/relogiclabs/json/schema/tree/SchemaTree.java +++ b/src/main/java/com/relogiclabs/jschema/tree/SchemaTree.java @@ -1,16 +1,17 @@ -package com.relogiclabs.json.schema.tree; +package com.relogiclabs.jschema.tree; -import com.relogiclabs.json.schema.internal.antlr.SchemaLexer; -import com.relogiclabs.json.schema.internal.antlr.SchemaParser; -import com.relogiclabs.json.schema.internal.tree.SchemaTreeVisitor; -import com.relogiclabs.json.schema.internal.util.LexerErrorListener; -import com.relogiclabs.json.schema.internal.util.ParserErrorListener; -import com.relogiclabs.json.schema.type.JRoot; +import com.relogiclabs.jschema.internal.antlr.SchemaLexer; +import com.relogiclabs.jschema.internal.antlr.SchemaParser; +import com.relogiclabs.jschema.internal.engine.ScriptTreeVisitor3; +import com.relogiclabs.jschema.internal.tree.SchemaTreeVisitor; +import com.relogiclabs.jschema.internal.util.LexerErrorListener; +import com.relogiclabs.jschema.internal.util.ParserErrorListener; +import com.relogiclabs.jschema.node.JRoot; import lombok.Getter; import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; -import static com.relogiclabs.json.schema.tree.TreeType.SCHEMA_TREE; +import static com.relogiclabs.jschema.tree.TreeType.SCHEMA_TREE; @Getter public final class SchemaTree implements DataTree { @@ -25,13 +26,17 @@ public SchemaTree(RuntimeContext runtime, String input) { var schemaParser = new SchemaParser(new CommonTokenStream(schemaLexer)); schemaParser.removeErrorListeners(); schemaParser.addErrorListener(ParserErrorListener.SCHEMA); - root = (JRoot) new SchemaTreeVisitor(runtime).visit(schemaParser.schema()); + var schemaParseTree = schemaParser.schema(); + var scriptVisitor = new ScriptTreeVisitor3(runtime); + var evaluator = scriptVisitor.visit(schemaParseTree); + root = (JRoot) new SchemaTreeVisitor(scriptVisitor).visit(schemaParseTree); + evaluator.evaluate(runtime.getScriptContext()); } @Override public boolean match(DataTree dataTree) { var result = root.match(dataTree.getRoot()); - result &= runtime.invokeValidators(); + result &= runtime.invokeFutures(); return result; } diff --git a/src/main/java/com/relogiclabs/json/schema/tree/TreeType.java b/src/main/java/com/relogiclabs/jschema/tree/TreeType.java similarity index 86% rename from src/main/java/com/relogiclabs/json/schema/tree/TreeType.java rename to src/main/java/com/relogiclabs/jschema/tree/TreeType.java index b0f41bf..14873e5 100644 --- a/src/main/java/com/relogiclabs/json/schema/tree/TreeType.java +++ b/src/main/java/com/relogiclabs/jschema/tree/TreeType.java @@ -1,4 +1,4 @@ -package com.relogiclabs.json.schema.tree; +package com.relogiclabs.jschema.tree; import lombok.Getter; diff --git a/src/main/java/com/relogiclabs/json/schema/util/Reference.java b/src/main/java/com/relogiclabs/jschema/util/Reference.java similarity index 83% rename from src/main/java/com/relogiclabs/json/schema/util/Reference.java rename to src/main/java/com/relogiclabs/jschema/util/Reference.java index 97fc683..042ddde 100644 --- a/src/main/java/com/relogiclabs/json/schema/util/Reference.java +++ b/src/main/java/com/relogiclabs/jschema/util/Reference.java @@ -1,4 +1,4 @@ -package com.relogiclabs.json.schema.util; +package com.relogiclabs.jschema.util; import lombok.Data; diff --git a/src/main/java/com/relogiclabs/json/schema/exception/DuplicateIncludeException.java b/src/main/java/com/relogiclabs/json/schema/exception/DuplicateIncludeException.java deleted file mode 100644 index 2fe6d02..0000000 --- a/src/main/java/com/relogiclabs/json/schema/exception/DuplicateIncludeException.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.relogiclabs.json.schema.exception; - -import com.relogiclabs.json.schema.message.ErrorDetail; - -public class DuplicateIncludeException extends CommonException { - public DuplicateIncludeException(ErrorDetail detail) { - super(detail); - } -} diff --git a/src/main/java/com/relogiclabs/json/schema/exception/InvalidIncludeException.java b/src/main/java/com/relogiclabs/json/schema/exception/InvalidIncludeException.java deleted file mode 100644 index 1bcc7f7..0000000 --- a/src/main/java/com/relogiclabs/json/schema/exception/InvalidIncludeException.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.relogiclabs.json.schema.exception; - -import com.relogiclabs.json.schema.message.ErrorDetail; - -public class InvalidIncludeException extends CommonException { - public InvalidIncludeException(ErrorDetail detail) { - super(detail); - } -} diff --git a/src/main/java/com/relogiclabs/json/schema/function/CoreFunctions1.java b/src/main/java/com/relogiclabs/json/schema/function/CoreFunctions1.java deleted file mode 100644 index 8946b12..0000000 --- a/src/main/java/com/relogiclabs/json/schema/function/CoreFunctions1.java +++ /dev/null @@ -1,166 +0,0 @@ -package com.relogiclabs.json.schema.function; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.message.ActualDetail; -import com.relogiclabs.json.schema.message.ErrorDetail; -import com.relogiclabs.json.schema.message.ExpectedDetail; -import com.relogiclabs.json.schema.tree.RuntimeContext; -import com.relogiclabs.json.schema.type.JArray; -import com.relogiclabs.json.schema.type.JInteger; -import com.relogiclabs.json.schema.type.JObject; -import com.relogiclabs.json.schema.type.JString; -import com.relogiclabs.json.schema.type.JUndefined; - -import static com.relogiclabs.json.schema.message.ErrorCode.ALEN01; -import static com.relogiclabs.json.schema.message.ErrorCode.ALEN02; -import static com.relogiclabs.json.schema.message.ErrorCode.ALEN03; -import static com.relogiclabs.json.schema.message.ErrorCode.ALEN04; -import static com.relogiclabs.json.schema.message.ErrorCode.ALEN05; -import static com.relogiclabs.json.schema.message.ErrorCode.OLEN01; -import static com.relogiclabs.json.schema.message.ErrorCode.OLEN02; -import static com.relogiclabs.json.schema.message.ErrorCode.OLEN03; -import static com.relogiclabs.json.schema.message.ErrorCode.OLEN04; -import static com.relogiclabs.json.schema.message.ErrorCode.OLEN05; -import static com.relogiclabs.json.schema.message.ErrorCode.SLEN01; -import static com.relogiclabs.json.schema.message.ErrorCode.SLEN02; -import static com.relogiclabs.json.schema.message.ErrorCode.SLEN03; -import static com.relogiclabs.json.schema.message.ErrorCode.SLEN04; -import static com.relogiclabs.json.schema.message.ErrorCode.SLEN05; - -public class CoreFunctions1 extends FunctionBase { - public CoreFunctions1(RuntimeContext runtime) { - super(runtime); - } - - public boolean length(JString target, JInteger length) { - var rLength = target.getValue().length(); - if(rLength != length.getValue()) return failWith(new JsonSchemaException( - new ErrorDetail(SLEN01, "Invalid length of string ", target), - new ExpectedDetail(function, "a string of length ", length), - new ActualDetail(target, "found ", rLength, " which does not match"))); - return true; - } - - public boolean length(JArray target, JInteger length) { - var rLength = target.getElements().size(); - if(rLength != length.getValue()) return failWith(new JsonSchemaException( - new ErrorDetail(ALEN01, "Invalid length of array ", target.getOutline()), - new ExpectedDetail(function, "an array of length ", length), - new ActualDetail(target, "found ", rLength, " which does not match"))); - return true; - } - - public boolean length(JObject target, JInteger length) { - var rLength = target.getProperties().size(); - if(rLength != length.getValue()) return failWith(new JsonSchemaException( - new ErrorDetail(OLEN01, "Invalid size or length of object ", target.getOutline()), - new ExpectedDetail(function, "an object of length ", length), - new ActualDetail(target, "found ", rLength, " which does not match"))); - return true; - } - - public boolean length(JString target, JInteger minimum, JInteger maximum) { - var length = target.getValue().length(); - if(length < minimum.getValue()) - return failWith(new JsonSchemaException(new ErrorDetail(SLEN02, - "String ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), - new ActualDetail(target, "found ", length, " that is less than ", minimum))); - if(length > maximum.getValue()) - return failWith(new JsonSchemaException(new ErrorDetail(SLEN03, - "String ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), - new ActualDetail(target, "found ", length, " that is greater than ", maximum))); - return true; - } - - public boolean length(JString target, JInteger minimum, JUndefined undefined) { - var length = target.getValue().length(); - if(length < minimum.getValue()) - return failWith(new JsonSchemaException(new ErrorDetail(SLEN04, - "String ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", undefined, "]"), - new ActualDetail(target, "found ", length, " that is less than ", minimum))); - return true; - } - - public boolean length(JString target, JUndefined undefined, JInteger maximum) { - var length = target.getValue().length(); - if(length > maximum.getValue()) - return failWith(new JsonSchemaException(new ErrorDetail(SLEN05, - "String ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", undefined, ", ", maximum, "]"), - new ActualDetail(target, "found ", length, " that is greater than ", maximum))); - return true; - } - - public boolean length(JArray target, JInteger minimum, JInteger maximum) { - var length = target.getElements().size(); - if(length < minimum.getValue()) - return failWith(new JsonSchemaException(new ErrorDetail(ALEN02, - "Array ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), - new ActualDetail(target, "found ", length, " that is less than ", minimum))); - if(length > maximum.getValue()) - return failWith(new JsonSchemaException(new ErrorDetail(ALEN03, - "Array ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), - new ActualDetail(target, "found ", length, " that is greater than ", maximum))); - return true; - } - - public boolean length(JArray target, JInteger minimum, JUndefined undefined) { - var length = target.getElements().size(); - if(length < minimum.getValue()) - return failWith(new JsonSchemaException(new ErrorDetail(ALEN04, - "Array ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", undefined, "]"), - new ActualDetail(target, "found ", length, " that is less than ", minimum))); - return true; - } - - public boolean length(JArray target, JUndefined undefined, JInteger maximum) { - var length = target.getElements().size(); - if(length > maximum.getValue()) - return failWith(new JsonSchemaException(new ErrorDetail(ALEN05, - "Array ", target.getOutline(), " length is outside of range"), - new ExpectedDetail(function, "length in range [", undefined, ", ", maximum, "]"), - new ActualDetail(target, "found ", length, " that is greater than ", maximum))); - return true; - } - - public boolean length(JObject target, JInteger minimum, JInteger maximum) { - var length = target.getProperties().size(); - if(length < minimum.getValue()) - return failWith(new JsonSchemaException(new ErrorDetail(OLEN02, - "Object ", target.getOutline(), " size or length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), - new ActualDetail(target, "found ", length, " that is less than ", minimum))); - if(length > maximum.getValue()) - return failWith(new JsonSchemaException(new ErrorDetail(OLEN03, - "Object ", target.getOutline(), " size or length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", maximum, "]"), - new ActualDetail(target, "found ", length, " that is greater than ", maximum))); - return true; - } - - public boolean length(JObject target, JInteger minimum, JUndefined undefined) { - var length = target.getProperties().size(); - if(length < minimum.getValue()) - return failWith(new JsonSchemaException(new ErrorDetail(OLEN04, - "Object ", target.getOutline(), " size or length is outside of range"), - new ExpectedDetail(function, "length in range [", minimum, ", ", undefined, "]"), - new ActualDetail(target, "found ", length, " that is less than ", minimum))); - return true; - } - - public boolean length(JObject target, JUndefined undefined, JInteger maximum) { - var length = target.getProperties().size(); - if(length > maximum.getValue()) - return failWith(new JsonSchemaException(new ErrorDetail(OLEN05, - "Object ", target.getOutline(), " size or length is outside of range"), - new ExpectedDetail(function, "length in range [", undefined, ", ", maximum, "]"), - new ActualDetail(target, "found ", length, " that is greater than ", maximum))); - return true; - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/function/CoreFunctions2.java b/src/main/java/com/relogiclabs/json/schema/function/CoreFunctions2.java deleted file mode 100644 index 4953f76..0000000 --- a/src/main/java/com/relogiclabs/json/schema/function/CoreFunctions2.java +++ /dev/null @@ -1,203 +0,0 @@ -package com.relogiclabs.json.schema.function; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.message.ActualDetail; -import com.relogiclabs.json.schema.message.ErrorDetail; -import com.relogiclabs.json.schema.message.ExpectedDetail; -import com.relogiclabs.json.schema.tree.RuntimeContext; -import com.relogiclabs.json.schema.type.JArray; -import com.relogiclabs.json.schema.type.JBoolean; -import com.relogiclabs.json.schema.type.JNumber; -import com.relogiclabs.json.schema.type.JObject; -import com.relogiclabs.json.schema.type.JString; -import com.relogiclabs.json.schema.type.JUndefined; - -import java.util.Arrays; -import java.util.function.Supplier; - -import static com.relogiclabs.json.schema.internal.util.StringHelper.joinWith; -import static com.relogiclabs.json.schema.message.ErrorCode.ENUM01; -import static com.relogiclabs.json.schema.message.ErrorCode.ENUM02; -import static com.relogiclabs.json.schema.message.ErrorCode.MAXI01; -import static com.relogiclabs.json.schema.message.ErrorCode.MAXI02; -import static com.relogiclabs.json.schema.message.ErrorCode.MAXI03; -import static com.relogiclabs.json.schema.message.ErrorCode.MINI01; -import static com.relogiclabs.json.schema.message.ErrorCode.MINI02; -import static com.relogiclabs.json.schema.message.ErrorCode.MINI03; -import static com.relogiclabs.json.schema.message.ErrorCode.NEGI01; -import static com.relogiclabs.json.schema.message.ErrorCode.NEGI02; -import static com.relogiclabs.json.schema.message.ErrorCode.NEMT01; -import static com.relogiclabs.json.schema.message.ErrorCode.NEMT02; -import static com.relogiclabs.json.schema.message.ErrorCode.NEMT03; -import static com.relogiclabs.json.schema.message.ErrorCode.POSI01; -import static com.relogiclabs.json.schema.message.ErrorCode.POSI02; -import static com.relogiclabs.json.schema.message.ErrorCode.RANG01; -import static com.relogiclabs.json.schema.message.ErrorCode.RANG02; -import static com.relogiclabs.json.schema.message.ErrorCode.RANG03; -import static com.relogiclabs.json.schema.message.ErrorCode.RANG04; - -public class CoreFunctions2 extends CoreFunctions1 { - public CoreFunctions2(RuntimeContext runtime) { - super(runtime); - } - - // enum is a keyword in Java but _ will be escaped - public boolean _enum(JString target, JString... items) { - var list = Arrays.asList(items); - if(!list.contains(target)) return failWith(new JsonSchemaException( - new ErrorDetail(ENUM01, "String is not in enum list"), - new ExpectedDetail(function, "string in list ", joinWith(list, ", ", "[", "]")), - new ActualDetail(target, "string ", target, " is not found in list"))); - return true; - } - - public boolean _enum(JNumber target, JNumber... items) { - var list = Arrays.asList(items); - if(!list.contains(target)) return failWith(new JsonSchemaException( - new ErrorDetail(ENUM02, "Number is not in enum list"), - new ExpectedDetail(function, "number in list ", joinWith(list, ", ", "[", "]")), - new ActualDetail(target, "number ", target, " is not found in list"))); - return true; - } - - public boolean minimum(JNumber target, JNumber minimum) { - if(target.compare(minimum) < 0) - return failWith(new JsonSchemaException( - new ErrorDetail(MINI01, "Number is less than provided minimum"), - new ExpectedDetail(function, "a number greater than or equal to ", minimum), - new ActualDetail(target, "number ", target, " is less than ", minimum))); - return true; - } - - public boolean minimum(JNumber target, JNumber minimum, JBoolean exclusive) { - Supplier relationTo = () -> exclusive.getValue() - ? "greater than" - : "greater than or equal to"; - - if(target.compare(minimum) < 0) - return failWith(new JsonSchemaException( - new ErrorDetail(MINI02, "Number is less than provided minimum"), - new ExpectedDetail(function, "a number ", relationTo.get(), " ", minimum), - new ActualDetail(target, "number ", target, " is less than ", minimum))); - if(exclusive.getValue() && target.compare(minimum) == 0) - return failWith(new JsonSchemaException( - new ErrorDetail(MINI03, "Number is equal to provided minimum"), - new ExpectedDetail(function, "a number ", relationTo.get(), " ", minimum), - new ActualDetail(target, "number ", target, " is equal to ", minimum))); - return true; - } - - public boolean maximum(JNumber target, JNumber maximum) { - if(target.compare(maximum) > 0) - return failWith(new JsonSchemaException( - new ErrorDetail(MAXI01, "Number is greater than provided maximum"), - new ExpectedDetail(function, "a number less than or equal ", maximum), - new ActualDetail(target, "number ", target, " is greater than ", maximum))); - return true; - } - - public boolean maximum(JNumber target, JNumber maximum, JBoolean exclusive) { - Supplier relationTo = () -> exclusive.getValue() - ? "less than" - : "less than or equal to"; - - if(target.compare(maximum) > 0) - return failWith(new JsonSchemaException( - new ErrorDetail(MAXI02, "Number is greater than provided maximum"), - new ExpectedDetail(function, "a number ", relationTo.get(), " ", maximum), - new ActualDetail(target, "number ", target, " is greater than ", maximum))); - if(exclusive.getValue() && target.compare(maximum) == 0) - return failWith(new JsonSchemaException( - new ErrorDetail(MAXI03, "Number is equal to provided maximum"), - new ExpectedDetail(function, "a number ", relationTo.get(), " ", maximum), - new ActualDetail(target, "number ", target, " is equal to ", maximum))); - return true; - } - - public boolean positive(JNumber target) { - if(target.compare(0) <= 0) return failWith(new JsonSchemaException( - new ErrorDetail(POSI01, "Number is not positive"), - new ExpectedDetail(function, "a positive number"), - new ActualDetail(target, "number ", target, " is less than or equal to zero"))); - return true; - } - - public boolean negative(JNumber target) { - if(target.compare(0) >= 0) return failWith(new JsonSchemaException( - new ErrorDetail(NEGI01, "Number is not negative"), - new ExpectedDetail(function, "a negative number"), - new ActualDetail(target, "number ", target, " is greater than or equal to zero"))); - return true; - } - - public boolean positive(JNumber target, JNumber reference) { - if(target.compare(reference) < 0) return failWith(new JsonSchemaException( - new ErrorDetail(POSI02, "Number is not positive from reference"), - new ExpectedDetail(function, "a positive number from ", reference), - new ActualDetail(target, "number ", target, " is less than reference"))); - return true; - } - - public boolean negative(JNumber target, JNumber reference) { - if(target.compare(reference) > 0) return failWith(new JsonSchemaException( - new ErrorDetail(NEGI02, "Number is not negative from reference"), - new ExpectedDetail(function, "a negative number from ", reference), - new ActualDetail(target, "number ", target, " is greater than reference"))); - return true; - } - - public boolean range(JNumber target, JNumber minimum, JNumber maximum) { - if(target.compare(minimum) < 0) return failWith(new JsonSchemaException( - new ErrorDetail(RANG01, "Number is outside of range"), - new ExpectedDetail(function, "number in range [", minimum, ", ", maximum, "]"), - new ActualDetail(target, "number ", target, " is less than ", minimum))); - if(target.compare(maximum) > 0) return failWith(new JsonSchemaException( - new ErrorDetail(RANG02, "Number is outside of range"), - new ExpectedDetail(function, "number in range [", minimum, ", ", maximum, "]"), - new ActualDetail(target, "number ", target, " is greater than ", maximum))); - return true; - } - - public boolean range(JNumber target, JNumber minimum, JUndefined undefined) { - if(target.compare(minimum) < 0) return failWith(new JsonSchemaException( - new ErrorDetail(RANG03, "Number is outside of range"), - new ExpectedDetail(function, "number in range [", minimum, ", ", undefined, "]"), - new ActualDetail(target, "number ", target, " is less than ", minimum))); - return true; - } - - public boolean range(JNumber target, JUndefined undefined, JNumber maximum) { - if(target.compare(maximum) > 0) return failWith(new JsonSchemaException( - new ErrorDetail(RANG04, "Number is outside of range"), - new ExpectedDetail(function, "number in range [", undefined, ", ", maximum, "]"), - new ActualDetail(target, "number ", target, " is greater than ", maximum))); - return true; - } - - public boolean nonempty(JString target) { - var length = target.getValue().length(); - if(length <= 0) return failWith(new JsonSchemaException( - new ErrorDetail(NEMT01, "String is empty"), - new ExpectedDetail(function, "Non empty string"), - new ActualDetail(target, "found empty string"))); - return true; - } - - public boolean nonempty(JArray target) { - var length = target.getElements().size(); - if(length <= 0) return failWith(new JsonSchemaException( - new ErrorDetail(NEMT02, "Array is empty"), - new ExpectedDetail(function, "Non empty array"), - new ActualDetail(target, "found empty array"))); - return true; - } - - public boolean nonempty(JObject target) { - var length = target.getProperties().size(); - if(length <= 0) return failWith(new JsonSchemaException( - new ErrorDetail(NEMT03, "Object is empty"), - new ExpectedDetail(function, "Non empty object"), - new ActualDetail(target, "found empty object"))); - return true; - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/function/CoreFunctions3.java b/src/main/java/com/relogiclabs/json/schema/function/CoreFunctions3.java deleted file mode 100644 index 5a81ff9..0000000 --- a/src/main/java/com/relogiclabs/json/schema/function/CoreFunctions3.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.relogiclabs.json.schema.function; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.message.ActualDetail; -import com.relogiclabs.json.schema.message.ErrorDetail; -import com.relogiclabs.json.schema.message.ExpectedDetail; -import com.relogiclabs.json.schema.tree.RuntimeContext; -import com.relogiclabs.json.schema.type.JArray; -import com.relogiclabs.json.schema.type.JNode; -import com.relogiclabs.json.schema.type.JObject; -import com.relogiclabs.json.schema.type.JString; - -import java.net.URI; -import java.util.Arrays; -import java.util.regex.Pattern; - -import static com.relogiclabs.json.schema.internal.util.CollectionHelper.containsKeys; -import static com.relogiclabs.json.schema.internal.util.CollectionHelper.containsValues; -import static com.relogiclabs.json.schema.internal.util.StreamHelper.count; -import static com.relogiclabs.json.schema.internal.util.StringHelper.quote; -import static com.relogiclabs.json.schema.message.ErrorCode.ELEM01; -import static com.relogiclabs.json.schema.message.ErrorCode.EMAL01; -import static com.relogiclabs.json.schema.message.ErrorCode.KEYS01; -import static com.relogiclabs.json.schema.message.ErrorCode.PHON01; -import static com.relogiclabs.json.schema.message.ErrorCode.REGX01; -import static com.relogiclabs.json.schema.message.ErrorCode.URLA01; -import static com.relogiclabs.json.schema.message.ErrorCode.URLA02; -import static com.relogiclabs.json.schema.message.ErrorCode.URLA03; -import static com.relogiclabs.json.schema.message.ErrorCode.URLA04; -import static com.relogiclabs.json.schema.message.ErrorCode.VALU01; - -public class CoreFunctions3 extends CoreFunctions2 { - private static final String URI_SCHEME_HTTPS = "https"; - private static final String URI_SCHEME_HTTP = "http"; - - private static final Pattern EMAIL_REGEX - = Pattern.compile("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}"); - private static final Pattern PHONE_REGEX - = Pattern.compile("\\+?[0-9 ()-]+"); - - public CoreFunctions3(RuntimeContext runtime) { - super(runtime); - } - - public boolean elements(JArray target, JNode... items) { - return count(Arrays.stream(items) - .filter(n -> !target.getElements().contains(n)) - .map(n -> failOnElement(target, n))) == 0; - } - - private boolean failOnElement(JArray target, JNode node) { - return failWith(new JsonSchemaException( - new ErrorDetail(ELEM01, "Value is not an element of array"), - new ExpectedDetail(function, "array with value ", node), - new ActualDetail(target, "not found in ", target.getOutline()))); - } - - public boolean keys(JObject target, JString... items) { - return count(containsKeys(target.getProperties(), items) - .stream().map(s -> failOnKey(target, s))) == 0; - } - - private boolean failOnKey(JObject target, String string) { - return failWith(new JsonSchemaException( - new ErrorDetail(KEYS01, "Object does not contain the key"), - new ExpectedDetail(function, "object with key ", quote(string)), - new ActualDetail(target, "does not contain in ", target.getOutline()))); - } - - public boolean values(JObject target, JNode... items) { - return count(containsValues(target.getProperties(), items) - .stream().map(n -> failOnValue(target, n))) == 0; - } - - private boolean failOnValue(JObject target, JNode node) { - return failWith(new JsonSchemaException( - new ErrorDetail(VALU01, "Object does not contain the value"), - new ExpectedDetail(function, "object with value ", node), - new ActualDetail(target, "does not contain in ", target.getOutline()))); - } - - public boolean regex(JString target, JString pattern) { - if(!Pattern.matches(pattern.getValue(), target.getValue())) - return failWith(new JsonSchemaException( - new ErrorDetail(REGX01, "Regex pattern does not match"), - new ExpectedDetail(function, "string of pattern ", pattern.getOutline()), - new ActualDetail(target, "found ", target.getOutline(), - " that mismatches with pattern"))); - return true; - } - - public boolean email(JString target) { - // Based on SMTP protocol RFC 5322 - if(!EMAIL_REGEX.matcher(target.getValue()).matches()) - return failWith(new JsonSchemaException( - new ErrorDetail(EMAL01, "Invalid email address"), - new ExpectedDetail(function, "a valid email address"), - new ActualDetail(target, "found ", target, " that is invalid"))); - return true; - } - - public boolean url(JString target) { - boolean result; - URI uri; - try { - uri = new URI(target.getValue()); - result = switch(uri.getScheme()) { - case URI_SCHEME_HTTP, URI_SCHEME_HTTPS -> true; - default -> false; - }; - } catch (Exception e) { - return failWith(new JsonSchemaException( - new ErrorDetail(URLA01, "Invalid url address"), - new ExpectedDetail(function, "a valid url address"), - new ActualDetail(target, "found ", target, " that is invalid"))); - } - if(!result) return failWith(new JsonSchemaException( - new ErrorDetail(URLA02, "Invalid url address scheme"), - new ExpectedDetail(function, "HTTP or HTTPS scheme"), - new ActualDetail(target, "found ", quote(uri.getScheme()), " from ", - target, " that has invalid scheme"))); - return true; - } - - public boolean url(JString target, JString scheme) { - boolean result; - URI uri; - try { - uri = new URI(target.getValue()); - } catch (Exception e) { - return failWith(new JsonSchemaException( - new ErrorDetail(URLA03, "Invalid url address"), - new ExpectedDetail(function, "a valid url address"), - new ActualDetail(target, "found ", target, " that is invalid"))); - } - result = scheme.getValue().equals(uri.getScheme()); - if(!result) return failWith(new JsonSchemaException( - new ErrorDetail(URLA04, "Mismatch url address scheme"), - new ExpectedDetail(function, "scheme ", scheme, " for url address"), - new ActualDetail(target, "found ", quote(uri.getScheme()), " from ", - target, " that does not matched"))); - return true; - } - - public boolean phone(JString target) { - // Based on ITU-T E.163 and E.164 (extended) - if(!PHONE_REGEX.matcher(target.getValue()).matches()) - return failWith(new JsonSchemaException( - new ErrorDetail(PHON01, "Invalid phone number format"), - new ExpectedDetail(function, "a valid phone number"), - new ActualDetail(target, "found ", target, " that is invalid"))); - return true; - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/function/CoreFunctions4.java b/src/main/java/com/relogiclabs/json/schema/function/CoreFunctions4.java deleted file mode 100644 index 7ac2c10..0000000 --- a/src/main/java/com/relogiclabs/json/schema/function/CoreFunctions4.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.relogiclabs.json.schema.function; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.internal.function.DateTimeAgent; -import com.relogiclabs.json.schema.internal.time.DateTimeParser; -import com.relogiclabs.json.schema.message.ActualDetail; -import com.relogiclabs.json.schema.message.ErrorDetail; -import com.relogiclabs.json.schema.message.ExpectedDetail; -import com.relogiclabs.json.schema.time.DateTimeType; -import com.relogiclabs.json.schema.tree.RuntimeContext; -import com.relogiclabs.json.schema.type.JDateTime; -import com.relogiclabs.json.schema.type.JString; -import com.relogiclabs.json.schema.type.JUndefined; - -import static com.relogiclabs.json.schema.message.ErrorCode.AFTR01; -import static com.relogiclabs.json.schema.message.ErrorCode.AFTR02; -import static com.relogiclabs.json.schema.message.ErrorCode.BFOR01; -import static com.relogiclabs.json.schema.message.ErrorCode.BFOR02; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG01; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG02; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG03; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG04; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG05; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG06; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG07; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG08; -import static com.relogiclabs.json.schema.message.ErrorCode.ENDE01; -import static com.relogiclabs.json.schema.message.ErrorCode.ENDE02; -import static com.relogiclabs.json.schema.message.ErrorCode.STRT01; -import static com.relogiclabs.json.schema.message.ErrorCode.STRT02; -import static com.relogiclabs.json.schema.time.DateTimeType.DATE_TYPE; - -public class CoreFunctions4 extends CoreFunctions3 { - public CoreFunctions4(RuntimeContext runtime) { - super(runtime); - } - - public boolean date(JString target, JString pattern) { - return dateTime(target, pattern, DATE_TYPE); - } - - public boolean time(JString target, JString pattern) { - return dateTime(target, pattern, DateTimeType.TIME_TYPE); - } - - private boolean dateTime(JString target, JString pattern, DateTimeType type) { - return new DateTimeAgent(pattern.getValue(), type).parse(function, target) != null; - } - - public boolean before(JDateTime target, JString reference) { - var dateTime = getDateTime(target.getDateTimeParser(), reference); - if(dateTime == null) return false; - if(target.getDateTime().compare(dateTime.getDateTime()) < 0) return true; - var type = target.getDateTime().getType(); - var code = type == DATE_TYPE ? BFOR01 : BFOR02; - return failWith(new JsonSchemaException( - new ErrorDetail(code, type, " is not earlier than specified"), - new ExpectedDetail(reference, "a ", type, " before ", reference), - new ActualDetail(target, "found ", target, " which is not inside limit") - )); - } - - public boolean after(JDateTime target, JString reference) { - var dateTime = getDateTime(target.getDateTimeParser(), reference); - if(dateTime == null) return false; - if(target.getDateTime().compare(dateTime.getDateTime()) > 0) return true; - var type = target.getDateTime().getType(); - var code = type == DATE_TYPE ? AFTR01 : AFTR02; - return failWith(new JsonSchemaException( - new ErrorDetail(code, type, " is not later than specified"), - new ExpectedDetail(reference, "a ", type, " after ", reference), - new ActualDetail(target, "found ", target, " which is not inside limit") - )); - } - - public boolean range(JDateTime target, JString start, JString end) { - var rStart = getDateTime(target.getDateTimeParser(), start); - if(rStart == null) return false; - var rEnd = getDateTime(target.getDateTimeParser(), end); - if(rEnd == null) return false; - if(target.getDateTime().compare(rStart.getDateTime()) < 0) - return failOnStartDate(target, rStart, getErrorCode(target, DRNG01, DRNG02)); - if(target.getDateTime().compare(rEnd.getDateTime()) > 0) - return failOnEndDate(target, rEnd, getErrorCode(target, DRNG03, DRNG04)); - return true; - } - - private static String getErrorCode(JDateTime target, String date, String time) { - return target.getDateTime().getType() == DATE_TYPE ? date : time; - } - - private boolean failOnStartDate(JDateTime target, JDateTime start, String code) { - var type = target.getDateTime().getType(); - return failWith(new JsonSchemaException( - new ErrorDetail(code, type, " is earlier than start ", type), - new ExpectedDetail(start, "a ", type, " from or after ", start), - new ActualDetail(target, "found ", target, " which is before start ", type) - )); - } - - private boolean failOnEndDate(JDateTime target, JDateTime end, String code) { - var type = target.getDateTime().getType(); - return failWith(new JsonSchemaException( - new ErrorDetail(code, type, " is later than end ", type), - new ExpectedDetail(end, "a ", type, " until or before ", end), - new ActualDetail(target, "found ", target, " which is after end ", type) - )); - } - - public boolean range(JDateTime target, JUndefined start, JString end) { - var rEnd = getDateTime(target.getDateTimeParser(), end); - if(rEnd == null) return false; - if (target.getDateTime().compare(rEnd.getDateTime()) <= 0) return true; - return failOnEndDate(target, rEnd, getErrorCode(target, DRNG05, DRNG06)); - } - - public boolean range(JDateTime target, JString start, JUndefined end) { - var rStart = getDateTime(target.getDateTimeParser(), start); - if(rStart == null) return false; - if (target.getDateTime().compare(rStart.getDateTime()) >= 0) return true; - return failOnStartDate(target, rStart, getErrorCode(target, DRNG07, DRNG08)); - } - - public boolean start(JDateTime target, JString reference) { - var dateTime = getDateTime(target.getDateTimeParser(), reference); - if(dateTime == null) return false; - if(target.getDateTime().compare(dateTime.getDateTime()) < 0) { - var type = target.getDateTime().getType(); - var code = type == DATE_TYPE ? STRT01 : STRT02; - return failWith(new JsonSchemaException( - new ErrorDetail(code, type, " is earlier than specified"), - new ExpectedDetail(dateTime, "a ", type, " from or after ", dateTime), - new ActualDetail(target, "found ", target, " which is before limit") - )); - } - return true; - } - - public boolean end(JDateTime target, JString reference) { - var dateTime = getDateTime(target.getDateTimeParser(), reference); - if(dateTime == null) return false; - if(target.getDateTime().compare(dateTime.getDateTime()) > 0) { - var type = target.getDateTime().getType(); - var code = type == DATE_TYPE ? ENDE01 : ENDE02; - return failWith(new JsonSchemaException( - new ErrorDetail(code, type, " is later than specified"), - new ExpectedDetail(dateTime, "a ", type, " until or before ", dateTime), - new ActualDetail(target, "found ", target, " which is after limit") - )); - } - return true; - } - - private JDateTime getDateTime(DateTimeParser parser, JString dateTime) { - if(dateTime.getDerived() instanceof JDateTime result - && result.getDateTime().getType() == parser.getType()) return result; - var jDateTime = new DateTimeAgent(parser).parse(function, dateTime); - if(jDateTime == null) return null; - dateTime.setDerived(jDateTime.createNode(dateTime)); - return (JDateTime) dateTime.getDerived(); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/function/FutureValidator.java b/src/main/java/com/relogiclabs/json/schema/function/FutureValidator.java deleted file mode 100644 index 25de656..0000000 --- a/src/main/java/com/relogiclabs/json/schema/function/FutureValidator.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.relogiclabs.json.schema.function; - -@FunctionalInterface -public interface FutureValidator { - boolean validate(); -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/DateTimeLexer.interp b/src/main/java/com/relogiclabs/json/schema/internal/antlr/DateTimeLexer.interp deleted file mode 100644 index 5e85dd7..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/DateTimeLexer.interp +++ /dev/null @@ -1,110 +0,0 @@ -token literal names: -null -'G' -'YYYY' -'YY' -'MMMM' -'MMM' -'MM' -'M' -'DDDD' -'DDD' -'DD' -'D' -'t' -'hh' -'h' -'mm' -'m' -'ss' -'s' -'ffffff' -'fffff' -'ffff' -'fff' -'ff' -'f' -'F' -'ZZZ' -'ZZ' -'Z' -null -null -null - -token symbolic names: -null -ERA -YEAR_NUMBER4 -YEAR_NUMBER2 -MONTH_NAME -MONTH_SHORT_NAME -MONTH_NUMBER2 -MONTH_NUMBER -WEEKDAY_NAME -WEEKDAY_SHORT_NAME -DAY_NUMBER2 -DAY_NUMBER -CLOCK_AM_PM -HOUR_NUMBER2 -HOUR_NUMBER -MINUTE_NUMBER2 -MINUTE_NUMBER -SECOND_NUMBER2 -SECOND_NUMBER -FRACTION_NUMBER6 -FRACTION_NUMBER5 -FRACTION_NUMBER4 -FRACTION_NUMBER3 -FRACTION_NUMBER2 -FRACTION_NUMBER1 -FRACTION_NUMBER -UTC_OFFSET_TIME2 -UTC_OFFSET_TIME1 -UTC_OFFSET_HOUR -SYMBOL -WHITESPACE -TEXT - -rule names: -ERA -YEAR_NUMBER4 -YEAR_NUMBER2 -MONTH_NAME -MONTH_SHORT_NAME -MONTH_NUMBER2 -MONTH_NUMBER -WEEKDAY_NAME -WEEKDAY_SHORT_NAME -DAY_NUMBER2 -DAY_NUMBER -CLOCK_AM_PM -HOUR_NUMBER2 -HOUR_NUMBER -MINUTE_NUMBER2 -MINUTE_NUMBER -SECOND_NUMBER2 -SECOND_NUMBER -FRACTION_NUMBER6 -FRACTION_NUMBER5 -FRACTION_NUMBER4 -FRACTION_NUMBER3 -FRACTION_NUMBER2 -FRACTION_NUMBER1 -FRACTION_NUMBER -UTC_OFFSET_TIME2 -UTC_OFFSET_TIME1 -UTC_OFFSET_HOUR -SYMBOL -WHITESPACE -TEXT - -channel names: -DEFAULT_TOKEN_CHANNEL -HIDDEN - -mode names: -DEFAULT_MODE - -atn: -[4, 0, 31, 177, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 4, 28, 158, 8, 28, 11, 28, 12, 28, 159, 1, 29, 4, 29, 163, 8, 29, 11, 29, 12, 29, 164, 1, 30, 1, 30, 1, 30, 1, 30, 5, 30, 171, 8, 30, 10, 30, 12, 30, 174, 9, 30, 1, 30, 1, 30, 0, 0, 31, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 1, 0, 3, 4, 0, 33, 47, 58, 64, 91, 96, 123, 126, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 39, 39, 180, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 1, 63, 1, 0, 0, 0, 3, 65, 1, 0, 0, 0, 5, 70, 1, 0, 0, 0, 7, 73, 1, 0, 0, 0, 9, 78, 1, 0, 0, 0, 11, 82, 1, 0, 0, 0, 13, 85, 1, 0, 0, 0, 15, 87, 1, 0, 0, 0, 17, 92, 1, 0, 0, 0, 19, 96, 1, 0, 0, 0, 21, 99, 1, 0, 0, 0, 23, 101, 1, 0, 0, 0, 25, 103, 1, 0, 0, 0, 27, 106, 1, 0, 0, 0, 29, 108, 1, 0, 0, 0, 31, 111, 1, 0, 0, 0, 33, 113, 1, 0, 0, 0, 35, 116, 1, 0, 0, 0, 37, 118, 1, 0, 0, 0, 39, 125, 1, 0, 0, 0, 41, 131, 1, 0, 0, 0, 43, 136, 1, 0, 0, 0, 45, 140, 1, 0, 0, 0, 47, 143, 1, 0, 0, 0, 49, 145, 1, 0, 0, 0, 51, 147, 1, 0, 0, 0, 53, 151, 1, 0, 0, 0, 55, 154, 1, 0, 0, 0, 57, 157, 1, 0, 0, 0, 59, 162, 1, 0, 0, 0, 61, 166, 1, 0, 0, 0, 63, 64, 5, 71, 0, 0, 64, 2, 1, 0, 0, 0, 65, 66, 5, 89, 0, 0, 66, 67, 5, 89, 0, 0, 67, 68, 5, 89, 0, 0, 68, 69, 5, 89, 0, 0, 69, 4, 1, 0, 0, 0, 70, 71, 5, 89, 0, 0, 71, 72, 5, 89, 0, 0, 72, 6, 1, 0, 0, 0, 73, 74, 5, 77, 0, 0, 74, 75, 5, 77, 0, 0, 75, 76, 5, 77, 0, 0, 76, 77, 5, 77, 0, 0, 77, 8, 1, 0, 0, 0, 78, 79, 5, 77, 0, 0, 79, 80, 5, 77, 0, 0, 80, 81, 5, 77, 0, 0, 81, 10, 1, 0, 0, 0, 82, 83, 5, 77, 0, 0, 83, 84, 5, 77, 0, 0, 84, 12, 1, 0, 0, 0, 85, 86, 5, 77, 0, 0, 86, 14, 1, 0, 0, 0, 87, 88, 5, 68, 0, 0, 88, 89, 5, 68, 0, 0, 89, 90, 5, 68, 0, 0, 90, 91, 5, 68, 0, 0, 91, 16, 1, 0, 0, 0, 92, 93, 5, 68, 0, 0, 93, 94, 5, 68, 0, 0, 94, 95, 5, 68, 0, 0, 95, 18, 1, 0, 0, 0, 96, 97, 5, 68, 0, 0, 97, 98, 5, 68, 0, 0, 98, 20, 1, 0, 0, 0, 99, 100, 5, 68, 0, 0, 100, 22, 1, 0, 0, 0, 101, 102, 5, 116, 0, 0, 102, 24, 1, 0, 0, 0, 103, 104, 5, 104, 0, 0, 104, 105, 5, 104, 0, 0, 105, 26, 1, 0, 0, 0, 106, 107, 5, 104, 0, 0, 107, 28, 1, 0, 0, 0, 108, 109, 5, 109, 0, 0, 109, 110, 5, 109, 0, 0, 110, 30, 1, 0, 0, 0, 111, 112, 5, 109, 0, 0, 112, 32, 1, 0, 0, 0, 113, 114, 5, 115, 0, 0, 114, 115, 5, 115, 0, 0, 115, 34, 1, 0, 0, 0, 116, 117, 5, 115, 0, 0, 117, 36, 1, 0, 0, 0, 118, 119, 5, 102, 0, 0, 119, 120, 5, 102, 0, 0, 120, 121, 5, 102, 0, 0, 121, 122, 5, 102, 0, 0, 122, 123, 5, 102, 0, 0, 123, 124, 5, 102, 0, 0, 124, 38, 1, 0, 0, 0, 125, 126, 5, 102, 0, 0, 126, 127, 5, 102, 0, 0, 127, 128, 5, 102, 0, 0, 128, 129, 5, 102, 0, 0, 129, 130, 5, 102, 0, 0, 130, 40, 1, 0, 0, 0, 131, 132, 5, 102, 0, 0, 132, 133, 5, 102, 0, 0, 133, 134, 5, 102, 0, 0, 134, 135, 5, 102, 0, 0, 135, 42, 1, 0, 0, 0, 136, 137, 5, 102, 0, 0, 137, 138, 5, 102, 0, 0, 138, 139, 5, 102, 0, 0, 139, 44, 1, 0, 0, 0, 140, 141, 5, 102, 0, 0, 141, 142, 5, 102, 0, 0, 142, 46, 1, 0, 0, 0, 143, 144, 5, 102, 0, 0, 144, 48, 1, 0, 0, 0, 145, 146, 5, 70, 0, 0, 146, 50, 1, 0, 0, 0, 147, 148, 5, 90, 0, 0, 148, 149, 5, 90, 0, 0, 149, 150, 5, 90, 0, 0, 150, 52, 1, 0, 0, 0, 151, 152, 5, 90, 0, 0, 152, 153, 5, 90, 0, 0, 153, 54, 1, 0, 0, 0, 154, 155, 5, 90, 0, 0, 155, 56, 1, 0, 0, 0, 156, 158, 7, 0, 0, 0, 157, 156, 1, 0, 0, 0, 158, 159, 1, 0, 0, 0, 159, 157, 1, 0, 0, 0, 159, 160, 1, 0, 0, 0, 160, 58, 1, 0, 0, 0, 161, 163, 7, 1, 0, 0, 162, 161, 1, 0, 0, 0, 163, 164, 1, 0, 0, 0, 164, 162, 1, 0, 0, 0, 164, 165, 1, 0, 0, 0, 165, 60, 1, 0, 0, 0, 166, 172, 5, 39, 0, 0, 167, 171, 8, 2, 0, 0, 168, 169, 5, 39, 0, 0, 169, 171, 5, 39, 0, 0, 170, 167, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 171, 174, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, 173, 175, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 175, 176, 5, 39, 0, 0, 176, 62, 1, 0, 0, 0, 5, 0, 159, 164, 170, 172, 0] \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/DateTimeLexer.java b/src/main/java/com/relogiclabs/json/schema/internal/antlr/DateTimeLexer.java deleted file mode 100644 index ee872ed..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/DateTimeLexer.java +++ /dev/null @@ -1,245 +0,0 @@ -package com.relogiclabs.json.schema.internal.antlr; - -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.Lexer; -import org.antlr.v4.runtime.RuntimeMetaData; -import org.antlr.v4.runtime.Vocabulary; -import org.antlr.v4.runtime.VocabularyImpl; -import org.antlr.v4.runtime.atn.ATN; -import org.antlr.v4.runtime.atn.ATNDeserializer; -import org.antlr.v4.runtime.atn.LexerATNSimulator; -import org.antlr.v4.runtime.atn.PredictionContextCache; -import org.antlr.v4.runtime.dfa.DFA; - -@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) -public class DateTimeLexer extends Lexer { - static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - ERA=1, YEAR_NUMBER4=2, YEAR_NUMBER2=3, MONTH_NAME=4, MONTH_SHORT_NAME=5, - MONTH_NUMBER2=6, MONTH_NUMBER=7, WEEKDAY_NAME=8, WEEKDAY_SHORT_NAME=9, - DAY_NUMBER2=10, DAY_NUMBER=11, CLOCK_AM_PM=12, HOUR_NUMBER2=13, HOUR_NUMBER=14, - MINUTE_NUMBER2=15, MINUTE_NUMBER=16, SECOND_NUMBER2=17, SECOND_NUMBER=18, - FRACTION_NUMBER6=19, FRACTION_NUMBER5=20, FRACTION_NUMBER4=21, FRACTION_NUMBER3=22, - FRACTION_NUMBER2=23, FRACTION_NUMBER1=24, FRACTION_NUMBER=25, UTC_OFFSET_TIME2=26, - UTC_OFFSET_TIME1=27, UTC_OFFSET_HOUR=28, SYMBOL=29, WHITESPACE=30, TEXT=31; - public static String[] channelNames = { - "DEFAULT_TOKEN_CHANNEL", "HIDDEN" - }; - - public static String[] modeNames = { - "DEFAULT_MODE" - }; - - private static String[] makeRuleNames() { - return new String[] { - "ERA", "YEAR_NUMBER4", "YEAR_NUMBER2", "MONTH_NAME", "MONTH_SHORT_NAME", - "MONTH_NUMBER2", "MONTH_NUMBER", "WEEKDAY_NAME", "WEEKDAY_SHORT_NAME", - "DAY_NUMBER2", "DAY_NUMBER", "CLOCK_AM_PM", "HOUR_NUMBER2", "HOUR_NUMBER", - "MINUTE_NUMBER2", "MINUTE_NUMBER", "SECOND_NUMBER2", "SECOND_NUMBER", - "FRACTION_NUMBER6", "FRACTION_NUMBER5", "FRACTION_NUMBER4", "FRACTION_NUMBER3", - "FRACTION_NUMBER2", "FRACTION_NUMBER1", "FRACTION_NUMBER", "UTC_OFFSET_TIME2", - "UTC_OFFSET_TIME1", "UTC_OFFSET_HOUR", "SYMBOL", "WHITESPACE", "TEXT" - }; - } - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[] { - null, "'G'", "'YYYY'", "'YY'", "'MMMM'", "'MMM'", "'MM'", "'M'", "'DDDD'", - "'DDD'", "'DD'", "'D'", "'t'", "'hh'", "'h'", "'mm'", "'m'", "'ss'", - "'s'", "'ffffff'", "'fffff'", "'ffff'", "'fff'", "'ff'", "'f'", "'F'", - "'ZZZ'", "'ZZ'", "'Z'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, "ERA", "YEAR_NUMBER4", "YEAR_NUMBER2", "MONTH_NAME", "MONTH_SHORT_NAME", - "MONTH_NUMBER2", "MONTH_NUMBER", "WEEKDAY_NAME", "WEEKDAY_SHORT_NAME", - "DAY_NUMBER2", "DAY_NUMBER", "CLOCK_AM_PM", "HOUR_NUMBER2", "HOUR_NUMBER", - "MINUTE_NUMBER2", "MINUTE_NUMBER", "SECOND_NUMBER2", "SECOND_NUMBER", - "FRACTION_NUMBER6", "FRACTION_NUMBER5", "FRACTION_NUMBER4", "FRACTION_NUMBER3", - "FRACTION_NUMBER2", "FRACTION_NUMBER1", "FRACTION_NUMBER", "UTC_OFFSET_TIME2", - "UTC_OFFSET_TIME1", "UTC_OFFSET_HOUR", "SYMBOL", "WHITESPACE", "TEXT" - }; - } - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - - public DateTimeLexer(CharStream input) { - super(input); - _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @Override - public String getGrammarFileName() { return "DateTimeLexer.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public String[] getChannelNames() { return channelNames; } - - @Override - public String[] getModeNames() { return modeNames; } - - @Override - public ATN getATN() { return _ATN; } - - public static final String _serializedATN = - "\u0004\u0000\u001f\u00b1\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002"+ - "\u0001\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002"+ - "\u0004\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002"+ - "\u0007\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002"+ - "\u000b\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e"+ - "\u0002\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011"+ - "\u0002\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014"+ - "\u0002\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017"+ - "\u0002\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a"+ - "\u0002\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d"+ - "\u0002\u001e\u0007\u001e\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0002"+ - "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0004"+ - "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005"+ - "\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ - "\u0001\u0007\u0001\b\u0001\b\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0001"+ - "\n\u0001\n\u0001\u000b\u0001\u000b\u0001\f\u0001\f\u0001\f\u0001\r\u0001"+ - "\r\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u0010"+ - "\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012"+ - "\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0013"+ - "\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0014"+ - "\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015"+ - "\u0001\u0015\u0001\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0017"+ - "\u0001\u0017\u0001\u0018\u0001\u0018\u0001\u0019\u0001\u0019\u0001\u0019"+ - "\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b"+ - "\u0001\u001c\u0004\u001c\u009e\b\u001c\u000b\u001c\f\u001c\u009f\u0001"+ - "\u001d\u0004\u001d\u00a3\b\u001d\u000b\u001d\f\u001d\u00a4\u0001\u001e"+ - "\u0001\u001e\u0001\u001e\u0001\u001e\u0005\u001e\u00ab\b\u001e\n\u001e"+ - "\f\u001e\u00ae\t\u001e\u0001\u001e\u0001\u001e\u0000\u0000\u001f\u0001"+ - "\u0001\u0003\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b\u0006\r\u0007"+ - "\u000f\b\u0011\t\u0013\n\u0015\u000b\u0017\f\u0019\r\u001b\u000e\u001d"+ - "\u000f\u001f\u0010!\u0011#\u0012%\u0013\'\u0014)\u0015+\u0016-\u0017/"+ - "\u00181\u00193\u001a5\u001b7\u001c9\u001d;\u001e=\u001f\u0001\u0000\u0003"+ - "\u0004\u0000!/:@[`{~\u0003\u0000\t\n\r\r \u0001\u0000\'\'\u00b4\u0000"+ - "\u0001\u0001\u0000\u0000\u0000\u0000\u0003\u0001\u0000\u0000\u0000\u0000"+ - "\u0005\u0001\u0000\u0000\u0000\u0000\u0007\u0001\u0000\u0000\u0000\u0000"+ - "\t\u0001\u0000\u0000\u0000\u0000\u000b\u0001\u0000\u0000\u0000\u0000\r"+ - "\u0001\u0000\u0000\u0000\u0000\u000f\u0001\u0000\u0000\u0000\u0000\u0011"+ - "\u0001\u0000\u0000\u0000\u0000\u0013\u0001\u0000\u0000\u0000\u0000\u0015"+ - "\u0001\u0000\u0000\u0000\u0000\u0017\u0001\u0000\u0000\u0000\u0000\u0019"+ - "\u0001\u0000\u0000\u0000\u0000\u001b\u0001\u0000\u0000\u0000\u0000\u001d"+ - "\u0001\u0000\u0000\u0000\u0000\u001f\u0001\u0000\u0000\u0000\u0000!\u0001"+ - "\u0000\u0000\u0000\u0000#\u0001\u0000\u0000\u0000\u0000%\u0001\u0000\u0000"+ - "\u0000\u0000\'\u0001\u0000\u0000\u0000\u0000)\u0001\u0000\u0000\u0000"+ - "\u0000+\u0001\u0000\u0000\u0000\u0000-\u0001\u0000\u0000\u0000\u0000/"+ - "\u0001\u0000\u0000\u0000\u00001\u0001\u0000\u0000\u0000\u00003\u0001\u0000"+ - "\u0000\u0000\u00005\u0001\u0000\u0000\u0000\u00007\u0001\u0000\u0000\u0000"+ - "\u00009\u0001\u0000\u0000\u0000\u0000;\u0001\u0000\u0000\u0000\u0000="+ - "\u0001\u0000\u0000\u0000\u0001?\u0001\u0000\u0000\u0000\u0003A\u0001\u0000"+ - "\u0000\u0000\u0005F\u0001\u0000\u0000\u0000\u0007I\u0001\u0000\u0000\u0000"+ - "\tN\u0001\u0000\u0000\u0000\u000bR\u0001\u0000\u0000\u0000\rU\u0001\u0000"+ - "\u0000\u0000\u000fW\u0001\u0000\u0000\u0000\u0011\\\u0001\u0000\u0000"+ - "\u0000\u0013`\u0001\u0000\u0000\u0000\u0015c\u0001\u0000\u0000\u0000\u0017"+ - "e\u0001\u0000\u0000\u0000\u0019g\u0001\u0000\u0000\u0000\u001bj\u0001"+ - "\u0000\u0000\u0000\u001dl\u0001\u0000\u0000\u0000\u001fo\u0001\u0000\u0000"+ - "\u0000!q\u0001\u0000\u0000\u0000#t\u0001\u0000\u0000\u0000%v\u0001\u0000"+ - "\u0000\u0000\'}\u0001\u0000\u0000\u0000)\u0083\u0001\u0000\u0000\u0000"+ - "+\u0088\u0001\u0000\u0000\u0000-\u008c\u0001\u0000\u0000\u0000/\u008f"+ - "\u0001\u0000\u0000\u00001\u0091\u0001\u0000\u0000\u00003\u0093\u0001\u0000"+ - "\u0000\u00005\u0097\u0001\u0000\u0000\u00007\u009a\u0001\u0000\u0000\u0000"+ - "9\u009d\u0001\u0000\u0000\u0000;\u00a2\u0001\u0000\u0000\u0000=\u00a6"+ - "\u0001\u0000\u0000\u0000?@\u0005G\u0000\u0000@\u0002\u0001\u0000\u0000"+ - "\u0000AB\u0005Y\u0000\u0000BC\u0005Y\u0000\u0000CD\u0005Y\u0000\u0000"+ - "DE\u0005Y\u0000\u0000E\u0004\u0001\u0000\u0000\u0000FG\u0005Y\u0000\u0000"+ - "GH\u0005Y\u0000\u0000H\u0006\u0001\u0000\u0000\u0000IJ\u0005M\u0000\u0000"+ - "JK\u0005M\u0000\u0000KL\u0005M\u0000\u0000LM\u0005M\u0000\u0000M\b\u0001"+ - "\u0000\u0000\u0000NO\u0005M\u0000\u0000OP\u0005M\u0000\u0000PQ\u0005M"+ - "\u0000\u0000Q\n\u0001\u0000\u0000\u0000RS\u0005M\u0000\u0000ST\u0005M"+ - "\u0000\u0000T\f\u0001\u0000\u0000\u0000UV\u0005M\u0000\u0000V\u000e\u0001"+ - "\u0000\u0000\u0000WX\u0005D\u0000\u0000XY\u0005D\u0000\u0000YZ\u0005D"+ - "\u0000\u0000Z[\u0005D\u0000\u0000[\u0010\u0001\u0000\u0000\u0000\\]\u0005"+ - "D\u0000\u0000]^\u0005D\u0000\u0000^_\u0005D\u0000\u0000_\u0012\u0001\u0000"+ - "\u0000\u0000`a\u0005D\u0000\u0000ab\u0005D\u0000\u0000b\u0014\u0001\u0000"+ - "\u0000\u0000cd\u0005D\u0000\u0000d\u0016\u0001\u0000\u0000\u0000ef\u0005"+ - "t\u0000\u0000f\u0018\u0001\u0000\u0000\u0000gh\u0005h\u0000\u0000hi\u0005"+ - "h\u0000\u0000i\u001a\u0001\u0000\u0000\u0000jk\u0005h\u0000\u0000k\u001c"+ - "\u0001\u0000\u0000\u0000lm\u0005m\u0000\u0000mn\u0005m\u0000\u0000n\u001e"+ - "\u0001\u0000\u0000\u0000op\u0005m\u0000\u0000p \u0001\u0000\u0000\u0000"+ - "qr\u0005s\u0000\u0000rs\u0005s\u0000\u0000s\"\u0001\u0000\u0000\u0000"+ - "tu\u0005s\u0000\u0000u$\u0001\u0000\u0000\u0000vw\u0005f\u0000\u0000w"+ - "x\u0005f\u0000\u0000xy\u0005f\u0000\u0000yz\u0005f\u0000\u0000z{\u0005"+ - "f\u0000\u0000{|\u0005f\u0000\u0000|&\u0001\u0000\u0000\u0000}~\u0005f"+ - "\u0000\u0000~\u007f\u0005f\u0000\u0000\u007f\u0080\u0005f\u0000\u0000"+ - "\u0080\u0081\u0005f\u0000\u0000\u0081\u0082\u0005f\u0000\u0000\u0082("+ - "\u0001\u0000\u0000\u0000\u0083\u0084\u0005f\u0000\u0000\u0084\u0085\u0005"+ - "f\u0000\u0000\u0085\u0086\u0005f\u0000\u0000\u0086\u0087\u0005f\u0000"+ - "\u0000\u0087*\u0001\u0000\u0000\u0000\u0088\u0089\u0005f\u0000\u0000\u0089"+ - "\u008a\u0005f\u0000\u0000\u008a\u008b\u0005f\u0000\u0000\u008b,\u0001"+ - "\u0000\u0000\u0000\u008c\u008d\u0005f\u0000\u0000\u008d\u008e\u0005f\u0000"+ - "\u0000\u008e.\u0001\u0000\u0000\u0000\u008f\u0090\u0005f\u0000\u0000\u0090"+ - "0\u0001\u0000\u0000\u0000\u0091\u0092\u0005F\u0000\u0000\u00922\u0001"+ - "\u0000\u0000\u0000\u0093\u0094\u0005Z\u0000\u0000\u0094\u0095\u0005Z\u0000"+ - "\u0000\u0095\u0096\u0005Z\u0000\u0000\u00964\u0001\u0000\u0000\u0000\u0097"+ - "\u0098\u0005Z\u0000\u0000\u0098\u0099\u0005Z\u0000\u0000\u00996\u0001"+ - "\u0000\u0000\u0000\u009a\u009b\u0005Z\u0000\u0000\u009b8\u0001\u0000\u0000"+ - "\u0000\u009c\u009e\u0007\u0000\u0000\u0000\u009d\u009c\u0001\u0000\u0000"+ - "\u0000\u009e\u009f\u0001\u0000\u0000\u0000\u009f\u009d\u0001\u0000\u0000"+ - "\u0000\u009f\u00a0\u0001\u0000\u0000\u0000\u00a0:\u0001\u0000\u0000\u0000"+ - "\u00a1\u00a3\u0007\u0001\u0000\u0000\u00a2\u00a1\u0001\u0000\u0000\u0000"+ - "\u00a3\u00a4\u0001\u0000\u0000\u0000\u00a4\u00a2\u0001\u0000\u0000\u0000"+ - "\u00a4\u00a5\u0001\u0000\u0000\u0000\u00a5<\u0001\u0000\u0000\u0000\u00a6"+ - "\u00ac\u0005\'\u0000\u0000\u00a7\u00ab\b\u0002\u0000\u0000\u00a8\u00a9"+ - "\u0005\'\u0000\u0000\u00a9\u00ab\u0005\'\u0000\u0000\u00aa\u00a7\u0001"+ - "\u0000\u0000\u0000\u00aa\u00a8\u0001\u0000\u0000\u0000\u00ab\u00ae\u0001"+ - "\u0000\u0000\u0000\u00ac\u00aa\u0001\u0000\u0000\u0000\u00ac\u00ad\u0001"+ - "\u0000\u0000\u0000\u00ad\u00af\u0001\u0000\u0000\u0000\u00ae\u00ac\u0001"+ - "\u0000\u0000\u0000\u00af\u00b0\u0005\'\u0000\u0000\u00b0>\u0001\u0000"+ - "\u0000\u0000\u0005\u0000\u009f\u00a4\u00aa\u00ac\u0000"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonLexer.interp b/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonLexer.interp deleted file mode 100644 index 0cf649b..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonLexer.interp +++ /dev/null @@ -1,66 +0,0 @@ -token literal names: -null -'true' -'false' -'null' -'[' -']' -'{' -'}' -',' -':' -null -null -null -null -null - -token symbolic names: -null -TRUE -FALSE -NULL -LBRACKET -RBRACKET -LBRACE -RBRACE -COMMA -COLON -STRING -INTEGER -FLOAT -DOUBLE -WHITE_SPACE - -rule names: -TRUE -FALSE -NULL -LBRACKET -RBRACKET -LBRACE -RBRACE -COMMA -COLON -STRING -ESCAPE -UNICODE -HEXDIGIT -SAFECODEPOINT -INTEGER -FLOAT -DOUBLE -INTDIGIT -EXPONENT -DIGIT -WHITE_SPACE - -channel names: -DEFAULT_TOKEN_CHANNEL -HIDDEN - -mode names: -DEFAULT_MODE - -atn: -[4, 0, 14, 147, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 5, 9, 75, 8, 9, 10, 9, 12, 9, 78, 9, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 3, 10, 85, 8, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 3, 14, 98, 8, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 4, 15, 105, 8, 15, 11, 15, 12, 15, 106, 1, 16, 1, 16, 1, 16, 4, 16, 112, 8, 16, 11, 16, 12, 16, 113, 3, 16, 116, 8, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 5, 17, 123, 8, 17, 10, 17, 12, 17, 126, 9, 17, 3, 17, 128, 8, 17, 1, 18, 1, 18, 3, 18, 132, 8, 18, 1, 18, 4, 18, 135, 8, 18, 11, 18, 12, 18, 136, 1, 19, 1, 19, 1, 20, 4, 20, 142, 8, 20, 11, 20, 12, 20, 143, 1, 20, 1, 20, 0, 0, 21, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 0, 23, 0, 25, 0, 27, 0, 29, 11, 31, 12, 33, 13, 35, 0, 37, 0, 39, 0, 41, 14, 1, 0, 8, 8, 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 0, 31, 34, 34, 92, 92, 1, 0, 49, 57, 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 1, 0, 48, 57, 3, 0, 9, 10, 13, 13, 32, 32, 151, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 1, 43, 1, 0, 0, 0, 3, 48, 1, 0, 0, 0, 5, 54, 1, 0, 0, 0, 7, 59, 1, 0, 0, 0, 9, 61, 1, 0, 0, 0, 11, 63, 1, 0, 0, 0, 13, 65, 1, 0, 0, 0, 15, 67, 1, 0, 0, 0, 17, 69, 1, 0, 0, 0, 19, 71, 1, 0, 0, 0, 21, 81, 1, 0, 0, 0, 23, 86, 1, 0, 0, 0, 25, 92, 1, 0, 0, 0, 27, 94, 1, 0, 0, 0, 29, 97, 1, 0, 0, 0, 31, 101, 1, 0, 0, 0, 33, 108, 1, 0, 0, 0, 35, 127, 1, 0, 0, 0, 37, 129, 1, 0, 0, 0, 39, 138, 1, 0, 0, 0, 41, 141, 1, 0, 0, 0, 43, 44, 5, 116, 0, 0, 44, 45, 5, 114, 0, 0, 45, 46, 5, 117, 0, 0, 46, 47, 5, 101, 0, 0, 47, 2, 1, 0, 0, 0, 48, 49, 5, 102, 0, 0, 49, 50, 5, 97, 0, 0, 50, 51, 5, 108, 0, 0, 51, 52, 5, 115, 0, 0, 52, 53, 5, 101, 0, 0, 53, 4, 1, 0, 0, 0, 54, 55, 5, 110, 0, 0, 55, 56, 5, 117, 0, 0, 56, 57, 5, 108, 0, 0, 57, 58, 5, 108, 0, 0, 58, 6, 1, 0, 0, 0, 59, 60, 5, 91, 0, 0, 60, 8, 1, 0, 0, 0, 61, 62, 5, 93, 0, 0, 62, 10, 1, 0, 0, 0, 63, 64, 5, 123, 0, 0, 64, 12, 1, 0, 0, 0, 65, 66, 5, 125, 0, 0, 66, 14, 1, 0, 0, 0, 67, 68, 5, 44, 0, 0, 68, 16, 1, 0, 0, 0, 69, 70, 5, 58, 0, 0, 70, 18, 1, 0, 0, 0, 71, 76, 5, 34, 0, 0, 72, 75, 3, 21, 10, 0, 73, 75, 3, 27, 13, 0, 74, 72, 1, 0, 0, 0, 74, 73, 1, 0, 0, 0, 75, 78, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 79, 1, 0, 0, 0, 78, 76, 1, 0, 0, 0, 79, 80, 5, 34, 0, 0, 80, 20, 1, 0, 0, 0, 81, 84, 5, 92, 0, 0, 82, 85, 7, 0, 0, 0, 83, 85, 3, 23, 11, 0, 84, 82, 1, 0, 0, 0, 84, 83, 1, 0, 0, 0, 85, 22, 1, 0, 0, 0, 86, 87, 5, 117, 0, 0, 87, 88, 3, 25, 12, 0, 88, 89, 3, 25, 12, 0, 89, 90, 3, 25, 12, 0, 90, 91, 3, 25, 12, 0, 91, 24, 1, 0, 0, 0, 92, 93, 7, 1, 0, 0, 93, 26, 1, 0, 0, 0, 94, 95, 8, 2, 0, 0, 95, 28, 1, 0, 0, 0, 96, 98, 5, 45, 0, 0, 97, 96, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 99, 1, 0, 0, 0, 99, 100, 3, 35, 17, 0, 100, 30, 1, 0, 0, 0, 101, 102, 3, 29, 14, 0, 102, 104, 5, 46, 0, 0, 103, 105, 3, 39, 19, 0, 104, 103, 1, 0, 0, 0, 105, 106, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 106, 107, 1, 0, 0, 0, 107, 32, 1, 0, 0, 0, 108, 115, 3, 29, 14, 0, 109, 111, 5, 46, 0, 0, 110, 112, 3, 39, 19, 0, 111, 110, 1, 0, 0, 0, 112, 113, 1, 0, 0, 0, 113, 111, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 116, 1, 0, 0, 0, 115, 109, 1, 0, 0, 0, 115, 116, 1, 0, 0, 0, 116, 117, 1, 0, 0, 0, 117, 118, 3, 37, 18, 0, 118, 34, 1, 0, 0, 0, 119, 128, 5, 48, 0, 0, 120, 124, 7, 3, 0, 0, 121, 123, 3, 39, 19, 0, 122, 121, 1, 0, 0, 0, 123, 126, 1, 0, 0, 0, 124, 122, 1, 0, 0, 0, 124, 125, 1, 0, 0, 0, 125, 128, 1, 0, 0, 0, 126, 124, 1, 0, 0, 0, 127, 119, 1, 0, 0, 0, 127, 120, 1, 0, 0, 0, 128, 36, 1, 0, 0, 0, 129, 131, 7, 4, 0, 0, 130, 132, 7, 5, 0, 0, 131, 130, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 134, 1, 0, 0, 0, 133, 135, 3, 39, 19, 0, 134, 133, 1, 0, 0, 0, 135, 136, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 136, 137, 1, 0, 0, 0, 137, 38, 1, 0, 0, 0, 138, 139, 7, 6, 0, 0, 139, 40, 1, 0, 0, 0, 140, 142, 7, 7, 0, 0, 141, 140, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 141, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 144, 145, 1, 0, 0, 0, 145, 146, 6, 20, 0, 0, 146, 42, 1, 0, 0, 0, 13, 0, 74, 76, 84, 97, 106, 113, 115, 124, 127, 131, 136, 143, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonLexer.java b/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonLexer.java deleted file mode 100644 index 6c3baaf..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonLexer.java +++ /dev/null @@ -1,210 +0,0 @@ -package com.relogiclabs.json.schema.internal.antlr; - -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.Lexer; -import org.antlr.v4.runtime.RuntimeMetaData; -import org.antlr.v4.runtime.Vocabulary; -import org.antlr.v4.runtime.VocabularyImpl; -import org.antlr.v4.runtime.atn.ATN; -import org.antlr.v4.runtime.atn.ATNDeserializer; -import org.antlr.v4.runtime.atn.LexerATNSimulator; -import org.antlr.v4.runtime.atn.PredictionContextCache; -import org.antlr.v4.runtime.dfa.DFA; - -@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) -public class JsonLexer extends Lexer { - static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - TRUE=1, FALSE=2, NULL=3, LBRACKET=4, RBRACKET=5, LBRACE=6, RBRACE=7, COMMA=8, - COLON=9, STRING=10, INTEGER=11, FLOAT=12, DOUBLE=13, WHITE_SPACE=14; - public static String[] channelNames = { - "DEFAULT_TOKEN_CHANNEL", "HIDDEN" - }; - - public static String[] modeNames = { - "DEFAULT_MODE" - }; - - private static String[] makeRuleNames() { - return new String[] { - "TRUE", "FALSE", "NULL", "LBRACKET", "RBRACKET", "LBRACE", "RBRACE", - "COMMA", "COLON", "STRING", "ESCAPE", "UNICODE", "HEXDIGIT", "SAFECODEPOINT", - "INTEGER", "FLOAT", "DOUBLE", "INTDIGIT", "EXPONENT", "DIGIT", "WHITE_SPACE" - }; - } - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[] { - null, "'true'", "'false'", "'null'", "'['", "']'", "'{'", "'}'", "','", - "':'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, "TRUE", "FALSE", "NULL", "LBRACKET", "RBRACKET", "LBRACE", "RBRACE", - "COMMA", "COLON", "STRING", "INTEGER", "FLOAT", "DOUBLE", "WHITE_SPACE" - }; - } - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - - public JsonLexer(CharStream input) { - super(input); - _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @Override - public String getGrammarFileName() { return "JsonLexer.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public String[] getChannelNames() { return channelNames; } - - @Override - public String[] getModeNames() { return modeNames; } - - @Override - public ATN getATN() { return _ATN; } - - public static final String _serializedATN = - "\u0004\u0000\u000e\u0093\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002"+ - "\u0001\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002"+ - "\u0004\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002"+ - "\u0007\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002"+ - "\u000b\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e"+ - "\u0002\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011"+ - "\u0002\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014"+ - "\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002"+ - "\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+ - "\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006"+ - "\u0001\u0007\u0001\u0007\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0005"+ - "\tK\b\t\n\t\f\tN\t\t\u0001\t\u0001\t\u0001\n\u0001\n\u0001\n\u0003\nU"+ - "\b\n\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001"+ - "\u000b\u0001\f\u0001\f\u0001\r\u0001\r\u0001\u000e\u0003\u000eb\b\u000e"+ - "\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u000f\u0004\u000f"+ - "i\b\u000f\u000b\u000f\f\u000fj\u0001\u0010\u0001\u0010\u0001\u0010\u0004"+ - "\u0010p\b\u0010\u000b\u0010\f\u0010q\u0003\u0010t\b\u0010\u0001\u0010"+ - "\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0011\u0005\u0011{\b\u0011"+ - "\n\u0011\f\u0011~\t\u0011\u0003\u0011\u0080\b\u0011\u0001\u0012\u0001"+ - "\u0012\u0003\u0012\u0084\b\u0012\u0001\u0012\u0004\u0012\u0087\b\u0012"+ - "\u000b\u0012\f\u0012\u0088\u0001\u0013\u0001\u0013\u0001\u0014\u0004\u0014"+ - "\u008e\b\u0014\u000b\u0014\f\u0014\u008f\u0001\u0014\u0001\u0014\u0000"+ - "\u0000\u0015\u0001\u0001\u0003\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b"+ - "\u0006\r\u0007\u000f\b\u0011\t\u0013\n\u0015\u0000\u0017\u0000\u0019\u0000"+ - "\u001b\u0000\u001d\u000b\u001f\f!\r#\u0000%\u0000\'\u0000)\u000e\u0001"+ - "\u0000\b\b\u0000\"\"//\\\\bbffnnrrtt\u0003\u000009AFaf\u0003\u0000\u0000"+ - "\u001f\"\"\\\\\u0001\u000019\u0002\u0000EEee\u0002\u0000++--\u0001\u0000"+ - "09\u0003\u0000\t\n\r\r \u0097\u0000\u0001\u0001\u0000\u0000\u0000\u0000"+ - "\u0003\u0001\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0000"+ - "\u0007\u0001\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0000\u000b"+ - "\u0001\u0000\u0000\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000\u000f\u0001"+ - "\u0000\u0000\u0000\u0000\u0011\u0001\u0000\u0000\u0000\u0000\u0013\u0001"+ - "\u0000\u0000\u0000\u0000\u001d\u0001\u0000\u0000\u0000\u0000\u001f\u0001"+ - "\u0000\u0000\u0000\u0000!\u0001\u0000\u0000\u0000\u0000)\u0001\u0000\u0000"+ - "\u0000\u0001+\u0001\u0000\u0000\u0000\u00030\u0001\u0000\u0000\u0000\u0005"+ - "6\u0001\u0000\u0000\u0000\u0007;\u0001\u0000\u0000\u0000\t=\u0001\u0000"+ - "\u0000\u0000\u000b?\u0001\u0000\u0000\u0000\rA\u0001\u0000\u0000\u0000"+ - "\u000fC\u0001\u0000\u0000\u0000\u0011E\u0001\u0000\u0000\u0000\u0013G"+ - "\u0001\u0000\u0000\u0000\u0015Q\u0001\u0000\u0000\u0000\u0017V\u0001\u0000"+ - "\u0000\u0000\u0019\\\u0001\u0000\u0000\u0000\u001b^\u0001\u0000\u0000"+ - "\u0000\u001da\u0001\u0000\u0000\u0000\u001fe\u0001\u0000\u0000\u0000!"+ - "l\u0001\u0000\u0000\u0000#\u007f\u0001\u0000\u0000\u0000%\u0081\u0001"+ - "\u0000\u0000\u0000\'\u008a\u0001\u0000\u0000\u0000)\u008d\u0001\u0000"+ - "\u0000\u0000+,\u0005t\u0000\u0000,-\u0005r\u0000\u0000-.\u0005u\u0000"+ - "\u0000./\u0005e\u0000\u0000/\u0002\u0001\u0000\u0000\u000001\u0005f\u0000"+ - "\u000012\u0005a\u0000\u000023\u0005l\u0000\u000034\u0005s\u0000\u0000"+ - "45\u0005e\u0000\u00005\u0004\u0001\u0000\u0000\u000067\u0005n\u0000\u0000"+ - "78\u0005u\u0000\u000089\u0005l\u0000\u00009:\u0005l\u0000\u0000:\u0006"+ - "\u0001\u0000\u0000\u0000;<\u0005[\u0000\u0000<\b\u0001\u0000\u0000\u0000"+ - "=>\u0005]\u0000\u0000>\n\u0001\u0000\u0000\u0000?@\u0005{\u0000\u0000"+ - "@\f\u0001\u0000\u0000\u0000AB\u0005}\u0000\u0000B\u000e\u0001\u0000\u0000"+ - "\u0000CD\u0005,\u0000\u0000D\u0010\u0001\u0000\u0000\u0000EF\u0005:\u0000"+ - "\u0000F\u0012\u0001\u0000\u0000\u0000GL\u0005\"\u0000\u0000HK\u0003\u0015"+ - "\n\u0000IK\u0003\u001b\r\u0000JH\u0001\u0000\u0000\u0000JI\u0001\u0000"+ - "\u0000\u0000KN\u0001\u0000\u0000\u0000LJ\u0001\u0000\u0000\u0000LM\u0001"+ - "\u0000\u0000\u0000MO\u0001\u0000\u0000\u0000NL\u0001\u0000\u0000\u0000"+ - "OP\u0005\"\u0000\u0000P\u0014\u0001\u0000\u0000\u0000QT\u0005\\\u0000"+ - "\u0000RU\u0007\u0000\u0000\u0000SU\u0003\u0017\u000b\u0000TR\u0001\u0000"+ - "\u0000\u0000TS\u0001\u0000\u0000\u0000U\u0016\u0001\u0000\u0000\u0000"+ - "VW\u0005u\u0000\u0000WX\u0003\u0019\f\u0000XY\u0003\u0019\f\u0000YZ\u0003"+ - "\u0019\f\u0000Z[\u0003\u0019\f\u0000[\u0018\u0001\u0000\u0000\u0000\\"+ - "]\u0007\u0001\u0000\u0000]\u001a\u0001\u0000\u0000\u0000^_\b\u0002\u0000"+ - "\u0000_\u001c\u0001\u0000\u0000\u0000`b\u0005-\u0000\u0000a`\u0001\u0000"+ - "\u0000\u0000ab\u0001\u0000\u0000\u0000bc\u0001\u0000\u0000\u0000cd\u0003"+ - "#\u0011\u0000d\u001e\u0001\u0000\u0000\u0000ef\u0003\u001d\u000e\u0000"+ - "fh\u0005.\u0000\u0000gi\u0003\'\u0013\u0000hg\u0001\u0000\u0000\u0000"+ - "ij\u0001\u0000\u0000\u0000jh\u0001\u0000\u0000\u0000jk\u0001\u0000\u0000"+ - "\u0000k \u0001\u0000\u0000\u0000ls\u0003\u001d\u000e\u0000mo\u0005.\u0000"+ - "\u0000np\u0003\'\u0013\u0000on\u0001\u0000\u0000\u0000pq\u0001\u0000\u0000"+ - "\u0000qo\u0001\u0000\u0000\u0000qr\u0001\u0000\u0000\u0000rt\u0001\u0000"+ - "\u0000\u0000sm\u0001\u0000\u0000\u0000st\u0001\u0000\u0000\u0000tu\u0001"+ - "\u0000\u0000\u0000uv\u0003%\u0012\u0000v\"\u0001\u0000\u0000\u0000w\u0080"+ - "\u00050\u0000\u0000x|\u0007\u0003\u0000\u0000y{\u0003\'\u0013\u0000zy"+ - "\u0001\u0000\u0000\u0000{~\u0001\u0000\u0000\u0000|z\u0001\u0000\u0000"+ - "\u0000|}\u0001\u0000\u0000\u0000}\u0080\u0001\u0000\u0000\u0000~|\u0001"+ - "\u0000\u0000\u0000\u007fw\u0001\u0000\u0000\u0000\u007fx\u0001\u0000\u0000"+ - "\u0000\u0080$\u0001\u0000\u0000\u0000\u0081\u0083\u0007\u0004\u0000\u0000"+ - "\u0082\u0084\u0007\u0005\u0000\u0000\u0083\u0082\u0001\u0000\u0000\u0000"+ - "\u0083\u0084\u0001\u0000\u0000\u0000\u0084\u0086\u0001\u0000\u0000\u0000"+ - "\u0085\u0087\u0003\'\u0013\u0000\u0086\u0085\u0001\u0000\u0000\u0000\u0087"+ - "\u0088\u0001\u0000\u0000\u0000\u0088\u0086\u0001\u0000\u0000\u0000\u0088"+ - "\u0089\u0001\u0000\u0000\u0000\u0089&\u0001\u0000\u0000\u0000\u008a\u008b"+ - "\u0007\u0006\u0000\u0000\u008b(\u0001\u0000\u0000\u0000\u008c\u008e\u0007"+ - "\u0007\u0000\u0000\u008d\u008c\u0001\u0000\u0000\u0000\u008e\u008f\u0001"+ - "\u0000\u0000\u0000\u008f\u008d\u0001\u0000\u0000\u0000\u008f\u0090\u0001"+ - "\u0000\u0000\u0000\u0090\u0091\u0001\u0000\u0000\u0000\u0091\u0092\u0006"+ - "\u0014\u0000\u0000\u0092*\u0001\u0000\u0000\u0000\r\u0000JLTajqs|\u007f"+ - "\u0083\u0088\u008f\u0001\u0006\u0000\u0000"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParser.interp b/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParser.interp deleted file mode 100644 index 1d3e6d0..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParser.interp +++ /dev/null @@ -1,45 +0,0 @@ -token literal names: -null -'true' -'false' -'null' -'[' -']' -'{' -'}' -',' -':' -null -null -null -null -null - -token symbolic names: -null -TRUE -FALSE -NULL -LBRACKET -RBRACKET -LBRACE -RBRACE -COMMA -COLON -STRING -INTEGER -FLOAT -DOUBLE -WHITE_SPACE - -rule names: -json -value -object -property -array -primitive - - -atn: -[4, 1, 14, 60, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 3, 1, 19, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 25, 8, 2, 10, 2, 12, 2, 28, 9, 2, 3, 2, 30, 8, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 5, 4, 42, 8, 4, 10, 4, 12, 4, 45, 9, 4, 3, 4, 47, 8, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 58, 8, 5, 1, 5, 0, 0, 6, 0, 2, 4, 6, 8, 10, 0, 0, 65, 0, 12, 1, 0, 0, 0, 2, 18, 1, 0, 0, 0, 4, 20, 1, 0, 0, 0, 6, 33, 1, 0, 0, 0, 8, 37, 1, 0, 0, 0, 10, 57, 1, 0, 0, 0, 12, 13, 3, 2, 1, 0, 13, 14, 5, 0, 0, 1, 14, 1, 1, 0, 0, 0, 15, 19, 3, 10, 5, 0, 16, 19, 3, 4, 2, 0, 17, 19, 3, 8, 4, 0, 18, 15, 1, 0, 0, 0, 18, 16, 1, 0, 0, 0, 18, 17, 1, 0, 0, 0, 19, 3, 1, 0, 0, 0, 20, 29, 5, 6, 0, 0, 21, 26, 3, 6, 3, 0, 22, 23, 5, 8, 0, 0, 23, 25, 3, 6, 3, 0, 24, 22, 1, 0, 0, 0, 25, 28, 1, 0, 0, 0, 26, 24, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 30, 1, 0, 0, 0, 28, 26, 1, 0, 0, 0, 29, 21, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 31, 1, 0, 0, 0, 31, 32, 5, 7, 0, 0, 32, 5, 1, 0, 0, 0, 33, 34, 5, 10, 0, 0, 34, 35, 5, 9, 0, 0, 35, 36, 3, 2, 1, 0, 36, 7, 1, 0, 0, 0, 37, 46, 5, 4, 0, 0, 38, 43, 3, 2, 1, 0, 39, 40, 5, 8, 0, 0, 40, 42, 3, 2, 1, 0, 41, 39, 1, 0, 0, 0, 42, 45, 1, 0, 0, 0, 43, 41, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 47, 1, 0, 0, 0, 45, 43, 1, 0, 0, 0, 46, 38, 1, 0, 0, 0, 46, 47, 1, 0, 0, 0, 47, 48, 1, 0, 0, 0, 48, 49, 5, 5, 0, 0, 49, 9, 1, 0, 0, 0, 50, 58, 5, 1, 0, 0, 51, 58, 5, 2, 0, 0, 52, 58, 5, 10, 0, 0, 53, 58, 5, 11, 0, 0, 54, 58, 5, 12, 0, 0, 55, 58, 5, 13, 0, 0, 56, 58, 5, 3, 0, 0, 57, 50, 1, 0, 0, 0, 57, 51, 1, 0, 0, 0, 57, 52, 1, 0, 0, 0, 57, 53, 1, 0, 0, 0, 57, 54, 1, 0, 0, 0, 57, 55, 1, 0, 0, 0, 57, 56, 1, 0, 0, 0, 58, 11, 1, 0, 0, 0, 6, 18, 26, 29, 43, 46, 57] \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParser.java b/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParser.java deleted file mode 100644 index 358f9b9..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParser.java +++ /dev/null @@ -1,618 +0,0 @@ -package com.relogiclabs.json.schema.internal.antlr; - -import org.antlr.v4.runtime.NoViableAltException; -import org.antlr.v4.runtime.Parser; -import org.antlr.v4.runtime.ParserRuleContext; -import org.antlr.v4.runtime.RecognitionException; -import org.antlr.v4.runtime.RuntimeMetaData; -import org.antlr.v4.runtime.TokenStream; -import org.antlr.v4.runtime.Vocabulary; -import org.antlr.v4.runtime.VocabularyImpl; -import org.antlr.v4.runtime.atn.ATN; -import org.antlr.v4.runtime.atn.ATNDeserializer; -import org.antlr.v4.runtime.atn.ParserATNSimulator; -import org.antlr.v4.runtime.atn.PredictionContextCache; -import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.tree.ParseTreeVisitor; -import org.antlr.v4.runtime.tree.TerminalNode; - -import java.util.List; - -@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) -public class JsonParser extends Parser { - static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - TRUE=1, FALSE=2, NULL=3, LBRACKET=4, RBRACKET=5, LBRACE=6, RBRACE=7, COMMA=8, - COLON=9, STRING=10, INTEGER=11, FLOAT=12, DOUBLE=13, WHITE_SPACE=14; - public static final int - RULE_json = 0, RULE_value = 1, RULE_object = 2, RULE_property = 3, RULE_array = 4, - RULE_primitive = 5; - private static String[] makeRuleNames() { - return new String[] { - "json", "value", "object", "property", "array", "primitive" - }; - } - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[] { - null, "'true'", "'false'", "'null'", "'['", "']'", "'{'", "'}'", "','", - "':'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, "TRUE", "FALSE", "NULL", "LBRACKET", "RBRACKET", "LBRACE", "RBRACE", - "COMMA", "COLON", "STRING", "INTEGER", "FLOAT", "DOUBLE", "WHITE_SPACE" - }; - } - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - @Override - public String getGrammarFileName() { return "JsonParser.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public ATN getATN() { return _ATN; } - - public JsonParser(TokenStream input) { - super(input); - _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @SuppressWarnings("CheckReturnValue") - public static class JsonContext extends ParserRuleContext { - public ValueContext value() { - return getRuleContext(ValueContext.class,0); - } - public TerminalNode EOF() { return getToken(JsonParser.EOF, 0); } - public JsonContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_json; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitJson(this); - else return visitor.visitChildren(this); - } - } - - public final JsonContext json() throws RecognitionException { - JsonContext _localctx = new JsonContext(_ctx, getState()); - enterRule(_localctx, 0, RULE_json); - try { - enterOuterAlt(_localctx, 1); - { - setState(12); - value(); - setState(13); - match(EOF); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ValueContext extends ParserRuleContext { - public PrimitiveContext primitive() { - return getRuleContext(PrimitiveContext.class,0); - } - public ObjectContext object() { - return getRuleContext(ObjectContext.class,0); - } - public ArrayContext array() { - return getRuleContext(ArrayContext.class,0); - } - public ValueContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_value; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitValue(this); - else return visitor.visitChildren(this); - } - } - - public final ValueContext value() throws RecognitionException { - ValueContext _localctx = new ValueContext(_ctx, getState()); - enterRule(_localctx, 2, RULE_value); - try { - setState(18); - _errHandler.sync(this); - switch (_input.LA(1)) { - case TRUE: - case FALSE: - case NULL: - case STRING: - case INTEGER: - case FLOAT: - case DOUBLE: - enterOuterAlt(_localctx, 1); - { - setState(15); - primitive(); - } - break; - case LBRACE: - enterOuterAlt(_localctx, 2); - { - setState(16); - object(); - } - break; - case LBRACKET: - enterOuterAlt(_localctx, 3); - { - setState(17); - array(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ObjectContext extends ParserRuleContext { - public TerminalNode LBRACE() { return getToken(JsonParser.LBRACE, 0); } - public TerminalNode RBRACE() { return getToken(JsonParser.RBRACE, 0); } - public List property() { - return getRuleContexts(PropertyContext.class); - } - public PropertyContext property(int i) { - return getRuleContext(PropertyContext.class,i); - } - public List COMMA() { return getTokens(JsonParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(JsonParser.COMMA, i); - } - public ObjectContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_object; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitObject(this); - else return visitor.visitChildren(this); - } - } - - public final ObjectContext object() throws RecognitionException { - ObjectContext _localctx = new ObjectContext(_ctx, getState()); - enterRule(_localctx, 4, RULE_object); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(20); - match(LBRACE); - setState(29); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==STRING) { - { - setState(21); - property(); - setState(26); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==COMMA) { - { - { - setState(22); - match(COMMA); - setState(23); - property(); - } - } - setState(28); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - - setState(31); - match(RBRACE); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class PropertyContext extends ParserRuleContext { - public TerminalNode STRING() { return getToken(JsonParser.STRING, 0); } - public TerminalNode COLON() { return getToken(JsonParser.COLON, 0); } - public ValueContext value() { - return getRuleContext(ValueContext.class,0); - } - public PropertyContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_property; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitProperty(this); - else return visitor.visitChildren(this); - } - } - - public final PropertyContext property() throws RecognitionException { - PropertyContext _localctx = new PropertyContext(_ctx, getState()); - enterRule(_localctx, 6, RULE_property); - try { - enterOuterAlt(_localctx, 1); - { - setState(33); - match(STRING); - setState(34); - match(COLON); - setState(35); - value(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ArrayContext extends ParserRuleContext { - public TerminalNode LBRACKET() { return getToken(JsonParser.LBRACKET, 0); } - public TerminalNode RBRACKET() { return getToken(JsonParser.RBRACKET, 0); } - public List value() { - return getRuleContexts(ValueContext.class); - } - public ValueContext value(int i) { - return getRuleContext(ValueContext.class,i); - } - public List COMMA() { return getTokens(JsonParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(JsonParser.COMMA, i); - } - public ArrayContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_array; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitArray(this); - else return visitor.visitChildren(this); - } - } - - public final ArrayContext array() throws RecognitionException { - ArrayContext _localctx = new ArrayContext(_ctx, getState()); - enterRule(_localctx, 8, RULE_array); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(37); - match(LBRACKET); - setState(46); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 15454L) != 0)) { - { - setState(38); - value(); - setState(43); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==COMMA) { - { - { - setState(39); - match(COMMA); - setState(40); - value(); - } - } - setState(45); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - - setState(48); - match(RBRACKET); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveContext extends ParserRuleContext { - public PrimitiveContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_primitive; } - - public PrimitiveContext() { } - public void copyFrom(PrimitiveContext ctx) { - super.copyFrom(ctx); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveDoubleContext extends PrimitiveContext { - public TerminalNode DOUBLE() { return getToken(JsonParser.DOUBLE, 0); } - public PrimitiveDoubleContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveDouble(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveFloatContext extends PrimitiveContext { - public TerminalNode FLOAT() { return getToken(JsonParser.FLOAT, 0); } - public PrimitiveFloatContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveFloat(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveNullContext extends PrimitiveContext { - public TerminalNode NULL() { return getToken(JsonParser.NULL, 0); } - public PrimitiveNullContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveNull(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveTrueContext extends PrimitiveContext { - public TerminalNode TRUE() { return getToken(JsonParser.TRUE, 0); } - public PrimitiveTrueContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveTrue(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveFalseContext extends PrimitiveContext { - public TerminalNode FALSE() { return getToken(JsonParser.FALSE, 0); } - public PrimitiveFalseContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveFalse(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveStringContext extends PrimitiveContext { - public TerminalNode STRING() { return getToken(JsonParser.STRING, 0); } - public PrimitiveStringContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveString(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveIntegerContext extends PrimitiveContext { - public TerminalNode INTEGER() { return getToken(JsonParser.INTEGER, 0); } - public PrimitiveIntegerContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof JsonParserVisitor ) return ((JsonParserVisitor)visitor).visitPrimitiveInteger(this); - else return visitor.visitChildren(this); - } - } - - public final PrimitiveContext primitive() throws RecognitionException { - PrimitiveContext _localctx = new PrimitiveContext(_ctx, getState()); - enterRule(_localctx, 10, RULE_primitive); - try { - setState(57); - _errHandler.sync(this); - switch (_input.LA(1)) { - case TRUE: - _localctx = new PrimitiveTrueContext(_localctx); - enterOuterAlt(_localctx, 1); - { - setState(50); - match(TRUE); - } - break; - case FALSE: - _localctx = new PrimitiveFalseContext(_localctx); - enterOuterAlt(_localctx, 2); - { - setState(51); - match(FALSE); - } - break; - case STRING: - _localctx = new PrimitiveStringContext(_localctx); - enterOuterAlt(_localctx, 3); - { - setState(52); - match(STRING); - } - break; - case INTEGER: - _localctx = new PrimitiveIntegerContext(_localctx); - enterOuterAlt(_localctx, 4); - { - setState(53); - match(INTEGER); - } - break; - case FLOAT: - _localctx = new PrimitiveFloatContext(_localctx); - enterOuterAlt(_localctx, 5); - { - setState(54); - match(FLOAT); - } - break; - case DOUBLE: - _localctx = new PrimitiveDoubleContext(_localctx); - enterOuterAlt(_localctx, 6); - { - setState(55); - match(DOUBLE); - } - break; - case NULL: - _localctx = new PrimitiveNullContext(_localctx); - enterOuterAlt(_localctx, 7); - { - setState(56); - match(NULL); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static final String _serializedATN = - "\u0004\u0001\u000e<\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ - "\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+ - "\u0005\u0007\u0005\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001\u0001"+ - "\u0001\u0001\u0001\u0003\u0001\u0013\b\u0001\u0001\u0002\u0001\u0002\u0001"+ - "\u0002\u0001\u0002\u0005\u0002\u0019\b\u0002\n\u0002\f\u0002\u001c\t\u0002"+ - "\u0003\u0002\u001e\b\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+ - "\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004"+ - "\u0005\u0004*\b\u0004\n\u0004\f\u0004-\t\u0004\u0003\u0004/\b\u0004\u0001"+ - "\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001"+ - "\u0005\u0001\u0005\u0001\u0005\u0003\u0005:\b\u0005\u0001\u0005\u0000"+ - "\u0000\u0006\u0000\u0002\u0004\u0006\b\n\u0000\u0000A\u0000\f\u0001\u0000"+ - "\u0000\u0000\u0002\u0012\u0001\u0000\u0000\u0000\u0004\u0014\u0001\u0000"+ - "\u0000\u0000\u0006!\u0001\u0000\u0000\u0000\b%\u0001\u0000\u0000\u0000"+ - "\n9\u0001\u0000\u0000\u0000\f\r\u0003\u0002\u0001\u0000\r\u000e\u0005"+ - "\u0000\u0000\u0001\u000e\u0001\u0001\u0000\u0000\u0000\u000f\u0013\u0003"+ - "\n\u0005\u0000\u0010\u0013\u0003\u0004\u0002\u0000\u0011\u0013\u0003\b"+ - "\u0004\u0000\u0012\u000f\u0001\u0000\u0000\u0000\u0012\u0010\u0001\u0000"+ - "\u0000\u0000\u0012\u0011\u0001\u0000\u0000\u0000\u0013\u0003\u0001\u0000"+ - "\u0000\u0000\u0014\u001d\u0005\u0006\u0000\u0000\u0015\u001a\u0003\u0006"+ - "\u0003\u0000\u0016\u0017\u0005\b\u0000\u0000\u0017\u0019\u0003\u0006\u0003"+ - "\u0000\u0018\u0016\u0001\u0000\u0000\u0000\u0019\u001c\u0001\u0000\u0000"+ - "\u0000\u001a\u0018\u0001\u0000\u0000\u0000\u001a\u001b\u0001\u0000\u0000"+ - "\u0000\u001b\u001e\u0001\u0000\u0000\u0000\u001c\u001a\u0001\u0000\u0000"+ - "\u0000\u001d\u0015\u0001\u0000\u0000\u0000\u001d\u001e\u0001\u0000\u0000"+ - "\u0000\u001e\u001f\u0001\u0000\u0000\u0000\u001f \u0005\u0007\u0000\u0000"+ - " \u0005\u0001\u0000\u0000\u0000!\"\u0005\n\u0000\u0000\"#\u0005\t\u0000"+ - "\u0000#$\u0003\u0002\u0001\u0000$\u0007\u0001\u0000\u0000\u0000%.\u0005"+ - "\u0004\u0000\u0000&+\u0003\u0002\u0001\u0000\'(\u0005\b\u0000\u0000(*"+ - "\u0003\u0002\u0001\u0000)\'\u0001\u0000\u0000\u0000*-\u0001\u0000\u0000"+ - "\u0000+)\u0001\u0000\u0000\u0000+,\u0001\u0000\u0000\u0000,/\u0001\u0000"+ - "\u0000\u0000-+\u0001\u0000\u0000\u0000.&\u0001\u0000\u0000\u0000./\u0001"+ - "\u0000\u0000\u0000/0\u0001\u0000\u0000\u000001\u0005\u0005\u0000\u0000"+ - "1\t\u0001\u0000\u0000\u00002:\u0005\u0001\u0000\u00003:\u0005\u0002\u0000"+ - "\u00004:\u0005\n\u0000\u00005:\u0005\u000b\u0000\u00006:\u0005\f\u0000"+ - "\u00007:\u0005\r\u0000\u00008:\u0005\u0003\u0000\u000092\u0001\u0000\u0000"+ - "\u000093\u0001\u0000\u0000\u000094\u0001\u0000\u0000\u000095\u0001\u0000"+ - "\u0000\u000096\u0001\u0000\u0000\u000097\u0001\u0000\u0000\u000098\u0001"+ - "\u0000\u0000\u0000:\u000b\u0001\u0000\u0000\u0000\u0006\u0012\u001a\u001d"+ - "+.9"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParserBaseVisitor.java b/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParserBaseVisitor.java deleted file mode 100644 index 14b4da4..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParserBaseVisitor.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.relogiclabs.json.schema.internal.antlr; -import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; - -/** - * This class provides an empty implementation of {@link JsonParserVisitor}, - * which can be extended to create a visitor which only needs to handle a subset - * of the available methods. - * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. - */ -@SuppressWarnings("CheckReturnValue") -public class JsonParserBaseVisitor extends AbstractParseTreeVisitor implements JsonParserVisitor { - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitJson(JsonParser.JsonContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitValue(JsonParser.ValueContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitObject(JsonParser.ObjectContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitProperty(JsonParser.PropertyContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitArray(JsonParser.ArrayContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveTrue(JsonParser.PrimitiveTrueContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveFalse(JsonParser.PrimitiveFalseContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveString(JsonParser.PrimitiveStringContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveInteger(JsonParser.PrimitiveIntegerContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveFloat(JsonParser.PrimitiveFloatContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveDouble(JsonParser.PrimitiveDoubleContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveNull(JsonParser.PrimitiveNullContext ctx) { return visitChildren(ctx); } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParserVisitor.java b/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParserVisitor.java deleted file mode 100644 index 03cb172..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/JsonParserVisitor.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.relogiclabs.json.schema.internal.antlr; -import org.antlr.v4.runtime.tree.ParseTreeVisitor; - -/** - * This interface defines a complete generic visitor for a parse tree produced - * by {@link JsonParser}. - * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. - */ -public interface JsonParserVisitor extends ParseTreeVisitor { - /** - * Visit a parse tree produced by {@link JsonParser#json}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitJson(JsonParser.JsonContext ctx); - /** - * Visit a parse tree produced by {@link JsonParser#value}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitValue(JsonParser.ValueContext ctx); - /** - * Visit a parse tree produced by {@link JsonParser#object}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitObject(JsonParser.ObjectContext ctx); - /** - * Visit a parse tree produced by {@link JsonParser#property}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitProperty(JsonParser.PropertyContext ctx); - /** - * Visit a parse tree produced by {@link JsonParser#array}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitArray(JsonParser.ArrayContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveTrue} - * labeled alternative in {@link JsonParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveTrue(JsonParser.PrimitiveTrueContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveFalse} - * labeled alternative in {@link JsonParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveFalse(JsonParser.PrimitiveFalseContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveString} - * labeled alternative in {@link JsonParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveString(JsonParser.PrimitiveStringContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveInteger} - * labeled alternative in {@link JsonParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveInteger(JsonParser.PrimitiveIntegerContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveFloat} - * labeled alternative in {@link JsonParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveFloat(JsonParser.PrimitiveFloatContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveDouble} - * labeled alternative in {@link JsonParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveDouble(JsonParser.PrimitiveDoubleContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveNull} - * labeled alternative in {@link JsonParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveNull(JsonParser.PrimitiveNullContext ctx); -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaLexer.interp b/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaLexer.interp deleted file mode 100644 index 9c9cb35..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaLexer.interp +++ /dev/null @@ -1,142 +0,0 @@ -token literal names: -null -'%title' -'%version' -'%include' -'%pragma' -'%define' -'%schema' -'true' -'false' -'null' -null -',' -'*' -'{' -'}' -'[' -']' -'(' -')' -'?' -'!' -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null - -token symbolic names: -null -TITLE -VERSION -INCLUDE -PRAGMA -DEFINE -SCHEMA -TRUE -FALSE -NULL -COLON -COMMA -STAR -LBRACE -RBRACE -LBRACKET -RBRACKET -LPAREN -RPAREN -OPTIONAL -UNDEFINED -IDENTIFIER -ALIAS -DATATYPE -FUNCTION -RECEIVER -STRING -INTEGER -FLOAT -DOUBLE -MULTILINE_COMMENT -LINE_COMMENT -WHITE_SPACE -COLON1 -VERSION_NUMBER1 -WHITE_SPACE1 -MULTILINE_COMMENT1 -LINE_COMMENT1 - -rule names: -TITLE -VERSION -INCLUDE -PRAGMA -DEFINE -SCHEMA -TRUE -FALSE -NULL -COLON -COMMA -STAR -LBRACE -RBRACE -LBRACKET -RBRACKET -LPAREN -RPAREN -OPTIONAL -UNDEFINED -IDENTIFIER -ALIAS -DATATYPE -FUNCTION -RECEIVER -BASE_IDENTIFIER -ALPHA -ALPHANUMERIC -STRING -ESCAPE -UNICODE -HEXDIGIT -SAFECODEPOINT -INTEGER -FLOAT -DOUBLE -INTDIGIT -EXPONENT -DIGIT -MULTILINE_COMMENT -LINE_COMMENT -MULTILINE_CMT -LINE_CMT -WHITE_SPACE -WHITE_SPC -COLON1 -VERSION_NUMBER1 -WHITE_SPACE1 -MULTILINE_COMMENT1 -LINE_COMMENT1 - -channel names: -DEFAULT_TOKEN_CHANNEL -HIDDEN - -mode names: -DEFAULT_MODE -DIRECTIVE_VERSION1 - -atn: -[4, 0, 37, 364, 6, -1, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 5, 20, 195, 8, 20, 10, 20, 12, 20, 198, 9, 20, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 4, 22, 205, 8, 22, 11, 22, 12, 22, 206, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 5, 25, 217, 8, 25, 10, 25, 12, 25, 220, 9, 25, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 5, 28, 229, 8, 28, 10, 28, 12, 28, 232, 9, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 3, 29, 239, 8, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 32, 1, 32, 1, 33, 3, 33, 252, 8, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 4, 34, 259, 8, 34, 11, 34, 12, 34, 260, 1, 35, 1, 35, 1, 35, 4, 35, 266, 8, 35, 11, 35, 12, 35, 267, 3, 35, 270, 8, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 5, 36, 277, 8, 36, 10, 36, 12, 36, 280, 9, 36, 3, 36, 282, 8, 36, 1, 37, 1, 37, 3, 37, 286, 8, 37, 1, 37, 4, 37, 289, 8, 37, 11, 37, 12, 37, 290, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, 41, 5, 41, 307, 8, 41, 10, 41, 12, 41, 310, 9, 41, 1, 41, 1, 41, 1, 41, 1, 42, 1, 42, 1, 42, 1, 42, 5, 42, 319, 8, 42, 10, 42, 12, 42, 322, 9, 42, 1, 43, 1, 43, 1, 43, 1, 43, 1, 44, 4, 44, 329, 8, 44, 11, 44, 12, 44, 330, 1, 45, 1, 45, 1, 46, 4, 46, 336, 8, 46, 11, 46, 12, 46, 337, 1, 46, 1, 46, 4, 46, 342, 8, 46, 11, 46, 12, 46, 343, 5, 46, 346, 8, 46, 10, 46, 12, 46, 349, 9, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, 49, 1, 49, 1, 308, 0, 50, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18, 9, 20, 10, 22, 11, 24, 12, 26, 13, 28, 14, 30, 15, 32, 16, 34, 17, 36, 18, 38, 19, 40, 20, 42, 21, 44, 22, 46, 23, 48, 24, 50, 25, 52, 0, 54, 0, 56, 0, 58, 26, 60, 0, 62, 0, 64, 0, 66, 0, 68, 27, 70, 28, 72, 29, 74, 0, 76, 0, 78, 0, 80, 30, 82, 31, 84, 0, 86, 0, 88, 32, 90, 0, 92, 33, 94, 34, 96, 35, 98, 36, 100, 37, 2, 0, 1, 11, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 8, 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 0, 31, 34, 34, 92, 92, 1, 0, 49, 57, 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 1, 0, 48, 57, 2, 0, 10, 10, 13, 13, 3, 0, 9, 10, 13, 13, 32, 32, 369, 0, 2, 1, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 6, 1, 0, 0, 0, 0, 8, 1, 0, 0, 0, 0, 10, 1, 0, 0, 0, 0, 12, 1, 0, 0, 0, 0, 14, 1, 0, 0, 0, 0, 16, 1, 0, 0, 0, 0, 18, 1, 0, 0, 0, 0, 20, 1, 0, 0, 0, 0, 22, 1, 0, 0, 0, 0, 24, 1, 0, 0, 0, 0, 26, 1, 0, 0, 0, 0, 28, 1, 0, 0, 0, 0, 30, 1, 0, 0, 0, 0, 32, 1, 0, 0, 0, 0, 34, 1, 0, 0, 0, 0, 36, 1, 0, 0, 0, 0, 38, 1, 0, 0, 0, 0, 40, 1, 0, 0, 0, 0, 42, 1, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 46, 1, 0, 0, 0, 0, 48, 1, 0, 0, 0, 0, 50, 1, 0, 0, 0, 0, 58, 1, 0, 0, 0, 0, 68, 1, 0, 0, 0, 0, 70, 1, 0, 0, 0, 0, 72, 1, 0, 0, 0, 0, 80, 1, 0, 0, 0, 0, 82, 1, 0, 0, 0, 0, 88, 1, 0, 0, 0, 1, 92, 1, 0, 0, 0, 1, 94, 1, 0, 0, 0, 1, 96, 1, 0, 0, 0, 1, 98, 1, 0, 0, 0, 1, 100, 1, 0, 0, 0, 2, 102, 1, 0, 0, 0, 4, 109, 1, 0, 0, 0, 6, 120, 1, 0, 0, 0, 8, 129, 1, 0, 0, 0, 10, 137, 1, 0, 0, 0, 12, 145, 1, 0, 0, 0, 14, 153, 1, 0, 0, 0, 16, 158, 1, 0, 0, 0, 18, 164, 1, 0, 0, 0, 20, 169, 1, 0, 0, 0, 22, 171, 1, 0, 0, 0, 24, 173, 1, 0, 0, 0, 26, 175, 1, 0, 0, 0, 28, 177, 1, 0, 0, 0, 30, 179, 1, 0, 0, 0, 32, 181, 1, 0, 0, 0, 34, 183, 1, 0, 0, 0, 36, 185, 1, 0, 0, 0, 38, 187, 1, 0, 0, 0, 40, 189, 1, 0, 0, 0, 42, 191, 1, 0, 0, 0, 44, 199, 1, 0, 0, 0, 46, 202, 1, 0, 0, 0, 48, 208, 1, 0, 0, 0, 50, 211, 1, 0, 0, 0, 52, 214, 1, 0, 0, 0, 54, 221, 1, 0, 0, 0, 56, 223, 1, 0, 0, 0, 58, 225, 1, 0, 0, 0, 60, 235, 1, 0, 0, 0, 62, 240, 1, 0, 0, 0, 64, 246, 1, 0, 0, 0, 66, 248, 1, 0, 0, 0, 68, 251, 1, 0, 0, 0, 70, 255, 1, 0, 0, 0, 72, 262, 1, 0, 0, 0, 74, 281, 1, 0, 0, 0, 76, 283, 1, 0, 0, 0, 78, 292, 1, 0, 0, 0, 80, 294, 1, 0, 0, 0, 82, 298, 1, 0, 0, 0, 84, 302, 1, 0, 0, 0, 86, 314, 1, 0, 0, 0, 88, 323, 1, 0, 0, 0, 90, 328, 1, 0, 0, 0, 92, 332, 1, 0, 0, 0, 94, 335, 1, 0, 0, 0, 96, 352, 1, 0, 0, 0, 98, 356, 1, 0, 0, 0, 100, 360, 1, 0, 0, 0, 102, 103, 5, 37, 0, 0, 103, 104, 5, 116, 0, 0, 104, 105, 5, 105, 0, 0, 105, 106, 5, 116, 0, 0, 106, 107, 5, 108, 0, 0, 107, 108, 5, 101, 0, 0, 108, 3, 1, 0, 0, 0, 109, 110, 5, 37, 0, 0, 110, 111, 5, 118, 0, 0, 111, 112, 5, 101, 0, 0, 112, 113, 5, 114, 0, 0, 113, 114, 5, 115, 0, 0, 114, 115, 5, 105, 0, 0, 115, 116, 5, 111, 0, 0, 116, 117, 5, 110, 0, 0, 117, 118, 1, 0, 0, 0, 118, 119, 6, 1, 0, 0, 119, 5, 1, 0, 0, 0, 120, 121, 5, 37, 0, 0, 121, 122, 5, 105, 0, 0, 122, 123, 5, 110, 0, 0, 123, 124, 5, 99, 0, 0, 124, 125, 5, 108, 0, 0, 125, 126, 5, 117, 0, 0, 126, 127, 5, 100, 0, 0, 127, 128, 5, 101, 0, 0, 128, 7, 1, 0, 0, 0, 129, 130, 5, 37, 0, 0, 130, 131, 5, 112, 0, 0, 131, 132, 5, 114, 0, 0, 132, 133, 5, 97, 0, 0, 133, 134, 5, 103, 0, 0, 134, 135, 5, 109, 0, 0, 135, 136, 5, 97, 0, 0, 136, 9, 1, 0, 0, 0, 137, 138, 5, 37, 0, 0, 138, 139, 5, 100, 0, 0, 139, 140, 5, 101, 0, 0, 140, 141, 5, 102, 0, 0, 141, 142, 5, 105, 0, 0, 142, 143, 5, 110, 0, 0, 143, 144, 5, 101, 0, 0, 144, 11, 1, 0, 0, 0, 145, 146, 5, 37, 0, 0, 146, 147, 5, 115, 0, 0, 147, 148, 5, 99, 0, 0, 148, 149, 5, 104, 0, 0, 149, 150, 5, 101, 0, 0, 150, 151, 5, 109, 0, 0, 151, 152, 5, 97, 0, 0, 152, 13, 1, 0, 0, 0, 153, 154, 5, 116, 0, 0, 154, 155, 5, 114, 0, 0, 155, 156, 5, 117, 0, 0, 156, 157, 5, 101, 0, 0, 157, 15, 1, 0, 0, 0, 158, 159, 5, 102, 0, 0, 159, 160, 5, 97, 0, 0, 160, 161, 5, 108, 0, 0, 161, 162, 5, 115, 0, 0, 162, 163, 5, 101, 0, 0, 163, 17, 1, 0, 0, 0, 164, 165, 5, 110, 0, 0, 165, 166, 5, 117, 0, 0, 166, 167, 5, 108, 0, 0, 167, 168, 5, 108, 0, 0, 168, 19, 1, 0, 0, 0, 169, 170, 5, 58, 0, 0, 170, 21, 1, 0, 0, 0, 171, 172, 5, 44, 0, 0, 172, 23, 1, 0, 0, 0, 173, 174, 5, 42, 0, 0, 174, 25, 1, 0, 0, 0, 175, 176, 5, 123, 0, 0, 176, 27, 1, 0, 0, 0, 177, 178, 5, 125, 0, 0, 178, 29, 1, 0, 0, 0, 179, 180, 5, 91, 0, 0, 180, 31, 1, 0, 0, 0, 181, 182, 5, 93, 0, 0, 182, 33, 1, 0, 0, 0, 183, 184, 5, 40, 0, 0, 184, 35, 1, 0, 0, 0, 185, 186, 5, 41, 0, 0, 186, 37, 1, 0, 0, 0, 187, 188, 5, 63, 0, 0, 188, 39, 1, 0, 0, 0, 189, 190, 5, 33, 0, 0, 190, 41, 1, 0, 0, 0, 191, 196, 3, 52, 25, 0, 192, 193, 5, 46, 0, 0, 193, 195, 3, 52, 25, 0, 194, 192, 1, 0, 0, 0, 195, 198, 1, 0, 0, 0, 196, 194, 1, 0, 0, 0, 196, 197, 1, 0, 0, 0, 197, 43, 1, 0, 0, 0, 198, 196, 1, 0, 0, 0, 199, 200, 5, 36, 0, 0, 200, 201, 3, 52, 25, 0, 201, 45, 1, 0, 0, 0, 202, 204, 5, 35, 0, 0, 203, 205, 3, 54, 26, 0, 204, 203, 1, 0, 0, 0, 205, 206, 1, 0, 0, 0, 206, 204, 1, 0, 0, 0, 206, 207, 1, 0, 0, 0, 207, 47, 1, 0, 0, 0, 208, 209, 5, 64, 0, 0, 209, 210, 3, 52, 25, 0, 210, 49, 1, 0, 0, 0, 211, 212, 5, 38, 0, 0, 212, 213, 3, 52, 25, 0, 213, 51, 1, 0, 0, 0, 214, 218, 3, 54, 26, 0, 215, 217, 3, 56, 27, 0, 216, 215, 1, 0, 0, 0, 217, 220, 1, 0, 0, 0, 218, 216, 1, 0, 0, 0, 218, 219, 1, 0, 0, 0, 219, 53, 1, 0, 0, 0, 220, 218, 1, 0, 0, 0, 221, 222, 7, 0, 0, 0, 222, 55, 1, 0, 0, 0, 223, 224, 7, 1, 0, 0, 224, 57, 1, 0, 0, 0, 225, 230, 5, 34, 0, 0, 226, 229, 3, 60, 29, 0, 227, 229, 3, 66, 32, 0, 228, 226, 1, 0, 0, 0, 228, 227, 1, 0, 0, 0, 229, 232, 1, 0, 0, 0, 230, 228, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 233, 1, 0, 0, 0, 232, 230, 1, 0, 0, 0, 233, 234, 5, 34, 0, 0, 234, 59, 1, 0, 0, 0, 235, 238, 5, 92, 0, 0, 236, 239, 7, 2, 0, 0, 237, 239, 3, 62, 30, 0, 238, 236, 1, 0, 0, 0, 238, 237, 1, 0, 0, 0, 239, 61, 1, 0, 0, 0, 240, 241, 5, 117, 0, 0, 241, 242, 3, 64, 31, 0, 242, 243, 3, 64, 31, 0, 243, 244, 3, 64, 31, 0, 244, 245, 3, 64, 31, 0, 245, 63, 1, 0, 0, 0, 246, 247, 7, 3, 0, 0, 247, 65, 1, 0, 0, 0, 248, 249, 8, 4, 0, 0, 249, 67, 1, 0, 0, 0, 250, 252, 5, 45, 0, 0, 251, 250, 1, 0, 0, 0, 251, 252, 1, 0, 0, 0, 252, 253, 1, 0, 0, 0, 253, 254, 3, 74, 36, 0, 254, 69, 1, 0, 0, 0, 255, 256, 3, 68, 33, 0, 256, 258, 5, 46, 0, 0, 257, 259, 3, 78, 38, 0, 258, 257, 1, 0, 0, 0, 259, 260, 1, 0, 0, 0, 260, 258, 1, 0, 0, 0, 260, 261, 1, 0, 0, 0, 261, 71, 1, 0, 0, 0, 262, 269, 3, 68, 33, 0, 263, 265, 5, 46, 0, 0, 264, 266, 3, 78, 38, 0, 265, 264, 1, 0, 0, 0, 266, 267, 1, 0, 0, 0, 267, 265, 1, 0, 0, 0, 267, 268, 1, 0, 0, 0, 268, 270, 1, 0, 0, 0, 269, 263, 1, 0, 0, 0, 269, 270, 1, 0, 0, 0, 270, 271, 1, 0, 0, 0, 271, 272, 3, 76, 37, 0, 272, 73, 1, 0, 0, 0, 273, 282, 5, 48, 0, 0, 274, 278, 7, 5, 0, 0, 275, 277, 3, 78, 38, 0, 276, 275, 1, 0, 0, 0, 277, 280, 1, 0, 0, 0, 278, 276, 1, 0, 0, 0, 278, 279, 1, 0, 0, 0, 279, 282, 1, 0, 0, 0, 280, 278, 1, 0, 0, 0, 281, 273, 1, 0, 0, 0, 281, 274, 1, 0, 0, 0, 282, 75, 1, 0, 0, 0, 283, 285, 7, 6, 0, 0, 284, 286, 7, 7, 0, 0, 285, 284, 1, 0, 0, 0, 285, 286, 1, 0, 0, 0, 286, 288, 1, 0, 0, 0, 287, 289, 3, 78, 38, 0, 288, 287, 1, 0, 0, 0, 289, 290, 1, 0, 0, 0, 290, 288, 1, 0, 0, 0, 290, 291, 1, 0, 0, 0, 291, 77, 1, 0, 0, 0, 292, 293, 7, 8, 0, 0, 293, 79, 1, 0, 0, 0, 294, 295, 3, 84, 41, 0, 295, 296, 1, 0, 0, 0, 296, 297, 6, 39, 1, 0, 297, 81, 1, 0, 0, 0, 298, 299, 3, 86, 42, 0, 299, 300, 1, 0, 0, 0, 300, 301, 6, 40, 1, 0, 301, 83, 1, 0, 0, 0, 302, 303, 5, 47, 0, 0, 303, 304, 5, 42, 0, 0, 304, 308, 1, 0, 0, 0, 305, 307, 9, 0, 0, 0, 306, 305, 1, 0, 0, 0, 307, 310, 1, 0, 0, 0, 308, 309, 1, 0, 0, 0, 308, 306, 1, 0, 0, 0, 309, 311, 1, 0, 0, 0, 310, 308, 1, 0, 0, 0, 311, 312, 5, 42, 0, 0, 312, 313, 5, 47, 0, 0, 313, 85, 1, 0, 0, 0, 314, 315, 5, 47, 0, 0, 315, 316, 5, 47, 0, 0, 316, 320, 1, 0, 0, 0, 317, 319, 8, 9, 0, 0, 318, 317, 1, 0, 0, 0, 319, 322, 1, 0, 0, 0, 320, 318, 1, 0, 0, 0, 320, 321, 1, 0, 0, 0, 321, 87, 1, 0, 0, 0, 322, 320, 1, 0, 0, 0, 323, 324, 3, 90, 44, 0, 324, 325, 1, 0, 0, 0, 325, 326, 6, 43, 1, 0, 326, 89, 1, 0, 0, 0, 327, 329, 7, 10, 0, 0, 328, 327, 1, 0, 0, 0, 329, 330, 1, 0, 0, 0, 330, 328, 1, 0, 0, 0, 330, 331, 1, 0, 0, 0, 331, 91, 1, 0, 0, 0, 332, 333, 5, 58, 0, 0, 333, 93, 1, 0, 0, 0, 334, 336, 3, 78, 38, 0, 335, 334, 1, 0, 0, 0, 336, 337, 1, 0, 0, 0, 337, 335, 1, 0, 0, 0, 337, 338, 1, 0, 0, 0, 338, 347, 1, 0, 0, 0, 339, 341, 5, 46, 0, 0, 340, 342, 3, 78, 38, 0, 341, 340, 1, 0, 0, 0, 342, 343, 1, 0, 0, 0, 343, 341, 1, 0, 0, 0, 343, 344, 1, 0, 0, 0, 344, 346, 1, 0, 0, 0, 345, 339, 1, 0, 0, 0, 346, 349, 1, 0, 0, 0, 347, 345, 1, 0, 0, 0, 347, 348, 1, 0, 0, 0, 348, 350, 1, 0, 0, 0, 349, 347, 1, 0, 0, 0, 350, 351, 6, 46, 2, 0, 351, 95, 1, 0, 0, 0, 352, 353, 3, 90, 44, 0, 353, 354, 1, 0, 0, 0, 354, 355, 6, 47, 1, 0, 355, 97, 1, 0, 0, 0, 356, 357, 3, 84, 41, 0, 357, 358, 1, 0, 0, 0, 358, 359, 6, 48, 1, 0, 359, 99, 1, 0, 0, 0, 360, 361, 3, 86, 42, 0, 361, 362, 1, 0, 0, 0, 362, 363, 6, 49, 1, 0, 363, 101, 1, 0, 0, 0, 22, 0, 1, 196, 206, 218, 228, 230, 238, 251, 260, 267, 269, 278, 281, 285, 290, 308, 320, 330, 337, 343, 347, 3, 5, 1, 0, 0, 1, 0, 4, 0, 0] \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaLexer.java b/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaLexer.java deleted file mode 100644 index 4ced5ad..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaLexer.java +++ /dev/null @@ -1,364 +0,0 @@ -package com.relogiclabs.json.schema.internal.antlr; - -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.Lexer; -import org.antlr.v4.runtime.RuntimeMetaData; -import org.antlr.v4.runtime.Vocabulary; -import org.antlr.v4.runtime.VocabularyImpl; -import org.antlr.v4.runtime.atn.ATN; -import org.antlr.v4.runtime.atn.ATNDeserializer; -import org.antlr.v4.runtime.atn.LexerATNSimulator; -import org.antlr.v4.runtime.atn.PredictionContextCache; -import org.antlr.v4.runtime.dfa.DFA; - -@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) -public class SchemaLexer extends Lexer { - static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - TITLE=1, VERSION=2, INCLUDE=3, PRAGMA=4, DEFINE=5, SCHEMA=6, TRUE=7, FALSE=8, - NULL=9, COLON=10, COMMA=11, STAR=12, LBRACE=13, RBRACE=14, LBRACKET=15, - RBRACKET=16, LPAREN=17, RPAREN=18, OPTIONAL=19, UNDEFINED=20, IDENTIFIER=21, - ALIAS=22, DATATYPE=23, FUNCTION=24, RECEIVER=25, STRING=26, INTEGER=27, - FLOAT=28, DOUBLE=29, MULTILINE_COMMENT=30, LINE_COMMENT=31, WHITE_SPACE=32, - COLON1=33, VERSION_NUMBER1=34, WHITE_SPACE1=35, MULTILINE_COMMENT1=36, - LINE_COMMENT1=37; - public static final int - DIRECTIVE_VERSION1=1; - public static String[] channelNames = { - "DEFAULT_TOKEN_CHANNEL", "HIDDEN" - }; - - public static String[] modeNames = { - "DEFAULT_MODE", "DIRECTIVE_VERSION1" - }; - - private static String[] makeRuleNames() { - return new String[] { - "TITLE", "VERSION", "INCLUDE", "PRAGMA", "DEFINE", "SCHEMA", "TRUE", - "FALSE", "NULL", "COLON", "COMMA", "STAR", "LBRACE", "RBRACE", "LBRACKET", - "RBRACKET", "LPAREN", "RPAREN", "OPTIONAL", "UNDEFINED", "IDENTIFIER", - "ALIAS", "DATATYPE", "FUNCTION", "RECEIVER", "BASE_IDENTIFIER", "ALPHA", - "ALPHANUMERIC", "STRING", "ESCAPE", "UNICODE", "HEXDIGIT", "SAFECODEPOINT", - "INTEGER", "FLOAT", "DOUBLE", "INTDIGIT", "EXPONENT", "DIGIT", "MULTILINE_COMMENT", - "LINE_COMMENT", "MULTILINE_CMT", "LINE_CMT", "WHITE_SPACE", "WHITE_SPC", - "COLON1", "VERSION_NUMBER1", "WHITE_SPACE1", "MULTILINE_COMMENT1", "LINE_COMMENT1" - }; - } - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[] { - null, "'%title'", "'%version'", "'%include'", "'%pragma'", "'%define'", - "'%schema'", "'true'", "'false'", "'null'", null, "','", "'*'", "'{'", - "'}'", "'['", "']'", "'('", "')'", "'?'", "'!'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, "TITLE", "VERSION", "INCLUDE", "PRAGMA", "DEFINE", "SCHEMA", "TRUE", - "FALSE", "NULL", "COLON", "COMMA", "STAR", "LBRACE", "RBRACE", "LBRACKET", - "RBRACKET", "LPAREN", "RPAREN", "OPTIONAL", "UNDEFINED", "IDENTIFIER", - "ALIAS", "DATATYPE", "FUNCTION", "RECEIVER", "STRING", "INTEGER", "FLOAT", - "DOUBLE", "MULTILINE_COMMENT", "LINE_COMMENT", "WHITE_SPACE", "COLON1", - "VERSION_NUMBER1", "WHITE_SPACE1", "MULTILINE_COMMENT1", "LINE_COMMENT1" - }; - } - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - - public SchemaLexer(CharStream input) { - super(input); - _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @Override - public String getGrammarFileName() { return "SchemaLexer.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public String[] getChannelNames() { return channelNames; } - - @Override - public String[] getModeNames() { return modeNames; } - - @Override - public ATN getATN() { return _ATN; } - - public static final String _serializedATN = - "\u0004\u0000%\u016c\u0006\uffff\uffff\u0006\uffff\uffff\u0002\u0000\u0007"+ - "\u0000\u0002\u0001\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007"+ - "\u0003\u0002\u0004\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007"+ - "\u0006\u0002\u0007\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n"+ - "\u0007\n\u0002\u000b\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002"+ - "\u000e\u0007\u000e\u0002\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002"+ - "\u0011\u0007\u0011\u0002\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002"+ - "\u0014\u0007\u0014\u0002\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002"+ - "\u0017\u0007\u0017\u0002\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002"+ - "\u001a\u0007\u001a\u0002\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002"+ - "\u001d\u0007\u001d\u0002\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002"+ - " \u0007 \u0002!\u0007!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002"+ - "%\u0007%\u0002&\u0007&\u0002\'\u0007\'\u0002(\u0007(\u0002)\u0007)\u0002"+ - "*\u0007*\u0002+\u0007+\u0002,\u0007,\u0002-\u0007-\u0002.\u0007.\u0002"+ - "/\u0007/\u00020\u00070\u00021\u00071\u0001\u0000\u0001\u0000\u0001\u0000"+ - "\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ - "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0002"+ - "\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002"+ - "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003"+ - "\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004"+ - "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005"+ - "\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005"+ - "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0007"+ - "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\b\u0001"+ - "\b\u0001\b\u0001\b\u0001\b\u0001\t\u0001\t\u0001\n\u0001\n\u0001\u000b"+ - "\u0001\u000b\u0001\f\u0001\f\u0001\r\u0001\r\u0001\u000e\u0001\u000e\u0001"+ - "\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001"+ - "\u0012\u0001\u0012\u0001\u0013\u0001\u0013\u0001\u0014\u0001\u0014\u0001"+ - "\u0014\u0005\u0014\u00c3\b\u0014\n\u0014\f\u0014\u00c6\t\u0014\u0001\u0015"+ - "\u0001\u0015\u0001\u0015\u0001\u0016\u0001\u0016\u0004\u0016\u00cd\b\u0016"+ - "\u000b\u0016\f\u0016\u00ce\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0018"+ - "\u0001\u0018\u0001\u0018\u0001\u0019\u0001\u0019\u0005\u0019\u00d9\b\u0019"+ - "\n\u0019\f\u0019\u00dc\t\u0019\u0001\u001a\u0001\u001a\u0001\u001b\u0001"+ - "\u001b\u0001\u001c\u0001\u001c\u0001\u001c\u0005\u001c\u00e5\b\u001c\n"+ - "\u001c\f\u001c\u00e8\t\u001c\u0001\u001c\u0001\u001c\u0001\u001d\u0001"+ - "\u001d\u0001\u001d\u0003\u001d\u00ef\b\u001d\u0001\u001e\u0001\u001e\u0001"+ - "\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001f\u0001\u001f\u0001"+ - " \u0001 \u0001!\u0003!\u00fc\b!\u0001!\u0001!\u0001\"\u0001\"\u0001\""+ - "\u0004\"\u0103\b\"\u000b\"\f\"\u0104\u0001#\u0001#\u0001#\u0004#\u010a"+ - "\b#\u000b#\f#\u010b\u0003#\u010e\b#\u0001#\u0001#\u0001$\u0001$\u0001"+ - "$\u0005$\u0115\b$\n$\f$\u0118\t$\u0003$\u011a\b$\u0001%\u0001%\u0003%"+ - "\u011e\b%\u0001%\u0004%\u0121\b%\u000b%\f%\u0122\u0001&\u0001&\u0001\'"+ - "\u0001\'\u0001\'\u0001\'\u0001(\u0001(\u0001(\u0001(\u0001)\u0001)\u0001"+ - ")\u0001)\u0005)\u0133\b)\n)\f)\u0136\t)\u0001)\u0001)\u0001)\u0001*\u0001"+ - "*\u0001*\u0001*\u0005*\u013f\b*\n*\f*\u0142\t*\u0001+\u0001+\u0001+\u0001"+ - "+\u0001,\u0004,\u0149\b,\u000b,\f,\u014a\u0001-\u0001-\u0001.\u0004.\u0150"+ - "\b.\u000b.\f.\u0151\u0001.\u0001.\u0004.\u0156\b.\u000b.\f.\u0157\u0005"+ - ".\u015a\b.\n.\f.\u015d\t.\u0001.\u0001.\u0001/\u0001/\u0001/\u0001/\u0001"+ - "0\u00010\u00010\u00010\u00011\u00011\u00011\u00011\u0001\u0134\u00002"+ - "\u0002\u0001\u0004\u0002\u0006\u0003\b\u0004\n\u0005\f\u0006\u000e\u0007"+ - "\u0010\b\u0012\t\u0014\n\u0016\u000b\u0018\f\u001a\r\u001c\u000e\u001e"+ - "\u000f \u0010\"\u0011$\u0012&\u0013(\u0014*\u0015,\u0016.\u00170\u0018"+ - "2\u00194\u00006\u00008\u0000:\u001a<\u0000>\u0000@\u0000B\u0000D\u001b"+ - "F\u001cH\u001dJ\u0000L\u0000N\u0000P\u001eR\u001fT\u0000V\u0000X Z\u0000"+ - "\\!^\"`#b$d%\u0002\u0000\u0001\u000b\u0003\u0000AZ__az\u0004\u000009A"+ - "Z__az\b\u0000\"\"//\\\\bbffnnrrtt\u0003\u000009AFaf\u0003\u0000\u0000"+ - "\u001f\"\"\\\\\u0001\u000019\u0002\u0000EEee\u0002\u0000++--\u0001\u0000"+ - "09\u0002\u0000\n\n\r\r\u0003\u0000\t\n\r\r \u0171\u0000\u0002\u0001\u0000"+ - "\u0000\u0000\u0000\u0004\u0001\u0000\u0000\u0000\u0000\u0006\u0001\u0000"+ - "\u0000\u0000\u0000\b\u0001\u0000\u0000\u0000\u0000\n\u0001\u0000\u0000"+ - "\u0000\u0000\f\u0001\u0000\u0000\u0000\u0000\u000e\u0001\u0000\u0000\u0000"+ - "\u0000\u0010\u0001\u0000\u0000\u0000\u0000\u0012\u0001\u0000\u0000\u0000"+ - "\u0000\u0014\u0001\u0000\u0000\u0000\u0000\u0016\u0001\u0000\u0000\u0000"+ - "\u0000\u0018\u0001\u0000\u0000\u0000\u0000\u001a\u0001\u0000\u0000\u0000"+ - "\u0000\u001c\u0001\u0000\u0000\u0000\u0000\u001e\u0001\u0000\u0000\u0000"+ - "\u0000 \u0001\u0000\u0000\u0000\u0000\"\u0001\u0000\u0000\u0000\u0000"+ - "$\u0001\u0000\u0000\u0000\u0000&\u0001\u0000\u0000\u0000\u0000(\u0001"+ - "\u0000\u0000\u0000\u0000*\u0001\u0000\u0000\u0000\u0000,\u0001\u0000\u0000"+ - "\u0000\u0000.\u0001\u0000\u0000\u0000\u00000\u0001\u0000\u0000\u0000\u0000"+ - "2\u0001\u0000\u0000\u0000\u0000:\u0001\u0000\u0000\u0000\u0000D\u0001"+ - "\u0000\u0000\u0000\u0000F\u0001\u0000\u0000\u0000\u0000H\u0001\u0000\u0000"+ - "\u0000\u0000P\u0001\u0000\u0000\u0000\u0000R\u0001\u0000\u0000\u0000\u0000"+ - "X\u0001\u0000\u0000\u0000\u0001\\\u0001\u0000\u0000\u0000\u0001^\u0001"+ - "\u0000\u0000\u0000\u0001`\u0001\u0000\u0000\u0000\u0001b\u0001\u0000\u0000"+ - "\u0000\u0001d\u0001\u0000\u0000\u0000\u0002f\u0001\u0000\u0000\u0000\u0004"+ - "m\u0001\u0000\u0000\u0000\u0006x\u0001\u0000\u0000\u0000\b\u0081\u0001"+ - "\u0000\u0000\u0000\n\u0089\u0001\u0000\u0000\u0000\f\u0091\u0001\u0000"+ - "\u0000\u0000\u000e\u0099\u0001\u0000\u0000\u0000\u0010\u009e\u0001\u0000"+ - "\u0000\u0000\u0012\u00a4\u0001\u0000\u0000\u0000\u0014\u00a9\u0001\u0000"+ - "\u0000\u0000\u0016\u00ab\u0001\u0000\u0000\u0000\u0018\u00ad\u0001\u0000"+ - "\u0000\u0000\u001a\u00af\u0001\u0000\u0000\u0000\u001c\u00b1\u0001\u0000"+ - "\u0000\u0000\u001e\u00b3\u0001\u0000\u0000\u0000 \u00b5\u0001\u0000\u0000"+ - "\u0000\"\u00b7\u0001\u0000\u0000\u0000$\u00b9\u0001\u0000\u0000\u0000"+ - "&\u00bb\u0001\u0000\u0000\u0000(\u00bd\u0001\u0000\u0000\u0000*\u00bf"+ - "\u0001\u0000\u0000\u0000,\u00c7\u0001\u0000\u0000\u0000.\u00ca\u0001\u0000"+ - "\u0000\u00000\u00d0\u0001\u0000\u0000\u00002\u00d3\u0001\u0000\u0000\u0000"+ - "4\u00d6\u0001\u0000\u0000\u00006\u00dd\u0001\u0000\u0000\u00008\u00df"+ - "\u0001\u0000\u0000\u0000:\u00e1\u0001\u0000\u0000\u0000<\u00eb\u0001\u0000"+ - "\u0000\u0000>\u00f0\u0001\u0000\u0000\u0000@\u00f6\u0001\u0000\u0000\u0000"+ - "B\u00f8\u0001\u0000\u0000\u0000D\u00fb\u0001\u0000\u0000\u0000F\u00ff"+ - "\u0001\u0000\u0000\u0000H\u0106\u0001\u0000\u0000\u0000J\u0119\u0001\u0000"+ - "\u0000\u0000L\u011b\u0001\u0000\u0000\u0000N\u0124\u0001\u0000\u0000\u0000"+ - "P\u0126\u0001\u0000\u0000\u0000R\u012a\u0001\u0000\u0000\u0000T\u012e"+ - "\u0001\u0000\u0000\u0000V\u013a\u0001\u0000\u0000\u0000X\u0143\u0001\u0000"+ - "\u0000\u0000Z\u0148\u0001\u0000\u0000\u0000\\\u014c\u0001\u0000\u0000"+ - "\u0000^\u014f\u0001\u0000\u0000\u0000`\u0160\u0001\u0000\u0000\u0000b"+ - "\u0164\u0001\u0000\u0000\u0000d\u0168\u0001\u0000\u0000\u0000fg\u0005"+ - "%\u0000\u0000gh\u0005t\u0000\u0000hi\u0005i\u0000\u0000ij\u0005t\u0000"+ - "\u0000jk\u0005l\u0000\u0000kl\u0005e\u0000\u0000l\u0003\u0001\u0000\u0000"+ - "\u0000mn\u0005%\u0000\u0000no\u0005v\u0000\u0000op\u0005e\u0000\u0000"+ - "pq\u0005r\u0000\u0000qr\u0005s\u0000\u0000rs\u0005i\u0000\u0000st\u0005"+ - "o\u0000\u0000tu\u0005n\u0000\u0000uv\u0001\u0000\u0000\u0000vw\u0006\u0001"+ - "\u0000\u0000w\u0005\u0001\u0000\u0000\u0000xy\u0005%\u0000\u0000yz\u0005"+ - "i\u0000\u0000z{\u0005n\u0000\u0000{|\u0005c\u0000\u0000|}\u0005l\u0000"+ - "\u0000}~\u0005u\u0000\u0000~\u007f\u0005d\u0000\u0000\u007f\u0080\u0005"+ - "e\u0000\u0000\u0080\u0007\u0001\u0000\u0000\u0000\u0081\u0082\u0005%\u0000"+ - "\u0000\u0082\u0083\u0005p\u0000\u0000\u0083\u0084\u0005r\u0000\u0000\u0084"+ - "\u0085\u0005a\u0000\u0000\u0085\u0086\u0005g\u0000\u0000\u0086\u0087\u0005"+ - "m\u0000\u0000\u0087\u0088\u0005a\u0000\u0000\u0088\t\u0001\u0000\u0000"+ - "\u0000\u0089\u008a\u0005%\u0000\u0000\u008a\u008b\u0005d\u0000\u0000\u008b"+ - "\u008c\u0005e\u0000\u0000\u008c\u008d\u0005f\u0000\u0000\u008d\u008e\u0005"+ - "i\u0000\u0000\u008e\u008f\u0005n\u0000\u0000\u008f\u0090\u0005e\u0000"+ - "\u0000\u0090\u000b\u0001\u0000\u0000\u0000\u0091\u0092\u0005%\u0000\u0000"+ - "\u0092\u0093\u0005s\u0000\u0000\u0093\u0094\u0005c\u0000\u0000\u0094\u0095"+ - "\u0005h\u0000\u0000\u0095\u0096\u0005e\u0000\u0000\u0096\u0097\u0005m"+ - "\u0000\u0000\u0097\u0098\u0005a\u0000\u0000\u0098\r\u0001\u0000\u0000"+ - "\u0000\u0099\u009a\u0005t\u0000\u0000\u009a\u009b\u0005r\u0000\u0000\u009b"+ - "\u009c\u0005u\u0000\u0000\u009c\u009d\u0005e\u0000\u0000\u009d\u000f\u0001"+ - "\u0000\u0000\u0000\u009e\u009f\u0005f\u0000\u0000\u009f\u00a0\u0005a\u0000"+ - "\u0000\u00a0\u00a1\u0005l\u0000\u0000\u00a1\u00a2\u0005s\u0000\u0000\u00a2"+ - "\u00a3\u0005e\u0000\u0000\u00a3\u0011\u0001\u0000\u0000\u0000\u00a4\u00a5"+ - "\u0005n\u0000\u0000\u00a5\u00a6\u0005u\u0000\u0000\u00a6\u00a7\u0005l"+ - "\u0000\u0000\u00a7\u00a8\u0005l\u0000\u0000\u00a8\u0013\u0001\u0000\u0000"+ - "\u0000\u00a9\u00aa\u0005:\u0000\u0000\u00aa\u0015\u0001\u0000\u0000\u0000"+ - "\u00ab\u00ac\u0005,\u0000\u0000\u00ac\u0017\u0001\u0000\u0000\u0000\u00ad"+ - "\u00ae\u0005*\u0000\u0000\u00ae\u0019\u0001\u0000\u0000\u0000\u00af\u00b0"+ - "\u0005{\u0000\u0000\u00b0\u001b\u0001\u0000\u0000\u0000\u00b1\u00b2\u0005"+ - "}\u0000\u0000\u00b2\u001d\u0001\u0000\u0000\u0000\u00b3\u00b4\u0005[\u0000"+ - "\u0000\u00b4\u001f\u0001\u0000\u0000\u0000\u00b5\u00b6\u0005]\u0000\u0000"+ - "\u00b6!\u0001\u0000\u0000\u0000\u00b7\u00b8\u0005(\u0000\u0000\u00b8#"+ - "\u0001\u0000\u0000\u0000\u00b9\u00ba\u0005)\u0000\u0000\u00ba%\u0001\u0000"+ - "\u0000\u0000\u00bb\u00bc\u0005?\u0000\u0000\u00bc\'\u0001\u0000\u0000"+ - "\u0000\u00bd\u00be\u0005!\u0000\u0000\u00be)\u0001\u0000\u0000\u0000\u00bf"+ - "\u00c4\u00034\u0019\u0000\u00c0\u00c1\u0005.\u0000\u0000\u00c1\u00c3\u0003"+ - "4\u0019\u0000\u00c2\u00c0\u0001\u0000\u0000\u0000\u00c3\u00c6\u0001\u0000"+ - "\u0000\u0000\u00c4\u00c2\u0001\u0000\u0000\u0000\u00c4\u00c5\u0001\u0000"+ - "\u0000\u0000\u00c5+\u0001\u0000\u0000\u0000\u00c6\u00c4\u0001\u0000\u0000"+ - "\u0000\u00c7\u00c8\u0005$\u0000\u0000\u00c8\u00c9\u00034\u0019\u0000\u00c9"+ - "-\u0001\u0000\u0000\u0000\u00ca\u00cc\u0005#\u0000\u0000\u00cb\u00cd\u0003"+ - "6\u001a\u0000\u00cc\u00cb\u0001\u0000\u0000\u0000\u00cd\u00ce\u0001\u0000"+ - "\u0000\u0000\u00ce\u00cc\u0001\u0000\u0000\u0000\u00ce\u00cf\u0001\u0000"+ - "\u0000\u0000\u00cf/\u0001\u0000\u0000\u0000\u00d0\u00d1\u0005@\u0000\u0000"+ - "\u00d1\u00d2\u00034\u0019\u0000\u00d21\u0001\u0000\u0000\u0000\u00d3\u00d4"+ - "\u0005&\u0000\u0000\u00d4\u00d5\u00034\u0019\u0000\u00d53\u0001\u0000"+ - "\u0000\u0000\u00d6\u00da\u00036\u001a\u0000\u00d7\u00d9\u00038\u001b\u0000"+ - "\u00d8\u00d7\u0001\u0000\u0000\u0000\u00d9\u00dc\u0001\u0000\u0000\u0000"+ - "\u00da\u00d8\u0001\u0000\u0000\u0000\u00da\u00db\u0001\u0000\u0000\u0000"+ - "\u00db5\u0001\u0000\u0000\u0000\u00dc\u00da\u0001\u0000\u0000\u0000\u00dd"+ - "\u00de\u0007\u0000\u0000\u0000\u00de7\u0001\u0000\u0000\u0000\u00df\u00e0"+ - "\u0007\u0001\u0000\u0000\u00e09\u0001\u0000\u0000\u0000\u00e1\u00e6\u0005"+ - "\"\u0000\u0000\u00e2\u00e5\u0003<\u001d\u0000\u00e3\u00e5\u0003B \u0000"+ - "\u00e4\u00e2\u0001\u0000\u0000\u0000\u00e4\u00e3\u0001\u0000\u0000\u0000"+ - "\u00e5\u00e8\u0001\u0000\u0000\u0000\u00e6\u00e4\u0001\u0000\u0000\u0000"+ - "\u00e6\u00e7\u0001\u0000\u0000\u0000\u00e7\u00e9\u0001\u0000\u0000\u0000"+ - "\u00e8\u00e6\u0001\u0000\u0000\u0000\u00e9\u00ea\u0005\"\u0000\u0000\u00ea"+ - ";\u0001\u0000\u0000\u0000\u00eb\u00ee\u0005\\\u0000\u0000\u00ec\u00ef"+ - "\u0007\u0002\u0000\u0000\u00ed\u00ef\u0003>\u001e\u0000\u00ee\u00ec\u0001"+ - "\u0000\u0000\u0000\u00ee\u00ed\u0001\u0000\u0000\u0000\u00ef=\u0001\u0000"+ - "\u0000\u0000\u00f0\u00f1\u0005u\u0000\u0000\u00f1\u00f2\u0003@\u001f\u0000"+ - "\u00f2\u00f3\u0003@\u001f\u0000\u00f3\u00f4\u0003@\u001f\u0000\u00f4\u00f5"+ - "\u0003@\u001f\u0000\u00f5?\u0001\u0000\u0000\u0000\u00f6\u00f7\u0007\u0003"+ - "\u0000\u0000\u00f7A\u0001\u0000\u0000\u0000\u00f8\u00f9\b\u0004\u0000"+ - "\u0000\u00f9C\u0001\u0000\u0000\u0000\u00fa\u00fc\u0005-\u0000\u0000\u00fb"+ - "\u00fa\u0001\u0000\u0000\u0000\u00fb\u00fc\u0001\u0000\u0000\u0000\u00fc"+ - "\u00fd\u0001\u0000\u0000\u0000\u00fd\u00fe\u0003J$\u0000\u00feE\u0001"+ - "\u0000\u0000\u0000\u00ff\u0100\u0003D!\u0000\u0100\u0102\u0005.\u0000"+ - "\u0000\u0101\u0103\u0003N&\u0000\u0102\u0101\u0001\u0000\u0000\u0000\u0103"+ - "\u0104\u0001\u0000\u0000\u0000\u0104\u0102\u0001\u0000\u0000\u0000\u0104"+ - "\u0105\u0001\u0000\u0000\u0000\u0105G\u0001\u0000\u0000\u0000\u0106\u010d"+ - "\u0003D!\u0000\u0107\u0109\u0005.\u0000\u0000\u0108\u010a\u0003N&\u0000"+ - "\u0109\u0108\u0001\u0000\u0000\u0000\u010a\u010b\u0001\u0000\u0000\u0000"+ - "\u010b\u0109\u0001\u0000\u0000\u0000\u010b\u010c\u0001\u0000\u0000\u0000"+ - "\u010c\u010e\u0001\u0000\u0000\u0000\u010d\u0107\u0001\u0000\u0000\u0000"+ - "\u010d\u010e\u0001\u0000\u0000\u0000\u010e\u010f\u0001\u0000\u0000\u0000"+ - "\u010f\u0110\u0003L%\u0000\u0110I\u0001\u0000\u0000\u0000\u0111\u011a"+ - "\u00050\u0000\u0000\u0112\u0116\u0007\u0005\u0000\u0000\u0113\u0115\u0003"+ - "N&\u0000\u0114\u0113\u0001\u0000\u0000\u0000\u0115\u0118\u0001\u0000\u0000"+ - "\u0000\u0116\u0114\u0001\u0000\u0000\u0000\u0116\u0117\u0001\u0000\u0000"+ - "\u0000\u0117\u011a\u0001\u0000\u0000\u0000\u0118\u0116\u0001\u0000\u0000"+ - "\u0000\u0119\u0111\u0001\u0000\u0000\u0000\u0119\u0112\u0001\u0000\u0000"+ - "\u0000\u011aK\u0001\u0000\u0000\u0000\u011b\u011d\u0007\u0006\u0000\u0000"+ - "\u011c\u011e\u0007\u0007\u0000\u0000\u011d\u011c\u0001\u0000\u0000\u0000"+ - "\u011d\u011e\u0001\u0000\u0000\u0000\u011e\u0120\u0001\u0000\u0000\u0000"+ - "\u011f\u0121\u0003N&\u0000\u0120\u011f\u0001\u0000\u0000\u0000\u0121\u0122"+ - "\u0001\u0000\u0000\u0000\u0122\u0120\u0001\u0000\u0000\u0000\u0122\u0123"+ - "\u0001\u0000\u0000\u0000\u0123M\u0001\u0000\u0000\u0000\u0124\u0125\u0007"+ - "\b\u0000\u0000\u0125O\u0001\u0000\u0000\u0000\u0126\u0127\u0003T)\u0000"+ - "\u0127\u0128\u0001\u0000\u0000\u0000\u0128\u0129\u0006\'\u0001\u0000\u0129"+ - "Q\u0001\u0000\u0000\u0000\u012a\u012b\u0003V*\u0000\u012b\u012c\u0001"+ - "\u0000\u0000\u0000\u012c\u012d\u0006(\u0001\u0000\u012dS\u0001\u0000\u0000"+ - "\u0000\u012e\u012f\u0005/\u0000\u0000\u012f\u0130\u0005*\u0000\u0000\u0130"+ - "\u0134\u0001\u0000\u0000\u0000\u0131\u0133\t\u0000\u0000\u0000\u0132\u0131"+ - "\u0001\u0000\u0000\u0000\u0133\u0136\u0001\u0000\u0000\u0000\u0134\u0135"+ - "\u0001\u0000\u0000\u0000\u0134\u0132\u0001\u0000\u0000\u0000\u0135\u0137"+ - "\u0001\u0000\u0000\u0000\u0136\u0134\u0001\u0000\u0000\u0000\u0137\u0138"+ - "\u0005*\u0000\u0000\u0138\u0139\u0005/\u0000\u0000\u0139U\u0001\u0000"+ - "\u0000\u0000\u013a\u013b\u0005/\u0000\u0000\u013b\u013c\u0005/\u0000\u0000"+ - "\u013c\u0140\u0001\u0000\u0000\u0000\u013d\u013f\b\t\u0000\u0000\u013e"+ - "\u013d\u0001\u0000\u0000\u0000\u013f\u0142\u0001\u0000\u0000\u0000\u0140"+ - "\u013e\u0001\u0000\u0000\u0000\u0140\u0141\u0001\u0000\u0000\u0000\u0141"+ - "W\u0001\u0000\u0000\u0000\u0142\u0140\u0001\u0000\u0000\u0000\u0143\u0144"+ - "\u0003Z,\u0000\u0144\u0145\u0001\u0000\u0000\u0000\u0145\u0146\u0006+"+ - "\u0001\u0000\u0146Y\u0001\u0000\u0000\u0000\u0147\u0149\u0007\n\u0000"+ - "\u0000\u0148\u0147\u0001\u0000\u0000\u0000\u0149\u014a\u0001\u0000\u0000"+ - "\u0000\u014a\u0148\u0001\u0000\u0000\u0000\u014a\u014b\u0001\u0000\u0000"+ - "\u0000\u014b[\u0001\u0000\u0000\u0000\u014c\u014d\u0005:\u0000\u0000\u014d"+ - "]\u0001\u0000\u0000\u0000\u014e\u0150\u0003N&\u0000\u014f\u014e\u0001"+ - "\u0000\u0000\u0000\u0150\u0151\u0001\u0000\u0000\u0000\u0151\u014f\u0001"+ - "\u0000\u0000\u0000\u0151\u0152\u0001\u0000\u0000\u0000\u0152\u015b\u0001"+ - "\u0000\u0000\u0000\u0153\u0155\u0005.\u0000\u0000\u0154\u0156\u0003N&"+ - "\u0000\u0155\u0154\u0001\u0000\u0000\u0000\u0156\u0157\u0001\u0000\u0000"+ - "\u0000\u0157\u0155\u0001\u0000\u0000\u0000\u0157\u0158\u0001\u0000\u0000"+ - "\u0000\u0158\u015a\u0001\u0000\u0000\u0000\u0159\u0153\u0001\u0000\u0000"+ - "\u0000\u015a\u015d\u0001\u0000\u0000\u0000\u015b\u0159\u0001\u0000\u0000"+ - "\u0000\u015b\u015c\u0001\u0000\u0000\u0000\u015c\u015e\u0001\u0000\u0000"+ - "\u0000\u015d\u015b\u0001\u0000\u0000\u0000\u015e\u015f\u0006.\u0002\u0000"+ - "\u015f_\u0001\u0000\u0000\u0000\u0160\u0161\u0003Z,\u0000\u0161\u0162"+ - "\u0001\u0000\u0000\u0000\u0162\u0163\u0006/\u0001\u0000\u0163a\u0001\u0000"+ - "\u0000\u0000\u0164\u0165\u0003T)\u0000\u0165\u0166\u0001\u0000\u0000\u0000"+ - "\u0166\u0167\u00060\u0001\u0000\u0167c\u0001\u0000\u0000\u0000\u0168\u0169"+ - "\u0003V*\u0000\u0169\u016a\u0001\u0000\u0000\u0000\u016a\u016b\u00061"+ - "\u0001\u0000\u016be\u0001\u0000\u0000\u0000\u0016\u0000\u0001\u00c4\u00ce"+ - "\u00da\u00e4\u00e6\u00ee\u00fb\u0104\u010b\u010d\u0116\u0119\u011d\u0122"+ - "\u0134\u0140\u014a\u0151\u0157\u015b\u0003\u0005\u0001\u0000\u0000\u0001"+ - "\u0000\u0004\u0000\u0000"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaLexer.tokens b/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaLexer.tokens deleted file mode 100644 index a186819..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaLexer.tokens +++ /dev/null @@ -1,56 +0,0 @@ -TITLE=1 -VERSION=2 -INCLUDE=3 -PRAGMA=4 -DEFINE=5 -SCHEMA=6 -TRUE=7 -FALSE=8 -NULL=9 -COLON=10 -COMMA=11 -STAR=12 -LBRACE=13 -RBRACE=14 -LBRACKET=15 -RBRACKET=16 -LPAREN=17 -RPAREN=18 -OPTIONAL=19 -UNDEFINED=20 -IDENTIFIER=21 -ALIAS=22 -DATATYPE=23 -FUNCTION=24 -RECEIVER=25 -STRING=26 -INTEGER=27 -FLOAT=28 -DOUBLE=29 -MULTILINE_COMMENT=30 -LINE_COMMENT=31 -WHITE_SPACE=32 -COLON1=33 -VERSION_NUMBER1=34 -WHITE_SPACE1=35 -MULTILINE_COMMENT1=36 -LINE_COMMENT1=37 -'%title'=1 -'%version'=2 -'%include'=3 -'%pragma'=4 -'%define'=5 -'%schema'=6 -'true'=7 -'false'=8 -'null'=9 -','=11 -'*'=12 -'{'=13 -'}'=14 -'['=15 -']'=16 -'('=17 -')'=18 -'?'=19 -'!'=20 diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParser.interp b/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParser.interp deleted file mode 100644 index 6c0e994..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParser.interp +++ /dev/null @@ -1,104 +0,0 @@ -token literal names: -null -'%title' -'%version' -'%include' -'%pragma' -'%define' -'%schema' -'true' -'false' -'null' -null -',' -'*' -'{' -'}' -'[' -']' -'(' -')' -'?' -'!' -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null -null - -token symbolic names: -null -TITLE -VERSION -INCLUDE -PRAGMA -DEFINE -SCHEMA -TRUE -FALSE -NULL -COLON -COMMA -STAR -LBRACE -RBRACE -LBRACKET -RBRACKET -LPAREN -RPAREN -OPTIONAL -UNDEFINED -IDENTIFIER -ALIAS -DATATYPE -FUNCTION -RECEIVER -STRING -INTEGER -FLOAT -DOUBLE -MULTILINE_COMMENT -LINE_COMMENT -WHITE_SPACE -COLON1 -VERSION_NUMBER1 -WHITE_SPACE1 -MULTILINE_COMMENT1 -LINE_COMMENT1 - -rule names: -schema -schemaBase -title -version -include -pragma -define -alias -validatorMain -validator -value -receiver -object -property -array -datatype -function -argument -primitive - - -atn: -[4, 1, 37, 249, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 1, 0, 3, 0, 40, 8, 0, 1, 0, 3, 0, 43, 8, 0, 1, 0, 5, 0, 46, 8, 0, 10, 0, 12, 0, 49, 9, 0, 1, 0, 5, 0, 52, 8, 0, 10, 0, 12, 0, 55, 9, 0, 1, 0, 5, 0, 58, 8, 0, 10, 0, 12, 0, 61, 9, 0, 1, 0, 1, 0, 5, 0, 65, 8, 0, 10, 0, 12, 0, 68, 9, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 75, 8, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 94, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 5, 8, 110, 8, 8, 10, 8, 12, 8, 113, 9, 8, 1, 8, 5, 8, 116, 8, 8, 10, 8, 12, 8, 119, 9, 8, 1, 8, 5, 8, 122, 8, 8, 10, 8, 12, 8, 125, 9, 8, 1, 8, 3, 8, 128, 8, 8, 1, 8, 4, 8, 131, 8, 8, 11, 8, 12, 8, 132, 1, 8, 5, 8, 136, 8, 8, 10, 8, 12, 8, 139, 9, 8, 1, 8, 5, 8, 142, 8, 8, 10, 8, 12, 8, 145, 9, 8, 1, 8, 3, 8, 148, 8, 8, 1, 8, 4, 8, 151, 8, 8, 11, 8, 12, 8, 152, 1, 8, 5, 8, 156, 8, 8, 10, 8, 12, 8, 159, 9, 8, 1, 8, 3, 8, 162, 8, 8, 3, 8, 164, 8, 8, 1, 9, 1, 9, 3, 9, 168, 8, 9, 1, 10, 1, 10, 1, 10, 3, 10, 173, 8, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 5, 12, 181, 8, 12, 10, 12, 12, 12, 184, 9, 12, 3, 12, 186, 8, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 5, 14, 198, 8, 14, 10, 14, 12, 14, 201, 9, 14, 3, 14, 203, 8, 14, 1, 14, 1, 14, 1, 15, 1, 15, 3, 15, 209, 8, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 215, 8, 15, 1, 16, 1, 16, 3, 16, 219, 8, 16, 1, 16, 1, 16, 1, 16, 1, 16, 5, 16, 225, 8, 16, 10, 16, 12, 16, 228, 9, 16, 3, 16, 230, 8, 16, 1, 16, 3, 16, 233, 8, 16, 1, 17, 1, 17, 3, 17, 237, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 247, 8, 18, 1, 18, 0, 0, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 0, 0, 271, 0, 74, 1, 0, 0, 0, 2, 76, 1, 0, 0, 0, 4, 80, 1, 0, 0, 0, 6, 84, 1, 0, 0, 0, 8, 88, 1, 0, 0, 0, 10, 95, 1, 0, 0, 0, 12, 100, 1, 0, 0, 0, 14, 105, 1, 0, 0, 0, 16, 163, 1, 0, 0, 0, 18, 167, 1, 0, 0, 0, 20, 172, 1, 0, 0, 0, 22, 174, 1, 0, 0, 0, 24, 176, 1, 0, 0, 0, 26, 189, 1, 0, 0, 0, 28, 193, 1, 0, 0, 0, 30, 206, 1, 0, 0, 0, 32, 216, 1, 0, 0, 0, 34, 236, 1, 0, 0, 0, 36, 246, 1, 0, 0, 0, 38, 40, 3, 4, 2, 0, 39, 38, 1, 0, 0, 0, 39, 40, 1, 0, 0, 0, 40, 42, 1, 0, 0, 0, 41, 43, 3, 6, 3, 0, 42, 41, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 47, 1, 0, 0, 0, 44, 46, 3, 8, 4, 0, 45, 44, 1, 0, 0, 0, 46, 49, 1, 0, 0, 0, 47, 45, 1, 0, 0, 0, 47, 48, 1, 0, 0, 0, 48, 53, 1, 0, 0, 0, 49, 47, 1, 0, 0, 0, 50, 52, 3, 10, 5, 0, 51, 50, 1, 0, 0, 0, 52, 55, 1, 0, 0, 0, 53, 51, 1, 0, 0, 0, 53, 54, 1, 0, 0, 0, 54, 59, 1, 0, 0, 0, 55, 53, 1, 0, 0, 0, 56, 58, 3, 12, 6, 0, 57, 56, 1, 0, 0, 0, 58, 61, 1, 0, 0, 0, 59, 57, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 62, 1, 0, 0, 0, 61, 59, 1, 0, 0, 0, 62, 66, 3, 2, 1, 0, 63, 65, 3, 12, 6, 0, 64, 63, 1, 0, 0, 0, 65, 68, 1, 0, 0, 0, 66, 64, 1, 0, 0, 0, 66, 67, 1, 0, 0, 0, 67, 69, 1, 0, 0, 0, 68, 66, 1, 0, 0, 0, 69, 70, 5, 0, 0, 1, 70, 75, 1, 0, 0, 0, 71, 72, 3, 18, 9, 0, 72, 73, 5, 0, 0, 1, 73, 75, 1, 0, 0, 0, 74, 39, 1, 0, 0, 0, 74, 71, 1, 0, 0, 0, 75, 1, 1, 0, 0, 0, 76, 77, 5, 6, 0, 0, 77, 78, 5, 10, 0, 0, 78, 79, 3, 18, 9, 0, 79, 3, 1, 0, 0, 0, 80, 81, 5, 1, 0, 0, 81, 82, 5, 10, 0, 0, 82, 83, 5, 26, 0, 0, 83, 5, 1, 0, 0, 0, 84, 85, 5, 2, 0, 0, 85, 86, 5, 33, 0, 0, 86, 87, 5, 34, 0, 0, 87, 7, 1, 0, 0, 0, 88, 89, 5, 3, 0, 0, 89, 90, 5, 10, 0, 0, 90, 93, 5, 21, 0, 0, 91, 92, 5, 11, 0, 0, 92, 94, 5, 21, 0, 0, 93, 91, 1, 0, 0, 0, 93, 94, 1, 0, 0, 0, 94, 9, 1, 0, 0, 0, 95, 96, 5, 4, 0, 0, 96, 97, 5, 21, 0, 0, 97, 98, 5, 10, 0, 0, 98, 99, 3, 36, 18, 0, 99, 11, 1, 0, 0, 0, 100, 101, 5, 5, 0, 0, 101, 102, 3, 14, 7, 0, 102, 103, 5, 10, 0, 0, 103, 104, 3, 16, 8, 0, 104, 13, 1, 0, 0, 0, 105, 106, 5, 22, 0, 0, 106, 15, 1, 0, 0, 0, 107, 111, 3, 20, 10, 0, 108, 110, 3, 32, 16, 0, 109, 108, 1, 0, 0, 0, 110, 113, 1, 0, 0, 0, 111, 109, 1, 0, 0, 0, 111, 112, 1, 0, 0, 0, 112, 117, 1, 0, 0, 0, 113, 111, 1, 0, 0, 0, 114, 116, 3, 30, 15, 0, 115, 114, 1, 0, 0, 0, 116, 119, 1, 0, 0, 0, 117, 115, 1, 0, 0, 0, 117, 118, 1, 0, 0, 0, 118, 123, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 120, 122, 3, 22, 11, 0, 121, 120, 1, 0, 0, 0, 122, 125, 1, 0, 0, 0, 123, 121, 1, 0, 0, 0, 123, 124, 1, 0, 0, 0, 124, 127, 1, 0, 0, 0, 125, 123, 1, 0, 0, 0, 126, 128, 5, 19, 0, 0, 127, 126, 1, 0, 0, 0, 127, 128, 1, 0, 0, 0, 128, 164, 1, 0, 0, 0, 129, 131, 3, 32, 16, 0, 130, 129, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 130, 1, 0, 0, 0, 132, 133, 1, 0, 0, 0, 133, 137, 1, 0, 0, 0, 134, 136, 3, 30, 15, 0, 135, 134, 1, 0, 0, 0, 136, 139, 1, 0, 0, 0, 137, 135, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 143, 1, 0, 0, 0, 139, 137, 1, 0, 0, 0, 140, 142, 3, 22, 11, 0, 141, 140, 1, 0, 0, 0, 142, 145, 1, 0, 0, 0, 143, 141, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 144, 147, 1, 0, 0, 0, 145, 143, 1, 0, 0, 0, 146, 148, 5, 19, 0, 0, 147, 146, 1, 0, 0, 0, 147, 148, 1, 0, 0, 0, 148, 164, 1, 0, 0, 0, 149, 151, 3, 30, 15, 0, 150, 149, 1, 0, 0, 0, 151, 152, 1, 0, 0, 0, 152, 150, 1, 0, 0, 0, 152, 153, 1, 0, 0, 0, 153, 157, 1, 0, 0, 0, 154, 156, 3, 22, 11, 0, 155, 154, 1, 0, 0, 0, 156, 159, 1, 0, 0, 0, 157, 155, 1, 0, 0, 0, 157, 158, 1, 0, 0, 0, 158, 161, 1, 0, 0, 0, 159, 157, 1, 0, 0, 0, 160, 162, 5, 19, 0, 0, 161, 160, 1, 0, 0, 0, 161, 162, 1, 0, 0, 0, 162, 164, 1, 0, 0, 0, 163, 107, 1, 0, 0, 0, 163, 130, 1, 0, 0, 0, 163, 150, 1, 0, 0, 0, 164, 17, 1, 0, 0, 0, 165, 168, 3, 16, 8, 0, 166, 168, 3, 14, 7, 0, 167, 165, 1, 0, 0, 0, 167, 166, 1, 0, 0, 0, 168, 19, 1, 0, 0, 0, 169, 173, 3, 36, 18, 0, 170, 173, 3, 24, 12, 0, 171, 173, 3, 28, 14, 0, 172, 169, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 171, 1, 0, 0, 0, 173, 21, 1, 0, 0, 0, 174, 175, 5, 25, 0, 0, 175, 23, 1, 0, 0, 0, 176, 185, 5, 13, 0, 0, 177, 182, 3, 26, 13, 0, 178, 179, 5, 11, 0, 0, 179, 181, 3, 26, 13, 0, 180, 178, 1, 0, 0, 0, 181, 184, 1, 0, 0, 0, 182, 180, 1, 0, 0, 0, 182, 183, 1, 0, 0, 0, 183, 186, 1, 0, 0, 0, 184, 182, 1, 0, 0, 0, 185, 177, 1, 0, 0, 0, 185, 186, 1, 0, 0, 0, 186, 187, 1, 0, 0, 0, 187, 188, 5, 14, 0, 0, 188, 25, 1, 0, 0, 0, 189, 190, 5, 26, 0, 0, 190, 191, 5, 10, 0, 0, 191, 192, 3, 18, 9, 0, 192, 27, 1, 0, 0, 0, 193, 202, 5, 15, 0, 0, 194, 199, 3, 18, 9, 0, 195, 196, 5, 11, 0, 0, 196, 198, 3, 18, 9, 0, 197, 195, 1, 0, 0, 0, 198, 201, 1, 0, 0, 0, 199, 197, 1, 0, 0, 0, 199, 200, 1, 0, 0, 0, 200, 203, 1, 0, 0, 0, 201, 199, 1, 0, 0, 0, 202, 194, 1, 0, 0, 0, 202, 203, 1, 0, 0, 0, 203, 204, 1, 0, 0, 0, 204, 205, 5, 16, 0, 0, 205, 29, 1, 0, 0, 0, 206, 208, 5, 23, 0, 0, 207, 209, 5, 12, 0, 0, 208, 207, 1, 0, 0, 0, 208, 209, 1, 0, 0, 0, 209, 214, 1, 0, 0, 0, 210, 211, 5, 17, 0, 0, 211, 212, 3, 14, 7, 0, 212, 213, 5, 18, 0, 0, 213, 215, 1, 0, 0, 0, 214, 210, 1, 0, 0, 0, 214, 215, 1, 0, 0, 0, 215, 31, 1, 0, 0, 0, 216, 218, 5, 24, 0, 0, 217, 219, 5, 12, 0, 0, 218, 217, 1, 0, 0, 0, 218, 219, 1, 0, 0, 0, 219, 232, 1, 0, 0, 0, 220, 229, 5, 17, 0, 0, 221, 226, 3, 34, 17, 0, 222, 223, 5, 11, 0, 0, 223, 225, 3, 34, 17, 0, 224, 222, 1, 0, 0, 0, 225, 228, 1, 0, 0, 0, 226, 224, 1, 0, 0, 0, 226, 227, 1, 0, 0, 0, 227, 230, 1, 0, 0, 0, 228, 226, 1, 0, 0, 0, 229, 221, 1, 0, 0, 0, 229, 230, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 233, 5, 18, 0, 0, 232, 220, 1, 0, 0, 0, 232, 233, 1, 0, 0, 0, 233, 33, 1, 0, 0, 0, 234, 237, 3, 20, 10, 0, 235, 237, 3, 22, 11, 0, 236, 234, 1, 0, 0, 0, 236, 235, 1, 0, 0, 0, 237, 35, 1, 0, 0, 0, 238, 247, 5, 7, 0, 0, 239, 247, 5, 8, 0, 0, 240, 247, 5, 26, 0, 0, 241, 247, 5, 27, 0, 0, 242, 247, 5, 28, 0, 0, 243, 247, 5, 29, 0, 0, 244, 247, 5, 9, 0, 0, 245, 247, 5, 20, 0, 0, 246, 238, 1, 0, 0, 0, 246, 239, 1, 0, 0, 0, 246, 240, 1, 0, 0, 0, 246, 241, 1, 0, 0, 0, 246, 242, 1, 0, 0, 0, 246, 243, 1, 0, 0, 0, 246, 244, 1, 0, 0, 0, 246, 245, 1, 0, 0, 0, 247, 37, 1, 0, 0, 0, 34, 39, 42, 47, 53, 59, 66, 74, 93, 111, 117, 123, 127, 132, 137, 143, 147, 152, 157, 161, 163, 167, 172, 182, 185, 199, 202, 208, 214, 218, 226, 229, 232, 236, 246] \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParser.java b/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParser.java deleted file mode 100644 index 276a478..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParser.java +++ /dev/null @@ -1,1797 +0,0 @@ -package com.relogiclabs.json.schema.internal.antlr; - -import org.antlr.v4.runtime.NoViableAltException; -import org.antlr.v4.runtime.Parser; -import org.antlr.v4.runtime.ParserRuleContext; -import org.antlr.v4.runtime.RecognitionException; -import org.antlr.v4.runtime.RuntimeMetaData; -import org.antlr.v4.runtime.TokenStream; -import org.antlr.v4.runtime.Vocabulary; -import org.antlr.v4.runtime.VocabularyImpl; -import org.antlr.v4.runtime.atn.ATN; -import org.antlr.v4.runtime.atn.ATNDeserializer; -import org.antlr.v4.runtime.atn.ParserATNSimulator; -import org.antlr.v4.runtime.atn.PredictionContextCache; -import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.tree.ParseTreeVisitor; -import org.antlr.v4.runtime.tree.TerminalNode; - -import java.util.List; - -@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) -public class SchemaParser extends Parser { - static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - TITLE=1, VERSION=2, INCLUDE=3, PRAGMA=4, DEFINE=5, SCHEMA=6, TRUE=7, FALSE=8, - NULL=9, COLON=10, COMMA=11, STAR=12, LBRACE=13, RBRACE=14, LBRACKET=15, - RBRACKET=16, LPAREN=17, RPAREN=18, OPTIONAL=19, UNDEFINED=20, IDENTIFIER=21, - ALIAS=22, DATATYPE=23, FUNCTION=24, RECEIVER=25, STRING=26, INTEGER=27, - FLOAT=28, DOUBLE=29, MULTILINE_COMMENT=30, LINE_COMMENT=31, WHITE_SPACE=32, - COLON1=33, VERSION_NUMBER1=34, WHITE_SPACE1=35, MULTILINE_COMMENT1=36, - LINE_COMMENT1=37; - public static final int - RULE_schema = 0, RULE_schemaBase = 1, RULE_title = 2, RULE_version = 3, - RULE_include = 4, RULE_pragma = 5, RULE_define = 6, RULE_alias = 7, RULE_validatorMain = 8, - RULE_validator = 9, RULE_value = 10, RULE_receiver = 11, RULE_object = 12, - RULE_property = 13, RULE_array = 14, RULE_datatype = 15, RULE_function = 16, - RULE_argument = 17, RULE_primitive = 18; - private static String[] makeRuleNames() { - return new String[] { - "schema", "schemaBase", "title", "version", "include", "pragma", "define", - "alias", "validatorMain", "validator", "value", "receiver", "object", - "property", "array", "datatype", "function", "argument", "primitive" - }; - } - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[] { - null, "'%title'", "'%version'", "'%include'", "'%pragma'", "'%define'", - "'%schema'", "'true'", "'false'", "'null'", null, "','", "'*'", "'{'", - "'}'", "'['", "']'", "'('", "')'", "'?'", "'!'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, "TITLE", "VERSION", "INCLUDE", "PRAGMA", "DEFINE", "SCHEMA", "TRUE", - "FALSE", "NULL", "COLON", "COMMA", "STAR", "LBRACE", "RBRACE", "LBRACKET", - "RBRACKET", "LPAREN", "RPAREN", "OPTIONAL", "UNDEFINED", "IDENTIFIER", - "ALIAS", "DATATYPE", "FUNCTION", "RECEIVER", "STRING", "INTEGER", "FLOAT", - "DOUBLE", "MULTILINE_COMMENT", "LINE_COMMENT", "WHITE_SPACE", "COLON1", - "VERSION_NUMBER1", "WHITE_SPACE1", "MULTILINE_COMMENT1", "LINE_COMMENT1" - }; - } - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - @Override - public String getGrammarFileName() { return "SchemaParser.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public ATN getATN() { return _ATN; } - - public SchemaParser(TokenStream input) { - super(input); - _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @SuppressWarnings("CheckReturnValue") - public static class SchemaContext extends ParserRuleContext { - public SchemaContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_schema; } - - public SchemaContext() { } - public void copyFrom(SchemaContext ctx) { - super.copyFrom(ctx); - } - } - @SuppressWarnings("CheckReturnValue") - public static class CoreSchemaContext extends SchemaContext { - public ValidatorContext validator() { - return getRuleContext(ValidatorContext.class,0); - } - public TerminalNode EOF() { return getToken(SchemaParser.EOF, 0); } - public CoreSchemaContext(SchemaContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitCoreSchema(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class AggregateSchemaContext extends SchemaContext { - public SchemaBaseContext schemaBase() { - return getRuleContext(SchemaBaseContext.class,0); - } - public TerminalNode EOF() { return getToken(SchemaParser.EOF, 0); } - public TitleContext title() { - return getRuleContext(TitleContext.class,0); - } - public VersionContext version() { - return getRuleContext(VersionContext.class,0); - } - public List include() { - return getRuleContexts(IncludeContext.class); - } - public IncludeContext include(int i) { - return getRuleContext(IncludeContext.class,i); - } - public List pragma() { - return getRuleContexts(PragmaContext.class); - } - public PragmaContext pragma(int i) { - return getRuleContext(PragmaContext.class,i); - } - public List define() { - return getRuleContexts(DefineContext.class); - } - public DefineContext define(int i) { - return getRuleContext(DefineContext.class,i); - } - public AggregateSchemaContext(SchemaContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitAggregateSchema(this); - else return visitor.visitChildren(this); - } - } - - public final SchemaContext schema() throws RecognitionException { - SchemaContext _localctx = new SchemaContext(_ctx, getState()); - enterRule(_localctx, 0, RULE_schema); - int _la; - try { - setState(74); - _errHandler.sync(this); - switch (_input.LA(1)) { - case TITLE: - case VERSION: - case INCLUDE: - case PRAGMA: - case DEFINE: - case SCHEMA: - _localctx = new AggregateSchemaContext(_localctx); - enterOuterAlt(_localctx, 1); - { - setState(39); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==TITLE) { - { - setState(38); - title(); - } - } - - setState(42); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VERSION) { - { - setState(41); - version(); - } - } - - setState(47); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==INCLUDE) { - { - { - setState(44); - include(); - } - } - setState(49); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(53); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==PRAGMA) { - { - { - setState(50); - pragma(); - } - } - setState(55); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(59); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==DEFINE) { - { - { - setState(56); - define(); - } - } - setState(61); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(62); - schemaBase(); - setState(66); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==DEFINE) { - { - { - setState(63); - define(); - } - } - setState(68); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(69); - match(EOF); - } - break; - case TRUE: - case FALSE: - case NULL: - case LBRACE: - case LBRACKET: - case UNDEFINED: - case ALIAS: - case DATATYPE: - case FUNCTION: - case STRING: - case INTEGER: - case FLOAT: - case DOUBLE: - _localctx = new CoreSchemaContext(_localctx); - enterOuterAlt(_localctx, 2); - { - setState(71); - validator(); - setState(72); - match(EOF); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class SchemaBaseContext extends ParserRuleContext { - public TerminalNode SCHEMA() { return getToken(SchemaParser.SCHEMA, 0); } - public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } - public ValidatorContext validator() { - return getRuleContext(ValidatorContext.class,0); - } - public SchemaBaseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_schemaBase; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitSchemaBase(this); - else return visitor.visitChildren(this); - } - } - - public final SchemaBaseContext schemaBase() throws RecognitionException { - SchemaBaseContext _localctx = new SchemaBaseContext(_ctx, getState()); - enterRule(_localctx, 2, RULE_schemaBase); - try { - enterOuterAlt(_localctx, 1); - { - setState(76); - match(SCHEMA); - setState(77); - match(COLON); - setState(78); - validator(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class TitleContext extends ParserRuleContext { - public TerminalNode TITLE() { return getToken(SchemaParser.TITLE, 0); } - public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } - public TerminalNode STRING() { return getToken(SchemaParser.STRING, 0); } - public TitleContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_title; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitTitle(this); - else return visitor.visitChildren(this); - } - } - - public final TitleContext title() throws RecognitionException { - TitleContext _localctx = new TitleContext(_ctx, getState()); - enterRule(_localctx, 4, RULE_title); - try { - enterOuterAlt(_localctx, 1); - { - setState(80); - match(TITLE); - setState(81); - match(COLON); - setState(82); - match(STRING); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class VersionContext extends ParserRuleContext { - public TerminalNode VERSION() { return getToken(SchemaParser.VERSION, 0); } - public TerminalNode COLON1() { return getToken(SchemaParser.COLON1, 0); } - public TerminalNode VERSION_NUMBER1() { return getToken(SchemaParser.VERSION_NUMBER1, 0); } - public VersionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_version; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitVersion(this); - else return visitor.visitChildren(this); - } - } - - public final VersionContext version() throws RecognitionException { - VersionContext _localctx = new VersionContext(_ctx, getState()); - enterRule(_localctx, 6, RULE_version); - try { - enterOuterAlt(_localctx, 1); - { - setState(84); - match(VERSION); - setState(85); - match(COLON1); - setState(86); - match(VERSION_NUMBER1); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class IncludeContext extends ParserRuleContext { - public TerminalNode INCLUDE() { return getToken(SchemaParser.INCLUDE, 0); } - public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } - public List IDENTIFIER() { return getTokens(SchemaParser.IDENTIFIER); } - public TerminalNode IDENTIFIER(int i) { - return getToken(SchemaParser.IDENTIFIER, i); - } - public TerminalNode COMMA() { return getToken(SchemaParser.COMMA, 0); } - public IncludeContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_include; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitInclude(this); - else return visitor.visitChildren(this); - } - } - - public final IncludeContext include() throws RecognitionException { - IncludeContext _localctx = new IncludeContext(_ctx, getState()); - enterRule(_localctx, 8, RULE_include); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(88); - match(INCLUDE); - setState(89); - match(COLON); - setState(90); - match(IDENTIFIER); - setState(93); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COMMA) { - { - setState(91); - match(COMMA); - setState(92); - match(IDENTIFIER); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class PragmaContext extends ParserRuleContext { - public TerminalNode PRAGMA() { return getToken(SchemaParser.PRAGMA, 0); } - public TerminalNode IDENTIFIER() { return getToken(SchemaParser.IDENTIFIER, 0); } - public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } - public PrimitiveContext primitive() { - return getRuleContext(PrimitiveContext.class,0); - } - public PragmaContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_pragma; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPragma(this); - else return visitor.visitChildren(this); - } - } - - public final PragmaContext pragma() throws RecognitionException { - PragmaContext _localctx = new PragmaContext(_ctx, getState()); - enterRule(_localctx, 10, RULE_pragma); - try { - enterOuterAlt(_localctx, 1); - { - setState(95); - match(PRAGMA); - setState(96); - match(IDENTIFIER); - setState(97); - match(COLON); - setState(98); - primitive(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class DefineContext extends ParserRuleContext { - public TerminalNode DEFINE() { return getToken(SchemaParser.DEFINE, 0); } - public AliasContext alias() { - return getRuleContext(AliasContext.class,0); - } - public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } - public ValidatorMainContext validatorMain() { - return getRuleContext(ValidatorMainContext.class,0); - } - public DefineContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_define; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitDefine(this); - else return visitor.visitChildren(this); - } - } - - public final DefineContext define() throws RecognitionException { - DefineContext _localctx = new DefineContext(_ctx, getState()); - enterRule(_localctx, 12, RULE_define); - try { - enterOuterAlt(_localctx, 1); - { - setState(100); - match(DEFINE); - setState(101); - alias(); - setState(102); - match(COLON); - setState(103); - validatorMain(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class AliasContext extends ParserRuleContext { - public TerminalNode ALIAS() { return getToken(SchemaParser.ALIAS, 0); } - public AliasContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_alias; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitAlias(this); - else return visitor.visitChildren(this); - } - } - - public final AliasContext alias() throws RecognitionException { - AliasContext _localctx = new AliasContext(_ctx, getState()); - enterRule(_localctx, 14, RULE_alias); - try { - enterOuterAlt(_localctx, 1); - { - setState(105); - match(ALIAS); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ValidatorMainContext extends ParserRuleContext { - public ValueContext value() { - return getRuleContext(ValueContext.class,0); - } - public List function() { - return getRuleContexts(FunctionContext.class); - } - public FunctionContext function(int i) { - return getRuleContext(FunctionContext.class,i); - } - public List datatype() { - return getRuleContexts(DatatypeContext.class); - } - public DatatypeContext datatype(int i) { - return getRuleContext(DatatypeContext.class,i); - } - public List receiver() { - return getRuleContexts(ReceiverContext.class); - } - public ReceiverContext receiver(int i) { - return getRuleContext(ReceiverContext.class,i); - } - public TerminalNode OPTIONAL() { return getToken(SchemaParser.OPTIONAL, 0); } - public ValidatorMainContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_validatorMain; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitValidatorMain(this); - else return visitor.visitChildren(this); - } - } - - public final ValidatorMainContext validatorMain() throws RecognitionException { - ValidatorMainContext _localctx = new ValidatorMainContext(_ctx, getState()); - enterRule(_localctx, 16, RULE_validatorMain); - int _la; - try { - setState(163); - _errHandler.sync(this); - switch (_input.LA(1)) { - case TRUE: - case FALSE: - case NULL: - case LBRACE: - case LBRACKET: - case UNDEFINED: - case STRING: - case INTEGER: - case FLOAT: - case DOUBLE: - enterOuterAlt(_localctx, 1); - { - setState(107); - value(); - setState(111); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==FUNCTION) { - { - { - setState(108); - function(); - } - } - setState(113); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(117); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==DATATYPE) { - { - { - setState(114); - datatype(); - } - } - setState(119); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(123); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==RECEIVER) { - { - { - setState(120); - receiver(); - } - } - setState(125); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(127); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==OPTIONAL) { - { - setState(126); - match(OPTIONAL); - } - } - - } - break; - case FUNCTION: - enterOuterAlt(_localctx, 2); - { - setState(130); - _errHandler.sync(this); - _la = _input.LA(1); - do { - { - { - setState(129); - function(); - } - } - setState(132); - _errHandler.sync(this); - _la = _input.LA(1); - } while ( _la==FUNCTION ); - setState(137); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==DATATYPE) { - { - { - setState(134); - datatype(); - } - } - setState(139); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(143); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==RECEIVER) { - { - { - setState(140); - receiver(); - } - } - setState(145); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(147); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==OPTIONAL) { - { - setState(146); - match(OPTIONAL); - } - } - - } - break; - case DATATYPE: - enterOuterAlt(_localctx, 3); - { - setState(150); - _errHandler.sync(this); - _la = _input.LA(1); - do { - { - { - setState(149); - datatype(); - } - } - setState(152); - _errHandler.sync(this); - _la = _input.LA(1); - } while ( _la==DATATYPE ); - setState(157); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==RECEIVER) { - { - { - setState(154); - receiver(); - } - } - setState(159); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(161); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==OPTIONAL) { - { - setState(160); - match(OPTIONAL); - } - } - - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ValidatorContext extends ParserRuleContext { - public ValidatorMainContext validatorMain() { - return getRuleContext(ValidatorMainContext.class,0); - } - public AliasContext alias() { - return getRuleContext(AliasContext.class,0); - } - public ValidatorContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_validator; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitValidator(this); - else return visitor.visitChildren(this); - } - } - - public final ValidatorContext validator() throws RecognitionException { - ValidatorContext _localctx = new ValidatorContext(_ctx, getState()); - enterRule(_localctx, 18, RULE_validator); - try { - setState(167); - _errHandler.sync(this); - switch (_input.LA(1)) { - case TRUE: - case FALSE: - case NULL: - case LBRACE: - case LBRACKET: - case UNDEFINED: - case DATATYPE: - case FUNCTION: - case STRING: - case INTEGER: - case FLOAT: - case DOUBLE: - enterOuterAlt(_localctx, 1); - { - setState(165); - validatorMain(); - } - break; - case ALIAS: - enterOuterAlt(_localctx, 2); - { - setState(166); - alias(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ValueContext extends ParserRuleContext { - public PrimitiveContext primitive() { - return getRuleContext(PrimitiveContext.class,0); - } - public ObjectContext object() { - return getRuleContext(ObjectContext.class,0); - } - public ArrayContext array() { - return getRuleContext(ArrayContext.class,0); - } - public ValueContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_value; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitValue(this); - else return visitor.visitChildren(this); - } - } - - public final ValueContext value() throws RecognitionException { - ValueContext _localctx = new ValueContext(_ctx, getState()); - enterRule(_localctx, 20, RULE_value); - try { - setState(172); - _errHandler.sync(this); - switch (_input.LA(1)) { - case TRUE: - case FALSE: - case NULL: - case UNDEFINED: - case STRING: - case INTEGER: - case FLOAT: - case DOUBLE: - enterOuterAlt(_localctx, 1); - { - setState(169); - primitive(); - } - break; - case LBRACE: - enterOuterAlt(_localctx, 2); - { - setState(170); - object(); - } - break; - case LBRACKET: - enterOuterAlt(_localctx, 3); - { - setState(171); - array(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ReceiverContext extends ParserRuleContext { - public TerminalNode RECEIVER() { return getToken(SchemaParser.RECEIVER, 0); } - public ReceiverContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_receiver; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitReceiver(this); - else return visitor.visitChildren(this); - } - } - - public final ReceiverContext receiver() throws RecognitionException { - ReceiverContext _localctx = new ReceiverContext(_ctx, getState()); - enterRule(_localctx, 22, RULE_receiver); - try { - enterOuterAlt(_localctx, 1); - { - setState(174); - match(RECEIVER); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ObjectContext extends ParserRuleContext { - public TerminalNode LBRACE() { return getToken(SchemaParser.LBRACE, 0); } - public TerminalNode RBRACE() { return getToken(SchemaParser.RBRACE, 0); } - public List property() { - return getRuleContexts(PropertyContext.class); - } - public PropertyContext property(int i) { - return getRuleContext(PropertyContext.class,i); - } - public List COMMA() { return getTokens(SchemaParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(SchemaParser.COMMA, i); - } - public ObjectContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_object; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitObject(this); - else return visitor.visitChildren(this); - } - } - - public final ObjectContext object() throws RecognitionException { - ObjectContext _localctx = new ObjectContext(_ctx, getState()); - enterRule(_localctx, 24, RULE_object); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(176); - match(LBRACE); - setState(185); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==STRING) { - { - setState(177); - property(); - setState(182); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==COMMA) { - { - { - setState(178); - match(COMMA); - setState(179); - property(); - } - } - setState(184); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - - setState(187); - match(RBRACE); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class PropertyContext extends ParserRuleContext { - public TerminalNode STRING() { return getToken(SchemaParser.STRING, 0); } - public TerminalNode COLON() { return getToken(SchemaParser.COLON, 0); } - public ValidatorContext validator() { - return getRuleContext(ValidatorContext.class,0); - } - public PropertyContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_property; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitProperty(this); - else return visitor.visitChildren(this); - } - } - - public final PropertyContext property() throws RecognitionException { - PropertyContext _localctx = new PropertyContext(_ctx, getState()); - enterRule(_localctx, 26, RULE_property); - try { - enterOuterAlt(_localctx, 1); - { - setState(189); - match(STRING); - setState(190); - match(COLON); - setState(191); - validator(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ArrayContext extends ParserRuleContext { - public TerminalNode LBRACKET() { return getToken(SchemaParser.LBRACKET, 0); } - public TerminalNode RBRACKET() { return getToken(SchemaParser.RBRACKET, 0); } - public List validator() { - return getRuleContexts(ValidatorContext.class); - } - public ValidatorContext validator(int i) { - return getRuleContext(ValidatorContext.class,i); - } - public List COMMA() { return getTokens(SchemaParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(SchemaParser.COMMA, i); - } - public ArrayContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_array; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitArray(this); - else return visitor.visitChildren(this); - } - } - - public final ArrayContext array() throws RecognitionException { - ArrayContext _localctx = new ArrayContext(_ctx, getState()); - enterRule(_localctx, 28, RULE_array); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(193); - match(LBRACKET); - setState(202); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 1037083520L) != 0)) { - { - setState(194); - validator(); - setState(199); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==COMMA) { - { - { - setState(195); - match(COMMA); - setState(196); - validator(); - } - } - setState(201); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - - setState(204); - match(RBRACKET); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class DatatypeContext extends ParserRuleContext { - public TerminalNode DATATYPE() { return getToken(SchemaParser.DATATYPE, 0); } - public TerminalNode STAR() { return getToken(SchemaParser.STAR, 0); } - public TerminalNode LPAREN() { return getToken(SchemaParser.LPAREN, 0); } - public AliasContext alias() { - return getRuleContext(AliasContext.class,0); - } - public TerminalNode RPAREN() { return getToken(SchemaParser.RPAREN, 0); } - public DatatypeContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_datatype; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitDatatype(this); - else return visitor.visitChildren(this); - } - } - - public final DatatypeContext datatype() throws RecognitionException { - DatatypeContext _localctx = new DatatypeContext(_ctx, getState()); - enterRule(_localctx, 30, RULE_datatype); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(206); - match(DATATYPE); - setState(208); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==STAR) { - { - setState(207); - match(STAR); - } - } - - setState(214); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LPAREN) { - { - setState(210); - match(LPAREN); - setState(211); - alias(); - setState(212); - match(RPAREN); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class FunctionContext extends ParserRuleContext { - public TerminalNode FUNCTION() { return getToken(SchemaParser.FUNCTION, 0); } - public TerminalNode STAR() { return getToken(SchemaParser.STAR, 0); } - public TerminalNode LPAREN() { return getToken(SchemaParser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(SchemaParser.RPAREN, 0); } - public List argument() { - return getRuleContexts(ArgumentContext.class); - } - public ArgumentContext argument(int i) { - return getRuleContext(ArgumentContext.class,i); - } - public List COMMA() { return getTokens(SchemaParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(SchemaParser.COMMA, i); - } - public FunctionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_function; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitFunction(this); - else return visitor.visitChildren(this); - } - } - - public final FunctionContext function() throws RecognitionException { - FunctionContext _localctx = new FunctionContext(_ctx, getState()); - enterRule(_localctx, 32, RULE_function); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(216); - match(FUNCTION); - setState(218); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==STAR) { - { - setState(217); - match(STAR); - } - } - - setState(232); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LPAREN) { - { - setState(220); - match(LPAREN); - setState(229); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 1041277824L) != 0)) { - { - setState(221); - argument(); - setState(226); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==COMMA) { - { - { - setState(222); - match(COMMA); - setState(223); - argument(); - } - } - setState(228); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - - setState(231); - match(RPAREN); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class ArgumentContext extends ParserRuleContext { - public ValueContext value() { - return getRuleContext(ValueContext.class,0); - } - public ReceiverContext receiver() { - return getRuleContext(ReceiverContext.class,0); - } - public ArgumentContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_argument; } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitArgument(this); - else return visitor.visitChildren(this); - } - } - - public final ArgumentContext argument() throws RecognitionException { - ArgumentContext _localctx = new ArgumentContext(_ctx, getState()); - enterRule(_localctx, 34, RULE_argument); - try { - setState(236); - _errHandler.sync(this); - switch (_input.LA(1)) { - case TRUE: - case FALSE: - case NULL: - case LBRACE: - case LBRACKET: - case UNDEFINED: - case STRING: - case INTEGER: - case FLOAT: - case DOUBLE: - enterOuterAlt(_localctx, 1); - { - setState(234); - value(); - } - break; - case RECEIVER: - enterOuterAlt(_localctx, 2); - { - setState(235); - receiver(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveContext extends ParserRuleContext { - public PrimitiveContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_primitive; } - - public PrimitiveContext() { } - public void copyFrom(PrimitiveContext ctx) { - super.copyFrom(ctx); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveDoubleContext extends PrimitiveContext { - public TerminalNode DOUBLE() { return getToken(SchemaParser.DOUBLE, 0); } - public PrimitiveDoubleContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveDouble(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveFloatContext extends PrimitiveContext { - public TerminalNode FLOAT() { return getToken(SchemaParser.FLOAT, 0); } - public PrimitiveFloatContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveFloat(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveNullContext extends PrimitiveContext { - public TerminalNode NULL() { return getToken(SchemaParser.NULL, 0); } - public PrimitiveNullContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveNull(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveUndefinedContext extends PrimitiveContext { - public TerminalNode UNDEFINED() { return getToken(SchemaParser.UNDEFINED, 0); } - public PrimitiveUndefinedContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveUndefined(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveTrueContext extends PrimitiveContext { - public TerminalNode TRUE() { return getToken(SchemaParser.TRUE, 0); } - public PrimitiveTrueContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveTrue(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveFalseContext extends PrimitiveContext { - public TerminalNode FALSE() { return getToken(SchemaParser.FALSE, 0); } - public PrimitiveFalseContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveFalse(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveStringContext extends PrimitiveContext { - public TerminalNode STRING() { return getToken(SchemaParser.STRING, 0); } - public PrimitiveStringContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveString(this); - else return visitor.visitChildren(this); - } - } - @SuppressWarnings("CheckReturnValue") - public static class PrimitiveIntegerContext extends PrimitiveContext { - public TerminalNode INTEGER() { return getToken(SchemaParser.INTEGER, 0); } - public PrimitiveIntegerContext(PrimitiveContext ctx) { copyFrom(ctx); } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof SchemaParserVisitor ) return ((SchemaParserVisitor)visitor).visitPrimitiveInteger(this); - else return visitor.visitChildren(this); - } - } - - public final PrimitiveContext primitive() throws RecognitionException { - PrimitiveContext _localctx = new PrimitiveContext(_ctx, getState()); - enterRule(_localctx, 36, RULE_primitive); - try { - setState(246); - _errHandler.sync(this); - switch (_input.LA(1)) { - case TRUE: - _localctx = new PrimitiveTrueContext(_localctx); - enterOuterAlt(_localctx, 1); - { - setState(238); - match(TRUE); - } - break; - case FALSE: - _localctx = new PrimitiveFalseContext(_localctx); - enterOuterAlt(_localctx, 2); - { - setState(239); - match(FALSE); - } - break; - case STRING: - _localctx = new PrimitiveStringContext(_localctx); - enterOuterAlt(_localctx, 3); - { - setState(240); - match(STRING); - } - break; - case INTEGER: - _localctx = new PrimitiveIntegerContext(_localctx); - enterOuterAlt(_localctx, 4); - { - setState(241); - match(INTEGER); - } - break; - case FLOAT: - _localctx = new PrimitiveFloatContext(_localctx); - enterOuterAlt(_localctx, 5); - { - setState(242); - match(FLOAT); - } - break; - case DOUBLE: - _localctx = new PrimitiveDoubleContext(_localctx); - enterOuterAlt(_localctx, 6); - { - setState(243); - match(DOUBLE); - } - break; - case NULL: - _localctx = new PrimitiveNullContext(_localctx); - enterOuterAlt(_localctx, 7); - { - setState(244); - match(NULL); - } - break; - case UNDEFINED: - _localctx = new PrimitiveUndefinedContext(_localctx); - enterOuterAlt(_localctx, 8); - { - setState(245); - match(UNDEFINED); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static final String _serializedATN = - "\u0004\u0001%\u00f9\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ - "\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+ - "\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007\u0002"+ - "\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b\u0007\u000b\u0002"+ - "\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0002\u000f\u0007\u000f"+ - "\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011\u0002\u0012\u0007\u0012"+ - "\u0001\u0000\u0003\u0000(\b\u0000\u0001\u0000\u0003\u0000+\b\u0000\u0001"+ - "\u0000\u0005\u0000.\b\u0000\n\u0000\f\u00001\t\u0000\u0001\u0000\u0005"+ - "\u00004\b\u0000\n\u0000\f\u00007\t\u0000\u0001\u0000\u0005\u0000:\b\u0000"+ - "\n\u0000\f\u0000=\t\u0000\u0001\u0000\u0001\u0000\u0005\u0000A\b\u0000"+ - "\n\u0000\f\u0000D\t\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000"+ - "\u0001\u0000\u0003\u0000K\b\u0000\u0001\u0001\u0001\u0001\u0001\u0001"+ - "\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003"+ - "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004"+ - "\u0001\u0004\u0001\u0004\u0003\u0004^\b\u0004\u0001\u0005\u0001\u0005"+ - "\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+ - "\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0001\b\u0001\b\u0005"+ - "\bn\b\b\n\b\f\bq\t\b\u0001\b\u0005\bt\b\b\n\b\f\bw\t\b\u0001\b\u0005\b"+ - "z\b\b\n\b\f\b}\t\b\u0001\b\u0003\b\u0080\b\b\u0001\b\u0004\b\u0083\b\b"+ - "\u000b\b\f\b\u0084\u0001\b\u0005\b\u0088\b\b\n\b\f\b\u008b\t\b\u0001\b"+ - "\u0005\b\u008e\b\b\n\b\f\b\u0091\t\b\u0001\b\u0003\b\u0094\b\b\u0001\b"+ - "\u0004\b\u0097\b\b\u000b\b\f\b\u0098\u0001\b\u0005\b\u009c\b\b\n\b\f\b"+ - "\u009f\t\b\u0001\b\u0003\b\u00a2\b\b\u0003\b\u00a4\b\b\u0001\t\u0001\t"+ - "\u0003\t\u00a8\b\t\u0001\n\u0001\n\u0001\n\u0003\n\u00ad\b\n\u0001\u000b"+ - "\u0001\u000b\u0001\f\u0001\f\u0001\f\u0001\f\u0005\f\u00b5\b\f\n\f\f\f"+ - "\u00b8\t\f\u0003\f\u00ba\b\f\u0001\f\u0001\f\u0001\r\u0001\r\u0001\r\u0001"+ - "\r\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0005\u000e\u00c6\b"+ - "\u000e\n\u000e\f\u000e\u00c9\t\u000e\u0003\u000e\u00cb\b\u000e\u0001\u000e"+ - "\u0001\u000e\u0001\u000f\u0001\u000f\u0003\u000f\u00d1\b\u000f\u0001\u000f"+ - "\u0001\u000f\u0001\u000f\u0001\u000f\u0003\u000f\u00d7\b\u000f\u0001\u0010"+ - "\u0001\u0010\u0003\u0010\u00db\b\u0010\u0001\u0010\u0001\u0010\u0001\u0010"+ - "\u0001\u0010\u0005\u0010\u00e1\b\u0010\n\u0010\f\u0010\u00e4\t\u0010\u0003"+ - "\u0010\u00e6\b\u0010\u0001\u0010\u0003\u0010\u00e9\b\u0010\u0001\u0011"+ - "\u0001\u0011\u0003\u0011\u00ed\b\u0011\u0001\u0012\u0001\u0012\u0001\u0012"+ - "\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0003\u0012"+ - "\u00f7\b\u0012\u0001\u0012\u0000\u0000\u0013\u0000\u0002\u0004\u0006\b"+ - "\n\f\u000e\u0010\u0012\u0014\u0016\u0018\u001a\u001c\u001e \"$\u0000\u0000"+ - "\u010f\u0000J\u0001\u0000\u0000\u0000\u0002L\u0001\u0000\u0000\u0000\u0004"+ - "P\u0001\u0000\u0000\u0000\u0006T\u0001\u0000\u0000\u0000\bX\u0001\u0000"+ - "\u0000\u0000\n_\u0001\u0000\u0000\u0000\fd\u0001\u0000\u0000\u0000\u000e"+ - "i\u0001\u0000\u0000\u0000\u0010\u00a3\u0001\u0000\u0000\u0000\u0012\u00a7"+ - "\u0001\u0000\u0000\u0000\u0014\u00ac\u0001\u0000\u0000\u0000\u0016\u00ae"+ - "\u0001\u0000\u0000\u0000\u0018\u00b0\u0001\u0000\u0000\u0000\u001a\u00bd"+ - "\u0001\u0000\u0000\u0000\u001c\u00c1\u0001\u0000\u0000\u0000\u001e\u00ce"+ - "\u0001\u0000\u0000\u0000 \u00d8\u0001\u0000\u0000\u0000\"\u00ec\u0001"+ - "\u0000\u0000\u0000$\u00f6\u0001\u0000\u0000\u0000&(\u0003\u0004\u0002"+ - "\u0000\'&\u0001\u0000\u0000\u0000\'(\u0001\u0000\u0000\u0000(*\u0001\u0000"+ - "\u0000\u0000)+\u0003\u0006\u0003\u0000*)\u0001\u0000\u0000\u0000*+\u0001"+ - "\u0000\u0000\u0000+/\u0001\u0000\u0000\u0000,.\u0003\b\u0004\u0000-,\u0001"+ - "\u0000\u0000\u0000.1\u0001\u0000\u0000\u0000/-\u0001\u0000\u0000\u0000"+ - "/0\u0001\u0000\u0000\u000005\u0001\u0000\u0000\u00001/\u0001\u0000\u0000"+ - "\u000024\u0003\n\u0005\u000032\u0001\u0000\u0000\u000047\u0001\u0000\u0000"+ - "\u000053\u0001\u0000\u0000\u000056\u0001\u0000\u0000\u00006;\u0001\u0000"+ - "\u0000\u000075\u0001\u0000\u0000\u00008:\u0003\f\u0006\u000098\u0001\u0000"+ - "\u0000\u0000:=\u0001\u0000\u0000\u0000;9\u0001\u0000\u0000\u0000;<\u0001"+ - "\u0000\u0000\u0000<>\u0001\u0000\u0000\u0000=;\u0001\u0000\u0000\u0000"+ - ">B\u0003\u0002\u0001\u0000?A\u0003\f\u0006\u0000@?\u0001\u0000\u0000\u0000"+ - "AD\u0001\u0000\u0000\u0000B@\u0001\u0000\u0000\u0000BC\u0001\u0000\u0000"+ - "\u0000CE\u0001\u0000\u0000\u0000DB\u0001\u0000\u0000\u0000EF\u0005\u0000"+ - "\u0000\u0001FK\u0001\u0000\u0000\u0000GH\u0003\u0012\t\u0000HI\u0005\u0000"+ - "\u0000\u0001IK\u0001\u0000\u0000\u0000J\'\u0001\u0000\u0000\u0000JG\u0001"+ - "\u0000\u0000\u0000K\u0001\u0001\u0000\u0000\u0000LM\u0005\u0006\u0000"+ - "\u0000MN\u0005\n\u0000\u0000NO\u0003\u0012\t\u0000O\u0003\u0001\u0000"+ - "\u0000\u0000PQ\u0005\u0001\u0000\u0000QR\u0005\n\u0000\u0000RS\u0005\u001a"+ - "\u0000\u0000S\u0005\u0001\u0000\u0000\u0000TU\u0005\u0002\u0000\u0000"+ - "UV\u0005!\u0000\u0000VW\u0005\"\u0000\u0000W\u0007\u0001\u0000\u0000\u0000"+ - "XY\u0005\u0003\u0000\u0000YZ\u0005\n\u0000\u0000Z]\u0005\u0015\u0000\u0000"+ - "[\\\u0005\u000b\u0000\u0000\\^\u0005\u0015\u0000\u0000][\u0001\u0000\u0000"+ - "\u0000]^\u0001\u0000\u0000\u0000^\t\u0001\u0000\u0000\u0000_`\u0005\u0004"+ - "\u0000\u0000`a\u0005\u0015\u0000\u0000ab\u0005\n\u0000\u0000bc\u0003$"+ - "\u0012\u0000c\u000b\u0001\u0000\u0000\u0000de\u0005\u0005\u0000\u0000"+ - "ef\u0003\u000e\u0007\u0000fg\u0005\n\u0000\u0000gh\u0003\u0010\b\u0000"+ - "h\r\u0001\u0000\u0000\u0000ij\u0005\u0016\u0000\u0000j\u000f\u0001\u0000"+ - "\u0000\u0000ko\u0003\u0014\n\u0000ln\u0003 \u0010\u0000ml\u0001\u0000"+ - "\u0000\u0000nq\u0001\u0000\u0000\u0000om\u0001\u0000\u0000\u0000op\u0001"+ - "\u0000\u0000\u0000pu\u0001\u0000\u0000\u0000qo\u0001\u0000\u0000\u0000"+ - "rt\u0003\u001e\u000f\u0000sr\u0001\u0000\u0000\u0000tw\u0001\u0000\u0000"+ - "\u0000us\u0001\u0000\u0000\u0000uv\u0001\u0000\u0000\u0000v{\u0001\u0000"+ - "\u0000\u0000wu\u0001\u0000\u0000\u0000xz\u0003\u0016\u000b\u0000yx\u0001"+ - "\u0000\u0000\u0000z}\u0001\u0000\u0000\u0000{y\u0001\u0000\u0000\u0000"+ - "{|\u0001\u0000\u0000\u0000|\u007f\u0001\u0000\u0000\u0000}{\u0001\u0000"+ - "\u0000\u0000~\u0080\u0005\u0013\u0000\u0000\u007f~\u0001\u0000\u0000\u0000"+ - "\u007f\u0080\u0001\u0000\u0000\u0000\u0080\u00a4\u0001\u0000\u0000\u0000"+ - "\u0081\u0083\u0003 \u0010\u0000\u0082\u0081\u0001\u0000\u0000\u0000\u0083"+ - "\u0084\u0001\u0000\u0000\u0000\u0084\u0082\u0001\u0000\u0000\u0000\u0084"+ - "\u0085\u0001\u0000\u0000\u0000\u0085\u0089\u0001\u0000\u0000\u0000\u0086"+ - "\u0088\u0003\u001e\u000f\u0000\u0087\u0086\u0001\u0000\u0000\u0000\u0088"+ - "\u008b\u0001\u0000\u0000\u0000\u0089\u0087\u0001\u0000\u0000\u0000\u0089"+ - "\u008a\u0001\u0000\u0000\u0000\u008a\u008f\u0001\u0000\u0000\u0000\u008b"+ - "\u0089\u0001\u0000\u0000\u0000\u008c\u008e\u0003\u0016\u000b\u0000\u008d"+ - "\u008c\u0001\u0000\u0000\u0000\u008e\u0091\u0001\u0000\u0000\u0000\u008f"+ - "\u008d\u0001\u0000\u0000\u0000\u008f\u0090\u0001\u0000\u0000\u0000\u0090"+ - "\u0093\u0001\u0000\u0000\u0000\u0091\u008f\u0001\u0000\u0000\u0000\u0092"+ - "\u0094\u0005\u0013\u0000\u0000\u0093\u0092\u0001\u0000\u0000\u0000\u0093"+ - "\u0094\u0001\u0000\u0000\u0000\u0094\u00a4\u0001\u0000\u0000\u0000\u0095"+ - "\u0097\u0003\u001e\u000f\u0000\u0096\u0095\u0001\u0000\u0000\u0000\u0097"+ - "\u0098\u0001\u0000\u0000\u0000\u0098\u0096\u0001\u0000\u0000\u0000\u0098"+ - "\u0099\u0001\u0000\u0000\u0000\u0099\u009d\u0001\u0000\u0000\u0000\u009a"+ - "\u009c\u0003\u0016\u000b\u0000\u009b\u009a\u0001\u0000\u0000\u0000\u009c"+ - "\u009f\u0001\u0000\u0000\u0000\u009d\u009b\u0001\u0000\u0000\u0000\u009d"+ - "\u009e\u0001\u0000\u0000\u0000\u009e\u00a1\u0001\u0000\u0000\u0000\u009f"+ - "\u009d\u0001\u0000\u0000\u0000\u00a0\u00a2\u0005\u0013\u0000\u0000\u00a1"+ - "\u00a0\u0001\u0000\u0000\u0000\u00a1\u00a2\u0001\u0000\u0000\u0000\u00a2"+ - "\u00a4\u0001\u0000\u0000\u0000\u00a3k\u0001\u0000\u0000\u0000\u00a3\u0082"+ - "\u0001\u0000\u0000\u0000\u00a3\u0096\u0001\u0000\u0000\u0000\u00a4\u0011"+ - "\u0001\u0000\u0000\u0000\u00a5\u00a8\u0003\u0010\b\u0000\u00a6\u00a8\u0003"+ - "\u000e\u0007\u0000\u00a7\u00a5\u0001\u0000\u0000\u0000\u00a7\u00a6\u0001"+ - "\u0000\u0000\u0000\u00a8\u0013\u0001\u0000\u0000\u0000\u00a9\u00ad\u0003"+ - "$\u0012\u0000\u00aa\u00ad\u0003\u0018\f\u0000\u00ab\u00ad\u0003\u001c"+ - "\u000e\u0000\u00ac\u00a9\u0001\u0000\u0000\u0000\u00ac\u00aa\u0001\u0000"+ - "\u0000\u0000\u00ac\u00ab\u0001\u0000\u0000\u0000\u00ad\u0015\u0001\u0000"+ - "\u0000\u0000\u00ae\u00af\u0005\u0019\u0000\u0000\u00af\u0017\u0001\u0000"+ - "\u0000\u0000\u00b0\u00b9\u0005\r\u0000\u0000\u00b1\u00b6\u0003\u001a\r"+ - "\u0000\u00b2\u00b3\u0005\u000b\u0000\u0000\u00b3\u00b5\u0003\u001a\r\u0000"+ - "\u00b4\u00b2\u0001\u0000\u0000\u0000\u00b5\u00b8\u0001\u0000\u0000\u0000"+ - "\u00b6\u00b4\u0001\u0000\u0000\u0000\u00b6\u00b7\u0001\u0000\u0000\u0000"+ - "\u00b7\u00ba\u0001\u0000\u0000\u0000\u00b8\u00b6\u0001\u0000\u0000\u0000"+ - "\u00b9\u00b1\u0001\u0000\u0000\u0000\u00b9\u00ba\u0001\u0000\u0000\u0000"+ - "\u00ba\u00bb\u0001\u0000\u0000\u0000\u00bb\u00bc\u0005\u000e\u0000\u0000"+ - "\u00bc\u0019\u0001\u0000\u0000\u0000\u00bd\u00be\u0005\u001a\u0000\u0000"+ - "\u00be\u00bf\u0005\n\u0000\u0000\u00bf\u00c0\u0003\u0012\t\u0000\u00c0"+ - "\u001b\u0001\u0000\u0000\u0000\u00c1\u00ca\u0005\u000f\u0000\u0000\u00c2"+ - "\u00c7\u0003\u0012\t\u0000\u00c3\u00c4\u0005\u000b\u0000\u0000\u00c4\u00c6"+ - "\u0003\u0012\t\u0000\u00c5\u00c3\u0001\u0000\u0000\u0000\u00c6\u00c9\u0001"+ - "\u0000\u0000\u0000\u00c7\u00c5\u0001\u0000\u0000\u0000\u00c7\u00c8\u0001"+ - "\u0000\u0000\u0000\u00c8\u00cb\u0001\u0000\u0000\u0000\u00c9\u00c7\u0001"+ - "\u0000\u0000\u0000\u00ca\u00c2\u0001\u0000\u0000\u0000\u00ca\u00cb\u0001"+ - "\u0000\u0000\u0000\u00cb\u00cc\u0001\u0000\u0000\u0000\u00cc\u00cd\u0005"+ - "\u0010\u0000\u0000\u00cd\u001d\u0001\u0000\u0000\u0000\u00ce\u00d0\u0005"+ - "\u0017\u0000\u0000\u00cf\u00d1\u0005\f\u0000\u0000\u00d0\u00cf\u0001\u0000"+ - "\u0000\u0000\u00d0\u00d1\u0001\u0000\u0000\u0000\u00d1\u00d6\u0001\u0000"+ - "\u0000\u0000\u00d2\u00d3\u0005\u0011\u0000\u0000\u00d3\u00d4\u0003\u000e"+ - "\u0007\u0000\u00d4\u00d5\u0005\u0012\u0000\u0000\u00d5\u00d7\u0001\u0000"+ - "\u0000\u0000\u00d6\u00d2\u0001\u0000\u0000\u0000\u00d6\u00d7\u0001\u0000"+ - "\u0000\u0000\u00d7\u001f\u0001\u0000\u0000\u0000\u00d8\u00da\u0005\u0018"+ - "\u0000\u0000\u00d9\u00db\u0005\f\u0000\u0000\u00da\u00d9\u0001\u0000\u0000"+ - "\u0000\u00da\u00db\u0001\u0000\u0000\u0000\u00db\u00e8\u0001\u0000\u0000"+ - "\u0000\u00dc\u00e5\u0005\u0011\u0000\u0000\u00dd\u00e2\u0003\"\u0011\u0000"+ - "\u00de\u00df\u0005\u000b\u0000\u0000\u00df\u00e1\u0003\"\u0011\u0000\u00e0"+ - "\u00de\u0001\u0000\u0000\u0000\u00e1\u00e4\u0001\u0000\u0000\u0000\u00e2"+ - "\u00e0\u0001\u0000\u0000\u0000\u00e2\u00e3\u0001\u0000\u0000\u0000\u00e3"+ - "\u00e6\u0001\u0000\u0000\u0000\u00e4\u00e2\u0001\u0000\u0000\u0000\u00e5"+ - "\u00dd\u0001\u0000\u0000\u0000\u00e5\u00e6\u0001\u0000\u0000\u0000\u00e6"+ - "\u00e7\u0001\u0000\u0000\u0000\u00e7\u00e9\u0005\u0012\u0000\u0000\u00e8"+ - "\u00dc\u0001\u0000\u0000\u0000\u00e8\u00e9\u0001\u0000\u0000\u0000\u00e9"+ - "!\u0001\u0000\u0000\u0000\u00ea\u00ed\u0003\u0014\n\u0000\u00eb\u00ed"+ - "\u0003\u0016\u000b\u0000\u00ec\u00ea\u0001\u0000\u0000\u0000\u00ec\u00eb"+ - "\u0001\u0000\u0000\u0000\u00ed#\u0001\u0000\u0000\u0000\u00ee\u00f7\u0005"+ - "\u0007\u0000\u0000\u00ef\u00f7\u0005\b\u0000\u0000\u00f0\u00f7\u0005\u001a"+ - "\u0000\u0000\u00f1\u00f7\u0005\u001b\u0000\u0000\u00f2\u00f7\u0005\u001c"+ - "\u0000\u0000\u00f3\u00f7\u0005\u001d\u0000\u0000\u00f4\u00f7\u0005\t\u0000"+ - "\u0000\u00f5\u00f7\u0005\u0014\u0000\u0000\u00f6\u00ee\u0001\u0000\u0000"+ - "\u0000\u00f6\u00ef\u0001\u0000\u0000\u0000\u00f6\u00f0\u0001\u0000\u0000"+ - "\u0000\u00f6\u00f1\u0001\u0000\u0000\u0000\u00f6\u00f2\u0001\u0000\u0000"+ - "\u0000\u00f6\u00f3\u0001\u0000\u0000\u0000\u00f6\u00f4\u0001\u0000\u0000"+ - "\u0000\u00f6\u00f5\u0001\u0000\u0000\u0000\u00f7%\u0001\u0000\u0000\u0000"+ - "\"\'*/5;BJ]ou{\u007f\u0084\u0089\u008f\u0093\u0098\u009d\u00a1\u00a3\u00a7"+ - "\u00ac\u00b6\u00b9\u00c7\u00ca\u00d0\u00d6\u00da\u00e2\u00e5\u00e8\u00ec"+ - "\u00f6"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParser.tokens b/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParser.tokens deleted file mode 100644 index a186819..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParser.tokens +++ /dev/null @@ -1,56 +0,0 @@ -TITLE=1 -VERSION=2 -INCLUDE=3 -PRAGMA=4 -DEFINE=5 -SCHEMA=6 -TRUE=7 -FALSE=8 -NULL=9 -COLON=10 -COMMA=11 -STAR=12 -LBRACE=13 -RBRACE=14 -LBRACKET=15 -RBRACKET=16 -LPAREN=17 -RPAREN=18 -OPTIONAL=19 -UNDEFINED=20 -IDENTIFIER=21 -ALIAS=22 -DATATYPE=23 -FUNCTION=24 -RECEIVER=25 -STRING=26 -INTEGER=27 -FLOAT=28 -DOUBLE=29 -MULTILINE_COMMENT=30 -LINE_COMMENT=31 -WHITE_SPACE=32 -COLON1=33 -VERSION_NUMBER1=34 -WHITE_SPACE1=35 -MULTILINE_COMMENT1=36 -LINE_COMMENT1=37 -'%title'=1 -'%version'=2 -'%include'=3 -'%pragma'=4 -'%define'=5 -'%schema'=6 -'true'=7 -'false'=8 -'null'=9 -','=11 -'*'=12 -'{'=13 -'}'=14 -'['=15 -']'=16 -'('=17 -')'=18 -'?'=19 -'!'=20 diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParserBaseVisitor.java b/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParserBaseVisitor.java deleted file mode 100644 index d5c4bd9..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParserBaseVisitor.java +++ /dev/null @@ -1,203 +0,0 @@ -package com.relogiclabs.json.schema.internal.antlr; -import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; - -/** - * This class provides an empty implementation of {@link SchemaParserVisitor}, - * which can be extended to create a visitor which only needs to handle a subset - * of the available methods. - * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. - */ -@SuppressWarnings("CheckReturnValue") -public class SchemaParserBaseVisitor extends AbstractParseTreeVisitor implements SchemaParserVisitor { - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitAggregateSchema(SchemaParser.AggregateSchemaContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitCoreSchema(SchemaParser.CoreSchemaContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitSchemaBase(SchemaParser.SchemaBaseContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitTitle(SchemaParser.TitleContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitVersion(SchemaParser.VersionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitInclude(SchemaParser.IncludeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPragma(SchemaParser.PragmaContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitDefine(SchemaParser.DefineContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitAlias(SchemaParser.AliasContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitValidatorMain(SchemaParser.ValidatorMainContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitValidator(SchemaParser.ValidatorContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitValue(SchemaParser.ValueContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitReceiver(SchemaParser.ReceiverContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitObject(SchemaParser.ObjectContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitProperty(SchemaParser.PropertyContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitArray(SchemaParser.ArrayContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitDatatype(SchemaParser.DatatypeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitFunction(SchemaParser.FunctionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitArgument(SchemaParser.ArgumentContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveTrue(SchemaParser.PrimitiveTrueContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveFalse(SchemaParser.PrimitiveFalseContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveString(SchemaParser.PrimitiveStringContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveInteger(SchemaParser.PrimitiveIntegerContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveFloat(SchemaParser.PrimitiveFloatContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveDouble(SchemaParser.PrimitiveDoubleContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveNull(SchemaParser.PrimitiveNullContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

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

- */ - @Override public T visitPrimitiveUndefined(SchemaParser.PrimitiveUndefinedContext ctx) { return visitChildren(ctx); } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParserVisitor.java b/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParserVisitor.java deleted file mode 100644 index 1d9c768..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/antlr/SchemaParserVisitor.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.relogiclabs.json.schema.internal.antlr; -import org.antlr.v4.runtime.tree.ParseTreeVisitor; - -/** - * This interface defines a complete generic visitor for a parse tree produced - * by {@link SchemaParser}. - * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. - */ -public interface SchemaParserVisitor extends ParseTreeVisitor { - /** - * Visit a parse tree produced by the {@code AggregateSchema} - * labeled alternative in {@link SchemaParser#schema}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitAggregateSchema(SchemaParser.AggregateSchemaContext ctx); - /** - * Visit a parse tree produced by the {@code CoreSchema} - * labeled alternative in {@link SchemaParser#schema}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitCoreSchema(SchemaParser.CoreSchemaContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#schemaBase}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitSchemaBase(SchemaParser.SchemaBaseContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#title}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitTitle(SchemaParser.TitleContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#version}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitVersion(SchemaParser.VersionContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#include}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitInclude(SchemaParser.IncludeContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#pragma}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPragma(SchemaParser.PragmaContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#define}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitDefine(SchemaParser.DefineContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#alias}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitAlias(SchemaParser.AliasContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#validatorMain}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitValidatorMain(SchemaParser.ValidatorMainContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#validator}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitValidator(SchemaParser.ValidatorContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#value}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitValue(SchemaParser.ValueContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#receiver}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitReceiver(SchemaParser.ReceiverContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#object}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitObject(SchemaParser.ObjectContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#property}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitProperty(SchemaParser.PropertyContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#array}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitArray(SchemaParser.ArrayContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#datatype}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitDatatype(SchemaParser.DatatypeContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#function}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFunction(SchemaParser.FunctionContext ctx); - /** - * Visit a parse tree produced by {@link SchemaParser#argument}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitArgument(SchemaParser.ArgumentContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveTrue} - * labeled alternative in {@link SchemaParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveTrue(SchemaParser.PrimitiveTrueContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveFalse} - * labeled alternative in {@link SchemaParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveFalse(SchemaParser.PrimitiveFalseContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveString} - * labeled alternative in {@link SchemaParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveString(SchemaParser.PrimitiveStringContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveInteger} - * labeled alternative in {@link SchemaParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveInteger(SchemaParser.PrimitiveIntegerContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveFloat} - * labeled alternative in {@link SchemaParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveFloat(SchemaParser.PrimitiveFloatContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveDouble} - * labeled alternative in {@link SchemaParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveDouble(SchemaParser.PrimitiveDoubleContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveNull} - * labeled alternative in {@link SchemaParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveNull(SchemaParser.PrimitiveNullContext ctx); - /** - * Visit a parse tree produced by the {@code PrimitiveUndefined} - * labeled alternative in {@link SchemaParser#primitive}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimitiveUndefined(SchemaParser.PrimitiveUndefinedContext ctx); -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/function/DateTimeAgent.java b/src/main/java/com/relogiclabs/json/schema/internal/function/DateTimeAgent.java deleted file mode 100644 index d480a0e..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/function/DateTimeAgent.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.relogiclabs.json.schema.internal.function; - -import com.relogiclabs.json.schema.exception.DateTimeLexerException; -import com.relogiclabs.json.schema.exception.InvalidDateTimeException; -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.internal.time.DateTimeParser; -import com.relogiclabs.json.schema.message.ActualDetail; -import com.relogiclabs.json.schema.message.ErrorDetail; -import com.relogiclabs.json.schema.message.ExpectedDetail; -import com.relogiclabs.json.schema.time.DateTimeType; -import com.relogiclabs.json.schema.time.JsonDateTime; -import com.relogiclabs.json.schema.type.JFunction; -import com.relogiclabs.json.schema.type.JString; - -public class DateTimeAgent { - private final String pattern; - private final DateTimeType type; - private DateTimeParser parser; - - public DateTimeAgent(String pattern, DateTimeType type) { - this.pattern = pattern; - this.type = type; - } - - public DateTimeAgent(DateTimeParser parser) { - this.pattern = parser.getPattern(); - this.type = parser.getType(); - this.parser = parser; - } - - public JsonDateTime parse(JFunction function, JString dateTime) { - var exceptions = function.getRuntime().getExceptions(); - try { - if(parser == null) parser = new DateTimeParser(pattern, type); - return parser.parse(dateTime.getValue()); - } catch(DateTimeLexerException ex) { - exceptions.failWith(new JsonSchemaException( - new ErrorDetail(ex.getCode(), ex.getMessage()), - new ExpectedDetail(function, "a valid ", type, " pattern"), - new ActualDetail(dateTime, "found ", pattern, " that is invalid"), - ex)); - } catch(InvalidDateTimeException ex) { - exceptions.failWith(new JsonSchemaException( - new ErrorDetail(ex.getCode(), ex.getMessage()), - new ExpectedDetail(function, "a valid ", type, " formatted as ", pattern), - new ActualDetail(dateTime, "found ", dateTime, " that is invalid or malformatted"), - ex)); - } - return null; - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/grammar/SchemaLexer.g4 b/src/main/java/com/relogiclabs/json/schema/internal/grammar/SchemaLexer.g4 deleted file mode 100644 index 83f3784..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/grammar/SchemaLexer.g4 +++ /dev/null @@ -1,74 +0,0 @@ -lexer grammar SchemaLexer; - -// Components -TITLE: '%title'; -VERSION: '%version' -> pushMode(DIRECTIVE_VERSION1); -INCLUDE: '%include'; -PRAGMA: '%pragma'; -DEFINE: '%define'; -SCHEMA: '%schema'; - -// Keywords -TRUE: 'true'; -FALSE: 'false'; -NULL: 'null'; - -// Symbols -COLON: ':'; -COMMA: ','; -STAR: '*'; -LBRACE: '{'; -RBRACE: '}'; -LBRACKET: '['; -RBRACKET: ']'; -LPAREN: '('; -RPAREN: ')'; -OPTIONAL: '?'; -UNDEFINED: '!'; - -// Identifiers -IDENTIFIER: BASE_IDENTIFIER ('.' BASE_IDENTIFIER)*; -ALIAS: '$' BASE_IDENTIFIER; -DATATYPE: '#' ALPHA+; -FUNCTION: '@' BASE_IDENTIFIER; -RECEIVER: '&' BASE_IDENTIFIER; - -fragment BASE_IDENTIFIER: ALPHA ALPHANUMERIC*; -fragment ALPHA: [A-Za-z_]; -fragment ALPHANUMERIC: [A-Za-z0-9_]; - -// String -STRING: '"' (ESCAPE | SAFECODEPOINT)* '"'; -fragment ESCAPE: '\\' (["\\/bfnrt] | UNICODE); -fragment UNICODE: 'u' HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT; -fragment HEXDIGIT: [0-9a-fA-F]; -fragment SAFECODEPOINT: ~["\\\u0000-\u001F]; - -// Numbers -INTEGER: '-'? INTDIGIT; -FLOAT: INTEGER ('.' DIGIT+); -DOUBLE: INTEGER ('.' DIGIT+)? EXPONENT; - -fragment INTDIGIT: '0' | [1-9] DIGIT*; -fragment EXPONENT: [eE] [+\-]? DIGIT+; -fragment DIGIT: [0-9]; - -// Comments -MULTILINE_COMMENT: MULTILINE_CMT -> channel(HIDDEN); -LINE_COMMENT: LINE_CMT -> channel(HIDDEN); - -fragment MULTILINE_CMT: '/*' .*? '*/'; -fragment LINE_CMT: '//' ~('\r' | '\n')*; - -// Whitespace -WHITE_SPACE: WHITE_SPC -> channel(HIDDEN); -fragment WHITE_SPC: [\n\r\t ]+; - -//---------------DIRECTIVE_VERSION1--------------- -mode DIRECTIVE_VERSION1; - -COLON1: ':'; -VERSION_NUMBER1: DIGIT+ ('.' DIGIT+)* -> popMode; -WHITE_SPACE1: WHITE_SPC -> channel(HIDDEN); -MULTILINE_COMMENT1: MULTILINE_CMT -> channel(HIDDEN); -LINE_COMMENT1: LINE_CMT -> channel(HIDDEN); \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/grammar/SchemaParser.g4 b/src/main/java/com/relogiclabs/json/schema/internal/grammar/SchemaParser.g4 deleted file mode 100644 index 90766f4..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/grammar/SchemaParser.g4 +++ /dev/null @@ -1,93 +0,0 @@ -parser grammar SchemaParser; - -options { tokenVocab = SchemaLexer; } - -schema - : title? version? include* pragma* - define* schemaBase define* EOF # AggregateSchema - | validator EOF # CoreSchema - ; - -schemaBase - : SCHEMA COLON validator - ; - -title - : TITLE COLON STRING - ; - -version - : VERSION COLON1 VERSION_NUMBER1; - -include - : INCLUDE COLON IDENTIFIER (COMMA IDENTIFIER)? - ; - -pragma - : PRAGMA IDENTIFIER COLON primitive - ; - -define - : DEFINE alias COLON validatorMain - ; - -alias - : ALIAS - ; - -validatorMain - : value function* datatype* receiver* OPTIONAL? - | function+ datatype* receiver* OPTIONAL? - | datatype+ receiver* OPTIONAL? - ; - -validator - : validatorMain - | alias - ; - -value - : primitive - | object - | array - ; - -receiver - : RECEIVER - ; - -object - : LBRACE (property (COMMA property)*)? RBRACE - ; - -property - : STRING COLON validator - ; - -array - : LBRACKET (validator (COMMA validator)*)? RBRACKET - ; - -datatype - : DATATYPE STAR? (LPAREN alias RPAREN)? - ; - -function - : FUNCTION STAR? (LPAREN (argument (COMMA argument)*)? RPAREN)? - ; - -argument - : value - | receiver - ; - -primitive - : TRUE # PrimitiveTrue - | FALSE # PrimitiveFalse - | STRING # PrimitiveString - | INTEGER # PrimitiveInteger - | FLOAT # PrimitiveFloat - | DOUBLE # PrimitiveDouble - | NULL # PrimitiveNull - | UNDEFINED # PrimitiveUndefined - ; \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/time/DateTimeParser.java b/src/main/java/com/relogiclabs/json/schema/internal/time/DateTimeParser.java deleted file mode 100644 index 03ee7a3..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/time/DateTimeParser.java +++ /dev/null @@ -1,166 +0,0 @@ -package com.relogiclabs.json.schema.internal.time; - -import com.relogiclabs.json.schema.exception.InvalidDateTimeException; -import com.relogiclabs.json.schema.internal.antlr.DateTimeLexer; -import com.relogiclabs.json.schema.internal.util.DebugUtilities; -import com.relogiclabs.json.schema.internal.util.LexerErrorListener; -import com.relogiclabs.json.schema.time.DateTimeType; -import com.relogiclabs.json.schema.time.JsonDateTime; -import com.relogiclabs.json.schema.util.Reference; -import lombok.Getter; -import org.antlr.v4.runtime.CharStreams; -import org.antlr.v4.runtime.Token; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.CLOCK_AM_PM; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.DAY_NUMBER; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.DAY_NUMBER2; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.ERA; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.FRACTION_NUMBER; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.FRACTION_NUMBER1; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.FRACTION_NUMBER2; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.FRACTION_NUMBER3; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.FRACTION_NUMBER4; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.FRACTION_NUMBER5; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.FRACTION_NUMBER6; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.HOUR_NUMBER; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.HOUR_NUMBER2; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.MINUTE_NUMBER; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.MINUTE_NUMBER2; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.MONTH_NAME; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.MONTH_NUMBER; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.MONTH_NUMBER2; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.MONTH_SHORT_NAME; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.SECOND_NUMBER; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.SECOND_NUMBER2; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.SYMBOL; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.TEXT; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.UTC_OFFSET_HOUR; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.UTC_OFFSET_TIME1; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.UTC_OFFSET_TIME2; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.WEEKDAY_NAME; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.WEEKDAY_SHORT_NAME; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.WHITESPACE; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.YEAR_NUMBER2; -import static com.relogiclabs.json.schema.internal.antlr.DateTimeLexer.YEAR_NUMBER4; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.ClockAmPm; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.DayNumber; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.DayNumber2; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.Era; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.FractionNumber; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.FractionNumber1; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.FractionNumber2; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.FractionNumber3; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.FractionNumber4; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.FractionNumber5; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.FractionNumber6; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.HourNumber; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.HourNumber2; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.MinuteNumber; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.MinuteNumber2; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.MonthName; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.MonthNumber; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.MonthNumber2; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.MonthShortName; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.SecondNumber; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.SecondNumber2; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.Symbol; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.Text; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.UtcOffsetHour; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.UtcOffsetTime1; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.UtcOffsetTime2; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.WeekdayName; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.WeekdayShortName; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.Whitespace; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.YearNumber2; -import static com.relogiclabs.json.schema.internal.time.SegmentProcessor.YearNumber4; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static com.relogiclabs.json.schema.message.ErrorCode.DINV02; - -public final class DateTimeParser { - private static final Map PROCESSORS; - private final DateTimeLexer dateTimeLexer; - private final List lexerTokens; - - @Getter private final String pattern; - @Getter private final DateTimeType type; - - static { - PROCESSORS = new HashMap<>(50); - addProcessor(TEXT, Text); - addProcessor(SYMBOL, Symbol); - addProcessor(WHITESPACE, Whitespace); - addProcessor(ERA, Era); - addProcessor(YEAR_NUMBER4, YearNumber4); - addProcessor(YEAR_NUMBER2, YearNumber2); - addProcessor(MONTH_NAME, MonthName); - addProcessor(MONTH_SHORT_NAME, MonthShortName); - addProcessor(MONTH_NUMBER2, MonthNumber2); - addProcessor(MONTH_NUMBER, MonthNumber); - addProcessor(WEEKDAY_NAME, WeekdayName); - addProcessor(WEEKDAY_SHORT_NAME, WeekdayShortName); - addProcessor(DAY_NUMBER2, DayNumber2); - addProcessor(DAY_NUMBER, DayNumber); - addProcessor(CLOCK_AM_PM, ClockAmPm); - addProcessor(HOUR_NUMBER2, HourNumber2); - addProcessor(HOUR_NUMBER, HourNumber); - addProcessor(MINUTE_NUMBER2, MinuteNumber2); - addProcessor(MINUTE_NUMBER, MinuteNumber); - addProcessor(SECOND_NUMBER2, SecondNumber2); - addProcessor(SECOND_NUMBER, SecondNumber); - addProcessor(FRACTION_NUMBER, FractionNumber); - addProcessor(FRACTION_NUMBER1, FractionNumber1); - addProcessor(FRACTION_NUMBER2, FractionNumber2); - addProcessor(FRACTION_NUMBER3, FractionNumber3); - addProcessor(FRACTION_NUMBER4, FractionNumber4); - addProcessor(FRACTION_NUMBER5, FractionNumber5); - addProcessor(FRACTION_NUMBER6, FractionNumber6); - addProcessor(UTC_OFFSET_HOUR, UtcOffsetHour); - addProcessor(UTC_OFFSET_TIME1, UtcOffsetTime1); - addProcessor(UTC_OFFSET_TIME2, UtcOffsetTime2); - } - - private static void addProcessor(int index, SegmentProcessor processor) { - PROCESSORS.put(DateTimeLexer.ruleNames[index - 1], processor); - } - - @SuppressWarnings("unchecked") - public DateTimeParser(String pattern, DateTimeType type) { - this.pattern = pattern; - this.type = type; - this.dateTimeLexer = new DateTimeLexer(CharStreams.fromString(pattern)); - this.dateTimeLexer.removeErrorListeners(); - this.dateTimeLexer.addErrorListener(LexerErrorListener.DATE_TIME); - this.lexerTokens = (List) dateTimeLexer.getAllTokens(); - } - - private JsonDateTime parse(String input, DateTimeContext context) { - for(var token : lexerTokens) { - var processor = PROCESSORS.get(dateTimeLexer.getVocabulary().getSymbolicName(token.getType())); - input = processor.process(input, token, context); - } - if(input.length() != 0) throw new InvalidDateTimeException(DINV02, - concat("Invalid ", context.getType(), " input format")); - - var dateTime = context.validate(); - DebugUtilities.print(context); - return dateTime; - } - - public JsonDateTime parse(String input) { - return parse(input, new DateTimeContext(type)); - } - - public JsonDateTime tryParse(String input, Reference error) { - try { - return parse(input); - } catch(InvalidDateTimeException e) { - DebugUtilities.print(e); - error.setValue(e.getMessage()); - return null; - } - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/tree/FunctionCache.java b/src/main/java/com/relogiclabs/json/schema/internal/tree/FunctionCache.java deleted file mode 100644 index 26d2174..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/tree/FunctionCache.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.relogiclabs.json.schema.internal.tree; - -import com.relogiclabs.json.schema.type.JFunction; -import com.relogiclabs.json.schema.type.JNode; -import lombok.Getter; -import lombok.Setter; -import lombok.Value; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import static com.relogiclabs.json.schema.internal.util.MiscellaneousHelper.getDerived; - -public class FunctionCache implements Iterable { - - @Value - public static class Entry { - MethodPointer methodPointer; - Object[] arguments; - - public boolean isTargetMatch(JNode target) { - return methodPointer.getParameter(0).getType().isInstance(getDerived(target)); - } - - public Object invoke(JFunction function, JNode target) { - arguments[0] = getDerived(target); - return methodPointer.invoke(function, arguments); - } - } - - @Getter @Setter - private static int sizeLimit = 10; - private final List cache; - - public FunctionCache() { - this.cache = new ArrayList<>(sizeLimit); - } - - public void add(MethodPointer methodPointer, Object[] arguments) { - if(cache.size() > sizeLimit) cache.remove(0); - arguments[0] = null; - cache.add(new Entry(methodPointer, arguments)); - } - - @Override - public Iterator iterator() { - return cache.iterator(); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/tree/MethodPointer.java b/src/main/java/com/relogiclabs/json/schema/internal/tree/MethodPointer.java deleted file mode 100644 index 6e76780..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/tree/MethodPointer.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.relogiclabs.json.schema.internal.tree; - -import com.relogiclabs.json.schema.exception.TargetInvocationException; -import com.relogiclabs.json.schema.function.FunctionBase; -import com.relogiclabs.json.schema.type.JFunction; -import lombok.Getter; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Parameter; -import java.util.Arrays; -import java.util.List; - -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC07; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC08; -import static java.util.stream.Collectors.joining; - -@Getter -public final class MethodPointer { - - private final FunctionBase instance; - private final Method method; - public final List parameters; - - public MethodPointer(FunctionBase instance, Method method, Parameter[] parameters) { - this.instance = instance; - this.method = method; - this.parameters = List.of(parameters); - } - - public Parameter getParameter(int index) { - return parameters.get(index); - } - - public Object invoke(JFunction function, Object[] arguments) { - try { - instance.setFunction(function); - Object result = method.invoke(instance, arguments); - if(result == null) throw new IllegalStateException("Function return cannot be null"); - return result; - } catch (InvocationTargetException e) { - throw new TargetInvocationException(FUNC07, - "Target invocation exception occurred", e.getCause()); - } catch (IllegalAccessException e) { - throw new TargetInvocationException(FUNC08, - "Illegal access exception occurred", e); - } - } - - public static String getSignature(Method method) { - String typeName = method.getDeclaringClass().getName(); - String methodName = method.getName(); - String parameters = Arrays.stream(method.getParameters()) - .map(MethodPointer::stringOf).collect(joining(", ")); - String returnType = method.getReturnType().getName(); - return concat(returnType, " ", typeName, ".", methodName, "(", parameters, ")"); - } - - private static String stringOf(Parameter parameter) { - var builder = new StringBuilder(parameter.getType().getSimpleName()); - builder.append(" ").append(parameter.getName()); - return builder.toString(); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/tree/SchemaTreeVisitor.java b/src/main/java/com/relogiclabs/json/schema/internal/tree/SchemaTreeVisitor.java deleted file mode 100644 index af65620..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/tree/SchemaTreeVisitor.java +++ /dev/null @@ -1,324 +0,0 @@ -package com.relogiclabs.json.schema.internal.tree; - -import com.relogiclabs.json.schema.function.CoreFunctions4; -import com.relogiclabs.json.schema.internal.antlr.SchemaParser; -import com.relogiclabs.json.schema.internal.antlr.SchemaParserBaseVisitor; -import com.relogiclabs.json.schema.internal.builder.JAliasBuilder; -import com.relogiclabs.json.schema.internal.builder.JArrayBuilder; -import com.relogiclabs.json.schema.internal.builder.JBooleanBuilder; -import com.relogiclabs.json.schema.internal.builder.JDataTypeBuilder; -import com.relogiclabs.json.schema.internal.builder.JDefinitionBuilder; -import com.relogiclabs.json.schema.internal.builder.JDoubleBuilder; -import com.relogiclabs.json.schema.internal.builder.JFloatBuilder; -import com.relogiclabs.json.schema.internal.builder.JFunctionBuilder; -import com.relogiclabs.json.schema.internal.builder.JIncludeBuilder; -import com.relogiclabs.json.schema.internal.builder.JIntegerBuilder; -import com.relogiclabs.json.schema.internal.builder.JNullBuilder; -import com.relogiclabs.json.schema.internal.builder.JObjectBuilder; -import com.relogiclabs.json.schema.internal.builder.JPragmaBuilder; -import com.relogiclabs.json.schema.internal.builder.JPropertyBuilder; -import com.relogiclabs.json.schema.internal.builder.JReceiverBuilder; -import com.relogiclabs.json.schema.internal.builder.JRootBuilder; -import com.relogiclabs.json.schema.internal.builder.JStringBuilder; -import com.relogiclabs.json.schema.internal.builder.JTitleBuilder; -import com.relogiclabs.json.schema.internal.builder.JUndefinedBuilder; -import com.relogiclabs.json.schema.internal.builder.JValidatorBuilder; -import com.relogiclabs.json.schema.internal.builder.JVersionBuilder; -import com.relogiclabs.json.schema.tree.Context; -import com.relogiclabs.json.schema.tree.RuntimeContext; -import com.relogiclabs.json.schema.type.JAlias; -import com.relogiclabs.json.schema.type.JDataType; -import com.relogiclabs.json.schema.type.JDefinition; -import com.relogiclabs.json.schema.type.JFunction; -import com.relogiclabs.json.schema.type.JInclude; -import com.relogiclabs.json.schema.type.JNode; -import com.relogiclabs.json.schema.type.JPragma; -import com.relogiclabs.json.schema.type.JProperty; -import com.relogiclabs.json.schema.type.JReceiver; -import com.relogiclabs.json.schema.type.JTitle; -import com.relogiclabs.json.schema.type.JValidator; -import com.relogiclabs.json.schema.type.JVersion; -import com.relogiclabs.json.schema.type.JsonType; -import org.antlr.v4.runtime.tree.ParseTree; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static com.relogiclabs.json.schema.internal.tree.TreeHelper.requireUniqueness; -import static com.relogiclabs.json.schema.internal.util.StringHelper.toEncoded; -import static com.relogiclabs.json.schema.internal.util.StringHelper.unquote; -import static com.relogiclabs.json.schema.message.ErrorCode.PROP04; -import static java.util.stream.Collectors.joining; - -public final class SchemaTreeVisitor extends SchemaParserBaseVisitor { - private final Map relations; - private final RuntimeContext runtime; - - public SchemaTreeVisitor(RuntimeContext runtime) { - this.runtime = runtime; - this.relations = new HashMap<>(); - } - - @Override - public JNode visitAggregateSchema(SchemaParser.AggregateSchemaContext ctx) { - return new JRootBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .title((JTitle) visit(ctx.title())) - .version((JVersion) visit(ctx.version())) - .includes(processIncludes(ctx.include())) - .pragmas(ctx.pragma().stream().map(c -> (JPragma) visit(c)).toList()) - .definitions(ctx.define().stream().map(c -> (JDefinition) visit(c)).toList()) - .value(visit(ctx.schemaBase())) - .build(); - } - - @Override - public JNode visitCoreSchema(SchemaParser.CoreSchemaContext ctx) { - return new JRootBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .includes(processIncludes(Collections.emptyList())) - .value(visit(ctx.validator())) - .build(); - } - - @Override - public JNode visitSchemaBase(SchemaParser.SchemaBaseContext ctx) { - return visit(ctx.validator()); - } - - private List processIncludes(List contexts) { - runtime.getFunctions().addClass(CoreFunctions4.class.getName(), null); - return contexts.stream().map(c -> (JInclude) visit(c)).toList(); - } - - @Override - public JNode visitTitle(SchemaParser.TitleContext ctx) { - return new JTitleBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .title(ctx.STRING().getText()) - .build(); - } - - @Override - public JNode visitVersion(SchemaParser.VersionContext ctx) { - return new JVersionBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .version(ctx.VERSION_NUMBER1().getText()) - .build(); - } - - @Override - public JNode visitInclude(SchemaParser.IncludeContext ctx) { - var include = new JIncludeBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .className(ctx.IDENTIFIER().stream().map(ParseTree::getText) - .collect(joining(","))) - .build(); - return runtime.getFunctions().addClass(include); - } - - @Override - public JNode visitPragma(SchemaParser.PragmaContext ctx) { - var pragma = new JPragmaBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .name(ctx.IDENTIFIER().getText()) - .value(visit(ctx.primitive())).build(); - return runtime.getPragmas().addPragma(pragma); - } - - @Override - public JNode visitDefine(SchemaParser.DefineContext ctx) { - var definition = new JDefinitionBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .alias((JAlias) visit(ctx.alias())) - .validator((JValidator) visit(ctx.validatorMain())) - .build(); - return runtime.addDefinition(definition); - } - - @Override - public JNode visitAlias(SchemaParser.AliasContext ctx) { - return new JAliasBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .name(ctx.ALIAS().getText()) - .build(); - } - - @Override - public JNode visitValidatorMain(SchemaParser.ValidatorMainContext ctx) { - return new JValidatorBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .value(visit(ctx.value())) - .functions(ctx.function().stream().map(c -> (JFunction) visit(c)).toList()) - .dataTypes(ctx.datatype().stream().map(c -> (JDataType) visit(c)).toList()) - .receivers(ctx.receiver().stream().map(c -> (JReceiver) visit(c)).toList()) - .optional(ctx.OPTIONAL() != null) - .build(); - } - - @Override - public JNode visitValidator(SchemaParser.ValidatorContext ctx) { - if(ctx.alias() != null) return visit(ctx.alias()); - if(ctx.validatorMain() != null) return visit(ctx.validatorMain()); - throw new IllegalStateException("Invalid parser state"); - } - - @Override - public JNode visitValue(SchemaParser.ValueContext ctx) { - if(ctx.primitive() != null) return visit(ctx.primitive()); - if(ctx.array() != null) return visit(ctx.array()); - if(ctx.object() != null) return visit(ctx.object()); - throw new IllegalStateException("Invalid parser state"); - } - - @Override - public JNode visitObject(SchemaParser.ObjectContext ctx) { - return new JObjectBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .properties(requireUniqueness(ctx.property().stream() - .map(c -> (JProperty) visit(c)).toList(), PROP04)) - .build(); - } - - @Override - public JNode visitProperty(SchemaParser.PropertyContext ctx) { - return new JPropertyBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .key(unquote(ctx.STRING().getText())) - .value(visit(ctx.validator())) - .build(); - } - - @Override - public JNode visitArray(SchemaParser.ArrayContext ctx) { - return new JArrayBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .elements(ctx.validator().stream().map(this::visit).toList()) - .build(); - } - - @Override - public JNode visitDatatype(SchemaParser.DatatypeContext ctx) { - return new JDataTypeBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .jsonType(JsonType.from(ctx.DATATYPE())) - .alias((JAlias) visit(ctx.alias())) - .nested(ctx.STAR() != null) - .build(); - } - - @Override - public JNode visitFunction(SchemaParser.FunctionContext ctx) { - return new JFunctionBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .name(ctx.FUNCTION().getText()) - .arguments(ctx.argument().stream().map(this::visit).toList()) - .nested(ctx.STAR() != null) - .build(); - } - - @Override - public JNode visitArgument(SchemaParser.ArgumentContext ctx) { - if(ctx.value() != null) return visit(ctx.value()); - if(ctx.receiver() != null) return visit(ctx.receiver()); - throw new IllegalStateException("Invalid parser state"); - } - - @Override - public JNode visitReceiver(SchemaParser.ReceiverContext ctx) { - return new JReceiverBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .name(ctx.RECEIVER().getText()).build(); - } - - @Override - public JNode visitPrimitiveTrue(SchemaParser.PrimitiveTrueContext ctx) { - return new JBooleanBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .value(true).build(); - } - - @Override - public JNode visitPrimitiveFalse(SchemaParser.PrimitiveFalseContext ctx) { - return new JBooleanBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .value(false).build(); - } - - @Override - public JNode visitPrimitiveString(SchemaParser.PrimitiveStringContext ctx) { - return new JStringBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .value(toEncoded(ctx.STRING().getText())) - .build(); - } - - @Override - public JNode visitPrimitiveInteger(SchemaParser.PrimitiveIntegerContext ctx) { - return new JIntegerBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .value(Long.valueOf(ctx.INTEGER().getText())) - .build(); - } - - @Override - public JNode visitPrimitiveFloat(SchemaParser.PrimitiveFloatContext ctx) { - return new JFloatBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .value(Double.valueOf(ctx.FLOAT().getText())) - .build(); - } - - @Override - public JNode visitPrimitiveDouble(SchemaParser.PrimitiveDoubleContext ctx) { - return new JDoubleBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .value(Double.valueOf(ctx.DOUBLE().getText())) - .build(); - } - - @Override - public JNode visitPrimitiveNull(SchemaParser.PrimitiveNullContext ctx) { - return new JNullBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .build(); - } - - @Override - public JNode visitPrimitiveUndefined(SchemaParser.PrimitiveUndefinedContext ctx) { - return new JUndefinedBuilder() - .relations(relations) - .context(new Context(ctx, runtime)) - .build(); - } - - @Override - public JNode visit(ParseTree tree) { - if(tree == null) return null; - return super.visit(tree); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/tree/TreeHelper.java b/src/main/java/com/relogiclabs/json/schema/internal/tree/TreeHelper.java deleted file mode 100644 index be3f527..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/tree/TreeHelper.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.relogiclabs.json.schema.internal.tree; - -import com.relogiclabs.json.schema.exception.DuplicatePropertyKeyException; -import com.relogiclabs.json.schema.type.JProperty; - -import java.util.List; -import java.util.function.Function; - -import static com.relogiclabs.json.schema.internal.util.StreamHelper.halt; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static com.relogiclabs.json.schema.internal.util.StringHelper.quote; -import static com.relogiclabs.json.schema.message.MessageFormatter.formatForJson; -import static java.util.stream.Collectors.toMap; - -public final class TreeHelper { - public static List requireUniqueness(List list, String errorCode) { - list.stream().collect(toMap(JProperty::getKey, Function.identity(), - (p1, p2) -> halt(new DuplicatePropertyKeyException(formatForJson(errorCode, - concat("Multiple key with name ", quote(p2.getKey()), " found"), p2))) - )); - return list; - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/util/DebugUtilities.java b/src/main/java/com/relogiclabs/json/schema/internal/util/DebugUtilities.java deleted file mode 100644 index 8f5f224..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/util/DebugUtilities.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.relogiclabs.json.schema.internal.util; - -import com.relogiclabs.json.schema.internal.time.DateTimeContext; -import com.relogiclabs.json.schema.tree.DataTree; -import org.antlr.v4.runtime.Parser; -import org.antlr.v4.runtime.Recognizer; - -import java.util.Collections; -import java.util.List; - -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; - -// External logging library may consider -// Kept it lightweight for now -public final class DebugUtilities { - public static boolean debugPrint = false; - - public static void print(DataTree expected, DataTree actual) { - if(!debugPrint) return; - System.out.println(concat("[DEBUG] Expected ", expected.getType(), - " tree interpretation:")); - System.out.println(expected.getRoot()); - System.out.println("---"); - System.out.println(concat("[DEBUG] Actual ", actual.getType(), - " tree interpretation:")); - System.out.println(actual.getRoot()); - System.out.println("---"); - } - - public static void print(Recognizer recognizer) { - if(!debugPrint) return; - List stack = ((Parser) recognizer).getRuleInvocationStack(); - Collections.reverse(stack); - System.err.println("[DEBUG] Rule stack: " + String.join(" > ", stack)); - } - - public static void print(DateTimeContext context) { - if(!debugPrint) return; - System.out.println("[DEBUG] Date and time interpretation: " + context); - } - - public static void print(Exception e) { - if(!debugPrint) return; - System.err.println("[DEBUG] Print of exception: " + e); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/util/MiscellaneousHelper.java b/src/main/java/com/relogiclabs/json/schema/internal/util/MiscellaneousHelper.java deleted file mode 100644 index d7b0e83..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/util/MiscellaneousHelper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.relogiclabs.json.schema.internal.util; - -import com.relogiclabs.json.schema.type.Derivable; -import com.relogiclabs.json.schema.type.JNode; - -public final class MiscellaneousHelper { - public static T nonNull(T value, T defaultValue) { - return value != null ? value : defaultValue; - } - - public static JNode getDerived(JNode target) { - if(target instanceof Derivable derivable) - return nonNull(derivable.getDerived(), target); - return target; - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/internal/util/ParserErrorListener.java b/src/main/java/com/relogiclabs/json/schema/internal/util/ParserErrorListener.java deleted file mode 100644 index 6c9c9b7..0000000 --- a/src/main/java/com/relogiclabs/json/schema/internal/util/ParserErrorListener.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.relogiclabs.json.schema.internal.util; - -import com.relogiclabs.json.schema.exception.CommonException; -import com.relogiclabs.json.schema.exception.JsonParserException; -import com.relogiclabs.json.schema.exception.SchemaParserException; -import org.antlr.v4.runtime.BaseErrorListener; -import org.antlr.v4.runtime.RecognitionException; -import org.antlr.v4.runtime.Recognizer; - -import static com.relogiclabs.json.schema.message.ErrorCode.JPRS01; -import static com.relogiclabs.json.schema.message.ErrorCode.SPRS01; - -public abstract class ParserErrorListener extends BaseErrorListener { - public static final ParserErrorListener SCHEMA = new SchemaErrorListener(); - public static final ParserErrorListener JSON = new JsonErrorListener(); - - protected abstract CommonException createException(String message, Throwable cause); - protected abstract String getMessageFormat(); - - private static final class SchemaErrorListener extends ParserErrorListener { - @Override - protected CommonException createException(String message, Throwable cause) { - return new SchemaParserException(SPRS01, message, cause); - } - - @Override - protected String getMessageFormat() { - return "Schema (Line %d:%d) [" + SPRS01 + "]: %s (error on '%s')"; - } - } - - private static final class JsonErrorListener extends ParserErrorListener { - @Override - protected CommonException createException(String message, Throwable cause) { - return new JsonParserException(JPRS01, message, cause); - } - - @Override - protected String getMessageFormat() { - return "Json (Line %d:%d) [" + JPRS01 + "]: %s (error on '%s')"; - } - } - - @Override - public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, - int charPositionInLine, String msg, RecognitionException e) { - DebugUtilities.print(recognizer); - var message = getMessageFormat().formatted(line, charPositionInLine, msg, offendingSymbol); - throw createException(message, e); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/tree/FunctionRegistry.java b/src/main/java/com/relogiclabs/json/schema/tree/FunctionRegistry.java deleted file mode 100644 index 320c900..0000000 --- a/src/main/java/com/relogiclabs/json/schema/tree/FunctionRegistry.java +++ /dev/null @@ -1,229 +0,0 @@ -package com.relogiclabs.json.schema.tree; - -import com.relogiclabs.json.schema.exception.ClassInstantiationException; -import com.relogiclabs.json.schema.exception.CommonException; -import com.relogiclabs.json.schema.exception.DuplicateIncludeException; -import com.relogiclabs.json.schema.exception.FunctionNotFoundException; -import com.relogiclabs.json.schema.exception.InvalidFunctionException; -import com.relogiclabs.json.schema.exception.InvalidIncludeException; -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.exception.NotFoundClassException; -import com.relogiclabs.json.schema.function.FunctionBase; -import com.relogiclabs.json.schema.function.FutureValidator; -import com.relogiclabs.json.schema.internal.tree.FunctionKey; -import com.relogiclabs.json.schema.internal.tree.MethodPointer; -import com.relogiclabs.json.schema.message.ActualDetail; -import com.relogiclabs.json.schema.message.ErrorDetail; -import com.relogiclabs.json.schema.message.ExpectedDetail; -import com.relogiclabs.json.schema.type.JFunction; -import com.relogiclabs.json.schema.type.JInclude; -import com.relogiclabs.json.schema.type.JNode; - -import java.lang.reflect.Array; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Parameter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.getTypeName; -import static com.relogiclabs.json.schema.internal.tree.MethodPointer.getSignature; -import static com.relogiclabs.json.schema.internal.util.CollectionHelper.merge; -import static com.relogiclabs.json.schema.internal.util.MiscellaneousHelper.getDerived; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static com.relogiclabs.json.schema.message.ErrorCode.CLAS01; -import static com.relogiclabs.json.schema.message.ErrorCode.CLAS02; -import static com.relogiclabs.json.schema.message.ErrorCode.CLAS03; -import static com.relogiclabs.json.schema.message.ErrorCode.CLAS04; -import static com.relogiclabs.json.schema.message.ErrorCode.CLAS05; -import static com.relogiclabs.json.schema.message.ErrorCode.CLAS06; -import static com.relogiclabs.json.schema.message.ErrorCode.CLAS07; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC01; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC02; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC03; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC04; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC05; -import static com.relogiclabs.json.schema.message.MessageFormatter.formatForSchema; - -public final class FunctionRegistry { - private final Set includes; - private final Map> functions; - private final RuntimeContext runtime; - - public FunctionRegistry(RuntimeContext runtime) { - this.runtime = runtime; - this.includes = new HashSet<>(); - this.functions = new HashMap<>(); - } - - public JInclude addClass(JInclude include) { - addClass(include.getClassName(), include.getContext()); - return include; - } - - public void addClass(String className, Context context) { - if(!includes.contains(className)) includes.add(className); - else throw new DuplicateIncludeException(formatForSchema( - CLAS01, "Class already included " + className, context)); - Class subclass; - try { - subclass = Class.forName(className); - } catch(ClassNotFoundException ex) { - throw new NotFoundClassException(formatForSchema(CLAS02, "Not found " + className, context)); - } - var baseclass = FunctionBase.class; - // if not FunctionBase's subclass - if(!baseclass.isAssignableFrom(subclass)) - throw new InvalidIncludeException(formatForSchema(CLAS03, subclass.getName() + " needs to inherit " - + baseclass.getName(), context)); - try { - merge(functions, extractMethods(subclass, createInstance(subclass, context))); - } catch(InvalidFunctionException ex) { - throw new InvalidFunctionException(formatForSchema(ex.getCode(), ex.getMessage(), context)); - } - } - - private static Map> extractMethods( - Class subclass, FunctionBase instance) { - var baseclass = FunctionBase.class; - Map> functions = new HashMap<>(); - for(var m : subclass.getMethods()) { - if(!baseclass.isAssignableFrom(m.getDeclaringClass())) continue; - if(baseclass == m.getDeclaringClass()) continue; - Parameter[] parameters = m.getParameters(); - if(!isValidReturnType(m.getReturnType())) throw new InvalidFunctionException(FUNC01, - concat("Function [", getSignature(m), "] requires valid return type")); - if(parameters.length < 1) throw new InvalidFunctionException(FUNC02, - concat("Function [", getSignature(m), "] requires target parameter")); - var key = new FunctionKey(m, getParameterCount(parameters)); - var value = new MethodPointer(instance, m, parameters); - var valueList = functions.get(key); - if(valueList == null) valueList = new ArrayList<>(); - valueList.add(value); - functions.put(key, valueList); - } - return functions; - } - - private static boolean isValidReturnType(Class type) { - if(type == boolean.class) return true; - if(type == Boolean.class) return true; - if(type == FutureValidator.class) return true; - return false; - } - - private static int getParameterCount(Parameter[] parameters) { - for(var p : parameters) if(p.isVarArgs()) return -1; - return parameters.length; - } - - private FunctionBase createInstance(Class type, Context context) { - try { - var constructor = type.getDeclaredConstructor(RuntimeContext.class); - return (FunctionBase) constructor.newInstance(runtime); - } catch (NoSuchMethodException e) { - throw createException(CLAS04, e, type, context); - } catch (InstantiationException e) { - throw createException(CLAS05, e, type, context); - } catch (InvocationTargetException e) { - throw createException(CLAS06, e, type, context); - } catch (IllegalAccessException e) { - throw createException(CLAS07, e, type, context); - } - } - - private static CommonException createException(String code, Exception ex, Class type, Context context) { - return new ClassInstantiationException(formatForSchema( - code, "Fail to create instance of " + type.getName(), context), ex); - } - - private boolean handleFuture(Object result) { - return result instanceof FutureValidator validator - ? runtime.addValidator(validator) - : (boolean) result; - } - - public boolean invokeFunction(JFunction function, JNode target) { - for(var e : function.getCache()) { - if (e.isTargetMatch(target)) - return handleFuture(e.invoke(function, target)); - } - var methods = getMethods(function); - Parameter mismatchParameter = null; - - for(var method : methods) { - var parameters = method.getParameters(); - var arguments = function.getArguments(); - var schemaArgs = processArgs(parameters, arguments); - if(schemaArgs == null) continue; - if(isMatch(parameters.get(0), target)) { - Object[] allArgs = addTarget(schemaArgs, target).toArray(); - var result = method.invoke(function, allArgs); - function.getCache().add(method, allArgs); - return handleFuture(result); - } - mismatchParameter = parameters.get(0); - } - if(mismatchParameter != null) - return failWith(new JsonSchemaException(new ErrorDetail(FUNC03, - "Function ", function.getOutline(), " is incompatible with the target data type"), - new ExpectedDetail(function, "applying to a supported data type such as ", - getTypeName(mismatchParameter.getType())), - new ActualDetail(target, "applied to an unsupported data type ", - getTypeName(target.getClass()), " of ", target))); - - return failWith(new FunctionNotFoundException(formatForSchema(FUNC04, function.getOutline(), function))); - } - - private List getMethods(JFunction function) { - var methodPointers = functions.get(new FunctionKey(function)); - if(methodPointers == null) - methodPointers = functions.get(new FunctionKey(function.getName(), -1)); - if(methodPointers == null) throw new FunctionNotFoundException(formatForSchema(FUNC05, "Not found " + function.getOutline(), function)); - return methodPointers; - } - - private static List addTarget(List arguments, JNode target) { - arguments.add(0, getDerived(target)); - return arguments; - } - - private static List processArgs(List parameters, List arguments) { - var result = new ArrayList<>(); - for(int i = 1; i < parameters.size(); i++) { - if(parameters.get(i).isVarArgs()) { - List rest = arguments.subList(i - 1, arguments.size() - i + 1); - var varArgs = processVarArgs(parameters.get(i), rest); - if(varArgs == null) return null; - result.add(varArgs); - break; - } - if(!isMatch(parameters.get(i), arguments.get(i - 1))) return null; - result.add(arguments.get(i - 1)); - } - return result; - } - - private static boolean isMatch(Parameter parameter, JNode argument) { - return parameter.getType().isInstance(getDerived(argument)); - } - - private static Object processVarArgs(Parameter parameter, List arguments) { - var componentType = parameter.getType().getComponentType(); - if(componentType == null) throw new IllegalStateException("Invalid function parameter"); - Object result = Array.newInstance(componentType, arguments.size()); - for(var i = 0; i < arguments.size(); i++) { - var arg = arguments.get(i); - if(!componentType.isInstance(arg)) return null; - Array.set(result, i, arg); - } - return result; - } - - private boolean failWith(RuntimeException exception) { - return runtime.getExceptions().failWith(exception); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/tree/RuntimeContext.java b/src/main/java/com/relogiclabs/json/schema/tree/RuntimeContext.java deleted file mode 100644 index 042ec90..0000000 --- a/src/main/java/com/relogiclabs/json/schema/tree/RuntimeContext.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.relogiclabs.json.schema.tree; - -import com.relogiclabs.json.schema.exception.DuplicateDefinitionException; -import com.relogiclabs.json.schema.function.FutureValidator; -import com.relogiclabs.json.schema.message.MessageFormatter; -import com.relogiclabs.json.schema.type.JAlias; -import com.relogiclabs.json.schema.type.JDefinition; -import com.relogiclabs.json.schema.type.JValidator; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static com.relogiclabs.json.schema.internal.util.StringHelper.quote; -import static com.relogiclabs.json.schema.message.ErrorCode.DEFI01; -import static com.relogiclabs.json.schema.message.MessageFormatter.formatForSchema; - -public final class RuntimeContext { - @Getter private final FunctionRegistry functions; - @Getter private final PragmaRegistry pragmas; - @Getter private final Map definitions; - @Getter private final ExceptionRegistry exceptions; - @Getter private final Map validators; - @Getter private final ReceiverRegistry receivers; - @Getter private final Map storage; - @Getter private final MessageFormatter messageFormatter; - - public RuntimeContext(MessageFormatter messageFormatter, boolean throwException) { - this.messageFormatter = messageFormatter; - this.definitions = new HashMap<>(); - this.functions = new FunctionRegistry(this); - this.pragmas = new PragmaRegistry(); - this.exceptions = new ExceptionRegistry(throwException); - this.receivers = new ReceiverRegistry(); - this.storage = new HashMap<>(); - this.validators = new HashMap<>(); - } - - public JDefinition addDefinition(JDefinition definition) { - var previous = definitions.get(definition.getAlias()); - if(previous != null) - throw new DuplicateDefinitionException(formatForSchema(DEFI01, - concat("Duplicate definition of ", quote(definition.getAlias()), - " is found and already defined as ", previous.getOutline()), - definition.getContext())); - definitions.put(definition.getAlias(), definition.getValidator()); - return definition; - } - - public boolean areEqual(double value1, double value2) { - return Math.abs(value1 - value2) < pragmas.getFloatingPointTolerance(); - } - - public boolean addValidator(FutureValidator validator) { - return validators.put(UUID.randomUUID().toString(), validator) == null; - } - - public boolean invokeValidators() { - var result = true; - for(var v : validators.values()) result &= v.validate(); - return result; - } - - public void clear() { - exceptions.clear(); - storage.clear(); - receivers.clear(); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/Derivable.java b/src/main/java/com/relogiclabs/json/schema/type/Derivable.java deleted file mode 100644 index 40da7ce..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/Derivable.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.relogiclabs.json.schema.type; - -public interface Derivable { - JNode getDerived(); -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JAlias.java b/src/main/java/com/relogiclabs/json/schema/type/JAlias.java deleted file mode 100644 index 7dd8aab..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JAlias.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.DefinitionNotFoundException; -import com.relogiclabs.json.schema.internal.builder.JAliasBuilder; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import static com.relogiclabs.json.schema.internal.util.StringHelper.quote; -import static com.relogiclabs.json.schema.message.ErrorCode.DEFI02; -import static com.relogiclabs.json.schema.message.MessageFormatter.formatForSchema; -import static java.util.Objects.requireNonNull; - -@Getter -@EqualsAndHashCode -public final class JAlias extends JLeaf { - private final String name; - - private JAlias(JAliasBuilder builder) { - super(builder); - name = requireNonNull(builder.name()); - } - - public static JAlias from(JAliasBuilder builder) { - return new JAlias(builder).initialize(); - } - - @Override - public boolean match(JNode node) { - var definitions = getRuntime().getDefinitions(); - if(!definitions.containsKey(this)) - throw new DefinitionNotFoundException(formatForSchema(DEFI02, "Definition of " - + quote(name) + " not found", getContext())); - return definitions.get(this).match(node); - } - - @Override - public String toString() { - return name; - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JArray.java b/src/main/java/com/relogiclabs/json/schema/type/JArray.java deleted file mode 100644 index 6d6feb8..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JArray.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.exception.MisplacedOptionalException; -import com.relogiclabs.json.schema.internal.builder.JArrayBuilder; -import com.relogiclabs.json.schema.internal.message.ActualHelper; -import com.relogiclabs.json.schema.internal.message.ExpectedHelper; -import com.relogiclabs.json.schema.message.ErrorDetail; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import java.util.Collection; -import java.util.List; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.ArrayElementNotFound; -import static com.relogiclabs.json.schema.internal.util.StringHelper.joinWith; -import static com.relogiclabs.json.schema.message.ErrorCode.ARRY01; -import static com.relogiclabs.json.schema.message.ErrorCode.ARRY02; -import static com.relogiclabs.json.schema.message.MessageFormatter.formatForSchema; -import static java.util.Objects.requireNonNull; - -@Getter -@EqualsAndHashCode -public final class JArray extends JComposite { - private final List elements; - - private JArray(JArrayBuilder builder) { - super(builder); - elements = requireNonNull(builder.elements()); - children = elements; - } - - public static JArray from(JArrayBuilder builder) { - return new JArray(builder).initialize(); - } - - @Override - public JsonType getType() { - return JsonType.ARRAY; - } - - @Override - public Collection components() { - return elements; - } - - @Override - public boolean match(JNode node) { - var other = castType(node, JArray.class); - if(other == null) return false; - boolean result = true, restOptional = false; - for(var i = 0; i < elements.size(); i++) { - var optional = isOptional(elements.get(i)); - if((restOptional |= optional) != optional) - return failWith(new MisplacedOptionalException(formatForSchema(ARRY02, - "Mandatory array element cannot appear after optional element", - elements.get(i)))); - if(i >= other.elements.size() && !optional) - return failWith(new JsonSchemaException( - new ErrorDetail(ARRY01, ArrayElementNotFound), - ExpectedHelper.asArrayElementNotFound(elements.get(i), i), - ActualHelper.asArrayElementNotFound(other, i))); - if(i >= other.elements.size()) continue; - result &= elements.get(i).match(other.elements.get(i)); - } - return result; - } - - private static boolean isOptional(JNode node) { - if(node instanceof JValidator validator) - return validator.getOptional(); - return false; - } - - @Override - public String toString() { - return joinWith(elements, ", ", "[", "]"); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JBoolean.java b/src/main/java/com/relogiclabs/json/schema/type/JBoolean.java deleted file mode 100644 index 35bc6b9..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JBoolean.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.internal.builder.JBooleanBuilder; -import com.relogiclabs.json.schema.internal.message.ActualHelper; -import com.relogiclabs.json.schema.internal.message.ExpectedHelper; -import com.relogiclabs.json.schema.message.ErrorDetail; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.ValueMismatch; -import static com.relogiclabs.json.schema.message.ErrorCode.BOOL01; -import static java.util.Objects.requireNonNull; - -@Getter -@EqualsAndHashCode -public final class JBoolean extends JPrimitive implements PragmaValue { - private final boolean value; - - private JBoolean(JBooleanBuilder builder) { - super(builder); - value = requireNonNull(builder.value()); - } - - public static JBoolean from(JBooleanBuilder builder) { - return new JBoolean(builder).initialize(); - } - - @Override - public JsonType getType() { - return JsonType.BOOLEAN; - } - - @Override - public boolean match(JNode node) { - var other = castType(node, JBoolean.class); - if(other == null) return false; - if(value == other.value) return true; - return failWith(new JsonSchemaException( - new ErrorDetail(BOOL01, ValueMismatch), - ExpectedHelper.asValueMismatch(this), - ActualHelper.asValueMismatch(other))); - } - - @Override - public Boolean toNativeValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JDataType.java b/src/main/java/com/relogiclabs/json/schema/type/JDataType.java deleted file mode 100644 index 23219bc..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JDataType.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.DefinitionNotFoundException; -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.internal.builder.JDataTypeBuilder; -import com.relogiclabs.json.schema.internal.message.ActualHelper; -import com.relogiclabs.json.schema.internal.message.ExpectedHelper; -import com.relogiclabs.json.schema.message.ErrorDetail; -import com.relogiclabs.json.schema.util.Reference; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.DataTypeArgumentFailed; -import static com.relogiclabs.json.schema.internal.message.MessageHelper.DataTypeMismatch; -import static com.relogiclabs.json.schema.internal.util.CollectionHelper.asList; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static com.relogiclabs.json.schema.internal.util.StringHelper.quote; -import static com.relogiclabs.json.schema.message.ErrorCode.DEFI03; -import static com.relogiclabs.json.schema.message.ErrorCode.DEFI04; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP04; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP05; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP06; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP07; -import static com.relogiclabs.json.schema.message.MessageFormatter.formatForSchema; -import static java.util.Objects.requireNonNull; -import static org.apache.commons.lang3.StringUtils.isEmpty; -import static org.apache.commons.lang3.StringUtils.uncapitalize; - -@Getter -@EqualsAndHashCode -public final class JDataType extends JBranch implements NestedMode { - static final String NESTED_MARKER = "*"; - static final String DATA_TYPE_NAME = "DATA_TYPE_NAME"; - private final JsonType jsonType; - private final JAlias alias; - private final boolean nested; - - private JDataType(JDataTypeBuilder builder) { - super(builder); - jsonType = requireNonNull(builder.jsonType()); - nested = requireNonNull(builder.nested()); - alias = builder.alias(); - children = asList(alias); - } - - public static JDataType from(JDataTypeBuilder builder) { - return new JDataType(builder).initialize(); - } - - @Override - public boolean match(JNode node) { - Reference error = new Reference<>(); - if(!jsonType.match(node, error)) return failTypeWith(new JsonSchemaException( - new ErrorDetail(nested ? DTYP06 : DTYP04, - formatMessage(DataTypeMismatch, error.getValue())), - ExpectedHelper.asDataTypeMismatch(this), - ActualHelper.asDataTypeMismatch(node))); - if(alias == null) return true; - var validator = getRuntime().getDefinitions().get(alias); - if(validator == null) return failWith(new DefinitionNotFoundException( - formatForSchema(nested ? DEFI04 : DEFI03, "No definition found for " - + quote(alias), this))); - if(!validator.match(node)) return failWith(new JsonSchemaException( - new ErrorDetail(nested ? DTYP07 : DTYP05, DataTypeArgumentFailed), - ExpectedHelper.asDataTypeArgumentFailed(this), - ActualHelper.asDataTypeArgumentFailed(node))); - return true; - } - - private boolean failTypeWith(JsonSchemaException exception) { - exception.setAttribute(DATA_TYPE_NAME, toString(true)); - return failWith(exception); - } - - private static String formatMessage(String main, String optional) { - return isEmpty(optional) ? main : concat(main, " (", uncapitalize(optional), ")"); - } - - boolean isApplicable(JNode node) { - return !nested || node instanceof JComposite; - } - - boolean isMatchNull() { - return !nested && jsonType == JsonType.NULL; - } - - @Override - public String toString() { - return toString(false); - } - - public String toString(boolean baseForm) { - var builder = new StringBuilder(jsonType.toString()); - if(nested && !baseForm) builder.append(NESTED_MARKER); - if(alias != null && !baseForm) builder.append("(").append(alias).append(")"); - return builder.toString(); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JDouble.java b/src/main/java/com/relogiclabs/json/schema/type/JDouble.java deleted file mode 100644 index 584cbbc..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JDouble.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.internal.builder.JDoubleBuilder; -import com.relogiclabs.json.schema.internal.message.ActualHelper; -import com.relogiclabs.json.schema.internal.message.ExpectedHelper; -import com.relogiclabs.json.schema.message.ErrorDetail; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import java.text.DecimalFormat; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.ValueMismatch; -import static com.relogiclabs.json.schema.message.ErrorCode.DUBL01; -import static java.util.Objects.requireNonNull; - -@Getter -@EqualsAndHashCode -public final class JDouble extends JNumber implements PragmaValue { - private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("0.0##############E0"); - private final double value; - - private JDouble(JDoubleBuilder builder) { - super(builder); - value = requireNonNull(builder.value()); - } - - public static JDouble from(JDoubleBuilder builder) { - return new JDouble(builder).initialize(); - } - - @Override - public JsonType getType() { - return JsonType.DOUBLE; - } - - @Override - public boolean match(JNode node) { - var other = castType(node, JDouble.class); - if(other == null) return false; - if(areEqual(value, other.value)) return true; - return failWith(new JsonSchemaException( - new ErrorDetail(DUBL01, ValueMismatch), - ExpectedHelper.asValueMismatch(this), - ActualHelper.asValueMismatch(other))); - } - - @Override - public double toDouble() { - return value; - } - - @Override - public Double toNativeValue() { - return value; - } - - @Override - public String toString() { - return DOUBLE_FORMAT.format(value); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JFloat.java b/src/main/java/com/relogiclabs/json/schema/type/JFloat.java deleted file mode 100644 index 053a513..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JFloat.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.internal.builder.JFloatBuilder; -import com.relogiclabs.json.schema.internal.message.ActualHelper; -import com.relogiclabs.json.schema.internal.message.ExpectedHelper; -import com.relogiclabs.json.schema.message.ErrorDetail; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import java.text.DecimalFormat; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.ValueMismatch; -import static com.relogiclabs.json.schema.message.ErrorCode.FLOT01; -import static java.util.Objects.requireNonNull; - -@Getter -@EqualsAndHashCode -public final class JFloat extends JNumber implements PragmaValue { - private static final DecimalFormat FLOAT_FORMAT = new DecimalFormat("0.0##############"); - private final double value; - - private JFloat(JFloatBuilder builder) { - super(builder); - value = requireNonNull(builder.value()); - } - - public static JFloat from(JFloatBuilder builder) { - return new JFloat(builder).initialize(); - } - - @Override - public JsonType getType() { - return JsonType.FLOAT; - } - - @Override - public boolean match(JNode node) { - var other = castType(node, JFloat.class); - if(other == null) return false; - if(areEqual(value, other.value)) return true; - return failWith(new JsonSchemaException( - new ErrorDetail(FLOT01, ValueMismatch), - ExpectedHelper.asValueMismatch(this), - ActualHelper.asValueMismatch(other))); - } - - @Override - public double toDouble() { - return value; - } - - @Override - public Double toNativeValue() { - return value; - } - - @Override - public String toString() { - return FLOAT_FORMAT.format(value); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JFunction.java b/src/main/java/com/relogiclabs/json/schema/type/JFunction.java deleted file mode 100644 index 15939ee..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JFunction.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.exception.TargetInvocationException; -import com.relogiclabs.json.schema.internal.builder.JFunctionBuilder; -import com.relogiclabs.json.schema.internal.message.ActualHelper; -import com.relogiclabs.json.schema.internal.message.ExpectedHelper; -import com.relogiclabs.json.schema.internal.tree.FunctionCache; -import com.relogiclabs.json.schema.message.ErrorDetail; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import java.util.List; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.InvalidNestedFunction; -import static com.relogiclabs.json.schema.internal.util.MiscellaneousHelper.nonNull; -import static com.relogiclabs.json.schema.internal.util.StreamHelper.forEachTrue; -import static com.relogiclabs.json.schema.internal.util.StringHelper.join; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC06; -import static java.util.Objects.requireNonNull; - -@Getter -@EqualsAndHashCode -public final class JFunction extends JBranch implements NestedMode { - static final String NESTED_MARKER = "*"; - private final String name; - private final boolean nested; - private final List arguments; - private final FunctionCache cache; - - private JFunction(JFunctionBuilder builder) { - super(builder); - name = requireNonNull(builder.name()); - nested = requireNonNull(builder.nested()); - arguments = requireNonNull(builder.arguments()); - children = arguments; - cache = new FunctionCache(); - } - - public static JFunction from(JFunctionBuilder builder) { - return new JFunction(builder).initialize(); - } - - @Override - public boolean match(JNode node) { - if(!nested) return invokeFunction(node); - if(!(node instanceof JComposite composite)) - return failWith(new JsonSchemaException( - new ErrorDetail(FUNC06, InvalidNestedFunction), - ExpectedHelper.asInvalidFunction(this), - ActualHelper.asInvalidFunction(node))); - return forEachTrue(composite.components().stream().map(this::invokeFunction)); - } - - private boolean invokeFunction(JNode node) { - try { - return getRuntime().getFunctions().invokeFunction(this, node); - } catch(Exception ex) { - var exception = ex instanceof TargetInvocationException ? nonNull(ex.getCause(), ex) : ex; - if(exception instanceof RuntimeException runtimeException) throw runtimeException; - else throw new RuntimeException(exception); - } - } - - @Override - public boolean getNested() { - return nested; - } - - boolean isApplicable(JNode node) { - return !nested || node instanceof JComposite; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(name); - if(nested) builder.append(NESTED_MARKER); - builder.append(join(arguments, ", ", "(", ")")); - return builder.toString(); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JInteger.java b/src/main/java/com/relogiclabs/json/schema/type/JInteger.java deleted file mode 100644 index bb8ad9d..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JInteger.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.internal.builder.JIntegerBuilder; -import com.relogiclabs.json.schema.internal.message.ActualHelper; -import com.relogiclabs.json.schema.internal.message.ExpectedHelper; -import com.relogiclabs.json.schema.message.ErrorDetail; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.ValueMismatch; -import static com.relogiclabs.json.schema.message.ErrorCode.INTE01; -import static java.util.Objects.requireNonNull; - -@Getter -@EqualsAndHashCode -public final class JInteger extends JNumber implements PragmaValue { - private final long value; - - private JInteger(JIntegerBuilder builder) { - super(builder); - value = requireNonNull(builder.value()); - } - - public static JInteger from(JIntegerBuilder builder) { - return new JInteger(builder).initialize(); - } - - @Override - public JsonType getType() { - return JsonType.INTEGER; - } - - @Override - public boolean match(JNode node) { - var other = castType(node, JInteger.class); - if(other == null) return false; - if(value == other.value) return true; - return failWith(new JsonSchemaException( - new ErrorDetail(INTE01, ValueMismatch), - ExpectedHelper.asValueMismatch(this), - ActualHelper.asValueMismatch(other))); - } - - @Override - public double toDouble() { - return value; - } - - @Override - public Long toNativeValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JNode.java b/src/main/java/com/relogiclabs/json/schema/type/JNode.java deleted file mode 100644 index 62a696d..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JNode.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.internal.builder.JNodeBuilder; -import com.relogiclabs.json.schema.internal.message.ActualHelper; -import com.relogiclabs.json.schema.internal.message.ExpectedHelper; -import com.relogiclabs.json.schema.message.ErrorDetail; -import com.relogiclabs.json.schema.tree.Context; -import com.relogiclabs.json.schema.tree.RuntimeContext; -import lombok.Getter; - -import java.util.Collection; -import java.util.Map; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.DataTypeMismatch; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP02; -import static java.util.Collections.emptyList; -import static java.util.Objects.requireNonNull; - -public abstract class JNode { - private final Map relations; - @Getter private final Context context; - @Getter protected Collection children = emptyList(); - - JNode(JNodeBuilder builder) { - requireNonNull(builder); - relations = requireNonNull(builder.relations()); - context = requireNonNull(builder.context()); - } - - JNode(JNode node) { - requireNonNull(node); - relations = requireNonNull(node.relations); - context = requireNonNull(node.context); - children = requireNonNull(node.children); - } - - public JNode getParent() { - return relations.get(this); - } - - @SuppressWarnings("unchecked") - T initialize() { - for(var c : getChildren()) relations.put(c, this); - return (T) this; - } - - public RuntimeContext getRuntime() { - return context.getRuntime(); - } - - T castType(JNode node, Class type) { - if(type.isInstance(node)) return type.cast(node); - failWith(new JsonSchemaException( - new ErrorDetail(DTYP02, DataTypeMismatch), - ExpectedHelper.asDataTypeMismatch(this), - ActualHelper.asDataTypeMismatch(node))); - return null; - } - - boolean checkType(JNode node, Class type) { - return castType(node, type) != null; - } - - public abstract boolean match(JNode node); - public abstract String toString(); - - public String getOutline() { - return getRuntime().getMessageFormatter().createOutline(toString()); - } - - boolean failWith(RuntimeException exception) { - return getRuntime().getExceptions().failWith(exception); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JObject.java b/src/main/java/com/relogiclabs/json/schema/type/JObject.java deleted file mode 100644 index bb59129..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JObject.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.collection.IndexMap; -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.internal.builder.JObjectBuilder; -import com.relogiclabs.json.schema.internal.message.ActualHelper; -import com.relogiclabs.json.schema.internal.message.ExpectedHelper; -import com.relogiclabs.json.schema.message.ErrorDetail; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import java.util.Collection; -import java.util.HashSet; -import java.util.List; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.PropertyNotFound; -import static com.relogiclabs.json.schema.internal.message.MessageHelper.PropertyOrderMismatch; -import static com.relogiclabs.json.schema.internal.message.MessageHelper.UndefinedPropertyFound; -import static com.relogiclabs.json.schema.internal.util.MiscellaneousHelper.nonNull; -import static com.relogiclabs.json.schema.internal.util.StringHelper.joinWith; -import static com.relogiclabs.json.schema.message.ErrorCode.PROP05; -import static com.relogiclabs.json.schema.message.ErrorCode.PROP06; -import static com.relogiclabs.json.schema.message.ErrorCode.PROP07; -import static java.util.Objects.requireNonNull; - -@EqualsAndHashCode -public final class JObject extends JComposite { - @Getter private final IndexMap properties; - private final List components; - - private JObject(JObjectBuilder builder) { - super(builder); - properties = requireNonNull(builder.properties()); - components = properties.values().stream().map(JProperty::getValue).toList(); - children = properties.values(); - } - - public static JObject from(JObjectBuilder builder) { - return new JObject(builder).initialize(); - } - - @Override - public JsonType getType() { - return JsonType.OBJECT; - } - - @Override - public boolean match(JNode node) { - var other = castType(node, JObject.class); - if(other == null) return false; - var result = true; - var unresolved = new HashSet<>(other.properties.keySet()); - for(var i = 0; i < properties.size(); i++) { - var thisProp = properties.get(i); - var otherProp = getOtherProp(other, i); - if(otherProp != null) { - result &= thisProp.getValue().match(otherProp.getValue()); - unresolved.remove(thisProp.getKey()); - continue; - } - if(!((JValidator) thisProp.getValue()).getOptional()) - return failWith(new JsonSchemaException( - new ErrorDetail(PROP05, PropertyNotFound), - ExpectedHelper.asPropertyNotFound(thisProp), - ActualHelper.asPropertyNotFound(node, thisProp))); - } - if(unresolved.isEmpty() || getRuntime().getPragmas() - .getIgnoreUndefinedProperties()) return result; - for(String key : unresolved) { - var property = other.properties.get(key); - result &= failWith(new JsonSchemaException( - new ErrorDetail(PROP06, UndefinedPropertyFound), - ExpectedHelper.asUndefinedProperty(this, property), - ActualHelper.asUndefinedProperty(property))); - } - return result; - } - - private JProperty getOtherProp(JObject other, int index) { - var thisProp = properties.get(index); - JProperty otherProp = null; - if(!getRuntime().getPragmas().getIgnoreObjectPropertyOrder()) { - var atProp = getPropAt(other.properties, index); - if(areKeysEqual(atProp, thisProp)) otherProp = atProp; - JProperty existing = null; - if(otherProp == null) existing = other.properties.get(thisProp.getKey()); - if(otherProp == null && existing != null) - failWith(new JsonSchemaException( - new ErrorDetail(PROP07, PropertyOrderMismatch), - ExpectedHelper.asPropertyOrderMismatch(thisProp), - ActualHelper.asPropertyOrderMismatch(nonNull(atProp, other)))); - } else otherProp = other.properties.get(thisProp.getKey()); - return otherProp; - } - - private static JProperty getPropAt(IndexMap properties, int index) { - return index >= properties.size() ? null : properties.get(index); - } - - private static boolean areKeysEqual(JProperty p1, JProperty p2) { - if(p1 == null || p2 == null) return false; - return p1.getKey().equals(p2.getKey()); - } - - @Override - public String toString() { - return joinWith(properties.values(), ", ", "{", "}"); - } - - @Override - public Collection components() { - return components; - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JPragma.java b/src/main/java/com/relogiclabs/json/schema/type/JPragma.java deleted file mode 100644 index 1a5a8da..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JPragma.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.internal.builder.JPragmaBuilder; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import static com.relogiclabs.json.schema.internal.util.CollectionHelper.asList; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static java.util.Objects.requireNonNull; - -@Getter -@EqualsAndHashCode -public final class JPragma extends JDirective { - static final String PRAGMA_MARKER = "%pragma"; - private final String name; - private final PragmaValue value; - - private JPragma(JPragmaBuilder builder) { - super(builder); - name = requireNonNull(builder.name()); - value = (PragmaValue) requireNonNull(builder.value()); - children = asList(builder.value()); - } - - public static JPragma from(JPragmaBuilder builder) { - return new JPragma(builder).initialize(); - } - - @SuppressWarnings("unchecked") - public PragmaValue getValue() { - return (PragmaValue) value; - } - - @Override - public String toString() { - return concat(PRAGMA_MARKER, " ", name, ": ", value); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JProperty.java b/src/main/java/com/relogiclabs/json/schema/type/JProperty.java deleted file mode 100644 index dc558e2..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JProperty.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.collection.Keyable; -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.internal.builder.JPropertyBuilder; -import com.relogiclabs.json.schema.internal.message.ActualHelper; -import com.relogiclabs.json.schema.internal.message.ExpectedHelper; -import com.relogiclabs.json.schema.message.ErrorDetail; -import lombok.Getter; - -import java.util.Objects; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.PropertyKeyMismatch; -import static com.relogiclabs.json.schema.internal.message.MessageHelper.PropertyValueMismatch; -import static com.relogiclabs.json.schema.internal.util.CollectionHelper.asList; -import static com.relogiclabs.json.schema.internal.util.StringHelper.quote; -import static com.relogiclabs.json.schema.message.ErrorCode.PROP01; -import static com.relogiclabs.json.schema.message.ErrorCode.PROP02; -import static java.util.Objects.requireNonNull; - -@Getter -public final class JProperty extends JBranch implements Keyable { - private final String key; - private final JNode value; - - private JProperty(JPropertyBuilder builder) { - super(builder); - key = requireNonNull(builder.key()); - value = requireNonNull(builder.value()); - children = asList(value); - } - - public static JProperty from(JPropertyBuilder builder) { - return new JProperty(builder).initialize(); - } - - @Override - public boolean equals(Object other) { - if(this == other) return true; - if(other == null || getClass() != other.getClass()) return false; - JProperty property = (JProperty) other; - return Objects.equals(key, property.key); - } - - @Override - public int hashCode() { - return Objects.hash(key); - } - - @Override - public boolean match(JNode node) { - var other = castType(node, JProperty.class); - if(other == null) return false; - if(!key.equals(other.key)) return failWith(new JsonSchemaException( - new ErrorDetail(PROP01, PropertyKeyMismatch), - ExpectedHelper.asValueMismatch(this), - ActualHelper.asValueMismatch(other))); - if(!value.match(other.value)) return failWith(new JsonSchemaException( - new ErrorDetail(PROP02, PropertyValueMismatch), - ExpectedHelper.asValueMismatch(this), - ActualHelper.asValueMismatch(other))); - return true; - } - - @Override - public String toString() { - return quote(key) + ": " + value; - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JReceiver.java b/src/main/java/com/relogiclabs/json/schema/type/JReceiver.java deleted file mode 100644 index 5ac76c4..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JReceiver.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.NoValueReceivedException; -import com.relogiclabs.json.schema.exception.ReceiverNotFoundException; -import com.relogiclabs.json.schema.internal.builder.JReceiverBuilder; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import java.util.List; - -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static com.relogiclabs.json.schema.message.ErrorCode.RECV01; -import static com.relogiclabs.json.schema.message.ErrorCode.RECV02; -import static com.relogiclabs.json.schema.message.ErrorCode.RECV03; -import static com.relogiclabs.json.schema.message.ErrorCode.RECV04; -import static com.relogiclabs.json.schema.message.MessageFormatter.formatForSchema; -import static java.util.Objects.requireNonNull; - -@Getter -@EqualsAndHashCode -public final class JReceiver extends JLeaf { - private final String name; - - private JReceiver(JReceiverBuilder builder) { - super(builder); - name = requireNonNull(builder.name()); - } - - public static JReceiver from(JReceiverBuilder builder) { - return new JReceiver(builder).initialize(); - } - - @Override - public boolean match(JNode node) { - throw new IllegalStateException("Invalid runtime state"); - } - - public int getValueCount() { - var list = getRuntime().getReceivers().fetch(this); - if(list == null) throw new ReceiverNotFoundException( - formatForSchema(RECV01, concat("Receiver '", name, "' not found"), this)); - return list.size(); - } - - @SuppressWarnings("unchecked") - public T getValueNode() { - var list = getRuntime().getReceivers().fetch(this); - if(list == null) throw new ReceiverNotFoundException( - formatForSchema(RECV02, concat("Receiver '", name, "' not found"), this)); - if(list.isEmpty()) throw new NoValueReceivedException( - formatForSchema(RECV03, concat("No value received for '", name, "'"), this)); - if(list.size() > 1) throw new UnsupportedOperationException("Multiple values exist"); - return (T) list.get(0); - } - - @SuppressWarnings("unchecked") - public List getValueNodes() { - var list = getRuntime().getReceivers().fetch(this); - if(list == null) throw new ReceiverNotFoundException( - formatForSchema(RECV04, concat("Receiver '", name, "' not found"), this)); - return list.stream().map(i -> (T) i).toList(); - } - - @Override - public String toString() { - return name; - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JRoot.java b/src/main/java/com/relogiclabs/json/schema/type/JRoot.java deleted file mode 100644 index f0b275a..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JRoot.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.internal.builder.JRootBuilder; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import java.util.ArrayList; -import java.util.List; - -import static com.relogiclabs.json.schema.internal.util.CollectionHelper.addToList; -import static com.relogiclabs.json.schema.internal.util.StringHelper.join; -import static java.util.Collections.unmodifiableCollection; -import static java.util.Objects.requireNonNull; - -@Getter -@EqualsAndHashCode -public final class JRoot extends JNode { - private static final String NEW_LINE = System.lineSeparator(); - - private final JTitle title; - private final JVersion version; - private final List includes; - private final List pragmas; - private final List definitions; - private final JNode value; - - private JRoot(JRootBuilder builder) { - super(builder); - title = builder.title(); - version = builder.version(); - includes = builder.includes(); - pragmas = builder.pragmas(); - definitions = builder.definitions(); - value = requireNonNull(builder.value()); - var nodes = new ArrayList(); - addToList(nodes, title, version); - addToList(nodes, includes, pragmas, definitions); - addToList(nodes, value); - children = unmodifiableCollection(children); - } - - public static JRoot from(JRootBuilder builder) { - return new JRoot(builder).initialize(); - } - - @Override - public boolean match(JNode node) { - var other = castType(node, JRoot.class); - if(other == null) return false; - return value.match(other.value); - } - - @Override - public String toString() { - var builder = new StringBuilder(); - appendTo(builder, title); - appendTo(builder, version); - appendTo(builder, includes); - appendTo(builder, pragmas); - appendTo(builder, definitions); - appendTo(builder, value); - return builder.toString().trim(); - } - - private void appendTo(StringBuilder builder, JNode node) { - if(node == null) return; - builder.append(node).append(NEW_LINE); - } - - private void appendTo(StringBuilder builder, List list) { - if(list == null || list.isEmpty()) return; - builder.append(join(list, NEW_LINE, "", NEW_LINE)); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JString.java b/src/main/java/com/relogiclabs/json/schema/type/JString.java deleted file mode 100644 index dc060a1..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JString.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.internal.builder.JStringBuilder; -import com.relogiclabs.json.schema.internal.message.ActualHelper; -import com.relogiclabs.json.schema.internal.message.ExpectedHelper; -import com.relogiclabs.json.schema.message.ErrorDetail; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.ValueMismatch; -import static com.relogiclabs.json.schema.internal.util.StringHelper.quote; -import static com.relogiclabs.json.schema.message.ErrorCode.STRN01; -import static java.util.Objects.requireNonNull; - -@Getter -@EqualsAndHashCode -public class JString extends JPrimitive implements Derivable, PragmaValue { - private final String value; - @Getter @Setter private JNode derived; - - private JString(JStringBuilder builder) { - super(builder); - value = requireNonNull(builder.value()); - } - - JString(JString node) { - super(node); - this.value = requireNonNull(node.value); - } - - public static JString from(JStringBuilder builder) { - return new JString(builder).initialize(); - } - - @Override - public JsonType getType() { - return JsonType.STRING; - } - - @Override - public boolean match(JNode node) { - var other = castType(node, JString.class); - if(other == null) return false; - if(value.equals(other.value)) return true; - return failWith(new JsonSchemaException( - new ErrorDetail(STRN01, ValueMismatch), - ExpectedHelper.asValueMismatch(this), - ActualHelper.asValueMismatch(other))); - } - - @Override - public String toNativeValue() { - return value; - } - - @Override - public String toString() { - return quote(value); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JValidator.java b/src/main/java/com/relogiclabs/json/schema/type/JValidator.java deleted file mode 100644 index fd486a9..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JValidator.java +++ /dev/null @@ -1,166 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.internal.builder.JValidatorBuilder; -import com.relogiclabs.json.schema.internal.message.ActualHelper; -import com.relogiclabs.json.schema.internal.message.ExpectedHelper; -import com.relogiclabs.json.schema.message.ErrorDetail; -import com.relogiclabs.json.schema.message.ExpectedDetail; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import static com.relogiclabs.json.schema.internal.message.MessageHelper.InvalidNonCompositeType; -import static com.relogiclabs.json.schema.internal.message.MessageHelper.ValidationFailed; -import static com.relogiclabs.json.schema.internal.util.CollectionHelper.addToList; -import static com.relogiclabs.json.schema.internal.util.CollectionHelper.tryGetLast; -import static com.relogiclabs.json.schema.internal.util.StreamHelper.forEachTrue; -import static com.relogiclabs.json.schema.internal.util.StringHelper.concat; -import static com.relogiclabs.json.schema.internal.util.StringHelper.join; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP03; -import static com.relogiclabs.json.schema.message.ErrorCode.VALD01; -import static com.relogiclabs.json.schema.type.JDataType.DATA_TYPE_NAME; -import static java.util.Collections.unmodifiableCollection; -import static lombok.AccessLevel.NONE; - -@Getter -@EqualsAndHashCode -public final class JValidator extends JBranch { - static final String OPTIONAL_MARKER = "?"; - - private final JNode value; - private final List functions; - private final List dataTypes; - private final List receivers; - private final boolean optional; - - @Getter(NONE) - @EqualsAndHashCode.Exclude - private final List exceptions; - - private JValidator(JValidatorBuilder builder) { - super(builder); - value = builder.value(); - functions = builder.functions(); - dataTypes = builder.dataTypes(); - receivers = builder.receivers(); - optional = builder.optional(); - exceptions = new LinkedList<>(); - getRuntime().getReceivers().register(receivers); - var nodes = new ArrayList(); - addToList(nodes, value); - addToList(nodes, functions, dataTypes, receivers); - children = unmodifiableCollection(nodes); - } - - public static JValidator from(JValidatorBuilder builder) { - return new JValidator(builder).initialize(); - } - - @Override - public boolean match(JNode node) { - boolean rValue = true; - var other = castType(node, JsonTypable.class); - if(other == null) return false; - getRuntime().getReceivers().receive(receivers, node); - if(node instanceof JNull && dataTypes.stream() - .anyMatch(JDataType::isMatchNull)) return true; - if(value != null) rValue &= value.match(other.getNode()); - if(!rValue) return failWith(new JsonSchemaException( - new ErrorDetail(VALD01, ValidationFailed), - ExpectedHelper.asGeneralValueMismatch(value), - ActualHelper.asGeneralValueMismatch(node))); - var rDataType = matchDataType(node); - var fDataType = rDataType && dataTypes.size() != 0; - boolean rFunction = forEachTrue(functions.stream() - .filter(f -> f.isApplicable(node) || !fDataType) - .map(f -> f.match(node))); - return rValue & rDataType & rFunction; - } - - private boolean matchDataType(JNode node) { - if(getRuntime().getExceptions().tryExecute(() -> checkDataType(node))) return true; - saveTryBuffer(); - for(var e : exceptions) failWith((RuntimeException) e); - return false; - } - - private static List processTryBuffer(List buffer) { - var list = new ArrayList(buffer.size()); - for(var e : buffer) { - var result = mergeException(tryGetLast(list), e); - if(result != null) list.set(list.size() - 1, result); - else list.add(e); - } - return list; - } - - private static JsonSchemaException mergeException(Exception ex1, Exception ex2) { - if(!(ex1 instanceof JsonSchemaException e1)) return null; - if(!(ex2 instanceof JsonSchemaException e2)) return null; - if(!e1.getCode().equals(e2.getCode())) return null; - var a1 = e1.getAttribute(DATA_TYPE_NAME); - var a2 = e2.getAttribute(DATA_TYPE_NAME); - if(a1 == null || a2 == null) return null; - var result = new JsonSchemaException(e1.getError(), mergeExpected(e1, e2), e2.getActual()); - result.setAttribute(DATA_TYPE_NAME, a1 + a2); - return result; - } - - private static ExpectedDetail mergeExpected(JsonSchemaException ex1, - JsonSchemaException ex2) { - var typeName2 = ex2.getAttribute(DATA_TYPE_NAME); - var expected1 = ex1.getExpected(); - return new ExpectedDetail(expected1.getContext(), - concat(expected1.getMessage(), " or ", typeName2)); - } - - private boolean checkDataType(JNode node) { - var list1 = dataTypes.stream().filter(d -> !d.getNested()).toList(); - var result1 = anyMatch(list1, node); - if(result1) getTryBuffer().clear(); - var list2 = dataTypes.stream().filter(d -> d.getNested() - && (d.isApplicable(node) || !result1)).toList(); - if(list2.isEmpty()) return result1 || list1.isEmpty(); - if(!(node instanceof JComposite composite)) - return failWith(new JsonSchemaException( - new ErrorDetail(DTYP03, InvalidNonCompositeType), - ExpectedHelper.asInvalidNonCompositeType(list2.get(0)), - ActualHelper.asInvalidNonCompositeType(node))); - saveTryBuffer(); - var result2 = forEachTrue(composite.components().stream() - .map(n -> anyMatch(list2, n))); - return (result1 || list1.isEmpty()) && result2; - } - - private boolean anyMatch(List list, JNode node) { - getTryBuffer().clear(); - for(var d : list) if(d.match(node)) return true; - saveTryBuffer(); - return false; - } - - private List getTryBuffer() { - return getRuntime().getExceptions().getTryBuffer(); - } - - private void saveTryBuffer() { - List tryBuffer = getTryBuffer(); - if(tryBuffer.isEmpty()) return; - exceptions.addAll(processTryBuffer(tryBuffer)); - tryBuffer.clear(); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - if(value != null) builder.append(value); - builder.append(join(functions, " ", " ")); - builder.append(join(dataTypes, " ", " ")); - if(optional) builder.append(" " + OPTIONAL_MARKER); - return builder.toString().trim(); - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JsonTypable.java b/src/main/java/com/relogiclabs/json/schema/type/JsonTypable.java deleted file mode 100644 index 0d086c2..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JsonTypable.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.relogiclabs.json.schema.type; - -public interface JsonTypable { - default JsonType getType() { - return JsonType.ANY; - } - JNode getNode(); -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/JsonType.java b/src/main/java/com/relogiclabs/json/schema/type/JsonType.java deleted file mode 100644 index 7b98565..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/JsonType.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.relogiclabs.json.schema.type; - -import com.relogiclabs.json.schema.exception.InvalidDataTypeException; -import com.relogiclabs.json.schema.tree.Location; -import com.relogiclabs.json.schema.util.Reference; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.antlr.v4.runtime.tree.TerminalNode; - -import java.util.HashMap; -import java.util.Map; - -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP01; -import static com.relogiclabs.json.schema.message.MessageFormatter.formatForSchema; - -@Getter -@AllArgsConstructor -public enum JsonType { - BOOLEAN("#boolean", JBoolean.class), - STRING("#string", JString.class), - INTEGER("#integer", JInteger.class), - FLOAT("#float", JFloat.class), - DOUBLE("#double", JDouble.class), - OBJECT("#object", JObject.class), - ARRAY("#array", JArray.class), - NULL("#null", JNull.class), - NUMBER("#number", JNumber.class), - DATE("#date", JString.class), - TIME("#time", JString.class), - PRIMITIVE("#primitive", JPrimitive.class), - COMPOSITE("#composite", JComposite.class), - ANY("#any", JsonTypable.class); - - private static final Map stringTypeMap; - private static final Map, JsonType> classTypeMap; - - private final String name; - private final Class type; - - static { - stringTypeMap = new HashMap<>(); - classTypeMap = new HashMap<>(); - for(JsonType t : JsonType.values()) { - stringTypeMap.put(t.name, t); - classTypeMap.putIfAbsent(t.type, t); - } - } - - public static JsonType from(TerminalNode node) { - return from(node.getText(), Location.from(node.getSymbol())); - } - - public static JsonType from(Class type) { - return classTypeMap.get(type); - } - - private static JsonType from(String name, Location location) { - var result = stringTypeMap.get(name); - if(result == null) throw new InvalidDataTypeException( - formatForSchema(DTYP01, "Invalid data type " + name, location)); - return result; - } - - public boolean match(JNode node, Reference error) { - if(!type.isInstance(node)) return false; - if(this == DATE) { - var date = (JString) node; - var dateTime = node.getRuntime().getPragmas().getDateTypeParser() - .tryParse(date.getValue(), error); - if(dateTime == null) return false; - date.setDerived(JDate.from(date, dateTime)); - } else if(this == TIME) { - var time = (JString) node; - var dateTime = node.getRuntime().getPragmas().getTimeTypeParser() - .tryParse(time.getValue(), error); - if(dateTime == null) return false; - time.setDerived(JTime.from(time, dateTime)); - } - return true; - } - - @Override - public String toString() { - return name; - } -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/NestedMode.java b/src/main/java/com/relogiclabs/json/schema/type/NestedMode.java deleted file mode 100644 index c3c32c7..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/NestedMode.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.relogiclabs.json.schema.type; - -public interface NestedMode { - boolean getNested(); -} \ No newline at end of file diff --git a/src/main/java/com/relogiclabs/json/schema/type/PragmaValue.java b/src/main/java/com/relogiclabs/json/schema/type/PragmaValue.java deleted file mode 100644 index 6c0fb2d..0000000 --- a/src/main/java/com/relogiclabs/json/schema/type/PragmaValue.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.relogiclabs.json.schema.type; - -public interface PragmaValue { - T toNativeValue(); -} \ No newline at end of file diff --git a/src/main/java/lombok.config b/src/main/java/lombok.config index 8e301ea..4143db8 100644 --- a/src/main/java/lombok.config +++ b/src/main/java/lombok.config @@ -1,5 +1,3 @@ config.stopBubbling = true -lombok.getter.noIsPrefix = true lombok.equalsAndHashCode.doNotUseGetters = true -lombok.equalsAndHashCode.callSuper = skip - +lombok.equalsAndHashCode.callSuper = skip \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions.java b/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions.java similarity index 64% rename from src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions.java rename to src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions.java index 0aedbb6..990972d 100644 --- a/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions.java +++ b/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions.java @@ -1,24 +1,24 @@ -package com.relogiclabs.json.schema.external; +package com.relogiclabs.jschema.test.external; -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.function.FunctionBase; -import com.relogiclabs.json.schema.function.FutureValidator; -import com.relogiclabs.json.schema.message.ActualDetail; -import com.relogiclabs.json.schema.message.ErrorDetail; -import com.relogiclabs.json.schema.message.ExpectedDetail; -import com.relogiclabs.json.schema.tree.RuntimeContext; -import com.relogiclabs.json.schema.type.JBoolean; -import com.relogiclabs.json.schema.type.JInteger; -import com.relogiclabs.json.schema.type.JNumber; -import com.relogiclabs.json.schema.type.JReceiver; -import com.relogiclabs.json.schema.type.JString; +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.function.FunctionProvider; +import com.relogiclabs.jschema.function.FutureFunction; +import com.relogiclabs.jschema.message.ActualDetail; +import com.relogiclabs.jschema.message.ErrorDetail; +import com.relogiclabs.jschema.message.ExpectedDetail; +import com.relogiclabs.jschema.node.JBoolean; +import com.relogiclabs.jschema.node.JInteger; +import com.relogiclabs.jschema.node.JNumber; +import com.relogiclabs.jschema.node.JReceiver; +import com.relogiclabs.jschema.node.JString; +import com.relogiclabs.jschema.tree.RuntimeContext; import java.util.Arrays; -import static com.relogiclabs.json.schema.internal.util.StringHelper.join; +import static com.relogiclabs.jschema.internal.util.StringHelper.join; // Functions for positive (valid) test cases -public class ExternalFunctions extends FunctionBase { +public class ExternalFunctions extends FunctionProvider { public static final String EVENFUNC01 = "EVENFUNC01"; public static final String ERRACCESS01 = "ERRACCESS01"; public static final String CONDFUNC01 = "CONDFUNC01"; @@ -32,9 +32,9 @@ public ExternalFunctions(RuntimeContext runtime) { public boolean even(JNumber target) { boolean result = (target.toDouble() % 2 == 0); - if(!result) return failWith(new JsonSchemaException( + if(!result) return fail(new JsonSchemaException( new ErrorDetail(EVENFUNC01, "Number is not even"), - new ExpectedDetail(function, "even number"), + new ExpectedDetail(caller, "even number"), new ActualDetail(target, "number ", target, " is odd"))); return true; } @@ -49,9 +49,9 @@ public boolean canTest(JNumber target, JString str1, JBoolean bool1, JNumber... public boolean checkAccess(JInteger target, JReceiver userRole) { String role = userRole.getValueNode().getValue(); - if(role.equals("user") && target.getValue() > 5) return failWith(new JsonSchemaException( + if(role.equals("user") && target.getValue() > 5) return fail(new JsonSchemaException( new ErrorDetail(ERRACCESS01, "Data access incompatible with 'user' role"), - new ExpectedDetail(function, "an access at most 5 for 'user' role"), + new ExpectedDetail(caller, "an access at most 5 for 'user' role"), new ActualDetail(target, "found access ", target, " which is greater than 5"))); return true; } @@ -60,9 +60,9 @@ public boolean condition(JInteger target, JReceiver receiver) { long threshold = receiver.getValueNode().getValue(); System.out.println("Received integer: " + threshold); boolean result = threshold < target.getValue(); - if(!result) return failWith(new JsonSchemaException( + if(!result) return fail(new JsonSchemaException( new ErrorDetail(CONDFUNC01, "Number does not satisfy the condition"), - new ExpectedDetail(function, "a number > ", threshold, " of '", receiver.getName(), "'"), + new ExpectedDetail(caller, "a number > ", threshold, " of '", receiver.getName(), "'"), new ActualDetail(target, "found number ", target, " <= ", threshold))); return result; } @@ -73,16 +73,16 @@ public boolean conditionAll(JInteger target, JReceiver receiver) { System.out.println("Target: " + target); System.out.println("Received integers: " + values); boolean result = list.stream().allMatch(i -> i.getValue() < target.getValue()); - if(!result) return failWith(new JsonSchemaException( + if(!result) return fail(new JsonSchemaException( new ErrorDetail(CONDFUNC02, "Number does not satisfy the condition"), - new ExpectedDetail(function, "a number > any of ", values, " of '", receiver.getName(), "'"), + new ExpectedDetail(caller, "a number > any of ", values, " of '", receiver.getName(), "'"), new ActualDetail(target, "found number ", target, " <= some of ", values))); return true; } - public FutureValidator sumEqual(JInteger target, JReceiver receiver) { - // Capture the current value of the function for future lambda - var caller = function; + public FutureFunction sumEqual(JInteger target, JReceiver receiver) { + // Capture the current value of the caller + var current = caller; return () -> { var values = receiver.getValueNodes(); var expression = join(values, "+"); @@ -90,28 +90,28 @@ public FutureValidator sumEqual(JInteger target, JReceiver receiver) { System.out.println("Received values: " + expression); long result = values.stream().mapToLong(JInteger::getValue).sum(); if(result != target.getValue()) - return failWith(new JsonSchemaException( + return fail(new JsonSchemaException( new ErrorDetail(SUMEQUAL01, "Number != sum of ", expression, " = ", result), - new ExpectedDetail(caller, "a number = sum of numbers ", result), + new ExpectedDetail(current, "a number = sum of numbers ", result), new ActualDetail(target, "found number ", target, " != ", result))); return true; }; } - public FutureValidator minmax(JInteger target, JReceiver min, JReceiver max) { - // Capture the current value of the function for future lambda - var caller = function; + public FutureFunction minmax(JInteger target, JReceiver min, JReceiver max) { + // Capture the current value of the caller + var current = caller; return () -> { var intMin = min.getValueNode().getValue(); var intMax = max.getValueNode().getValue(); System.out.println("Target: " + target); System.out.println("Received min: " + intMin + ", max: " + intMax); boolean result = target.getValue() >= intMin && target.getValue() <= intMax; - if(!result) return failWith(new JsonSchemaException( + if(!result) return fail(new JsonSchemaException( new ErrorDetail(MINMAX01, "Number is outside of range"), - new ExpectedDetail(caller, "a number in range [", intMin, ", ", intMax, "]"), + new ExpectedDetail(current, "a number in range [", intMin, ", ", intMax, "]"), new ActualDetail(target, "found number ", target, " not in range"))); return true; }; } -} +} \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions1.java b/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions1.java similarity index 74% rename from src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions1.java rename to src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions1.java index 85cf198..8bff1a4 100644 --- a/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions1.java +++ b/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions1.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.external; +package com.relogiclabs.jschema.test.external; -import com.relogiclabs.json.schema.type.JNumber; +import com.relogiclabs.jschema.node.JNumber; // Functions for negative (error) test cases public class ExternalFunctions1 { diff --git a/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions2.java b/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions2.java similarity index 53% rename from src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions2.java rename to src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions2.java index 160f713..7dd778e 100644 --- a/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions2.java +++ b/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions2.java @@ -1,11 +1,11 @@ -package com.relogiclabs.json.schema.external; +package com.relogiclabs.jschema.test.external; -import com.relogiclabs.json.schema.function.FunctionBase; -import com.relogiclabs.json.schema.tree.RuntimeContext; -import com.relogiclabs.json.schema.type.JNumber; +import com.relogiclabs.jschema.function.FunctionProvider; +import com.relogiclabs.jschema.node.JNumber; +import com.relogiclabs.jschema.tree.RuntimeContext; // Functions for negative (error) test cases -public class ExternalFunctions2 extends FunctionBase { +public class ExternalFunctions2 extends FunctionProvider { public ExternalFunctions2(RuntimeContext runtime) { super(runtime); } diff --git a/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions3.java b/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions3.java similarity index 50% rename from src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions3.java rename to src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions3.java index c72de8b..7632ec7 100644 --- a/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions3.java +++ b/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions3.java @@ -1,10 +1,10 @@ -package com.relogiclabs.json.schema.external; +package com.relogiclabs.jschema.test.external; -import com.relogiclabs.json.schema.function.FunctionBase; -import com.relogiclabs.json.schema.tree.RuntimeContext; +import com.relogiclabs.jschema.function.FunctionProvider; +import com.relogiclabs.jschema.tree.RuntimeContext; // Functions for negative (error) test cases -public class ExternalFunctions3 extends FunctionBase { +public class ExternalFunctions3 extends FunctionProvider { public ExternalFunctions3(RuntimeContext runtime) { super(runtime); } diff --git a/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions4.java b/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions4.java new file mode 100644 index 0000000..0b8917f --- /dev/null +++ b/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions4.java @@ -0,0 +1,17 @@ +package com.relogiclabs.jschema.test.external; + +import com.relogiclabs.jschema.function.FunctionProvider; +import com.relogiclabs.jschema.node.JNumber; +import com.relogiclabs.jschema.tree.RuntimeContext; + +// Functions for negative (error) test cases +public class ExternalFunctions4 extends FunctionProvider { + public ExternalFunctions4(RuntimeContext runtime) { + super(runtime); + } + + public boolean canTest(JNumber target) { + // If you just want to throw any exception without details + return fail(new RuntimeException("something went wrong")); + } +} \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions5.java b/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions5.java new file mode 100644 index 0000000..5e44fd6 --- /dev/null +++ b/src/test/java/com/relogiclabs/jschema/test/external/ExternalFunctions5.java @@ -0,0 +1,10 @@ +package com.relogiclabs.jschema.test.external; + +import com.relogiclabs.jschema.function.FunctionProvider; + +// Functions for negative (error) test cases +public class ExternalFunctions5 extends FunctionProvider { + public ExternalFunctions5() { + super(null); + } +} \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/json/schema/negative/AggregatedTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/AggregatedTests.java similarity index 54% rename from src/test/java/com/relogiclabs/json/schema/negative/AggregatedTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/AggregatedTests.java index 0a2b9a4..c60f0af 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/AggregatedTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/AggregatedTests.java @@ -1,12 +1,12 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.JsonSchemaException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.JsonSchemaException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.external.ExternalFunctions.ERRACCESS01; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP04; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP04; +import static com.relogiclabs.jschema.test.external.ExternalFunctions.ERRACCESS01; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -15,7 +15,7 @@ public class AggregatedTests { public void When_JsonSchemaAggregatedTestWithWrongData_ExceptionThrown() { var schema = """ %title: "User Profile Response" - %version: 1.0.0 + %version: "1.0.0-basic" %schema: { "user": { @@ -25,9 +25,11 @@ public void When_JsonSchemaAggregatedTestWithWrongData_ExceptionThrown() { /*currently only one role is allowed by system*/ "role": "user" #string, "isActive": #boolean, //user account current status + "registeredAt": #time, "profile": { "firstName": @regex("[A-Za-z ]{3,50}") #string, "lastName": @regex("[A-Za-z ]{3,50}") #string, + "dateOfBirth": #date, "age": @range(18, 130) #integer, "email": @email #string, "pictureURL": @url #string, @@ -47,9 +49,11 @@ public void When_JsonSchemaAggregatedTestWithWrongData_ExceptionThrown() { "username": "john doe", "role": "user", "isActive": true, + "registeredAt": "2023-09-06T15:10:30.639Z", "profile": { "firstName": "John", "lastName": "Doe", + "dateOfBirth": "1993-06-17", "age": 30, "email": "john.doe@example.com", "pictureURL": "https://example.com/picture.jpg", @@ -73,8 +77,8 @@ public void When_JsonSchemaAggregatedTestWithWrongData_ExceptionThrown() { public void When_ExtendedAggregatedTestWithInvalidAccess_ExceptionThrown() { var schema = """ %title: "Extended User Profile Dashboard API Response" - %version: 2.0.0 - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %version: "2.0.0-extended" + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %pragma IgnoreUndefinedProperties: true %define $post: { @@ -170,8 +174,8 @@ public void When_ExtendedAggregatedTestWithInvalidAccess_ExceptionThrown() { }, { "id": 2, - "title": "Working with JSON in C#", - "content": "C# provides built-in support for working with JSON...", + "title": "Working with JSON in Java", + "content": "Java provides great support for working with JSON...", "tags": [ "CSharp", "JSON", @@ -230,4 +234,180 @@ public void When_ExtendedAggregatedTestWithInvalidAccess_ExceptionThrown() { assertEquals(ERRACCESS01, exception.getCode()); exception.printStackTrace(); } + + @Test + public void When_ExtendedAggregatedScriptTestWithInvalidAccess_ExceptionThrown() { + var schema = """ + %title: "Extended User Profile Dashboard API Response" + %version: "2.0.0-extended" + + %pragma DateDataTypeFormat: "DD-MM-YYYY" + %pragma TimeDataTypeFormat: "DD-MM-YYYY hh:mm:ss" + %pragma IgnoreUndefinedProperties: true + + %define $post: { + "id": @range(1, 1000) #integer, + "title": @length(10, 100) #string, + "content": @length(30, 1000) #string, + "tags": $tags + } #object + + %define $product: { + "id": @length(2, 10) @regex("[a-z][a-z0-9]+") #string, + "name": @length(5, 30) #string, + "brand": @length(5, 30) #string, + "price": @range(0.1, 1000000), + "inStock": #boolean, + "specs": { + "cpu": @length(5, 30) #string, + "ram": @regex("[0-9]{1,2}GB") #string, + "storage": @regex("[0-9]{1,4}GB (SSD|HDD)") #string + } #object #null + } + + %define $tags: @length(1, 10) #string*($tag) #array + %define $tag: @length(3, 20) @regex("[A-Za-z_]+") #string + + %schema: + { + "user": { + "id": @range(1, 10000) #integer, + /*username does not allow special characters*/ + "username": @regex("[a-z_]{3,30}") #string, + "role": @enum("user", "admin") #string &role, + "isActive": #boolean, //user account current status + "registeredAt": @after("01-01-2010 00:00:00") #time, + "dataAccess": @checkAccess(&role) #integer, + "profile": { + "firstName": @regex("[A-Za-z]{3,50}") #string, + "lastName": @regex("[A-Za-z]{3,50}") #string, + "dateOfBirth": @before("01-01-2006") #date, + "age": @range(18, 128) #integer, + "email": @email #string, + "pictureURL": @url #string, + "address": { + "street": @length(10, 200) #string, + "city": @length(3, 50) #string, + "country": @regex("[A-Za-z ]{3,50}") #string + } #object #null, + "hobbies": !? + }, + "posts": @length(0, 1000) #object*($post) #array, + "preferences": { + "theme": @enum("light", "dark") #string, + "fontSize": @range(9, 24) #integer, + "autoSave": #boolean + } + }, + "products": #object*($product) #array, + "weather": { + "temperature": @range(-50, 60) #integer #float, + "isCloudy": #boolean + } + } + + %script: { + future constraint checkAccess(role) { + if(role[0] == "user" && target > 5) return fail( + "ERRACCESS01", "Data access incompatible with 'user' role", + expected("an access at most 5 for 'user' role"), + actual("found access " + target + " which is greater than 5")); + } + } + """; + var json = """ + { + "user": { + "id": 1234, + "username": "johndoe", + "role": "user", + "isActive": true, + "registeredAt": "06-09-2023 15:10:30", + "dataAccess": 6, + "profile": { + "firstName": "John", + "lastName": "Doe", + "dateOfBirth": "17-06-1993", + "age": 30, + "email": "john.doe@example.com", + "pictureURL": "https://example.com/picture.jpg", + "address": { + "street": "123 Some St", + "city": "Some town", + "country": "Some Country" + } + }, + "posts": [ + { + "id": 1, + "title": "Introduction to JSON", + "content": "JSON (JavaScript Object Notation) is a lightweight data interchange format...", + "tags": [ + "JSON", + "tutorial", + "data" + ] + }, + { + "id": 2, + "title": "Working with JSON in Java", + "content": "Java provides great support for working with JSON...", + "tags": [ + "CSharp", + "JSON", + "tutorial" + ] + }, + { + "id": 3, + "title": "Introduction to JSON Schema", + "content": "A JSON schema defines the structure and data types of JSON objects...", + "tags": [ + "Schema", + "JSON", + "tutorial" + ] + } + ], + "preferences": { + "theme": "dark", + "fontSize": 14, + "autoSave": true + } + }, + "products": [ + { + "id": "p1", + "name": "Smartphone", + "brand": "TechGiant", + "price": 1.99, + "inStock": true, + "specs": null + }, + { + "id": "p2", + "name": "Laptop", + "brand": "SuperTech", + "price": 1299.99, + "inStock": false, + "specs": { + "cpu": "Ryzen 11", + "ram": "11GB", + "storage": "11GB SSD" + } + } + ], + "weather": { + "temperature": 25.5, + "isCloudy": true, + "conditions": null + } + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(JsonSchemaException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(ERRACCESS01, exception.getCode()); + exception.printStackTrace(); + } } \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/json/schema/negative/ArrayTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/ArrayTests.java similarity index 89% rename from src/test/java/com/relogiclabs/json/schema/negative/ArrayTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/ArrayTests.java index 8776415..556381e 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/ArrayTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/ArrayTests.java @@ -1,22 +1,22 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.JsonParserException; -import com.relogiclabs.json.schema.exception.JsonSchemaException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.JsonParserException; +import com.relogiclabs.jschema.exception.JsonSchemaException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.message.ErrorCode.ALEN01; -import static com.relogiclabs.json.schema.message.ErrorCode.ALEN02; -import static com.relogiclabs.json.schema.message.ErrorCode.ALEN03; -import static com.relogiclabs.json.schema.message.ErrorCode.ALEN04; -import static com.relogiclabs.json.schema.message.ErrorCode.ALEN05; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP04; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP06; -import static com.relogiclabs.json.schema.message.ErrorCode.ELEM01; -import static com.relogiclabs.json.schema.message.ErrorCode.ENUM02; -import static com.relogiclabs.json.schema.message.ErrorCode.JPRS01; -import static com.relogiclabs.json.schema.message.ErrorCode.NEMT02; +import static com.relogiclabs.jschema.message.ErrorCode.ALEN01; +import static com.relogiclabs.jschema.message.ErrorCode.ALEN02; +import static com.relogiclabs.jschema.message.ErrorCode.ALEN03; +import static com.relogiclabs.jschema.message.ErrorCode.ALEN04; +import static com.relogiclabs.jschema.message.ErrorCode.ALEN05; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP04; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP06; +import static com.relogiclabs.jschema.message.ErrorCode.ELEM01; +import static com.relogiclabs.jschema.message.ErrorCode.ENUM02; +import static com.relogiclabs.jschema.message.ErrorCode.JPRS01; +import static com.relogiclabs.jschema.message.ErrorCode.NEMT02; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/relogiclabs/json/schema/negative/BooleanTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/BooleanTests.java similarity index 88% rename from src/test/java/com/relogiclabs/json/schema/negative/BooleanTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/BooleanTests.java index 0c76f00..3a93286 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/BooleanTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/BooleanTests.java @@ -1,13 +1,13 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.JsonSchemaException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.JsonSchemaException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.message.ErrorCode.BOOL01; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP04; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP06; +import static com.relogiclabs.jschema.message.ErrorCode.BOOL01; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP04; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP06; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/relogiclabs/json/schema/negative/ComponentTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/ComponentTests.java similarity index 81% rename from src/test/java/com/relogiclabs/json/schema/negative/ComponentTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/ComponentTests.java index 63162a6..bf97cc2 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/ComponentTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/ComponentTests.java @@ -1,12 +1,12 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.exception.DefinitionNotFoundException; -import com.relogiclabs.json.schema.exception.DuplicateDefinitionException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.exception.DefinitionNotFoundException; +import com.relogiclabs.jschema.exception.DuplicateDefinitionException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.message.ErrorCode.DEFI01; -import static com.relogiclabs.json.schema.message.ErrorCode.DEFI02; +import static com.relogiclabs.jschema.message.ErrorCode.DEFI01; +import static com.relogiclabs.jschema.message.ErrorCode.DEFI02; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/relogiclabs/json/schema/negative/DataTypeTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/DataTypeTests.java similarity index 91% rename from src/test/java/com/relogiclabs/json/schema/negative/DataTypeTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/DataTypeTests.java index dea15b5..a791c07 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/DataTypeTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/DataTypeTests.java @@ -1,16 +1,16 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.DefinitionNotFoundException; -import com.relogiclabs.json.schema.exception.JsonSchemaException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.DefinitionNotFoundException; +import com.relogiclabs.jschema.exception.JsonSchemaException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.message.ErrorCode.DEFI03; -import static com.relogiclabs.json.schema.message.ErrorCode.DEFI04; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP03; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP04; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP06; +import static com.relogiclabs.jschema.message.ErrorCode.DEFI03; +import static com.relogiclabs.jschema.message.ErrorCode.DEFI04; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP03; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP04; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP06; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/relogiclabs/json/schema/negative/DateTimeTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/DateTimeTests.java similarity index 89% rename from src/test/java/com/relogiclabs/json/schema/negative/DateTimeTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/DateTimeTests.java index 09178d9..a9e80aa 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/DateTimeTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/DateTimeTests.java @@ -1,48 +1,48 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.JsonSchemaException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.JsonSchemaException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.message.ErrorCode.AFTR01; -import static com.relogiclabs.json.schema.message.ErrorCode.BFOR01; -import static com.relogiclabs.json.schema.message.ErrorCode.DCNF01; -import static com.relogiclabs.json.schema.message.ErrorCode.DDAY03; -import static com.relogiclabs.json.schema.message.ErrorCode.DDAY04; -import static com.relogiclabs.json.schema.message.ErrorCode.DERA01; -import static com.relogiclabs.json.schema.message.ErrorCode.DFRC04; -import static com.relogiclabs.json.schema.message.ErrorCode.DHUR01; -import static com.relogiclabs.json.schema.message.ErrorCode.DHUR02; -import static com.relogiclabs.json.schema.message.ErrorCode.DHUR03; -import static com.relogiclabs.json.schema.message.ErrorCode.DHUR06; -import static com.relogiclabs.json.schema.message.ErrorCode.DINV02; -import static com.relogiclabs.json.schema.message.ErrorCode.DLEX01; -import static com.relogiclabs.json.schema.message.ErrorCode.DMIN01; -import static com.relogiclabs.json.schema.message.ErrorCode.DMIN03; -import static com.relogiclabs.json.schema.message.ErrorCode.DMON01; -import static com.relogiclabs.json.schema.message.ErrorCode.DMON02; -import static com.relogiclabs.json.schema.message.ErrorCode.DMON03; -import static com.relogiclabs.json.schema.message.ErrorCode.DMON05; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG01; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG02; -import static com.relogiclabs.json.schema.message.ErrorCode.DSEC01; -import static com.relogiclabs.json.schema.message.ErrorCode.DSEC03; -import static com.relogiclabs.json.schema.message.ErrorCode.DTAP01; -import static com.relogiclabs.json.schema.message.ErrorCode.DTXT01; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP04; -import static com.relogiclabs.json.schema.message.ErrorCode.DUTC01; -import static com.relogiclabs.json.schema.message.ErrorCode.DUTC04; -import static com.relogiclabs.json.schema.message.ErrorCode.DUTC05; -import static com.relogiclabs.json.schema.message.ErrorCode.DWKD02; -import static com.relogiclabs.json.schema.message.ErrorCode.DWKD03; -import static com.relogiclabs.json.schema.message.ErrorCode.DWTS01; -import static com.relogiclabs.json.schema.message.ErrorCode.DYAR01; -import static com.relogiclabs.json.schema.message.ErrorCode.DYAR02; -import static com.relogiclabs.json.schema.message.ErrorCode.DYAR03; -import static com.relogiclabs.json.schema.message.ErrorCode.ENDE01; -import static com.relogiclabs.json.schema.message.ErrorCode.ENDE02; -import static com.relogiclabs.json.schema.message.ErrorCode.STRT01; +import static com.relogiclabs.jschema.message.ErrorCode.AFTR01; +import static com.relogiclabs.jschema.message.ErrorCode.BFOR01; +import static com.relogiclabs.jschema.message.ErrorCode.DCNF01; +import static com.relogiclabs.jschema.message.ErrorCode.DDAY03; +import static com.relogiclabs.jschema.message.ErrorCode.DDAY04; +import static com.relogiclabs.jschema.message.ErrorCode.DERA01; +import static com.relogiclabs.jschema.message.ErrorCode.DFRC04; +import static com.relogiclabs.jschema.message.ErrorCode.DHUR01; +import static com.relogiclabs.jschema.message.ErrorCode.DHUR02; +import static com.relogiclabs.jschema.message.ErrorCode.DHUR03; +import static com.relogiclabs.jschema.message.ErrorCode.DHUR06; +import static com.relogiclabs.jschema.message.ErrorCode.DINV02; +import static com.relogiclabs.jschema.message.ErrorCode.DLEX01; +import static com.relogiclabs.jschema.message.ErrorCode.DMIN01; +import static com.relogiclabs.jschema.message.ErrorCode.DMIN03; +import static com.relogiclabs.jschema.message.ErrorCode.DMON01; +import static com.relogiclabs.jschema.message.ErrorCode.DMON02; +import static com.relogiclabs.jschema.message.ErrorCode.DMON03; +import static com.relogiclabs.jschema.message.ErrorCode.DMON05; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG01; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG02; +import static com.relogiclabs.jschema.message.ErrorCode.DSEC01; +import static com.relogiclabs.jschema.message.ErrorCode.DSEC03; +import static com.relogiclabs.jschema.message.ErrorCode.DTAP01; +import static com.relogiclabs.jschema.message.ErrorCode.DTXT01; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP04; +import static com.relogiclabs.jschema.message.ErrorCode.DUTC01; +import static com.relogiclabs.jschema.message.ErrorCode.DUTC04; +import static com.relogiclabs.jschema.message.ErrorCode.DUTC05; +import static com.relogiclabs.jschema.message.ErrorCode.DWKD02; +import static com.relogiclabs.jschema.message.ErrorCode.DWKD03; +import static com.relogiclabs.jschema.message.ErrorCode.DWTS01; +import static com.relogiclabs.jschema.message.ErrorCode.DYAR01; +import static com.relogiclabs.jschema.message.ErrorCode.DYAR02; +import static com.relogiclabs.jschema.message.ErrorCode.DYAR03; +import static com.relogiclabs.jschema.message.ErrorCode.ENDE01; +import static com.relogiclabs.jschema.message.ErrorCode.ENDE02; +import static com.relogiclabs.jschema.message.ErrorCode.STRT01; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/relogiclabs/json/schema/negative/FunctionTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/FunctionTests.java similarity index 60% rename from src/test/java/com/relogiclabs/json/schema/negative/FunctionTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/FunctionTests.java index 3fc116c..41e0370 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/FunctionTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/FunctionTests.java @@ -1,24 +1,24 @@ -package com.relogiclabs.json.schema.negative; - -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.ClassInstantiationException; -import com.relogiclabs.json.schema.exception.DuplicateIncludeException; -import com.relogiclabs.json.schema.exception.FunctionNotFoundException; -import com.relogiclabs.json.schema.exception.InvalidFunctionException; -import com.relogiclabs.json.schema.exception.InvalidIncludeException; -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.exception.NotFoundClassException; +package com.relogiclabs.jschema.test.negative; + +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.ClassInstantiationException; +import com.relogiclabs.jschema.exception.DuplicateImportException; +import com.relogiclabs.jschema.exception.FunctionNotFoundException; +import com.relogiclabs.jschema.exception.InvalidFunctionException; +import com.relogiclabs.jschema.exception.InvalidImportException; +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.exception.NotFoundClassException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.message.ErrorCode.CLAS01; -import static com.relogiclabs.json.schema.message.ErrorCode.CLAS02; -import static com.relogiclabs.json.schema.message.ErrorCode.CLAS03; -import static com.relogiclabs.json.schema.message.ErrorCode.CLAS04; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC01; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC02; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC03; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC05; +import static com.relogiclabs.jschema.message.ErrorCode.CLAS01; +import static com.relogiclabs.jschema.message.ErrorCode.CLAS02; +import static com.relogiclabs.jschema.message.ErrorCode.CLAS03; +import static com.relogiclabs.jschema.message.ErrorCode.CLAS04; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC01; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC02; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC03; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC05; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -43,26 +43,26 @@ public void When_FunctionAppliedOnWrongType_ExceptionThrown() { } @Test - public void When_ExternalIncludeNotInheritBaseClass_ExceptionThrown() { + public void When_ExternalImportNotInheritBaseClass_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions1 + %import: com.relogiclabs.jschema.test.external.ExternalFunctions1 %schema: @odd #integer """; var json = "10"; //JsonSchema.isValid(schema, json); - var exception = assertThrows(InvalidIncludeException.class, + var exception = assertThrows(InvalidImportException.class, () -> JsonAssert.isValid(schema, json)); assertEquals(CLAS03, exception.getCode()); exception.printStackTrace(); } @Test - public void When_ExternalIncludeNotExisting_ExceptionThrown() { + public void When_ExternalImportNotExisting_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.negative.function.NotExisting + %import: com.relogiclabs.json.schema.negative.function.NotExisting %schema: @odd #integer """; var json = "10"; @@ -75,27 +75,27 @@ public void When_ExternalIncludeNotExisting_ExceptionThrown() { } @Test - public void When_ExternalIncludeDuplicationOccurred_ExceptionThrown() { + public void When_ExternalImportDuplicationOccurred_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: @odd #integer """; var json = "10"; //JsonSchema.isValid(schema, json); - var exception = assertThrows(DuplicateIncludeException.class, + var exception = assertThrows(DuplicateImportException.class, () -> JsonAssert.isValid(schema, json)); assertEquals(CLAS01, exception.getCode()); exception.printStackTrace(); } @Test - public void When_ExternalIncludeInstantiationNotCompleted_ExceptionThrown() { + public void When_ExternalImportInstantiationNotCompleted_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions5 + %import: com.relogiclabs.jschema.test.external.ExternalFunctions5 %schema: @odd #integer """; var json = "10"; @@ -111,7 +111,7 @@ public void When_ExternalIncludeInstantiationNotCompleted_ExceptionThrown() { public void When_ExternalFunctionWrongReturnType_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions2 + %import: com.relogiclabs.jschema.test.external.ExternalFunctions2 %schema: @odd #integer """; var json = "10"; @@ -127,7 +127,7 @@ public void When_ExternalFunctionWrongReturnType_ExceptionThrown() { public void When_ExternalFunctionWrongParameterNumber_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions3 + %import: com.relogiclabs.jschema.test.external.ExternalFunctions3 %schema: @odd #integer """; var json = "10"; @@ -143,7 +143,7 @@ public void When_ExternalFunctionWrongParameterNumber_ExceptionThrown() { public void When_ExternalFunctionNotExists_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions4 + %import: com.relogiclabs.jschema.test.external.ExternalFunctions4 %schema: @odd #integer """; var json = "10"; @@ -159,7 +159,7 @@ public void When_ExternalFunctionNotExists_ExceptionThrown() { public void When_FunctionThrowArbitraryException_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions4 + %import: com.relogiclabs.jschema.test.external.ExternalFunctions4 %schema: @canTest #integer """; var json = "10"; @@ -168,4 +168,19 @@ public void When_FunctionThrowArbitraryException_ExceptionThrown() { () -> JsonAssert.isValid(schema, json)); exception.printStackTrace(); } + + @Test + public void When_IncompatibleTargetForExternalFunction_ExceptionThrown() { + var schema = + """ + %import: com.relogiclabs.jschema.test.external.ExternalFunctions + %schema: @even #string + """; + var json = "\"test\""; + JsonSchema.isValid(schema, json); + var exception = assertThrows(JsonSchemaException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(FUNC03, exception.getCode()); + exception.printStackTrace(); + } } \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/json/schema/negative/IntegerTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/IntegerTests.java similarity index 89% rename from src/test/java/com/relogiclabs/json/schema/negative/IntegerTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/IntegerTests.java index 68f1ade..147da84 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/IntegerTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/IntegerTests.java @@ -1,17 +1,17 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.JsonSchemaException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.JsonSchemaException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP04; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP06; -import static com.relogiclabs.json.schema.message.ErrorCode.FUNC06; -import static com.relogiclabs.json.schema.message.ErrorCode.INTE01; -import static com.relogiclabs.json.schema.message.ErrorCode.RANG01; -import static com.relogiclabs.json.schema.message.ErrorCode.RANG03; -import static com.relogiclabs.json.schema.message.ErrorCode.RANG04; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP04; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP06; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC06; +import static com.relogiclabs.jschema.message.ErrorCode.INTE01; +import static com.relogiclabs.jschema.message.ErrorCode.RANG01; +import static com.relogiclabs.jschema.message.ErrorCode.RANG03; +import static com.relogiclabs.jschema.message.ErrorCode.RANG04; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/relogiclabs/json/schema/negative/NumberTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/NumberTests.java similarity index 90% rename from src/test/java/com/relogiclabs/json/schema/negative/NumberTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/NumberTests.java index 911c74e..706b4d5 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/NumberTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/NumberTests.java @@ -1,18 +1,18 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.JsonSchemaException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.JsonSchemaException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.message.ErrorCode.MAXI01; -import static com.relogiclabs.json.schema.message.ErrorCode.MAXI03; -import static com.relogiclabs.json.schema.message.ErrorCode.MINI01; -import static com.relogiclabs.json.schema.message.ErrorCode.MINI03; -import static com.relogiclabs.json.schema.message.ErrorCode.NEGI01; -import static com.relogiclabs.json.schema.message.ErrorCode.NEGI02; -import static com.relogiclabs.json.schema.message.ErrorCode.POSI01; -import static com.relogiclabs.json.schema.message.ErrorCode.POSI02; +import static com.relogiclabs.jschema.message.ErrorCode.MAXI01; +import static com.relogiclabs.jschema.message.ErrorCode.MAXI03; +import static com.relogiclabs.jschema.message.ErrorCode.MINI01; +import static com.relogiclabs.jschema.message.ErrorCode.MINI03; +import static com.relogiclabs.jschema.message.ErrorCode.NEGI01; +import static com.relogiclabs.jschema.message.ErrorCode.NEGI02; +import static com.relogiclabs.jschema.message.ErrorCode.POSI01; +import static com.relogiclabs.jschema.message.ErrorCode.POSI02; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/relogiclabs/json/schema/negative/ObjectTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/ObjectTests.java similarity index 90% rename from src/test/java/com/relogiclabs/json/schema/negative/ObjectTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/ObjectTests.java index 179c903..759d484 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/ObjectTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/ObjectTests.java @@ -1,23 +1,23 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.DuplicatePropertyKeyException; -import com.relogiclabs.json.schema.exception.JsonSchemaException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.DuplicatePropertyKeyException; +import com.relogiclabs.jschema.exception.JsonSchemaException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP04; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP06; -import static com.relogiclabs.json.schema.message.ErrorCode.ENUM02; -import static com.relogiclabs.json.schema.message.ErrorCode.KEYS01; -import static com.relogiclabs.json.schema.message.ErrorCode.NEMT03; -import static com.relogiclabs.json.schema.message.ErrorCode.OLEN01; -import static com.relogiclabs.json.schema.message.ErrorCode.OLEN02; -import static com.relogiclabs.json.schema.message.ErrorCode.OLEN04; -import static com.relogiclabs.json.schema.message.ErrorCode.OLEN05; -import static com.relogiclabs.json.schema.message.ErrorCode.PROP03; -import static com.relogiclabs.json.schema.message.ErrorCode.PROP04; -import static com.relogiclabs.json.schema.message.ErrorCode.VALU01; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP04; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP06; +import static com.relogiclabs.jschema.message.ErrorCode.ENUM02; +import static com.relogiclabs.jschema.message.ErrorCode.KEYS01; +import static com.relogiclabs.jschema.message.ErrorCode.NEMT03; +import static com.relogiclabs.jschema.message.ErrorCode.OLEN01; +import static com.relogiclabs.jschema.message.ErrorCode.OLEN02; +import static com.relogiclabs.jschema.message.ErrorCode.OLEN04; +import static com.relogiclabs.jschema.message.ErrorCode.OLEN05; +import static com.relogiclabs.jschema.message.ErrorCode.PROP03; +import static com.relogiclabs.jschema.message.ErrorCode.PROP04; +import static com.relogiclabs.jschema.message.ErrorCode.VALU01; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/relogiclabs/json/schema/negative/OtherTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/OtherTests.java similarity index 85% rename from src/test/java/com/relogiclabs/json/schema/negative/OtherTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/OtherTests.java index ac0a210..90a62ab 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/OtherTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/OtherTests.java @@ -1,19 +1,19 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.InvalidDataTypeException; -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.exception.MisplacedOptionalException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.InvalidDataTypeException; +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.exception.MisplacedOptionalException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.message.ErrorCode.ARRY01; -import static com.relogiclabs.json.schema.message.ErrorCode.ARRY02; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP01; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP04; -import static com.relogiclabs.json.schema.message.ErrorCode.DUBL01; -import static com.relogiclabs.json.schema.message.ErrorCode.FLOT01; -import static com.relogiclabs.json.schema.message.ErrorCode.PROP05; +import static com.relogiclabs.jschema.message.ErrorCode.ARRY01; +import static com.relogiclabs.jschema.message.ErrorCode.ARRY02; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP01; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP04; +import static com.relogiclabs.jschema.message.ErrorCode.DUBL01; +import static com.relogiclabs.jschema.message.ErrorCode.FLOT01; +import static com.relogiclabs.jschema.message.ErrorCode.PROP05; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/relogiclabs/json/schema/negative/PragmaTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/PragmaTests.java similarity index 89% rename from src/test/java/com/relogiclabs/json/schema/negative/PragmaTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/PragmaTests.java index af976ee..9dfa67e 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/PragmaTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/PragmaTests.java @@ -1,35 +1,35 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.DateTimeLexerException; -import com.relogiclabs.json.schema.exception.DuplicatePragmaException; -import com.relogiclabs.json.schema.exception.InvalidPragmaValueException; -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.exception.PragmaNotFoundException; -import com.relogiclabs.json.schema.exception.SchemaParserException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.DateTimeLexerException; +import com.relogiclabs.jschema.exception.DuplicatePragmaException; +import com.relogiclabs.jschema.exception.InvalidPragmaValueException; +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.exception.PragmaNotFoundException; +import com.relogiclabs.jschema.exception.SchemaParserException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.message.ErrorCode.AFTR01; -import static com.relogiclabs.json.schema.message.ErrorCode.AFTR02; -import static com.relogiclabs.json.schema.message.ErrorCode.BFOR01; -import static com.relogiclabs.json.schema.message.ErrorCode.BFOR02; -import static com.relogiclabs.json.schema.message.ErrorCode.DLEX01; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG01; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG02; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG05; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG06; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG07; -import static com.relogiclabs.json.schema.message.ErrorCode.DRNG08; -import static com.relogiclabs.json.schema.message.ErrorCode.DSYM01; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP04; -import static com.relogiclabs.json.schema.message.ErrorCode.FLOT01; -import static com.relogiclabs.json.schema.message.ErrorCode.PRAG01; -import static com.relogiclabs.json.schema.message.ErrorCode.PRAG02; -import static com.relogiclabs.json.schema.message.ErrorCode.PRAG03; -import static com.relogiclabs.json.schema.message.ErrorCode.PROP06; -import static com.relogiclabs.json.schema.message.ErrorCode.PROP07; -import static com.relogiclabs.json.schema.message.ErrorCode.SPRS01; +import static com.relogiclabs.jschema.message.ErrorCode.AFTR01; +import static com.relogiclabs.jschema.message.ErrorCode.AFTR02; +import static com.relogiclabs.jschema.message.ErrorCode.BFOR01; +import static com.relogiclabs.jschema.message.ErrorCode.BFOR02; +import static com.relogiclabs.jschema.message.ErrorCode.DLEX01; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG01; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG02; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG05; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG06; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG07; +import static com.relogiclabs.jschema.message.ErrorCode.DRNG08; +import static com.relogiclabs.jschema.message.ErrorCode.DSYM01; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP04; +import static com.relogiclabs.jschema.message.ErrorCode.FLOT01; +import static com.relogiclabs.jschema.message.ErrorCode.PRAG01; +import static com.relogiclabs.jschema.message.ErrorCode.PRAG02; +import static com.relogiclabs.jschema.message.ErrorCode.PRAG03; +import static com.relogiclabs.jschema.message.ErrorCode.PROP06; +import static com.relogiclabs.jschema.message.ErrorCode.PROP07; +import static com.relogiclabs.jschema.message.ErrorCode.SPRS01; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/relogiclabs/json/schema/negative/ReceiverTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/ReceiverTests.java similarity index 79% rename from src/test/java/com/relogiclabs/json/schema/negative/ReceiverTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/ReceiverTests.java index e75d228..676e637 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/ReceiverTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/ReceiverTests.java @@ -1,18 +1,18 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.exception.NoValueReceivedException; -import com.relogiclabs.json.schema.exception.ReceiverNotFoundException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.exception.NoValueReceivedException; +import com.relogiclabs.jschema.exception.ReceiverNotFoundException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.external.ExternalFunctions.CONDFUNC01; -import static com.relogiclabs.json.schema.external.ExternalFunctions.CONDFUNC02; -import static com.relogiclabs.json.schema.external.ExternalFunctions.MINMAX01; -import static com.relogiclabs.json.schema.external.ExternalFunctions.SUMEQUAL01; -import static com.relogiclabs.json.schema.message.ErrorCode.RECV02; -import static com.relogiclabs.json.schema.message.ErrorCode.RECV03; +import static com.relogiclabs.jschema.message.ErrorCode.RECV01; +import static com.relogiclabs.jschema.message.ErrorCode.RECV03; +import static com.relogiclabs.jschema.test.external.ExternalFunctions.CONDFUNC01; +import static com.relogiclabs.jschema.test.external.ExternalFunctions.CONDFUNC02; +import static com.relogiclabs.jschema.test.external.ExternalFunctions.MINMAX01; +import static com.relogiclabs.jschema.test.external.ExternalFunctions.SUMEQUAL01; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -21,7 +21,7 @@ public class ReceiverTests { public void When_WrongReceiverNameInObject_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: { "key1": #integer &someName, @@ -38,7 +38,7 @@ public void When_WrongReceiverNameInObject_ExceptionThrown() { //JsonSchema.isValid(schema, json); var exception = assertThrows(ReceiverNotFoundException.class, () -> JsonAssert.isValid(schema, json)); - assertEquals(RECV02, exception.getCode()); + assertEquals(RECV01, exception.getCode()); exception.printStackTrace(); } @@ -46,7 +46,7 @@ public void When_WrongReceiverNameInObject_ExceptionThrown() { public void When_NoValueReceiveInObject_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: { @@ -72,7 +72,7 @@ public void When_NoValueReceiveInObject_ExceptionThrown() { public void When_ConditionFailedInObject_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: { @@ -98,7 +98,7 @@ public void When_ConditionFailedInObject_ExceptionThrown() { public void When_ConditionAllFailedInObject_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %define $numbers: @range(1, 10) #integer &relatedValues %schema: @@ -125,7 +125,7 @@ public void When_ConditionAllFailedInObject_ExceptionThrown() { public void When_ReceiveWrongValuesInObject_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: { "key1": #integer &relatedData, @@ -158,7 +158,7 @@ public void When_ReceiveWrongValuesInObject_ExceptionThrown() { public void When_MultiReceiverFunctionWrongValuesInObject_ExceptionThrown() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: { diff --git a/src/test/java/com/relogiclabs/json/schema/negative/StringTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/StringTests.java similarity index 89% rename from src/test/java/com/relogiclabs/json/schema/negative/StringTests.java rename to src/test/java/com/relogiclabs/jschema/test/negative/StringTests.java index 7431f68..9b3104e 100644 --- a/src/test/java/com/relogiclabs/json/schema/negative/StringTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/negative/StringTests.java @@ -1,27 +1,27 @@ -package com.relogiclabs.json.schema.negative; +package com.relogiclabs.jschema.test.negative; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; -import com.relogiclabs.json.schema.exception.JsonLexerException; -import com.relogiclabs.json.schema.exception.JsonSchemaException; -import com.relogiclabs.json.schema.exception.SchemaLexerException; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.JsonLexerException; +import com.relogiclabs.jschema.exception.JsonSchemaException; +import com.relogiclabs.jschema.exception.SchemaLexerException; import org.junit.jupiter.api.Test; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP04; -import static com.relogiclabs.json.schema.message.ErrorCode.DTYP06; -import static com.relogiclabs.json.schema.message.ErrorCode.EMAL01; -import static com.relogiclabs.json.schema.message.ErrorCode.ENUM01; -import static com.relogiclabs.json.schema.message.ErrorCode.JLEX01; -import static com.relogiclabs.json.schema.message.ErrorCode.NEMT01; -import static com.relogiclabs.json.schema.message.ErrorCode.PHON01; -import static com.relogiclabs.json.schema.message.ErrorCode.REGX01; -import static com.relogiclabs.json.schema.message.ErrorCode.SLEN01; -import static com.relogiclabs.json.schema.message.ErrorCode.SLEN03; -import static com.relogiclabs.json.schema.message.ErrorCode.SLEN04; -import static com.relogiclabs.json.schema.message.ErrorCode.SLEN05; -import static com.relogiclabs.json.schema.message.ErrorCode.SLEX01; -import static com.relogiclabs.json.schema.message.ErrorCode.URLA01; -import static com.relogiclabs.json.schema.message.ErrorCode.URLA04; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP04; +import static com.relogiclabs.jschema.message.ErrorCode.DTYP06; +import static com.relogiclabs.jschema.message.ErrorCode.EMAL01; +import static com.relogiclabs.jschema.message.ErrorCode.ENUM01; +import static com.relogiclabs.jschema.message.ErrorCode.JLEX01; +import static com.relogiclabs.jschema.message.ErrorCode.NEMT01; +import static com.relogiclabs.jschema.message.ErrorCode.PHON01; +import static com.relogiclabs.jschema.message.ErrorCode.REGX01; +import static com.relogiclabs.jschema.message.ErrorCode.SLEN01; +import static com.relogiclabs.jschema.message.ErrorCode.SLEN03; +import static com.relogiclabs.jschema.message.ErrorCode.SLEN04; +import static com.relogiclabs.jschema.message.ErrorCode.SLEN05; +import static com.relogiclabs.jschema.message.ErrorCode.SLEX01; +import static com.relogiclabs.jschema.message.ErrorCode.URLA01; +import static com.relogiclabs.jschema.message.ErrorCode.URLA04; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/relogiclabs/json/schema/positive/AggregatedTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/AggregatedTests.java similarity index 63% rename from src/test/java/com/relogiclabs/json/schema/positive/AggregatedTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/AggregatedTests.java index 4cd2adf..a9e862a 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/AggregatedTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/AggregatedTests.java @@ -1,15 +1,15 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class AggregatedTests { @Test - public void When_SchemaAggregatedTest_ValidTrue() { + public void When_SchemaAggregatedTestWithBasicJson_ValidTrue() { var schema = """ %title: "Example Schema For Some Json HTTP Request or Response" - %version: 2023.09.11 - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %version: "February 11, 2023" + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %pragma IgnoreUndefinedProperties: true %define $component1: { @@ -137,7 +137,7 @@ public void When_JsonAggregatedFormatTest_ValidTrue() { public void When_SimpleJsonSchemaAggregatedTest_ValidTrue() { var schema = """ %title: "User Profile Response" - %version: 1.0.0 + %version: "1.0.0-basic" %schema: { "user": { @@ -195,8 +195,8 @@ public void When_SimpleJsonSchemaAggregatedTest_ValidTrue() { public void When_ExtendedJsonSchemaAggregatedTest_ValidTrue() { var schema = """ %title: "Extended User Profile Dashboard API Response" - %version: 2.0.0 - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %version: "2.0.0-extended" + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %pragma DateDataTypeFormat: "DD-MM-YYYY" %pragma TimeDataTypeFormat: "DD-MM-YYYY hh:mm:ss" @@ -299,7 +299,180 @@ public void When_ExtendedJsonSchemaAggregatedTest_ValidTrue() { { "id": 2, "title": "Working with JSON in Java", - "content": "Java provides built-in support for working with JSON...", + "content": "Java provides great support for working with JSON...", + "tags": [ + "CSharp", + "JSON", + "tutorial" + ] + }, + { + "id": 3, + "title": "Introduction to JSON Schema", + "content": "A JSON schema defines the structure and data types of JSON objects...", + "tags": [ + "Schema", + "JSON", + "tutorial" + ] + } + ], + "preferences": { + "theme": "dark", + "fontSize": 14, + "autoSave": true + } + }, + "products": [ + { + "id": "p1", + "name": "Smartphone", + "brand": "TechGiant", + "price": 1.99, + "inStock": true, + "specs": null + }, + { + "id": "p2", + "name": "Laptop", + "brand": "SuperTech", + "price": 1299.99, + "inStock": false, + "specs": { + "cpu": "Ryzen 11", + "ram": "11GB", + "storage": "11GB SSD" + } + } + ], + "weather": { + "temperature": 25.5, + "isCloudy": true, + "conditions": null + } + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ExtendedJsonSchemaWithScriptAggregatedTest_ValidTrue() { + var schema = """ + %title: "Extended User Profile Dashboard API Response" + %version: "2.0.0-extended" + + %pragma DateDataTypeFormat: "DD-MM-YYYY" + %pragma TimeDataTypeFormat: "DD-MM-YYYY hh:mm:ss" + %pragma IgnoreUndefinedProperties: true + + %define $post: { + "id": @range(1, 1000) #integer, + "title": @length(10, 100) #string, + "content": @length(30, 1000) #string, + "tags": $tags + } #object + + %define $product: { + "id": @length(2, 10) @regex("[a-z][a-z0-9]+") #string, + "name": @length(5, 30) #string, + "brand": @length(5, 30) #string, + "price": @range(0.1, 1000000), + "inStock": #boolean, + "specs": { + "cpu": @length(5, 30) #string, + "ram": @regex("[0-9]{1,2}GB") #string, + "storage": @regex("[0-9]{1,4}GB (SSD|HDD)") #string + } #object #null + } + + %define $tags: @length(1, 10) #string*($tag) #array + %define $tag: @length(3, 20) @regex("[A-Za-z_]+") #string + + %schema: + { + "user": { + "id": @range(1, 10000) #integer, + /*username does not allow special characters*/ + "username": @regex("[a-z_]{3,30}") #string, + "role": @enum("user", "admin") #string &role, + "isActive": #boolean, //user account current status + "registeredAt": @after("01-01-2010 00:00:00") #time, + "dataAccess": @checkAccess(&role) #integer, + "profile": { + "firstName": @regex("[A-Za-z]{3,50}") #string, + "lastName": @regex("[A-Za-z]{3,50}") #string, + "dateOfBirth": @before("01-01-2006") #date, + "age": @range(18, 128) #integer, + "email": @email #string, + "pictureURL": @url #string, + "address": { + "street": @length(10, 200) #string, + "city": @length(3, 50) #string, + "country": @regex("[A-Za-z ]{3,50}") #string + } #object #null, + "hobbies": !? + }, + "posts": @length(0, 1000) #object*($post) #array, + "preferences": { + "theme": @enum("light", "dark") #string, + "fontSize": @range(9, 24) #integer, + "autoSave": #boolean + } + }, + "products": #object*($product) #array, + "weather": { + "temperature": @range(-50, 60) #integer #float, + "isCloudy": #boolean + } + } + + %script: { + future checkAccess(role) { + if(role[0] == "user" && target > 5) return fail( + "ERRACCESS", "Data access incompatible with 'user' role", + expected("an access at most 5 for 'user' role"), + actual("found access " + target + " which is greater than 5")); + return true; // Skipping this line also works as expected + } + } + """; + var json = """ + { + "user": { + "id": 1234, + "username": "johndoe", + "role": "admin", + "isActive": true, + "registeredAt": "06-09-2023 15:10:30", + "dataAccess": 10, + "profile": { + "firstName": "John", + "lastName": "Doe", + "dateOfBirth": "17-06-1993", + "age": 30, + "email": "john.doe@example.com", + "pictureURL": "https://example.com/picture.jpg", + "address": { + "street": "123 Some St", + "city": "Some town", + "country": "Some Country" + } + }, + "posts": [ + { + "id": 1, + "title": "Introduction to JSON", + "content": "JSON (JavaScript Object Notation) is a lightweight data interchange format...", + "tags": [ + "JSON", + "tutorial", + "data" + ] + }, + { + "id": 2, + "title": "Working with JSON in Java", + "content": "Java provides great support for working with JSON...", "tags": [ "CSharp", "JSON", diff --git a/src/test/java/com/relogiclabs/json/schema/positive/ArrayTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/ArrayTests.java similarity index 97% rename from src/test/java/com/relogiclabs/json/schema/positive/ArrayTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/ArrayTests.java index 22ecc78..eca87b1 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/ArrayTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/ArrayTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class ArrayTests @@ -92,7 +92,7 @@ public void When_NestedElementsWithArrayInArray_ValidTrue() { @Test public void When_EnumInArray_ValidTrue() { - var schema = + var schema = """ [ @enum(5, 10, 15), diff --git a/src/test/java/com/relogiclabs/json/schema/positive/BooleanTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/BooleanTests.java similarity index 94% rename from src/test/java/com/relogiclabs/json/schema/positive/BooleanTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/BooleanTests.java index 09d61a2..2e2aa76 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/BooleanTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/BooleanTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class BooleanTests { diff --git a/src/test/java/com/relogiclabs/json/schema/positive/ComponentTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/ComponentTests.java similarity index 95% rename from src/test/java/com/relogiclabs/json/schema/positive/ComponentTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/ComponentTests.java index a389b42..6fcee53 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/ComponentTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/ComponentTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class ComponentTests { @@ -23,19 +23,19 @@ public void When_ComponentExampleInArray_ValidTrue() { "id": 1, "title": "Getting Started", "preview": "This guide will show you through the essential steps to quickly...", - "tags": ["JSON", "Json Schema", "Quick Start"] + "tags": ["JSON", "JSchema", "Quick Start"] }, { "id": 2, "title": "Validation Syntax", "preview": "A JSON document is a structured data format used for the exchange...", - "tags": ["JSON", "Json Schema", "Validation Syntax"] + "tags": ["JSON", "JSchema", "Validation Syntax"] }, { "id": 3, "title": "Constraint Functions", "preview": "This document serves as a brief overview, providing key insights into...", - "tags": ["JSON", "Json Schema", "Constraint Functions"] + "tags": ["JSON", "JSchema", "Constraint Functions"] } ] """; diff --git a/src/test/java/com/relogiclabs/json/schema/positive/DataTypeTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/DataTypeTests.java similarity index 96% rename from src/test/java/com/relogiclabs/json/schema/positive/DataTypeTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/DataTypeTests.java index dfcfe9e..35a77a6 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/DataTypeTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/DataTypeTests.java @@ -1,7 +1,7 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; -import com.relogiclabs.json.schema.JsonSchema; +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; import org.junit.jupiter.api.Test; public class DataTypeTests { diff --git a/src/test/java/com/relogiclabs/json/schema/positive/DateTimeTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/DateTimeTests.java similarity index 99% rename from src/test/java/com/relogiclabs/json/schema/positive/DateTimeTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/DateTimeTests.java index b8adbbe..73c85af 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/DateTimeTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/DateTimeTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class DateTimeTests { diff --git a/src/test/java/com/relogiclabs/json/schema/positive/DirectiveTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/DirectiveTests.java similarity index 88% rename from src/test/java/com/relogiclabs/json/schema/positive/DirectiveTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/DirectiveTests.java index 3fae099..3c4dccf 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/DirectiveTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/DirectiveTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class DirectiveTests { @@ -27,7 +27,7 @@ public void When_SchemaTitleGiven_ValidTrue() { public void When_SchemaVersionGiven_ValidTrue() { var schema = """ - %version: 1.0.0 + %version: "1.0.0-alpha" %schema: { "key1": #integer @@ -47,7 +47,7 @@ public void When_SchemaTitleAndVersionGiven_ValidTrue() { var schema = """ %title: "This is a title for this schema" - %version: 1.0.0 + %version: "1.0.0-beta" %schema: { "key1": #integer diff --git a/src/test/java/com/relogiclabs/json/schema/positive/FunctionTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/FunctionTests.java similarity index 79% rename from src/test/java/com/relogiclabs/json/schema/positive/FunctionTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/FunctionTests.java index 9f7d576..ce9fcdc 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/FunctionTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/FunctionTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class FunctionTests { @@ -8,7 +8,7 @@ public class FunctionTests { public void When_ExternalFunctionExecute_ValidTrue() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: @even #integer """; var json = "10"; @@ -19,7 +19,7 @@ public void When_ExternalFunctionExecute_ValidTrue() { public void When_ExternalFunctionExecute2_ValidTrue() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: @canTest("test", true, 1, 2, 3) #integer """; var json = "10"; @@ -30,7 +30,7 @@ public void When_ExternalFunctionExecute2_ValidTrue() { public void When_ExternalFunctionWithoutDataType_ValidTrue() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: @even """; var json = "10"; @@ -41,7 +41,7 @@ public void When_ExternalFunctionWithoutDataType_ValidTrue() { public void When_ExternalFunctionInObject_ValidTrue() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: { "key1": @even #integer, @@ -62,7 +62,7 @@ public void When_ExternalFunctionInObject_ValidTrue() { public void When_ExternalFunctionInArray_ValidTrue() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: [ @even #integer, @even #integer diff --git a/src/test/java/com/relogiclabs/json/schema/positive/IntegerTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/IntegerTests.java similarity index 96% rename from src/test/java/com/relogiclabs/json/schema/positive/IntegerTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/IntegerTests.java index e122611..6ad6144 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/IntegerTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/IntegerTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class IntegerTests { diff --git a/src/test/java/com/relogiclabs/json/schema/positive/NumberTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/NumberTests.java similarity index 97% rename from src/test/java/com/relogiclabs/json/schema/positive/NumberTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/NumberTests.java index af4b986..7b52519 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/NumberTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/NumberTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class NumberTests { diff --git a/src/test/java/com/relogiclabs/json/schema/positive/ObjectTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/ObjectTests.java similarity index 97% rename from src/test/java/com/relogiclabs/json/schema/positive/ObjectTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/ObjectTests.java index dab7495..66f0cce 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/ObjectTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/ObjectTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class ObjectTests { @@ -150,7 +150,7 @@ public void When_NestedKeysAndValuesWithObjectInArray_ValidTrue() { @Test public void When_EnumWithObject_ValidTrue() { - var schema = + var schema = """ { "key1": @enum(5, 10, 15), @@ -158,7 +158,7 @@ public void When_EnumWithObject_ValidTrue() { "key3": @enum("abc", "pqr", "xyz") } #object """; - var json = + var json = """ { "key1": 10, diff --git a/src/test/java/com/relogiclabs/json/schema/positive/OptionalTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/OptionalTests.java similarity index 94% rename from src/test/java/com/relogiclabs/json/schema/positive/OptionalTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/OptionalTests.java index e86a783..0bb37ba 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/OptionalTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/OptionalTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class OptionalTests { diff --git a/src/test/java/com/relogiclabs/json/schema/positive/OtherTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/OtherTests.java similarity index 89% rename from src/test/java/com/relogiclabs/json/schema/positive/OtherTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/OtherTests.java index 42bae17..998c681 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/OtherTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/OtherTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class OtherTests { @@ -36,8 +36,8 @@ public void When_DataTypeUndefined_ValidTrue() { public void When_NonStaticValidMethod_ValidTrue() { var schema = """ - %version: 2023.09.11 - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %version: "October 09, 2010" + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %pragma IgnoreUndefinedProperties: true %define $element: @range(1, 100) #integer %schema: { diff --git a/src/test/java/com/relogiclabs/json/schema/positive/PragmaTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/PragmaTests.java similarity index 98% rename from src/test/java/com/relogiclabs/json/schema/positive/PragmaTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/PragmaTests.java index 03f0c8b..7eff50a 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/PragmaTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/PragmaTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class PragmaTests { diff --git a/src/test/java/com/relogiclabs/json/schema/positive/ReceiverTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/ReceiverTests.java similarity index 88% rename from src/test/java/com/relogiclabs/json/schema/positive/ReceiverTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/ReceiverTests.java index ee57a02..8519c90 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/ReceiverTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/ReceiverTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class ReceiverTests { @@ -8,7 +8,7 @@ public class ReceiverTests { public void When_ReceiveSingleValueInObject_ValidTrue() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: { "key1": #integer &dependent, @@ -38,7 +38,7 @@ public void When_ReceiveSingleValueInObject_ValidTrue() { public void When_MultiReceiversValueInObject_ValidTrue() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: { "key1": #integer &receiver1 &receiver2 &receiver3, @@ -59,7 +59,7 @@ public void When_MultiReceiversValueInObject_ValidTrue() { public void When_ReceiveArrayValuesInObject_ValidTrue() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %define $numbers: @range(1, 10) #integer &relatedValues %schema: @@ -82,7 +82,7 @@ public void When_ReceiveArrayValuesInObject_ValidTrue() { public void When_ReceiveMultipleValuesInObject_ValidTrue() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: { @@ -112,7 +112,7 @@ public void When_ReceiveMultipleValuesInObject_ValidTrue() { public void When_MultiReceiversFunctionInObject_ValidTrue() { var schema = """ - %include: com.relogiclabs.json.schema.external.ExternalFunctions + %import: com.relogiclabs.jschema.test.external.ExternalFunctions %schema: { diff --git a/src/test/java/com/relogiclabs/json/schema/positive/StringTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/StringTests.java similarity index 98% rename from src/test/java/com/relogiclabs/json/schema/positive/StringTests.java rename to src/test/java/com/relogiclabs/jschema/test/positive/StringTests.java index 2e03006..9a1fa31 100644 --- a/src/test/java/com/relogiclabs/json/schema/positive/StringTests.java +++ b/src/test/java/com/relogiclabs/jschema/test/positive/StringTests.java @@ -1,6 +1,6 @@ -package com.relogiclabs.json.schema.positive; +package com.relogiclabs.jschema.test.positive; -import com.relogiclabs.json.schema.JsonAssert; +import com.relogiclabs.jschema.JsonAssert; import org.junit.jupiter.api.Test; public class StringTests { diff --git a/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions4.java b/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions4.java deleted file mode 100644 index 9aa9c1e..0000000 --- a/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions4.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.relogiclabs.json.schema.external; - -import com.relogiclabs.json.schema.function.FunctionBase; -import com.relogiclabs.json.schema.tree.RuntimeContext; -import com.relogiclabs.json.schema.type.JNumber; - -// Functions for negative (error) test cases -public class ExternalFunctions4 extends FunctionBase { - public ExternalFunctions4(RuntimeContext runtime) { - super(runtime); - } - - public boolean canTest(JNumber target) { - // If you just want to throw any exception without details - return failWith(new RuntimeException("something went wrong")); - } -} \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions5.java b/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions5.java deleted file mode 100644 index 109f203..0000000 --- a/src/test/java/com/relogiclabs/json/schema/external/ExternalFunctions5.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.relogiclabs.json.schema.external; - -import com.relogiclabs.json.schema.function.FunctionBase; - -// Functions for negative (error) test cases -public class ExternalFunctions5 extends FunctionBase { - public ExternalFunctions5() { - super(null); - } -} \ No newline at end of file From e40b325250abf6683e456a832cc93eff4a43fce1 Mon Sep 17 00:00:00 2001 From: Zahid Hossain <60911932+zhossain-info@users.noreply.github.com> Date: Fri, 23 Feb 2024 21:18:22 +0600 Subject: [PATCH 12/12] Add new test cases for script --- .../test/negative/ScriptBasicTests.java | 342 +++++++++++++++ .../test/negative/ScriptFunctionTests.java | 386 ++++++++++++++++ .../test/negative/ScriptGeneralTests.java | 239 ++++++++++ .../test/positive/ScriptBasicTests.java | 389 ++++++++++++++++ .../test/positive/ScriptFunctionTests.java | 257 +++++++++++ .../test/positive/ScriptGeneralTests.java | 256 +++++++++++ .../test/positive/ScriptLiteralTests.java | 271 ++++++++++++ .../test/positive/ScriptSearchTests.java | 212 +++++++++ .../test/positive/ScriptSortTests.java | 414 ++++++++++++++++++ 9 files changed, 2766 insertions(+) create mode 100644 src/test/java/com/relogiclabs/jschema/test/negative/ScriptBasicTests.java create mode 100644 src/test/java/com/relogiclabs/jschema/test/negative/ScriptFunctionTests.java create mode 100644 src/test/java/com/relogiclabs/jschema/test/negative/ScriptGeneralTests.java create mode 100644 src/test/java/com/relogiclabs/jschema/test/positive/ScriptBasicTests.java create mode 100644 src/test/java/com/relogiclabs/jschema/test/positive/ScriptFunctionTests.java create mode 100644 src/test/java/com/relogiclabs/jschema/test/positive/ScriptGeneralTests.java create mode 100644 src/test/java/com/relogiclabs/jschema/test/positive/ScriptLiteralTests.java create mode 100644 src/test/java/com/relogiclabs/jschema/test/positive/ScriptSearchTests.java create mode 100644 src/test/java/com/relogiclabs/jschema/test/positive/ScriptSortTests.java diff --git a/src/test/java/com/relogiclabs/jschema/test/negative/ScriptBasicTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/ScriptBasicTests.java new file mode 100644 index 0000000..95cfb65 --- /dev/null +++ b/src/test/java/com/relogiclabs/jschema/test/negative/ScriptBasicTests.java @@ -0,0 +1,342 @@ +package com.relogiclabs.jschema.test.negative; + +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.ScriptRuntimeException; +import com.relogiclabs.jschema.exception.SystemOperationException; +import org.junit.jupiter.api.Test; + +import static com.relogiclabs.jschema.message.ErrorCode.DIVD02; +import static com.relogiclabs.jschema.message.ErrorCode.ITER01; +import static com.relogiclabs.jschema.message.ErrorCode.VARD01; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class ScriptBasicTests { + @Test + public void When_DuplicateVariableDefinition_ExceptionThrown() { + var schema = + """ + %schema: + { + "variableTest": @variableTest #integer + } + %script: { + constraint variableTest() { + var test = 10; + if(true) { + // Variable shadowing in inner scope + var test = 30; + if(test != 30) return fail("Invalid: " + test); + } + if(test != 10) return fail("Invalid: " + test); + // Variable 'test' already defined in this scope + var test = 20; + } + } + """; + var json = + """ + { + "variableTest": 2 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(VARD01, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_ForeachWithNonIterableValue_ExceptionThrown() { + var schema = + """ + %schema: + { + "iteratorTest": @iteratorTest #integer + } + %script: { + constraint iteratorTest() { + foreach(var i in target) print(i); + } + } + """; + var json = + """ + { + "iteratorTest": 2 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(ITER01, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_WrongIndexAndRangeOutOfBounds_ExceptionThrown() { + var schema = + """ + %schema: + { + "indexTest1": @indexArrayTest #array, + "indexTest2": @indexStringTest #string + } + %script: { + constraint indexArrayTest() { + var result1 = tryof(target[10]); + if(find(result1.error, "[INDX04]") < 0) + return fail("Invalid: " + result1); + var result2 = tryof(target[-1]); + if(find(result2.error, "[INDX05]") < 0) + return fail("Invalid: " + result2); + var result3 = tryof(target[10..]); + if(find(result3.error, "[RNGS07]") < 0) + return fail("Invalid: " + result3); + var result4 = tryof(target[..10]); + if(find(result4.error, "[RNGS08]") < 0) + return fail("Invalid: " + result4); + var array = [10, 20]; + // only assign at the end of array to add + // use fill function for array of specific size + var result5 = tryof(array[10] = 10); + if(find(result5.error, "[INDX04]") < 0) + return fail("Invalid: " + result5); + } + + constraint indexStringTest() { + var result1 = tryof(target[100]); + if(find(result1.error, "[INDX02]") < 0) + return fail("Invalid: " + result1); + var result2 = tryof(target[-1]); + if(find(result2.error, "[INDX03]") < 0) + return fail("Invalid: " + result2); + var result3 = tryof(target[100..]); + if(find(result3.error, "[RNGS04]") < 0) + return fail("Invalid: " + result3); + var result4 = tryof(target[..100]); + if(find(result4.error, "[RNGS05]") < 0) + return fail("Invalid: " + result4); + } + } + """; + var json = + """ + { + "indexTest1": [1, 2, 3], + "indexTest2": "This is a test" + } + """; + //JsonSchema.isValid(schema, json); + JsonAssert.isValid(schema, json); + } + + @Test + public void When_WrongTypeForDifferentOperations_ExceptionThrown() { + var schema = + """ + %schema: + { + "operationTest": @operationTest #object + } + %script: { + constraint operationTest() { + var result1 = tryof(target + 10); + if(find(result1.error, "[ADDI01]") < 0) + return fail("Invalid: " + result1); + var result2 = tryof(target - 10); + if(find(result2.error, "[SUBT01]") < 0) + return fail("Invalid: " + result2); + var result3 = tryof(target * 10); + if(find(result3.error, "[MULT01]") < 0) + return fail("Invalid: " + result3); + var result4 = tryof(target / 10); + if(find(result4.error, "[DIVD01]") < 0) + return fail("Invalid: " + result4); + var result5 = tryof(target > 10); + if(find(result5.error, "[RELA01]") < 0) + return fail("Invalid: " + result5); + var result6 = tryof(target >= 10); + if(find(result6.error, "[RELA02]") < 0) + return fail("Invalid: " + result6); + var result7 = tryof(target < 10); + if(find(result7.error, "[RELA03]") < 0) + return fail("Invalid: " + result7); + var result8 = tryof(target <= 10); + if(find(result8.error, "[RELA04]") < 0) + return fail("Invalid: " + result8); + } + } + """; + var json = + """ + { + "operationTest": {} + } + """; + //JsonSchema.isValid(schema, json); + JsonAssert.isValid(schema, json); + } + + @Test + public void When_WrongLValueForIncrementDecrement_ExceptionThrown() { + var schema = + """ + %schema: + { + "incDecTest1": @incDecTest1 #object, + "incDecTest2": @incDecTest1 #array + } + %script: { + constraint incDecTest1() { + var t = target; + var result1 = tryof(t++); + if(find(result1.error, "[INCR02]") < 0) + return fail("Invalid: " + result1); + var result2 = tryof(++t); + if(find(result2.error, "[INCR04]") < 0) + return fail("Invalid: " + result2); + var result3 = tryof(t--); + if(find(result3.error, "[DECR02]") < 0) + return fail("Invalid: " + result3); + var result4 = tryof(--t); + if(find(result4.error, "[DECR04]") < 0) + return fail("Invalid: " + result4); + } + } + """; + var json = + """ + { + "incDecTest1": {}, + "incDecTest2": [] + } + """; + //JsonSchema.isValid(schema, json); + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ReadonlyLValueForOperations_ExceptionThrown() { + var schema = + """ + %schema: + { + "lvalueTest1": @lvalueTest1 #object, + "lvalueTest2": @lvalueTest2 #array + } + %script: { + constraint lvalueTest1() { + var result1 = tryof(target.test = 10); + if(find(result1.error, "[PRPS02]") < 0) + return fail("Invalid: " + result1); + var result2 = tryof(target.k1 = 10); + if(find(result2.error, "[ASIN01]") < 0) + return fail("Invalid: " + result2); + } + + constraint lvalueTest2() { + var result1 = tryof(target[2] = 10); + if(find(result1.error, "[INDX04]") < 0) + return fail("Invalid: " + result1); + var result2 = tryof(target[0] = 10); + if(find(result2.error, "[ASIN01]") < 0) + return fail("Invalid: " + result2); + } + } + """; + var json = + """ + { + "lvalueTest1": {"k1": 100}, + "lvalueTest2": [100, 200] + } + """; + //JsonSchema.isValid(schema, json); + JsonAssert.isValid(schema, json); + } + + @Test + public void When_WrongLValueForMemberAndIndexRangeOperations_ExceptionThrown() { + var schema = + """ + %schema: + { + "lvalueTest1": @lvalueTest1 #array, + "lvalueTest2": @lvalueTest2 #object, + "lvalueTest3": @lvalueTest3 #integer + } + %script: { + constraint lvalueTest1() { + var result1 = tryof(target.test = 100); + if(find(result1.error, "[PRPS01]") < 0) + return fail("Invalid: " + result1); + var result2 = tryof(target["test"] = 100); + if(find(result2.error, "[INDX07]") < 0) + return fail("Invalid: " + result2); + } + + constraint lvalueTest2() { + var result1 = tryof(target[0] = 100); + if(find(result1.error, "[INDX06]") < 0) + return fail("Invalid: " + result1); + var result2 = tryof(target[0..] = 100); + if(find(result2.error, "[RNGS10]") < 0) + return fail("Invalid: " + result2); + } + + constraint lvalueTest3() { + var result1 = tryof(target.test = 10); + if(find(result1.error, "[PRPS01]") < 0) + return fail("Invalid: " + result1); + var result2 = tryof(target[0] = 10); + if(find(result2.error, "[INDX06]") < 0) + return fail("Invalid: " + result2); + var result3 = tryof(target[0..] = 100); + if(find(result3.error, "[RNGS10]") < 0) + return fail("Invalid: " + result3); + } + } + """; + var json = + """ + { + "lvalueTest1": [10, 20], + "lvalueTest2": { "k1": 10 }, + "lvalueTest3": 10 + } + """; + //JsonSchema.isValid(schema, json); + JsonAssert.isValid(schema, json); + } + + @Test + public void When_RuntimeSystemException_ExceptionThrown() { + // Exception like OutOfMemoryError / DivideByZero etc. + var schema = + """ + %schema: + { + "exceptionTest": @exceptionTest #integer + } + %script: { + constraint exceptionTest() { + var result = target / 0; + } + } + """; + var json = + """ + { + "exceptionTest": 10 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(SystemOperationException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(DIVD02, exception.getCode()); + exception.printStackTrace(); + } +} \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/jschema/test/negative/ScriptFunctionTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/ScriptFunctionTests.java new file mode 100644 index 0000000..c2cacef --- /dev/null +++ b/src/test/java/com/relogiclabs/jschema/test/negative/ScriptFunctionTests.java @@ -0,0 +1,386 @@ +package com.relogiclabs.jschema.test.negative; + +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.FunctionNotFoundException; +import com.relogiclabs.jschema.exception.ScriptRuntimeException; +import org.junit.jupiter.api.Test; + +import static com.relogiclabs.jschema.message.ErrorCode.CALR01; +import static com.relogiclabs.jschema.message.ErrorCode.FAIL09; +import static com.relogiclabs.jschema.message.ErrorCode.FIND02; +import static com.relogiclabs.jschema.message.ErrorCode.FUNC05; +import static com.relogiclabs.jschema.message.ErrorCode.FUNS02; +import static com.relogiclabs.jschema.message.ErrorCode.FUNS03; +import static com.relogiclabs.jschema.message.ErrorCode.FUNS04; +import static com.relogiclabs.jschema.message.ErrorCode.FUNS05; +import static com.relogiclabs.jschema.message.ErrorCode.RETN01; +import static com.relogiclabs.jschema.message.ErrorCode.TRGT01; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class ScriptFunctionTests { + @Test + public void When_ConstraintFunctionNotExists_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest #integer + } + """; + var json = + """ + { + "funcTest": 2 + } + """; + //JsonSchema.isValid(schema, json); + var exception = assertThrows(FunctionNotFoundException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(FUNC05, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_SubroutineFunctionNotExists_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest #integer + } + + %script: { + constraint funcTest() { + subroutineFunction(target); + } + } + """; + var json = + """ + { + "funcTest": 2 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(FUNS04, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_SubroutineVariadicCallWithoutRequiredArguments_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest #integer + } + + %script: { + constraint funcTest() { + testFunction(10); + } + + subroutine function testFunction(p1, p2, p3...) { + return false; + } + } + """; + var json = + """ + { + "funcTest": 2 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(FUNS05, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_InvalidReturnTypeOfConstraint_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest #integer + } + %script: { + // constraint functions are available to schema context + // subroutine functions are not available to schema context + constraint function funcTest() { + return 10; + } + } + """; + var json = + """ + { + "funcTest": 2 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(RETN01, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_MultipleVariadicSubroutine_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest #integer + } + %script: { + constraint funcTest() { + return true; + } + + // Regardless required params only one variadic subroutine + // can be overloaded with the same name but any number of + // fixed params subroutine can be overload with the same name + subroutine testFunction(p1, p2, p3...) { + return false; + } + + subroutine testFunction(p1, p2...) { + return false; + } + } + """; + var json = + """ + { + "funcTest": 2 + } + """; + //JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(FUNS03, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_InvalidArgumentTypeWithNativeSubroutine_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest + } + %script: { + constraint funcTest() { + if(!regular(target)) return fail("Invalid: " + target); + var result = find(target, 10); + } + } + """; + var json = + """ + { + "funcTest": 2 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(FIND02, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_InvalidArgumentValueWithNativeSubroutine_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest + } + %script: { + constraint funcTest() { + fail("ERR01", "Test Message", { node: null }, {}); + } + } + """; + var json = + """ + { + "funcTest": 2 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(FAIL09, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_ScriptInitiatedCallNotFoundTargetNode_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest + } + %script: { + // target is available inside subroutine when call initiated from schema + subroutine subroutineTest() { + var test = target; + return 10; + } + var test = subroutineTest(); + } + """; + var json = + """ + { + "funcTest": 2 + } + """; + //JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(TRGT01, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_ScriptInitiatedCallNotFoundCallerNode_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest + } + %script: { + // caller is available inside subroutine when call initiated from schema + subroutine subroutineTest() { + var test = caller; + return 10; + } + var test = subroutineTest(); + } + """; + var json = + """ + { + "funcTest": 2 + } + """; + //JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(CALR01, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_DuplicateConstraintDefinitionsConflict_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest(5) + } + %script: { + constraint funcTest(param1) { + return true; + } + + constraint funcTest(param1) { + return true; + } + } + """; + var json = + """ + { + "funcTest": 10 + } + """; + //JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(FUNS02, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_DuplicateConstraintDefinitionsWithFutureConflict_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest(5) + } + %script: { + constraint funcTest(param1) { + return true; + } + + // future functions are also constraint functions + future constraint funcTest(param1) { + return true; + } + } + """; + var json = + """ + { + "funcTest": 10 + } + """; + //JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(FUNS02, exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_DuplicateSubroutineDefinitionsConflict_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest(5) + } + %script: { + constraint funcTest(param1) { + return true; + } + + // Constraint functions are special functions and are not callable + // from script thus preventing any conflicts with subroutines + subroutine funcTest(param1) { + return true; + } + + subroutine funcTest(param1) { + return true; + } + } + """; + var json = + """ + { + "funcTest": 10 + } + """; + //JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals(FUNS03, exception.getCode()); + exception.printStackTrace(); + } +} \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/jschema/test/negative/ScriptGeneralTests.java b/src/test/java/com/relogiclabs/jschema/test/negative/ScriptGeneralTests.java new file mode 100644 index 0000000..fd17e1d --- /dev/null +++ b/src/test/java/com/relogiclabs/jschema/test/negative/ScriptGeneralTests.java @@ -0,0 +1,239 @@ +package com.relogiclabs.jschema.test.negative; + +import com.relogiclabs.jschema.JsonAssert; +import com.relogiclabs.jschema.JsonSchema; +import com.relogiclabs.jschema.exception.ScriptInitiatedException; +import com.relogiclabs.jschema.exception.ScriptRuntimeException; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class ScriptGeneralTests { + @Test + public void When_WrongValuesConditionUnsatisfiedV1_ExceptionThrown() { + var schema = + """ + %schema: + { + "role": #string &role, + "dataAccess": @checkAccess(&role) #integer + } + %script: { + future constraint checkAccess(role) { + if(role[0] == "user" && target > 5) return fail( + "ERRACCESS01", "Data access incompatible with 'user' role", + // 'caller' is the default node added automatically + expected("an access at most 5 for 'user' role"), + // 'target' is the default node added automatically + actual("found access " + target + " which is greater than 5")); + } + } + """; + var json = + """ + { + "role": "user", + "dataAccess": 6 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals("ERRACCESS01", exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_WrongValuesConditionUnsatisfiedV2_ExceptionThrown() { + var schema = + """ + %schema: + { + "role": #string &role, + "dataAccess": @checkAccess(&role) #integer + } + %script: { + future constraint checkAccess(role) { + if(role[0] == "user" && target > 5) return fail( + "ERRACCESS01", "Data access incompatible with 'user' role", + // Pass any node explicitly to the expected function + expected(caller, "an access at most 5 for 'user' role"), + // Pass any node explicitly to the actual function + actual(target, "found access " + target + " which is greater than 5")); + } + } + """; + var json = + """ + { + "role": "user", + "dataAccess": 6 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals("ERRACCESS01", exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_WrongValuesConditionUnsatisfiedV3_ExceptionThrown() { + var schema = + """ + %schema: + { + "role": #string &role, + "dataAccess": @checkAccess(&role) #integer + } + %script: { + constraint checkAccess(role) { + if(role[0] == "user" && target > 5) return fail( + "ERRACCESS01", "Data access incompatible with 'user' role", + // Create an expected object explicitly without any function + { node: caller, message: "an access at most 5 for 'user' role" }, + // Create an actual object explicitly without any function + { node: target, message: "found access " + target + + " which is greater than 5" }); + } + } + """; + var json = + """ + { + "role": "user", + "dataAccess": 7 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals("ERRACCESS01", exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_WrongValuesConditionUnsatisfiedV4_ExceptionThrown() { + var schema = + """ + %schema: + { + "role": #string &role, + "dataAccess": @checkAccess(&role) #integer + } + %script: { + future constraint checkAccess(role) { + // Fail with simple message and a code + if(role[0] == "user" && target > 5) return fail( + "ERRACCESS01", "Data access incompatible with 'user' role"); + } + } + """; + var json = + """ + { + "role": "user", + "dataAccess": 6 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals("ERRACCESS01", exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_WrongValuesConditionUnsatisfiedV5_ExceptionThrown() { + var schema = + """ + %schema: + { + "role": #string &role, + "dataAccess": @checkAccess(&role) #integer + } + %script: { + future constraint checkAccess(role) { + // Fail with just a message + if(role[0] == "user" && target > 5) return fail( + "Data access incompatible with 'user' role"); + } + } + """; + var json = + """ + { + "role": "user", + "dataAccess": 6 + } + """; + JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptRuntimeException.class, + () -> JsonAssert.isValid(schema, json)); + // FAIL01 is the default code if no code provided + assertEquals("FAIL01", exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_ThrowExceptionFromScriptV1_ExceptionThrown() { + var schema = + """ + %schema: + { + "throwTest": @throwTest #array + } + %script: { + future constraint throwTest() { + if(type(target) != "#array") return fail("Invalid: " + target); + if(find(target, 45.5) < 0) return fail("Invalid: " + target); + throw("ERROR01", "Throw exception from script"); + } + } + """; + var json = + """ + { + "throwTest": [10, 20, 30, 45.5] + } + """; + //JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptInitiatedException.class, + () -> JsonAssert.isValid(schema, json)); + assertEquals("ERROR01", exception.getCode()); + exception.printStackTrace(); + } + + @Test + public void When_ThrowExceptionFromScriptV2_ExceptionThrown() { + var schema = + """ + %schema: + { + "throwTest": @throwTest #array + } + %script: { + future constraint throwTest() { + var c1 = copy(target[0]); + var c2 = copy(target[3]); + if(c1 != 10) return fail("Invalid: " + c1); + if(c2 != 45.5) return fail("Invalid: " + c2); + throw("Throw exception from script"); + } + } + """; + var json = + """ + { + "throwTest": [10, 20, 30, 45.5] + } + """; + //JsonSchema.isValid(schema, json); + var exception = assertThrows(ScriptInitiatedException.class, + () -> JsonAssert.isValid(schema, json)); + // THRO01 is the default code if no code provided + assertEquals("THRO01", exception.getCode()); + exception.printStackTrace(); + } +} \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/jschema/test/positive/ScriptBasicTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/ScriptBasicTests.java new file mode 100644 index 0000000..71d2808 --- /dev/null +++ b/src/test/java/com/relogiclabs/jschema/test/positive/ScriptBasicTests.java @@ -0,0 +1,389 @@ +package com.relogiclabs.jschema.test.positive; + +import com.relogiclabs.jschema.JsonAssert; +import org.junit.jupiter.api.Test; + +public class ScriptBasicTests { + @Test + public void When_ArithmeticIntegerExpression_ValidTrue() { + var schema = + """ + %schema: + { + "exprTest": @exprTest #integer + } + %script: { + constraint exprTest() { + var num = 2; + var result = num + 3 * (2 + 1) - 8 / 2; + result = -result; + if(result == -target) return true; + return fail("Invalid: " + result); + } + } + """; + var json = + """ + { + "exprTest": 7 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ArithmeticDoubleExpression_ValidTrue() { + var schema = + """ + %script: { + constraint exprTest() { + var num = 3.5; + var result = 10.1 - (3.5 - 1.2) * 16.1 + 45.15 / num; + if(-result == target) return true; + return fail("Invalid: " + result); + } + } + %schema: + { + "exprTest": @exprTest #float + } + """; + var json = + """ + { + "exprTest": 14.03 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_FindSecondOccurrenceInString_ValidTrue() { + var schema = + """ + %schema: + { + "stringTest": @stringTest #string + } + %script: { + constraint stringTest() { + var result = find(target, "Ipsum"); + result = find(target, "Ipsum", result + 1); + print("Second Occurrence at: " + result); + if(result != 12) return fail("Invalid: " + target); + } + } + """; + var json = + """ + { + "stringTest": "Lorem Ipsum Ipsum" + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_FindSecondOccurrenceInArray_ValidTrue() { + var schema = + """ + %schema: + { + "arrayTest": @arrayTest #array + } + %script: { + constraint arrayTest() { + var result = find(target, 10); + result = find(target, 10, result + 1); + print("Second Occurrence at: " + result); + if(result != 4) return fail("Invalid: " + target); + } + } + """; + var json = + """ + { + "arrayTest": [5, 10, 20, 30, 10, 50, 80] + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ConcatWithStringAutoConvertToString_ValidTrue() { + var schema = + """ + %schema: + { + "stringTest": @stringTest #string + } + %script: { + constraint stringTest() { + if(type(target) != "#string") return fail("Invalid: " + target); + var result = "Lorem " + "Ipsum" + 10 + [1, 20] + {k1: 100}; + if(result != target) return fail("Invalid: " + result); + } + } + """; + var json = + """ + { + "stringTest": "Lorem Ipsum10[1, 20]{\\"k1\\": 100}" + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ComparisonOperationWithNumber_ValidTrue() { + var schema = + """ + %schema: + { + "comparisonTest": @comparisonTest #float + } + %script: { + constraint comparisonTest() { + if(!(target >= 10.1)) return fail("Err[>= 10.1]: " + target); + if(!(target >= 10)) return fail("Err[>= 10]: " + target); + if(!(target <= 10.1)) return fail("Err[<= 10.1]: " + target); + if(!(target <= 11)) return fail("Err[<= 11]: " + target); + if(!(target > 10.01)) return fail("Err[> 10.01]: " + target); + if(!(target > 10)) return fail("Err[> 10]: " + target); + if(!(target < 10.11)) return fail("Err[< 10.11]: " + target); + if(!(target < 11)) return fail("Err[< 11]: " + target); + if(target != 10.1) return fail("Err[!= 10.1]: " + target); + if(target == 10) return fail("Err[== 10]: " + target); + } + } + """; + var json = + """ + { + "comparisonTest": 10.1 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_TryofWithSuccessAndFailOperation_ValidTrue() { + var schema = + """ + %schema: + { + "tryofTest": @tryofTest + } + %script: { + constraint tryofTest() { + var result1 = tryof(target.k2); + if(result1.error) print("Error: " + result1.error); + else print("Value: " + result1.value); + var result2 = tryof(target.k1[5].item); + if(result2.error) print("Error: " + result2.error); + else print("Value: " + result2.value); + } + } + """; + var json = + """ + { + "tryofTest": { "k1": 10, "k2": "test", + "k3": null, "k4": 100.5 } + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_TryofWithThrowError_ValidTrue() { + var schema = + """ + %schema: + { + "tryofTest": @tryofTest + } + %script: { + constraint tryofTest() { + var result = tryof(throwerFunc(12)); + if(result.error) print("Error: " + result.error); + else print("Value : " + result.value); + } + + subroutine function throwerFunc(value) { + throw("ERR001", "This function's operation failed"); + print("This line not execute"); + } + } + """; + var json = + """ + { + "tryofTest": { "k1": 10, "k2": "test", + "k3": null, "k4": 100.5 } + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_CheckSchemaNodeDataType_ValidTrue() { + var schema = + """ + %schema: + { + "type1": @checkType("#integer") #integer, + "type2": @checkType("#float") #float, + "type3": @checkType("#double") #double, + "type4": @checkType("#string") #string, + "type5": @checkType("#boolean") #boolean, + "type6": @checkType("#array") #array, + "type7": @checkType("#object") #object, + // Nothing to validate on null if accepted + "type8": @checkType2(null, "#null") #number, + // Undefined is a special value of schema + "type9": @checkType2(!, "#undefined") #number + } + %script: { + constraint checkType(type) { + if(type(target) != type) return fail("Invalid: " + type(target)); + } + + constraint checkType2(value, type) { + if(type(value) != type) return fail("Invalid: " + type(value)); + } + } + """; + var json = + """ + { + "type1": 10, + "type2": 100.55, + "type3": 10E3, + "type4": "Test", + "type5": true, + "type6": [], + "type7": {}, + "type8": 0, + "type9": 0 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_CheckScriptValueDataType_ValidTrue() { + var schema = + """ + %schema: + { + "scriptType": @checkType #integer + } + %script: { + constraint checkType() { + var integer = 10; + var double = 10.5E3; + var string = "Test"; + var boolean = true; + var array = []; + var object = {}; + var nullVal = null; + var undefVal = undefined; + var noneAssigned; + + if(type(integer) != "#integer") return fail("Invalid: " + type(integer)); + if(type(double) != "#double") return fail("Invalid: " + type(double)); + if(type(string) != "#string") return fail("Invalid: " + type(string)); + if(type(boolean) != "#boolean") return fail("Invalid: " + type(boolean)); + if(type(array) != "#array") return fail("Invalid: " + type(array)); + if(type(object) != "#object") return fail("Invalid: " + type(object)); + if(type(nullVal) != "#null") return fail("Invalid: " + type(nullVal)); + if(type(undefVal) != "#undefined") return fail("Invalid: " + type(undefVal)); + if(type(noneAssigned) != "#void") return fail("Invalid: " + type(noneAssigned)); + } + } + """; + var json = + """ + { + "scriptType": 10 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_PrePostIncrementDecrement_ValidTrue() { + var schema = + """ + %schema: + { + "testIncDec": @testIncDec + } + %script: { + constraint testIncDec() { + var t = target; + var preInc = ++t; + if(preInc != t) return fail("Invalid: " + t); + var postInc = t++; + if(postInc != t - 1) return fail("Invalid: " + t); + var preDec = --t; + if(preDec != t) return fail("Invalid: " + t); + var postDec = t--; + if(postDec != t + 1) return fail("Invalid: " + t); + } + } + """; + var json = + """ + { + "testIncDec": 10 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_MultipleScriptBlocksAndComponents_ValidTrue() { + var schema = + """ + %script: { + constraint blockTest1() { + var value = 0; + for(;;) { + if(value < 10) value++; + else break; + } + if(target != value) return fail("Invalid: " + target); + } + } + %define $component2: @range(10, 20) @blockTest2 #integer + %schema: + { + "block1": $component1, + "block2": $component2, + "block3": @blockTest3 #integer + } + %script: { + constraint blockTest2() { + if(target != 20) return fail("Invalid: " + target); + } + } + %script: { + constraint blockTest3() { + if(target != 30) return fail("Invalid: " + target); + } + } + %define $component1: @range(1, 10) @blockTest1 #integer + """; + var json = + """ + { + "block1": 10, + "block2": 20, + "block3": 30 + } + """; + JsonAssert.isValid(schema, json); + } +} \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/jschema/test/positive/ScriptFunctionTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/ScriptFunctionTests.java new file mode 100644 index 0000000..edcba0d --- /dev/null +++ b/src/test/java/com/relogiclabs/jschema/test/positive/ScriptFunctionTests.java @@ -0,0 +1,257 @@ +package com.relogiclabs.jschema.test.positive; + +import com.relogiclabs.jschema.JsonAssert; +import org.junit.jupiter.api.Test; + +public class ScriptFunctionTests { + @Test + public void When_CheckConstraintOverloadingPrecedence_ValidTrue() { + var schema = + """ + %schema: + { + "funcTest1": @funcTest #integer, + "funcTest2": @funcTest(1) #integer, + "funcTest3": @funcTest(3, 5) #integer, + "funcTest4": @funcTest(2, 4, 6, 8) #integer + } + %script: { + // Fixed parameter functions always take precedence over + // variable parameter functions when arguments match both + constraint funcTest(params...) { + if(!(target == 10 || target == 40)) return fail("Invalid: " + caller); + var n = size(params); + print("Params size: " + n); + if(!(n == 0 || n == 4)) return fail("Invalid: " + n); + foreach(var p in params) print("Received param: " + p); + return true; + } + + constraint funcTest(param1) { + if(target != 20 || param1 != 1) return fail("Invalid: " + caller); + return true; + } + + constraint funcTest(param1, param2) { + if(target != 30 || param1 != 3 || param2 != 5) + return fail("Invalid: " + caller); + return true; + } + } + """; + var json = + """ + { + "funcTest1": 10, + "funcTest2": 20, + "funcTest3": 30, + "funcTest4": 40 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_SameConstraintWithSubroutineNoConflict_ExceptionThrown() { + var schema = + """ + %schema: + { + "funcTest": @funcTest + } + %script: { + constraint funcTest() { + return funcTest(); + } + + // Constraint functions are special functions and are not callable + // from script thereby preventing any conflicts with subroutines + // 'target' and 'caller' are available due to call initiated from schema + subroutine funcTest() { + if(target != 10) return fail("Target not found"); + if(stringify(caller) != "@funcTest") return fail("Caller not found"); + return true; + } + } + """; + var json = + """ + { + "funcTest": 10 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ConstraintOverloadingWithFixedParameters_ValidTrue() { + var schema = + """ + %schema: + { + "funcTest1": @funcTest #integer, + "funcTest2": @funcTest("test") #integer, + "funcTest3": @funcTest(10, 20.5, "value") #integer + } + %script: { + constraint funcTest() { + if(target != 10) fail("Invalid: " + target); + return true; + } + + constraint funcTest(param1) { + if(target != 20) fail("Invalid: " + target); + return true; + } + + constraint funcTest(param1, param2, param3) { + if(target != 30) fail("Invalid: " + target); + return true; + } + } + """; + var json = + """ + { + "funcTest1": 10, + "funcTest2": 20, + "funcTest3": 30 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_SubroutineVariadicCallWithVariableParameters_ValidTrue() { + var schema = + """ + %schema: + { + "funcTest": @funcTest #integer + } + + %script: { + constraint funcTest() { + var r1 = funcVar(); + if(r1 != 0) fail("Invalid: " + r1); + var r2 = funcVar(1, 2, 3, 4); + if(r2 != 4) fail("Invalid: " + r2); + } + + subroutine funcVar(params...) { + return size(params); + } + } + """; + var json = + """ + { + "funcTest": 10 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_AlternativeSyntaxForDifferentFunctionTypes_ValidTrue() { + var schema = + """ + %schema: + { + "funcTest1": @funcTest1 #integer, + "funcTest2": @funcTest2 #integer, + "funcTest3": @funcTest3 #integer, + "funcTest4": @funcTest4 #integer, + "funcTest5": @funcTest5 #integer, + "funcTest6": @funcTest6 #integer + } + + %script: { + constraint funcTest1() { + print("funcTest1"); + return funcTest7(); + } + + constraint function funcTest2() { + print("funcTest2"); + return funcTest8(); + } + + future funcTest3() { + print("funcTest3"); + return true; + } + + future constraint funcTest4() { + print("funcTest4"); + return true; + } + + future function funcTest5() { + print("funcTest5"); + return true; + } + + future constraint function funcTest6() { + print("funcTest6"); + return true; + } + + subroutine funcTest7() { + print("funcTest7"); + return true; + } + + subroutine function funcTest8() { + print("funcTest8"); + return true; + } + } + """; + var json = + """ + { + "funcTest1": 10, + "funcTest2": 20, + "funcTest3": 30, + "funcTest4": 40, + "funcTest5": 50, + "funcTest6": 60 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_CheckScriptGlobalVariableState_ValidTrue() { + var schema = + """ + %schema: + { + "funcTest1": @funcTest1 #integer, + "funcTest2": @funcTest2 #integer + } + + %script: { + var test = 10, test2 = 5; + constraint funcTest1() { + test = target; + test2 = 10; + } + + constraint funcTest2() { + if(test != target - 10) return fail("Invalid: " + test); + if(test2 != 10) return fail("Invalid: " + test2); + } + } + """; + var json = + """ + { + "funcTest1": 20, + "funcTest2": 30 + } + """; + JsonAssert.isValid(schema, json); + } +} \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/jschema/test/positive/ScriptGeneralTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/ScriptGeneralTests.java new file mode 100644 index 0000000..3d746eb --- /dev/null +++ b/src/test/java/com/relogiclabs/jschema/test/positive/ScriptGeneralTests.java @@ -0,0 +1,256 @@ +package com.relogiclabs.jschema.test.positive; + +import com.relogiclabs.jschema.JsonAssert; +import org.junit.jupiter.api.Test; + +public class ScriptGeneralTests { + @Test + public void When_ConditionSatisfiedWithValuesV1_ValidTrue() { + var schema = + """ + %schema: + { + "role": #string &role, + "dataAccess": @checkAccess(&role) #integer + } + %script: { + future constraint checkAccess(role) { + if(role[0] == "user" && target > 5) return fail( + "ERRACCESS01", "Data access incompatible with 'user' role", + // 'caller' is the default node added automatically + expected("an access at most 5 for 'user' role"), + // 'target' is the default node added automatically + actual("found access " + target + " which is greater than 5")); + } + } + """; + var json = + """ + { + "role": "user", + "dataAccess": 5 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ConditionSatisfiedWithValuesV2_ValidTrue() { + var schema = + """ + %schema: + { + "role": #string &role, + "dataAccess": @checkAccess(&role) #integer + } + %script: { + future checkAccess(role) { + if(role[0] == "user" && target > 5) return fail( + "ERRACCESS01", "Data access incompatible with 'user' role", + // Pass any node explicitly to the expected function + expected(caller, "an access at most 5 for 'user' role"), + // Pass any node explicitly to the actual function + actual(target, "found access " + target + " which is greater than 5")); + } + } + """; + var json = + """ + { + "role": "user", + "dataAccess": 3 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ConditionSatisfiedWithValuesV3_ValidTrue() { + var schema = + """ + %schema: + { + "role": #string &role, + "dataAccess": @checkAccess(&role) #integer + } + %script: { + constraint checkAccess(role) { + if(role[0] == "user" && target > 5) return fail( + "ERRACCESS01", "Data access incompatible with 'user' role", + // Create an expected object explicitly without any function + { node: caller, message: "an access at most 5 for 'user' role" }, + // Create an actual object explicitly without any function + { node: target, message: "found access " + target + + " which is greater than 5" }); + } + } + """; + var json = + """ + { + "role": "user", + "dataAccess": 2 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_SumOfValuesFromSingleReceivedArray_ValidTrue() { + var schema = + """ + %schema: + { + "array": #array &array, + "result": @sumTest(&array) #integer + } + %script: { + future sumTest(array) { + var sum1 = 0; + // &array received an array value stored at 0 + foreach(var e in array[0]) sum1 = sum1 + e; + var sum2 = 0; + // auto unbox inside foreach iterator for special case + foreach(var e in array) sum2 = sum2 + e; + if(sum1 != sum2) return fail("Invalid: " + sum1 + "!=" + sum2); + if(sum1 != target) return fail("Invalid: " + sum1); + // skip return true consider successful validation + } + } + """; + var json = + """ + { + "array": [10, 20, 30, 40, 50, 60, 70], + "result": 280 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_SumOfReceivedMultiValuesFromReceiver_ValidTrue() { + var schema = + """ + %schema: + { + "v1": #integer #float &values, + "v2": #integer #float &values, + "v3": #integer #float &values, + "v4": #integer #float &values, + "v5": #integer #float &values, + "result": @sumTest(&values) #float + } + %script: { + future constraint function sumTest(values) { + var sum = 0; + foreach(var e in values) sum = sum + e; + if(sum != target) return fail("Invalid: " + sum); + } + } + """; + var json = + """ + { + "v1": 10.5, + "v2": 16, + "v3": 90.3, + "v4": 130.1, + "v5": 50, + "result": 296.9 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ArithmeticOnTargetAndReceivedNumber_ValidTrue() { + var schema = + """ + %schema: + { + "value1": #float &value1, + "value2": @numberTest(&value1) + } + %script: { + constraint numberTest(number) { + if(target / 2 - 43.78 + 88.56 != number[0] * 2 + 78.9 - 21.07) + return fail("Invalid: " + target); + } + } + """; + var json = + """ + { + "value1": 25.4, + "value2": 127.7 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_TargetRangeDependsOnOtherValues_ValidTrue() { + var schema = + """ + %schema: + { + "min": #integer &min, + "value": @checkRange(&min, &max) #integer, + "max": #integer &max + } + %script: { + future constraint checkRange(min, max) { + if(target < min[0] || target > max[0]) return fail( + "RANGEERR01", "The target value is out of range", + expected("a value in range " + [min[0], max[0]]), + actual("but found " + target + " which is out of range")); + } + } + """; + var json = + """ + { + "min": 100, + "value": 180, + "max": 200 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_FindByIterationOnObjectProperties_ValidTrue() { + var schema = + """ + %schema: + { + "key1": #string, + "key2": #string, + "key3": #string + } @checkObject + + %script: { + constraint checkObject() { + if(type(target) != "#object") return fail("Target is not object"); + var hasKey = false; + foreach(var k in target) { + if(k == "key2") hasKey = true; + //print("Value of", k, ":", target[k]); + } + if(!hasKey) return fail("Invalid: " + target); + print("key2: " + target.key2); + } + } + """; + var json = + """ + { + "key1": "value1", + "key2": "value2", + "key3": "value3" + } + """; + JsonAssert.isValid(schema, json); + } +} \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/jschema/test/positive/ScriptLiteralTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/ScriptLiteralTests.java new file mode 100644 index 0000000..03719f9 --- /dev/null +++ b/src/test/java/com/relogiclabs/jschema/test/positive/ScriptLiteralTests.java @@ -0,0 +1,271 @@ +package com.relogiclabs.jschema.test.positive; + +import com.relogiclabs.jschema.JsonAssert; +import org.junit.jupiter.api.Test; + +public class ScriptLiteralTests { + @Test + public void When_ObjectCreateAddUpdate_ValidTrue() { + var schema = + """ + %schema: + { + "value": @objectTest + } + %script: { + constraint objectTest() { + var test = null; + var obj = { "k1": 1, k3: { + k2: 20.5 + 4.2 * 3.5 + 8.7 - 5.0, + k3: test + } }; + obj["k2"] = "test"; + obj.k4 = 100.5; + obj.k1 = 100; + obj.k3.k1 = 10; + // Mixed property access check + if(obj["k3"].k2 != 38.9) return fail("Invalid: " + obj); + if(obj != target) return fail("Invalid: " + obj); + } + } + """; + var json = + """ + { + "value": { + "k1": 100, + "k2": "test", + "k3": { + "k1": 10, + "k2": 38.9, + "k3": null + }, + "k4": 100.5 + } + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ArrayCreateAddUpdateWithObject_ValidTrue() { + var schema = + """ + %schema: + { + "value": @objectTest + } + %script: { + constraint objectTest() { + var result = 30; + var obj = { k1: 1, k2: 20, "k3": { + k2: [ 10, 30.9, 20.5 + 4.2 * 3.5 + 8.7 - 5.0, + { k4 : result } + ] + } }; + obj["k1"] = "test"; + obj.k3.k2[4] = [10, 20]; + if(obj.k3.k2 != target) return fail("Invalid: " + obj); + if(obj.k3.k2[2] != 38.9) return fail("Invalid: " + obj); + if(obj.k3.k2[4] != [10, 20]) return fail("Invalid: " + obj); + obj.k2 = 100; + if(obj.k2 != 100) return fail("Invalid: " + obj); + } + } + """; + var json = + """ + { + "value": [10, 30.9, 38.9, {"k4": 30}, [10, 20]] + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ArrayCreateAddUpdate_ValidTrue() { + var schema = + """ + %schema: + { + "value": @arrayTest + } + %script: { + constraint arrayTest() { + var test = null; + var arr = [1, 20, [100.5, 1E-3, test], 50, test, undefined]; + arr[0] = { k10: 10E2 }; + arr[6] = 34.5; + if(arr[2] != target) return fail("Invalid: " + arr); + if(arr[0] != { k10: 10E2 }) return fail("Invalid: " + arr); + } + } + """; + var json = + """ + { + "value": [100.5, 1E-3, null] + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_HandleUndefinedFromSchema_ValidTrue() { + var schema = + """ + %schema: + { + "value1": @checkRange(10, !) #integer, + "value2": @checkRange(!, 1000) #integer + } + %script: { + future constraint checkRange(min, max) { + if(min != undefined && target < min) return fail( + "RANGEERR01", "The value is less than minimum", + expected("a value in range " + [min, max]), + actual("but found " + target + " which out of range")); + if(max != undefined && target > max) return fail( + "RANGEERR02", "The value is greater than maximum", + expected("a value in range " + [min, max]), + actual("but found " + target + " which out of range")); + } + } + """; + var json = + """ + { + "value1": 10, + "value2": 1000 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_HandleNullFromSchema_ValidTrue() { + var schema = + """ + %schema: + { + "value1": @checkRange(10, null) #integer, + "value2": @checkRange(null, 10000) #integer + } + %script: { + future constraint checkRange(min, max) { + if(min != null && target < min) return fail( + "RANGEERR01", "The value is less than minimum", + expected("a value in range " + [min, max]), + actual("but found " + target + " which out of range")); + if(max != null && target > max) return fail( + "RANGEERR02", "The value is greater than maximum", + expected("a value in range " + [min, max]), + actual("but found " + target + " which out of range")); + } + } + """; + var json = + """ + { + "value1": 90, + "value2": 500 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_HandleNullOrUndefinedFromSchema_ValidTrue() { + var schema = + """ + %schema: + { + "value1": @checkRange(0, 100) #integer, + "value2": @checkRange(200, 1000) #integer, + "value3": @checkRange(20, !) #integer, + "value4": @checkRange(null, 1000) #integer + } + %script: { + future constraint checkRange(min, max) { + if(min && target < min) return fail( + "RANGEERR01", "The value is less than minimum", + expected("a value in range " + [min, max]), + actual("but found " + target + " which out of range")); + if(max && target > max) return fail( + "RANGEERR02", "The value is greater than maximum", + expected("a value in range " + [min, max]), + actual("but found " + target + " which out of range")); + } + } + """; + var json = + """ + { + "value1": 90, + "value2": 500, + "value3": 20, + "value4": 1000 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ApplyRangeAndIteratorOnString_ValidTrue() { + var schema = + """ + %schema: + { + "value": @stringTest + } + %script: { + constraint stringTest() { + if(target[-4..] != "text") return fail("Invalid: " + target[-4..]); + if(target[0..] != "This is a text") return fail("Invalid: " + target[0..]); + if(target[2..7] != "is is") return fail("Invalid: " + target[2..7]); + if(target[5..-5] != "is a") return fail("Invalid: " + target[5..-5]); + if(target[..-5] != "This is a") return fail("Invalid: " + target[..-5]); + var string = ""; + foreach(var c in target) string = string + c; + if(target != string) return fail("Invalid: " + string); + } + } + """; + var json = + """ + { + "value": "This is a text" + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_ApplyRangeAndIteratorOnArray_ValidTrue() { + var schema = + """ + %schema: + { + "value": @arrayTest + } + %script: { + constraint arrayTest() { + if(target[3..] != [4, 5, 6, 7]) return fail("Invalid: " + target[3..]); + if(target[3..6] != [4, 5, 6]) return fail("Invalid: " + target[3..6]); + if(target[-5..-2] != [3, 4, 5]) return fail("Invalid: " + target[-5..-2]); + if(target[..4] != [1, 2, 3, 4]) return fail("Invalid: " + target[..4]); + var array = [], index = 0; + foreach(var e in target) array[index++] = e; + if(target != array) return fail("Invalid: " + array); + } + } + """; + var json = + """ + { + "value": [1, 2, 3, 4, 5, 6, 7] + } + """; + JsonAssert.isValid(schema, json); + } +} \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/jschema/test/positive/ScriptSearchTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/ScriptSearchTests.java new file mode 100644 index 0000000..739b730 --- /dev/null +++ b/src/test/java/com/relogiclabs/jschema/test/positive/ScriptSearchTests.java @@ -0,0 +1,212 @@ +package com.relogiclabs.jschema.test.positive; + +import com.relogiclabs.jschema.JsonAssert; +import org.junit.jupiter.api.Test; + +// Use native functions for large and process-intensive tasks +public class ScriptSearchTests { + @Test + public void When_LinearSearchInString_ValidTrue() { + var schema = + """ + %schema: + { + "mainText": @searchTest(&query) #string, + "query": #string &query + } + %script: { + future searchTest(query) { + var index = search(target, query[0]); + print("Received query: " + query[0]); + print("Found at: " + index); + if(index != 28) return fail("Invalid: " + index); + } + + subroutine search(text, query) { + var n = size(text); + var m = size(query); + + for(var i = 0; i <= n - m; i++) { + var match = true; + for(var j = 0; j < m; j++) { + if(text[i + j] != query[j]) { + match = false; + break; + } + } + if(match) return i; + } + return -1; + } + } + """; + var json = + """ + { + "mainText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit", + "query": "consectetur" + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_BinarySearchInArray_ValidTrue() { + var schema = + """ + %schema: + { + "sortedArray": @searchTest(&searchKey) #float* #array, + "searchKey": #float &searchKey + } + %script: { + future searchTest(searchKey) { + var index = binarySearch(target, searchKey[0]); + print("Received key: " + searchKey[0]); + print("Found at: " + index); + if(index != 97) return fail("Invalid: " + index); + } + + subroutine binarySearch(array, key) { + var low = 0; + var high = size(array) - 1; + + while(low <= high) { + var mid = low + (high - low) / 2; + var midVal = array[mid]; + + if(midVal == key) { + return mid; + } else if(midVal < key) { + low = mid + 1; + } else { + high = mid - 1; + } + } + return -1; + } + } + """; + var json = + """ + { + "sortedArray": [26.73, 27.64, 30.10, 43.23, 49.67, 78.75, 118.82, 143.45, 163.78, + 174.04, 187.14, 191.31, 203.42, 217.67, 242.93, 243.58, 245.01, 264.11, + 264.30, 267.15, 275.08, 290.28, 293.32, 293.81, 321.01, 365.10, 367.10, + 377.74, 404.28, 422.42, 427.30, 433.56, 435.14, 442.65, 454.49, 458.71, + 462.34, 469.23, 478.34, 479.23, 495.34, 519.93, 524.16, 524.77, 526.23, + 532.42, 539.10, 564.29, 583.18, 585.50, 614.79, 616.86, 620.88, 634.81, + 637.26, 639.96, 652.08, 657.21, 657.42, 659.09, 665.45, 681.13, 696.57, + 704.03, 713.98, 727.89, 734.30, 757.58, 761.33, 778.55, 781.93, 785.39, + 801.44, 812.91, 814.34, 824.60, 827.37, 834.94, 857.54, 865.48, 870.42, + 870.87, 879.25, 889.30, 899.27, 905.59, 915.16, 916.99, 930.06, 930.93, + 933.80, 935.46, 950.84, 957.79, 977.36, 977.45, 978.02, 980.75, 983.62, + 988.69], + "searchKey": 980.75 + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_DepthFirstSearchInGraph_ValidTrue() { + var schema = + """ + %schema: + { + "adjacencyList": @dfsTest(&visitedOrder) #array, + "visitedOrder": #string &visitedOrder + } + %script: { + var visitedOrder = ""; + future dfsTest(order) { + var graph = [[6, 7, 12], [2, 9], [1, 8], [4, 5], [3, 13], [3, 17], [0, 8], + [0, 10, 18], [2, 6], [1, 14], [0, 11], [10, 15], [0, 13], [4, 12], [4], + [9, 16], [11, 19], [15], [5, 19], [7]]; + if(graph != target) return fail("Different graph: " + target); + var visited = fill(false, size(graph)); + dfs(graph, 0, visited); + visitedOrder = visitedOrder[2..]; + if(visitedOrder != order[0]) return fail("Invalid: " + visitedOrder); + print(visitedOrder); + } + + subroutine dfs(graph, start, visited) { + visited[start] = true; + visitedOrder = visitedOrder + ", " + start; + foreach(var neighbor in graph[start]) { + if(!visited[neighbor]) { + dfs(graph, neighbor, visited); + } + } + } + } + """; + var json = + """ + { + "adjacencyList": [[6, 7, 12], [2, 9], [1, 8], [4, 5], [3, 13], [3, 17], [0, 8], + [0, 10, 18], [2, 6], [1, 14], [0, 11], [10, 15], [0, 13], [4, 12], [4], + [9, 16], [11, 19], [15], [5, 19], [7]], + "visitedOrder": "0, 6, 8, 2, 1, 9, 14, 4, 3, 5, 17, 15, 16, 11, 10, 19, 7, 18, 13, 12" + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_BreadthFirstSearchInGraph_ValidTrue() { + var schema = + """ + %schema: + { + "adjacencyList": @bfsTest(&visitedOrder) #array, + "visitedOrder": #string &visitedOrder + } + %script: { + var visitedOrder = ""; + + future bfsTest(order) { + var graph = [[6, 7, 12], [2, 9], [1, 8], [4, 5], [3, 13], [3, 17], [0, 8], + [0, 10, 18], [2, 6], [1, 14], [0, 11], [10, 15], [0, 13], [4, 12], [4], + [9, 16], [11, 19], [15], [5, 19], [7]]; + if(graph != target) return fail("Different graph: " + target); + var visited = fill(false, size(graph)); + bfs(graph, 0); + visitedOrder = visitedOrder[..-2]; + if(visitedOrder != order[0]) return fail("Invalid: " + visitedOrder); + } + + subroutine bfs(graph, start) { + var visited = fill(false, size(graph)); + var front = 0, rear = 0; + var queue = []; + queue[rear++] = start; + visited[start] = true; + + while (front != rear) { + var current = queue[front++]; + visitedOrder = visitedOrder + current + ", "; + + foreach(var neighbor in graph[current]) { + if (!visited[neighbor]) { + queue[rear++] = neighbor; + visited[neighbor] = true; + } + } + } + } + } + """; + var json = + """ + { + "adjacencyList": [[6, 7, 12], [2, 9], [1, 8], [4, 5], [3, 13], [3, 17], [0, 8], + [0, 10, 18], [2, 6], [1, 14], [0, 11], [10, 15], [0, 13], [4, 12], [4], + [9, 16], [11, 19], [15], [5, 19], [7]], + "visitedOrder": "0, 6, 7, 12, 8, 10, 18, 13, 2, 11, 5, 19, 4, 1, 15, 3, 17, 9, 16, 14" + } + """; + JsonAssert.isValid(schema, json); + } +} \ No newline at end of file diff --git a/src/test/java/com/relogiclabs/jschema/test/positive/ScriptSortTests.java b/src/test/java/com/relogiclabs/jschema/test/positive/ScriptSortTests.java new file mode 100644 index 0000000..a5dc0c2 --- /dev/null +++ b/src/test/java/com/relogiclabs/jschema/test/positive/ScriptSortTests.java @@ -0,0 +1,414 @@ +package com.relogiclabs.jschema.test.positive; + +import com.relogiclabs.jschema.JsonAssert; +import org.junit.jupiter.api.Test; + +// Use native functions for large and process-intensive tasks +public class ScriptSortTests { + @Test + public void When_SortArrayUsingInsertionSort_ValidTrue() { + var schema = + """ + %schema: + { + "unsorted": @insertionSort(&sorted) #array, + "sorted": #array &sorted + } + %script: { + future insertionSort(result) { + // Copy creates a writable copy from readonly node + var array = copy(target); + var n = size(target); + for(var i = 1; i < n; i++) { + var key = array[i]; + var j = i - 1; + while(j >= 0 && array[j] > key) { + array[j-- + 1] = array[j]; + } + array[j + 1] = key; + } + if(array != result[0]) return fail("Invalid: " + array); + } + } + """; + var json = + """ + { + "unsorted": [-284, -782, -162, -737, 159, -580, -678, -92, -416, -408, -460, 605, -143, + 808, -142, -869, -735, 984, -665, 514, -421, 668, -872, -647, -581, 574, -499, -956, + 204, 646, -382, 248, -597, 998, -590, -815, -969, -515, -970, 888, 972, -942, 690, + 981, 742, -409, 248, 599, 275, -325], + + "sorted": [-970, -969, -956, -942, -872, -869, -815, -782, -737, -735, -678, -665, -647, + -597, -590, -581, -580, -515, -499, -460, -421, -416, -409, -408, -382, -325, -284, + -162, -143, -142, -92, 159, 204, 248, 248, 275, 514, 574, 599, 605, 646, 668, 690, + 742, 808, 888, 972, 981, 984, 998] + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_SortArrayUsingQuickSort_ValidTrue() { + var schema = + """ + %schema: + { + "sorted": #array &sorted, + "unsorted": @quickSort(&sorted) #array + } + %script: { + constraint quickSort(result) { + var array = copy(target); + quickSort(array, 0, size(target) - 1); + if(array != result[0]) return fail("Invalid: " + array); + } + + subroutine quickSort(array, low, high) { + if(low < high) { + var pi = partition(array, low, high); + quickSort(array, low, pi - 1); + quickSort(array, pi + 1, high); + } + } + + subroutine partition(array, low, high) { + var pivot = array[high]; + var i = low - 1; + for(var j = low; j < high; j++) { + if(array[j] <= pivot) { + swap(array, ++i, j); + } + } + swap(array, i + 1, high); + return i + 1; + } + + subroutine swap(array, i, j) { + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + } + """; + var json = + """ + { + "sorted": [26.73, 27.64, 30.10, 43.23, 49.67, 78.75, 118.82, 143.45, 163.78, + 174.04, 187.14, 191.31, 203.42, 217.67, 242.93, 243.58, 245.01, 264.11, + 264.30, 267.15, 275.08, 290.28, 293.32, 293.81, 321.01, 365.10, 367.10, + 377.74, 404.28, 422.42, 427.30, 433.56, 435.14, 442.65, 454.49, 458.71, + 462.34, 469.23, 478.34, 479.23, 495.34, 519.93, 524.16, 524.77, 526.23, + 532.42, 539.10, 564.29, 583.18, 585.50], + + "unsorted": [564.29, 462.34, 143.45, 118.82, 290.28, 242.93, 435.14, 458.71, 539.10, + 585.50, 524.16, 78.75, 243.58, 404.28, 217.67, 264.30, 367.10, 49.67, 203.42, + 26.73, 479.23, 245.01, 264.11, 532.42, 524.77, 583.18, 469.23, 27.64, 275.08, + 442.65, 454.49, 377.74, 187.14, 267.15, 163.78, 519.93, 174.04, 191.31, 321.01, + 427.30, 293.32, 30.10, 478.34, 526.23, 365.10, 43.23, 433.56, 422.42, 293.81, + 495.34] + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_SortArrayUsingBubbleSort_ValidTrue() { + var schema = + """ + %schema: + { + "unsorted": @bubbleSort(&sorted) #array, + "sorted": #array &sorted + } + %script: { + future bubbleSort(result) { + var array = copy(target); + var n = size(target) - 1; + var swapped = false; + + for(var i = 0; i < n; i++) { + swapped = false; + for(var j = 0; j < n - i; j++) { + if(array[j] > array[j + 1]) { + var temp = array[j]; + array[j] = array[j + 1]; + array[j + 1] = temp; + swapped = true; + } + } + if(!swapped) break; + } + if(array != result[0]) return fail("Invalid: " + array); + } + } + """; + var json = + """ + { + "unsorted": [575, 991, 877, 106, 163, -149, 730, -604, 755, -125, 496, 39, -226, + -803, 141, -461, -706, 390, -367, 631, 723, 789, -295, -615, 415, -150, 408, + -684, 385, -984, -558, -990, -979, -129, 508, -529, 666, -891, -63, -715, -435, + 431, 135, -243, 787, -911, -475, 914, -970, -138], + + "sorted": [-990, -984, -979, -970, -911, -891, -803, -715, -706, -684, -615, -604, + -558, -529, -475, -461, -435, -367, -295, -243, -226, -150, -149, -138, -129, + -125, -63, 39, 106, 135, 141, 163, 385, 390, 408, 415, 431, 496, 508, 575, 631, + 666, 723, 730, 755, 787, 789, 877, 914, 991] + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_SortArrayUsingMergeSort_ValidTrue() { + var schema = + """ + %schema: + { + "sorted": #array &sorted, + "unsorted": @mergeSort(&sorted) #array + } + %script: { + constraint mergeSort(result) { + var array = copy(target); + mergeSort(array, 0, size(target) - 1); + if(array != result[0]) return fail("Invalid: " + array); + } + + subroutine mergeSort(array, low, high) { + if(low < high) { + var mid = (low + high) / 2; + mergeSort(array, low, mid); + mergeSort(array, mid + 1, high); + merge(array, low, mid, high); + } + } + + subroutine merge(array, low, mid, high) { + var n1 = mid - low + 1; + var n2 = high - mid; + var left = []; + var right = []; + + for(var i = 0; i < n1; i++) { + left[i] = array[low + i]; + } + + for(var j = 0; j < n2; j++) { + right[j] = array[mid + 1 + j]; + } + + var i = 0, j = 0, k = low; + while(i < n1 && j < n2) { + if(left[i] <= right[j]) { + array[k++] = left[i++]; + } else { + array[k++] = right[j++]; + } + } + while(i < n1) array[k++] = left[i++]; + while(j < n2) array[k++] = right[j++]; + } + } + """; + var json = + """ + { + "sorted": [26.73, 27.64, 30.10, 43.23, 49.67, 78.75, 118.82, 143.45, 163.78, + 174.04, 187.14, 191.31, 203.42, 217.67, 242.93, 243.58, 245.01, 264.11, + 264.30, 267.15, 275.08, 290.28, 293.32, 293.81, 321.01, 365.10, 367.10, + 377.74, 404.28, 422.42, 427.30, 433.56, 435.14, 442.65, 454.49, 458.71, + 462.34, 469.23, 478.34, 479.23, 495.34, 519.93, 524.16, 524.77, 526.23, + 532.42, 539.10, 564.29, 583.18, 585.50], + + "unsorted": [454.49, 293.32, 143.45, 519.93, 532.42, 78.75, 267.15, 43.23, 427.30, + 245.01, 433.56, 30.10, 583.18, 404.28, 275.08, 49.67, 203.42, 191.31, 174.04, + 524.77, 495.34, 163.78, 264.30, 479.23, 365.10, 290.28, 118.82, 458.71, 187.14, + 264.11, 243.58, 526.23, 422.42, 442.65, 469.23, 217.67, 564.29, 585.50, 27.64, + 435.14, 26.73, 293.81, 478.34, 462.34, 367.10, 321.01, 242.93, 524.16, 377.74, + 539.10] + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_SortArrayUsingHeapSort_ValidTrue() { + var schema = + """ + %schema: + { + "sorted": #array &sorted, + "unsorted": @heapSort(&sorted) #array + } + %script: { + constraint heapSort(result) { + var array = copy(target); + var n = size(array); + + for(var i = n / 2 - 1; i >= 0; i--) { + heapify(array, n, i); + } + + for(var i = n - 1; i >= 0; i--) { + var temp = array[0]; + array[0] = array[i]; + array[i] = temp; + heapify(array, i, 0); + } + if(array != result[0]) return fail("Invalid: " + array); + } + + subroutine heapify(array, n, i) { + var largest = i; + var l = 2 * i + 1; + var r = 2 * i + 2; + + if(l < n && array[l] > array[largest]) largest = l; + if(r < n && array[r] > array[largest]) largest = r; + + if(largest != i) { + var swap = array[i]; + array[i] = array[largest]; + array[largest] = swap; + heapify(array, n, largest); + } + } + } + """; + var json = + """ + { + "sorted": [26.73, 27.64, 30.10, 43.23, 49.67, 78.75, 118.82, 143.45, 163.78, + 174.04, 187.14, 191.31, 203.42, 217.67, 242.93, 243.58, 245.01, 264.11, + 264.30, 267.15, 275.08, 290.28, 293.32, 293.81, 321.01, 365.10, 367.10, + 377.74, 404.28, 422.42, 427.30, 433.56, 435.14, 442.65, 454.49, 458.71, + 462.34, 469.23, 478.34, 479.23, 495.34, 519.93, 524.16, 524.77, 526.23, + 532.42, 539.10, 564.29, 583.18, 585.50], + + "unsorted": [454.49, 293.32, 143.45, 519.93, 532.42, 78.75, 267.15, 43.23, 427.30, + 245.01, 433.56, 30.10, 583.18, 404.28, 275.08, 49.67, 203.42, 191.31, 174.04, + 524.77, 495.34, 163.78, 264.30, 479.23, 365.10, 290.28, 118.82, 458.71, 187.14, + 264.11, 243.58, 526.23, 422.42, 442.65, 469.23, 217.67, 564.29, 585.50, 27.64, + 435.14, 26.73, 293.81, 478.34, 462.34, 367.10, 321.01, 242.93, 524.16, 377.74, + 539.10] + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_SortArrayUsingCountingSort_ValidTrue() { + var schema = + """ + %schema: + { + "unsorted": @countingSort(&sorted) #array, + "sorted": #array &sorted + } + %script: { + future countingSort(result) { + var array = copy(target); + countingSort(array); + if(array != result[0]) return fail("Invalid: " + array); + } + + subroutine countingSort(array) { + var max = array[0]; + var min = array[0]; + + foreach(var value in array) { + if (value > max) max = value; + if (value < min) min = value; + } + + var range = max - min + 1; + var counts = fill(0, range); + + foreach(var value in array) counts[value - min]++; + + var index = 0; + for(var i = 0; i < range; i++) { + while(counts[i] > 0) { + array[index] = i + min; + index++; + counts[i]--; + } + } + } + } + """; + var json = + """ + { + "unsorted": [575, 991, 877, 106, 163, -149, 730, -604, 755, -125, 496, 39, -226, + -803, 141, -461, -706, 390, -367, 631, 723, 789, -295, -615, 415, -150, 408, + -684, 385, -984, -558, -990, -979, -129, 508, -529, 666, -891, -63, -715, -435, + 431, 135, -243, 787, -911, -475, 914, -970, -138], + + "sorted": [-990, -984, -979, -970, -911, -891, -803, -715, -706, -684, -615, -604, + -558, -529, -475, -461, -435, -367, -295, -243, -226, -150, -149, -138, -129, + -125, -63, 39, 106, 135, 141, 163, 385, 390, 408, 415, 431, 496, 508, 575, 631, + 666, 723, 730, 755, 787, 789, 877, 914, 991] + } + """; + JsonAssert.isValid(schema, json); + } + + @Test + public void When_SortArrayUsingRadixSort_ValidTrue() { + var schema = + """ + %schema: + { + "unsorted": @radixSort(&sorted) #array, + "sorted": #array &sorted + } + %script: { + future radixSort(result) { + var array = copy(target); + radixSort(array); + if(array != result[0]) return fail("Invalid: " + array); + } + + subroutine radixSort(array) { + var max = array[0]; + foreach(var num in array) { + if(num > max) max = num; + } + + var numDigits = floor(log(max) / log(10)) + 1; + for(var digit = 1; digit <= numDigits; digit++) { + var buckets = []; + for(var i = 0; i < 10; i++) buckets[i] = []; + + foreach(var num in array) { + var bucket = buckets[floor(mod(num / pow(10, digit - 1), 10))]; + bucket[size(bucket)] = num; + } + var index = 0; + foreach(var bucket in buckets) { + foreach(var num in bucket) { + array[index++] = num; + } + } + } + } + } + """; + var json = + """ + { + "unsorted": [133, 955, 254, 784, 645, 778, 679, 970, 807, 207, 407, 299, 260, 358, 134, + 374, 156, 840, 39, 344, 418, 309, 186, 314, 957, 182, 116, 741, 107, 636, 969, 527, + 61, 343, 96, 738, 538, 542, 244, 480, 617, 914, 532, 355, 544, 251, 669, 777, 610, + 947], + "sorted": [39, 61, 96, 107, 116, 133, 134, 156, 182, 186, 207, 244, 251, 254, 260, 299, + 309, 314, 343, 344, 355, 358, 374, 407, 418, 480, 527, 532, 538, 542, 544, 610, 617, + 636, 645, 669, 679, 738, 741, 777, 778, 784, 807, 840, 914, 947, 955, 957, 969, 970] + } + """; + JsonAssert.isValid(schema, json); + } +} \ No newline at end of file