From a810a5d5ddc4d0147ac3d6be184463652ec0532f Mon Sep 17 00:00:00 2001 From: Joshua Shinavier Date: Mon, 16 Sep 2024 19:58:17 -0700 Subject: [PATCH] Work in progress on the GQL model (#140) --- .../Hydra/Sources/Tier4/Ext/Gql/OpenGql.hs | 4076 +++++++++++++++++ 1 file changed, 4076 insertions(+) create mode 100644 hydra-haskell/src/main/haskell/Hydra/Sources/Tier4/Ext/Gql/OpenGql.hs diff --git a/hydra-haskell/src/main/haskell/Hydra/Sources/Tier4/Ext/Gql/OpenGql.hs b/hydra-haskell/src/main/haskell/Hydra/Sources/Tier4/Ext/Gql/OpenGql.hs new file mode 100644 index 000000000..0e78a8a67 --- /dev/null +++ b/hydra-haskell/src/main/haskell/Hydra/Sources/Tier4/Ext/Gql/OpenGql.hs @@ -0,0 +1,4076 @@ +{-# LANGUAGE OverloadedStrings #-} +module Hydra.Sources.Tier4.Ext.Gql.OpenGql where + +import Hydra.Sources.Tier3.All +import Hydra.Dsl.Annotations +import Hydra.Dsl.Bootstrap +import Hydra.Dsl.Types as Types + +openGqlModule :: Module +openGqlModule = Module ns elements [hydraCoreModule] tier0Modules + $ Just ("A GQL model based on the OpenGQL ANTLR grammar, version 15b256b (2024-09-05), available at:" + ++ " https://github.com/opengql/grammar/blob/main/GQL.g4") + where + ns = Namespace "hydra/ext/gql/openGql" + def = datatype ns + gql = typeref ns + + elements = [ + +-- grammar GQL; +-- +-- options { caseInsensitive = true; } +-- +-- // 6 +-- +-- gqlProgram +-- : programActivity sessionCloseCommand? EOF +-- | sessionCloseCommand EOF +-- ; + def "GqlProgram" $ + union [ + "activity">: gql "GqlProgramActivity", + "close">: gql "SessionCloseCommand"], + + def "GqlProgramActivity" $ + record [ + "programActivity">: gql "ProgramActivity", + "sessionCloseCommand">: optional $ gql "SessionCloseCommand"], + +-- programActivity = sessionActivity +-- | transactionActivity +-- ; + def "ProgramActivity" $ + union [ + "session">: gql "SessionActivity", + "transaction">: gql "TransactionActivity"], + +-- sessionActivity = sessionResetCommand+ +-- | sessionSetCommand+ sessionResetCommand* +-- ; + def "SessionActivity" $ + union [ + "resetCommands">: nonemptyList $ gql "SessionResetCommand", + "setAndResetCommands">: gql "SessionSetAndResetCommands"], + + def "SessionSetAndResetCommands" $ + record [ + "setCommands">: nonemptyList $ gql "SessionSetCommand", + "resetCommands">: list $ gql "SessionResetCommand"], + +-- transactionActivity = startTransactionCommand (procedureSpecification endTransactionCommand?)? +-- | procedureSpecification endTransactionCommand? +-- | endTransactionCommand +-- ; + def "TransactionActivity" $ + union [ + "startAndMaybeProcedureAndEnd">: gql "StartAndMaybeProcedureAndEnd", + "procedureAndMaybeEnd">: gql "ProcedureAndMaybeEnd", + "end">: gql "EndTransactionCommand"], + + def "StartAndMaybeProcedureAndEnd" $ + record [ + "start">: gql "StartTransactionCommand", + "procedureAndEnd">: optional $ gql "ProcedureAndMaybeEnd"], + + def "ProcedureAndMaybeEnd" $ + record [ + "procedure">: gql "ProcedureSpecification", + "end">: optional $ gql "EndTransactionCommand"] + +-- endTransactionCommand = rollbackCommand +-- | commitCommand +-- ; + def "EndTransactionCommand" $ + union [ + "rollback">: gql "RollbackCommand", + "commit">: gql "CommitCommand"] + +-- // 7.1 +-- +-- sessionSetCommand = SESSION SET (sessionSetSchemaClause | sessionSetGraphClause | sessionSetTimeZoneClause | sessionSetParameterClause) +-- ; + def "SessionSetCommand" $ + union [ + "schema">: gql "SessionSetSchemaClause", + "graph">: gql "SessionSetGraphClause", + "timeZone">: gql "SessionSetTimeZoneClause", + "parameter">: gql "SessionSetParameterClause"], + +-- sessionSetSchemaClause = SCHEMA schemaReference +-- ; + def "SessionSetSchemaClause" $ + gql "SchemaReference", + +-- sessionSetGraphClause = PROPERTY? GRAPH graphExpression +-- ; + def "SessionSetGraphClause" $ + record [ + "property">: boolean, + "graphExpression">: gql "GraphExpression"], + +-- sessionSetTimeZoneClause = TIME ZONE setTimeZoneValue +-- ; + def "SessionSetTimeZoneClause" $ + gql "SetTimeZoneValue", + +-- setTimeZoneValue = timeZoneString +-- ; + def "SetTimeZoneValue" $ + gql "TimeZoneString", + + + + + + + + +-- sessionSetParameterClause = sessionSetGraphParameterClause +-- | sessionSetBindingTableParameterClause +-- | sessionSetValueParameterClause +-- ; + def "SessionSetParameterClause" $ + union [ + "graphParameter">: gql "SessionSetGraphParameterClause", + "bindingTableParameter">: gql "SessionSetBindingTableParameterClause", + "valueParameter">: gql "SessionSetValueParameterClause"], + +-- sessionSetGraphParameterClause = PROPERTY? GRAPH sessionSetParameterName optTypedGraphInitializer +-- ; + def "SessionSetGraphParameterClause" $ + record [ + "property">: boolean, + "graph">: gql "SessionSetParameterName", + "optTypedGraphInitializer">: gql "OptTypedGraphInitializer"], + +-- sessionSetBindingTableParameterClause = BINDING? TABLE sessionSetParameterName optTypedBindingTableInitializer +-- ; + def "SessionSetBindingTableParameterClause" $ + record [ + "binding">: boolean, + "table">: gql "SessionSetParameterName", + "optTypedBindingTableInitializer">: gql "OptTypedBindingTableInitializer"], + +-- sessionSetValueParameterClause = VALUE sessionSetParameterName optTypedValueInitializer +-- ; + def "SessionSetValueParameterClause" $ + record [ + "value">: gql "SessionSetParameterName", + "optTypedValueInitializer">: gql "OptTypedValueInitializer"], + +-- sessionSetParameterName = (IF NOT EXISTS)? sessionParameterSpecification +-- ; + def "SessionSetParameterName" $ + record [ + "ifNotExists">: boolean, + "sessionParameterSpecification">: gql "SessionParameterSpecification"] + + + + + + + +-- // 7.2 +-- +-- sessionResetCommand +-- : SESSION RESET sessionResetArguments? +-- ; + def "SessionResetCommand" $ + optional $ gql "SessionResetArguments", + +-- sessionResetArguments +-- : ALL? (PARAMETERS | CHARACTERISTICS) +-- | SCHEMA +-- | PROPERTY? GRAPH +-- | TIME ZONE +-- | PARAMETER? sessionParameterSpecification +-- ; + def "SessionResetArguments" $ + union [ + "allParametersOrCharacteristics">: gql "AllParametersOrCharacteristics", + "schema">: unit, + "propertyGraph">: gql "PropertyGraph", + "timeZone">: unit, + "parameterSessionSpecification">: gql "ParameterSessionSpecification"], + + def "AllParametersOrCharacteristics" $ + record [ + "all">: boolean, + "type">: gql "ParametersOrCharacteristics"], + + def "ParametersOrCharacteristics" $ + union [ + "parameters">: unit, + "characteristics">: unit], + + def "PropertyGraph" $ + record [ + "property">: boolean, + "graph">: unit], + + def "ParameterSessionSpecification" $ + record [ + "parameter">: boolean, + "sessionParameterSpecification">: gql "SessionParameterSpecification"] + + + + + +-- // 7.3 +-- +-- sessionCloseCommand +-- : SESSION CLOSE +-- ; + def "SessionCloseCommand" $ + unit, + + + +-- // 7.4 +-- +-- sessionParameterSpecification +-- : GENERAL_PARAMETER_REFERENCE +-- ; + def "SessionParameterSpecification" $ + gql "GeneralParameterReference", + + + + + +-- // 8.1 +-- +-- startTransactionCommand +-- : START TRANSACTION transactionCharacteristics? +-- ; + def "StartTransactionCommand" $ + optional $ gql "TransactionCharacteristics", + + + + +-- // 8.2 + +-- transactionCharacteristics +-- : transactionMode (COMMA transactionMode)* +-- ; + def "TransactionCharacteristics" $ + nonemptyList $ gql "TransactionMode", + +-- transactionMode +-- : transactionAccessMode +-- ; + def "TransactionMode" $ + gql "TransactionAccessMode", + +-- transactionAccessMode +-- : READ ONLY +-- | READ WRITE +-- ; + def "TransactionAccessMode" $ + enum [ + "readOnly", + "readWrite"], + + + + + +-- // 8.3 + +-- rollbackCommand +-- : ROLLBACK +-- ; + def "RollbackCommand" $ + unit, + + + + +-- // 8.4 + +-- commitCommand +-- : COMMIT +-- ; + def "CommitCommand" $ + unit, + + + +-- // 9.1 + +-- nestedProcedureSpecification +-- : LEFT_BRACE procedureSpecification RIGHT_BRACE +-- ; + def "NestedProcedureSpecification" $ + gql "ProcedureSpecification", + +-- procedureSpecification +-- : procedureBody +-- // : catalogModifyingProcedureSpecification +-- // | dataModifyingProcedureSpecification +-- // | querySpecification +-- ; + def "ProcedureSpecification" $ + gql "ProcedureBody", + +-- //catalogModifyingProcedureSpecification +-- // : procedureBody +-- // ; + +-- nestedDataModifyingProcedureSpecification +-- : LEFT_BRACE procedureBody RIGHT_BRACE +-- ; + def "NestedDataModifyingProcedureSpecification" $ + gql "ProcedureBody", + +-- //dataModifyingProcedureSpecification +-- // : procedureBody +-- // ; + +-- nestedQuerySpecification +-- : LEFT_BRACE procedureBody RIGHT_BRACE +-- ; + def "NestedQuerySpecification" $ + gql "ProcedureBody", + +-- //querySpecification +-- // : procedureBody +-- // ; + + + + + + + + + +-- // 9.2 + +-- procedureBody +-- : atSchemaClause? bindingVariableDefinitionBlock? statementBlock +-- ; + def "ProcedureBody" $ + record [ + "atSchemaClause":> optional $ gql "AtSchemaClause", + "bindingVariableDefinitionBlock":> optional $ gql "BindingVariableDefinitionBlock", + "statementBlock":> gql "StatementBlock"], + +-- bindingVariableDefinitionBlock +-- : bindingVariableDefinition+ +-- ; + def "BindingVariableDefinitionBlock" $ + nonemptyList $ gql "BindingVariableDefinition", + +-- bindingVariableDefinition +-- : graphVariableDefinition +-- | bindingTableVariableDefinition +-- | valueVariableDefinition +-- ; + def "BindingVariableDefinition" $ + union [ + "graphVariable":> gql "GraphVariableDefinition", + "bindingTableVariable":> gql "BindingTableVariableDefinition", + "valueVariable":> gql "ValueVariableDefinition"], + +-- statementBlock +-- : statement nextStatement* +-- ; + def "StatementBlock" $ + record [ + "statement":> gql "Statement", + "nextStatements":> list $ gql "NextStatement"], + +-- statement +-- : linearCatalogModifyingStatement +-- | linearDataModifyingStatement +-- | compositeQueryStatement +-- ; + def "Statement" $ + union [ + "linearCatalogModifying":> gql "LinearCatalogModifyingStatement", + "linearDataModifying":> gql "LinearDataModifyingStatement", + "compositeQuery":> gql "CompositeQueryStatement"], + +-- nextStatement +-- : NEXT yieldClause? statement +-- ; + def "NextStatement" $ + record [ + "yieldClause":> optional $ gql "YieldClause", + "statement":> gql "Statement"], + + + + + +-- // 10.1 + +-- graphVariableDefinition +-- : PROPERTY? GRAPH bindingVariable optTypedGraphInitializer +-- ; + def "GraphVariableDefinition" $ + record [ + "property":> boolean, + "bindingVariable":> gql "BindingVariable", + "optTypedGraphInitializer":> gql "OptTypedGraphInitializer"], + +-- optTypedGraphInitializer +-- : (typed? graphReferenceValueType)? graphInitializer +-- ; + def "OptTypedGraphInitializer" $ + record [ + "typedGraphReferenceValueType":> optional $ gql "TypedGraphReferenceValueType", + "graphInitializer":> gql "GraphInitializer"], + + def "TypedGraphReferenceValueType" $ + record [ + "typed":> optional $ gql "Typed", + "graphReferenceValueType":> gql "GraphReferenceValueType"], + +-- graphInitializer +-- : EQUALS_OPERATOR graphExpression +-- ; + def "GraphInitializer" $ gql "GraphExpression", + + + + + + + + + + + + + +-- // 10.2 + +-- bindingTableVariableDefinition +-- : BINDING? TABLE bindingVariable optTypedBindingTableInitializer +-- ; + def "BindingTableVariableDefinition" $ + record [ + "isBinding":> boolean, + "bindingVariable":> gql "BindingVariable", + "optTypedInitializer":> gql "OptTypedBindingTableInitializer"], + +-- optTypedBindingTableInitializer +-- : (typed? bindingTableReferenceValueType)? bindingTableInitializer +-- ; + def "OptTypedBindingTableInitializer" $ + record [ + "typedRefType":> optional $ gql "TypedBindingTableReferenceValueType", + "initializer":> gql "BindingTableInitializer"], + +-- typedBindingTableReferenceValueType + def "TypedBindingTableReferenceValueType" $ + record [ + "isTyped":> optional $ gql "Typed", + "refValueType":> gql "BindingTableReferenceValueType"], + +-- bindingTableInitializer +-- : EQUALS_OPERATOR bindingTableExpression +-- ; + def "BindingTableInitializer" $ gql "BindingTableExpression", + +-- // 10.3 + +-- valueVariableDefinition +-- : VALUE bindingVariable optTypedValueInitializer +-- ; + def "ValueVariableDefinition" $ + record [ + "bindingVariable":> gql "BindingVariable", + "optTypedInitializer":> gql "OptTypedValueInitializer"], + +-- optTypedValueInitializer +-- : (typed? valueType)? valueInitializer +-- ; + def "OptTypedValueInitializer" $ + record [ + "typedValueType":> optional $ gql "TypedValueType", + "initializer":> gql "ValueInitializer"], + +-- typedValueType + def "TypedValueType" $ + record [ + "isTyped":> optional $ gql "Typed", + "valueType":> gql "ValueType"], + +-- valueInitializer +-- : EQUALS_OPERATOR valueExpression +-- ; + def "ValueInitializer" $ gql "ValueExpression", + +-- // 11.1 + +-- graphExpression +-- : objectExpressionPrimary +-- | graphReference +-- | objectNameOrBindingVariable +-- | currentGraph +-- ; + def "GraphExpression" $ + union [ + "objectExpr":> gql "ObjectExpressionPrimary", + "graphRef":> gql "GraphReference", + "nameOrVar":> gql "ObjectNameOrBindingVariable", + "current":> gql "CurrentGraph"], + +-- currentGraph +-- : CURRENT_PROPERTY_GRAPH +-- | CURRENT_GRAPH +-- ; + def "CurrentGraph" $ + enum ["CurrentPropertyGraph", "CurrentGraph"], + +-- // 11.2 + +-- bindingTableExpression +-- : nestedBindingTableQuerySpecification +-- | objectExpressionPrimary +-- | bindingTableReference +-- | objectNameOrBindingVariable +-- ; + def "BindingTableExpression" $ + union [ + "nestedSpec":> gql "NestedBindingTableQuerySpecification", + "objectExpr":> gql "ObjectExpressionPrimary", + "tableRef":> gql "BindingTableReference", + "nameOrVar":> gql "ObjectNameOrBindingVariable"], + +-- nestedBindingTableQuerySpecification +-- : nestedQuerySpecification +-- ; + def "NestedBindingTableQuerySpecification" $ gql "NestedQuerySpecification", + +-- // 11.3 + +-- objectExpressionPrimary +-- : VARIABLE valueExpressionPrimary +-- | parenthesizedValueExpression +-- | nonParenthesizedValueExpressionPrimarySpecialCase +-- ; + def "ObjectExpressionPrimary" $ + union [ + "variableExpr":> gql "ValueExpressionPrimary", + "parenthesized":> gql "ParenthesizedValueExpression", + "nonParenthesized":> gql "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 +-- : simpleDataAccessingStatement+ +-- ; +-- +-- 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