Skip to main content

AstTreePrinter

Struct AstTreePrinter 

Source
pub struct AstTreePrinter { /* private fields */ }
Expand description

A visitor that renders programs or individual AST subtrees.

Visit one or more roots, then consume the printer with Self::finish. Node order is deterministic and follows the visitor’s structural order.

use std::ops::ControlFlow;
use gql_parser::{AstTreePrinter, Expr};
use gql_parser::visit::Visitor;
let mut printer = AstTreePrinter::new();
let ControlFlow::Continue(()) = printer.visit_expr(&Expr::Wildcard);
assert_eq!(printer.finish(), "Expr::Wildcard\n");

Implementations§

Source§

impl AstTreePrinter

Source

pub fn new() -> Self

Source

pub fn finish(self) -> String

Finish rendering. An unused printer returns an empty string.

§Panics

Panics if entry/exit hooks were manually called without balancing them. Normal typed visit_* calls always balance the hooks.

Trait Implementations§

Source§

impl Debug for AstTreePrinter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AstTreePrinter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'ast> Visitor<'ast> for AstTreePrinter

Source§

type Break = !

Source§

fn enter_node(&mut self, node: AstNode<'ast>) -> ControlFlow<Self::Break>

Source§

fn leave_node(&mut self, _node: AstNode<'ast>) -> ControlFlow<Self::Break>

Source§

fn enter_field(&mut self, field: Field) -> ControlFlow<Self::Break>

Source§

fn leave_field(&mut self, _field: Field) -> ControlFlow<Self::Break>

Source§

fn enter_list(&mut self, len: usize) -> ControlFlow<Self::Break>

Source§

fn leave_list(&mut self) -> ControlFlow<Self::Break>

Source§

fn visit_scalar(&mut self, value: Scalar<'ast>) -> ControlFlow<Self::Break>

Source§

fn visit_program(&mut self, node: &'ast Program) -> ControlFlow<Self::Break>

Source§

fn visit_graph_variable_definition( &mut self, node: &'ast GraphVariableDefinition, ) -> ControlFlow<Self::Break>

Source§

fn visit_binding_table_variable_definition( &mut self, node: &'ast BindingTableVariableDefinition, ) -> ControlFlow<Self::Break>

Source§

fn visit_value_variable_definition( &mut self, node: &'ast ValueVariableDefinition, ) -> ControlFlow<Self::Break>

Source§

fn visit_next_statement( &mut self, node: &'ast NextStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_query_statement( &mut self, node: &'ast QueryStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_query_body( &mut self, node: &'ast QueryBody, ) -> ControlFlow<Self::Break>

Source§

fn visit_query_set_operation( &mut self, node: &'ast QuerySetOperation, ) -> ControlFlow<Self::Break>

Source§

fn visit_select_graph_match( &mut self, node: &'ast SelectGraphMatch, ) -> ControlFlow<Self::Break>

Source§

fn visit_select_query_specification( &mut self, node: &'ast SelectQuerySpecification, ) -> ControlFlow<Self::Break>

Source§

fn visit_match_clause( &mut self, node: &'ast MatchClause, ) -> ControlFlow<Self::Break>

Source§

fn visit_filter_clause( &mut self, node: &'ast FilterClause, ) -> ControlFlow<Self::Break>

Source§

fn visit_let_clause( &mut self, node: &'ast LetClause, ) -> ControlFlow<Self::Break>

Source§

fn visit_let_item(&mut self, node: &'ast LetItem) -> ControlFlow<Self::Break>

Source§

fn visit_for_clause( &mut self, node: &'ast ForClause, ) -> ControlFlow<Self::Break>

Source§

fn visit_for_ordinality_or_offset( &mut self, node: &'ast ForOrdinalityOrOffset, ) -> ControlFlow<Self::Break>

Source§

fn visit_call_clause( &mut self, node: &'ast CallClause, ) -> ControlFlow<Self::Break>

Source§

fn visit_inline_procedure_call( &mut self, node: &'ast InlineProcedureCall, ) -> ControlFlow<Self::Break>

Source§

fn visit_order_by_page_clause( &mut self, node: &'ast OrderByPageClause, ) -> ControlFlow<Self::Break>

Source§

fn visit_call_statement( &mut self, node: &'ast CallStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_yield_clause( &mut self, node: &'ast YieldClause, ) -> ControlFlow<Self::Break>

Source§

fn visit_result_clause( &mut self, node: &'ast ResultClause, ) -> ControlFlow<Self::Break>

Source§

fn visit_result_item( &mut self, node: &'ast ResultItem, ) -> ControlFlow<Self::Break>

Source§

fn visit_order_by_item( &mut self, node: &'ast OrderByItem, ) -> ControlFlow<Self::Break>

Source§

fn visit_insert_statement( &mut self, node: &'ast InsertStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_delete_statement( &mut self, node: &'ast DeleteStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_set_statement( &mut self, node: &'ast SetStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_remove_statement( &mut self, node: &'ast RemoveStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_session_set_command( &mut self, node: &'ast SessionSetCommand, ) -> ControlFlow<Self::Break>

Source§

fn visit_session_set_graph_parameter( &mut self, node: &'ast SessionSetGraphParameter, ) -> ControlFlow<Self::Break>

Source§

fn visit_session_set_binding_table_parameter( &mut self, node: &'ast SessionSetBindingTableParameter, ) -> ControlFlow<Self::Break>

Source§

fn visit_session_set_value_parameter( &mut self, node: &'ast SessionSetValueParameter, ) -> ControlFlow<Self::Break>

Source§

fn visit_session_reset_command( &mut self, node: &'ast SessionResetCommand, ) -> ControlFlow<Self::Break>

Source§

fn visit_session_close_command( &mut self, node: &'ast SessionCloseCommand, ) -> ControlFlow<Self::Break>

Source§

fn visit_create_graph_statement( &mut self, node: &'ast CreateGraphStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_drop_graph_statement( &mut self, node: &'ast DropGraphStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_create_graph_type_statement( &mut self, node: &'ast CreateGraphTypeStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_drop_graph_type_statement( &mut self, node: &'ast DropGraphTypeStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_create_schema_statement( &mut self, node: &'ast CreateSchemaStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_drop_schema_statement( &mut self, node: &'ast DropSchemaStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_start_transaction_statement( &mut self, node: &'ast StartTransactionStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_commit_statement( &mut self, node: &'ast CommitStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_rollback_statement( &mut self, node: &'ast RollbackStatement, ) -> ControlFlow<Self::Break>

Source§

fn visit_graph_name( &mut self, node: &'ast GraphName, ) -> ControlFlow<Self::Break>

Source§

fn visit_binding_table_name( &mut self, node: &'ast BindingTableName, ) -> ControlFlow<Self::Break>

Source§

fn visit_graph_type_name( &mut self, node: &'ast GraphTypeName, ) -> ControlFlow<Self::Break>

Source§

fn visit_schema_name( &mut self, node: &'ast SchemaName, ) -> ControlFlow<Self::Break>

Source§

fn visit_procedure_name( &mut self, node: &'ast ProcedureName, ) -> ControlFlow<Self::Break>

Source§

fn visit_path_pattern( &mut self, node: &'ast PathPattern, ) -> ControlFlow<Self::Break>

Source§

fn visit_parenthesized_path_pattern_expression( &mut self, node: &'ast ParenthesizedPathPatternExpression, ) -> ControlFlow<Self::Break>

Source§

fn visit_path_pattern_term( &mut self, node: &'ast PathPatternTerm, ) -> ControlFlow<Self::Break>

Source§

fn visit_path_pattern_chain( &mut self, node: &'ast PathPatternChain, ) -> ControlFlow<Self::Break>

Source§

fn visit_node_pattern( &mut self, node: &'ast NodePattern, ) -> ControlFlow<Self::Break>

Source§

fn visit_relationship_pattern( &mut self, node: &'ast RelationshipPattern, ) -> ControlFlow<Self::Break>

Source§

fn visit_graph_type_body( &mut self, node: &'ast GraphTypeBody, ) -> ControlFlow<Self::Break>

Source§

fn visit_node_type_definition( &mut self, node: &'ast NodeTypeDefinition, ) -> ControlFlow<Self::Break>

Source§

fn visit_edge_type_definition( &mut self, node: &'ast EdgeTypeDefinition, ) -> ControlFlow<Self::Break>

Source§

fn visit_property_type_definition( &mut self, node: &'ast PropertyTypeDefinition, ) -> ControlFlow<Self::Break>

Source§

fn visit_field_type( &mut self, node: &'ast FieldType, ) -> ControlFlow<Self::Break>

Source§

fn visit_case_when_clause( &mut self, node: &'ast CaseWhenClause, ) -> ControlFlow<Self::Break>

Source§

fn visit_map_literal( &mut self, node: &'ast MapLiteral, ) -> ControlFlow<Self::Break>

Source§

fn visit_sql_interval_qualifier( &mut self, node: &'ast SqlIntervalQualifier, ) -> ControlFlow<Self::Break>

Source§

fn visit_identifier( &mut self, node: &'ast Identifier, ) -> ControlFlow<Self::Break>

Source§

fn visit_binding_variable_definition( &mut self, node: &'ast BindingVariableDefinition, ) -> ControlFlow<Self::Break>

Source§

fn visit_statement(&mut self, node: &'ast Statement) -> ControlFlow<Self::Break>

Source§

fn visit_query_set_operator( &mut self, node: &'ast QuerySetOperator, ) -> ControlFlow<Self::Break>

Source§

fn visit_set_quantifier( &mut self, node: &'ast SetQuantifier, ) -> ControlFlow<Self::Break>

Source§

fn visit_query_clause( &mut self, node: &'ast QueryClause, ) -> ControlFlow<Self::Break>

Source§

fn visit_match_mode( &mut self, node: &'ast MatchMode, ) -> ControlFlow<Self::Break>

Source§

fn visit_for_ordinality_or_offset_kind( &mut self, node: &'ast ForOrdinalityOrOffsetKind, ) -> ControlFlow<Self::Break>

Source§

fn visit_procedure_call( &mut self, node: &'ast ProcedureCall, ) -> ControlFlow<Self::Break>

Source§

fn visit_procedure_reference( &mut self, node: &'ast ProcedureReference, ) -> ControlFlow<Self::Break>

Source§

fn visit_yield_item( &mut self, node: &'ast YieldItem, ) -> ControlFlow<Self::Break>

Source§

fn visit_result_kind( &mut self, node: &'ast ResultKind, ) -> ControlFlow<Self::Break>

Source§

fn visit_sort_direction( &mut self, node: &'ast SortDirection, ) -> ControlFlow<Self::Break>

Source§

fn visit_null_ordering( &mut self, node: &'ast NullOrdering, ) -> ControlFlow<Self::Break>

Source§

fn visit_set_item(&mut self, node: &'ast SetItem) -> ControlFlow<Self::Break>

Source§

fn visit_remove_item( &mut self, node: &'ast RemoveItem, ) -> ControlFlow<Self::Break>

Source§

fn visit_session_set_target( &mut self, node: &'ast SessionSetTarget, ) -> ControlFlow<Self::Break>

Source§

fn visit_session_reset_target( &mut self, node: &'ast SessionResetTarget, ) -> ControlFlow<Self::Break>

Source§

fn visit_create_graph_type( &mut self, node: &'ast CreateGraphType, ) -> ControlFlow<Self::Break>

Source§

fn visit_create_graph_type_source( &mut self, node: &'ast CreateGraphTypeSource, ) -> ControlFlow<Self::Break>

Source§

fn visit_transaction_access_mode( &mut self, node: &'ast TransactionAccessMode, ) -> ControlFlow<Self::Break>

Source§

fn visit_isolation_level( &mut self, node: &'ast IsolationLevel, ) -> ControlFlow<Self::Break>

Source§

fn visit_graph_expression( &mut self, node: &'ast GraphExpression, ) -> ControlFlow<Self::Break>

Source§

fn visit_binding_table_expression( &mut self, node: &'ast BindingTableExpression, ) -> ControlFlow<Self::Break>

Source§

fn visit_graph_type_reference( &mut self, node: &'ast GraphTypeReference, ) -> ControlFlow<Self::Break>

Source§

fn visit_schema_reference( &mut self, node: &'ast SchemaReference, ) -> ControlFlow<Self::Break>

Source§

fn visit_path_pattern_factor( &mut self, node: &'ast PathPatternFactor, ) -> ControlFlow<Self::Break>

Source§

fn visit_path_pattern_alternation( &mut self, node: &'ast PathPatternAlternation, ) -> ControlFlow<Self::Break>

Source§

fn visit_path_pattern_prefix( &mut self, node: &'ast PathPatternPrefix, ) -> ControlFlow<Self::Break>

Source§

fn visit_path_mode(&mut self, node: &'ast PathMode) -> ControlFlow<Self::Break>

Source§

fn visit_path_or_paths( &mut self, node: &'ast PathOrPaths, ) -> ControlFlow<Self::Break>

Source§

fn visit_path_search_prefix( &mut self, node: &'ast PathSearchPrefix, ) -> ControlFlow<Self::Break>

Source§

fn visit_unsigned_integer_specification( &mut self, node: &'ast UnsignedIntegerSpecification, ) -> ControlFlow<Self::Break>

Source§

fn visit_direction(&mut self, node: &'ast Direction) -> ControlFlow<Self::Break>

Source§

fn visit_label_expression( &mut self, node: &'ast LabelExpression, ) -> ControlFlow<Self::Break>

Source§

fn visit_path_pattern_quantifier( &mut self, node: &'ast PathPatternQuantifier, ) -> ControlFlow<Self::Break>

Source§

fn visit_graph_type_element( &mut self, node: &'ast GraphTypeElement, ) -> ControlFlow<Self::Break>

Source§

fn visit_value_type( &mut self, node: &'ast ValueType, ) -> ControlFlow<Self::Break>

Source§

fn visit_character_string_type_kind( &mut self, node: &'ast CharacterStringTypeKind, ) -> ControlFlow<Self::Break>

Source§

fn visit_boolean_type_kind( &mut self, node: &'ast BooleanTypeKind, ) -> ControlFlow<Self::Break>

Source§

fn visit_temporal_type_kind( &mut self, node: &'ast TemporalTypeKind, ) -> ControlFlow<Self::Break>

Source§

fn visit_byte_string_type_kind( &mut self, node: &'ast ByteStringTypeKind, ) -> ControlFlow<Self::Break>

Source§

fn visit_exact_numeric_type_kind( &mut self, node: &'ast ExactNumericTypeKind, ) -> ControlFlow<Self::Break>

Source§

fn visit_approximate_numeric_type_kind( &mut self, node: &'ast ApproximateNumericTypeKind, ) -> ControlFlow<Self::Break>

Source§

fn visit_expr(&mut self, node: &'ast Expr) -> ControlFlow<Self::Break>

Source§

fn visit_trim_spec(&mut self, node: &'ast TrimSpec) -> ControlFlow<Self::Break>

Source§

fn visit_string_length_unit( &mut self, node: &'ast StringLengthUnit, ) -> ControlFlow<Self::Break>

Source§

fn visit_substring_side( &mut self, node: &'ast SubstringSide, ) -> ControlFlow<Self::Break>

Source§

fn visit_numeric_function_kind( &mut self, node: &'ast NumericFunctionKind, ) -> ControlFlow<Self::Break>

Source§

fn visit_date_time_function_kind( &mut self, node: &'ast DateTimeFunctionKind, ) -> ControlFlow<Self::Break>

Source§

fn visit_list_value_type_name( &mut self, node: &'ast ListValueTypeName, ) -> ControlFlow<Self::Break>

Source§

fn visit_source_destination_kind( &mut self, node: &'ast SourceDestinationKind, ) -> ControlFlow<Self::Break>

Source§

fn visit_literal(&mut self, node: &'ast Literal) -> ControlFlow<Self::Break>

Source§

fn visit_unary_op(&mut self, node: &'ast UnaryOp) -> ControlFlow<Self::Break>

Source§

fn visit_binary_op(&mut self, node: &'ast BinaryOp) -> ControlFlow<Self::Break>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.