pub struct Statement {
pub clauses: Vec<Clause>,
pub union: Option<Box<UnionPart>>,
pub preamble: PreambleMode,
pub next: Option<Box<Statement>>,
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>>§preamble: PreambleModeThe CIP-150 preamble mode — top-level only; every nested body
carries PreambleMode::Execute.
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.
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.
Implementations§
Source§impl Statement
Manual PartialEq: deliberately ignores brace_wrapped. The unwrap
rule – 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 Statement
Manual PartialEq: deliberately ignores brace_wrapped. The unwrap
rule – 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.
Sourcepub fn tail_stage(&self) -> &Statement
pub fn tail_stage(&self) -> &Statement
The end of this statement’s NEXT chain: its true terminal stage
(CIP-213), not its own first stage.
Sourcepub fn projection_stage(&self) -> &Statement
pub fn projection_stage(&self) -> &Statement
The stage whose clauses decide what the statement projects (CIP-213):
a UNION head owns the whole composite, so it stands for itself; every
other statement projects through the tail of its own NEXT chain
(A UNION B NEXT C parses as (A UNION B) NEXT C).
Sourcepub fn projects_columns(&self) -> bool
pub fn projects_columns(&self) -> bool
Whether the statement’s final stage projects columns: it ends in a
RETURN, or in a conditional / nested CALL subquery that does. A
unit subquery call with no RETURN makes the enclosing arm a
no-column arm.