Skip to main content

Module parser

Module parser 

Source

Constants§

MAX_NESTING_DEPTH
ADR-0257: maximum nesting depth accepted while parsing. Enforced on expression nesting (every nested expression – parenthesized constructs, list/map literals, function-call arguments, subqueries, … – descends through [Parser::parse_expression]; NOT chains recurse through [Parser::parse_not]) and on statement nesting (subquery bodies). Recursive-descent parsing beyond this depth risks a stack-overflow abort, which – when the engine is embedded via the C ABI – kills the host process instead of surfacing a recoverable error (LABS-69). The front-end lowering boundary enforces the same limit on its own walkers.
MAX_QUERY_BYTES
ADR-0257: maximum size of a Cypher query text accepted by parse, in bytes (4 MiB). Enforced before lexing so that adversarial inputs cannot amplify into unbounded token allocations (LABS-81: 8 MiB of commas used to become >=520 MB of tokens). Every query path – the Rust API, the C ABI, the CLI, the TCK, and Bolt – funnels through the parser’s entry points, each of which constructs through Parser::new, the one site the cap is enforced, so this single check covers them all.
UNDEFINED_VARIABLE_DETAIL
The ParseError::detail tag naming the undefined-variable condition (Neo4j 42N62): every parser site that rejects an unbound name carries it, so EngineError::kind() surfaces UndefinedVariable instead of the generic UnexpectedSyntax fallback. The tag name matches ErrorKind::UndefinedVariable in relate-error.
UNSUPPORTED_ADMINISTRATION_DETAIL
ADR-0116 §2: the ParseError::detail tag on a parse failure for a recognized-but-unsupported database administration command (everything outside CE’s supported set on Relate’s fixed namespaces). The error’s message carries the verbatim statement text (without a leading CYPHER n preamble), so relate-front can raise CE’s UnsupportedAdministrationCommand (51N27) echoing it. The tag name matches ErrorKind::UnsupportedAdministrationCommand in relate-error, so even an unmapped parse error keeps the right TCK kind/class.

Functions§

parse
Parse a Cypher query string into a Statement AST.
parse_expression_str
Parse a bare value expression on the dialect floor (crate::lexer::ParseOptions::default) – the public wrapper for callers with no preview gates to thread; gated callers (and the interpolation-embed sub-parse) use parse_expression_str_with_options.
parse_graph_type_body
Parse a bare <graph type specification body> – the { ... } grammar shared by CREATE GRAPH TYPE/ALTER CURRENT GRAPH TYPE, without the surrounding statement (canonical is wrapped in braces here, so callers pass the CIP-180 canonical form’s comma-joined contents, no braces of their own). Used by relate-executor’s Graph to reconstruct a persisted current_graph_type model from the snapshot manifest on load – see Graph::restore_graph_type_spec. The ADR-0257 size cap rides the constructor (Parser::new’s first statement) and checks the wrapped string – the exact text this entry point lexes.
parse_with_options
Parse a Cypher query string into a Statement AST under parse-affecting preview opt-ins (crate::lexer::ParseOptions: the ADR-0371 gate set the caller’s store resolved from RELATE_PREVIEW, threaded here by relate-front’s preview admission). crate::lexer::ParseOptions::default is the dialect floor: every option widens acceptance of a form the floor rejects, never narrows it, so the ungated parse is exactly parse_with_options with all options off. The ADR-0257 size cap rides the constructor (Parser::new’s first statement), the parser’s one tokenizing site – not this entry point.
selector_is_selective
Whether a CIP-73 path selector is selective in Neo4j’s sense: an explicit selector other than ALL. None (the implicit selector) and ALL are the non-selective spellings; ANY, ANY SHORTEST, ALL SHORTEST and SHORTEST <n> are selective. Neo4j 2026 accepts a named parenthesized sub-path only under a selective search (42N42).