Permalink
Fetching contributors…
Cannot retrieve contributors at this time
352 lines (289 sloc) 10.1 KB
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015-2018 "Neo Technology,"
Network Engine for Objects in Lund AB [http://neotechnology.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.
Attribution Notice under the terms of the Apache License 2.0
This work was created by the collective efforts of the openCypher community.
Without limiting the terms of Section 6, any Derivative Work that is not
approved by the public consensus process of the openCypher Implementers Group
should not be described as “Cypher” (and Cypher® is a registered trademark of
Neo4j Inc.) or as "openCypher". Extensions by implementers or prototypes or
proposals for change that have been documented or implemented should only be
described as "implementation extensions to Cypher" or as "proposed changes to
Cypher that are not yet approved by the openCypher community".
-->
<!DOCTYPE grammar [
<!ENTITY WS "<opt><non-terminal ref='SP'/></opt>">
<!ENTITY SP "<non-terminal ref='SP'/>">
<!ENTITY expr "<non-terminal ref='Expression'/>">
<!ENTITY var "<non-terminal ref='Variable'/>">
]>
<grammar language="Cypher"
xmlns="http://opencypher.org/grammar"
xmlns:rr="http://opencypher.org/railroad"
xmlns:oc="http://opencypher.org/opencypher"
xmlns:scope="http://opencypher.org/scope">
<production name="Cypher">
&WS;
<non-terminal ref="QueryOptions"/>
<non-terminal ref="Statement"/>
<opt>&WS; ;</opt>
&WS;
<character set="EOI"/>
</production>
<vocabulary file="pre-parser.xml"/>
<!-- / STATEMENTS \ -->
<production name="Statement" rr:inline="true">
<alt>
<non-terminal ref="Command"/>
<non-terminal ref="Query"/>
</alt>
</production>
<production name="Query" rr:inline="true">
<alt>
<non-terminal ref="RegularQuery"/>
<non-terminal ref="StandaloneCall"/>
<non-terminal ref="BulkImportQuery"/>
</alt>
</production>
<production name="RegularQuery" rr:inline="true">
<non-terminal ref="SingleQuery"/>
<repeat>&WS;<non-terminal ref="Union"/></repeat>
</production>
<production name="BulkImportQuery" oc:legacy="true">
<non-terminal ref="PeriodicCommitHint"/>
&WS;
<non-terminal ref="LoadCSVQuery"/>
</production>
<production name="PeriodicCommitHint" rr:inline="true" oc:legacy="true">
USING &SP; PERIODIC &SP; COMMIT
<opt>&SP;<non-terminal ref="IntegerLiteral"/></opt>
</production>
<production name="LoadCSVQuery" rr:inline="true" oc:legacy="true">
<non-terminal ref="LoadCSV"/>
<non-terminal ref="SingleQuery"/>
</production>
<production name="Union" rr:inline="true">
<alt>
<seq>UNION &SP; ALL &WS;<non-terminal ref="SingleQuery"/></seq>
<seq>UNION &WS;<non-terminal ref="SingleQuery"/></seq>
</alt>
</production>
<production name="SingleQuery" rr:inline="true">
<alt>
<non-terminal ref="SinglePartQuery"/>
<non-terminal ref="MultiPartQuery"/>
</alt>
</production>
<production name="SinglePartQuery">
<alt>
<seq>
<repeat>
<non-terminal ref="ReadingClause"/> &WS;
</repeat>
<non-terminal ref="Return"/>
</seq>
<seq>
<repeat>
<non-terminal ref="ReadingClause"/> &WS;
</repeat>
<non-terminal ref="UpdatingClause"/>
<repeat>
&WS; <non-terminal ref="UpdatingClause"/>
</repeat>
<opt>&WS; <non-terminal ref="Return"/></opt>
</seq>
</alt>
</production>
<production name="MultiPartQuery">
<repeat min="1">
<repeat>
<non-terminal ref="ReadingClause"/> &WS;
</repeat>
<repeat>
<non-terminal ref="UpdatingClause"/> &WS;
</repeat>
<non-terminal ref="With"/> &WS;
</repeat>
<non-terminal ref="SinglePartQuery"/>
</production>
<production name="UpdatingClause" rr:inline="true">
<alt>
<non-terminal ref="Create"/>
<non-terminal ref="Merge"/>
<non-terminal ref="CreateUnique"/>
<non-terminal ref="Foreach"/>
<non-terminal ref="Delete"/>
<non-terminal ref="Set"/>
<non-terminal ref="Remove"/>
</alt>
</production>
<production name="ReadingClause" rr:inline="true">
<alt>
<non-terminal ref="LoadCSV"/>
<non-terminal ref="Start"/>
<non-terminal ref="Match"/>
<non-terminal ref="Unwind"/>
<non-terminal ref="InQueryCall"/>
</alt>
</production>
<!-- \ STATEMENTS / -->
<vocabulary file="commands.xml"/>
<!-- / CLAUSES \ -->
<production name="LoadCSV" oc:legacy="true">
LOAD &SP; CSV &SP;
<opt>WITH &SP; HEADERS &SP;</opt>
FROM &SP; &expr; &SP;
AS &SP; &var; &SP;
<opt>FIELDTERMINATOR &SP; <non-terminal ref="StringLiteral"/></opt>
</production>
<production name="Match" scope:rule="new">
<opt>OPTIONAL &SP;</opt>MATCH &WS;
<non-terminal ref="Pattern"/>
<repeat><non-terminal ref="Hint"/></repeat>
<opt>&WS; <non-terminal ref="Where"/></opt>
</production>
<production name="Unwind">
UNWIND &WS; &expr; &SP; AS &SP; &var;
</production>
<production name="Merge">
MERGE &WS; <non-terminal ref="PatternPart"/>
<repeat>
&SP; <non-terminal ref="MergeAction"/>
</repeat>
</production>
<production name="MergeAction" rr:inline="true">
<alt>
<seq>ON &SP; MATCH &SP; <non-terminal ref="Set"/></seq>
<seq>ON &SP; CREATE &SP; <non-terminal ref="Set"/></seq>
</alt>
</production>
<production name="Create">
<seq>CREATE &WS; <non-terminal ref="Pattern"/></seq>
</production>
<production name="CreateUnique" oc:legacy="true">
<seq>CREATE &SP; UNIQUE &WS; <non-terminal ref="Pattern"/></seq>
</production>
<production name="Set">
SET &WS; <non-terminal ref="SetItem"/>
<repeat>
, <non-terminal ref="SetItem"/>
</repeat>
</production>
<production name="SetItem" rr:inline="true">
<alt>
<seq><non-terminal ref="PropertyExpression"/> &WS; = &WS; &expr;</seq>
<seq>&var; &WS; = &WS; &expr;</seq>
<seq>&var; &WS; += &WS; &expr;</seq>
<seq>&var; &WS; <non-terminal ref="NodeLabels"/></seq>
</alt>
</production>
<production name="Delete">
<seq>
<opt>DETACH &SP;</opt>
DELETE &WS; &expr;
<repeat>&WS; , &WS; &expr;</repeat>
</seq>
</production>
<production name="Remove">
REMOVE &SP; <non-terminal ref="RemoveItem"/>
<repeat>&WS;,&WS;<non-terminal ref="RemoveItem"/></repeat>
</production>
<production name="RemoveItem" rr:inline="true">
<alt>
<seq>&var;<non-terminal ref="NodeLabels"/></seq>
<non-terminal ref="PropertyExpression"/>
</alt>
</production>
<production name="Foreach" scope:rule="nested" oc:legacy="true">
FOREACH &WS; ( &WS; &var; &SP; IN &SP; &expr; &WS; | <repeat min="1">&SP;<non-terminal ref="UpdatingClause"/></repeat> &WS; )
</production>
<production name="InQueryCall">
<seq>CALL &SP; <non-terminal ref="ExplicitProcedureInvocation"/> <opt>&WS; YIELD &SP; <non-terminal ref="YieldItems"/></opt></seq>
</production>
<production name="StandaloneCall">
<seq>
CALL &SP;
<alt>
<non-terminal ref="ExplicitProcedureInvocation"/>
<non-terminal ref="ImplicitProcedureInvocation"/>
</alt>
<opt>&SP; YIELD &SP; <non-terminal ref="YieldItems"/></opt>
</seq>
</production>
<production name="YieldItems" rr:inline="true">
<alt>
<seq><non-terminal ref="YieldItem"/> <repeat>&WS; , &WS;<non-terminal ref="YieldItem"/></repeat></seq>
-
</alt>
</production>
<production name="YieldItem" rr:inline="true">
<seq><opt><non-terminal ref="ProcedureResultField"/> &SP; AS &SP;</opt> &var;</seq>
</production>
<production name="With" scope:rule="new">
<seq>
WITH
<opt>&WS; DISTINCT</opt> &SP;
<non-terminal ref="ReturnBody"/>
<opt>&WS;<non-terminal ref="Where"/></opt>
</seq>
</production>
<production name="Return">
<seq>
RETURN
<opt>&WS; DISTINCT</opt> &SP;
<non-terminal ref="ReturnBody"/>
</seq>
</production>
<production name="ReturnBody">
<non-terminal ref="ReturnItems"/>
<opt>&SP;<non-terminal ref="Order"/></opt>
<opt>&SP;<non-terminal ref="Skip"/></opt>
<opt>&SP;<non-terminal ref="Limit"/></opt>
</production>
<production name="ReturnItems" rr:inline="true">
<alt>
<seq>*<repeat>&WS; , &WS;<non-terminal ref="ReturnItem"/></repeat></seq>
<seq>
<non-terminal ref="ReturnItem"/>
<repeat>&WS; , &WS;<non-terminal ref="ReturnItem"/></repeat>
</seq>
</alt>
</production>
<production name="ReturnItem" rr:inline="true">
<alt> <seq>&expr; &SP; AS &SP; &var;</seq> &expr; </alt>
</production>
<production name="Order" rr:inline="true">
ORDER &SP; BY &SP; <non-terminal ref="SortItem"/>
<repeat> , &WS; <non-terminal ref="SortItem"/></repeat>
</production>
<production name="Skip" rr:inline="true">
SKIP &SP; &expr;
</production>
<production name="Limit" rr:inline="true">
LIMIT &SP; &expr;
</production>
<production name="SortItem" rr:inline="true">
<seq>&expr; <opt>&WS; <alt>ASCENDING ASC DESCENDING DESC</alt></opt></seq>
</production>
<production name="Hint" oc:legacy="true">
&WS;
<alt>
<seq>USING &SP; INDEX &SP; &var; <non-terminal ref="NodeLabel"/>(<non-terminal ref="PropertyKeyName"/>)</seq>
<seq>USING &SP; JOIN &SP; ON &SP; &var; <repeat>&WS;,&WS;&var;</repeat></seq>
<seq>USING &SP; SCAN &SP; &var; <non-terminal ref="NodeLabel"/></seq>
</alt>
</production>
<vocabulary file="start.xml"/>
<!-- \ CLAUSES / -->
<vocabulary file="basic-grammar.xml"/>
</grammar>