1use std::fmt;
38use std::ops::ControlFlow;
39
40use crate::ast::*;
41
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
44pub enum Field {
45 Named(&'static str),
46 Index(usize),
47}
48
49impl fmt::Display for Field {
50 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51 match self {
52 Self::Named(name) => f.write_str(name),
53 Self::Index(index) => write!(f, "[{index}]"),
54 }
55 }
56}
57
58#[derive(Clone, Copy, Debug, PartialEq)]
62pub enum Scalar<'ast> {
63 None,
64 Bool(bool),
65 Unsigned(u64),
66 Signed(i64),
67 Float(f64),
68 String(&'ast str),
69}
70
71impl fmt::Display for Scalar<'_> {
72 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
73 match self {
74 Self::None => f.write_str("None"),
75 Self::Bool(value) => write!(f, "{value}"),
76 Self::Unsigned(value) => write!(f, "{value}"),
77 Self::Signed(value) => write!(f, "{value}"),
78 Self::Float(value) => write!(f, "{value:?}"),
79 Self::String(value) => write!(f, "{value:?}"),
80 }
81 }
82}
83
84macro_rules! define_visitor {
89 (
90 structs {
91 $($struct:ident => $visit_struct:ident, $walk_struct:ident { $($field:ident),* $(,)? })*
92 }
93 enums {
94 $($enum:ident => $visit_enum:ident, $walk_enum:ident {
95 $($variant:ident $(($($tuple:ident),+))? $({$($named:ident),+})?),* $(,)?
96 })*
97 }
98 ) => {
99 #[derive(Clone, Copy, Debug)]
101 pub enum AstNode<'ast> {
102 $($struct(&'ast $struct),)*
103 $($enum(&'ast $enum),)*
104 }
105
106 impl AstNode<'_> {
107 pub fn kind(self) -> &'static str {
109 match self {
110 $(Self::$struct(_) => stringify!($struct),)*
111 $(Self::$enum(node) => match node {
112 $($enum::$variant $(($($tuple),+))? $({$($named),+})? => {
113 $($(let _ = $tuple;)+)?
114 $($(let _ = $named;)+)?
115 concat!(stringify!($enum), "::", stringify!($variant))
116 },)*
117 },)*
118 }
119 }
120 }
121
122 pub trait Visitor<'ast> {
128 type Break;
129
130 fn enter_node(&mut self, _node: AstNode<'ast>) -> ControlFlow<Self::Break> {
131 ControlFlow::Continue(())
132 }
133
134 fn leave_node(&mut self, _node: AstNode<'ast>) -> ControlFlow<Self::Break> {
135 ControlFlow::Continue(())
136 }
137
138 fn enter_field(&mut self, _field: Field) -> ControlFlow<Self::Break> {
139 ControlFlow::Continue(())
140 }
141
142 fn leave_field(&mut self, _field: Field) -> ControlFlow<Self::Break> {
143 ControlFlow::Continue(())
144 }
145
146 fn enter_list(&mut self, _len: usize) -> ControlFlow<Self::Break> {
147 ControlFlow::Continue(())
148 }
149
150 fn leave_list(&mut self) -> ControlFlow<Self::Break> {
151 ControlFlow::Continue(())
152 }
153
154 fn visit_scalar(&mut self, _value: Scalar<'ast>) -> ControlFlow<Self::Break> {
155 ControlFlow::Continue(())
156 }
157
158 $(fn $visit_struct(&mut self, node: &'ast $struct) -> ControlFlow<Self::Break> {
159 $walk_struct(self, node)
160 })*
161
162 $(fn $visit_enum(&mut self, node: &'ast $enum) -> ControlFlow<Self::Break> {
163 $walk_enum(self, node)
164 })*
165 }
166
167 $(
168 #[doc = concat!("Walk every field of [`", stringify!($struct), "`] in declaration order.")]
169 pub fn $walk_struct<'ast, V: Visitor<'ast> + ?Sized>(
170 visitor: &mut V,
171 node: &'ast $struct,
172 ) -> ControlFlow<V::Break> {
173 let $struct { $($field),* } = node;
174 visitor.enter_node(AstNode::$struct(node))?;
175 $(walk_field(visitor, Field::Named(stringify!($field)), $field)?;)*
176 visitor.leave_node(AstNode::$struct(node))
177 }
178
179 impl Walk for $struct {
180 fn walk<'ast, V: Visitor<'ast> + ?Sized>(&'ast self, visitor: &mut V) -> ControlFlow<V::Break> {
181 visitor.$visit_struct(self)
182 }
183 }
184 )*
185
186 $(
187 #[doc = concat!("Walk every field of the active [`", stringify!($enum), "`] variant.")]
188 pub fn $walk_enum<'ast, V: Visitor<'ast> + ?Sized>(
189 visitor: &mut V,
190 node: &'ast $enum,
191 ) -> ControlFlow<V::Break> {
192 visitor.enter_node(AstNode::$enum(node))?;
193 match node {
194 $($enum::$variant $(($($tuple),+))? $({$($named),+})? => {
195 $($(walk_field(visitor, Field::Named(stringify!($tuple)), $tuple)?;)+)?
196 $($(walk_field(visitor, Field::Named(stringify!($named)), $named)?;)+)?
197 },)*
198 }
199 visitor.leave_node(AstNode::$enum(node))
200 }
201
202 impl Walk for $enum {
203 fn walk<'ast, V: Visitor<'ast> + ?Sized>(&'ast self, visitor: &mut V) -> ControlFlow<V::Break> {
204 visitor.$visit_enum(self)
205 }
206 }
207 )*
208 };
209}
210
211trait Walk {
212 fn walk<'ast, V: Visitor<'ast> + ?Sized>(&'ast self, visitor: &mut V) -> ControlFlow<V::Break>;
213}
214
215fn walk_field<'ast, V: Visitor<'ast> + ?Sized, T: Walk>(
216 visitor: &mut V,
217 field: Field,
218 value: &'ast T,
219) -> ControlFlow<V::Break> {
220 visitor.enter_field(field)?;
221 value.walk(visitor)?;
222 visitor.leave_field(field)
223}
224
225impl<T: Walk> Walk for Option<T> {
226 fn walk<'ast, V: Visitor<'ast> + ?Sized>(&'ast self, visitor: &mut V) -> ControlFlow<V::Break> {
227 match self {
228 Some(value) => value.walk(visitor),
229 None => visitor.visit_scalar(Scalar::None),
230 }
231 }
232}
233
234impl<T: Walk> Walk for Box<T> {
235 fn walk<'ast, V: Visitor<'ast> + ?Sized>(&'ast self, visitor: &mut V) -> ControlFlow<V::Break> {
236 self.as_ref().walk(visitor)
237 }
238}
239
240impl<T: Walk> Walk for Vec<T> {
241 fn walk<'ast, V: Visitor<'ast> + ?Sized>(&'ast self, visitor: &mut V) -> ControlFlow<V::Break> {
242 visitor.enter_list(self.len())?;
243 for (index, value) in self.iter().enumerate() {
244 walk_field(visitor, Field::Index(index), value)?;
245 }
246 visitor.leave_list()
247 }
248}
249
250impl Walk for (Identifier, Expr) {
251 fn walk<'ast, V: Visitor<'ast> + ?Sized>(&'ast self, visitor: &mut V) -> ControlFlow<V::Break> {
252 walk_field(visitor, Field::Named("key"), &self.0)?;
253 walk_field(visitor, Field::Named("value"), &self.1)
254 }
255}
256
257impl Walk for String {
258 fn walk<'ast, V: Visitor<'ast> + ?Sized>(&'ast self, visitor: &mut V) -> ControlFlow<V::Break> {
259 visitor.visit_scalar(Scalar::String(self))
260 }
261}
262
263macro_rules! scalar_walk {
264 ($($type:ty => $variant:ident $(as $cast:ty)?),* $(,)?) => {
265 $(impl Walk for $type {
266 fn walk<'ast, V: Visitor<'ast> + ?Sized>(&'ast self, visitor: &mut V) -> ControlFlow<V::Break> {
267 visitor.visit_scalar(Scalar::$variant(*self $(as $cast)?))
268 }
269 })*
270 };
271}
272
273scalar_walk! {
274 bool => Bool,
275 u8 => Unsigned as u64,
276 u64 => Unsigned,
277 usize => Unsigned as u64,
278 i64 => Signed,
279 f64 => Float,
280}
281
282define_visitor! {
283 structs {
284 Program => visit_program, walk_program { at_schema, definitions, statements }
285 GraphVariableDefinition => visit_graph_variable_definition, walk_graph_variable_definition { property_graph, name, typed, value_type, initializer }
286 BindingTableVariableDefinition => visit_binding_table_variable_definition, walk_binding_table_variable_definition { binding, name, typed, value_type, initializer }
287 ValueVariableDefinition => visit_value_variable_definition, walk_value_variable_definition { name, typed, value_type, initializer }
288 NextStatement => visit_next_statement, walk_next_statement { yield_clause, statement }
289 QueryStatement => visit_query_statement, walk_query_statement { at_schema, use_graph, body, set_operations }
290 QueryBody => visit_query_body, walk_query_body { clauses, result_clause, select_from, select_query, select_where, group_by, empty_grouping_set, having, order_by, offset, limit }
291 QuerySetOperation => visit_query_set_operation, walk_query_set_operation { operator, quantifier, body }
292 SelectGraphMatch => visit_select_graph_match, walk_select_graph_match { graph, match_clause }
293 SelectQuerySpecification => visit_select_query_specification, walk_select_query_specification { graph, query }
294 MatchClause => visit_match_clause, walk_match_clause { optional, mode, patterns, keep, where_clause, yield_clause }
295 FilterClause => visit_filter_clause, walk_filter_clause { predicate }
296 LetClause => visit_let_clause, walk_let_clause { items }
297 LetItem => visit_let_item, walk_let_item { name, typed, value_type, value }
298 ForClause => visit_for_clause, walk_for_clause { variable, source, ordinality_or_offset }
299 ForOrdinalityOrOffset => visit_for_ordinality_or_offset, walk_for_ordinality_or_offset { kind, variable }
300 CallClause => visit_call_clause, walk_call_clause { optional, call, yield_clause }
301 InlineProcedureCall => visit_inline_procedure_call, walk_inline_procedure_call { variable_scope, body }
302 OrderByPageClause => visit_order_by_page_clause, walk_order_by_page_clause { order_by, offset, limit }
303 CallStatement => visit_call_statement, walk_call_statement { call }
304 YieldClause => visit_yield_clause, walk_yield_clause { items }
305 ResultClause => visit_result_clause, walk_result_clause { kind, quantifier, distinct, items }
306 ResultItem => visit_result_item, walk_result_item { expr, alias }
307 OrderByItem => visit_order_by_item, walk_order_by_item { expr, direction, null_ordering }
308 InsertStatement => visit_insert_statement, walk_insert_statement { patterns }
309 DeleteStatement => visit_delete_statement, walk_delete_statement { detach, items }
310 SetStatement => visit_set_statement, walk_set_statement { items }
311 RemoveStatement => visit_remove_statement, walk_remove_statement { items }
312 SessionSetCommand => visit_session_set_command, walk_session_set_command { target }
313 SessionSetGraphParameter => visit_session_set_graph_parameter, walk_session_set_graph_parameter { property_graph, if_not_exists, name, typed, value_type, initializer }
314 SessionSetBindingTableParameter => visit_session_set_binding_table_parameter, walk_session_set_binding_table_parameter { binding, if_not_exists, name, typed, value_type, initializer }
315 SessionSetValueParameter => visit_session_set_value_parameter, walk_session_set_value_parameter { if_not_exists, name, typed, value_type, initializer }
316 SessionResetCommand => visit_session_reset_command, walk_session_reset_command { target }
317 SessionCloseCommand => visit_session_close_command, walk_session_close_command { }
318 CreateGraphStatement => visit_create_graph_statement, walk_create_graph_statement { if_not_exists, or_replace, property_graph, name, graph_type, source }
319 DropGraphStatement => visit_drop_graph_statement, walk_drop_graph_statement { if_exists, property_graph, name }
320 CreateGraphTypeStatement => visit_create_graph_type_statement, walk_create_graph_type_statement { if_not_exists, or_replace, property_graph, name, source }
321 DropGraphTypeStatement => visit_drop_graph_type_statement, walk_drop_graph_type_statement { if_exists, property_graph, name }
322 CreateSchemaStatement => visit_create_schema_statement, walk_create_schema_statement { if_not_exists, name }
323 DropSchemaStatement => visit_drop_schema_statement, walk_drop_schema_statement { if_exists, name }
324 StartTransactionStatement => visit_start_transaction_statement, walk_start_transaction_statement { access_mode, isolation_level }
325 CommitStatement => visit_commit_statement, walk_commit_statement { }
326 RollbackStatement => visit_rollback_statement, walk_rollback_statement { }
327 GraphName => visit_graph_name, walk_graph_name { absolute, current_schema, home_schema, parent_levels, parts }
328 BindingTableName => visit_binding_table_name, walk_binding_table_name { absolute, current_schema, home_schema, parent_levels, parts }
329 GraphTypeName => visit_graph_type_name, walk_graph_type_name { absolute, current_schema, home_schema, parent_levels, parts }
330 SchemaName => visit_schema_name, walk_schema_name { absolute, current_schema, home_schema, parent_levels, parts }
331 ProcedureName => visit_procedure_name, walk_procedure_name { absolute, current_schema, home_schema, parent_levels, parts }
332 PathPattern => visit_path_pattern, walk_path_pattern { variable, prefix, parenthesized, start, chains, factors, alternation, alternatives }
333 ParenthesizedPathPatternExpression => visit_parenthesized_path_pattern_expression, walk_parenthesized_path_pattern_expression { variable, prefix, pattern, where_clause, quantifier, questioned }
334 PathPatternTerm => visit_path_pattern_term, walk_path_pattern_term { start, chains, factors }
335 PathPatternChain => visit_path_pattern_chain, walk_path_pattern_chain { relationship, node }
336 NodePattern => visit_node_pattern, walk_node_pattern { variable, temporary, labels, label_expression, properties, where_clause, quantifier }
337 RelationshipPattern => visit_relationship_pattern, walk_relationship_pattern { direction, variable, temporary, labels, label_expression, properties, where_clause, quantifier }
338 GraphTypeBody => visit_graph_type_body, walk_graph_type_body { elements }
339 NodeTypeDefinition => visit_node_type_definition, walk_node_type_definition { name, labels, properties }
340 EdgeTypeDefinition => visit_edge_type_definition, walk_edge_type_definition { name, direction, labels, source, destination, properties }
341 PropertyTypeDefinition => visit_property_type_definition, walk_property_type_definition { name, value_type }
342 FieldType => visit_field_type, walk_field_type { name, value_type }
343 CaseWhenClause => visit_case_when_clause, walk_case_when_clause { condition, additional_operands, result }
344 MapLiteral => visit_map_literal, walk_map_literal { entries }
345 SqlIntervalQualifier => visit_sql_interval_qualifier, walk_sql_interval_qualifier { start, start_precision, end, end_precision }
346 Identifier => visit_identifier, walk_identifier { value }
347 }
348 enums {
349 BindingVariableDefinition => visit_binding_variable_definition, walk_binding_variable_definition {
350 Graph(value),
351 BindingTable(value),
352 Value(value),
353 }
354 Statement => visit_statement, walk_statement {
355 LinearCatalog(value),
356 Query(value),
357 Call(value),
358 Next(value),
359 Insert(value),
360 Delete(value),
361 Set(value),
362 Remove(value),
363 CreateGraph(value),
364 DropGraph(value),
365 CreateGraphType(value),
366 DropGraphType(value),
367 CreateSchema(value),
368 DropSchema(value),
369 SessionSet(value),
370 SessionReset(value),
371 SessionClose(value),
372 StartTransaction(value),
373 Commit(value),
374 Rollback(value),
375 }
376 QuerySetOperator => visit_query_set_operator, walk_query_set_operator {
377 Union,
378 Except,
379 Intersect,
380 Otherwise,
381 }
382 SetQuantifier => visit_set_quantifier, walk_set_quantifier {
383 Distinct,
384 All,
385 }
386 QueryClause => visit_query_clause, walk_query_clause {
387 UseGraph(value),
388 NestedQuery(value),
389 Match(value),
390 OptionalMatchBlock(value),
391 Filter(value),
392 Let(value),
393 For(value),
394 Call(value),
395 Insert(value),
396 Delete(value),
397 Set(value),
398 Remove(value),
399 OrderByPage(value),
400 }
401 MatchMode => visit_match_mode, walk_match_mode {
402 RepeatableElements { bindings },
403 DifferentEdges { bindings },
404 }
405 ForOrdinalityOrOffsetKind => visit_for_ordinality_or_offset_kind, walk_for_ordinality_or_offset_kind {
406 Ordinality,
407 Offset,
408 }
409 ProcedureCall => visit_procedure_call, walk_procedure_call {
410 Named { procedure, args },
411 Inline(value),
412 }
413 ProcedureReference => visit_procedure_reference, walk_procedure_reference {
414 Name(value),
415 Parameter(value),
416 }
417 YieldItem => visit_yield_item, walk_yield_item {
418 All,
419 Item { name, alias },
420 }
421 ResultKind => visit_result_kind, walk_result_kind {
422 Return,
423 Select,
424 Finish,
425 }
426 SortDirection => visit_sort_direction, walk_sort_direction {
427 Asc,
428 Desc,
429 }
430 NullOrdering => visit_null_ordering, walk_null_ordering {
431 First,
432 Last,
433 }
434 SetItem => visit_set_item, walk_set_item {
435 Property { target, value },
436 AllProperties { variable, properties },
437 Label { variable, label },
438 }
439 RemoveItem => visit_remove_item, walk_remove_item {
440 Property(value),
441 Label { variable, label },
442 }
443 SessionSetTarget => visit_session_set_target, walk_session_set_target {
444 Schema(value),
445 Graph(value),
446 TimeZone(value),
447 GraphParameter(value),
448 BindingTableParameter(value),
449 ValueParameter(value),
450 }
451 SessionResetTarget => visit_session_reset_target, walk_session_reset_target {
452 AllCharacteristics,
453 AllParameters,
454 Schema,
455 Graph,
456 TimeZone,
457 Parameter(value),
458 }
459 CreateGraphType => visit_create_graph_type, walk_create_graph_type {
460 Any { typed, property_graph },
461 Like(value),
462 Named { typed, name },
463 Nested { typed, property_graph, body },
464 }
465 CreateGraphTypeSource => visit_create_graph_type_source, walk_create_graph_type_source {
466 CopyOf(value),
467 CopyOfExternal(value),
468 Like(value),
469 Nested(value),
470 }
471 TransactionAccessMode => visit_transaction_access_mode, walk_transaction_access_mode {
472 ReadOnly,
473 ReadWrite,
474 }
475 IsolationLevel => visit_isolation_level, walk_isolation_level {
476 Serializable,
477 RepeatableRead,
478 ReadCommitted,
479 ReadUncommitted,
480 }
481 GraphExpression => visit_graph_expression, walk_graph_expression {
482 Variable(value),
483 Name(value),
484 Parameter(value),
485 CurrentGraph,
486 CurrentPropertyGraph,
487 HomeGraph,
488 HomePropertyGraph,
489 }
490 BindingTableExpression => visit_binding_table_expression, walk_binding_table_expression {
491 NestedQuery(value),
492 Variable(value),
493 Name(value),
494 Parameter(value),
495 }
496 GraphTypeReference => visit_graph_type_reference, walk_graph_type_reference {
497 Name(value),
498 Parameter(value),
499 }
500 SchemaReference => visit_schema_reference, walk_schema_reference {
501 Name(value),
502 Absolute(value),
503 Root,
504 Parent { levels, name },
505 Parameter(value),
506 CurrentSchema,
507 HomeSchema,
508 }
509 PathPatternFactor => visit_path_pattern_factor, walk_path_pattern_factor {
510 Node(value),
511 Relationship(value),
512 Parenthesized(value),
513 Alternation { alternation, alternatives },
514 }
515 PathPatternAlternation => visit_path_pattern_alternation, walk_path_pattern_alternation {
516 Union,
517 Multiset,
518 }
519 PathPatternPrefix => visit_path_pattern_prefix, walk_path_pattern_prefix {
520 Mode { mode, path_or_paths },
521 Search(value),
522 }
523 PathMode => visit_path_mode, walk_path_mode {
524 Walk,
525 Trail,
526 Simple,
527 Acyclic,
528 }
529 PathOrPaths => visit_path_or_paths, walk_path_or_paths {
530 Path,
531 Paths,
532 }
533 PathSearchPrefix => visit_path_search_prefix, walk_path_search_prefix {
534 All { mode, path_or_paths },
535 Any { count, mode, path_or_paths },
536 Shortest { mode, path_or_paths },
537 AllShortest { mode, path_or_paths },
538 AnyShortest { mode, path_or_paths },
539 CountedShortest { count, mode, path_or_paths },
540 CountedShortestGroup { count, mode, path_or_paths, groups },
541 }
542 UnsignedIntegerSpecification => visit_unsigned_integer_specification, walk_unsigned_integer_specification {
543 Literal(value),
544 Parameter(value),
545 }
546 Direction => visit_direction, walk_direction {
547 Left,
548 Right,
549 Undirected,
550 LeftOrUndirected,
551 UndirectedOrRight,
552 LeftOrRight,
553 Any,
554 }
555 LabelExpression => visit_label_expression, walk_label_expression {
556 Label(value),
557 Wildcard,
558 And(left, right),
559 Or(left, right),
560 Not(value),
561 Parenthesized(value),
562 }
563 PathPatternQuantifier => visit_path_pattern_quantifier, walk_path_pattern_quantifier {
564 ZeroOrMore,
565 OneOrMore,
566 Optional,
567 Fixed(value),
568 Range { min, max },
569 }
570 GraphTypeElement => visit_graph_type_element, walk_graph_type_element {
571 Node(value),
572 Edge(value),
573 }
574 ValueType => visit_value_type, walk_value_type {
575 Named { name, parameters },
576 CharacterString { kind, max_length },
577 Boolean { kind },
578 Temporal { kind },
579 ByteString { kind, min_length, max_length },
580 ExactNumeric { kind, signed, precision, scale },
581 ApproximateNumeric { kind, precision, scale },
582 List(value),
583 ListWithLength { element, max_length },
584 Array(value),
585 ArrayWithLength { element, max_length },
586 Path,
587 AnyRecord,
588 Record(value),
589 AnyDynamic,
590 PropertyValue,
591 DynamicUnion(value),
592 GraphReference { property_graph, body },
593 NodeReference { definition },
594 EdgeReference { definition },
595 BindingTable { binding, fields },
596 NotNull(value),
597 }
598 CharacterStringTypeKind => visit_character_string_type_kind, walk_character_string_type_kind {
599 String,
600 Varchar,
601 }
602 BooleanTypeKind => visit_boolean_type_kind, walk_boolean_type_kind {
603 Bool,
604 Boolean,
605 }
606 TemporalTypeKind => visit_temporal_type_kind, walk_temporal_type_kind {
607 ZonedDateTime,
608 LocalDateTime,
609 Date,
610 ZonedTime,
611 LocalTime,
612 Duration,
613 }
614 ByteStringTypeKind => visit_byte_string_type_kind, walk_byte_string_type_kind {
615 Bytes,
616 Binary,
617 Varbinary,
618 }
619 ExactNumericTypeKind => visit_exact_numeric_type_kind, walk_exact_numeric_type_kind {
620 Decimal,
621 Integer,
622 }
623 ApproximateNumericTypeKind => visit_approximate_numeric_type_kind, walk_approximate_numeric_type_kind {
624 Float,
625 Real,
626 Double,
627 }
628 Expr => visit_expr, walk_expr {
629 Identifier(value),
630 Property { base, key },
631 GraphReference { property_graph, graph },
632 BindingTableReference { binding, table },
633 Parameter(value),
634 Literal(value),
635 Unary { op, expr },
636 Binary { left, op, right },
637 Function { name, quantifier, args },
638 SubstringByLength { side, value, length },
639 Trim { specification, trim_character, value },
640 MultiTrim { specification, value, trim_characters },
641 TrimList { value, count },
642 Elements { path },
643 StringLength { unit, value },
644 Fold { upper, value },
645 Normalize { value, normal_form },
646 CurrentDate,
647 CurrentTime { precision },
648 CurrentTimestamp { precision },
649 CurrentUser,
650 DateTimeFunction { function, value },
651 LocalTime { precision },
652 LocalTimestamp { precision },
653 AbsoluteValue { expr },
654 DurationFunction { value },
655 DurationBetween { left, right },
656 NumericFunction { function, args },
657 Cast { expr, value_type },
658 ValueQuery { query },
659 Let { items, value },
660 IsTyped { expr, negated, value_type },
661 IsNull { expr, negated },
662 IsUnknown { expr, negated },
663 IsTruth { expr, negated, value },
664 PropertyExists { variable, property },
665 ElementId { variable },
666 Exists { patterns },
667 ExistsQuery { query },
668 ExistsMatch { matches },
669 Same { variables },
670 AllDifferent { variables },
671 SourceDestination { node, negated, kind, edge },
672 IsNormalized { expr, negated, normal_form },
673 IsDirected { variable, negated },
674 IsLabeled { variable, negated, label_expression },
675 Case { operand, when_clauses, else_expr },
676 Coalesce(value),
677 NullIf { left, right },
678 List(value),
679 TypedList { type_name, values },
680 Path(value),
681 Record { explicit, fields },
682 Map(value),
683 Wildcard,
684 }
685 TrimSpec => visit_trim_spec, walk_trim_spec {
686 Leading,
687 Trailing,
688 Both,
689 }
690 StringLengthUnit => visit_string_length_unit, walk_string_length_unit {
691 Characters,
692 Bytes,
693 }
694 SubstringSide => visit_substring_side, walk_substring_side {
695 Left,
696 Right,
697 }
698 NumericFunctionKind => visit_numeric_function_kind, walk_numeric_function_kind {
699 Mod,
700 Floor,
701 Ceil,
702 Sqrt,
703 Power,
704 Log,
705 Log10,
706 Ln,
707 Exp,
708 Sin,
709 Cos,
710 Tan,
711 Cot,
712 Sinh,
713 Cosh,
714 Tanh,
715 Asin,
716 Acos,
717 Atan,
718 Degrees,
719 Radians,
720 PathLength,
721 }
722 DateTimeFunctionKind => visit_date_time_function_kind, walk_date_time_function_kind {
723 Date,
724 ZonedTime,
725 ZonedDateTime,
726 LocalTime,
727 LocalDateTime,
728 }
729 ListValueTypeName => visit_list_value_type_name, walk_list_value_type_name {
730 List,
731 Array,
732 }
733 SourceDestinationKind => visit_source_destination_kind, walk_source_destination_kind {
734 Source,
735 Destination,
736 }
737 Literal => visit_literal, walk_literal {
738 Null,
739 Boolean(value),
740 Unknown,
741 Integer(value),
742 Decimal(value),
743 String(value),
744 Bytes(value),
745 Date(value),
746 Time(value),
747 DateTime(value),
748 Duration(value),
749 SqlInterval { value, qualifier },
750 }
751 UnaryOp => visit_unary_op, walk_unary_op {
752 Not,
753 Pos,
754 Neg,
755 }
756 BinaryOp => visit_binary_op, walk_binary_op {
757 Or,
758 Xor,
759 And,
760 Eq,
761 Neq,
762 Lt,
763 Le,
764 Gt,
765 Ge,
766 Concat,
767 Add,
768 Sub,
769 Mul,
770 Div,
771 }
772 }
773}