diff --git a/engine/src/main/java/com/arcadedb/query/QueryEngineManager.java b/engine/src/main/java/com/arcadedb/query/QueryEngineManager.java index dd6dc54ded..b4e22b92e4 100644 --- a/engine/src/main/java/com/arcadedb/query/QueryEngineManager.java +++ b/engine/src/main/java/com/arcadedb/query/QueryEngineManager.java @@ -17,14 +17,12 @@ import com.arcadedb.database.DatabaseInternal; import com.arcadedb.query.cypher.CypherQueryEngine; +import com.arcadedb.query.graphql.GraphQLQueryEngine; import com.arcadedb.query.gremlin.GremlinQueryEngine; import com.arcadedb.query.mongo.MongoQueryEngine; import com.arcadedb.query.sql.SQLQueryEngine; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class QueryEngineManager { private final Map implementations = new HashMap<>(); @@ -34,6 +32,7 @@ public QueryEngineManager() { register(new GremlinQueryEngine.GremlinQueryEngineFactory()); register(new CypherQueryEngine.CypherQueryEngineFactory()); register(new MongoQueryEngine.MongoQueryEngineFactory()); + register(new GraphQLQueryEngine.GraphQLQueryEngineFactory()); } public void register(final QueryEngine.QueryEngineFactory impl) { diff --git a/engine/src/main/java/com/arcadedb/query/graphql/GraphQLQueryEngine.java b/engine/src/main/java/com/arcadedb/query/graphql/GraphQLQueryEngine.java new file mode 100644 index 0000000000..5f1d9b20e9 --- /dev/null +++ b/engine/src/main/java/com/arcadedb/query/graphql/GraphQLQueryEngine.java @@ -0,0 +1,124 @@ +/* + * Copyright © 2021-present Arcade Data Ltd (info@arcadedata.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.arcadedb.query.graphql; + +import com.arcadedb.database.Database; +import com.arcadedb.database.DatabaseInternal; +import com.arcadedb.exception.CommandExecutionException; +import com.arcadedb.exception.QueryParsingException; +import com.arcadedb.log.LogManager; +import com.arcadedb.query.QueryEngine; +import com.arcadedb.query.sql.executor.ResultSet; +import com.arcadedb.utility.FileUtils; + +import java.lang.reflect.*; +import java.util.*; +import java.util.logging.*; + +public class GraphQLQueryEngine implements QueryEngine { + private static final String ENGINE_NAME = "graphql-engine"; + private final Object graphQLSchema; + + public static class GraphQLQueryEngineFactory implements QueryEngineFactory { + private static Boolean available = null; + private static Class graphQLSchemaClass; + + @Override + public boolean isAvailable() { + if (available == null) { + try { + graphQLSchemaClass = Class.forName("com.arcadedb.graphql.schema.GraphQLSchema"); + available = true; + } catch (ClassNotFoundException e) { + available = false; + } + } + return available; + } + + @Override + public String getLanguage() { + return "graphql"; + } + + @Override + public QueryEngine getInstance(final DatabaseInternal database) { + Object engine = database.getWrappers().get(ENGINE_NAME); + if (engine != null) + return (GraphQLQueryEngine) engine; + + try { + engine = new GraphQLQueryEngine(graphQLSchemaClass.getConstructor(Database.class).newInstance(database)); + database.setWrapper(ENGINE_NAME, engine); + return (GraphQLQueryEngine) engine; + + } catch (Exception e) { + LogManager.instance().log(this, Level.SEVERE, "Error on initializing GraphQL query engine", e); + throw new QueryParsingException("Error on initializing GraphQL query engine", e); + } + } + } + + protected GraphQLQueryEngine(final Object graphQLSchema) { + this.graphQLSchema = graphQLSchema; + } + + @Override + public AnalyzedQuery analyze(String query) { + return new AnalyzedQuery() { + @Override + public boolean isIdempotent() { + return false; + } + + @Override + public boolean isDDL() { + return false; + } + }; + } + + @Override + public ResultSet query(final String query, final Map parameters) { + return command(query, parameters); + } + + @Override + public ResultSet query(final String query, final Object... parameters) { + return command(query, parameters); + } + + @Override + public ResultSet command(final String query, final Map parameters) { + try { + final ResultSet resultSet = (ResultSet) GraphQLQueryEngineFactory.graphQLSchemaClass.getMethod("execute", String.class).invoke(graphQLSchema, query); + + return resultSet; + } catch (InvocationTargetException e) { + throw new CommandExecutionException("Error on executing GraphQL command:\n" + FileUtils.printWithLineNumbers(query), e.getTargetException()); + } catch (Exception e) { + throw new QueryParsingException("Error on executing GraphQL query:\n" + FileUtils.printWithLineNumbers(query), e); + } + } + + @Override + public ResultSet command(final String query, final Object... parameters) { + final Map map = new HashMap<>(parameters.length / 2); + for (int i = 0; i < parameters.length; i += 2) + map.put((String) parameters[i], parameters[i + 1]); + return command(query, map); + } +} diff --git a/engine/src/main/java/com/arcadedb/query/sql/executor/ResultInternal.java b/engine/src/main/java/com/arcadedb/query/sql/executor/ResultInternal.java index 4ff32ff2e1..7ebb6a9960 100644 --- a/engine/src/main/java/com/arcadedb/query/sql/executor/ResultInternal.java +++ b/engine/src/main/java/com/arcadedb/query/sql/executor/ResultInternal.java @@ -221,7 +221,7 @@ public Optional getElement() { @Override public Map toMap() { - return content; + return element != null ? element.toMap() : content; } @Override diff --git a/engine/src/main/java/com/arcadedb/utility/FileUtils.java b/engine/src/main/java/com/arcadedb/utility/FileUtils.java index cd6daf6ec0..748ccdeb2e 100755 --- a/engine/src/main/java/com/arcadedb/utility/FileUtils.java +++ b/engine/src/main/java/com/arcadedb/utility/FileUtils.java @@ -409,4 +409,35 @@ public static String escapeHTML(final String s) { } return out.toString(); } + + public static String printWithLineNumbers(final String text) { + // COUNT TOTAL LINES FIRST + int totalLines = 1; + for (int i = 0; i < text.length(); i++) { + final Character current = text.charAt(i); + if (current == '\n') + ++totalLines; + } + + final int maxLineDigits = String.valueOf(totalLines).length(); + + final StringBuilder result = new StringBuilder("1: "); + + int line = 1; + for (int i = 0; i < text.length(); i++) { + final Character current = text.charAt(i); + final Character next = i + 1 < text.length() ? text.charAt(i) : null; + if (current == '\n') { + ++line; + result.append(String.format("\n%-" + maxLineDigits + "d: ", line)); + } else if (current == '\r' && (next == null || next == '\n')) { + ++line; + result.append(String.format("\n%-" + maxLineDigits + "d: ", line)); + ++i; + } else + result.append(current); + } + + return result.toString(); + } } diff --git a/graphql/pom.xml b/graphql/pom.xml new file mode 100755 index 0000000000..14d7c4410b --- /dev/null +++ b/graphql/pom.xml @@ -0,0 +1,81 @@ + + + + 4.0.0 + + com.arcadedb + arcadedb-parent + 21.12.1-SNAPSHOT + ../pom.xml + + + arcadedb-graphql + jar + + + 4.1.4 + + + + + com.arcadedb + arcadedb-server + ${project.parent.version} + compile + + + com.arcadedb + arcadedb-server + ${project.parent.version} + test + test-jar + + + + + + + com.helger.maven + ph-javacc-maven-plugin + ${ph-javacc-maven-plugin.version} + + + jjc1 + generate-sources + + jjtree-javacc + + + + + 1.8 + ${basedir}/src/main/grammar + ${basedir}/src/main/java + ${basedir}/src/main/java + + + + + + + + + diff --git a/graphql/src/main/grammar/graphql.jjt b/graphql/src/main/grammar/graphql.jjt new file mode 100755 index 0000000000..d08d17cb56 --- /dev/null +++ b/graphql/src/main/grammar/graphql.jjt @@ -0,0 +1,1142 @@ +/* + * Copyright (c) 2016, Christoph Engelbert (aka noctarius) and + * contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* The original grammar comes from Christoph Engelbert (aka noctarius) on repository +* https://github.com/noctarius/graphquul/blob/master/src/main/javacc/graphql.jj licensed as Apache 2.0. ArcadeDB project forked that +* grammar, so any changes from the original version are kept in the ArcadeDB project repository and not synchronized back to the +* original repository. +*/ + +options { + TRACK_TOKENS = true; + JDK_VERSION = "1.11"; + MULTI=true; + VISITOR=true; + STATIC=false; + USER_CHAR_STREAM = true ; + JAVA_UNICODE_ESCAPE=false; + NODE_PREFIX=""; +} +PARSER_BEGIN(GraphQLParser) +package com.arcadedb.graphql.parser; + +import java.io.*; +import com.arcadedb.query.sql.parser.JavaCharStream; + +public class GraphQLParser { + private int tokenId = 0; + + + public static Document parse(String query) throws ParseException { + return new GraphQLParser(new SimpleCharStream(new StringReader(query))).Document(); + } + + + private int line() { + return token_source.input_stream.getBeginLine(); + } + + private int column() { + return token_source.input_stream.getBeginColumn(); + } + + private int tokenId() { + return tokenId++; + } +} +PARSER_END(GraphQLParser) + +TOKEN: { + < COMMA : "," > + | < HASH : "#" > + | < BANG : "!" > + | < DOLLAR : "$" > + | < OPAR : "(" > + | < CPAR : ")" > + | < ELLIPSIS : "..." > + | < COLON : ":" > + | < EQ : "=" > + | < AT : "@" > + | < OBRA : "[" > + | < CBRA : "]" > + | < OCBR : "{" > + | < PIPE : "|" > + | < CCBR : "}" > + | < PLUS : "+" > + | < MINUS : "-" > + | < SIGN : | > +} + +TOKEN: { + < FRAGMENT : "fragment" > + | < QUERY : "query" > + | < MUTATION : "mutation" > + | < SCHEMA : "schema" > + | < SCALAR : "scalar" > + | < TYPE : "type" > + | < INTERFACE : "interface" > + | < IMPLEMENTS : "implements" > + | < ENUM : "enum" > + | < UNION : "union" > + | < INPUT : "input" > + | < EXTEND : "extend" > + | < DIRECTIVE : "directive" > + + | < TRUE : "true" > + | < FALSE : "false" > + | < NULL : "null" > + | < ON : "on" > +} + +TOKEN: { + < DIGIT : [ "0"-"9" ] > + | < NON_ZERO_DIGIT : [ "1"-"9" ] > +} + +SKIP: { + "\t" + | "\u0020" + | "\ufeff" // Unicode BOM + | < SKIP_NEW_LINE : > + | < SKIP_INSIGN_COMMA : > + | < SKIP_COMMENT : (~["\n", "\r", "\u2028", "\u2029"])* > +} + +TOKEN: { + < #LINE_TERMINATOR : ( ["\n", "\r", "\u2028", "\u2029"] ) > + | < #WHITESPACE : ["\t", "\u000b", "\f", "\u0020", "\u00a0"] > + | < #LETTER : ["\t", "\r", "\n", "\u0020"-"\uffff"] > + | < #EXPONENT_IDENFITIER : "e" | "E" > + | < #INTEGER_PART : "0" | ()* > + | < #FRACTIONAL_PART : "." ()* > + | < #EXPONENT_PART : ()? ()+ > + | < INTEGER_LITERAL : ()? > + | < FLOAT_LITERAL : ()? + ( + + | + | + ) > + | < STRING_LITERAL : "\"" + ( + ~["\"", "\\", "\u2028", "\u2029"] + | "\\u" ( ["0"-"9"] | ["A"-"F"] | ["a"-"f"] ){4} // Escaped Unicode + | "\\" ( "\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t" ) // Escaped Character + | ()+ + )* + "\"" > + | < NAME_LITERAL : ( "_" | ["A"-"Z"] | ["a"-"z"] ) ( "_" | ["0"-"9"] | ["A"-"Z"] | ["a"-"z"] )* > +} + +// Document structure +Document Document(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + Definition lastDef; +} +{ + ( + lastDef = Definition() { jjtThis.definitions.add(lastDef); } + )+ + + {return jjtThis;} +} + +Definition Definition(): { + Definition def; +} +{ + ( + def = OperationDefinition() + | + def = FragmentDefinition() + | + def = TypeSystemDefinition() + ) + {return def;} +} + +OperationDefinition OperationDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); +} +{ + ( + ( + jjtThis.selectionSet = SelectionSet() + ) + | + ( + jjtThis.operationType = OperationType() + (jjtThis.name = Name())? + (jjtThis.variableDefinitions = VariableDefinitions())? + (jjtThis.directives = Directives())? + jjtThis.selectionSet = SelectionSet() + ) + ) { + return jjtThis; + } +} + +VariableDefinitions VariableDefinitions(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + VariableDefinition lastDef; +} +{ + + ( lastDef = VariableDefinition() { jjtThis.variableDefinitions.add(lastDef); } )+ + + { + return jjtThis; + } +} + +VariableDefinition VariableDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + +} +{ + ( + jjtThis.variableLiteral = VariableLiteral() + + jjtThis.type = Type() + (jjtThis.defaultValue = DefaultValue())? + ) + { + return jjtThis; + } +} + +VariableLiteral VariableLiteral(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); +} +{ + jjtThis.name = Name() + { + return jjtThis; + } +} + +DefaultValue DefaultValue(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + +} +{ + jjtThis.value = Value() + { + return jjtThis; + } +} + +// Operations +SelectionSet SelectionSet(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + + Selection lastSelection; + +} +{ + + (lastSelection = Selection() { jjtThis.selections.add(lastSelection); })+ + + { + return jjtThis; + } +} + +Selection Selection(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); +} +{ + ( + ( + jjtThis.name = Name() + ( + jjtThis.fieldWithAlias = FieldWithAlias(jjtThis.name, line, column, tokenId) + | + jjtThis.field = Field(jjtThis.name, line, column, tokenId) + ) + ) + | + ( + {jjtThis.ellipsis = true;} + ( + jjtThis.fragmentSpread = FragmentSpread(line, column, tokenId) + | + jjtThis.inlineFragment = InlineFragment(line, column, tokenId) + ) + ) + ) {return jjtThis;} +} + +Field Field(Name name, int line, int column, int tokenId): { + +} +{ + ( + (jjtThis.arguments = Arguments())? + (jjtThis.directives = Directives())? + (jjtThis.selectionSet = SelectionSet())? + ) + { + return jjtThis; + } +} + +FieldWithAlias FieldWithAlias(Name alias, int line, int column, int tokenId): { +} +{ + ( + + jjtThis.name = Name() + (jjtThis.arguments = Arguments())? + (jjtThis.directives = Directives())? + (jjtThis.selectionSet = SelectionSet())? + ){ + return jjtThis; + } +} + +Arguments Arguments(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + Argument lastArg; +} +{ + + lastArg = Argument() { jjtThis.arguments.add(lastArg); } + ( lastArg = Argument() { jjtThis.arguments.add(lastArg); })* + + { + return jjtThis; + } +} + +Argument Argument(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); +} +{ + ( + jjtThis.name = Name() + + jjtThis.valueWithVariable = ValueWithVariable() + ) + { + return jjtThis; + } +} + +// Fragments +FragmentSpread FragmentSpread(int line, int column, int tokenId): { + +} +{ + ( + jjtThis.name = FragmentName() + (jjtThis.directives = Directives())? + ){ + return jjtThis; + } +} + +InlineFragment InlineFragment(int line, int column, int tokenId): { + +} +{ + ( + (jjtThis.typeCondition = TypeCondition())? + (jjtThis.directives = Directives())? + jjtThis.selectionSet = SelectionSet() + ){ + return jjtThis; + } +} + +FragmentDefinition FragmentDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); +} +{ + ( + + jjtThis.name = FragmentName() + jjtThis.type = TypeCondition() + (jjtThis.directives = Directives())? + jjtThis.selectionSet = SelectionSet() + ) + { + return jjtThis; + } +} + +FragmentName FragmentName(): { +} +{ + (jjtThis.name = Name()) + { + // TODO if ("on".equals(name.image)) throw new ParseException("on is not allowed at a name"); + return jjtThis; + } +} + +TypeCondition TypeCondition(): { +} +{ + + jjtThis.name = TypeName() { + return jjtThis; + } +} + +// Values +Name Name(): { + Token t; +} +{ + ( + t = | + t = | + t = | + t = | + t = | + t = | + t = | + t = | + t = | + t = | + t = | + t = | + t = | + t = + ) + { + jjtThis.value = t.image; + return jjtThis; + } +} + +Value Value(): { +} +{ + ( + //TODO class hierarchy here instead? + + jjtThis.intValue = IntValue() + | + jjtThis.floatValue = FloatValue() + | + jjtThis.stringValue = StringValue() + | + jjtThis.booleanValue = BooleanValue() + | + jjtThis.enumValue = EnumValue() + | + jjtThis.listValue = ListValue() + | + jjtThis.objectValue = ObjectValue() + ) + { + return jjtThis; + } +} + +ValueWithVariable ValueWithVariable(): {} +{ + ( + jjtThis.variableLiteral = VariableLiteral() + | + jjtThis.intValue = IntValue() + | + jjtThis.floatValue = FloatValue() + | + jjtThis.stringValue = StringValue() + | + jjtThis.booleanValue = BooleanValue() + | + jjtThis.enumValue = EnumValue() + | + jjtThis.listValueWithVariable = ListValueWithVariable() + | + jjtThis.objectValueWithVariable = ObjectValueWithVariable() + ) + {return jjtThis;} +} + +EnumValue EnumValue(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); +} +{ + jjtThis.name = Name() { + //TODO if ("true".equals(name.image) + //TODO || "false".equals(name.image) + //TODO || "null".equals(name.image)) throw new ParseException("true, false, null are not allowed as names"); + + return jjtThis; + } +} + +// List Value +ListValue ListValue(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + + Value lastVal; + +} +{ + + ( + lastVal = Value() { jjtThis.values.add(lastVal); } + )* + { + return jjtThis; + } +} + +ListValueWithVariable ListValueWithVariable(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + + ValueWithVariable lastVal; +} +{ + + ( + lastVal = ValueWithVariable() { jjtThis.values.add(lastVal); } + )* + { + return jjtThis; + } +} + +// Object Value +ObjectValue ObjectValue(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + + ObjectField lastVal; + +} +{ + + ( + lastVal = ObjectField() { jjtThis.values.add(lastVal); } + )* + { + return jjtThis; + } +} + +ObjectValueWithVariable ObjectValueWithVariable(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + + ObjectFieldWithValue lastVal; +} +{ + + ( + lastVal = ObjectFieldWithValue() { jjtThis.values.add(lastVal); } + )* + { + return jjtThis; + } +} + +ObjectField ObjectField(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + +} +{ + ( + jjtThis.name = Name() + + jjtThis.value = Value() + ) + { + return jjtThis; + } +} + +ObjectFieldWithValue ObjectFieldWithValue(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + +} +{ + ( + jjtThis.name = Name() + + jjtThis.value = ValueWithVariable() + ) + { + return jjtThis; + } +} + +// Directives +Directives Directives(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + + Directive lastDirective; +} +{ + ( + + lastDirective = Directive() { jjtThis.directives.add(lastDirective); } + ( + + lastDirective = Directive() { jjtThis.directives.add(lastDirective); } + )* + ){ + + } + { + return jjtThis; + } +} + +Directive Directive(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + +} +{ + ( + jjtThis.name = Name() + (jjtThis.arguments = Arguments())? + ) + { + return jjtThis; + } +} + +// Types +Type Type(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); +} +{ + ( + jjtThis.typeName = TypeName() + [ { jjtThis.bang = true; }] + | + jjtThis.listType = ListType() + ) + { + return jjtThis; + } +} + +TypeName TypeName(): { +} +{ + jjtThis.name = Name() { + return jjtThis; + } +} + +ListType ListType(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + +} +{ + ( + + jjtThis.type = Type() + + [ { jjtThis.bang = true; }] + ) + { + return jjtThis; + } +} + +// Type System +TypeSystemDefinition TypeSystemDefinition(): {} +{ + ( + jjtThis.schemaDefinition = SchemaDefinition() + | + jjtThis.typeDefinition = TypeDefinition() + | + jjtThis.typeExtensionDefinition = TypeExtensionDefinition() + | + jjtThis.directiveDefinition = DirectiveDefinition() + ) + { + return jjtThis; + } +} + +SchemaDefinition SchemaDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + OperationTypeDefinition lastOpTypeDef; +} +{ + ( + + (jjtThis.directives = Directives())? + + ( + lastOpTypeDef = OperationTypeDefinition() { jjtThis.operationTypeDefinitions.add(lastOpTypeDef); } + )+ + + ) + { + return jjtThis; + } +} + +OperationTypeDefinition OperationTypeDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + +} +{ + ( + jjtThis.operationType = OperationType() + + jjtThis.typeName = TypeName() + ) + { + return jjtThis; + } +} + +TypeDefinition TypeDefinition(): { + TypeDefinition result; +} +{ + ( + result = ScalarTypeDefinition() + | + result = ObjectTypeDefinition() + | + result = InterfaceTypeDefinition() + | + result = UnionTypeDefinition() + | + result = EnumTypeDefinition() + | + result = InputObjectTypeDefinition() + ) + { + return result; + } +} + +ScalarTypeDefinition ScalarTypeDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); +} +{ + ( + + jjtThis.name = Name() + (jjtThis.directives = Directives())? + ) + { + return jjtThis; + } +} + +ObjectTypeDefinition ObjectTypeDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + FieldDefinition lastFieldDef; +} +{ + ( + + jjtThis.name = Name() { + + } + ( jjtThis.implementsInterface = ImplementsInterface() )? + ( jjtThis.directives = Directives() )? + + ( lastFieldDef = FieldDefinition() {jjtThis.fieldDefinitions.add(lastFieldDef); })+ + + ) + { + return jjtThis; + } +} + +ImplementsInterface ImplementsInterface(): { + TypeName lastTypeName; +} +{ + ( + + ( + lastTypeName = TypeName() { jjtThis.typeNames.add(lastTypeName); } + )+ + ) + { + return jjtThis; + } +} + +FieldDefinition FieldDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + +} +{ + ( + jjtThis.name = Name() + (jjtThis.argumentsDefinition = ArgumentsDefinition())? + + jjtThis.type = Type() + (jjtThis.directives = Directives())? + ) + { + return jjtThis; + } +} + +ArgumentsDefinition ArgumentsDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + + InputValueDefinition lastVal; + +} +{ + ( + + (lastVal = InputValueDefinition() { jjtThis.inputValueDefinitions.add(lastVal); } )+ + + ) + { + return jjtThis; + } +} + +InputValueDefinition InputValueDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); +} +{ + ( + jjtThis.name = Name() + + jjtThis.type = Type() + (jjtThis.defaultValue = DefaultValue())? + (jjtThis.directives = Directives())? + ) + { + return jjtThis; + } +} + +InterfaceTypeDefinition InterfaceTypeDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + FieldDefinition lastFieldDef; +} +{ + ( + + jjtThis.name = Name() + (jjtThis.directives = Directives())? + + (lastFieldDef = FieldDefinition() { jjtThis.fieldDefinitions.add(lastFieldDef); } )+ + + ) + { + return jjtThis; + } +} + +UnionTypeDefinition UnionTypeDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); +} +{ + ( + + jjtThis.name = Name() + (jjtThis.directives = Directives())? + + jjtThis.unionMembers = UnionMembers() + ) + { + return jjtThis; + } +} + +UnionMembers UnionMembers(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + + TypeName lastTypeName; +} +{ + lastTypeName = TypeName() { + jjtThis.typeNames.add(lastTypeName); + } + ( + + lastTypeName = TypeName() { + jjtThis.typeNames.add(lastTypeName); + } + )* +} + +EnumTypeDefinition EnumTypeDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + EnumValueDefinition lastEnumValDef; +} +{ + ( + + jjtThis.name = Name() { + + } + (jjtThis.directives = Directives())? + + (lastEnumValDef = EnumValueDefinition() { jjtThis.enumValueDefinitions.add(lastEnumValDef); } )+ + + ) + { + return jjtThis; + } +} + +EnumValueDefinition EnumValueDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + +} +{ + ( + jjtThis.enumValue = EnumValue() + ( jjtThis.directives = Directives() )? + ) + { + return jjtThis; + } +} + +InputObjectTypeDefinition InputObjectTypeDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + + InputValueDefinition lastInputValDef; +} +{ + ( + + jjtThis.name = Name() + (jjtThis.directives = Directives())? + + ( lastInputValDef = InputValueDefinition() { jjtThis.inputValueDefinitions.add(lastInputValDef); } )+ + + ) + { + return jjtThis; + } +} + +TypeExtensionDefinition TypeExtensionDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + +} +{ + ( + + jjtThis.objectTypeDefinition = ObjectTypeDefinition() + ) + { + return jjtThis; + } +} + +DirectiveDefinition DirectiveDefinition(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); +} +{ + ( + + jjtThis.name = Name() + (jjtThis.argumentsDefinition = ArgumentsDefinition())? + + jjtThis.directiveLocations = DirectiveLocations() + ) + { + return jjtThis; + } +} + +DirectiveLocation DirectiveLocation(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); +} +{ + jjtThis.name = Name() + { + return jjtThis; + } +} + +DirectiveLocations DirectiveLocations(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + DirectiveLocation lastDirLocation; +} +{ + ( + lastDirLocation = DirectiveLocation() + { jjtThis.directiveLocations.add(lastDirLocation); } + ( + + lastDirLocation = DirectiveLocation() + { jjtThis.directiveLocations.add(lastDirLocation); } + )* + ) + { + return jjtThis; + } +} + +// Tokens +BooleanValue BooleanValue(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + +} +{ + ( + ( { jjtThis.val = true;} ) + | + ( { jjtThis.val = false;} ) + ) + { + return jjtThis; + } +} + +IntValue IntValue(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + Token literal; +} +{ + literal = { + jjtThis.val = Integer.parseInt(literal.image); + return jjtThis; + } +} + +FloatValue FloatValue(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + Token literal; +} +{ + literal = { + jjtThis.stringValue = literal.image; + //TODO parse! + return jjtThis; + } +} + +StringValue StringValue(): { + int tokenId = tokenId(); + int line = line(); + int column = column(); + Token literal; +} +{ + literal = { + jjtThis.val = literal.image; + return jjtThis; + } +} + +OperationType OperationType(): { +} +{ + ( + ( {jjtThis.mutation = true;} ) + | + ( {jjtThis.query = true;} ) + ) + { + return jjtThis; + } +} diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/AbstractCharStream.java b/graphql/src/main/java/com/arcadedb/graphql/parser/AbstractCharStream.java new file mode 100755 index 0000000000..2e62c604c8 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/AbstractCharStream.java @@ -0,0 +1,489 @@ +/* Generated by: ParserGeneratorCC: Do not edit this line. AbstractCharStream.java Version 1.1 */ +/* ParserGeneratorCCOptions:SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +/** + * An implementation of interface CharStream, where the stream is assumed to + * contain only ASCII characters (without unicode processing). + */ + +public abstract class AbstractCharStream implements CharStream { + /** + * Default buffer size if nothing is specified + */ + public static final int DEFAULT_BUF_SIZE = 4096; + + static final int hexval(final char c) throws java.io.IOException { + switch (c) { + case '0': + return 0; + case '1': + return 1; + case '2': + return 2; + case '3': + return 3; + case '4': + return 4; + case '5': + return 5; + case '6': + return 6; + case '7': + return 7; + case '8': + return 8; + case '9': + return 9; + case 'a': + case 'A': + return 10; + case 'b': + case 'B': + return 11; + case 'c': + case 'C': + return 12; + case 'd': + case 'D': + return 13; + case 'e': + case 'E': + return 14; + case 'f': + case 'F': + return 15; + default: + throw new java.io.IOException("Invalid hex char '" + c + "' (=" + (int) c + ") provided!"); + } + } + + /** + * Tab size for formatting. Usually in the range 1 to 8. + */ + private int m_nTabSize = 1; + + /** + * Internal circular buffer + */ + protected char[] buffer; + + /** + * Overall buffer size - same as buffer.length + */ + protected int bufsize; + + /** + * Current read position in buffer. + */ + protected int bufpos; + + /** + * The number of unoccupied buffer array positions + */ + protected int available; + + /** + * The first array index (of `buffer`) that the current token starts + */ + protected int tokenBegin; + + /** + * Characters in the backup/pushBack buffer + */ + protected int inBuf; + protected int maxNextCharInd; + + private int[] m_aBufLine; + private int[] m_aBufColumn; + + // Current line number + private int m_nLineNo; + // Current column number + private int m_nColumnNo; + + // Was the previous character a "\r" char? + private boolean m_bPrevCharIsCR; + // Was the previous character a "\n" char? + private boolean m_bPrevCharIsLF; + + // Is line/column tracking enabled? + private boolean m_bTrackLineColumn = true; + + /** + * Constructor. + */ + public AbstractCharStream(final int nStartLine, final int nStartColumn, final int nBufferSize) { + reInit(nStartLine, nStartColumn, nBufferSize); + } + + /** + * Reinitialise. + */ + public final void reInit(final int nStartLine, final int nStartColumn, final int nBufferSize) { + m_nLineNo = nStartLine; + m_nColumnNo = nStartColumn - 1; + m_bPrevCharIsCR = false; + m_bPrevCharIsLF = false; + if (buffer == null || nBufferSize != buffer.length) { + bufsize = nBufferSize; + available = nBufferSize; + buffer = new char[nBufferSize]; + m_aBufLine = new int[nBufferSize]; + m_aBufColumn = new int[nBufferSize]; + } + maxNextCharInd = 0; + inBuf = 0; + tokenBegin = 0; + bufpos = -1; + } + + /** + * Read from the underlying stream. + * + * @param aBuf the buffer to be filled + * @param nOfs The offset into the buffer. 0-based + * @param nLen Number of chars to read. + * + * @return Number of effective chars read, or -1 on error. + */ + protected abstract int streamRead(char[] aBuf, int nOfs, int nLen) throws java.io.IOException; + + /** + * Close the underlying stream. + * + * @throws java.io.IOException If closing fails. + */ + protected abstract void streamClose() throws java.io.IOException; + + // Override this method if you need more aggressive buffer size expansion + protected int getBufSizeAfterExpansion() { + // Double the size by default + return bufsize * 2; + } + + protected void expandBuff(final boolean bWrapAround) { + // Get the new buffer size + final int nNewBufSize = getBufSizeAfterExpansion(); + + final char[] newbuffer = new char[nNewBufSize]; + final int[] newbufline = new int[nNewBufSize]; + final int[] newbufcolumn = new int[nNewBufSize]; + + // Number of chars to be preserved + final int nPreservedChars = bufsize - tokenBegin; + + if (bWrapAround) { + // Move from offset "tokenBegin" to offset 0 + // arraycopy(src, srcPos, dest, destPos, length) + + // copy the "tail end" to the "start" (index 0) of the new buffer array + System.arraycopy(buffer, tokenBegin, newbuffer, 0, nPreservedChars); + + // copy the remaining "wrap around" content of the buffer from the start of the original buffer (starting at srcPos index 0) + System.arraycopy(buffer, 0, newbuffer, nPreservedChars, bufpos); + + // swap the new buffer in place of the old buffer + buffer = newbuffer; + + System.arraycopy(m_aBufLine, tokenBegin, newbufline, 0, nPreservedChars); + System.arraycopy(m_aBufLine, 0, newbufline, nPreservedChars, bufpos); + m_aBufLine = newbufline; + + System.arraycopy(m_aBufColumn, tokenBegin, newbufcolumn, 0, nPreservedChars); + System.arraycopy(m_aBufColumn, 0, newbufcolumn, nPreservedChars, bufpos); + m_aBufColumn = newbufcolumn; + + bufpos += nPreservedChars; + maxNextCharInd = bufpos; + } else { + // Move from offset "tokenBegin" to offset 0 + + System.arraycopy(buffer, tokenBegin, newbuffer, 0, nPreservedChars); + buffer = newbuffer; + + System.arraycopy(m_aBufLine, tokenBegin, newbufline, 0, nPreservedChars); + m_aBufLine = newbufline; + + System.arraycopy(m_aBufColumn, tokenBegin, newbufcolumn, 0, nPreservedChars); + m_aBufColumn = newbufcolumn; + + bufpos -= tokenBegin; + maxNextCharInd = bufpos; + } + + // Increase buffer size + bufsize = nNewBufSize; + available = nNewBufSize; + tokenBegin = 0; + } + + protected final void internalAdjustBuffSize() { + final int nHalfBufferSize = bufsize / 2; + if (available == bufsize) { + if (tokenBegin < 0) { + // If this method is called from "beginToken()" + // Just refill the buffer from the start + bufpos = 0; + maxNextCharInd = 0; + } else if (tokenBegin > nHalfBufferSize) { + // The token started in the second half - fill the front part + bufpos = 0; + maxNextCharInd = 0; + + // Available bytes are > 50% + available = tokenBegin; + } else { + // Token starts in the first half + // just append to existing buffer + expandBuff(false); + } + } else { + // A token was read across array boundaries + if (available > tokenBegin) { + available = bufsize; + } else if ((tokenBegin - available) < nHalfBufferSize) { + expandBuff(true); + } else { + available = tokenBegin; + } + } + } + + protected void fillBuff() throws java.io.IOException { + if (maxNextCharInd == available) + internalAdjustBuffSize(); + + try { + // Read from underlying stream + final int nCharsRead = streamRead(buffer, maxNextCharInd, available - maxNextCharInd); + if (nCharsRead == -1) { + // We reached the end of the file + streamClose(); + + // Caught down below and re-thrown + throw new java.io.IOException("PGCC end of stream"); + } + maxNextCharInd += nCharsRead; + } catch (final java.io.IOException ex) { + --bufpos; + // ?What is the reason of this? Backup of 0 does nothing + backup(0); + if (tokenBegin == -1) { + // Error occurred in "beginToken()" + tokenBegin = bufpos; + } + throw ex; + } + } + + protected final void internalSetBufLineColumn(final int nLine, final int nColumn) { + m_aBufLine[bufpos] = nLine; + m_aBufColumn[bufpos] = nColumn; + } + + protected final void internalUpdateLineColumn(final char c) { + m_nColumnNo++; + + if (m_bPrevCharIsLF) { + // It's a "\r\n" or "\n" + // Start of a new line + m_bPrevCharIsLF = false; + m_nColumnNo = 1; + m_nLineNo++; + } else if (m_bPrevCharIsCR) { + m_bPrevCharIsCR = false; + if (c == '\n') { + // It's a "\r\n" + m_bPrevCharIsLF = true; + } else { + // It's only a "\r" + m_nColumnNo = 1; + m_nLineNo++; + } + } + + switch (c) { + case '\r': + m_bPrevCharIsCR = true; + break; + case '\n': + m_bPrevCharIsLF = true; + break; + case '\t': + m_nColumnNo--; + m_nColumnNo += (m_nTabSize - (m_nColumnNo % m_nTabSize)); + break; + } + + internalSetBufLineColumn(m_nLineNo, m_nColumnNo); + } + + public char readChar() throws java.io.IOException { + if (inBuf > 0) { + // Something is left from last backup + --inBuf; + + ++bufpos; + if (bufpos == bufsize) { + // Buffer overflow + bufpos = 0; + } + + return buffer[bufpos]; + } + + ++bufpos; + if (bufpos >= maxNextCharInd) + fillBuff(); + + final char c = buffer[bufpos]; + + if (m_bTrackLineColumn) + internalUpdateLineColumn(c); + return c; + } + + public char beginToken() throws java.io.IOException { + tokenBegin = -1; + final char c = readChar(); + tokenBegin = bufpos; + return c; + } + + public int getBeginColumn() { + return m_aBufColumn[tokenBegin]; + } + + public int getBeginLine() { + return m_aBufLine[tokenBegin]; + } + + public int getEndColumn() { + return m_aBufColumn[bufpos]; + } + + public int getEndLine() { + return m_aBufLine[bufpos]; + } + + public void backup(final int nAmount) { + if (nAmount > bufsize) + throw new IllegalStateException("Cannot back " + nAmount + " chars which is larger than the internal buffer size (" + bufsize + ")"); + + inBuf += nAmount; + bufpos -= nAmount; + if (bufpos < 0) { + // Buffer underflow (modulo) + bufpos += bufsize; + } + } + + public String getImage() { + if (bufpos >= tokenBegin) { + // from tokenBegin to bufpos + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + } + + // from tokenBegin to bufsize, and from 0 to bufpos + return new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); + } + + public char[] getSuffix(final int len) { + char[] ret = new char[len]; + if ((bufpos + 1) >= len) { + // one piece + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + } else { + // Wrap around + final int nPart1 = len - bufpos - 1; + System.arraycopy(buffer, bufsize - nPart1, ret, 0, nPart1); + System.arraycopy(buffer, 0, ret, nPart1, bufpos + 1); + } + return ret; + } + + public void done() { + buffer = null; + m_aBufLine = null; + m_aBufColumn = null; + } + + public final int getTabSize() { + return m_nTabSize; + } + + public final void setTabSize(final int nTabSize) { + m_nTabSize = nTabSize; + } + + /** + * Method to adjust line and column numbers for the start of a token. + * This is used internally to + */ + public final void adjustBeginLineColumn(final int nNewLine, final int newCol) { + int start = tokenBegin; + int newLine = nNewLine; + + int len; + if (bufpos >= tokenBegin) { + len = bufpos - tokenBegin + inBuf + 1; + } else { + len = bufsize - tokenBegin + bufpos + 1 + inBuf; + } + + int i = 0; + int j = 0; + int k = 0; + int nextColDiff = 0; + int columnDiff = 0; + + // TODO disassemble meaning and split up + while (i < len && m_aBufLine[j = start % bufsize] == m_aBufLine[k = ++start % bufsize]) { + m_aBufLine[j] = newLine; + nextColDiff = columnDiff + m_aBufColumn[k] - m_aBufColumn[j]; + m_aBufColumn[j] = newCol + columnDiff; + columnDiff = nextColDiff; + i++; + } + + if (i < len) { + m_aBufLine[j] = newLine++; + m_aBufColumn[j] = newCol + columnDiff; + + while (i++ < len) { + // TODO disassemble meaning and split up + if (m_aBufLine[j = start % bufsize] != m_aBufLine[++start % bufsize]) + m_aBufLine[j] = newLine++; + else + m_aBufLine[j] = newLine; + } + } + + m_nLineNo = m_aBufLine[j]; + m_nColumnNo = m_aBufColumn[j]; + } + + /** + * @return the current line number. 0-based. + */ + protected final int getLine() { + return m_nLineNo; + } + + /** + * @return the current column number. 0-based. + */ + protected final int getColumn() { + return m_nColumnNo; + } + + public final boolean isTrackLineColumn() { + return m_bTrackLineColumn; + } + + public final void setTrackLineColumn(final boolean bTrackLineColumn) { + m_bTrackLineColumn = bTrackLineColumn; + } +} +/* ParserGeneratorCC - OriginalChecksum=07d465a794b9a51b32dad0a8743ee831 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/AbstractValue.java b/graphql/src/main/java/com/arcadedb/graphql/parser/AbstractValue.java new file mode 100755 index 0000000000..cb88ba2567 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/AbstractValue.java @@ -0,0 +1,29 @@ +/* Generated by: JJTree: Do not edit this line. VariableLiteral.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public abstract class AbstractValue extends SimpleNode { + protected Name name; + + public AbstractValue(int id) { + super(id); + } + + public AbstractValue(GraphQLParser p, int id) { + super(p, id); + } + + public abstract Object getValue(); + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public String getName() { + return name != null ? name.value : null; + } +} +/* ParserGeneratorCC - OriginalChecksum=1d24a436d5861d19357de949dd126579 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Argument.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Argument.java new file mode 100755 index 0000000000..d63d4347b6 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Argument.java @@ -0,0 +1,32 @@ +/* Generated by: JJTree: Do not edit this line. Argument.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class Argument extends SimpleNode { + protected Name name; + protected ValueWithVariable valueWithVariable; + + public Argument(int id) { + super(id); + } + + public Argument(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public String getName() { + return name != null ? name.value : null; + } + + public ValueWithVariable getValueWithVariable() { + return valueWithVariable; + } +} +/* ParserGeneratorCC - OriginalChecksum=5812dd8322af831327adf8100aeb4693 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Arguments.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Arguments.java new file mode 100755 index 0000000000..db4272f912 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Arguments.java @@ -0,0 +1,29 @@ +/* Generated by: JJTree: Do not edit this line. Arguments.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.*; + +public class Arguments extends SimpleNode { + protected final List arguments = new ArrayList<>(); + + public Arguments(int id) { + super(id); + } + + public Arguments(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public List getList() { + return arguments; + } +} +/* ParserGeneratorCC - OriginalChecksum=262d81780905472eac1cf2b9e5525261 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ArgumentsDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ArgumentsDefinition.java new file mode 100755 index 0000000000..0fdb278c66 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ArgumentsDefinition.java @@ -0,0 +1,29 @@ +/* Generated by: JJTree: Do not edit this line. ArgumentsDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.*; + +public class ArgumentsDefinition extends SimpleNode { + protected List inputValueDefinitions = new ArrayList<>(); + + public ArgumentsDefinition(int id) { + super(id); + } + + public ArgumentsDefinition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public List getInputValueDefinitions() { + return inputValueDefinitions; + } +} +/* ParserGeneratorCC - OriginalChecksum=70669c0b366fb4254a0d1083b0949a0c (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/BooleanValue.java b/graphql/src/main/java/com/arcadedb/graphql/parser/BooleanValue.java new file mode 100755 index 0000000000..9f294aaca9 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/BooleanValue.java @@ -0,0 +1,33 @@ +/* Generated by: JJTree: Do not edit this line. BooleanValue.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class BooleanValue extends AbstractValue { + protected boolean val; + + public BooleanValue(int id) { + super(id); + } + + public BooleanValue(GraphQLParser p, int id) { + super(p, id); + } + + @Override + public Object getValue() { + return null; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + @Override + public String toString() { + return "BooleanValue{" + val + '}'; + } +} +/* ParserGeneratorCC - OriginalChecksum=1bccd1d0355cd11bae5a23b0053abee0 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/CharStream.java b/graphql/src/main/java/com/arcadedb/graphql/parser/CharStream.java new file mode 100755 index 0000000000..019cc8740d --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/CharStream.java @@ -0,0 +1,125 @@ +/* Generated by: ParserGeneratorCC: Do not edit this line. CharStream.java Version 1.1 */ +/* ParserGeneratorCCOptions:SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +/** + * This interface describes a character stream that maintains line and + * column number positions of the characters. It also has the capability + * to backup the stream to some extent. An implementation of this + * interface is used in the TokenManager implementation generated by + * JavaCCParser. + * + * All the methods except backup can be implemented in any fashion. backup + * needs to be implemented correctly for the correct operation of the lexer. + * Rest of the methods are all used to get information like line number, + * column number and the String that constitutes a token and are not used + * by the lexer. Hence their implementation won't affect the generated lexer's + * operation. + */ + +public +interface CharStream { + /** + * Get the next character from the selected input. The method + * of selecting the input is the responsibility of the class + * implementing this interface. + * @return the next character from the selected input + * @throws java.io.IOException on IO error + */ + char readChar() throws java.io.IOException; + + /** + * @return the column number of the first character for current token (being + * matched after the last call to beginToken). + */ + int getBeginColumn(); + + /** + * @return the line number of the first character for current token (being + * matched after the last call to BeginToken). + */ + int getBeginLine(); + + /** + * @return the column number of the last character for current token (being + * matched after the last call to BeginToken). + */ + int getEndColumn(); + + /** + * @return the line number of the last character for current token (being + * matched after the last call to BeginToken). + */ + int getEndLine(); + + /** + * Backs up the input stream by amount steps. Lexer calls this method if it + * had already read some characters, but could not use them to match a + * (longer) token. So, they will be used again as the prefix of the next + * token and it is the implemetation's responsibility to do this right. + * @param amount Number of chars to back up. + */ + void backup(int amount); + + /** + * @return the next character that marks the beginning of the next token. + * All characters must remain in the buffer between two successive calls + * to this method to implement backup correctly. + */ + char beginToken() throws java.io.IOException; + + /** + * @return a string made up of characters from the marked token beginning + * to the current buffer position. Implementations have the choice of returning + * anything that they want to. For example, for efficiency, one might decide + * to just return null, which is a valid implementation. + */ + String getImage(); + + /** + * @return an array of characters that make up the suffix of length 'len' for + * the currently matched token. This is used to build up the matched string + * for use in actions in the case of MORE. A simple and inefficient + * implementation of this is as follows: + *
+   *   {
+   *      String t = getImage();
+   *      return t.substring(t.length() - len, t.length()).toCharArray();
+   *   }
+   * 
+ */ + char[] getSuffix(int len); + + /** + * The lexer calls this function to indicate that it is done with the stream + * and hence implementations can free any resources held by this class. + * Again, the body of this function can be just empty and it will not + * affect the lexer's operation. + */ + void done(); + + // Getters and setters + + /** + * @return Current tab size. + */ + int getTabSize(); + + /** + * Set the tab size to use. + * @param i spaces per tab + */ + void setTabSize(int i); + + /** + * @return true if line number and column numbers should be tracked. + */ + boolean isTrackLineColumn(); + + /** + * Enable or disable line number and column number tracking. + * @param trackLineColumn true to track it, false to not do it. + */ + void setTrackLineColumn(boolean trackLineColumn); +} +/* ParserGeneratorCC - OriginalChecksum=e3c4671e3d741e62a62dca2506e9cd85 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/DefaultValue.java b/graphql/src/main/java/com/arcadedb/graphql/parser/DefaultValue.java new file mode 100755 index 0000000000..c9911dfda5 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/DefaultValue.java @@ -0,0 +1,27 @@ +/* Generated by: JJTree: Do not edit this line. DefaultValue.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class DefaultValue extends SimpleNode { + protected Value value; + + public DefaultValue(int id) { + super(id); + } + + public DefaultValue(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public Value getValue() { + return value; + } +} +/* ParserGeneratorCC - OriginalChecksum=6e1bd5273dd69cf0cfa990d710b46276 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Definition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Definition.java new file mode 100755 index 0000000000..57bdf29930 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Definition.java @@ -0,0 +1,21 @@ +/* Generated by: JJTree: Do not edit this line. Definition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class Definition extends SimpleNode { + public Definition(int id) { + super(id); + } + + public Definition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=e08f7a082c359f9df4c56e489e349548 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Directive.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Directive.java new file mode 100755 index 0000000000..846db71b84 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Directive.java @@ -0,0 +1,33 @@ +/* Generated by: JJTree: Do not edit this line. Directive.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class Directive extends SimpleNode { + + protected Name name; + protected Arguments arguments; + + public Directive(int id) { + super(id); + } + + public Directive(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public String getName() { + return name != null ? name.value : null; + } + + public Arguments getArguments() { + return arguments; + } +} +/* ParserGeneratorCC - OriginalChecksum=2ab2407d8f843d5e31ff6480a48183d5 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/DirectiveDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/DirectiveDefinition.java new file mode 100755 index 0000000000..074c894a02 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/DirectiveDefinition.java @@ -0,0 +1,30 @@ +/* Generated by: JJTree: Do not edit this line. DirectiveDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class DirectiveDefinition extends SimpleNode { + + protected Name name; + protected ArgumentsDefinition argumentsDefinition; + protected DirectiveLocations directiveLocations; + + public DirectiveDefinition(int id) { + super(id); + } + + public DirectiveDefinition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public String getName() { + return name != null ? name.value : null; + } +} +/* ParserGeneratorCC - OriginalChecksum=4b1cd90db8c14c7ef8c7de1a56fd24a0 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/DirectiveLocation.java b/graphql/src/main/java/com/arcadedb/graphql/parser/DirectiveLocation.java new file mode 100755 index 0000000000..e68e9a46f0 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/DirectiveLocation.java @@ -0,0 +1,27 @@ +/* Generated by: JJTree: Do not edit this line. DirectiveLocation.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class DirectiveLocation extends SimpleNode { + protected Name name; + + public DirectiveLocation(int id) { + super(id); + } + + public DirectiveLocation(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public String getName() { + return name != null ? name.value : null; + } +} +/* ParserGeneratorCC - OriginalChecksum=ab5441899f62bc88ebd8e05a4fb75d82 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/DirectiveLocations.java b/graphql/src/main/java/com/arcadedb/graphql/parser/DirectiveLocations.java new file mode 100755 index 0000000000..95bbd57167 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/DirectiveLocations.java @@ -0,0 +1,28 @@ +/* Generated by: JJTree: Do not edit this line. DirectiveLocations.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.ArrayList; +import java.util.List; + +public +class DirectiveLocations extends SimpleNode { + + protected List directiveLocations = new ArrayList<>(); + + public DirectiveLocations(int id) { + super(id); + } + + public DirectiveLocations(GraphQLParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return + visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=f3ec1634dd11be6c17584efdd94bfbeb (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Directives.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Directives.java new file mode 100755 index 0000000000..74bfbad7f5 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Directives.java @@ -0,0 +1,29 @@ +/* Generated by: JJTree: Do not edit this line. Directives.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.*; + +public class Directives extends SimpleNode { + List directives = new ArrayList<>(); + + public Directives(int id) { + super(id); + } + + public Directives(GraphQLParser p, int id) { + super(p, id); + } + + public List getDirectives() { + return directives; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=f93ba7b3c8a0e407e3d07fabf22ecdf2 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Document.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Document.java new file mode 100755 index 0000000000..99f527719b --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Document.java @@ -0,0 +1,30 @@ +/* Generated by: JJTree: Do not edit this line. Document.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.*; + +public class Document extends SimpleNode { + + protected List definitions = new ArrayList<>(); + + public Document(int id) { + super(id); + } + + public Document(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public List getDefinitions() { + return definitions; + } +} +/* ParserGeneratorCC - OriginalChecksum=8ab9229334dc0c8cb1aec80c77abf8f6 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/EnumTypeDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/EnumTypeDefinition.java new file mode 100755 index 0000000000..86a4699719 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/EnumTypeDefinition.java @@ -0,0 +1,32 @@ +/* Generated by: JJTree: Do not edit this line. EnumTypeDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.*; + +public class EnumTypeDefinition extends TypeDefinition { + + protected Name name; + protected Directives directives; + protected List enumValueDefinitions = new ArrayList<>(); + + public EnumTypeDefinition(int id) { + super(id); + } + + public EnumTypeDefinition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public String getName() { + return name != null ? name.value : null; + } +} +/* ParserGeneratorCC - OriginalChecksum=5f52973b5c235ea0e825b12676a56e38 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/EnumValue.java b/graphql/src/main/java/com/arcadedb/graphql/parser/EnumValue.java new file mode 100755 index 0000000000..dbfb746b96 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/EnumValue.java @@ -0,0 +1,26 @@ +/* Generated by: JJTree: Do not edit this line. EnumValue.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class EnumValue extends AbstractValue { + public EnumValue(int id) { + super(id); + } + + public EnumValue(GraphQLParser p, int id) { + super(p, id); + } + + @Override + public Object getValue() { + return children.length > 0 ? ((Name) children[0]).value : null; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=30feac3e906da5a960df63eb165a4a50 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/EnumValueDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/EnumValueDefinition.java new file mode 100755 index 0000000000..c3b2b22426 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/EnumValueDefinition.java @@ -0,0 +1,25 @@ +/* Generated by: JJTree: Do not edit this line. EnumValueDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class EnumValueDefinition extends SimpleNode { + + protected EnumValue enumValue; + protected Directives directives; + + public EnumValueDefinition(int id) { + super(id); + } + + public EnumValueDefinition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=d501ea804071d45439cffe6e78b75781 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Field.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Field.java new file mode 100755 index 0000000000..16b454338e --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Field.java @@ -0,0 +1,48 @@ +/* Generated by: JJTree: Do not edit this line. Field.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class Field extends SimpleNode { + + protected Name name; + protected Arguments arguments; + protected Directives directives; + protected SelectionSet selectionSet; + + public Field(Name name, int line, int column, int tokenId) { + this(-1); + this.name = name; + } + + public Field(int id) { + super(id); + } + + public Field(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public Arguments getArguments() { + return arguments; + } + + public String getName() { + return name != null ? name.value : null; + } + + public SelectionSet getSelectionSet() { + return selectionSet; + } + + public Directives getDirectives() { + return directives; + } +} +/* ParserGeneratorCC - OriginalChecksum=2b182b10a025776d444c1f179f3e7ff4 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/FieldDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/FieldDefinition.java new file mode 100755 index 0000000000..2e8724cf74 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/FieldDefinition.java @@ -0,0 +1,43 @@ +/* Generated by: JJTree: Do not edit this line. FieldDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class FieldDefinition extends SimpleNode { + + protected Name name; + protected ArgumentsDefinition argumentsDefinition; + protected Type type; + protected Directives directives; + + public FieldDefinition(int id) { + super(id); + } + + public FieldDefinition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public String getName() { + return name != null ? name.value : null; + } + + public Type getType() { + return type; + } + + public Directives getDirectives() { + return directives; + } + + public ArgumentsDefinition getArgumentsDefinition() { + return argumentsDefinition; + } +} +/* ParserGeneratorCC - OriginalChecksum=6128650aa4801ab60df8105dc264845f (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/FieldWithAlias.java b/graphql/src/main/java/com/arcadedb/graphql/parser/FieldWithAlias.java new file mode 100755 index 0000000000..29981ed486 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/FieldWithAlias.java @@ -0,0 +1,37 @@ +/* Generated by: JJTree: Do not edit this line. FieldWithAlias.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class FieldWithAlias extends SimpleNode { + + Name alias; + protected Name name; + protected Arguments arguments; + protected Directives directives; + protected SelectionSet selectionSet; + + public FieldWithAlias(Name alias, int line, int column, int tokenId) { + this(-1); + this.alias = alias; + } + + public FieldWithAlias(int id) { + super(id); + } + + public FieldWithAlias(GraphQLParser p, int id) { + super(p, id); + } + + public String getName() { + return name != null ? name.value : null; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=46c98ffd2c99423a541cd9d46c3fc779 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/FloatValue.java b/graphql/src/main/java/com/arcadedb/graphql/parser/FloatValue.java new file mode 100755 index 0000000000..fa3302ebf5 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/FloatValue.java @@ -0,0 +1,33 @@ +/* Generated by: JJTree: Do not edit this line. FloatValue.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class FloatValue extends AbstractValue { + protected String stringValue; + + public FloatValue(int id) { + super(id); + } + + public FloatValue(GraphQLParser p, int id) { + super(p, id); + } + + @Override + public Object getValue() { + return stringValue; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + @Override + public String toString() { + return "FloatValue{" + stringValue + '}'; + } +} +/* ParserGeneratorCC - OriginalChecksum=6629a12b125a5d138e3a3f27eae0b061 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/FragmentDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/FragmentDefinition.java new file mode 100755 index 0000000000..7bd60be660 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/FragmentDefinition.java @@ -0,0 +1,27 @@ +/* Generated by: JJTree: Do not edit this line. FragmentDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class FragmentDefinition extends Definition { + + protected FragmentName name; + protected TypeCondition type; + protected Directives directives; + protected SelectionSet selectionSet; + + public FragmentDefinition(int id) { + super(id); + } + + public FragmentDefinition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=588294b34a10e410fa87ff81f52b5be4 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/FragmentName.java b/graphql/src/main/java/com/arcadedb/graphql/parser/FragmentName.java new file mode 100755 index 0000000000..b0161b3db3 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/FragmentName.java @@ -0,0 +1,27 @@ +/* Generated by: JJTree: Do not edit this line. FragmentName.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class FragmentName extends SimpleNode { + protected Name name; + + public FragmentName(int id) { + super(id); + } + + public FragmentName(GraphQLParser p, int id) { + super(p, id); + } + + public String getName() { + return name != null ? name.value : null; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=0cfaea8d7a4f254967c4a295b1af21a3 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/FragmentSpread.java b/graphql/src/main/java/com/arcadedb/graphql/parser/FragmentSpread.java new file mode 100755 index 0000000000..0cef41e0d3 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/FragmentSpread.java @@ -0,0 +1,25 @@ +/* Generated by: JJTree: Do not edit this line. FragmentSpread.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class FragmentSpread extends SimpleNode { + + protected FragmentName name; + protected Directives directives; + + public FragmentSpread(int id) { + super(id); + } + + public FragmentSpread(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=d963ff13f71ad79b35665827792399de (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParser.java b/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParser.java new file mode 100755 index 0000000000..38283ddd54 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParser.java @@ -0,0 +1,3374 @@ +/* GraphQLParser.java */ +/* Generated by: JJTree&ParserGeneratorCC: Do not edit this line. GraphQLParser.java */ +package com.arcadedb.graphql.parser; + +import java.io.*; +import com.arcadedb.query.sql.parser.JavaCharStream; + +public class GraphQLParser/*@bgen(jjtree)*/implements GraphQLParserTreeConstants, GraphQLParserConstants {/*@bgen(jjtree)*/ + protected JJTGraphQLParserState jjtree = new JJTGraphQLParserState();private int tokenId = 0; + + + public static Document parse(String query) throws ParseException { + return new GraphQLParser(new SimpleCharStream(new StringReader(query))).Document(); + } + + + private int line() { + return token_source.input_stream.getBeginLine(); + } + + private int column() { + return token_source.input_stream.getBeginColumn(); + } + + private int tokenId() { + return tokenId++; + } + +// Document structure + final public Document Document() throws ParseException {/*@bgen(jjtree) Document */ + Document jjtn000 = new Document(JJTDOCUMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + Definition lastDef; + try { + label_1: + while (true) { + lastDef = Definition(); +jjtn000.definitions.add(lastDef); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case OCBR: + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE:{ + break; + } + default: + jj_la1[0] = jj_gen; + break label_1; + } + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public Definition Definition() throws ParseException {/*@bgen(jjtree) Definition */ + Definition jjtn000 = new Definition(JJTDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));Definition def; + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case OCBR: + case QUERY: + case MUTATION:{ + def = OperationDefinition(); + break; + } + case FRAGMENT:{ + def = FragmentDefinition(); + break; + } + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE:{ + def = TypeSystemDefinition(); + break; + } + default: + jj_la1[1] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return def;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public OperationDefinition OperationDefinition() throws ParseException {/*@bgen(jjtree) OperationDefinition */ + OperationDefinition jjtn000 = new OperationDefinition(JJTOPERATIONDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case OCBR:{ + jjtn000.selectionSet = SelectionSet(); + break; + } + case QUERY: + case MUTATION:{ + jjtn000.operationType = OperationType(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + jjtn000.name = Name(); + break; + } + default: + jj_la1[2] = jj_gen; + ; + } + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case OPAR:{ + jjtn000.variableDefinitions = VariableDefinitions(); + break; + } + default: + jj_la1[3] = jj_gen; + ; + } + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[4] = jj_gen; + ; + } + jjtn000.selectionSet = SelectionSet(); + break; + } + default: + jj_la1[5] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public VariableDefinitions VariableDefinitions() throws ParseException {/*@bgen(jjtree) VariableDefinitions */ + VariableDefinitions jjtn000 = new VariableDefinitions(JJTVARIABLEDEFINITIONS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + VariableDefinition lastDef; + try { + jj_consume_token(OPAR); + label_2: + while (true) { + lastDef = VariableDefinition(); +jjtn000.variableDefinitions.add(lastDef); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case DOLLAR:{ + break; + } + default: + jj_la1[6] = jj_gen; + break label_2; + } + } + jj_consume_token(CPAR); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public VariableDefinition VariableDefinition() throws ParseException {/*@bgen(jjtree) VariableDefinition */ + VariableDefinition jjtn000 = new VariableDefinition(JJTVARIABLEDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jjtn000.variableLiteral = VariableLiteral(); + jj_consume_token(COLON); + jjtn000.type = Type(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case EQ:{ + jjtn000.defaultValue = DefaultValue(); + break; + } + default: + jj_la1[7] = jj_gen; + ; + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public VariableLiteral VariableLiteral() throws ParseException {/*@bgen(jjtree) VariableLiteral */ + VariableLiteral jjtn000 = new VariableLiteral(JJTVARIABLELITERAL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jj_consume_token(DOLLAR); + jjtn000.name = Name(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public DefaultValue DefaultValue() throws ParseException {/*@bgen(jjtree) DefaultValue */ + DefaultValue jjtn000 = new DefaultValue(JJTDEFAULTVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jj_consume_token(EQ); + jjtn000.value = Value(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + +// Operations + final public SelectionSet SelectionSet() throws ParseException {/*@bgen(jjtree) SelectionSet */ + SelectionSet jjtn000 = new SelectionSet(JJTSELECTIONSET); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + + Selection lastSelection; + try { + jj_consume_token(OCBR); + label_3: + while (true) { + lastSelection = Selection(); +jjtn000.selections.add(lastSelection); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case ELLIPSIS: + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + break; + } + default: + jj_la1[8] = jj_gen; + break label_3; + } + } + jj_consume_token(CCBR); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public Selection Selection() throws ParseException {/*@bgen(jjtree) Selection */ + Selection jjtn000 = new Selection(JJTSELECTION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + jjtn000.name = Name(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case COLON:{ + jjtn000.fieldWithAlias = FieldWithAlias(jjtn000.name, line, column, tokenId); + break; + } + default: + jj_la1[9] = jj_gen; + jjtn000.field = Field(jjtn000.name, line, column, tokenId); + } + break; + } + case ELLIPSIS:{ + jj_consume_token(ELLIPSIS); +jjtn000.ellipsis = true; + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + jjtn000.fragmentSpread = FragmentSpread(line, column, tokenId); + break; + } + case AT: + case OCBR: + case ON:{ + jjtn000.inlineFragment = InlineFragment(line, column, tokenId); + break; + } + default: + jj_la1[10] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + } + default: + jj_la1[11] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public Field Field(Name name, int line, int column, int tokenId) throws ParseException {/*@bgen(jjtree) Field */ + Field jjtn000 = new Field(JJTFIELD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1)); + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case OPAR:{ + jjtn000.arguments = Arguments(); + break; + } + default: + jj_la1[12] = jj_gen; + ; + } + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[13] = jj_gen; + ; + } + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case OCBR:{ + jjtn000.selectionSet = SelectionSet(); + break; + } + default: + jj_la1[14] = jj_gen; + ; + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public FieldWithAlias FieldWithAlias(Name alias, int line, int column, int tokenId) throws ParseException {/*@bgen(jjtree) FieldWithAlias */ + FieldWithAlias jjtn000 = new FieldWithAlias(JJTFIELDWITHALIAS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1)); + try { + jj_consume_token(COLON); + jjtn000.name = Name(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case OPAR:{ + jjtn000.arguments = Arguments(); + break; + } + default: + jj_la1[15] = jj_gen; + ; + } + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[16] = jj_gen; + ; + } + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case OCBR:{ + jjtn000.selectionSet = SelectionSet(); + break; + } + default: + jj_la1[17] = jj_gen; + ; + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public Arguments Arguments() throws ParseException {/*@bgen(jjtree) Arguments */ + Arguments jjtn000 = new Arguments(JJTARGUMENTS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + Argument lastArg; + try { + jj_consume_token(OPAR); + lastArg = Argument(); +jjtn000.arguments.add(lastArg); + label_4: + while (true) { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case COMMA:{ + break; + } + default: + jj_la1[18] = jj_gen; + break label_4; + } + jj_consume_token(COMMA); + lastArg = Argument(); +jjtn000.arguments.add(lastArg); + } + jj_consume_token(CPAR); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public Argument Argument() throws ParseException {/*@bgen(jjtree) Argument */ + Argument jjtn000 = new Argument(JJTARGUMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jjtn000.name = Name(); + jj_consume_token(COLON); + jjtn000.valueWithVariable = ValueWithVariable(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + +// Fragments + final public FragmentSpread FragmentSpread(int line, int column, int tokenId) throws ParseException {/*@bgen(jjtree) FragmentSpread */ + FragmentSpread jjtn000 = new FragmentSpread(JJTFRAGMENTSPREAD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1)); + try { + jjtn000.name = FragmentName(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[19] = jj_gen; + ; + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public InlineFragment InlineFragment(int line, int column, int tokenId) throws ParseException {/*@bgen(jjtree) InlineFragment */ + InlineFragment jjtn000 = new InlineFragment(JJTINLINEFRAGMENT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1)); + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case ON:{ + jjtn000.typeCondition = TypeCondition(); + break; + } + default: + jj_la1[20] = jj_gen; + ; + } + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[21] = jj_gen; + ; + } + jjtn000.selectionSet = SelectionSet(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public FragmentDefinition FragmentDefinition() throws ParseException {/*@bgen(jjtree) FragmentDefinition */ + FragmentDefinition jjtn000 = new FragmentDefinition(JJTFRAGMENTDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jj_consume_token(FRAGMENT); + jjtn000.name = FragmentName(); + jjtn000.type = TypeCondition(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[22] = jj_gen; + ; + } + jjtn000.selectionSet = SelectionSet(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public FragmentName FragmentName() throws ParseException {/*@bgen(jjtree) FragmentName */ + FragmentName jjtn000 = new FragmentName(JJTFRAGMENTNAME); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1)); + try { + jjtn000.name = Name(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +// TODO if ("on".equals(name.image)) throw new ParseException("on is not allowed at a name"); + {if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public TypeCondition TypeCondition() throws ParseException {/*@bgen(jjtree) TypeCondition */ + TypeCondition jjtn000 = new TypeCondition(JJTTYPECONDITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1)); + try { + jj_consume_token(ON); + jjtn000.name = TypeName(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + +// Values + final public Name Name() throws ParseException {/*@bgen(jjtree) Name */ + Name jjtn000 = new Name(JJTNAME); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));Token t; + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case NAME_LITERAL:{ + t = jj_consume_token(NAME_LITERAL); + break; + } + case FRAGMENT:{ + t = jj_consume_token(FRAGMENT); + break; + } + case QUERY:{ + t = jj_consume_token(QUERY); + break; + } + case MUTATION:{ + t = jj_consume_token(MUTATION); + break; + } + case SCHEMA:{ + t = jj_consume_token(SCHEMA); + break; + } + case SCALAR:{ + t = jj_consume_token(SCALAR); + break; + } + case TYPE:{ + t = jj_consume_token(TYPE); + break; + } + case INTERFACE:{ + t = jj_consume_token(INTERFACE); + break; + } + case IMPLEMENTS:{ + t = jj_consume_token(IMPLEMENTS); + break; + } + case ENUM:{ + t = jj_consume_token(ENUM); + break; + } + case UNION:{ + t = jj_consume_token(UNION); + break; + } + case INPUT:{ + t = jj_consume_token(INPUT); + break; + } + case EXTEND:{ + t = jj_consume_token(EXTEND); + break; + } + case DIRECTIVE:{ + t = jj_consume_token(DIRECTIVE); + break; + } + default: + jj_la1[23] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +jjtn000.value = t.image; + {if ("" != null) return jjtn000;} + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public Value Value() throws ParseException {/*@bgen(jjtree) Value */ + Value jjtn000 = new Value(JJTVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1)); + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case INTEGER_LITERAL:{ + //TODO class hierarchy here instead? + + jjtn000.intValue = IntValue(); + break; + } + case FLOAT_LITERAL:{ + jjtn000.floatValue = FloatValue(); + break; + } + case STRING_LITERAL:{ + jjtn000.stringValue = StringValue(); + break; + } + case TRUE: + case FALSE:{ + jjtn000.booleanValue = BooleanValue(); + break; + } + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + jjtn000.enumValue = EnumValue(); + break; + } + case OBRA:{ + jjtn000.listValue = ListValue(); + break; + } + case OCBR:{ + jjtn000.objectValue = ObjectValue(); + break; + } + default: + jj_la1[24] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public ValueWithVariable ValueWithVariable() throws ParseException {/*@bgen(jjtree) ValueWithVariable */ + ValueWithVariable jjtn000 = new ValueWithVariable(JJTVALUEWITHVARIABLE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1)); + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case DOLLAR:{ + jjtn000.variableLiteral = VariableLiteral(); + break; + } + case INTEGER_LITERAL:{ + jjtn000.intValue = IntValue(); + break; + } + case FLOAT_LITERAL:{ + jjtn000.floatValue = FloatValue(); + break; + } + case STRING_LITERAL:{ + jjtn000.stringValue = StringValue(); + break; + } + case TRUE: + case FALSE:{ + jjtn000.booleanValue = BooleanValue(); + break; + } + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + jjtn000.enumValue = EnumValue(); + break; + } + case OBRA:{ + jjtn000.listValueWithVariable = ListValueWithVariable(); + break; + } + case OCBR:{ + jjtn000.objectValueWithVariable = ObjectValueWithVariable(); + break; + } + default: + jj_la1[25] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public EnumValue EnumValue() throws ParseException {/*@bgen(jjtree) EnumValue */ + EnumValue jjtn000 = new EnumValue(JJTENUMVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jjtn000.name = Name(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +//TODO if ("true".equals(name.image) + //TODO || "false".equals(name.image) + //TODO || "null".equals(name.image)) throw new ParseException("true, false, null are not allowed as names"); + + {if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + +// List Value + final public ListValue ListValue() throws ParseException {/*@bgen(jjtree) ListValue */ + ListValue jjtn000 = new ListValue(JJTLISTVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + + Value lastVal; + try { + jj_consume_token(OBRA); + label_5: + while (true) { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case OBRA: + case OCBR: + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case TRUE: + case FALSE: + case INTEGER_LITERAL: + case FLOAT_LITERAL: + case STRING_LITERAL: + case NAME_LITERAL:{ + break; + } + default: + jj_la1[26] = jj_gen; + break label_5; + } + lastVal = Value(); +jjtn000.values.add(lastVal); + } + jj_consume_token(CBRA); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public ListValueWithVariable ListValueWithVariable() throws ParseException {/*@bgen(jjtree) ListValueWithVariable */ + ListValueWithVariable jjtn000 = new ListValueWithVariable(JJTLISTVALUEWITHVARIABLE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + + ValueWithVariable lastVal; + try { + jj_consume_token(OBRA); + label_6: + while (true) { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case DOLLAR: + case OBRA: + case OCBR: + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case TRUE: + case FALSE: + case INTEGER_LITERAL: + case FLOAT_LITERAL: + case STRING_LITERAL: + case NAME_LITERAL:{ + break; + } + default: + jj_la1[27] = jj_gen; + break label_6; + } + lastVal = ValueWithVariable(); +jjtn000.values.add(lastVal); + } + jj_consume_token(CBRA); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + +// Object Value + final public ObjectValue ObjectValue() throws ParseException {/*@bgen(jjtree) ObjectValue */ + ObjectValue jjtn000 = new ObjectValue(JJTOBJECTVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + + ObjectField lastVal; + try { + jj_consume_token(OCBR); + label_7: + while (true) { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + break; + } + default: + jj_la1[28] = jj_gen; + break label_7; + } + lastVal = ObjectField(); +jjtn000.values.add(lastVal); + } + jj_consume_token(CCBR); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public ObjectValueWithVariable ObjectValueWithVariable() throws ParseException {/*@bgen(jjtree) ObjectValueWithVariable */ + ObjectValueWithVariable jjtn000 = new ObjectValueWithVariable(JJTOBJECTVALUEWITHVARIABLE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + + ObjectFieldWithValue lastVal; + try { + jj_consume_token(OCBR); + label_8: + while (true) { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + break; + } + default: + jj_la1[29] = jj_gen; + break label_8; + } + lastVal = ObjectFieldWithValue(); +jjtn000.values.add(lastVal); + } + jj_consume_token(CCBR); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public ObjectField ObjectField() throws ParseException {/*@bgen(jjtree) ObjectField */ + ObjectField jjtn000 = new ObjectField(JJTOBJECTFIELD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jjtn000.name = Name(); + jj_consume_token(COLON); + jjtn000.value = Value(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public ObjectFieldWithValue ObjectFieldWithValue() throws ParseException {/*@bgen(jjtree) ObjectFieldWithValue */ + ObjectFieldWithValue jjtn000 = new ObjectFieldWithValue(JJTOBJECTFIELDWITHVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jjtn000.name = Name(); + jj_consume_token(COLON); + jjtn000.value = ValueWithVariable(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + +// Directives + final public Directives Directives() throws ParseException {/*@bgen(jjtree) Directives */ + Directives jjtn000 = new Directives(JJTDIRECTIVES); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + + Directive lastDirective; + try { + jj_consume_token(AT); + lastDirective = Directive(); +jjtn000.directives.add(lastDirective); + label_9: + while (true) { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + break; + } + default: + jj_la1[30] = jj_gen; + break label_9; + } + jj_consume_token(AT); + lastDirective = Directive(); +jjtn000.directives.add(lastDirective); + } + +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public Directive Directive() throws ParseException {/*@bgen(jjtree) Directive */ + Directive jjtn000 = new Directive(JJTDIRECTIVE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jjtn000.name = Name(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case OPAR:{ + jjtn000.arguments = Arguments(); + break; + } + default: + jj_la1[31] = jj_gen; + ; + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + +// Types + final public Type Type() throws ParseException {/*@bgen(jjtree) Type */ + Type jjtn000 = new Type(JJTTYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + jjtn000.typeName = TypeName(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case BANG:{ + jj_consume_token(BANG); +jjtn000.bang = true; + break; + } + default: + jj_la1[32] = jj_gen; + ; + } + break; + } + case OBRA:{ + jjtn000.listType = ListType(); + break; + } + default: + jj_la1[33] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public TypeName TypeName() throws ParseException {/*@bgen(jjtree) TypeName */ + TypeName jjtn000 = new TypeName(JJTTYPENAME); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1)); + try { + jjtn000.name = Name(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public ListType ListType() throws ParseException {/*@bgen(jjtree) ListType */ + ListType jjtn000 = new ListType(JJTLISTTYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jj_consume_token(OBRA); + jjtn000.type = Type(); + jj_consume_token(CBRA); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case BANG:{ + jj_consume_token(BANG); +jjtn000.bang = true; + break; + } + default: + jj_la1[34] = jj_gen; + ; + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + +// Type System + final public TypeSystemDefinition TypeSystemDefinition() throws ParseException {/*@bgen(jjtree) TypeSystemDefinition */ + TypeSystemDefinition jjtn000 = new TypeSystemDefinition(JJTTYPESYSTEMDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1)); + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case SCHEMA:{ + jjtn000.schemaDefinition = SchemaDefinition(); + break; + } + case SCALAR: + case TYPE: + case INTERFACE: + case ENUM: + case UNION: + case INPUT:{ + jjtn000.typeDefinition = TypeDefinition(); + break; + } + case EXTEND:{ + jjtn000.typeExtensionDefinition = TypeExtensionDefinition(); + break; + } + case DIRECTIVE:{ + jjtn000.directiveDefinition = DirectiveDefinition(); + break; + } + default: + jj_la1[35] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public SchemaDefinition SchemaDefinition() throws ParseException {/*@bgen(jjtree) SchemaDefinition */ + SchemaDefinition jjtn000 = new SchemaDefinition(JJTSCHEMADEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + OperationTypeDefinition lastOpTypeDef; + try { + jj_consume_token(SCHEMA); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[36] = jj_gen; + ; + } + jj_consume_token(OCBR); + label_10: + while (true) { + lastOpTypeDef = OperationTypeDefinition(); +jjtn000.operationTypeDefinitions.add(lastOpTypeDef); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case QUERY: + case MUTATION:{ + break; + } + default: + jj_la1[37] = jj_gen; + break label_10; + } + } + jj_consume_token(CCBR); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public OperationTypeDefinition OperationTypeDefinition() throws ParseException {/*@bgen(jjtree) OperationTypeDefinition */ + OperationTypeDefinition jjtn000 = new OperationTypeDefinition(JJTOPERATIONTYPEDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jjtn000.operationType = OperationType(); + jj_consume_token(COLON); + jjtn000.typeName = TypeName(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public TypeDefinition TypeDefinition() throws ParseException {/*@bgen(jjtree) TypeDefinition */ + TypeDefinition jjtn000 = new TypeDefinition(JJTTYPEDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));TypeDefinition result; + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case SCALAR:{ + result = ScalarTypeDefinition(); + break; + } + case TYPE:{ + result = ObjectTypeDefinition(); + break; + } + case INTERFACE:{ + result = InterfaceTypeDefinition(); + break; + } + case UNION:{ + result = UnionTypeDefinition(); + break; + } + case ENUM:{ + result = EnumTypeDefinition(); + break; + } + case INPUT:{ + result = InputObjectTypeDefinition(); + break; + } + default: + jj_la1[38] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return result;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public ScalarTypeDefinition ScalarTypeDefinition() throws ParseException {/*@bgen(jjtree) ScalarTypeDefinition */ + ScalarTypeDefinition jjtn000 = new ScalarTypeDefinition(JJTSCALARTYPEDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jj_consume_token(SCALAR); + jjtn000.name = Name(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[39] = jj_gen; + ; + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public ObjectTypeDefinition ObjectTypeDefinition() throws ParseException {/*@bgen(jjtree) ObjectTypeDefinition */ + ObjectTypeDefinition jjtn000 = new ObjectTypeDefinition(JJTOBJECTTYPEDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + FieldDefinition lastFieldDef; + try { + jj_consume_token(TYPE); + jjtn000.name = Name(); + + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case IMPLEMENTS:{ + jjtn000.implementsInterface = ImplementsInterface(); + break; + } + default: + jj_la1[40] = jj_gen; + ; + } + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[41] = jj_gen; + ; + } + jj_consume_token(OCBR); + label_11: + while (true) { + lastFieldDef = FieldDefinition(); +jjtn000.fieldDefinitions.add(lastFieldDef); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + break; + } + default: + jj_la1[42] = jj_gen; + break label_11; + } + } + jj_consume_token(CCBR); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public ImplementsInterface ImplementsInterface() throws ParseException {/*@bgen(jjtree) ImplementsInterface */ + ImplementsInterface jjtn000 = new ImplementsInterface(JJTIMPLEMENTSINTERFACE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));TypeName lastTypeName; + try { + jj_consume_token(IMPLEMENTS); + label_12: + while (true) { + lastTypeName = TypeName(); +jjtn000.typeNames.add(lastTypeName); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + break; + } + default: + jj_la1[43] = jj_gen; + break label_12; + } + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public FieldDefinition FieldDefinition() throws ParseException {/*@bgen(jjtree) FieldDefinition */ + FieldDefinition jjtn000 = new FieldDefinition(JJTFIELDDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jjtn000.name = Name(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case OPAR:{ + jjtn000.argumentsDefinition = ArgumentsDefinition(); + break; + } + default: + jj_la1[44] = jj_gen; + ; + } + jj_consume_token(COLON); + jjtn000.type = Type(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[45] = jj_gen; + ; + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public ArgumentsDefinition ArgumentsDefinition() throws ParseException {/*@bgen(jjtree) ArgumentsDefinition */ + ArgumentsDefinition jjtn000 = new ArgumentsDefinition(JJTARGUMENTSDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + + InputValueDefinition lastVal; + try { + jj_consume_token(OPAR); + label_13: + while (true) { + lastVal = InputValueDefinition(); +jjtn000.inputValueDefinitions.add(lastVal); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + break; + } + default: + jj_la1[46] = jj_gen; + break label_13; + } + } + jj_consume_token(CPAR); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public InputValueDefinition InputValueDefinition() throws ParseException {/*@bgen(jjtree) InputValueDefinition */ + InputValueDefinition jjtn000 = new InputValueDefinition(JJTINPUTVALUEDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jjtn000.name = Name(); + jj_consume_token(COLON); + jjtn000.type = Type(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case EQ:{ + jjtn000.defaultValue = DefaultValue(); + break; + } + default: + jj_la1[47] = jj_gen; + ; + } + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[48] = jj_gen; + ; + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public InterfaceTypeDefinition InterfaceTypeDefinition() throws ParseException {/*@bgen(jjtree) InterfaceTypeDefinition */ + InterfaceTypeDefinition jjtn000 = new InterfaceTypeDefinition(JJTINTERFACETYPEDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + FieldDefinition lastFieldDef; + try { + jj_consume_token(INTERFACE); + jjtn000.name = Name(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[49] = jj_gen; + ; + } + jj_consume_token(OCBR); + label_14: + while (true) { + lastFieldDef = FieldDefinition(); +jjtn000.fieldDefinitions.add(lastFieldDef); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + break; + } + default: + jj_la1[50] = jj_gen; + break label_14; + } + } + jj_consume_token(CCBR); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public UnionTypeDefinition UnionTypeDefinition() throws ParseException {/*@bgen(jjtree) UnionTypeDefinition */ + UnionTypeDefinition jjtn000 = new UnionTypeDefinition(JJTUNIONTYPEDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jj_consume_token(UNION); + jjtn000.name = Name(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[51] = jj_gen; + ; + } + jj_consume_token(EQ); + jjtn000.unionMembers = UnionMembers(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public UnionMembers UnionMembers() throws ParseException {/*@bgen(jjtree) UnionMembers */ + UnionMembers jjtn000 = new UnionMembers(JJTUNIONMEMBERS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + + TypeName lastTypeName; + try { + lastTypeName = TypeName(); +jjtn000.typeNames.add(lastTypeName); + label_15: + while (true) { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case PIPE:{ + break; + } + default: + jj_la1[52] = jj_gen; + break label_15; + } + jj_consume_token(PIPE); + lastTypeName = TypeName(); +jjtn000.typeNames.add(lastTypeName); + } + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public EnumTypeDefinition EnumTypeDefinition() throws ParseException {/*@bgen(jjtree) EnumTypeDefinition */ + EnumTypeDefinition jjtn000 = new EnumTypeDefinition(JJTENUMTYPEDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + EnumValueDefinition lastEnumValDef; + try { + jj_consume_token(ENUM); + jjtn000.name = Name(); + + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[53] = jj_gen; + ; + } + jj_consume_token(OCBR); + label_16: + while (true) { + lastEnumValDef = EnumValueDefinition(); +jjtn000.enumValueDefinitions.add(lastEnumValDef); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + break; + } + default: + jj_la1[54] = jj_gen; + break label_16; + } + } + jj_consume_token(CCBR); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public EnumValueDefinition EnumValueDefinition() throws ParseException {/*@bgen(jjtree) EnumValueDefinition */ + EnumValueDefinition jjtn000 = new EnumValueDefinition(JJTENUMVALUEDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jjtn000.enumValue = EnumValue(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[55] = jj_gen; + ; + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public InputObjectTypeDefinition InputObjectTypeDefinition() throws ParseException {/*@bgen(jjtree) InputObjectTypeDefinition */ + InputObjectTypeDefinition jjtn000 = new InputObjectTypeDefinition(JJTINPUTOBJECTTYPEDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + + InputValueDefinition lastInputValDef; + try { + jj_consume_token(INPUT); + jjtn000.name = Name(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case AT:{ + jjtn000.directives = Directives(); + break; + } + default: + jj_la1[56] = jj_gen; + ; + } + jj_consume_token(OCBR); + label_17: + while (true) { + lastInputValDef = InputValueDefinition(); +jjtn000.inputValueDefinitions.add(lastInputValDef); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case FRAGMENT: + case QUERY: + case MUTATION: + case SCHEMA: + case SCALAR: + case TYPE: + case INTERFACE: + case IMPLEMENTS: + case ENUM: + case UNION: + case INPUT: + case EXTEND: + case DIRECTIVE: + case NAME_LITERAL:{ + break; + } + default: + jj_la1[57] = jj_gen; + break label_17; + } + } + jj_consume_token(CCBR); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public TypeExtensionDefinition TypeExtensionDefinition() throws ParseException {/*@bgen(jjtree) TypeExtensionDefinition */ + TypeExtensionDefinition jjtn000 = new TypeExtensionDefinition(JJTTYPEEXTENSIONDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jj_consume_token(EXTEND); + jjtn000.objectTypeDefinition = ObjectTypeDefinition(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public DirectiveDefinition DirectiveDefinition() throws ParseException {/*@bgen(jjtree) DirectiveDefinition */ + DirectiveDefinition jjtn000 = new DirectiveDefinition(JJTDIRECTIVEDEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jj_consume_token(DIRECTIVE); + jj_consume_token(AT); + jjtn000.name = Name(); + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case OPAR:{ + jjtn000.argumentsDefinition = ArgumentsDefinition(); + break; + } + default: + jj_la1[58] = jj_gen; + ; + } + jj_consume_token(ON); + jjtn000.directiveLocations = DirectiveLocations(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public DirectiveLocation DirectiveLocation() throws ParseException {/*@bgen(jjtree) DirectiveLocation */ + DirectiveLocation jjtn000 = new DirectiveLocation(JJTDIRECTIVELOCATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + jjtn000.name = Name(); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public DirectiveLocations DirectiveLocations() throws ParseException {/*@bgen(jjtree) DirectiveLocations */ + DirectiveLocations jjtn000 = new DirectiveLocations(JJTDIRECTIVELOCATIONS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + DirectiveLocation lastDirLocation; + try { + lastDirLocation = DirectiveLocation(); +jjtn000.directiveLocations.add(lastDirLocation); + label_18: + while (true) { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case PIPE:{ + break; + } + default: + jj_la1[59] = jj_gen; + break label_18; + } + jj_consume_token(PIPE); + lastDirLocation = DirectiveLocation(); +jjtn000.directiveLocations.add(lastDirLocation); + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } catch (Throwable jjte000) { +if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof ParseException) { + throw (ParseException)jjte000; + } + if (jjte000 instanceof RuntimeException) { + throw (RuntimeException)jjte000; + } + throw (Error)jjte000; + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + +// Tokens + final public BooleanValue BooleanValue() throws ParseException {/*@bgen(jjtree) BooleanValue */ + BooleanValue jjtn000 = new BooleanValue(JJTBOOLEANVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case TRUE:{ + jj_consume_token(TRUE); +jjtn000.val = true; + break; + } + case FALSE:{ + jj_consume_token(FALSE); +jjtn000.val = false; + break; + } + default: + jj_la1[60] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public IntValue IntValue() throws ParseException {/*@bgen(jjtree) IntValue */ + IntValue jjtn000 = new IntValue(JJTINTVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + Token literal; + try { + literal = jj_consume_token(INTEGER_LITERAL); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +jjtn000.val = Integer.parseInt(literal.image); + {if ("" != null) return jjtn000;} + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public FloatValue FloatValue() throws ParseException {/*@bgen(jjtree) FloatValue */ + FloatValue jjtn000 = new FloatValue(JJTFLOATVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + Token literal; + try { + literal = jj_consume_token(FLOAT_LITERAL); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +jjtn000.stringValue = literal.image; + //TODO parse! + {if ("" != null) return jjtn000;} + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public StringValue StringValue() throws ParseException {/*@bgen(jjtree) StringValue */ + StringValue jjtn000 = new StringValue(JJTSTRINGVALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1));int tokenId = tokenId(); + int line = line(); + int column = column(); + Token literal; + try { + literal = jj_consume_token(STRING_LITERAL); +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +jjtn000.val = literal.image; + {if ("" != null) return jjtn000;} + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + final public OperationType OperationType() throws ParseException {/*@bgen(jjtree) OperationType */ + OperationType jjtn000 = new OperationType(JJTOPERATIONTYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtn000.jjtSetFirstToken(getToken(1)); + try { + switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) { + case MUTATION:{ + jj_consume_token(MUTATION); +jjtn000.mutation = true; + break; + } + case QUERY:{ + jj_consume_token(QUERY); +jjtn000.query = true; + break; + } + default: + jj_la1[61] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.jjtSetLastToken(getToken(0)); +{if ("" != null) return jjtn000;} + } finally { +if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtn000.jjtSetLastToken(getToken(0)); + } + } + throw new IllegalStateException ("Missing return statement in function"); +} + + /** Generated Token Manager. */ + public GraphQLParserTokenManager token_source; + /** Current token. */ + public Token token; + /** Next token. */ + public Token jj_nt; + private int jj_ntk; + private int jj_gen; + final private int[] jj_la1 = new int[62]; + static private int[] jj_la1_0; + static private int[] jj_la1_1; + static { + jj_la1_init_0(); + jj_la1_init_1(); + } + private static void jj_la1_init_0() { + jj_la1_0 = new int[] {0xfbf82000,0xfbf82000,0xfff80000,0x20,0x400,0x302000,0x10,0x200,0xfff80080,0x100,0xfff82400,0xfff80080,0x20,0x400,0x2000,0x20,0x400,0x2000,0x2,0x400,0x0,0x400,0x400,0xfff80000,0xfff82800,0xfff82810,0xfff82800,0xfff82810,0xfff80000,0xfff80000,0x400,0x20,0x8,0xfff80800,0x8,0xfbc00000,0x400,0x300000,0x3b800000,0x400,0x4000000,0x400,0xfff80000,0xfff80000,0x20,0x400,0xfff80000,0x200,0x400,0x400,0xfff80000,0x400,0x4000,0x400,0xfff80000,0x400,0x400,0xfff80000,0x20,0x4000,0x0,0x300000,}; + } + private static void jj_la1_init_1() { + jj_la1_1 = new int[] {0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x400008,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8,0x0,0x0,0x400000,0x780003,0x780003,0x780003,0x780003,0x400000,0x400000,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x400000,0x0,0x0,0x400000,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x400000,0x0,0x0,0x400000,0x0,0x0,0x3,0x0,}; + } + + /** + * Constructor with user supplied CharStream. + * @param stream stream to init with + */ + public GraphQLParser(final CharStream stream) { + token_source = new GraphQLParserTokenManager(stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 62; i++) jj_la1[i] = -1; + } + + /** + * Reinitialise. + * @param stream stream to init with + */ + public void ReInit(final CharStream stream) { + token_source.ReInit(stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 62; i++) + jj_la1[i] = -1; + } + + /** + * Constructor with generated Token Manager. + * @param tm Token manager to use + */ + public GraphQLParser(final GraphQLParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 62; i++) jj_la1[i] = -1; + } + + /** + * Reinitialise + * @param tm Token manager to use + */ + public void ReInit(final GraphQLParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 62; i++) jj_la1[i] = -1; + } + + private Token jj_consume_token(final int kind) throws ParseException { + final Token oldToken = token; + if (token.next != null) + token = token.next; + else { + token.next = token_source.getNextToken(); + token = token.next; + } + jj_ntk = -1; + if (token.kind == kind) { + jj_gen++; + return token; + } + token = oldToken; + jj_kind = kind; + throw generateParseException(); + } + + + /** + * @return the next Token. + */ + public final Token getNextToken() { + if (token.next != null) + token = token.next; + else + token = token.next = token_source.getNextToken(); + jj_ntk = -1; + jj_gen++; + return token; + } + + /** + * @param index index to be retrieved + * @return the specific Token. + */ + public final Token getToken(final int index) { + Token t = token; + for (int i = 0; i < index; i++) { + if (t.next == null) + t.next = token_source.getNextToken(); + t = t.next; + } + return t; + } + + private int jj_ntk_f() { + jj_nt = token.next; + if (jj_nt == null) { + token.next = token_source.getNextToken(); + jj_ntk = token.next.kind; + return jj_ntk; + } + jj_ntk = jj_nt.kind; + return jj_ntk; + } + + private java.util.List jj_expentries = new java.util.ArrayList<>(); + private int[] jj_expentry; + private int jj_kind = -1; + + /** + * Generate ParseException. + * @return new Exception object. Never null + */ + public ParseException generateParseException() { + jj_expentries.clear(); + boolean[] la1tokens = new boolean[55]; + if (jj_kind >= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 62; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1<false. + */ + public final boolean trace_enabled() { + return false; + } + + /** Enable tracing. */ + public final void enable_tracing() {} + + /** Disable tracing. */ + public final void disable_tracing() {} + +} diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserConstants.java b/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserConstants.java new file mode 100755 index 0000000000..89090d8267 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserConstants.java @@ -0,0 +1,178 @@ +/* Generated by: JJTree&ParserGeneratorCC: Do not edit this line. GraphQLParserConstants.java */ +package com.arcadedb.graphql.parser; + + +/** + * Token literal values and constants. + * Generated by com.helger.pgcc.output.java.OtherFilesGenJava#start() + */ +public interface GraphQLParserConstants { + + /** End of File. */ + int EOF = 0; + /** RegularExpression Id. */ + int COMMA = 1; + /** RegularExpression Id. */ + int HASH = 2; + /** RegularExpression Id. */ + int BANG = 3; + /** RegularExpression Id. */ + int DOLLAR = 4; + /** RegularExpression Id. */ + int OPAR = 5; + /** RegularExpression Id. */ + int CPAR = 6; + /** RegularExpression Id. */ + int ELLIPSIS = 7; + /** RegularExpression Id. */ + int COLON = 8; + /** RegularExpression Id. */ + int EQ = 9; + /** RegularExpression Id. */ + int AT = 10; + /** RegularExpression Id. */ + int OBRA = 11; + /** RegularExpression Id. */ + int CBRA = 12; + /** RegularExpression Id. */ + int OCBR = 13; + /** RegularExpression Id. */ + int PIPE = 14; + /** RegularExpression Id. */ + int CCBR = 15; + /** RegularExpression Id. */ + int PLUS = 16; + /** RegularExpression Id. */ + int MINUS = 17; + /** RegularExpression Id. */ + int SIGN = 18; + /** RegularExpression Id. */ + int FRAGMENT = 19; + /** RegularExpression Id. */ + int QUERY = 20; + /** RegularExpression Id. */ + int MUTATION = 21; + /** RegularExpression Id. */ + int SCHEMA = 22; + /** RegularExpression Id. */ + int SCALAR = 23; + /** RegularExpression Id. */ + int TYPE = 24; + /** RegularExpression Id. */ + int INTERFACE = 25; + /** RegularExpression Id. */ + int IMPLEMENTS = 26; + /** RegularExpression Id. */ + int ENUM = 27; + /** RegularExpression Id. */ + int UNION = 28; + /** RegularExpression Id. */ + int INPUT = 29; + /** RegularExpression Id. */ + int EXTEND = 30; + /** RegularExpression Id. */ + int DIRECTIVE = 31; + /** RegularExpression Id. */ + int TRUE = 32; + /** RegularExpression Id. */ + int FALSE = 33; + /** RegularExpression Id. */ + int NULL = 34; + /** RegularExpression Id. */ + int ON = 35; + /** RegularExpression Id. */ + int DIGIT = 36; + /** RegularExpression Id. */ + int NON_ZERO_DIGIT = 37; + /** RegularExpression Id. */ + int SKIP_NEW_LINE = 41; + /** RegularExpression Id. */ + int SKIP_INSIGN_COMMA = 42; + /** RegularExpression Id. */ + int SKIP_COMMENT = 43; + /** RegularExpression Id. */ + int LINE_TERMINATOR = 44; + /** RegularExpression Id. */ + int WHITESPACE = 45; + /** RegularExpression Id. */ + int LETTER = 46; + /** RegularExpression Id. */ + int EXPONENT_IDENFITIER = 47; + /** RegularExpression Id. */ + int INTEGER_PART = 48; + /** RegularExpression Id. */ + int FRACTIONAL_PART = 49; + /** RegularExpression Id. */ + int EXPONENT_PART = 50; + /** RegularExpression Id. */ + int INTEGER_LITERAL = 51; + /** RegularExpression Id. */ + int FLOAT_LITERAL = 52; + /** RegularExpression Id. */ + int STRING_LITERAL = 53; + /** RegularExpression Id. */ + int NAME_LITERAL = 54; + + /** Lexical state. */ + int DEFAULT = 0; + + /** Literal token values. */ + String[] tokenImage = { + "", + "\",\"", + "\"#\"", + "\"!\"", + "\"$\"", + "\"(\"", + "\")\"", + "\"...\"", + "\":\"", + "\"=\"", + "\"@\"", + "\"[\"", + "\"]\"", + "\"{\"", + "\"|\"", + "\"}\"", + "\"+\"", + "\"-\"", + "", + "\"fragment\"", + "\"query\"", + "\"mutation\"", + "\"schema\"", + "\"scalar\"", + "\"type\"", + "\"interface\"", + "\"implements\"", + "\"enum\"", + "\"union\"", + "\"input\"", + "\"extend\"", + "\"directive\"", + "\"true\"", + "\"false\"", + "\"null\"", + "\"on\"", + "", + "", + "\"\\t\"", + "\" \"", + "\"\\ufeff\"", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + }; + +} diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserDefaultVisitor.java b/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserDefaultVisitor.java new file mode 100755 index 0000000000..86a3688a73 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserDefaultVisitor.java @@ -0,0 +1,187 @@ +/* Generated by: ParserGeneratorCC: Do not edit this line. GraphQLParserDefaultVisitor.java Version 1.1.3 */ +package com.arcadedb.graphql.parser; + +public class GraphQLParserDefaultVisitor implements GraphQLParserVisitor{ + public Object defaultVisit(final SimpleNode node, final Object data){ + + return data; + } + public Object visit(final SimpleNode node, final Object data){ + return defaultVisit(node, data); + } + public Object visit(Document node, Object data){ + return defaultVisit(node, data); + } + public Object visit(Definition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(OperationDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(VariableDefinitions node, Object data){ + return defaultVisit(node, data); + } + public Object visit(VariableDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(VariableLiteral node, Object data){ + return defaultVisit(node, data); + } + public Object visit(DefaultValue node, Object data){ + return defaultVisit(node, data); + } + public Object visit(SelectionSet node, Object data){ + return defaultVisit(node, data); + } + public Object visit(Selection node, Object data){ + return defaultVisit(node, data); + } + public Object visit(Field node, Object data){ + return defaultVisit(node, data); + } + public Object visit(FieldWithAlias node, Object data){ + return defaultVisit(node, data); + } + public Object visit(Arguments node, Object data){ + return defaultVisit(node, data); + } + public Object visit(Argument node, Object data){ + return defaultVisit(node, data); + } + public Object visit(FragmentSpread node, Object data){ + return defaultVisit(node, data); + } + public Object visit(InlineFragment node, Object data){ + return defaultVisit(node, data); + } + public Object visit(FragmentDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(FragmentName node, Object data){ + return defaultVisit(node, data); + } + public Object visit(TypeCondition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(Name node, Object data){ + return defaultVisit(node, data); + } + public Object visit(Value node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ValueWithVariable node, Object data){ + return defaultVisit(node, data); + } + public Object visit(EnumValue node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ListValue node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ListValueWithVariable node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ObjectValue node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ObjectValueWithVariable node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ObjectField node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ObjectFieldWithValue node, Object data){ + return defaultVisit(node, data); + } + public Object visit(Directives node, Object data){ + return defaultVisit(node, data); + } + public Object visit(Directive node, Object data){ + return defaultVisit(node, data); + } + public Object visit(Type node, Object data){ + return defaultVisit(node, data); + } + public Object visit(TypeName node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ListType node, Object data){ + return defaultVisit(node, data); + } + public Object visit(TypeSystemDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(SchemaDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(OperationTypeDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(TypeDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ScalarTypeDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ObjectTypeDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ImplementsInterface node, Object data){ + return defaultVisit(node, data); + } + public Object visit(FieldDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ArgumentsDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(InputValueDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(InterfaceTypeDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(UnionTypeDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(UnionMembers node, Object data){ + return defaultVisit(node, data); + } + public Object visit(EnumTypeDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(EnumValueDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(InputObjectTypeDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(TypeExtensionDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(DirectiveDefinition node, Object data){ + return defaultVisit(node, data); + } + public Object visit(DirectiveLocation node, Object data){ + return defaultVisit(node, data); + } + public Object visit(DirectiveLocations node, Object data){ + return defaultVisit(node, data); + } + public Object visit(BooleanValue node, Object data){ + return defaultVisit(node, data); + } + public Object visit(IntValue node, Object data){ + return defaultVisit(node, data); + } + public Object visit(FloatValue node, Object data){ + return defaultVisit(node, data); + } + public Object visit(StringValue node, Object data){ + return defaultVisit(node, data); + } + public Object visit(OperationType node, Object data){ + return defaultVisit(node, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=e10e47b71ae8418b0a539838c2422255 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserTokenManager.java b/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserTokenManager.java new file mode 100755 index 0000000000..f69f261634 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserTokenManager.java @@ -0,0 +1,1105 @@ +/* GraphQLParserTokenManager.java */ +/* Generated by: JJTree&ParserGeneratorCC: Do not edit this line. GraphQLParserTokenManager.java */ +package com.arcadedb.graphql.parser; +import java.io.*; +import com.arcadedb.query.sql.parser.JavaCharStream; + +/** Token Manager. */ +@SuppressWarnings ("unused") +public class GraphQLParserTokenManager implements GraphQLParserConstants { +private final int jjStopStringLiteralDfa_0(int pos, long active0){ + switch (pos) + { + case 0: + if ((active0 & 0x4L) != 0x0L) + return 5; + if ((active0 & 0x20000L) != 0x0L) + return 36; + if ((active0 & 0xffff80000L) != 0x0L) + { + jjmatchedKind = 54; + return 19; + } + return -1; + case 1: + if ((active0 & 0x7fff80000L) != 0x0L) + { + jjmatchedKind = 54; + jjmatchedPos = 1; + return 19; + } + if ((active0 & 0x800000000L) != 0x0L) + return 19; + return -1; + case 2: + if ((active0 & 0x7fff80000L) != 0x0L) + { + jjmatchedKind = 54; + jjmatchedPos = 2; + return 19; + } + return -1; + case 3: + if ((active0 & 0x509000000L) != 0x0L) + return 19; + if ((active0 & 0x2f6f80000L) != 0x0L) + { + jjmatchedKind = 54; + jjmatchedPos = 3; + return 19; + } + return -1; + case 4: + if ((active0 & 0xc6e80000L) != 0x0L) + { + jjmatchedKind = 54; + jjmatchedPos = 4; + return 19; + } + if ((active0 & 0x230100000L) != 0x0L) + return 19; + return -1; + case 5: + if ((active0 & 0x86280000L) != 0x0L) + { + jjmatchedKind = 54; + jjmatchedPos = 5; + return 19; + } + if ((active0 & 0x40c00000L) != 0x0L) + return 19; + return -1; + case 6: + if ((active0 & 0x86280000L) != 0x0L) + { + jjmatchedKind = 54; + jjmatchedPos = 6; + return 19; + } + return -1; + case 7: + if ((active0 & 0x86000000L) != 0x0L) + { + jjmatchedKind = 54; + jjmatchedPos = 7; + return 19; + } + if ((active0 & 0x280000L) != 0x0L) + return 19; + return -1; + case 8: + if ((active0 & 0x4000000L) != 0x0L) + { + jjmatchedKind = 54; + jjmatchedPos = 8; + return 19; + } + if ((active0 & 0x82000000L) != 0x0L) + return 19; + return -1; + default : + return -1; + } +} +private final int jjStartNfa_0(int pos, long active0){ + return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); +} +private int jjStopAtPos(int pos, int kind) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + return pos + 1; +} +private int jjMoveStringLiteralDfa0_0(){ + switch(curChar) + { + case '!': + return jjStopAtPos(0, 3); + case '#': + return jjStartNfaWithStates_0(0, 2, 5); + case '$': + return jjStopAtPos(0, 4); + case '(': + return jjStopAtPos(0, 5); + case ')': + return jjStopAtPos(0, 6); + case '+': + return jjStopAtPos(0, 16); + case ',': + return jjStopAtPos(0, 1); + case '-': + return jjStartNfaWithStates_0(0, 17, 36); + case '.': + return jjMoveStringLiteralDfa1_0(0x80L); + case ':': + return jjStopAtPos(0, 8); + case '=': + return jjStopAtPos(0, 9); + case '@': + return jjStopAtPos(0, 10); + case '[': + return jjStopAtPos(0, 11); + case ']': + return jjStopAtPos(0, 12); + case 'd': + return jjMoveStringLiteralDfa1_0(0x80000000L); + case 'e': + return jjMoveStringLiteralDfa1_0(0x48000000L); + case 'f': + return jjMoveStringLiteralDfa1_0(0x200080000L); + case 'i': + return jjMoveStringLiteralDfa1_0(0x26000000L); + case 'm': + return jjMoveStringLiteralDfa1_0(0x200000L); + case 'n': + return jjMoveStringLiteralDfa1_0(0x400000000L); + case 'o': + return jjMoveStringLiteralDfa1_0(0x800000000L); + case 'q': + return jjMoveStringLiteralDfa1_0(0x100000L); + case 's': + return jjMoveStringLiteralDfa1_0(0xc00000L); + case 't': + return jjMoveStringLiteralDfa1_0(0x101000000L); + case 'u': + return jjMoveStringLiteralDfa1_0(0x10000000L); + case '{': + return jjStopAtPos(0, 13); + case '|': + return jjStopAtPos(0, 14); + case '}': + return jjStopAtPos(0, 15); + case 65279: + return jjStopAtPos(0, 40); + default : + return jjMoveNfa_0(0, 0); + } +} +private int jjMoveStringLiteralDfa1_0(long active0){ + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(0, active0); + return 1; + } + switch(curChar) + { + case '.': + return jjMoveStringLiteralDfa2_0(active0, 0x80L); + case 'a': + return jjMoveStringLiteralDfa2_0(active0, 0x200000000L); + case 'c': + return jjMoveStringLiteralDfa2_0(active0, 0xc00000L); + case 'i': + return jjMoveStringLiteralDfa2_0(active0, 0x80000000L); + case 'm': + return jjMoveStringLiteralDfa2_0(active0, 0x4000000L); + case 'n': + if ((active0 & 0x800000000L) != 0x0L) + return jjStartNfaWithStates_0(1, 35, 19); + return jjMoveStringLiteralDfa2_0(active0, 0x3a000000L); + case 'r': + return jjMoveStringLiteralDfa2_0(active0, 0x100080000L); + case 'u': + return jjMoveStringLiteralDfa2_0(active0, 0x400300000L); + case 'x': + return jjMoveStringLiteralDfa2_0(active0, 0x40000000L); + case 'y': + return jjMoveStringLiteralDfa2_0(active0, 0x1000000L); + default : + break; + } + return jjStartNfa_0(0, active0); +} +private int jjMoveStringLiteralDfa2_0(long old0, long active0){ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(0, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(1, active0); + return 2; + } + switch(curChar) + { + case '.': + if ((active0 & 0x80L) != 0x0L) + return jjStopAtPos(2, 7); + break; + case 'a': + return jjMoveStringLiteralDfa3_0(active0, 0x880000L); + case 'e': + return jjMoveStringLiteralDfa3_0(active0, 0x100000L); + case 'h': + return jjMoveStringLiteralDfa3_0(active0, 0x400000L); + case 'i': + return jjMoveStringLiteralDfa3_0(active0, 0x10000000L); + case 'l': + return jjMoveStringLiteralDfa3_0(active0, 0x600000000L); + case 'p': + return jjMoveStringLiteralDfa3_0(active0, 0x25000000L); + case 'r': + return jjMoveStringLiteralDfa3_0(active0, 0x80000000L); + case 't': + return jjMoveStringLiteralDfa3_0(active0, 0x42200000L); + case 'u': + return jjMoveStringLiteralDfa3_0(active0, 0x108000000L); + default : + break; + } + return jjStartNfa_0(1, active0); +} +private int jjMoveStringLiteralDfa3_0(long old0, long active0){ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(1, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(2, active0); + return 3; + } + switch(curChar) + { + case 'a': + return jjMoveStringLiteralDfa4_0(active0, 0x200000L); + case 'e': + if ((active0 & 0x1000000L) != 0x0L) + return jjStartNfaWithStates_0(3, 24, 19); + else if ((active0 & 0x100000000L) != 0x0L) + return jjStartNfaWithStates_0(3, 32, 19); + return jjMoveStringLiteralDfa4_0(active0, 0xc2400000L); + case 'g': + return jjMoveStringLiteralDfa4_0(active0, 0x80000L); + case 'l': + if ((active0 & 0x400000000L) != 0x0L) + return jjStartNfaWithStates_0(3, 34, 19); + return jjMoveStringLiteralDfa4_0(active0, 0x4800000L); + case 'm': + if ((active0 & 0x8000000L) != 0x0L) + return jjStartNfaWithStates_0(3, 27, 19); + break; + case 'o': + return jjMoveStringLiteralDfa4_0(active0, 0x10000000L); + case 'r': + return jjMoveStringLiteralDfa4_0(active0, 0x100000L); + case 's': + return jjMoveStringLiteralDfa4_0(active0, 0x200000000L); + case 'u': + return jjMoveStringLiteralDfa4_0(active0, 0x20000000L); + default : + break; + } + return jjStartNfa_0(2, active0); +} +private int jjMoveStringLiteralDfa4_0(long old0, long active0){ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(2, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(3, active0); + return 4; + } + switch(curChar) + { + case 'a': + return jjMoveStringLiteralDfa5_0(active0, 0x800000L); + case 'c': + return jjMoveStringLiteralDfa5_0(active0, 0x80000000L); + case 'e': + if ((active0 & 0x200000000L) != 0x0L) + return jjStartNfaWithStates_0(4, 33, 19); + return jjMoveStringLiteralDfa5_0(active0, 0x4000000L); + case 'm': + return jjMoveStringLiteralDfa5_0(active0, 0x480000L); + case 'n': + if ((active0 & 0x10000000L) != 0x0L) + return jjStartNfaWithStates_0(4, 28, 19); + return jjMoveStringLiteralDfa5_0(active0, 0x40000000L); + case 'r': + return jjMoveStringLiteralDfa5_0(active0, 0x2000000L); + case 't': + if ((active0 & 0x20000000L) != 0x0L) + return jjStartNfaWithStates_0(4, 29, 19); + return jjMoveStringLiteralDfa5_0(active0, 0x200000L); + case 'y': + if ((active0 & 0x100000L) != 0x0L) + return jjStartNfaWithStates_0(4, 20, 19); + break; + default : + break; + } + return jjStartNfa_0(3, active0); +} +private int jjMoveStringLiteralDfa5_0(long old0, long active0){ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(3, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(4, active0); + return 5; + } + switch(curChar) + { + case 'a': + if ((active0 & 0x400000L) != 0x0L) + return jjStartNfaWithStates_0(5, 22, 19); + break; + case 'd': + if ((active0 & 0x40000000L) != 0x0L) + return jjStartNfaWithStates_0(5, 30, 19); + break; + case 'e': + return jjMoveStringLiteralDfa6_0(active0, 0x80000L); + case 'f': + return jjMoveStringLiteralDfa6_0(active0, 0x2000000L); + case 'i': + return jjMoveStringLiteralDfa6_0(active0, 0x200000L); + case 'm': + return jjMoveStringLiteralDfa6_0(active0, 0x4000000L); + case 'r': + if ((active0 & 0x800000L) != 0x0L) + return jjStartNfaWithStates_0(5, 23, 19); + break; + case 't': + return jjMoveStringLiteralDfa6_0(active0, 0x80000000L); + default : + break; + } + return jjStartNfa_0(4, active0); +} +private int jjMoveStringLiteralDfa6_0(long old0, long active0){ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(4, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(5, active0); + return 6; + } + switch(curChar) + { + case 'a': + return jjMoveStringLiteralDfa7_0(active0, 0x2000000L); + case 'e': + return jjMoveStringLiteralDfa7_0(active0, 0x4000000L); + case 'i': + return jjMoveStringLiteralDfa7_0(active0, 0x80000000L); + case 'n': + return jjMoveStringLiteralDfa7_0(active0, 0x80000L); + case 'o': + return jjMoveStringLiteralDfa7_0(active0, 0x200000L); + default : + break; + } + return jjStartNfa_0(5, active0); +} +private int jjMoveStringLiteralDfa7_0(long old0, long active0){ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(5, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(6, active0); + return 7; + } + switch(curChar) + { + case 'c': + return jjMoveStringLiteralDfa8_0(active0, 0x2000000L); + case 'n': + if ((active0 & 0x200000L) != 0x0L) + return jjStartNfaWithStates_0(7, 21, 19); + return jjMoveStringLiteralDfa8_0(active0, 0x4000000L); + case 't': + if ((active0 & 0x80000L) != 0x0L) + return jjStartNfaWithStates_0(7, 19, 19); + break; + case 'v': + return jjMoveStringLiteralDfa8_0(active0, 0x80000000L); + default : + break; + } + return jjStartNfa_0(6, active0); +} +private int jjMoveStringLiteralDfa8_0(long old0, long active0){ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(6, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(7, active0); + return 8; + } + switch(curChar) + { + case 'e': + if ((active0 & 0x2000000L) != 0x0L) + return jjStartNfaWithStates_0(8, 25, 19); + else if ((active0 & 0x80000000L) != 0x0L) + return jjStartNfaWithStates_0(8, 31, 19); + break; + case 't': + return jjMoveStringLiteralDfa9_0(active0, 0x4000000L); + default : + break; + } + return jjStartNfa_0(7, active0); +} +private int jjMoveStringLiteralDfa9_0(long old0, long active0){ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(7, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(8, active0); + return 9; + } + switch(curChar) + { + case 's': + if ((active0 & 0x4000000L) != 0x0L) + return jjStartNfaWithStates_0(9, 26, 19); + break; + default : + break; + } + return jjStartNfa_0(8, active0); +} +private int jjStartNfaWithStates_0(int pos, int kind, int state) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return pos + 1; } + return jjMoveNfa_0(state, pos + 1); +} +static final long[] jjbitVec0 = { + 0x30000000000L, 0x0L, 0x0L, 0x0L +}; +static final long[] jjbitVec1 = { + 0xfffffffeL, 0x0L, 0x0L, 0x0L +}; +static final long[] jjbitVec3 = { + 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL +}; +static final long[] jjbitVec4 = { + 0xffffffffffL, 0x0L, 0x0L, 0x0L +}; +static final long[] jjbitVec5 = { + 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL +}; +private int jjMoveNfa_0(int startState, int curPos) +{ + int startsAt = 0; + jjnewStateCnt = 41; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (;;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + do + { + switch(jjstateSet[--i]) + { + case 0: + if ((0x3ff000000000000L & l) != 0x0L) + { + if (kind > 36) + kind = 36; + } + else if ((0x2400L & l) != 0x0L) + { + if (kind > 41) + kind = 41; + } + else if ((0x280000000000L & l) != 0x0L) + { + if (kind > 18) + kind = 18; + } + else if (curChar == 34) + { jjCheckNAddStates(0, 4); } + else if (curChar == 35) + { + if (kind > 43) + kind = 43; + { jjCheckNAdd(5); } + } + else if (curChar == 44) + { + if (kind > 42) + kind = 42; + } + if ((0x3fe000000000000L & l) != 0x0L) + { + if (kind > 37) + kind = 37; + { jjCheckNAddStates(5, 11); } + } + else if (curChar == 48) + { + if (kind > 51) + kind = 51; + { jjCheckNAddStates(12, 14); } + } + else if (curChar == 45) + { jjAddStates(15, 18); } + break; + case 36: + if ((0x3fe000000000000L & l) != 0x0L) + { jjCheckNAddStates(19, 24); } + else if (curChar == 48) + { jjCheckNAddStates(12, 14); } + if ((0x3fe000000000000L & l) != 0x0L) + { + if (kind > 51) + kind = 51; + { jjCheckNAdd(21); } + } + else if (curChar == 48) + { + if (kind > 51) + kind = 51; + } + break; + case 1: + if ((0x3ff000000000000L & l) != 0x0L && kind > 36) + kind = 36; + break; + case 2: + if ((0x2400L & l) != 0x0L && kind > 41) + kind = 41; + break; + case 3: + if (curChar == 44 && kind > 42) + kind = 42; + break; + case 4: + if (curChar != 35) + break; + if (kind > 43) + kind = 43; + { jjCheckNAdd(5); } + break; + case 5: + if ((0xffffffffffffdbffL & l) == 0x0L) + break; + if (kind > 43) + kind = 43; + { jjCheckNAdd(5); } + break; + case 6: + if (curChar == 34) + { jjCheckNAddStates(0, 4); } + break; + case 7: + if ((0xfffffffbffffffffL & l) != 0x0L) + { jjCheckNAddStates(0, 4); } + break; + case 9: + if ((0x3ff000000000000L & l) != 0x0L) + jjstateSet[jjnewStateCnt++] = 10; + break; + case 10: + if ((0x3ff000000000000L & l) != 0x0L) + jjstateSet[jjnewStateCnt++] = 11; + break; + case 11: + if ((0x3ff000000000000L & l) != 0x0L) + jjstateSet[jjnewStateCnt++] = 12; + break; + case 12: + if ((0x3ff000000000000L & l) != 0x0L) + { jjCheckNAddStates(0, 4); } + break; + case 15: + if ((0x800400000000L & l) != 0x0L) + { jjCheckNAddStates(0, 4); } + break; + case 16: + if ((0xffffffff00002600L & l) != 0x0L) + { jjCheckNAddStates(0, 4); } + break; + case 17: + if (curChar == 34 && kind > 53) + kind = 53; + break; + case 19: + if ((0x3ff000000000000L & l) == 0x0L) + break; + if (kind > 54) + kind = 54; + jjstateSet[jjnewStateCnt++] = 19; + break; + case 20: + if ((0x3fe000000000000L & l) == 0x0L) + break; + if (kind > 37) + kind = 37; + { jjCheckNAddStates(5, 11); } + break; + case 21: + if ((0x3ff000000000000L & l) == 0x0L) + break; + if (kind > 51) + kind = 51; + { jjCheckNAdd(21); } + break; + case 22: + if ((0x3ff000000000000L & l) != 0x0L) + { jjCheckNAddTwoStates(22, 23); } + break; + case 23: + if (curChar != 46) + break; + if (kind > 52) + kind = 52; + { jjCheckNAdd(24); } + break; + case 24: + if ((0x3ff000000000000L & l) == 0x0L) + break; + if (kind > 52) + kind = 52; + { jjCheckNAdd(24); } + break; + case 25: + if ((0x3ff000000000000L & l) != 0x0L) + { jjCheckNAddTwoStates(25, 26); } + break; + case 27: + if ((0x280000000000L & l) != 0x0L) + { jjCheckNAdd(28); } + break; + case 28: + if ((0x3ff000000000000L & l) == 0x0L) + break; + if (kind > 52) + kind = 52; + { jjCheckNAdd(28); } + break; + case 29: + if ((0x3ff000000000000L & l) != 0x0L) + { jjCheckNAddTwoStates(29, 30); } + break; + case 30: + if (curChar == 46) + { jjCheckNAddTwoStates(31, 32); } + break; + case 31: + if ((0x3ff000000000000L & l) != 0x0L) + { jjCheckNAddTwoStates(31, 32); } + break; + case 33: + if ((0x280000000000L & l) != 0x0L) + { jjCheckNAdd(34); } + break; + case 34: + if ((0x3ff000000000000L & l) == 0x0L) + break; + if (kind > 52) + kind = 52; + { jjCheckNAdd(34); } + break; + case 35: + if (curChar == 45) + { jjAddStates(15, 18); } + break; + case 37: + if ((0x3fe000000000000L & l) == 0x0L) + break; + if (kind > 51) + kind = 51; + { jjCheckNAdd(21); } + break; + case 38: + if (curChar == 48) + { jjCheckNAddStates(12, 14); } + break; + case 39: + if ((0x3fe000000000000L & l) != 0x0L) + { jjCheckNAddStates(19, 24); } + break; + case 40: + if (curChar != 48) + break; + if (kind > 51) + kind = 51; + { jjCheckNAddStates(12, 14); } + break; + default : break; + } + } while(i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 0: + case 19: + if ((0x7fffffe87fffffeL & l) == 0x0L) + break; + if (kind > 54) + kind = 54; + { jjCheckNAdd(19); } + break; + case 5: + if (kind > 43) + kind = 43; + jjstateSet[jjnewStateCnt++] = 5; + break; + case 7: + if ((0xffffffffefffffffL & l) != 0x0L) + { jjCheckNAddStates(0, 4); } + break; + case 8: + if (curChar == 117) + jjstateSet[jjnewStateCnt++] = 9; + break; + case 9: + if ((0x7e0000007eL & l) != 0x0L) + jjstateSet[jjnewStateCnt++] = 10; + break; + case 10: + if ((0x7e0000007eL & l) != 0x0L) + jjstateSet[jjnewStateCnt++] = 11; + break; + case 11: + if ((0x7e0000007eL & l) != 0x0L) + jjstateSet[jjnewStateCnt++] = 12; + break; + case 12: + if ((0x7e0000007eL & l) != 0x0L) + { jjCheckNAddStates(0, 4); } + break; + case 13: + if (curChar == 92) + jjstateSet[jjnewStateCnt++] = 8; + break; + case 14: + if (curChar == 92) + jjstateSet[jjnewStateCnt++] = 15; + break; + case 15: + if ((0x14404410000000L & l) != 0x0L) + { jjCheckNAddStates(0, 4); } + break; + case 16: + { jjCheckNAddStates(0, 4); } + break; + case 26: + if ((0x2000000020L & l) != 0x0L) + { jjAddStates(25, 26); } + break; + case 32: + if ((0x2000000020L & l) != 0x0L) + { jjAddStates(27, 28); } + break; + default : break; + } + } while(i != startsAt); + } + else + { + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 0: + if ((jjbitVec0[i2] & l2) != 0L && kind > 41) + kind = 41; + break; + case 5: + if ((jjbitVec3[i2] & l2) == 0L) + break; + if (kind > 43) + kind = 43; + jjstateSet[jjnewStateCnt++] = 5; + break; + case 7: + if ((jjbitVec3[i2] & l2) != 0L) + { jjCheckNAddStates(0, 4); } + break; + case 16: + if ((jjbitVec3[i2] & l2) != 0L) + { jjCheckNAddStates(0, 4); } + break; + default : break; + } + } while(i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + i = jjnewStateCnt; + jjnewStateCnt = startsAt; + startsAt = 41 - jjnewStateCnt; + if (i == startsAt) + return curPos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return curPos; } + } +} + +/** Token literal values. */ +public static final String[] jjstrLiteralImages = { +"", "\54", "\43", "\41", "\44", "\50", "\51", "\56\56\56", "\72", "\75", +"\100", "\133", "\135", "\173", "\174", "\175", "\53", "\55", null, +"\146\162\141\147\155\145\156\164", "\161\165\145\162\171", "\155\165\164\141\164\151\157\156", +"\163\143\150\145\155\141", "\163\143\141\154\141\162", "\164\171\160\145", +"\151\156\164\145\162\146\141\143\145", "\151\155\160\154\145\155\145\156\164\163", "\145\156\165\155", +"\165\156\151\157\156", "\151\156\160\165\164", "\145\170\164\145\156\144", +"\144\151\162\145\143\164\151\166\145", "\164\162\165\145", "\146\141\154\163\145", "\156\165\154\154", "\157\156", +null, null, null, null, null, null, null, null, null, null, null, null, null, null, +null, null, null, null, null, }; +protected Token jjFillToken() +{ + final Token t; + final String curTokenImage; + final int beginLine; + final int endLine; + final int beginColumn; + final int endColumn; + String im = jjstrLiteralImages[jjmatchedKind]; + curTokenImage = im == null ? input_stream.getImage() : im; + beginLine = input_stream.getBeginLine(); + beginColumn = input_stream.getBeginColumn(); + endLine = input_stream.getEndLine(); + endColumn = input_stream.getEndColumn(); + t = Token.newToken(jjmatchedKind); + t.kind = jjmatchedKind; + t.image = curTokenImage; + + t.beginLine = beginLine; + t.endLine = endLine; + t.beginColumn = beginColumn; + t.endColumn = endColumn; + + return t; +} +static final int[] jjnextStates = { + 7, 13, 14, 16, 17, 21, 22, 23, 25, 26, 29, 30, 23, 26, 30, 36, + 37, 38, 39, 22, 23, 25, 26, 29, 30, 27, 28, 33, 34, +}; + +int curLexState = 0; +int defaultLexState = 0; +int jjnewStateCnt; +int jjround; +int jjmatchedPos; +int jjmatchedKind; + +/** Get the next Token. */ +public Token getNextToken() +{ + Token matchedToken; + int curPos = 0; + + EOFLoop: + for (;;) + { + try + { + curChar = input_stream.beginToken(); + } + catch(final Exception e) + { + jjmatchedKind = 0; + jjmatchedPos = -1; + matchedToken = jjFillToken(); + return matchedToken; + } + + try { + input_stream.backup(0); + while (curChar <= 32 && (0x100000200L & (1L << curChar)) != 0x0L) + curChar = input_stream.beginToken(); + } + catch (final java.io.IOException e1) { + continue EOFLoop; + } + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_0(); + if (jjmatchedKind != 0x7fffffff) + { + if (jjmatchedPos + 1 < curPos) + input_stream.backup(curPos - jjmatchedPos - 1); + if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) + { + matchedToken = jjFillToken(); + return matchedToken; + } + else + { + continue EOFLoop; + } + } + int error_line = input_stream.getEndLine(); + int error_column = input_stream.getEndColumn(); + String error_after = null; + boolean EOFSeen = false; + try { + input_stream.readChar(); + input_stream.backup(1); + } + catch (final java.io.IOException e1) { + EOFSeen = true; + error_after = curPos <= 1 ? "" : input_stream.getImage(); + if (curChar == '\n' || curChar == '\r') { + error_line++; + error_column = 0; + } + else + error_column++; + } + if (!EOFSeen) { + input_stream.backup(1); + error_after = curPos <= 1 ? "" : input_stream.getImage(); + } + throw new TokenMgrException(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrException.LEXICAL_ERROR); + } +} + +void SkipLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + default : + break; + } +} +void MoreLexicalActions() +{ + jjimageLen += (lengthOfMatch = jjmatchedPos + 1); + switch(jjmatchedKind) + { + default : + break; + } +} +void TokenLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + default : + break; + } +} +private void jjCheckNAdd(int state) +{ + if (jjrounds[state] != jjround) + { + jjstateSet[jjnewStateCnt++] = state; + jjrounds[state] = jjround; + } +} +private void jjAddStates(int start, int end) +{ + do { + jjstateSet[jjnewStateCnt++] = jjnextStates[start]; + } while (start++ != end); +} +private void jjCheckNAddTwoStates(int state1, int state2) +{ + jjCheckNAdd(state1); + jjCheckNAdd(state2); +} + +private void jjCheckNAddStates(int start, int end) +{ + do { + jjCheckNAdd(jjnextStates[start]); + } while (start++ != end); +} + + /** Constructor. */ + public GraphQLParserTokenManager(CharStream stream){ + input_stream = stream; + } + + /** Constructor. */ + public GraphQLParserTokenManager (CharStream stream, int lexState){ + ReInit(stream); + SwitchTo(lexState); + } + + /** Reinitialise parser. */ + + public void ReInit(CharStream stream) + { + + + jjmatchedPos = + jjnewStateCnt = + 0; + curLexState = defaultLexState; + input_stream = stream; + ReInitRounds(); + } + + private void ReInitRounds() + { + int i; + jjround = 0x80000001; + for (i = 41; i-- > 0;) + jjrounds[i] = 0x80000000; + } + + /** Reinitialise parser. */ + public void ReInit(CharStream stream, int lexState) + { + ReInit(stream); + SwitchTo(lexState); + } + + /** Switch to specified lex state. */ + public void SwitchTo(int lexState) + { + if (lexState >= 1 || lexState < 0) + throw new TokenMgrException("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrException.INVALID_LEXICAL_STATE); + else + curLexState = lexState; + } + + +/** Lexer state names. */ +public static final String[] lexStateNames = { + "DEFAULT", +}; + +/** Lex State array. */ +public static final int[] jjnewLexState = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, +}; +static final long[] jjtoToken = { + 0x78003fffffffffL, +}; +static final long[] jjtoSkip = { + 0xfc000000000L, +}; +static final long[] jjtoSpecial = { + 0x0L, +}; +static final long[] jjtoMore = { + 0x0L, +}; + protected CharStream input_stream; + + private final int[] jjrounds = new int[41]; + private final int[] jjstateSet = new int[2 * 41]; + private final StringBuilder jjimage = new StringBuilder(); + private StringBuilder image = jjimage; + private int jjimageLen; + private int lengthOfMatch; + protected int curChar; +} diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserTreeConstants.java b/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserTreeConstants.java new file mode 100755 index 0000000000..df4e872ea3 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserTreeConstants.java @@ -0,0 +1,127 @@ +/* Generated by: ParserGeneratorCC: Do not edit this line. GraphQLParserTreeConstants.java Version 1.1.3 */ +package com.arcadedb.graphql.parser; + +public interface GraphQLParserTreeConstants +{ + public int JJTDOCUMENT = 0; + public int JJTDEFINITION = 1; + public int JJTOPERATIONDEFINITION = 2; + public int JJTVARIABLEDEFINITIONS = 3; + public int JJTVARIABLEDEFINITION = 4; + public int JJTVARIABLELITERAL = 5; + public int JJTDEFAULTVALUE = 6; + public int JJTSELECTIONSET = 7; + public int JJTSELECTION = 8; + public int JJTFIELD = 9; + public int JJTFIELDWITHALIAS = 10; + public int JJTARGUMENTS = 11; + public int JJTARGUMENT = 12; + public int JJTFRAGMENTSPREAD = 13; + public int JJTINLINEFRAGMENT = 14; + public int JJTFRAGMENTDEFINITION = 15; + public int JJTFRAGMENTNAME = 16; + public int JJTTYPECONDITION = 17; + public int JJTNAME = 18; + public int JJTVALUE = 19; + public int JJTVALUEWITHVARIABLE = 20; + public int JJTENUMVALUE = 21; + public int JJTLISTVALUE = 22; + public int JJTLISTVALUEWITHVARIABLE = 23; + public int JJTOBJECTVALUE = 24; + public int JJTOBJECTVALUEWITHVARIABLE = 25; + public int JJTOBJECTFIELD = 26; + public int JJTOBJECTFIELDWITHVALUE = 27; + public int JJTDIRECTIVES = 28; + public int JJTDIRECTIVE = 29; + public int JJTTYPE = 30; + public int JJTTYPENAME = 31; + public int JJTLISTTYPE = 32; + public int JJTTYPESYSTEMDEFINITION = 33; + public int JJTSCHEMADEFINITION = 34; + public int JJTOPERATIONTYPEDEFINITION = 35; + public int JJTTYPEDEFINITION = 36; + public int JJTSCALARTYPEDEFINITION = 37; + public int JJTOBJECTTYPEDEFINITION = 38; + public int JJTIMPLEMENTSINTERFACE = 39; + public int JJTFIELDDEFINITION = 40; + public int JJTARGUMENTSDEFINITION = 41; + public int JJTINPUTVALUEDEFINITION = 42; + public int JJTINTERFACETYPEDEFINITION = 43; + public int JJTUNIONTYPEDEFINITION = 44; + public int JJTUNIONMEMBERS = 45; + public int JJTENUMTYPEDEFINITION = 46; + public int JJTENUMVALUEDEFINITION = 47; + public int JJTINPUTOBJECTTYPEDEFINITION = 48; + public int JJTTYPEEXTENSIONDEFINITION = 49; + public int JJTDIRECTIVEDEFINITION = 50; + public int JJTDIRECTIVELOCATION = 51; + public int JJTDIRECTIVELOCATIONS = 52; + public int JJTBOOLEANVALUE = 53; + public int JJTINTVALUE = 54; + public int JJTFLOATVALUE = 55; + public int JJTSTRINGVALUE = 56; + public int JJTOPERATIONTYPE = 57; + + + public String[] jjtNodeName = { + "Document", + "Definition", + "OperationDefinition", + "VariableDefinitions", + "VariableDefinition", + "VariableLiteral", + "DefaultValue", + "SelectionSet", + "Selection", + "Field", + "FieldWithAlias", + "Arguments", + "Argument", + "FragmentSpread", + "InlineFragment", + "FragmentDefinition", + "FragmentName", + "TypeCondition", + "Name", + "Value", + "ValueWithVariable", + "EnumValue", + "ListValue", + "ListValueWithVariable", + "ObjectValue", + "ObjectValueWithVariable", + "ObjectField", + "ObjectFieldWithValue", + "Directives", + "Directive", + "Type", + "TypeName", + "ListType", + "TypeSystemDefinition", + "SchemaDefinition", + "OperationTypeDefinition", + "TypeDefinition", + "ScalarTypeDefinition", + "ObjectTypeDefinition", + "ImplementsInterface", + "FieldDefinition", + "ArgumentsDefinition", + "InputValueDefinition", + "InterfaceTypeDefinition", + "UnionTypeDefinition", + "UnionMembers", + "EnumTypeDefinition", + "EnumValueDefinition", + "InputObjectTypeDefinition", + "TypeExtensionDefinition", + "DirectiveDefinition", + "DirectiveLocation", + "DirectiveLocations", + "BooleanValue", + "IntValue", + "FloatValue", + "StringValue", + "OperationType", + }; +} +/* ParserGeneratorCC - OriginalChecksum=c673b5503d07c59e3a8f207cbc07b97e (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserVisitor.java b/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserVisitor.java new file mode 100755 index 0000000000..71e556b0e7 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/GraphQLParserVisitor.java @@ -0,0 +1,66 @@ +/* Generated by: ParserGeneratorCC: Do not edit this line. GraphQLParserVisitor.java Version 1.1.3 */ +package com.arcadedb.graphql.parser; + +public interface GraphQLParserVisitor +{ + public Object visit(SimpleNode node, Object data); + public Object visit(Document node, Object data); + public Object visit(Definition node, Object data); + public Object visit(OperationDefinition node, Object data); + public Object visit(VariableDefinitions node, Object data); + public Object visit(VariableDefinition node, Object data); + public Object visit(VariableLiteral node, Object data); + public Object visit(DefaultValue node, Object data); + public Object visit(SelectionSet node, Object data); + public Object visit(Selection node, Object data); + public Object visit(Field node, Object data); + public Object visit(FieldWithAlias node, Object data); + public Object visit(Arguments node, Object data); + public Object visit(Argument node, Object data); + public Object visit(FragmentSpread node, Object data); + public Object visit(InlineFragment node, Object data); + public Object visit(FragmentDefinition node, Object data); + public Object visit(FragmentName node, Object data); + public Object visit(TypeCondition node, Object data); + public Object visit(Name node, Object data); + public Object visit(Value node, Object data); + public Object visit(ValueWithVariable node, Object data); + public Object visit(EnumValue node, Object data); + public Object visit(ListValue node, Object data); + public Object visit(ListValueWithVariable node, Object data); + public Object visit(ObjectValue node, Object data); + public Object visit(ObjectValueWithVariable node, Object data); + public Object visit(ObjectField node, Object data); + public Object visit(ObjectFieldWithValue node, Object data); + public Object visit(Directives node, Object data); + public Object visit(Directive node, Object data); + public Object visit(Type node, Object data); + public Object visit(TypeName node, Object data); + public Object visit(ListType node, Object data); + public Object visit(TypeSystemDefinition node, Object data); + public Object visit(SchemaDefinition node, Object data); + public Object visit(OperationTypeDefinition node, Object data); + public Object visit(TypeDefinition node, Object data); + public Object visit(ScalarTypeDefinition node, Object data); + public Object visit(ObjectTypeDefinition node, Object data); + public Object visit(ImplementsInterface node, Object data); + public Object visit(FieldDefinition node, Object data); + public Object visit(ArgumentsDefinition node, Object data); + public Object visit(InputValueDefinition node, Object data); + public Object visit(InterfaceTypeDefinition node, Object data); + public Object visit(UnionTypeDefinition node, Object data); + public Object visit(UnionMembers node, Object data); + public Object visit(EnumTypeDefinition node, Object data); + public Object visit(EnumValueDefinition node, Object data); + public Object visit(InputObjectTypeDefinition node, Object data); + public Object visit(TypeExtensionDefinition node, Object data); + public Object visit(DirectiveDefinition node, Object data); + public Object visit(DirectiveLocation node, Object data); + public Object visit(DirectiveLocations node, Object data); + public Object visit(BooleanValue node, Object data); + public Object visit(IntValue node, Object data); + public Object visit(FloatValue node, Object data); + public Object visit(StringValue node, Object data); + public Object visit(OperationType node, Object data); +} +/* ParserGeneratorCC - OriginalChecksum=190db8fc1bc2ce8a84ebef80b4987a5a (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ImplementsInterface.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ImplementsInterface.java new file mode 100755 index 0000000000..c6e1939dbd --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ImplementsInterface.java @@ -0,0 +1,27 @@ +/* Generated by: JJTree: Do not edit this line. ImplementsInterface.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.ArrayList; +import java.util.List; + +public class ImplementsInterface extends SimpleNode { + + protected List typeNames = new ArrayList<>(); + + public ImplementsInterface(int id) { + super(id); + } + + public ImplementsInterface(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=49e5f69105886df7997cdcdbfef273bb (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/InlineFragment.java b/graphql/src/main/java/com/arcadedb/graphql/parser/InlineFragment.java new file mode 100755 index 0000000000..e7c009fcfb --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/InlineFragment.java @@ -0,0 +1,26 @@ +/* Generated by: JJTree: Do not edit this line. InlineFragment.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class InlineFragment extends SimpleNode { + + protected TypeCondition typeCondition; + protected Directives directives; + protected SelectionSet selectionSet; + + public InlineFragment(int id) { + super(id); + } + + public InlineFragment(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=b25dd549b07816d5a3cbcf5cf42f3a6f (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/InputObjectTypeDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/InputObjectTypeDefinition.java new file mode 100755 index 0000000000..8c2d570cae --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/InputObjectTypeDefinition.java @@ -0,0 +1,32 @@ +/* Generated by: JJTree: Do not edit this line. InputObjectTypeDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.*; + +public class InputObjectTypeDefinition extends TypeDefinition { + + protected Name name; + protected Directives directives; + protected List inputValueDefinitions = new ArrayList<>(); + + public InputObjectTypeDefinition(int id) { + super(id); + } + + public InputObjectTypeDefinition(GraphQLParser p, int id) { + super(p, id); + } + + public String getName() { + return name != null ? name.value : null; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=395d43b299254ecb99e16bccb871997c (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/InputValueDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/InputValueDefinition.java new file mode 100755 index 0000000000..3daa7e1def --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/InputValueDefinition.java @@ -0,0 +1,39 @@ +/* Generated by: JJTree: Do not edit this line. InputValueDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class InputValueDefinition extends SimpleNode { + + protected Name name; + protected Type type; + protected DefaultValue defaultValue; + protected Directives directives; + + public InputValueDefinition(int id) { + super(id); + } + + public InputValueDefinition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public Name getName() { + return name; + } + + public Type getType() { + return type; + } + + public DefaultValue getDefaultValue() { + return defaultValue; + } +} +/* ParserGeneratorCC - OriginalChecksum=3e7ab536d8fa5aeec277185038c0a682 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/IntValue.java b/graphql/src/main/java/com/arcadedb/graphql/parser/IntValue.java new file mode 100755 index 0000000000..41997ce075 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/IntValue.java @@ -0,0 +1,34 @@ +/* Generated by: JJTree: Do not edit this line. IntValue.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class IntValue extends AbstractValue { + + protected int val; + + public IntValue(int id) { + super(id); + } + + public IntValue(GraphQLParser p, int id) { + super(p, id); + } + + @Override + public Object getValue() { + return val; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + @Override + public String toString() { + return "IntValue{" + val + '}'; + } +} +/* ParserGeneratorCC - OriginalChecksum=7cc83806b39c0849299461073146a07c (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/InterfaceTypeDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/InterfaceTypeDefinition.java new file mode 100755 index 0000000000..67872a25be --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/InterfaceTypeDefinition.java @@ -0,0 +1,32 @@ +/* Generated by: JJTree: Do not edit this line. InterfaceTypeDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.*; + +public class InterfaceTypeDefinition extends TypeDefinition { + + protected Name name; + protected Directives directives; + protected List fieldDefinitions = new ArrayList<>(); + + public InterfaceTypeDefinition(int id) { + super(id); + } + + public InterfaceTypeDefinition(GraphQLParser p, int id) { + super(p, id); + } + + public String getName() { + return name != null ? name.value : null; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=f67913a71b0a0ce7fd7cf20494bf7fdd (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/JJTGraphQLParserState.java b/graphql/src/main/java/com/arcadedb/graphql/parser/JJTGraphQLParserState.java new file mode 100755 index 0000000000..dea06bcf06 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/JJTGraphQLParserState.java @@ -0,0 +1,125 @@ +/* Generated by: ParserGeneratorCC: Do not edit this line. JJTGraphQLParserState.java Version 1.1.3 */ +package com.arcadedb.graphql.parser; + +public class JJTGraphQLParserState implements java.io.Serializable { + private java.util.List nodes; + private java.util.List marks; + + /* number of nodes on stack */ + private int sp; + /* current mark */ + private int mk; + private boolean node_created; + + public JJTGraphQLParserState() { + nodes = new java.util.ArrayList<>(); + marks = new java.util.ArrayList<>(); + sp = 0; + mk = 0; + } + + /* Determines whether the current node was actually closed and + pushed. This should only be called in the final user action of a + node scope. */ + public boolean nodeCreated() { + return node_created; + } + + /* Call this to reinitialize the node stack. It is called + automatically by the parser's ReInit() method. */ + public void reset() { + nodes.clear(); + marks.clear(); + sp = 0; + mk = 0; + } + + /* Returns the root node of the AST. It only makes sense to call + this after a successful parse. */ + public Node rootNode() { + return nodes.get(0); + } + + /* Pushes a node on to the stack. */ + public void pushNode(Node n) { + nodes.add(n); + ++sp; + } + + /* Returns the node on the top of the stack, and remove it from the + stack. */ + public Node popNode() { + --sp; + if (sp < mk) { + mk = marks.remove(marks.size()-1).intValue(); + } + return nodes.remove(nodes.size()-1); + } + + /* Returns the node currently on the top of the stack. */ + public Node peekNode() { + return nodes.get(nodes.size()-1); + } + + /* Returns the number of children on the stack in the current node + scope. */ + public int nodeArity() { + return sp - mk; + } + + /* Parameter is currently unused. */ + public void clearNodeScope(@SuppressWarnings("unused") final Node n) { + while (sp > mk) { + popNode(); + } + mk = marks.remove(marks.size()-1).intValue(); + } + + public void openNodeScope(final Node n) { + marks.add(Integer.valueOf(mk)); + mk = sp; + n.jjtOpen(); + } + + /* A definite node is constructed from a specified number of + children. That number of nodes are popped from the stack and + made the children of the definite node. Then the definite node + is pushed on to the stack. */ + public void closeNodeScope(final Node n, final int numIn) { + mk = marks.remove(marks.size()-1).intValue(); + int num = numIn; + while (num-- > 0) { + Node c = popNode(); + c.jjtSetParent(n); + n.jjtAddChild(c, num); + } + n.jjtClose(); + pushNode(n); + node_created = true; + } + + + /* A conditional node is constructed if its condition is true. All + the nodes that have been pushed since the node was opened are + made children of the conditional node, which is then pushed + on to the stack. If the condition is false the node is not + constructed and they are left on the stack. */ + public void closeNodeScope(final Node n, final boolean condition) { + if (condition) { + int a = nodeArity(); + mk = marks.remove(marks.size()-1).intValue(); + while (a-- > 0) { + final Node c = popNode(); + c.jjtSetParent(n); + n.jjtAddChild(c, a); + } + n.jjtClose(); + pushNode(n); + node_created = true; + } else { + mk = marks.remove(marks.size()-1).intValue(); + node_created = false; + } + } +} +/* ParserGeneratorCC - OriginalChecksum=8f16c6ca694424614c1ce21fa9f6818f (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ListType.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ListType.java new file mode 100755 index 0000000000..e0d4029b5b --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ListType.java @@ -0,0 +1,25 @@ +/* Generated by: JJTree: Do not edit this line. ListType.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class ListType extends SimpleNode { + + protected Type type; + protected boolean bang = false; + + public ListType(int id) { + super(id); + } + + public ListType(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=24dd7322ed97d5b7b795158bfb5a0b17 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ListValue.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ListValue.java new file mode 100755 index 0000000000..66cfaf62cd --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ListValue.java @@ -0,0 +1,27 @@ +/* Generated by: JJTree: Do not edit this line. ListValue.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.ArrayList; +import java.util.List; + +public +class ListValue extends SimpleNode { + protected List values = new ArrayList<>(); + + public ListValue(int id) { + super(id); + } + + public ListValue(GraphQLParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return + visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=bbc6d6e1e0f7b2e23f8cd435deccb5e0 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ListValueWithVariable.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ListValueWithVariable.java new file mode 100755 index 0000000000..827de1be34 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ListValueWithVariable.java @@ -0,0 +1,35 @@ +/* Generated by: JJTree: Do not edit this line. ListValueWithVariable.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.*; + +public class ListValueWithVariable extends AbstractValue { + protected List values = new ArrayList<>(); + + public ListValueWithVariable(int id) { + super(id); + } + + public ListValueWithVariable(GraphQLParser p, int id) { + super(p, id); + } + + @Override + public Object getValue() { + return values; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + @Override + public String toString() { + return "ListValueWithVariable{" + values + '}'; + } +} +/* ParserGeneratorCC - OriginalChecksum=672edbff41d8e3737c5653f4b48b9d12 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Name.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Name.java new file mode 100755 index 0000000000..f75f9799de --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Name.java @@ -0,0 +1,28 @@ +/* Generated by: JJTree: Do not edit this line. Name.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class Name extends SimpleNode { + String value; + + public Name(int id) { + super(id); + } + + public Name(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + @Override + public String toString() { + return "Name{" + value + '}'; + } +} +/* ParserGeneratorCC - OriginalChecksum=bd50e2b87b7256145dfaab2aee30f3e9 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Node.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Node.java new file mode 100755 index 0000000000..f24e263fff --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Node.java @@ -0,0 +1,52 @@ +/* Generated by: JJTree: Do not edit this line. Node.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=false,NODE_USES_PARSER=false,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +/* All AST nodes must implement this interface. It provides basic + machinery for constructing the parent and child relationships + between nodes. */ + +public +interface Node extends java.io.Serializable { + /** This method is called after the node has been made the current + node. It indicates that child nodes can now be added to it. */ + void jjtOpen(); + + /** This method is called after all the child nodes have been + added. */ + void jjtClose(); + + /** + * Set the parent node of this node + * @param n parent node to set + */ + void jjtSetParent(Node n); + + /** + * @return parent node + */ + Node jjtGetParent(); + + /** + * This method tells the node to add its argument to the node's + * list of children. + * @param n node to add as a child + * @param i zero-based index where to add the child + */ + void jjtAddChild(Node n, int i); + + /** + * This method returns a child node. The children are numbered + * from zero, left to right. + * @param i zero-baeed child index + */ + Node jjtGetChild(int i); + + /** + * @return the number of children the node has. Always ≥ 0. + */ + int jjtGetNumChildren(); + + int getId(); +} +/* ParserGeneratorCC - OriginalChecksum=9e98cbfeabe2d9744f96749c7480aa19 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectField.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectField.java new file mode 100755 index 0000000000..f325b54cab --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectField.java @@ -0,0 +1,28 @@ +/* Generated by: JJTree: Do not edit this line. ObjectField.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class ObjectField extends SimpleNode { + protected Name name; + protected Value value; + + public ObjectField(int id) { + super(id); + } + + public ObjectField(GraphQLParser p, int id) { + super(p, id); + } + + public String getName() { + return name != null ? name.value : null; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=9d5773c7ec0ad7d266c683e3b2a33f31 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectFieldWithValue.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectFieldWithValue.java new file mode 100755 index 0000000000..c0b241cf61 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectFieldWithValue.java @@ -0,0 +1,29 @@ +/* Generated by: JJTree: Do not edit this line. ObjectFieldWithValue.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class ObjectFieldWithValue extends SimpleNode { + + protected Name name; + protected ValueWithVariable value; + + public ObjectFieldWithValue(int id) { + super(id); + } + + public ObjectFieldWithValue(GraphQLParser p, int id) { + super(p, id); + } + + public String getName() { + return name != null ? name.value : null; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=d85f205267573b6f9cb2631f3b734388 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectTypeDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectTypeDefinition.java new file mode 100755 index 0000000000..edb15ce8e7 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectTypeDefinition.java @@ -0,0 +1,58 @@ +/* Generated by: JJTree: Do not edit this line. ObjectTypeDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.*; + +public class ObjectTypeDefinition extends TypeDefinition { + + protected Name name; + protected ImplementsInterface implementsInterface; + protected Directives directives; + protected List fieldDefinitions = new ArrayList<>(); + + public ObjectTypeDefinition(int id) { + super(id); + } + + public ObjectTypeDefinition(GraphQLParser p, int id) { + super(p, id); + } + + public String getName() { + return name != null ? name.value : null; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public List getFieldDefinitions() { + return fieldDefinitions; + } + + public FieldDefinition getFieldDefinitionByPath(final String path) { + final int sep = path.indexOf("."); + if (sep > -1) { + final String prefix = path.substring(0, sep); + final FieldDefinition field = getFieldDefinitionByPath(prefix); + if (field != null) { + + } + } + + return getFieldDefinitionByName(path); + } + + public FieldDefinition getFieldDefinitionByName(final String fieldName) { + for (FieldDefinition f : fieldDefinitions) { + if (f.getName().equals(fieldName)) + return f; + } + return null; + } +} +/* ParserGeneratorCC - OriginalChecksum=22e41e7403da6914e57ff609136bdc3e (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectValue.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectValue.java new file mode 100755 index 0000000000..4a4e8d56fc --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectValue.java @@ -0,0 +1,28 @@ +/* Generated by: JJTree: Do not edit this line. ObjectValue.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.ArrayList; +import java.util.List; + +public +class ObjectValue extends SimpleNode { + + protected List values = new ArrayList<>(); + + public ObjectValue(int id) { + super(id); + } + + public ObjectValue(GraphQLParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return + visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=43f093da6ca25f39a972b74ac9c2f063 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectValueWithVariable.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectValueWithVariable.java new file mode 100755 index 0000000000..f1b4df2a8f --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ObjectValueWithVariable.java @@ -0,0 +1,35 @@ +/* Generated by: JJTree: Do not edit this line. ObjectValueWithVariable.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.*; + +public class ObjectValueWithVariable extends AbstractValue { + protected List values = new ArrayList<>(); + + public ObjectValueWithVariable(int id) { + super(id); + } + + public ObjectValueWithVariable(GraphQLParser p, int id) { + super(p, id); + } + + @Override + public Object getValue() { + return values; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + @Override + public String toString() { + return "ObjectValueWithVariable{" + values + '}'; + } +} +/* ParserGeneratorCC - OriginalChecksum=db23ca8591e199b1d772ae148743a174 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/OperationDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/OperationDefinition.java new file mode 100755 index 0000000000..e63bf245c9 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/OperationDefinition.java @@ -0,0 +1,43 @@ +/* Generated by: JJTree: Do not edit this line. OperationDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class OperationDefinition extends Definition { + protected SelectionSet selectionSet; + protected OperationType operationType; + protected Name name; + protected VariableDefinitions variableDefinitions; + protected Directives directives; + + public OperationDefinition(int id) { + super(id); + } + + public OperationDefinition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public SelectionSet getSelectionSet() { + return selectionSet; + } + + public Directives getDirectives() { + return directives; + } + + public boolean isQuery() { + return operationType == null || operationType.isQuery(); + } + + public String getName() { + return name != null ? name.value : null; + } +} +/* ParserGeneratorCC - OriginalChecksum=e02cbdbebbb7227a93ebc862dcd13871 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/OperationType.java b/graphql/src/main/java/com/arcadedb/graphql/parser/OperationType.java new file mode 100755 index 0000000000..9d3b2a1ac4 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/OperationType.java @@ -0,0 +1,29 @@ +/* Generated by: JJTree: Do not edit this line. OperationType.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class OperationType extends SimpleNode { + + protected boolean mutation = false; + protected boolean query = false; + + public OperationType(int id) { + super(id); + } + + public OperationType(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public boolean isQuery() { + return query; + } +} +/* ParserGeneratorCC - OriginalChecksum=68467c458edb7fe5b5133928f474d3d5 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/OperationTypeDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/OperationTypeDefinition.java new file mode 100755 index 0000000000..f9c78c2271 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/OperationTypeDefinition.java @@ -0,0 +1,25 @@ +/* Generated by: JJTree: Do not edit this line. OperationTypeDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class OperationTypeDefinition extends SimpleNode { + + protected OperationType operationType; + protected TypeName typeName; + + public OperationTypeDefinition(int id) { + super(id); + } + + public OperationTypeDefinition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=fd8564df2af33b83b138cd0ee5078447 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ParseException.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ParseException.java new file mode 100755 index 0000000000..703c3630dc --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ParseException.java @@ -0,0 +1,189 @@ +/* Generated by: ParserGeneratorCC: Do not edit this line. ParseException.java Version 1.1 */ +/* ParserGeneratorCCOptions:KEEP_LINE_COLUMN=true */ +package com.arcadedb.graphql.parser; + +/** + * This exception is thrown when parse errors are encountered. + * You can explicitly create objects of this exception type by + * calling the method generateParseException in the generated + * parser. + * + * You can modify this class to customize your error reporting + * mechanisms so long as you retain the public fields. + */ +public class ParseException extends Exception { + /** + * The end of line string for this machine. + */ + protected static final String EOL = System.getProperty("line.separator", "\n"); + + /** + * This constructor is used by the method "generateParseException" + * in the generated parser. Calling this constructor generates + * a new object of this type with the fields "currentToken", + * "expectedTokenSequences", and "tokenImage" set. + */ + public ParseException(final Token currentTokenVal, + final int[][] expectedTokenSequencesVal, + final String[] tokenImageVal) + { + super(_initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal)); + currentToken = currentTokenVal; + expectedTokenSequences = expectedTokenSequencesVal; + tokenImage = tokenImageVal; + } + + /** + * The following constructors are for use by you for whatever + * purpose you can think of. Constructing the exception in this + * manner makes the exception behave in the normal way - i.e., as + * documented in the class "Throwable". The fields "errorToken", + * "expectedTokenSequences", and "tokenImage" do not contain + * relevant information. The JavaCC generated code does not use + * these constructors. + */ + + public ParseException() { + super(); + } + + /** Constructor with message. */ + public ParseException(String message) { + super(message); + } + + + /** + * This is the last token that has been consumed successfully. If + * this object has been created due to a parse error, the token + * followng this token will (therefore) be the first error token. + */ + public Token currentToken; + + /** + * Each entry in this array is an array of integers. Each array + * of integers represents a sequence of tokens (by their ordinal + * values) that is expected at this point of the parse. + */ + public int[][] expectedTokenSequences; + + /** + * This is a reference to the "tokenImage" array of the generated + * parser within which the parse error occurred. This array is + * defined in the generated ...Constants interface. + */ + public String[] tokenImage; + + /** + * It uses "currentToken" and "expectedTokenSequences" to generate a parse + * error message and returns it. If this object has been created + * due to a parse error, and you do not catch it (it gets thrown + * from the parser) the correct error message + * gets displayed. + */ + private static String _initialise(final Token currentToken, + final int[][] expectedTokenSequences, + final String[] tokenImage) + { + StringBuilder expected = new StringBuilder(); + int maxSize = 0; + for (int i = 0; i < expectedTokenSequences.length; i++) { + if (maxSize < expectedTokenSequences[i].length) + maxSize = expectedTokenSequences[i].length; + for (int j = 0; j < expectedTokenSequences[i].length; j++) + expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); + + if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) + expected.append("..."); + expected.append(EOL).append(" "); + } + + StringBuilder sb = new StringBuilder(); + sb.append ("Encountered \""); + + Token tok = currentToken.next; + for (int i = 0; i < maxSize; i++) { + String tokenText = tok.image; + String escapedTokenText = add_escapes(tokenText); + if (i != 0) + sb.append (' '); + if (tok.kind == 0) { + sb.append(tokenImage[0]); + break; + } + sb.append(" " + tokenImage[tok.kind]); + sb.append(" \""); + sb.append(escapedTokenText); + sb.append("\""); + tok = tok.next; + } + sb.append ("\" at line ") + .append (currentToken.next.beginLine) + .append (", column ") + .append (currentToken.next.beginColumn); + sb.append(".").append(EOL); + + if (expectedTokenSequences.length == 0) { + // Nothing to add here + } else { + sb.append (EOL) + .append ("Was expecting") + .append (expectedTokenSequences.length == 1 ? ":" : " one of:") + .append (EOL) + .append (EOL) + .append (expected); + } + + return sb.toString (); + } + + + /** + * Used to convert raw characters to their escaped version + * when these raw version cannot be used as part of an ASCII + * string literal. + */ + static String add_escapes(String str) { + final StringBuilder retval = new StringBuilder(); + for (int i = 0; i < str.length(); i++) { + final char ch = str.charAt(i); + switch (ch) + { + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if (ch < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u").append (s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } +} +/* ParserGeneratorCC - OriginalChecksum=60ea1135d475bf2739bfeb9592e1a376 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ScalarTypeDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ScalarTypeDefinition.java new file mode 100755 index 0000000000..4c5c4647ac --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ScalarTypeDefinition.java @@ -0,0 +1,29 @@ +/* Generated by: JJTree: Do not edit this line. ScalarTypeDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class ScalarTypeDefinition extends TypeDefinition { + + protected Name name; + protected Directives directives; + + public ScalarTypeDefinition(int id) { + super(id); + } + + public ScalarTypeDefinition(GraphQLParser p, int id) { + super(p, id); + } + + public String getName() { + return name != null ? name.value : null; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=6e8b3a7ca60f3dcd59d75d4e9935e618 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/SchemaDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/SchemaDefinition.java new file mode 100755 index 0000000000..26665642a5 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/SchemaDefinition.java @@ -0,0 +1,28 @@ +/* Generated by: JJTree: Do not edit this line. SchemaDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.ArrayList; +import java.util.List; + +public class SchemaDefinition extends SimpleNode { + + protected Directives directives; + List operationTypeDefinitions = new ArrayList<>(); + + public SchemaDefinition(int id) { + super(id); + } + + public SchemaDefinition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=638a433ba28dc8ac47ea4183e6ab21d5 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Selection.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Selection.java new file mode 100755 index 0000000000..b2696ebcb4 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Selection.java @@ -0,0 +1,41 @@ +/* Generated by: JJTree: Do not edit this line. Selection.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class Selection extends SimpleNode { + + protected Name name; + protected FieldWithAlias fieldWithAlias; + protected Field field; + protected boolean ellipsis = false; + protected FragmentSpread fragmentSpread; + protected InlineFragment inlineFragment; + + public Selection(int id) { + super(id); + } + + public Selection(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public String getName() { + return name != null ? name.value : null; + } + + public Field getField() { + return field; + } + + public FieldWithAlias getFieldWithAlias() { + return fieldWithAlias; + } +} +/* ParserGeneratorCC - OriginalChecksum=aac9a2d576730b830f5ef7c02bdf7951 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/SelectionSet.java b/graphql/src/main/java/com/arcadedb/graphql/parser/SelectionSet.java new file mode 100755 index 0000000000..a9c384c9f1 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/SelectionSet.java @@ -0,0 +1,29 @@ +/* Generated by: JJTree: Do not edit this line. SelectionSet.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.*; + +public class SelectionSet extends SimpleNode { + List selections = new ArrayList<>(); + + public SelectionSet(int id) { + super(id); + } + + public SelectionSet(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public List getSelections() { + return selections; + } +} +/* ParserGeneratorCC - OriginalChecksum=1bfe30b29b4f429aad0444a9219ce976 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/SimpleCharStream.java b/graphql/src/main/java/com/arcadedb/graphql/parser/SimpleCharStream.java new file mode 100755 index 0000000000..9711db7352 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/SimpleCharStream.java @@ -0,0 +1,127 @@ +/* Generated by: ParserGeneratorCC: Do not edit this line. SimpleCharStream.java Version 1.1 */ +/* ParserGeneratorCCOptions:SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +/** + * An implementation of interface CharStream, where the stream is assumed to + * contain only ASCII characters (without unicode processing). + */ +public +class SimpleCharStream extends AbstractCharStream +{ + private java.io.Reader m_aIS; + + /** Constructor. */ + public SimpleCharStream(final java.io.Reader dstream, + final int startline, + final int startcolumn, + final int buffersize) + { + super (startline, startcolumn, buffersize); + m_aIS = dstream; + } + + /** Constructor. */ + public SimpleCharStream(final java.io.Reader dstream, + final int startline, + final int startcolumn) + { + this(dstream, startline, startcolumn, DEFAULT_BUF_SIZE); + } + + /** Constructor. */ + public SimpleCharStream(final java.io.Reader dstream) + { + this(dstream, 1, 1, DEFAULT_BUF_SIZE); + } + + /** Reinitialise. */ + public void reInit(final java.io.Reader dstream, + final int startline, + final int startcolumn, + final int buffersize) + { + m_aIS = dstream; + super.reInit (startline, startcolumn, buffersize); + } + + /** Reinitialise. */ + public void reInit(final java.io.Reader dstream, + final int startline, + final int startcolumn) + { + reInit(dstream, startline, startcolumn, DEFAULT_BUF_SIZE); + } + + /** Reinitialise. */ + public void reInit(final java.io.Reader dstream) + { + reInit(dstream, 1, 1, DEFAULT_BUF_SIZE); + } + + /** Constructor. */ + public SimpleCharStream(final java.io.InputStream dstream, + final java.nio.charset.Charset encoding, + final int startline, + final int startcolumn, + final int buffersize) + { + this(new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + /** Constructor. */ + public SimpleCharStream(final java.io.InputStream dstream, + final java.nio.charset.Charset encoding, + final int startline, + final int startcolumn) + { + this(dstream, encoding, startline, startcolumn, DEFAULT_BUF_SIZE); + } + + /** Constructor. */ + public SimpleCharStream(final java.io.InputStream dstream, + final java.nio.charset.Charset encoding) + { + this(dstream, encoding, 1, 1, DEFAULT_BUF_SIZE); + } + + /** Reinitialise. */ + public void reInit(final java.io.InputStream dstream, + final java.nio.charset.Charset encoding) + { + reInit(dstream, encoding, 1, 1, DEFAULT_BUF_SIZE); + } + + /** Reinitialise. */ + public void reInit(final java.io.InputStream dstream, + final java.nio.charset.Charset encoding, + final int startline, + final int startcolumn) + { + reInit(dstream, encoding, startline, startcolumn, DEFAULT_BUF_SIZE); + } + + /** Reinitialise. */ + public void reInit(final java.io.InputStream dstream, + final java.nio.charset.Charset encoding, + final int startline, + final int startcolumn, + final int buffersize) + { + reInit(new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + @Override + protected int streamRead (final char[] aBuf, final int nOfs, final int nLen) throws java.io.IOException + { + return m_aIS.read (aBuf, nOfs, nLen); + } + + @Override + protected void streamClose () throws java.io.IOException + { + if (m_aIS != null) + m_aIS.close (); + } +} +/* ParserGeneratorCC - OriginalChecksum=288df214d89d601f3bd87b0d29305baf (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/SimpleNode.java b/graphql/src/main/java/com/arcadedb/graphql/parser/SimpleNode.java new file mode 100755 index 0000000000..49dc0eabde --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/SimpleNode.java @@ -0,0 +1,124 @@ +/* Generated by: JJTree: Do not edit this line. SimpleNode.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=false,NODE_USES_PARSER=false,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import com.arcadedb.query.sql.parser.SqlParserVisitor; + +public class SimpleNode implements Node { + protected Node parent; + protected Node[] children; + protected int id; + protected Object value; + protected GraphQLParser parser; + protected Token firstToken; + protected Token lastToken; + + public SimpleNode(final int i) { + id = i; + } + + public SimpleNode(final GraphQLParser p, final int i) { + this(i); + parser = p; + } + + public void jjtOpen() { + } + + public void jjtClose() { + } + + public void jjtSetParent(final Node n) { + parent = n; + } + + public Node jjtGetParent() { + return parent; + } + + public void jjtAddChild(final Node n, final int i) { + if (children == null) { + children = new Node[i + 1]; + } else if (i >= children.length) { + Node c[] = new Node[i + 1]; + System.arraycopy(children, 0, c, 0, children.length); + children = c; + } + children[i] = n; + } + + public Node jjtGetChild(final int i) { + return children[i]; + } + + public int jjtGetNumChildren() { + return children == null ? 0 : children.length; + } + + public void jjtSetValue(final Object aValue) { + value = aValue; + } + + public Object jjtGetValue() { + return value; + } + + /* You can override these two methods in subclasses of SimpleNode to + customize the way the node appears when the tree is dumped. If + your output uses more than one line you should override + toString(String), otherwise overriding toString() is probably all + you need to do. */ + @Override + public String toString() { + return GraphQLParserTreeConstants.jjtNodeName[id]; + } + + public String toString(String prefix) { + return prefix + toString(); + } + + protected void dumpString(String s) { + // TODO get rid of this + System.out.println(s); + } + + /* Override this method if you want to customize how the node dumps + out its children. */ + public void dump(String prefix) { + dumpString(toString(prefix)); + if (children != null) { + for (int i = 0; i < children.length; ++i) { + SimpleNode n = (SimpleNode) children[i]; + if (n != null) + n.dump(prefix + " "); + } + } + } + + public int getId() { + return id; + } + + public void jjtSetFirstToken(Token token) { + this.firstToken = token; + } + + public void jjtSetLastToken(Token token) { + this.lastToken = token; + } + + public Object childrenAccept(SqlParserVisitor visitor, Object data) { + if (children != null) { + for (int i = 0; i < children.length; ++i) { +// children[i].jjtAccept(visitor, data);//TODO fix + } + } + return data; + } + + public Node[] getChildren() { + return children; + } +} + +/* ParserGeneratorCC - OriginalChecksum=a932dd6e6d33187f6cbda5ebe13d5edb (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/StringValue.java b/graphql/src/main/java/com/arcadedb/graphql/parser/StringValue.java new file mode 100755 index 0000000000..dfdff2c9be --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/StringValue.java @@ -0,0 +1,34 @@ +/* Generated by: JJTree: Do not edit this line. StringValue.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class StringValue extends AbstractValue { + protected String val; + + public StringValue(int id) { + super(id); + } + + public StringValue(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + @Override + public String toString() { + return "StringValue{" + val + '}'; + } + + public String getValue() { +// if (val != null && val.startsWith("\"")) +// return val.substring(1, val.length() - 1); + return val; + } +} +/* ParserGeneratorCC - OriginalChecksum=20e0a8fec30917a1654cd45e385fe65f (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Token.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Token.java new file mode 100755 index 0000000000..de2841397f --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Token.java @@ -0,0 +1,132 @@ +/* Generated by: ParserGeneratorCC: Do not edit this line. Token.java Version 1.1 */ +/* ParserGeneratorCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +/** + * Describes the input token stream. + */ + +public class Token +implements java.io.Serializable { + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + /** + * An integer that describes the kind of this token. This numbering + * system is determined by JavaCCParser, and a table of these numbers is + * stored in the file ...Constants.java. + */ + public int kind; + + /** The line number of the first character of this Token. */ + public int beginLine; + /** The column number of the first character of this Token. */ + public int beginColumn; + /** The line number of the last character of this Token. */ + public int endLine; + /** The column number of the last character of this Token. */ + public int endColumn; + + /** + * The string image of the token. + */ + public String image; + + /** + * A reference to the next regular (non-special) token from the input + * stream. If this is the last token from the input stream, or if the + * token manager has not read tokens beyond this one, this field is + * set to null. This is true only if this token is also a regular + * token. Otherwise, see below for a description of the contents of + * this field. + */ + public Token next; + + /** + * This field is used to access special tokens that occur prior to this + * token, but after the immediately preceding regular (non-special) token. + * If there are no such special tokens, this field is set to null. + * When there are more than one such special token, this field refers + * to the last of these special tokens, which in turn refers to the next + * previous special token through its specialToken field, and so on + * until the first special token (whose specialToken field is null). + * The next fields of special tokens refer to other special tokens that + * immediately follow it (without an intervening regular token). If there + * is no such token, this field is null. + */ + public Token specialToken; + + /** + * No-argument constructor + */ + public Token() {} + + /** + * Constructs a new token for the specified Image. + */ + public Token(final int nKind) + { + this(nKind, null); + } + + /** + * Constructs a new token for the specified Image and Kind. + */ + public Token(final int nKind, final String sImage) + { + this.kind = nKind; + this.image = sImage; + } + + /** + * An optional attribute value of the Token. + * Tokens which are not used as syntactic sugar will often contain + * meaningful values that will be used later on by the compiler or + * interpreter. This attribute value is often different from the image. + * Any subclass of Token that actually wants to return a non-null value can + * override this method as appropriate. + */ + public Object getValue() { + return null; + } + + /** + * Returns the image. + */ + @Override + public String toString() + { + return image; + } + + /** + * Returns a new Token object, by default. However, if you want, you + * can create and return subclass objects based on the value of ofKind. + * Simply add the cases to the switch for all those special cases. + * For example, if you have a subclass of Token called IDToken that + * you want to create if ofKind is ID, simply add something like : + * + * case MyParserConstants.ID : return new IDToken(ofKind, image); + * + * to the following switch statement. Then you can cast matchedToken + * variable to the appropriate type and use sit in your lexical actions. + */ + public static Token newToken(int ofKind, String image) + { + switch(ofKind) + { + default : return new Token(ofKind, image); + } + } + + public static Token newToken(int ofKind) + { + return newToken(ofKind, null); + } + +} +/* ParserGeneratorCC - OriginalChecksum=a833f01a0fe7069708c6b6e5827f5b76 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/TokenMgrException.java b/graphql/src/main/java/com/arcadedb/graphql/parser/TokenMgrException.java new file mode 100755 index 0000000000..68ec42e9e2 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/TokenMgrException.java @@ -0,0 +1,146 @@ +/* Generated by: ParserGeneratorCC: Do not edit this line. TokenMgrException.java Version 1.1 */ +/* ParserGeneratorCCOptions: */ +package com.arcadedb.graphql.parser; + +/** Token Manager Error. */ +public class TokenMgrException extends RuntimeException +{ + + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + /* + * Ordinals for various reasons why an Error of this type can be thrown. + */ + + /** + * Lexical error occurred. + */ + public static final int LEXICAL_ERROR = 0; + + /** + * An attempt was made to create a second instance of a static token manager. + */ + public static final int STATIC_LEXER_ERROR = 1; + + /** + * Tried to change to an invalid lexical state. + */ + public static final int INVALID_LEXICAL_STATE = 2; + + /** + * Detected (and bailed out of) an infinite loop in the token manager. + */ + public static final int LOOP_DETECTED = 3; + + /** + * Indicates the reason why the exception is thrown. It will have + * one of the above 4 values. + */ + int errorCode; + + /** + * Replaces unprintable characters by their escaped (or unicode escaped) + * equivalents in the given string + */ + protected static final String addEscapes(String str) { + StringBuilder retval = new StringBuilder(); + for (int i = 0; i < str.length(); i++) { + final char ch = str.charAt(i); + switch (ch) + { + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if (ch < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u").append (s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + + /** + * Returns a detailed message for the Error when it is thrown by the + * token manager to indicate a lexical error. + * Parameters : + * EOFSeen : indicates if EOF caused the lexical error + * curLexState : lexical state in which this error occurred + * errorLine : line number when the error occurred + * errorColumn : column number when the error occurred + * errorAfter : prefix that was seen before this error occurred + * curchar : the offending character + * Note: You can customize the lexical error message by modifying this method. + */ + protected static String LexicalErr(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar) { + char curChar1 = (char)curChar; + return("Lexical error at line " + + errorLine + ", column " + + errorColumn + ". Encountered: " + + (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar1)) + "\"") + " (" + curChar + "), ") + + "after : \"" + addEscapes(errorAfter) + "\""); + } + + /** + * You can also modify the body of this method to customize your error messages. + * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not + * of end-users concern, so you can return something like : + * + * "Internal Error : Please file a bug report .... " + * + * from this method for such cases in the release version of your parser. + */ + @Override + public String getMessage() { + return super.getMessage(); + } + + /* + * Constructors of various flavors follow. + */ + /** No arg constructor. */ + public TokenMgrException() { + } + + /** Constructor with message and reason. */ + public TokenMgrException(String message, int reason) { + super(message); + errorCode = reason; + } + + /** Full Constructor. */ + public TokenMgrException(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) { + this(LexicalErr(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); + } +} +/* ParserGeneratorCC - OriginalChecksum=1eb9c2aa79556af2bd3015d2ff9a0b18 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Type.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Type.java new file mode 100755 index 0000000000..44ca975137 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Type.java @@ -0,0 +1,37 @@ +/* Generated by: JJTree: Do not edit this line. Type.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class Type extends SimpleNode { + protected TypeName typeName; + boolean bang = false; + protected ListType listType; + + public Type(int id) { + super(id); + } + + public Type(GraphQLParser p, int id) { + super(p, id); + } + + public ListType getListType() { + return listType; + } + + public TypeName getTypeName() { + return typeName; + } + + public boolean isBang() { + return bang; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=c03be8fb7a8fc8bf149d18a7ff368c74 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/TypeCondition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/TypeCondition.java new file mode 100755 index 0000000000..8bb76f88f2 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/TypeCondition.java @@ -0,0 +1,24 @@ +/* Generated by: JJTree: Do not edit this line. TypeCondition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public +class TypeCondition extends SimpleNode { + + protected TypeName name; + public TypeCondition(int id) { + super(id); + } + + public TypeCondition(GraphQLParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return + visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=29df67b79bac10f7c2d7db706ec651dc (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/TypeDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/TypeDefinition.java new file mode 100755 index 0000000000..4ae28105fa --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/TypeDefinition.java @@ -0,0 +1,21 @@ +/* Generated by: JJTree: Do not edit this line. TypeDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class TypeDefinition extends SimpleNode { + public TypeDefinition(int id) { + super(id); + } + + public TypeDefinition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=33cd8382c24ca5f69a75be6cfc0e35b2 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/TypeExtensionDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/TypeExtensionDefinition.java new file mode 100755 index 0000000000..4ba099f07a --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/TypeExtensionDefinition.java @@ -0,0 +1,25 @@ +/* Generated by: JJTree: Do not edit this line. TypeExtensionDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public +class TypeExtensionDefinition extends SimpleNode { + + ObjectTypeDefinition objectTypeDefinition; + + public TypeExtensionDefinition(int id) { + super(id); + } + + public TypeExtensionDefinition(GraphQLParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return + visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=d55c3b56133043101f134e95980b384c (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/TypeName.java b/graphql/src/main/java/com/arcadedb/graphql/parser/TypeName.java new file mode 100755 index 0000000000..728e4f0091 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/TypeName.java @@ -0,0 +1,27 @@ +/* Generated by: JJTree: Do not edit this line. TypeName.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class TypeName extends SimpleNode { + protected Name name; + + public TypeName(int id) { + super(id); + } + + public TypeName(GraphQLParser p, int id) { + super(p, id); + } + + public String getName() { + return name != null ? name.value : null; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=d93c0e2c84e43cfe8e5dd3b12a3acd40 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/TypeSystemDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/TypeSystemDefinition.java new file mode 100755 index 0000000000..67750170f7 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/TypeSystemDefinition.java @@ -0,0 +1,31 @@ +/* Generated by: JJTree: Do not edit this line. TypeSystemDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class TypeSystemDefinition extends Definition { + + protected SchemaDefinition schemaDefinition; + protected TypeDefinition typeDefinition; + protected TypeExtensionDefinition typeExtensionDefinition; + protected DirectiveDefinition directiveDefinition; + + public TypeSystemDefinition(int id) { + super(id); + } + + public TypeSystemDefinition(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public TypeDefinition getTypeDefinition() { + return typeDefinition; + } +} +/* ParserGeneratorCC - OriginalChecksum=005bc98eb4088c1be28f3ba6eab61937 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/UnionMembers.java b/graphql/src/main/java/com/arcadedb/graphql/parser/UnionMembers.java new file mode 100755 index 0000000000..ef7bb3e009 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/UnionMembers.java @@ -0,0 +1,27 @@ +/* Generated by: JJTree: Do not edit this line. UnionMembers.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.ArrayList; +import java.util.List; + +public +class UnionMembers extends SimpleNode { + protected List typeNames = new ArrayList<>(); + + public UnionMembers(int id) { + super(id); + } + + public UnionMembers(GraphQLParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return + visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=f97c07f2fcabe34be203e80b7dda6297 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/UnionTypeDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/UnionTypeDefinition.java new file mode 100755 index 0000000000..0bdacf8105 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/UnionTypeDefinition.java @@ -0,0 +1,30 @@ +/* Generated by: JJTree: Do not edit this line. UnionTypeDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class UnionTypeDefinition extends TypeDefinition { + + protected Name name; + protected Directives directives; + protected UnionMembers unionMembers; + + public UnionTypeDefinition(int id) { + super(id); + } + + public UnionTypeDefinition(GraphQLParser p, int id) { + super(p, id); + } + + public String getName() { + return name != null ? name.value : null; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=e6e65813d48e37395b67db4c66d1b77a (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/Value.java b/graphql/src/main/java/com/arcadedb/graphql/parser/Value.java new file mode 100755 index 0000000000..e0f8044a7e --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/Value.java @@ -0,0 +1,36 @@ +/* Generated by: JJTree: Do not edit this line. Value.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public +class Value extends SimpleNode { + protected IntValue intValue; + + protected FloatValue floatValue; + + protected StringValue stringValue; + + protected BooleanValue booleanValue; + + protected EnumValue enumValue; + + protected ListValue listValue; + + protected ObjectValue objectValue; + + public Value(int id) { + super(id); + } + + public Value(GraphQLParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return + visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=3b4e38a9efac4b8f5a5e4a77f5ffce49 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/ValueWithVariable.java b/graphql/src/main/java/com/arcadedb/graphql/parser/ValueWithVariable.java new file mode 100755 index 0000000000..0aa2abb148 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/ValueWithVariable.java @@ -0,0 +1,52 @@ +/* Generated by: JJTree: Do not edit this line. ValueWithVariable.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class ValueWithVariable extends SimpleNode { + + protected VariableLiteral variableLiteral; + protected IntValue intValue; + protected FloatValue floatValue; + protected StringValue stringValue; + protected BooleanValue booleanValue; + protected EnumValue enumValue; + protected ListValueWithVariable listValueWithVariable; + protected ObjectValueWithVariable objectValueWithVariable; + + public ValueWithVariable(int id) { + super(id); + } + + public ValueWithVariable(GraphQLParser p, int id) { + super(p, id); + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public AbstractValue getValue() { + if (variableLiteral != null) + return variableLiteral; + else if (intValue != null) + return intValue; + else if (floatValue != null) + return floatValue; + else if (stringValue != null) + return stringValue; + else if (booleanValue != null) + return booleanValue; + else if (enumValue != null) + return enumValue; + else if (listValueWithVariable != null) + return listValueWithVariable; + else if (objectValueWithVariable != null) + return objectValueWithVariable; + + return null; + } +} +/* ParserGeneratorCC - OriginalChecksum=7d715420456ed7cdb3c0875b52f6a13a (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/VariableDefinition.java b/graphql/src/main/java/com/arcadedb/graphql/parser/VariableDefinition.java new file mode 100755 index 0000000000..ac8de5cf27 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/VariableDefinition.java @@ -0,0 +1,29 @@ +/* Generated by: JJTree: Do not edit this line. VariableDefinition.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public +class VariableDefinition extends SimpleNode { + + + protected VariableLiteral variableLiteral; + protected Type type; + protected DefaultValue defaultValue; + + + public VariableDefinition(int id) { + super(id); + } + + public VariableDefinition(GraphQLParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return + visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=d27742fee491b437eadc17b1257844df (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/VariableDefinitions.java b/graphql/src/main/java/com/arcadedb/graphql/parser/VariableDefinitions.java new file mode 100755 index 0000000000..a45d4ce8ca --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/VariableDefinitions.java @@ -0,0 +1,28 @@ +/* Generated by: JJTree: Do not edit this line. VariableDefinitions.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +import java.util.ArrayList; +import java.util.List; + +public +class VariableDefinitions extends SimpleNode { + + List variableDefinitions = new ArrayList<>(); + + public VariableDefinitions(int id) { + super(id); + } + + public VariableDefinitions(GraphQLParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return + visitor.visit(this, data); + } +} +/* ParserGeneratorCC - OriginalChecksum=67363ba7b163703fd2b2ad5392ae12ee (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/parser/VariableLiteral.java b/graphql/src/main/java/com/arcadedb/graphql/parser/VariableLiteral.java new file mode 100755 index 0000000000..cd277693f2 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/parser/VariableLiteral.java @@ -0,0 +1,31 @@ +/* Generated by: JJTree: Do not edit this line. VariableLiteral.java Version 1.1 */ +/* ParserGeneratorCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.arcadedb.graphql.parser; + +public class VariableLiteral extends AbstractValue { + public VariableLiteral(int id) { + super(id); + } + + public VariableLiteral(GraphQLParser p, int id) { + super(p, id); + } + + @Override + public Object getValue() { + return value; + } + + /** + * Accept the visitor. + **/ + public Object jjtAccept(GraphQLParserVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + @Override + public String toString() { + return "VariableLiteral{" + name + '}'; + } +} +/* ParserGeneratorCC - OriginalChecksum=1d24a436d5861d19357de949dd126579 (do not edit this line) */ diff --git a/graphql/src/main/java/com/arcadedb/graphql/schema/GraphQLResult.java b/graphql/src/main/java/com/arcadedb/graphql/schema/GraphQLResult.java new file mode 100644 index 0000000000..08fea28c2b --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/schema/GraphQLResult.java @@ -0,0 +1,47 @@ +/* + * Copyright 2021 Arcade Data Ltd + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package com.arcadedb.graphql.schema; + +import com.arcadedb.database.RID; +import com.arcadedb.query.sql.executor.ResultInternal; + +import java.util.*; + +/** + * @author Luca Garulli (l.garulli@arcadedata.com) + */ +public class GraphQLResult extends ResultInternal { + RID identity; + + public GraphQLResult() { + } + + public GraphQLResult(Map map) { + super(map); + identity = (RID) map.remove("@rid"); + } + + @Override + public Optional getIdentity() { + return identity == null ? Optional.empty() : Optional.of(identity); + } +} diff --git a/graphql/src/main/java/com/arcadedb/graphql/schema/GraphQLResultSet.java b/graphql/src/main/java/com/arcadedb/graphql/schema/GraphQLResultSet.java new file mode 100644 index 0000000000..549bbaefa0 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/schema/GraphQLResultSet.java @@ -0,0 +1,172 @@ +/* + * Copyright 2021 Arcade Data Ltd + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package com.arcadedb.graphql.schema; + +import com.arcadedb.database.Document; +import com.arcadedb.graph.Vertex; +import com.arcadedb.graphql.parser.Argument; +import com.arcadedb.graphql.parser.Directive; +import com.arcadedb.graphql.parser.Directives; +import com.arcadedb.graphql.parser.Field; +import com.arcadedb.graphql.parser.FieldDefinition; +import com.arcadedb.graphql.parser.ObjectTypeDefinition; +import com.arcadedb.graphql.parser.Selection; +import com.arcadedb.graphql.parser.SelectionSet; +import com.arcadedb.query.sql.executor.ExecutionPlan; +import com.arcadedb.query.sql.executor.Result; +import com.arcadedb.query.sql.executor.ResultInternal; +import com.arcadedb.query.sql.executor.ResultSet; + +import java.util.*; + +/** + * @author Luca Garulli (l.garulli@arcadedata.com) + */ +public class GraphQLResultSet implements ResultSet { + private final ResultSet resultSet; + private final SelectionSet projections; + private final ObjectTypeDefinition returnType; + + public GraphQLResultSet(final ResultSet resultSet, final SelectionSet projections, final ObjectTypeDefinition returnType) { + if (resultSet == null) + throw new IllegalArgumentException("NULL resultSet"); + if (projections == null) + throw new IllegalArgumentException("NULL projections"); + + this.resultSet = resultSet; + this.projections = projections; + this.returnType = returnType; + } + + @Override + public boolean hasNext() { + return resultSet.hasNext(); + } + + @Override + public Result next() { + return mapSelectionSet(resultSet.next(), projections.getSelections()); + } + + private GraphQLResult mapSelectionSet(final Result current, final List selections) { + final Map map = new HashMap<>(); + + if (current.getElement().isPresent()) { + final Document element = current.getElement().get(); + map.put("@rid", element.getIdentity()); + } + + for (Selection sel : selections) { + final String projName = sel.getName(); + final Field field = sel.getField(); + + Object projection = current.getProperty(projName); + + if (projection == null) { + // SEARCH IN THE SCHEMA + final FieldDefinition fieldDefinition = returnType.getFieldDefinitionByName(projName); + if (fieldDefinition != null) { + final Directives directives = fieldDefinition.getDirectives(); + if (directives != null) { + for (Directive directive : directives.getDirectives()) { + if ("relationship".equals(directive.getName())) { + if (directive.getArguments() != null) { + String type = null; + Vertex.DIRECTION direction = Vertex.DIRECTION.BOTH; + for (Argument argument : directive.getArguments().getList()) { + if ("type".equals(argument.getName())) { + type = argument.getValueWithVariable().getValue().getValue().toString(); + } else if ("direction".equals(argument.getName())) { + direction = Vertex.DIRECTION.valueOf(argument.getValueWithVariable().getValue().getValue().toString()); + } + } + + if (current.getElement().isPresent()) { + Vertex vertex = current.getElement().get().asVertex(); + final Iterable connected = type != null ? vertex.getVertices(direction, type) : vertex.getVertices(direction); + projection = connected; + } + } + } + } + } + } + } + + if (projection == null) { + if (field.getDirectives() != null) { + for (Directive directive : field.getDirectives().getDirectives()) { + if ("rid".equals(directive.getName())) { + if (current.getElement().isPresent()) + projection = current.getElement().get().getIdentity(); + } else if ("type".equals(directive.getName())) { + if (current.getElement().isPresent()) + projection = current.getElement().get().getTypeName(); + } + } + } + } + + if (field.getSelectionSet() != null) { + if (projection instanceof Map) + projection = mapSelectionSet(new ResultInternal((Map) projection), field.getSelectionSet().getSelections()); + else if (projection instanceof Result) + projection = mapSelectionSet((Result) projection, field.getSelectionSet().getSelections()); + else if (projection instanceof Iterable) { + final List subResults = new ArrayList<>(); + for (Object o : ((Iterable) projection)) { + Result item; + if (o instanceof Document) + item = mapSelectionSet(new ResultInternal((Document) o), field.getSelectionSet().getSelections()); + else if (o instanceof Result) + item = mapSelectionSet((Result) projection, field.getSelectionSet().getSelections()); + else + continue; + + subResults.add(item); + } + projection = subResults; + } else + continue; + } + + map.put(projName, projection); + } + + return new GraphQLResult(map); + } + + @Override + public void close() { + resultSet.close(); + } + + @Override + public Optional getExecutionPlan() { + return Optional.empty(); + } + + @Override + public Map getQueryStats() { + return new HashMap<>(); + } +} diff --git a/graphql/src/main/java/com/arcadedb/graphql/schema/GraphQLSchema.java b/graphql/src/main/java/com/arcadedb/graphql/schema/GraphQLSchema.java new file mode 100644 index 0000000000..2979fd5443 --- /dev/null +++ b/graphql/src/main/java/com/arcadedb/graphql/schema/GraphQLSchema.java @@ -0,0 +1,147 @@ +/* + * Copyright 2021 Arcade Data Ltd + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package com.arcadedb.graphql.schema; + +import com.arcadedb.database.Database; +import com.arcadedb.exception.QueryParsingException; +import com.arcadedb.graphql.parser.AbstractValue; +import com.arcadedb.graphql.parser.Argument; +import com.arcadedb.graphql.parser.Arguments; +import com.arcadedb.graphql.parser.Definition; +import com.arcadedb.graphql.parser.Document; +import com.arcadedb.graphql.parser.Field; +import com.arcadedb.graphql.parser.FieldDefinition; +import com.arcadedb.graphql.parser.GraphQLParser; +import com.arcadedb.graphql.parser.ObjectTypeDefinition; +import com.arcadedb.graphql.parser.OperationDefinition; +import com.arcadedb.graphql.parser.ParseException; +import com.arcadedb.graphql.parser.Selection; +import com.arcadedb.graphql.parser.SelectionSet; +import com.arcadedb.graphql.parser.TypeDefinition; +import com.arcadedb.graphql.parser.TypeSystemDefinition; +import com.arcadedb.query.sql.executor.InternalResultSet; +import com.arcadedb.query.sql.executor.ResultSet; + +import java.util.*; + +public class GraphQLSchema { + private Database database; + private Map objectTypeDefinitionMap = new HashMap<>(); + private ObjectTypeDefinition queryDefinition; + + public GraphQLSchema(Database database) { + this.database = database; + } + + public ResultSet execute(final String query) throws ParseException { + final Document ast = GraphQLParser.parse(query); + + ast.dump(""); + + final List definitions = ast.getDefinitions(); + if (!definitions.isEmpty()) { + for (Definition definition : definitions) { + if (definition instanceof TypeSystemDefinition) { + TypeSystemDefinition typeSystemDefinition = (TypeSystemDefinition) definition; + + final TypeDefinition type = typeSystemDefinition.getTypeDefinition(); + if (type instanceof ObjectTypeDefinition) { + final ObjectTypeDefinition obj = (ObjectTypeDefinition) type; + objectTypeDefinitionMap.put(obj.getName(), obj); + + if ("Query".equals(obj.getName())) + // SPECIAL TYPE QUERY + queryDefinition = obj; + } + + } else if (definition instanceof OperationDefinition) { + final OperationDefinition op = ((OperationDefinition) definition); + if (op.isQuery()) { + return executeQuery(op); + } else + throw new UnsupportedOperationException("GraphQL mutations not supported yet"); + } + } + } + + return new InternalResultSet(); + } + + private ResultSet executeQuery(final OperationDefinition op) { + String from = null; + String where = ""; + + SelectionSet projection = null; + ObjectTypeDefinition returnType = null; + + try { + for (Selection selection : op.getSelectionSet().getSelections()) { + final String queryName = selection.getName(); + if (queryDefinition != null) { + for (FieldDefinition f : queryDefinition.getFieldDefinitions()) { + if (queryName.equals(f.getName())) { + final String returnTypeName = f.getType().getTypeName().getName(); + returnType = objectTypeDefinitionMap.get(returnTypeName); + if (returnType == null) + throw new QueryParsingException("Returning type '" + returnTypeName + "' not defined in GraphQL schema"); + from = returnType.getName(); + break; + } + } + } + + final Field field = selection.getField(); + if (field != null) { + final Arguments arguments = field.getArguments(); + for (Argument argument : arguments.getList()) { + final String argName = argument.getName(); + final AbstractValue argValue = argument.getValueWithVariable().getValue(); + + if (where.length() > 0) + where += " and "; + where += argName; + where += " = "; + where += argValue.getValue(); + } + + projection = field.getSelectionSet(); + } + } + + if (from == null) + throw new QueryParsingException("Target type not defined for GraphQL query"); + + String query = "select from " + from; + if (!where.isEmpty()) + query += " where " + where; + + return new GraphQLResultSet(database.query("sql", query), projection, returnType); + + } catch (QueryParsingException e) { + throw e; + } catch (Exception e) { + if (op.getName() != null) + throw new QueryParsingException("Error on executing GraphQL query '" + op.getName() + "'", e); + throw new QueryParsingException("Error on executing GraphQL query", e); + } + } +} diff --git a/graphql/src/test/java/com/arcadedb/graphql/GraphQLQueries.java b/graphql/src/test/java/com/arcadedb/graphql/GraphQLQueries.java new file mode 100644 index 0000000000..d1ad63b991 --- /dev/null +++ b/graphql/src/test/java/com/arcadedb/graphql/GraphQLQueries.java @@ -0,0 +1,123 @@ +package com.arcadedb.graphql; + +import com.arcadedb.database.Database; +import com.arcadedb.database.DatabaseFactory; +import com.arcadedb.database.RID; +import com.arcadedb.graph.MutableVertex; +import com.arcadedb.query.sql.executor.Result; +import com.arcadedb.query.sql.executor.ResultSet; +import com.arcadedb.schema.Schema; +import com.arcadedb.utility.Callable; +import com.arcadedb.utility.FileUtils; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.*; + +public class GraphQLQueries { + + private static final String DB_PATH = "./target/testgraphql"; + + @Test + public void simpleExecute() { + executeTest((database) -> { + final String types = "type Query {\n" +// + " bookById(id: ID): Book\n" +// + "}\n\n" +// + "type Book {\n" +// + " id: ID\n" +// + " name: String\n" +// + " pageCount: Int\n" +// + " authors: [Author] @relationship(type: \"IS_AUTHOR_OF\", direction: IN)\n" +// + "}\n\n" +// + "type Author {\n" +// + " id: ID\n" +// + " firstName: String\n" +// + " lastName: String\n" +// + "}"; + + database.command("graphql", types); + + RID rid = null; + try (ResultSet resultSet = database.query("graphql", "{ bookById(id: \"book-1\"){" +// + " rid @rid" +// + " id" +// + " name" +// + " pageCount" +// + " authors {" +// + " firstName" +// + " lastName" +// + " }" +// + "}" +// + "}")) { + Assertions.assertTrue(resultSet.hasNext()); + final Result record = resultSet.next(); + + System.out.println(record.toJSON()); + + rid = record.getIdentity().get(); + Assertions.assertNotNull(rid); + + Assertions.assertEquals(5, record.getPropertyNames().size()); + + Assertions.assertFalse(resultSet.hasNext()); + } + + return null; + }); + } + + @BeforeEach + @AfterEach + public void clean() { + FileUtils.deleteRecursively(new File(DB_PATH)); + } + + protected void executeTest(final Callable callback) { + try (DatabaseFactory factory = new DatabaseFactory(DB_PATH)) { + if (factory.exists()) + factory.open().drop(); + + final Database database = factory.create(); + try { + database.transaction(() -> { + Schema schema = database.getSchema(); + schema.getOrCreateVertexType("Book"); + schema.getOrCreateVertexType("Author"); + schema.getOrCreateEdgeType("IS_AUTHOR_OF"); + + MutableVertex author1 = database.newVertex("Author"); + author1.set("id", "author-1"); + author1.set("firstName", "Joanne"); + author1.set("lastName", "Rowling"); + author1.save(); + + MutableVertex book1 = database.newVertex("Book"); + book1.set("id", "book-1"); + book1.set("name", "Harry Potter and the Philosopher's Stone"); + book1.set("pageCount", 223); + book1.save(); + + MutableVertex book2 = database.newVertex("Book"); + book2.set("id", "book-2"); + book2.set("name", "Mr. brain"); + book2.set("pageCount", 422); + book2.save(); + + author1.newEdge("IS_AUTHOR_OF", book1, true); + author1.newEdge("IS_AUTHOR_OF", book2, true); + }); + + database.transaction(() -> { + callback.call(database); + }); + } finally { + if (database.isTransactionActive()) + database.rollback(); + database.drop(); + } + } + } +} diff --git a/graphql/src/test/java/com/arcadedb/graphql/parser/GraphQLParserSchemaTest.java b/graphql/src/test/java/com/arcadedb/graphql/parser/GraphQLParserSchemaTest.java new file mode 100755 index 0000000000..cc78733f27 --- /dev/null +++ b/graphql/src/test/java/com/arcadedb/graphql/parser/GraphQLParserSchemaTest.java @@ -0,0 +1,29 @@ +package com.arcadedb.graphql.parser; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class GraphQLParserSchemaTest { + @Test + public void testTypes() throws ParseException { + final Document ast = GraphQLParser.parse("type Query {\n" +// + " bookById(id: ID): Book\n" +// + "}\n" +// + "\n" +// + "type Book {\n" +// + " id: ID\n" +// + " name: String\n" +// + " pageCount: Int\n" + " author: Author\n" +// + "}\n" +// + "\n" +// + "type Author {\n" +// + " id: ID\n" +// + " firstName: String\n" +// + " lastName: String\n" +// + "}"); + + Assertions.assertTrue(ast.children.length > 0); + + ast.dump("-"); + } +} diff --git a/graphql/src/test/java/com/arcadedb/graphql/parser/GraphQLParserTest.java b/graphql/src/test/java/com/arcadedb/graphql/parser/GraphQLParserTest.java new file mode 100755 index 0000000000..deb1fb2964 --- /dev/null +++ b/graphql/src/test/java/com/arcadedb/graphql/parser/GraphQLParserTest.java @@ -0,0 +1,29 @@ +package com.arcadedb.graphql.parser; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class GraphQLParserTest { + @Test + public void testBasic() throws ParseException { + GraphQLParser.parse("{ hero { name friends { name } }}"); + } + + @Test + public void testLookup() throws ParseException { + final Document ast = GraphQLParser.parse("{ bookById(id: \"book-1\"){" +// + " id" +// + " name" +// + " pageCount" +// + " author {" +// + " firstName" +// + " lastName" +// + " }" +// + "}" +// + "}"); + + Assertions.assertTrue(ast.children.length > 0); + + ast.dump("-"); + } +} diff --git a/graphql/src/test/resources/arcadedb-log.properties b/graphql/src/test/resources/arcadedb-log.properties new file mode 100755 index 0000000000..40ed2e04db --- /dev/null +++ b/graphql/src/test/resources/arcadedb-log.properties @@ -0,0 +1,46 @@ +# +# Copyright 2021 Arcade Data Ltd +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Specify the handlers to create in the root logger +# (all loggers are children of the root logger) +# The following creates two handlers +handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler + +# Set the default logging level for the root logger +.level = INFO +com.arcadedb.level = INFO + +# Set the default logging level for new ConsoleHandler instances +java.util.logging.ConsoleHandler.level = INFO +# Set the default formatter for new ConsoleHandler instances +java.util.logging.ConsoleHandler.formatter = com.arcadedb.utility.AnsiLogFormatter + +# Set the default logging level for new FileHandler instances +java.util.logging.FileHandler.level = INFO +# Naming style for the output file +java.util.logging.FileHandler.pattern=log/arcadedb.log +# Set the default formatter for new FileHandler instances +java.util.logging.FileHandler.formatter = com.arcadedb.log.LogFormatter +# Limiting size of output file in bytes: +java.util.logging.FileHandler.limit=100000000 +# Number of output files to cycle through, by appending an +# integer to the base file name: +java.util.logging.FileHandler.count=10 diff --git a/pom.xml b/pom.xml index e831ed7c6d..05c30f7475 100644 --- a/pom.xml +++ b/pom.xml @@ -110,6 +110,7 @@ integration console gremlin + graphql mongodbw redisw postgresw