pub struct Statement {
pub clauses: Vec<Clause>,
pub union: Option<Box<UnionPart>>,
pub explain: bool,
pub profile: bool,
pub next: Option<Box<Statement>>,
pub cypher_version: Option<u32>,
pub brace_wrapped: bool,
pub definitions: Vec<LocalDefinition>,
}Expand description
AST node types for the Cypher parser.
The AST uses enums for Clause, Expr, and PatternElement to avoid trait objects. Literal values use native Rust types (not CypherValue) since the AST is a compile-time concept.
Top-level AST node for a Cypher statement.
Fields§
§clauses: Vec<Clause>§union: Option<Box<UnionPart>>§explain: bool§profile: bool§next: Option<Box<Statement>>CIP-213 <statement block> ::= <statement> [<next statement>...],
<next statement> ::= NEXT <statement>. next chains this
statement (which may itself carry its own .union chain, or be a
sole Clause::Conditional) to the following NEXT stage’s own
statement (which may in turn have a .next of its own). None
means this is either not part of a NEXT chain, or is its final
stage. Deliberately a sibling field to union/Conditional
rather than nested inside them: per the CIP grammar, NEXT operates
on a whole <statement> (union-chain-or-conditional), one level
above where UNION/WHEN operate, so it’s threaded through the
outermost Statement of each stage only – a stage’s own .union
arms never carry their own independent .next chain.
cypher_version: Option<u32>CIP-150: the effective Cypher language version explicitly requested
by a CYPHER <version> statement preamble (5 or 25), or None
if the query had no version-bearing preamble clause at all (a
version-less CYPHER <options> clause with no <cypher version>
token also leaves this None). Only ever set on the outermost
Statement a top-level parse() call returns – the preamble is
parsed once, before any clause, so nested statements (UNION arms,
CALL/EXISTS/COUNT subquery bodies, NEXT stages) never carry
their own value here and consumers must read it off the top-level
statement. None means “use the session/database default
language”, which Relate always resolves to 25 (its only
implemented dialect) since it has no CIP-170 default-language
configuration surface.
brace_wrapped: boolCIP-146/CIP-242: true when this SingleQuery was written as
[ USE <graph-expr> ] '{' <RegularQuery> '}' – top-level braces –
rather than the plain unbraced form. The brace form’s content is
otherwise indistinguishable from an unbraced statement (same clause
list, same .union chain) once parsed, but CIP-242’s SHOW/TERMINATE
composability rule (“Composing a SHOW command without YIELD fails”)
treats an explicitly brace-wrapped bare SHOW (e.g. { SHOW INDEXES }) as composed, requiring YIELD, even though the identical
clause list unbraced (SHOW INDEXES alone) is the lenient
“canonical standalone” form that doesn’t need one – so this needs
its own marker distinct from clause shape. Set only by
parse_braced_single_query; every other Statement constructor
leaves it false (via #[derive(Default)] field-by-field
construction elsewhere).
definitions: Vec<LocalDefinition>CIP-231: the DEFINE <procedure definition> | <function definition> block parsed at the head of this statement block (only
the top-level statement and braced nested bodies carry definitions;
every statement-block parse site funnels through
parse_statement_block, where they are parsed). Rewritten away –
definitions and their call sites eliminated – by the front-end
resolver (relate-front’s local_callables) before lowering;
the planner/executor never see local callables. Default-empty so
the derived and hand-written constructors of un-gated statements
are unchanged.
Trait Implementations§
Source§impl PartialEq for Statement
Manual PartialEq: deliberately ignores brace_wrapped. CIP-146’s own
“Semantics Step 3, Unwrap Case 1” – and the parser tests pinning it
(test_brace_enclosed_top_level_query_is_transparent and friends) –
treat a brace-wrapped SingleQuery as producing an AST indistinguishable
from its unbraced spelling; brace_wrapped is out-of-band provenance a
couple of CIP-242 composability checks read directly off the field
(validate_show_composability), not part of that observable-content
equivalence.
impl PartialEq for Statement
Manual PartialEq: deliberately ignores brace_wrapped. CIP-146’s own
“Semantics Step 3, Unwrap Case 1” – and the parser tests pinning it
(test_brace_enclosed_top_level_query_is_transparent and friends) –
treat a brace-wrapped SingleQuery as producing an AST indistinguishable
from its unbraced spelling; brace_wrapped is out-of-band provenance a
couple of CIP-242 composability checks read directly off the field
(validate_show_composability), not part of that observable-content
equivalence.