From: Thomas Walker Lynch Date: Wed, 2 Oct 2024 15:22:01 +0000 (+0000) Subject: resting to original naming scheme X-Git-Url: https://git.reasoningtechnology.com/usr/lib/python2.7/encodings/cp862.py?a=commitdiff_plain;h=01d83323ada14b847e15dc2f559cfb52b37da586;p=GQL-to-Cypher resting to original naming scheme --- diff --git a/build.gradle b/build.gradle index 1358aa3..eaa7628 100644 --- a/build.gradle +++ b/build.gradle @@ -83,6 +83,8 @@ task installAntlr { } } + +// rather circular no? task installJava { dependsOn preface doLast { diff --git a/developer/ANTLR/ANTLRv4Lexer.g4 b/developer/ANTLR/ANTLRv4Lexer.g4 new file mode 100644 index 0000000..bf389d0 --- /dev/null +++ b/developer/ANTLR/ANTLRv4Lexer.g4 @@ -0,0 +1,437 @@ +/* + * [The "BSD license"] + * Copyright (c) 2012-2015 Terence Parr + * Copyright (c) 2012-2015 Sam Harwell + * Copyright (c) 2015 Gerald Rosenberg + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/** + * A grammar for ANTLR v4 implemented using v4 syntax + * + * Modified 2015.06.16 gbr + * -- update for compatibility with Antlr v4.5 + */ + +// $antlr-format alignTrailingComments on, columnLimit 130, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments off +// $antlr-format useTab off, allowShortRulesOnASingleLine off, allowShortBlocksOnASingleLine on, alignSemicolons hanging +// $antlr-format alignColons hanging + +// ====================================================== +// Lexer specification +// ====================================================== + +lexer grammar ANTLRv4Lexer; + +options { + superClass = LexerAdaptor; +} + +import LexBasic; + +// Standard set of fragments +tokens { + TOKEN_REF, + RULE_REF, + LEXER_CHAR_SET +} + +channels { + OFF_CHANNEL, + COMMENT +} + +// ------------------------- +// Comments +DOC_COMMENT + : DocComment -> channel (COMMENT) + ; + +BLOCK_COMMENT + : BlockComment -> channel (COMMENT) + ; + +LINE_COMMENT + : LineComment -> channel (COMMENT) + ; + +// ------------------------- +// Integer + +INT + : DecimalNumeral + ; + +// ------------------------- +// Literal string +// +// ANTLR makes no distinction between a single character literal and a +// multi-character string. All literals are single quote delimited and +// may contain unicode escape sequences of the form \uxxxx, where x +// is a valid hexadecimal number (per Unicode standard). +STRING_LITERAL + : SQuoteLiteral + ; + +UNTERMINATED_STRING_LITERAL + : USQuoteLiteral + ; + +// ------------------------- +// Arguments +// +// Certain argument lists, such as those specifying call parameters +// to a rule invocation, or input parameters to a rule specification +// are contained within square brackets. +BEGIN_ARGUMENT + : LBrack { this.handleBeginArgument(); } + ; + +// ------------------------- +// Target Language Actions +BEGIN_ACTION + : LBrace -> pushMode (TargetLanguageAction) + ; + +// ------------------------- +// Keywords +// +// 'options', 'tokens', and 'channels' are considered keywords +// but only when followed by '{', and considered as a single token. +// Otherwise, the symbols are tokenized as RULE_REF and allowed as +// an identifier in a labeledElement. +OPTIONS + : 'options' WSNLCHARS* '{' + ; + +TOKENS + : 'tokens' WSNLCHARS* '{' + ; + +CHANNELS + : 'channels' WSNLCHARS* '{' + ; + +fragment WSNLCHARS + : ' ' + | '\t' + | '\f' + | '\n' + | '\r' + ; + +IMPORT + : 'import' + ; + +FRAGMENT + : 'fragment' + ; + +LEXER + : 'lexer' + ; + +PARSER + : 'parser' + ; + +GRAMMAR + : 'grammar' + ; + +PROTECTED + : 'protected' + ; + +PUBLIC + : 'public' + ; + +PRIVATE + : 'private' + ; + +RETURNS + : 'returns' + ; + +LOCALS + : 'locals' + ; + +THROWS + : 'throws' + ; + +CATCH + : 'catch' + ; + +FINALLY + : 'finally' + ; + +MODE + : 'mode' + ; + +// ------------------------- +// Punctuation + +COLON + : Colon + ; + +COLONCOLON + : DColon + ; + +COMMA + : Comma + ; + +SEMI + : Semi + ; + +LPAREN + : LParen + ; + +RPAREN + : RParen + ; + +LBRACE + : LBrace + ; + +RBRACE + : RBrace + ; + +RARROW + : RArrow + ; + +LT + : Lt + ; + +GT + : Gt + ; + +ASSIGN + : Equal + ; + +QUESTION + : Question + ; + +STAR + : Star + ; + +PLUS_ASSIGN + : PlusAssign + ; + +PLUS + : Plus + ; + +OR + : Pipe + ; + +DOLLAR + : Dollar + ; + +RANGE + : Range + ; + +DOT + : Dot + ; + +AT + : At + ; + +POUND + : Pound + ; + +NOT + : Tilde + ; + +// ------------------------- +// Identifiers - allows unicode rule/token names + +ID + : Id + ; + +// ------------------------- +// Whitespace + +WS + : Ws+ -> channel (OFF_CHANNEL) + ; + +// ------------------------- +// Illegal Characters +// +// This is an illegal character trap which is always the last rule in the +// lexer specification. It matches a single character of any value and being +// the last rule in the file will match when no other rule knows what to do +// about the character. It is reported as an error but is not passed on to the +// parser. This means that the parser to deal with the gramamr file anyway +// but we will not try to analyse or code generate from a file with lexical +// errors. + +// Comment this rule out to allow the error to be propagated to the parser +ERRCHAR + : . -> channel (HIDDEN) + ; + +// ====================================================== +// Lexer modes +// ------------------------- +// Arguments +mode Argument; + +// E.g., [int x, List a[]] +NESTED_ARGUMENT + : LBrack -> type (ARGUMENT_CONTENT), pushMode (Argument) + ; + +ARGUMENT_ESCAPE + : EscAny -> type (ARGUMENT_CONTENT) + ; + +ARGUMENT_STRING_LITERAL + : DQuoteLiteral -> type (ARGUMENT_CONTENT) + ; + +ARGUMENT_CHAR_LITERAL + : SQuoteLiteral -> type (ARGUMENT_CONTENT) + ; + +END_ARGUMENT + : RBrack { this.handleEndArgument(); } + ; + +// added this to return non-EOF token type here. EOF does something weird +UNTERMINATED_ARGUMENT + : EOF -> popMode + ; + +ARGUMENT_CONTENT + : . + ; + +// TODO: This grammar and the one used in the Intellij Antlr4 plugin differ +// for "actions". This needs to be resolved at some point. +// The Intellij Antlr4 grammar is here: +// https://github.com/antlr/intellij-plugin-v4/blob/1f36fde17f7fa63cb18d7eeb9cb213815ac658fb/src/main/antlr/org/antlr/intellij/plugin/parser/ANTLRv4Lexer.g4#L587 + +// ------------------------- +// Target Language Actions +// +// Many language targets use {} as block delimiters and so we +// must recursively match {} delimited blocks to balance the +// braces. Additionally, we must make some assumptions about +// literal string representation in the target language. We assume +// that they are delimited by ' or " and so consume these +// in their own alts so as not to inadvertantly match {}. +mode TargetLanguageAction; + +NESTED_ACTION + : LBrace -> type (ACTION_CONTENT), pushMode (TargetLanguageAction) + ; + +ACTION_ESCAPE + : EscAny -> type (ACTION_CONTENT) + ; + +ACTION_STRING_LITERAL + : DQuoteLiteral -> type (ACTION_CONTENT) + ; + +ACTION_CHAR_LITERAL + : SQuoteLiteral -> type (ACTION_CONTENT) + ; + +ACTION_DOC_COMMENT + : DocComment -> type (ACTION_CONTENT) + ; + +ACTION_BLOCK_COMMENT + : BlockComment -> type (ACTION_CONTENT) + ; + +ACTION_LINE_COMMENT + : LineComment -> type (ACTION_CONTENT) + ; + +END_ACTION + : RBrace { this.handleEndAction(); } + ; + +UNTERMINATED_ACTION + : EOF -> popMode + ; + +ACTION_CONTENT + : . + ; + +// ------------------------- +mode LexerCharSet; + +LEXER_CHAR_SET_BODY + : (~ [\]\\] | EscAny)+ -> more + ; + +LEXER_CHAR_SET + : RBrack -> popMode + ; + +UNTERMINATED_CHAR_SET + : EOF -> popMode + ; + +// ------------------------------------------------------------------------------ +// Grammar specific Keywords, Punctuation, etc. +fragment Id + : NameStartChar NameChar* + ; \ No newline at end of file diff --git a/developer/ANTLR/ANTLRv4Parser.g4 b/developer/ANTLR/ANTLRv4Parser.g4 new file mode 100644 index 0000000..a4ff765 --- /dev/null +++ b/developer/ANTLR/ANTLRv4Parser.g4 @@ -0,0 +1,408 @@ +/* + * [The "BSD license"] + * Copyright (c) 2012-2014 Terence Parr + * Copyright (c) 2012-2014 Sam Harwell + * Copyright (c) 2015 Gerald Rosenberg + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* A grammar for ANTLR v4 written in ANTLR v4. + * + * Modified 2015.06.16 gbr + * -- update for compatibility with Antlr v4.5 + * -- add mode for channels + * -- moved members to LexerAdaptor + * -- move fragments to imports + */ + +// $antlr-format alignTrailingComments on, columnLimit 130, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments off +// $antlr-format useTab off, allowShortRulesOnASingleLine off, allowShortBlocksOnASingleLine on, alignSemicolons hanging +// $antlr-format alignColons hanging + +parser grammar ANTLRv4Parser; + +options { + tokenVocab = ANTLRv4Lexer; +} + +// The main entry point for parsing a v4 grammar. +grammarSpec + : grammarDecl prequelConstruct* rules modeSpec* EOF + ; + +grammarDecl + : grammarType identifier SEMI + ; + +grammarType + : LEXER GRAMMAR + | PARSER GRAMMAR + | GRAMMAR + ; + +// This is the list of all constructs that can be declared before +// the set of rules that compose the grammar, and is invoked 0..n +// times by the grammarPrequel rule. + +prequelConstruct + : optionsSpec + | delegateGrammars + | tokensSpec + | channelsSpec + | action_ + ; + +// ------------ +// Options - things that affect analysis and/or code generation + +optionsSpec + : OPTIONS (option SEMI)* RBRACE + ; + +option + : identifier ASSIGN optionValue + ; + +optionValue + : identifier (DOT identifier)* + | STRING_LITERAL + | actionBlock + | INT + ; + +// ------------ +// Delegates + +delegateGrammars + : IMPORT delegateGrammar (COMMA delegateGrammar)* SEMI + ; + +delegateGrammar + : identifier ASSIGN identifier + | identifier + ; + +// ------------ +// Tokens & Channels + +tokensSpec + : TOKENS idList? RBRACE + ; + +channelsSpec + : CHANNELS idList? RBRACE + ; + +idList + : identifier (COMMA identifier)* COMMA? + ; + +// Match stuff like @parser::members {int i;} + +action_ + : AT (actionScopeName COLONCOLON)? identifier actionBlock + ; + +// Scope names could collide with keywords; allow them as ids for action scopes + +actionScopeName + : identifier + | LEXER + | PARSER + ; + +actionBlock + : BEGIN_ACTION ACTION_CONTENT* END_ACTION + ; + +argActionBlock + : BEGIN_ARGUMENT ARGUMENT_CONTENT* END_ARGUMENT + ; + +modeSpec + : MODE identifier SEMI lexerRuleSpec* + ; + +rules + : ruleSpec* + ; + +ruleSpec + : parserRuleSpec + | lexerRuleSpec + ; + +parserRuleSpec + : ruleModifiers? RULE_REF argActionBlock? ruleReturns? throwsSpec? localsSpec? rulePrequel* COLON ruleBlock SEMI + exceptionGroup + ; + +exceptionGroup + : exceptionHandler* finallyClause? + ; + +exceptionHandler + : CATCH argActionBlock actionBlock + ; + +finallyClause + : FINALLY actionBlock + ; + +rulePrequel + : optionsSpec + | ruleAction + ; + +ruleReturns + : RETURNS argActionBlock + ; + +// -------------- +// Exception spec +throwsSpec + : THROWS identifier (COMMA identifier)* + ; + +localsSpec + : LOCALS argActionBlock + ; + +/** Match stuff like @init {int i;} */ +ruleAction + : AT identifier actionBlock + ; + +ruleModifiers + : ruleModifier+ + ; + +// An individual access modifier for a rule. The 'fragment' modifier +// is an internal indication for lexer rules that they do not match +// from the input but are like subroutines for other lexer rules to +// reuse for certain lexical patterns. The other modifiers are passed +// to the code generation templates and may be ignored by the template +// if they are of no use in that language. + +ruleModifier + : PUBLIC + | PRIVATE + | PROTECTED + | FRAGMENT + ; + +ruleBlock + : ruleAltList + ; + +ruleAltList + : labeledAlt (OR labeledAlt)* + ; + +labeledAlt + : alternative (POUND identifier)? + ; + +// -------------------- +// Lexer rules + +lexerRuleSpec + : FRAGMENT? TOKEN_REF optionsSpec? COLON lexerRuleBlock SEMI + ; + +lexerRuleBlock + : lexerAltList + ; + +lexerAltList + : lexerAlt (OR lexerAlt)* + ; + +lexerAlt + : lexerElements lexerCommands? + | + // explicitly allow empty alts + ; + +lexerElements + : lexerElement+ + | + ; + +lexerElement + : lexerAtom ebnfSuffix? + | lexerBlock ebnfSuffix? + | actionBlock QUESTION? + ; + +// but preds can be anywhere + +lexerBlock + : LPAREN lexerAltList RPAREN + ; + +// E.g., channel(HIDDEN), skip, more, mode(INSIDE), push(INSIDE), pop + +lexerCommands + : RARROW lexerCommand (COMMA lexerCommand)* + ; + +lexerCommand + : lexerCommandName LPAREN lexerCommandExpr RPAREN + | lexerCommandName + ; + +lexerCommandName + : identifier + | MODE + ; + +lexerCommandExpr + : identifier + | INT + ; + +// -------------------- +// Rule Alts + +altList + : alternative (OR alternative)* + ; + +alternative + : elementOptions? element+ + | + // explicitly allow empty alts + ; + +element + : labeledElement (ebnfSuffix |) + | atom (ebnfSuffix |) + | ebnf + | actionBlock (QUESTION predicateOptions?)? + ; + +predicateOptions + : LT predicateOption (COMMA predicateOption)* GT + ; + +predicateOption + : elementOption + | identifier ASSIGN actionBlock + ; + +labeledElement + : identifier (ASSIGN | PLUS_ASSIGN) (atom | block) + ; + +// -------------------- +// EBNF and blocks + +ebnf + : block blockSuffix? + ; + +blockSuffix + : ebnfSuffix + ; + +ebnfSuffix + : QUESTION QUESTION? + | STAR QUESTION? + | PLUS QUESTION? + ; + +lexerAtom + : characterRange + | terminalDef + | notSet + | LEXER_CHAR_SET + | DOT elementOptions? + ; + +atom + : terminalDef + | ruleref + | notSet + | DOT elementOptions? + ; + +// -------------------- +// Inverted element set +notSet + : NOT setElement + | NOT blockSet + ; + +blockSet + : LPAREN setElement (OR setElement)* RPAREN + ; + +setElement + : TOKEN_REF elementOptions? + | STRING_LITERAL elementOptions? + | characterRange + | LEXER_CHAR_SET + ; + +// ------------- +// Grammar Block +block + : LPAREN (optionsSpec? ruleAction* COLON)? altList RPAREN + ; + +// ---------------- +// Parser rule ref +ruleref + : RULE_REF argActionBlock? elementOptions? + ; + +// --------------- +// Character Range +characterRange + : STRING_LITERAL RANGE STRING_LITERAL + ; + +terminalDef + : TOKEN_REF elementOptions? + | STRING_LITERAL elementOptions? + ; + +// Terminals may be adorned with certain options when +// reference in the grammar: TOK<,,,> +elementOptions + : LT elementOption (COMMA elementOption)* GT + ; + +elementOption + : identifier + | identifier ASSIGN (identifier | STRING_LITERAL) + ; + +identifier + : RULE_REF + | TOKEN_REF + ; \ No newline at end of file diff --git a/developer/ANTLR/Arithmetic.g4 b/developer/ANTLR/Arithmetic.g4 new file mode 100644 index 0000000..4a61ec4 --- /dev/null +++ b/developer/ANTLR/Arithmetic.g4 @@ -0,0 +1,14 @@ +grammar Arithmetic; + +program: expression EOF; + +expression + : expression ('*'|'/') expression + | expression ('+'|'-') expression + | '(' expression ')' + | INT + ; + +INT: [0-9]+; + +WS: [ \t\r\n]+ -> skip; diff --git a/developer/ANTLR/Arithmetic2.g4 b/developer/ANTLR/Arithmetic2.g4 new file mode 100644 index 0000000..88fea64 --- /dev/null +++ b/developer/ANTLR/Arithmetic2.g4 @@ -0,0 +1,24 @@ +grammar Arithmetic2; + +program: statement+ EOF; + +statement + : expression + | variable '=' expression + ; + +expression + : expression ('*'|'/') expression + | expression ('+'|'-') expression + | '(' expression ')' + | variable + | INT + ; + +variable: VARIABLE; + +INT: [0-9]+; + +VARIABLE: [a-zA-Z]+; + +WS: [ \t\r\n]+ -> skip; diff --git a/developer/ANTLR/GQL_20240412.g4 b/developer/ANTLR/GQL_20240412.g4 new file mode 100644 index 0000000..ea8517c --- /dev/null +++ b/developer/ANTLR/GQL_20240412.g4 @@ -0,0 +1,3778 @@ +grammar GQL_20240412; + +options { caseInsensitive = true; } + +// 6 + +gqlProgram + : programActivity sessionCloseCommand? EOF + | sessionCloseCommand EOF + ; + +programActivity + : sessionActivity + | transactionActivity + ; + +sessionActivity + : sessionResetCommand+ + | sessionSetCommand+ sessionResetCommand* + ; + +transactionActivity + : startTransactionCommand (procedureSpecification endTransactionCommand?)? + | procedureSpecification endTransactionCommand? + | endTransactionCommand + ; + +endTransactionCommand + : rollbackCommand + | commitCommand + ; + +// 7.1 + +sessionSetCommand + : SESSION SET (sessionSetSchemaClause | sessionSetGraphClause | sessionSetTimeZoneClause | sessionSetParameterClause) + ; + +sessionSetSchemaClause + : SCHEMA schemaReference + ; + +sessionSetGraphClause + : PROPERTY? GRAPH graphExpression + ; + +sessionSetTimeZoneClause + : TIME ZONE setTimeZoneValue + ; + +setTimeZoneValue + : timeZoneString + ; + +sessionSetParameterClause + : sessionSetGraphParameterClause + | sessionSetBindingTableParameterClause + | sessionSetValueParameterClause + ; + +sessionSetGraphParameterClause + : PROPERTY? GRAPH sessionSetParameterName optTypedGraphInitializer + ; + +sessionSetBindingTableParameterClause + : BINDING? TABLE sessionSetParameterName optTypedBindingTableInitializer + ; + +sessionSetValueParameterClause + : VALUE sessionSetParameterName optTypedValueInitializer + ; + +sessionSetParameterName + : (IF NOT EXISTS)? sessionParameterSpecification + ; + +// 7.2 + +sessionResetCommand + : SESSION RESET sessionResetArguments? + ; + +sessionResetArguments + : ALL? (PARAMETERS | CHARACTERISTICS) + | SCHEMA + | PROPERTY? GRAPH + | TIME ZONE + | PARAMETER? sessionParameterSpecification + ; + +// 7.3 + +sessionCloseCommand + : SESSION CLOSE + ; + +// 7.4 + +sessionParameterSpecification + : GENERAL_PARAMETER_REFERENCE + ; + +// 8.1 + +startTransactionCommand + : START TRANSACTION transactionCharacteristics? + ; + +// 8.2 + +transactionCharacteristics + : transactionMode (COMMA transactionMode)* + ; + +transactionMode + : transactionAccessMode + ; + +transactionAccessMode + : READ ONLY + | READ WRITE + ; + +// 8.3 + +rollbackCommand + : ROLLBACK + ; + +// 8.4 + +commitCommand + : COMMIT + ; + +// 9.1 + +nestedProcedureSpecification + : LEFT_BRACE procedureSpecification RIGHT_BRACE + ; + +// , and are +// identical productions. The specification distinguishes them in the BNF, but in the implementation, the distinction +// has to be made sematically, in code, based on the kind of statements contained in the . +procedureSpecification + : procedureBody +// : catalogModifyingProcedureSpecification +// | dataModifyingProcedureSpecification +// | querySpecification + ; + +//catalogModifyingProcedureSpecification +// : procedureBody +// ; + +nestedDataModifyingProcedureSpecification + : LEFT_BRACE procedureBody RIGHT_BRACE + ; + +//dataModifyingProcedureSpecification +// : procedureBody +// ; + +nestedQuerySpecification + : LEFT_BRACE procedureBody RIGHT_BRACE + ; + +//querySpecification +// : procedureBody +// ; + +// 9.2 + +procedureBody + : atSchemaClause? bindingVariableDefinitionBlock? statementBlock + ; + +bindingVariableDefinitionBlock + : bindingVariableDefinition+ + ; + +bindingVariableDefinition + : graphVariableDefinition + | bindingTableVariableDefinition + | valueVariableDefinition + ; + +statementBlock + : statement nextStatement* + ; + +statement + : linearCatalogModifyingStatement + | linearDataModifyingStatement + | compositeQueryStatement + ; + +nextStatement + : NEXT yieldClause? statement + ; + +// 10.1 + +graphVariableDefinition + : PROPERTY? GRAPH bindingVariable optTypedGraphInitializer + ; + +optTypedGraphInitializer + : (typed? graphReferenceValueType)? graphInitializer + ; + +graphInitializer + : EQUALS_OPERATOR graphExpression + ; + +// 10.2 + +bindingTableVariableDefinition + : BINDING? TABLE bindingVariable optTypedBindingTableInitializer + ; + +optTypedBindingTableInitializer + : (typed? bindingTableReferenceValueType)? bindingTableInitializer + ; + +bindingTableInitializer + : EQUALS_OPERATOR bindingTableExpression + ; + +// 10.3 + +valueVariableDefinition + : VALUE bindingVariable optTypedValueInitializer + ; + +optTypedValueInitializer + : (typed? valueType)? valueInitializer + ; + +valueInitializer + : EQUALS_OPERATOR valueExpression + ; + +// 11.1 + +graphExpression + : objectExpressionPrimary + | graphReference + | objectNameOrBindingVariable + | currentGraph + ; + +currentGraph + : CURRENT_PROPERTY_GRAPH + | CURRENT_GRAPH + ; + +// 11.2 + +bindingTableExpression + : nestedBindingTableQuerySpecification + | objectExpressionPrimary + | bindingTableReference + | objectNameOrBindingVariable + ; + +nestedBindingTableQuerySpecification + : nestedQuerySpecification + ; + +// 11.3 + +objectExpressionPrimary + : VARIABLE valueExpressionPrimary + | parenthesizedValueExpression + | nonParenthesizedValueExpressionPrimarySpecialCase + ; + +// 12.1 + +linearCatalogModifyingStatement + : simpleCatalogModifyingStatement+ + ; + +simpleCatalogModifyingStatement + : primitiveCatalogModifyingStatement + | callCatalogModifyingProcedureStatement + ; + +primitiveCatalogModifyingStatement + : createSchemaStatement + | dropSchemaStatement + | createGraphStatement + | dropGraphStatement + | createGraphTypeStatement + | dropGraphTypeStatement + ; + +// 12.2 + +createSchemaStatement + : CREATE SCHEMA (IF NOT EXISTS)? catalogSchemaParentAndName + ; + +// 12.3 + +dropSchemaStatement + : DROP SCHEMA (IF EXISTS)? catalogSchemaParentAndName + ; + +// 12.4 + +createGraphStatement + : CREATE (PROPERTY? GRAPH (IF NOT EXISTS)? | OR REPLACE PROPERTY? GRAPH) catalogGraphParentAndName (openGraphType | ofGraphType) graphSource? + ; + +openGraphType + : typed? ANY (PROPERTY? GRAPH)? + ; + +ofGraphType + : graphTypeLikeGraph + | typed? graphTypeReference + | typed? (PROPERTY? GRAPH)? nestedGraphTypeSpecification + ; + +graphTypeLikeGraph + : LIKE graphExpression + ; + +graphSource + : AS COPY OF graphExpression + ; + +// 12.5 + +dropGraphStatement + : DROP PROPERTY? GRAPH (IF EXISTS)? catalogGraphParentAndName + ; + +// 12.6 + +createGraphTypeStatement + : CREATE (PROPERTY? GRAPH TYPE (IF NOT EXISTS)? | OR REPLACE PROPERTY? GRAPH TYPE) catalogGraphTypeParentAndName graphTypeSource + ; + +graphTypeSource + : AS? copyOfGraphType + | graphTypeLikeGraph + | AS? nestedGraphTypeSpecification + ; + +copyOfGraphType + : COPY OF graphTypeReference + ; + +// 12.7 + +dropGraphTypeStatement + : DROP PROPERTY? GRAPH TYPE (IF EXISTS)? catalogGraphTypeParentAndName + ; + +// 12.8 + +callCatalogModifyingProcedureStatement + : callProcedureStatement + ; + +// 13.1 + +linearDataModifyingStatement + : focusedLinearDataModifyingStatement + | ambientLinearDataModifyingStatement + ; + +focusedLinearDataModifyingStatement + : focusedLinearDataModifyingStatementBody + | focusedNestedDataModifyingProcedureSpecification + ; + +focusedLinearDataModifyingStatementBody + : useGraphClause simpleLinearDataAccessingStatement primitiveResultStatement? + ; + +focusedNestedDataModifyingProcedureSpecification + : useGraphClause nestedDataModifyingProcedureSpecification + ; + +ambientLinearDataModifyingStatement + : ambientLinearDataModifyingStatementBody + | nestedDataModifyingProcedureSpecification + ; + +ambientLinearDataModifyingStatementBody + : simpleLinearDataAccessingStatement primitiveResultStatement? + ; + +simpleLinearDataAccessingStatement + : simpleQueryStatement* simpleDataModifyingStatement+ + ; + +// Subsumed by previous rule to enforce 13.1 SR 5 +//simpleDataAccessingStatement +// : simpleQueryStatement +// | simpleDataModifyingStatement +// ; + +simpleDataModifyingStatement + : primitiveDataModifyingStatement + | callDataModifyingProcedureStatement + ; + +primitiveDataModifyingStatement + : insertStatement + | setStatement + | removeStatement + | deleteStatement + ; + +// 13.2 + +insertStatement + : INSERT insertGraphPattern + ; + +// 13.3 + +setStatement + : SET setItemList + ; + +setItemList + : setItem (COMMA setItem)* + ; + +setItem + : setPropertyItem + | setAllPropertiesItem + | setLabelItem + ; + +setPropertyItem + : bindingVariableReference PERIOD propertyName EQUALS_OPERATOR valueExpression + ; + +setAllPropertiesItem + : bindingVariableReference EQUALS_OPERATOR LEFT_BRACE propertyKeyValuePairList? RIGHT_BRACE + ; + +setLabelItem + : bindingVariableReference isOrColon labelName + ; + +// 13.4 + +removeStatement + : REMOVE removeItemList + ; + +removeItemList + : removeItem (COMMA removeItem)* + ; + +removeItem + : removePropertyItem + | removeLabelItem + ; + +removePropertyItem + : bindingVariableReference PERIOD propertyName + ; + +removeLabelItem + : bindingVariableReference isOrColon labelName + ; + +// 13.5 + +deleteStatement + : (DETACH | NODETACH)? DELETE deleteItemList + ; + +deleteItemList + : deleteItem (COMMA deleteItem)* + ; + +deleteItem + : valueExpression + ; + +// 13.6 + +callDataModifyingProcedureStatement + : callProcedureStatement + ; + +// 14.1 + +compositeQueryStatement + : compositeQueryExpression + ; + +// 14.2 + +compositeQueryExpression + : compositeQueryExpression queryConjunction compositeQueryPrimary + | compositeQueryPrimary + ; + +queryConjunction + : setOperator + | OTHERWISE + ; + +setOperator + : UNION setQuantifier? + | EXCEPT setQuantifier? + | INTERSECT setQuantifier? + ; + +compositeQueryPrimary + : linearQueryStatement + ; + +// 14.3 and + +linearQueryStatement + : focusedLinearQueryStatement + | ambientLinearQueryStatement + ; + +focusedLinearQueryStatement + : focusedLinearQueryStatementPart* focusedLinearQueryAndPrimitiveResultStatementPart + | focusedPrimitiveResultStatement + | focusedNestedQuerySpecification + | selectStatement + ; + +focusedLinearQueryStatementPart + : useGraphClause simpleLinearQueryStatement + ; + +focusedLinearQueryAndPrimitiveResultStatementPart + : useGraphClause simpleLinearQueryStatement primitiveResultStatement + ; + +focusedPrimitiveResultStatement + : useGraphClause primitiveResultStatement + ; + +focusedNestedQuerySpecification + : useGraphClause nestedQuerySpecification + ; + +ambientLinearQueryStatement + : simpleLinearQueryStatement? primitiveResultStatement + | nestedQuerySpecification + ; + +simpleLinearQueryStatement + : simpleQueryStatement+ + ; + +simpleQueryStatement + : primitiveQueryStatement + | callQueryStatement + ; + +primitiveQueryStatement + : matchStatement + | letStatement + | forStatement + | filterStatement + | orderByAndPageStatement + ; + +// 14.4 + +matchStatement + : simpleMatchStatement + | optionalMatchStatement + ; + +simpleMatchStatement + : MATCH graphPatternBindingTable + ; + +optionalMatchStatement + : OPTIONAL optionalOperand + ; + +optionalOperand + : simpleMatchStatement + | LEFT_BRACE matchStatementBlock RIGHT_BRACE + | LEFT_PAREN matchStatementBlock RIGHT_PAREN + ; + +matchStatementBlock + : matchStatement+ + ; + +// 14.5 + +callQueryStatement + : callProcedureStatement + ; + +// 14.6 + +filterStatement + : FILTER (whereClause | searchCondition) + ; + +// 14.7 + +letStatement + : LET letVariableDefinitionList + ; + +letVariableDefinitionList + : letVariableDefinition (COMMA letVariableDefinition)* + ; + +letVariableDefinition + : valueVariableDefinition + | bindingVariable EQUALS_OPERATOR valueExpression + ; + +// 14.8 + +forStatement + : FOR forItem forOrdinalityOrOffset? + ; + +forItem + : forItemAlias forItemSource + ; + +forItemAlias + : bindingVariable IN + ; + +forItemSource + : valueExpression + ; + +forOrdinalityOrOffset + : WITH (ORDINALITY | OFFSET) bindingVariable + ; + +// 14.9 + +orderByAndPageStatement + : orderByClause offsetClause? limitClause? + | offsetClause limitClause? + | limitClause + ; + +// 14.10 + +primitiveResultStatement + : returnStatement orderByAndPageStatement? + | FINISH + ; + +// 14.11 + +returnStatement + : RETURN returnStatementBody + ; + +returnStatementBody + : setQuantifier? (ASTERISK | returnItemList) groupByClause? + | NO BINDINGS + ; + +returnItemList + : returnItem (COMMA returnItem)* + ; + +returnItem + : aggregatingValueExpression returnItemAlias? + ; + +returnItemAlias + : AS identifier + ; + +// 14.12 + +// Original: selectStatement +CONTROL_FLOWselectStatementCONTROL_FLOW +// Original: : SELECT setQuantifier? (ASTERISK | selectItemList) (selectStatementBody whereClause? groupByClause? havingClause? orderByClause? offsetClause? limitClause?)? +// Original: : SELECT setQuantifier? (PUNCTUATION_OPERATOR | selectItemList) (selectStatementBody whereClause? groupByClause? havingClause? orderByClause? offsetClause? limitClause?)? +: KEYWORD setQuantifier? (PUNCTUATION_OPERATOR | selectItemList) (selectStatementBody whereClause? groupByClause? havingClause? orderByClause? offsetClause? limitClause?)? +; + +// Original: selectItemList +CONTROL_FLOWselectItemListCONTROL_FLOW +// Original: : selectItem (COMMA selectItem)* +: selectItem (PUNCTUATION_OPERATOR selectItem)* +; + +// Original: selectItem +CONTROL_FLOWselectItemCONTROL_FLOW +: aggregatingValueExpression selectItemAlias? +; + +// Original: selectItemAlias +CONTROL_FLOWselectItemAliasCONTROL_FLOW +// Original: : AS identifier +// Original: : KEYWORD identifier +: CONTROL_FLOWKEYWORDCONTROL_FLOW CONTROL_FLOWidentifierCONTROL_FLOW +; + +// Original: havingClause +CONTROL_FLOWhavingClauseCONTROL_FLOW +// Original: : HAVING searchCondition +: CONTROL_FLOWHAVINGCONTROL_FLOW CONTROL_FLOWsearchConditionCONTROL_FLOW +; + +// Original: selectStatementBody +CONTROL_FLOWselectStatementBodyCONTROL_FLOW +// Original: : FROM (selectGraphMatchList | selectQuerySpecification) +: KEYWORD (selectGraphMatchList | selectQuerySpecification) +; + +// Original: selectGraphMatchList +CONTROL_FLOWselectGraphMatchListCONTROL_FLOW +// Original: : selectGraphMatch (COMMA selectGraphMatch)* +: selectGraphMatch (PUNCTUATION_OPERATOR selectGraphMatch)* +; + +// Original: selectGraphMatch +CONTROL_FLOWselectGraphMatchCONTROL_FLOW +// Original: : graphExpression matchStatement +: CONTROL_FLOWgraphExpressionCONTROL_FLOW CONTROL_FLOWmatchStatementCONTROL_FLOW +; + +// Original: selectQuerySpecification +CONTROL_FLOWselectQuerySpecificationCONTROL_FLOW +// Original: : nestedQuerySpecification +: CONTROL_FLOWnestedQuerySpecificationCONTROL_FLOW +// Original: | graphExpression nestedQuerySpecification +| CONTROL_FLOWgraphExpressionCONTROL_FLOW CONTROL_FLOWnestedQuerySpecificationCONTROL_FLOW +; + +// 15.1 and + +// Original: callProcedureStatement +CONTROL_FLOWcallProcedureStatementCONTROL_FLOW +// Original: : OPTIONAL? CALL procedureCall +// Original: : OPTIONAL? KEYWORD procedureCall +: CONTROL_FLOWOPTIONALCONTROL_FLOW? CONTROL_FLOWKEYWORDCONTROL_FLOW CONTROL_FLOWprocedureCallCONTROL_FLOW +; + +// Original: procedureCall +CONTROL_FLOWprocedureCallCONTROL_FLOW +// Original: : inlineProcedureCall +: CONTROL_FLOWinlineProcedureCallCONTROL_FLOW +// Original: | namedProcedureCall +| CONTROL_FLOWnamedProcedureCallCONTROL_FLOW +; + +// 15.2 + +// Original: inlineProcedureCall +CONTROL_FLOWinlineProcedureCallCONTROL_FLOW +// Original: : variableScopeClause? nestedProcedureSpecification +: CONTROL_FLOWvariableScopeClauseCONTROL_FLOW? CONTROL_FLOWnestedProcedureSpecificationCONTROL_FLOW +; + +// Original: variableScopeClause +CONTROL_FLOWvariableScopeClauseCONTROL_FLOW +// Original: : LEFT_PAREN bindingVariableReferenceList? RIGHT_PAREN +// Original: : LEFT_PAREN bindingVariableReferenceList? PUNCTUATION_OPERATOR +: CONTROL_FLOWLEFT_PARENCONTROL_FLOW CONTROL_FLOWbindingVariableReferenceListCONTROL_FLOW? CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW +; + +// Original: bindingVariableReferenceList +CONTROL_FLOWbindingVariableReferenceListCONTROL_FLOW +// Original: : bindingVariableReference (COMMA bindingVariableReference)* +: bindingVariableReference (PUNCTUATION_OPERATOR bindingVariableReference)* +; + +// 15.3 + +// Original: namedProcedureCall +CONTROL_FLOWnamedProcedureCallCONTROL_FLOW +// Original: : procedureReference LEFT_PAREN procedureArgumentList? RIGHT_PAREN yieldClause? +// Original: : procedureReference LEFT_PAREN procedureArgumentList? PUNCTUATION_OPERATOR yieldClause? +: procedureReference PUNCTUATION_OPERATOR procedureArgumentList? PUNCTUATION_OPERATOR yieldClause? +; + +// Original: procedureArgumentList +CONTROL_FLOWprocedureArgumentListCONTROL_FLOW +// Original: : procedureArgument (COMMA procedureArgument)* +: procedureArgument (PUNCTUATION_OPERATOR procedureArgument)* +; + +// Original: procedureArgument +CONTROL_FLOWprocedureArgumentCONTROL_FLOW +// Original: : valueExpression +: CONTROL_FLOWvalueExpressionCONTROL_FLOW +; + +// 16.1 + +// Original: atSchemaClause +CONTROL_FLOWatSchemaClauseCONTROL_FLOW +// Original: : AT schemaReference +// Original: : KEYWORD schemaReference +: CONTROL_FLOWKEYWORDCONTROL_FLOW CONTROL_FLOWschemaReferenceCONTROL_FLOW +; + +// 16.2 + +// Original: useGraphClause +CONTROL_FLOWuseGraphClauseCONTROL_FLOW +// Original: : USE graphExpression +: CONTROL_FLOWUSECONTROL_FLOW CONTROL_FLOWgraphExpressionCONTROL_FLOW +; + +// 16.3 + +// Original: graphPatternBindingTable +CONTROL_FLOWgraphPatternBindingTableCONTROL_FLOW +: graphPattern graphPatternYieldClause? +; + +// Original: graphPatternYieldClause +CONTROL_FLOWgraphPatternYieldClauseCONTROL_FLOW +// Original: : YIELD graphPatternYieldItemList +// Original: : KEYWORD graphPatternYieldItemList +: CONTROL_FLOWKEYWORDCONTROL_FLOW CONTROL_FLOWgraphPatternYieldItemListCONTROL_FLOW +; + +// Original: graphPatternYieldItemList +CONTROL_FLOWgraphPatternYieldItemListCONTROL_FLOW +// Original: : graphPatternYieldItem (COMMA graphPatternYieldItem)* +: graphPatternYieldItem (PUNCTUATION_OPERATOR graphPatternYieldItem)* +// Original: | NO BINDINGS +// Original: | NO KEYWORD +| CONTROL_FLOWNOCONTROL_FLOW CONTROL_FLOWKEYWORDCONTROL_FLOW +; + +// Original: // and are identical productions, both consisting +// CONTROL_FLOWandCONTROL_FLOW CONTROL_FLOWareCONTROL_FLOW CONTROL_FLOWidenticalCONTROL_FLOW CONTROL_FLOWproductionsCONTROL_FLOW, CONTROL_FLOWbothCONTROL_FLOW CONTROL_FLOWconsistingCONTROL_FLOW +// Original: // of a single non-terminal . Thus is ambiguous +// CONTROL_FLOWofCONTROL_FLOW CONTROL_FLOWaCONTROL_FLOW CONTROL_FLOWsingleCONTROL_FLOW CONTROL_FLOWnonCONTROL_FLOW-CONTROL_FLOWterminalCONTROL_FLOW . CONTROL_FLOWThusCONTROL_FLOW CONTROL_FLOWisCONTROL_FLOW CONTROL_FLOWambiguousCONTROL_FLOW +// Original: // from a parsing standpoint. So here we simply use bindingVariableReference. Post parsing code must +// CONTROL_FLOWfromCONTROL_FLOW CONTROL_FLOWaCONTROL_FLOW CONTROL_FLOWparsingCONTROL_FLOW CONTROL_FLOWstandpointCONTROL_FLOW. CONTROL_FLOWSoCONTROL_FLOW CONTROL_FLOWhereCONTROL_FLOW CONTROL_FLOWweCONTROL_FLOW CONTROL_FLOWsimplyCONTROL_FLOW CONTROL_FLOWuseCONTROL_FLOW CONTROL_FLOWbindingVariableReferenceCONTROL_FLOW. CONTROL_FLOWPostCONTROL_FLOW CONTROL_FLOWparsingCONTROL_FLOW CONTROL_FLOWcodeCONTROL_FLOW CONTROL_FLOWmustCONTROL_FLOW +// apply the semantics assocaited with each type of . +// Original: graphPatternYieldItem +CONTROL_FLOWgraphPatternYieldItemCONTROL_FLOW +// Original: : bindingVariableReference +: CONTROL_FLOWbindingVariableReferenceCONTROL_FLOW +// Original: // : elementVariableReference +// : CONTROL_FLOWelementVariableReferenceCONTROL_FLOW +// Original: // | pathVariableReference +// | CONTROL_FLOWpathVariableReferenceCONTROL_FLOW +; + +// 16.4 + +// Original: graphPattern +CONTROL_FLOWgraphPatternCONTROL_FLOW +: matchMode? pathPatternList keepClause? graphPatternWhereClause? +; + +// Original: matchMode +CONTROL_FLOWmatchModeCONTROL_FLOW +// Original: : repeatableElementsMatchMode +: CONTROL_FLOWrepeatableElementsMatchModeCONTROL_FLOW +// Original: | differentEdgesMatchMode +| CONTROL_FLOWdifferentEdgesMatchModeCONTROL_FLOW +; + +// Original: repeatableElementsMatchMode +CONTROL_FLOWrepeatableElementsMatchModeCONTROL_FLOW +// Original: : REPEATABLE elementBindingsOrElements +: CONTROL_FLOWREPEATABLECONTROL_FLOW CONTROL_FLOWelementBindingsOrElementsCONTROL_FLOW +; + +// Original: differentEdgesMatchMode +CONTROL_FLOWdifferentEdgesMatchModeCONTROL_FLOW +// Original: : DIFFERENT edgeBindingsOrEdges +: CONTROL_FLOWDIFFERENTCONTROL_FLOW CONTROL_FLOWedgeBindingsOrEdgesCONTROL_FLOW +; + +// Original: elementBindingsOrElements +CONTROL_FLOWelementBindingsOrElementsCONTROL_FLOW +// Original: : ELEMENT BINDINGS? +// Original: : ELEMENT KEYWORD? +: DATA_TYPE KEYWORD? +// Original: | ELEMENTS +| CONTROL_FLOWELEMENTSCONTROL_FLOW +; + +// Original: edgeBindingsOrEdges +CONTROL_FLOWedgeBindingsOrEdgesCONTROL_FLOW +// Original: : edgeSynonym BINDINGS? +: edgeSynonym KEYWORD? +// Original: | edgesSynonym +| CONTROL_FLOWedgesSynonymCONTROL_FLOW +; + +// Original: pathPatternList +CONTROL_FLOWpathPatternListCONTROL_FLOW +// Original: : pathPattern (COMMA pathPattern)* +: pathPattern (PUNCTUATION_OPERATOR pathPattern)* +; + +// Original: pathPattern +CONTROL_FLOWpathPatternCONTROL_FLOW +// Original: : pathVariableDeclaration? pathPatternPrefix? pathPatternExpression +: CONTROL_FLOWpathVariableDeclarationCONTROL_FLOW? CONTROL_FLOWpathPatternPrefixCONTROL_FLOW? CONTROL_FLOWpathPatternExpressionCONTROL_FLOW +; + +// Original: pathVariableDeclaration +CONTROL_FLOWpathVariableDeclarationCONTROL_FLOW +// Original: : pathVariable EQUALS_OPERATOR +: CONTROL_FLOWpathVariableCONTROL_FLOW CONTROL_FLOWEQUALS_OPERATORCONTROL_FLOW +; + +// Original: keepClause +CONTROL_FLOWkeepClauseCONTROL_FLOW +// Original: : KEEP pathPatternPrefix +: CONTROL_FLOWKEEPCONTROL_FLOW CONTROL_FLOWpathPatternPrefixCONTROL_FLOW +; + +// Original: graphPatternWhereClause +CONTROL_FLOWgraphPatternWhereClauseCONTROL_FLOW +// Original: : WHERE searchCondition +// Original: : KEYWORD searchCondition +: CONTROL_FLOWKEYWORDCONTROL_FLOW CONTROL_FLOWsearchConditionCONTROL_FLOW +; + +// 16.5 + +// Original: insertGraphPattern +CONTROL_FLOWinsertGraphPatternCONTROL_FLOW +// Original: : insertPathPatternList +: CONTROL_FLOWinsertPathPatternListCONTROL_FLOW +; + +// Original: insertPathPatternList +CONTROL_FLOWinsertPathPatternListCONTROL_FLOW +// Original: : insertPathPattern (COMMA insertPathPattern)* +: insertPathPattern (PUNCTUATION_OPERATOR insertPathPattern)* +; + +// Original: insertPathPattern +CONTROL_FLOWinsertPathPatternCONTROL_FLOW +: insertNodePattern (insertEdgePattern insertNodePattern)* +; + +// Original: insertNodePattern +CONTROL_FLOWinsertNodePatternCONTROL_FLOW +// Original: : LEFT_PAREN insertElementPatternFiller? RIGHT_PAREN +// Original: : LEFT_PAREN insertElementPatternFiller? PUNCTUATION_OPERATOR +: CONTROL_FLOWLEFT_PARENCONTROL_FLOW CONTROL_FLOWinsertElementPatternFillerCONTROL_FLOW? CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW +; + +// Original: insertEdgePattern +CONTROL_FLOWinsertEdgePatternCONTROL_FLOW +// Original: : insertEdgePointingLeft +: CONTROL_FLOWinsertEdgePointingLeftCONTROL_FLOW +// Original: | insertEdgePointingRight +| CONTROL_FLOWinsertEdgePointingRightCONTROL_FLOW +// Original: | insertEdgeUndirected +| CONTROL_FLOWinsertEdgeUndirectedCONTROL_FLOW +; + +// Original: insertEdgePointingLeft +CONTROL_FLOWinsertEdgePointingLeftCONTROL_FLOW +// Original: : LEFT_ARROW_BRACKET insertElementPatternFiller? RIGHT_BRACKET_MINUS +: CONTROL_FLOWLEFT_ARROW_BRACKETCONTROL_FLOW CONTROL_FLOWinsertElementPatternFillerCONTROL_FLOW? CONTROL_FLOWRIGHT_BRACKET_MINUSCONTROL_FLOW +; + +// Original: insertEdgePointingRight +CONTROL_FLOWinsertEdgePointingRightCONTROL_FLOW +// Original: : MINUS_LEFT_BRACKET insertElementPatternFiller? BRACKET_RIGHT_ARROW +// Original: : MINUS_LEFT_BRACKET insertElementPatternFiller? PUNCTUATION_OPERATOR +: CONTROL_FLOWMINUS_LEFT_BRACKETCONTROL_FLOW CONTROL_FLOWinsertElementPatternFillerCONTROL_FLOW? CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW +; + +// Original: insertEdgeUndirected +CONTROL_FLOWinsertEdgeUndirectedCONTROL_FLOW +// Original: : TILDE_LEFT_BRACKET insertElementPatternFiller? RIGHT_BRACKET_TILDE +// Original: : TILDE_LEFT_BRACKET insertElementPatternFiller? PUNCTUATION_OPERATOR +// Original: : PUNCTUATION_OPERATOR insertElementPatternFiller? PUNCTUATION_OPERATOR +: CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW CONTROL_FLOWinsertElementPatternFillerCONTROL_FLOW? CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW +; + +// Original: insertElementPatternFiller +CONTROL_FLOWinsertElementPatternFillerCONTROL_FLOW +: elementVariableDeclaration labelAndPropertySetSpecification? +// Original: | elementVariableDeclaration? labelAndPropertySetSpecification +| CONTROL_FLOWelementVariableDeclarationCONTROL_FLOW? CONTROL_FLOWlabelAndPropertySetSpecificationCONTROL_FLOW +; + +// Original: labelAndPropertySetSpecification +CONTROL_FLOWlabelAndPropertySetSpecificationCONTROL_FLOW +: isOrColon labelSetSpecification elementPropertySpecification? +// Original: | (isOrColon labelSetSpecification)? elementPropertySpecification +| (CONTROL_FLOWisOrColonCONTROL_FLOW CONTROL_FLOWlabelSetSpecificationCONTROL_FLOW)? CONTROL_FLOWelementPropertySpecificationCONTROL_FLOW +; + +// 16.6 + +// Original: pathPatternPrefix +CONTROL_FLOWpathPatternPrefixCONTROL_FLOW +// Original: : pathModePrefix +: CONTROL_FLOWpathModePrefixCONTROL_FLOW +// Original: | pathSearchPrefix +| CONTROL_FLOWpathSearchPrefixCONTROL_FLOW +; + +// Original: pathModePrefix +CONTROL_FLOWpathModePrefixCONTROL_FLOW +: pathMode pathOrPaths? +; + +// Original: pathMode +CONTROL_FLOWpathModeCONTROL_FLOW +// Original: : WALK +: CONTROL_FLOWWALKCONTROL_FLOW +// Original: | TRAIL +| CONTROL_FLOWTRAILCONTROL_FLOW +// Original: | SIMPLE +// Original: | KEYWORD +| CONTROL_FLOWKEYWORDCONTROL_FLOW +// Original: | ACYCLIC +| CONTROL_FLOWACYCLICCONTROL_FLOW +; + +// Original: pathSearchPrefix +CONTROL_FLOWpathSearchPrefixCONTROL_FLOW +// Original: : allPathSearch +: CONTROL_FLOWallPathSearchCONTROL_FLOW +// Original: | anyPathSearch +| CONTROL_FLOWanyPathSearchCONTROL_FLOW +// Original: | shortestPathSearch +| CONTROL_FLOWshortestPathSearchCONTROL_FLOW +; + +// Original: allPathSearch +CONTROL_FLOWallPathSearchCONTROL_FLOW +// Original: : ALL pathMode? pathOrPaths? +: KEYWORD pathMode? pathOrPaths? +; + +// Original: pathOrPaths +CONTROL_FLOWpathOrPathsCONTROL_FLOW +// Original: : PATH +// Original: : KEYWORD +: CONTROL_FLOWKEYWORDCONTROL_FLOW +// Original: | PATHS +// Original: | KEYWORD +| CONTROL_FLOWKEYWORDCONTROL_FLOW +; + +// Original: anyPathSearch +CONTROL_FLOWanyPathSearchCONTROL_FLOW +// Original: : ANY numberOfPaths? pathMode? pathOrPaths? +: KEYWORD numberOfPaths? pathMode? pathOrPaths? +; + +// Original: numberOfPaths +CONTROL_FLOWnumberOfPathsCONTROL_FLOW +// Original: : nonNegativeIntegerSpecification +: CONTROL_FLOWnonNegativeIntegerSpecificationCONTROL_FLOW +; + +// Original: shortestPathSearch +CONTROL_FLOWshortestPathSearchCONTROL_FLOW +// Original: : allShortestPathSearch +: CONTROL_FLOWallShortestPathSearchCONTROL_FLOW +// Original: | anyShortestPathSearch +| CONTROL_FLOWanyShortestPathSearchCONTROL_FLOW +// Original: | countedShortestPathSearch +| CONTROL_FLOWcountedShortestPathSearchCONTROL_FLOW +// Original: | countedShortestGroupSearch +| CONTROL_FLOWcountedShortestGroupSearchCONTROL_FLOW +; + +// Original: allShortestPathSearch +CONTROL_FLOWallShortestPathSearchCONTROL_FLOW +// Original: : ALL SHORTEST pathMode? pathOrPaths? +// Original: : KEYWORD SHORTEST pathMode? pathOrPaths? +: KEYWORD KEYWORD pathMode? pathOrPaths? +; + +// Original: anyShortestPathSearch +CONTROL_FLOWanyShortestPathSearchCONTROL_FLOW +// Original: : ANY SHORTEST pathMode? pathOrPaths? +// Original: : ANY KEYWORD pathMode? pathOrPaths? +: KEYWORD KEYWORD pathMode? pathOrPaths? +; + +// Original: countedShortestPathSearch +CONTROL_FLOWcountedShortestPathSearchCONTROL_FLOW +// Original: : SHORTEST numberOfPaths pathMode? pathOrPaths? +: KEYWORD numberOfPaths pathMode? pathOrPaths? +; + +// Original: countedShortestGroupSearch +CONTROL_FLOWcountedShortestGroupSearchCONTROL_FLOW +// Original: : SHORTEST numberOfGroups? pathMode? pathOrPaths? (GROUP | GROUPS) +// Original: : SHORTEST numberOfGroups? pathMode? pathOrPaths? (GROUP | KEYWORD) +// Original: : SHORTEST numberOfGroups? pathMode? pathOrPaths? (KEYWORD | KEYWORD) +: KEYWORD numberOfGroups? pathMode? pathOrPaths? (KEYWORD | KEYWORD) +; + +// Original: numberOfGroups +CONTROL_FLOWnumberOfGroupsCONTROL_FLOW +// Original: : nonNegativeIntegerSpecification +: CONTROL_FLOWnonNegativeIntegerSpecificationCONTROL_FLOW +; + +// 16.7 + +// Original: pathPatternExpression +CONTROL_FLOWpathPatternExpressionCONTROL_FLOW +// Original: : pathTerm #ppePathTerm +: CONTROL_FLOWpathTermCONTROL_FLOW #CONTROL_FLOWppePathTermCONTROL_FLOW +// Original: | pathTerm (MULTISET_ALTERNATION_OPERATOR pathTerm)+ #ppeMultisetAlternation +| CONTROL_FLOWpathTermCONTROL_FLOW (CONTROL_FLOWMULTISET_ALTERNATION_OPERATORCONTROL_FLOW CONTROL_FLOWpathTermCONTROL_FLOW)+ #CONTROL_FLOWppeMultisetAlternationCONTROL_FLOW +// Original: | pathTerm (VERTICAL_BAR pathTerm)+ #ppePatternUnion +| CONTROL_FLOWpathTermCONTROL_FLOW (CONTROL_FLOWVERTICAL_BARCONTROL_FLOW CONTROL_FLOWpathTermCONTROL_FLOW)+ #CONTROL_FLOWppePatternUnionCONTROL_FLOW +; + +// Original: pathTerm +CONTROL_FLOWpathTermCONTROL_FLOW +: pathFactor+ +; + +// Original: pathFactor +CONTROL_FLOWpathFactorCONTROL_FLOW +// Original: : pathPrimary #pfPathPrimary +: CONTROL_FLOWpathPrimaryCONTROL_FLOW #CONTROL_FLOWpfPathPrimaryCONTROL_FLOW +// Original: | pathPrimary graphPatternQuantifier #pfQuantifiedPathPrimary +| CONTROL_FLOWpathPrimaryCONTROL_FLOW CONTROL_FLOWgraphPatternQuantifierCONTROL_FLOW #CONTROL_FLOWpfQuantifiedPathPrimaryCONTROL_FLOW +// Original: | pathPrimary QUESTION_MARK #pfQuestionedPathPrimary +| CONTROL_FLOWpathPrimaryCONTROL_FLOW CONTROL_FLOWQUESTION_MARKCONTROL_FLOW #CONTROL_FLOWpfQuestionedPathPrimaryCONTROL_FLOW +; + +// Original: pathPrimary +CONTROL_FLOWpathPrimaryCONTROL_FLOW +// Original: : elementPattern #ppElementPattern +: CONTROL_FLOWelementPatternCONTROL_FLOW #CONTROL_FLOWppElementPatternCONTROL_FLOW +// Original: | parenthesizedPathPatternExpression #ppParenthesizedPathPatternExpression +| CONTROL_FLOWparenthesizedPathPatternExpressionCONTROL_FLOW #CONTROL_FLOWppParenthesizedPathPatternExpressionCONTROL_FLOW +// Original: | simplifiedPathPatternExpression #ppSimplifiedPathPatternExpression +| CONTROL_FLOWsimplifiedPathPatternExpressionCONTROL_FLOW #CONTROL_FLOWppSimplifiedPathPatternExpressionCONTROL_FLOW +; + +// Original: elementPattern +CONTROL_FLOWelementPatternCONTROL_FLOW +// Original: : nodePattern +: CONTROL_FLOWnodePatternCONTROL_FLOW +// Original: | edgePattern +| CONTROL_FLOWedgePatternCONTROL_FLOW +; + +// Original: nodePattern +CONTROL_FLOWnodePatternCONTROL_FLOW +// Original: : LEFT_PAREN elementPatternFiller RIGHT_PAREN +// Original: : LEFT_PAREN elementPatternFiller PUNCTUATION_OPERATOR +: CONTROL_FLOWLEFT_PARENCONTROL_FLOW CONTROL_FLOWelementPatternFillerCONTROL_FLOW CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW +; + +// Original: elementPatternFiller +CONTROL_FLOWelementPatternFillerCONTROL_FLOW +: elementVariableDeclaration? isLabelExpression? elementPatternPredicate? +; + +// Original: elementVariableDeclaration +CONTROL_FLOWelementVariableDeclarationCONTROL_FLOW +// Original: : TEMP? elementVariable +: CONTROL_FLOWTEMPCONTROL_FLOW? CONTROL_FLOWelementVariableCONTROL_FLOW +; + +// Original: isLabelExpression +CONTROL_FLOWisLabelExpressionCONTROL_FLOW +// Original: : isOrColon labelExpression +: CONTROL_FLOWisOrColonCONTROL_FLOW CONTROL_FLOWlabelExpressionCONTROL_FLOW +; + +// Original: isOrColon +CONTROL_FLOWisOrColonCONTROL_FLOW +// Original: : IS +: CONTROL_FLOWISCONTROL_FLOW +// Original: | COLON +| CONTROL_FLOWCOLONCONTROL_FLOW +; + +// Original: elementPatternPredicate +CONTROL_FLOWelementPatternPredicateCONTROL_FLOW +// Original: : elementPatternWhereClause +: CONTROL_FLOWelementPatternWhereClauseCONTROL_FLOW +// Original: | elementPropertySpecification +| CONTROL_FLOWelementPropertySpecificationCONTROL_FLOW +; + +// Original: elementPatternWhereClause +CONTROL_FLOWelementPatternWhereClauseCONTROL_FLOW +// Original: : WHERE searchCondition +// Original: : KEYWORD searchCondition +: CONTROL_FLOWKEYWORDCONTROL_FLOW CONTROL_FLOWsearchConditionCONTROL_FLOW +; + +// Original: elementPropertySpecification +CONTROL_FLOWelementPropertySpecificationCONTROL_FLOW +// Original: : LEFT_BRACE propertyKeyValuePairList RIGHT_BRACE +: CONTROL_FLOWLEFT_BRACECONTROL_FLOW CONTROL_FLOWpropertyKeyValuePairListCONTROL_FLOW CONTROL_FLOWRIGHT_BRACECONTROL_FLOW +; + +// Original: propertyKeyValuePairList +CONTROL_FLOWpropertyKeyValuePairListCONTROL_FLOW +// Original: : propertyKeyValuePair (COMMA propertyKeyValuePair)* +: propertyKeyValuePair (PUNCTUATION_OPERATOR propertyKeyValuePair)* +; + +// Original: propertyKeyValuePair +CONTROL_FLOWpropertyKeyValuePairCONTROL_FLOW +// Original: : propertyName COLON valueExpression +: CONTROL_FLOWpropertyNameCONTROL_FLOW CONTROL_FLOWCOLONCONTROL_FLOW CONTROL_FLOWvalueExpressionCONTROL_FLOW +; + +// Original: edgePattern +CONTROL_FLOWedgePatternCONTROL_FLOW +// Original: : fullEdgePattern +: CONTROL_FLOWfullEdgePatternCONTROL_FLOW +// Original: | abbreviatedEdgePattern +| CONTROL_FLOWabbreviatedEdgePatternCONTROL_FLOW +; + +// Original: fullEdgePattern +CONTROL_FLOWfullEdgePatternCONTROL_FLOW +// Original: : fullEdgePointingLeft +: CONTROL_FLOWfullEdgePointingLeftCONTROL_FLOW +// Original: | fullEdgeUndirected +| CONTROL_FLOWfullEdgeUndirectedCONTROL_FLOW +// Original: | fullEdgePointingRight +| CONTROL_FLOWfullEdgePointingRightCONTROL_FLOW +// Original: | fullEdgeLeftOrUndirected +| CONTROL_FLOWfullEdgeLeftOrUndirectedCONTROL_FLOW +// Original: | fullEdgeUndirectedOrRight +| CONTROL_FLOWfullEdgeUndirectedOrRightCONTROL_FLOW +// Original: | fullEdgeLeftOrRight +| CONTROL_FLOWfullEdgeLeftOrRightCONTROL_FLOW +// Original: | fullEdgeAnyDirection +| CONTROL_FLOWfullEdgeAnyDirectionCONTROL_FLOW +; + +// Original: fullEdgePointingLeft +CONTROL_FLOWfullEdgePointingLeftCONTROL_FLOW +// Original: : LEFT_ARROW_BRACKET elementPatternFiller RIGHT_BRACKET_MINUS +: CONTROL_FLOWLEFT_ARROW_BRACKETCONTROL_FLOW CONTROL_FLOWelementPatternFillerCONTROL_FLOW CONTROL_FLOWRIGHT_BRACKET_MINUSCONTROL_FLOW +; + +// Original: fullEdgeUndirected +CONTROL_FLOWfullEdgeUndirectedCONTROL_FLOW +// Original: : TILDE_LEFT_BRACKET elementPatternFiller RIGHT_BRACKET_TILDE +// Original: : TILDE_LEFT_BRACKET elementPatternFiller PUNCTUATION_OPERATOR +// Original: : PUNCTUATION_OPERATOR elementPatternFiller PUNCTUATION_OPERATOR +: CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW CONTROL_FLOWelementPatternFillerCONTROL_FLOW CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW +; + +// Original: fullEdgePointingRight +CONTROL_FLOWfullEdgePointingRightCONTROL_FLOW +// Original: : MINUS_LEFT_BRACKET elementPatternFiller BRACKET_RIGHT_ARROW +// Original: : MINUS_LEFT_BRACKET elementPatternFiller PUNCTUATION_OPERATOR +: CONTROL_FLOWMINUS_LEFT_BRACKETCONTROL_FLOW CONTROL_FLOWelementPatternFillerCONTROL_FLOW CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW +; + +// Original: fullEdgeLeftOrUndirected +CONTROL_FLOWfullEdgeLeftOrUndirectedCONTROL_FLOW +// Original: : LEFT_ARROW_TILDE_BRACKET elementPatternFiller RIGHT_BRACKET_TILDE +// Original: : LEFT_ARROW_TILDE_BRACKET elementPatternFiller PUNCTUATION_OPERATOR +: CONTROL_FLOWLEFT_ARROW_TILDE_BRACKETCONTROL_FLOW CONTROL_FLOWelementPatternFillerCONTROL_FLOW CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW +; + +// Original: fullEdgeUndirectedOrRight +CONTROL_FLOWfullEdgeUndirectedOrRightCONTROL_FLOW +// Original: : TILDE_LEFT_BRACKET elementPatternFiller BRACKET_TILDE_RIGHT_ARROW +// Original: : PUNCTUATION_OPERATOR elementPatternFiller BRACKET_TILDE_RIGHT_ARROW +: CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW CONTROL_FLOWelementPatternFillerCONTROL_FLOW CONTROL_FLOWBRACKET_TILDE_RIGHT_ARROWCONTROL_FLOW +; + +// Original: fullEdgeLeftOrRight +CONTROL_FLOWfullEdgeLeftOrRightCONTROL_FLOW +// Original: : LEFT_ARROW_BRACKET elementPatternFiller BRACKET_RIGHT_ARROW +// Original: : LEFT_ARROW_BRACKET elementPatternFiller PUNCTUATION_OPERATOR +: CONTROL_FLOWLEFT_ARROW_BRACKETCONTROL_FLOW CONTROL_FLOWelementPatternFillerCONTROL_FLOW CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW +; + +// Original: fullEdgeAnyDirection +CONTROL_FLOWfullEdgeAnyDirectionCONTROL_FLOW +// Original: : MINUS_LEFT_BRACKET elementPatternFiller RIGHT_BRACKET_MINUS +: CONTROL_FLOWMINUS_LEFT_BRACKETCONTROL_FLOW CONTROL_FLOWelementPatternFillerCONTROL_FLOW CONTROL_FLOWRIGHT_BRACKET_MINUSCONTROL_FLOW +; + +// Original: abbreviatedEdgePattern +CONTROL_FLOWabbreviatedEdgePatternCONTROL_FLOW +// Original: : LEFT_ARROW +: CONTROL_FLOWLEFT_ARROWCONTROL_FLOW +// Original: | TILDE +| CONTROL_FLOWTILDECONTROL_FLOW +// Original: | RIGHT_ARROW +// Original: | PUNCTUATION_OPERATOR +| CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW +// Original: | LEFT_ARROW_TILDE +// Original: | KEYWORD +| CONTROL_FLOWKEYWORDCONTROL_FLOW +// Original: | TILDE_RIGHT_ARROW +| CONTROL_FLOWTILDE_RIGHT_ARROWCONTROL_FLOW +// Original: | LEFT_MINUS_RIGHT +| CONTROL_FLOWLEFT_MINUS_RIGHTCONTROL_FLOW +// Original: | MINUS_SIGN +| CONTROL_FLOWMINUS_SIGNCONTROL_FLOW +; + +// Original: parenthesizedPathPatternExpression +CONTROL_FLOWparenthesizedPathPatternExpressionCONTROL_FLOW +// Original: : LEFT_PAREN subpathVariableDeclaration? pathModePrefix? pathPatternExpression parenthesizedPathPatternWhereClause? RIGHT_PAREN +// Original: : LEFT_PAREN subpathVariableDeclaration? pathModePrefix? pathPatternExpression parenthesizedPathPatternWhereClause? PUNCTUATION_OPERATOR +: CONTROL_FLOWLEFT_PARENCONTROL_FLOW CONTROL_FLOWsubpathVariableDeclarationCONTROL_FLOW? CONTROL_FLOWpathModePrefixCONTROL_FLOW? CONTROL_FLOWpathPatternExpressionCONTROL_FLOW CONTROL_FLOWparenthesizedPathPatternWhereClauseCONTROL_FLOW? CONTROL_FLOWPUNCTUATION_OPERATORCONTROL_FLOW +; + +// Original: subpathVariableDeclaration +CONTROL_FLOWsubpathVariableDeclarationCONTROL_FLOW +// Original: : subpathVariable EQUALS_OPERATOR +: CONTROL_FLOWsubpathVariableCONTROL_FLOW CONTROL_FLOWEQUALS_OPERATORCONTROL_FLOW +; + +// Original: parenthesizedPathPatternWhereClause +CONTROL_FLOWparenthesizedPathPatternWhereClauseCONTROL_FLOW +// Original: : WHERE searchCondition +// Original: : KEYWORD searchCondition +: CONTROL_FLOWKEYWORDCONTROL_FLOW CONTROL_FLOWsearchConditionCONTROL_FLOW +; + +// 16.8