Grammar
Cypher Path Subset is defined as its own ANTLR parser grammar, derived from Neo4j’s Cypher 25 grammar. The railroad diagram below is generated directly from that grammar and shows every rule the parser accepts.
How it differs from Cypher 25
Cypher Path Subset keeps only what is needed to describe a path pattern and return it - most of Cypher 25’s surface area is removed:
- No write access:
CREATE,INSERT,DELETE,SET,REMOVEandMERGEare all gone - a query can only read. - No function calls or existence checks:
functionInvocation,existsExpressionandcountExpressionare not part of the grammar, which rules out arbitrary computation and nested sub-queries inside the query itself. - No procedures or sub-queries:
CALL(both standalone and as a subquery),LOAD CSV,FOREACHandUSEare removed. - A single, non-chainable pipeline: a query is exactly one optional
UNWINDfollowed by oneMATCHfollowed by oneRETURN- there’s noWITHclause to chain multiple stages, and noUNIONto combine queries. - A fixed, minimal
RETURN:returnItemonly allows a bare variable, not arbitrary expressions orASaliases - the query can only return the variablepaths(see step reference).
ORDER BY, SKIP and LIMIT on the result, as well as WHERE filters on patterns, are still fully supported - see the Cypher path query examples for both in use.
See also
- Cypher 25 railroad diagram - the full grammar Cypher Path Subset is derived from.
- openCypher 9 railroad diagram - the standardized core Cypher 25 itself extends.