Skip to main content

AstSerializer

Struct AstSerializer 

Source
pub struct AstSerializer<'a> { /* private fields */ }

Implementations§

Source§

impl AstSerializer<'_>

Source

pub fn format(node: &AstNode) -> String

Source

pub fn from_unit(unit: &CompilationUnit) -> String

Serializes a whole compilation unit back to Structured Text, POU by POU (header, variable blocks, body statements, closing keyword).

Source

pub fn format_nodes(nodes: &[AstNode]) -> String

Source

pub fn format_variable_block( variable_block: &VariableBlock, unit: &CompilationUnit, ) -> String

Trait Implementations§

Source§

impl AstVisitor for AstSerializer<'_>

Source§

fn visit(&mut self, node: &AstNode)

Visits this AstNode. The default implementation calls the walk method on the node and will eventually call the strongly typed visit method for the node (e.g. visit_assignment if the node is an AstStatement::Assignment). Read more
Source§

fn visit_compilation_unit(&mut self, unit: &CompilationUnit)

Visits a CompilationUnit node. Make sure to call walk on the CompilationUnit node to visit its children. Read more
Source§

fn visit_implementation(&mut self, implementation: &Implementation)

Visits an Implementation node. Make sure to call walk on the Implementation node to visit its children. Read more
Source§

fn visit_variable_block(&mut self, variable_block: &VariableBlock)

Visits a DataTypeDeclaration node. Make sure to call walk on the VariableBlock node to visit its children. Read more
Source§

fn visit_variable(&mut self, variable: &Variable)

Visits a Variable node. Make sure to call walk on the Variable node to visit its children. Read more
Source§

fn visit_config_variable(&mut self, _: &ConfigVariable)

Visits a ConfigVariable node. Make sure to call walk on the ConfigVariable node to visit its children. Read more
Source§

fn visit_interface(&mut self, _: &Interface)

Visits a Interface. Make sure to call walk on the Interface to visit its children. Read more
Source§

fn visit_property(&mut self, _: &PropertyBlock)

Visits a Property. Make sure to call walk on the PropertyBlock to visit its children.
Source§

fn visit_enum_element(&mut self, element: &AstNode)

Visits an enum element AstNode node. Make sure to call walk on the AstNode node to visit its children. Read more
Source§

fn visit_data_type_declaration( &mut self, data_type_declaration: &DataTypeDeclaration, )

Visits a DataTypeDeclaration node. Make sure to call walk on the DataTypeDeclaration node to visit its children. Read more
Source§

fn visit_user_type_declaration( &mut self, user_type_declaration: &UserTypeDeclaration, )

Visits a UserTypeDeclaration node. Make sure to call walk on the UserTypeDeclaration node to visit its children. Read more
Source§

fn visit_data_type(&mut self, data_type: &DataType)

Visits a UserTypeDeclaration node. Make sure to call walk on the DataType node to visit its children. Read more
Source§

fn visit_pou(&mut self, pou: &Pou)

Visits a Pou node. Make sure to call walk on the Pou node to visit its children. Read more
Source§

fn visit_empty_statement(&mut self, _stmt: &EmptyStatement, _node: &AstNode)

Visits an EmptyStatement node. Read more
Source§

fn visit_default_value(&mut self, _stmt: &DefaultValue, _node: &AstNode)

Visits a DefaultValue node. Read more
Source§

fn visit_literal(&mut self, stmt: &AstLiteral, _node: &AstNode)

Visits an AstLiteral node. Make sure to call walk on the AstLiteral node to visit its children. Read more
Source§

fn visit_multiplied_statement( &mut self, stmt: &MultipliedStatement, _node: &AstNode, )

Visits a MultipliedStatement node. Make sure to call walk on the MultipliedStatement node to visit its children. Read more
Source§

fn visit_reference_expr(&mut self, stmt: &ReferenceExpr, _node: &AstNode)

Visits a ReferenceExpr node. Make sure to call walk on the ReferenceExpr node to visit its children. Read more
Source§

fn visit_identifier(&mut self, stmt: &str, _node: &AstNode)

Visits an Identifier node. Make sure to call walk on the Identifier node to visit its children. Read more
Source§

fn visit_direct_access(&mut self, stmt: &DirectAccess, _node: &AstNode)

Visits a DirectAccess node. Make sure to call walk on the DirectAccess node to visit its children. Read more
Source§

fn visit_hardware_access(&mut self, stmt: &HardwareAccess, _node: &AstNode)

Visits a HardwareAccess node. Make sure to call walk on the HardwareAccess node to visit its children. Read more
Source§

fn visit_binary_expression(&mut self, stmt: &BinaryExpression, _node: &AstNode)

Visits a BinaryExpression node. Make sure to call walk on the BinaryExpression node to visit its children. Read more
Source§

fn visit_unary_expression(&mut self, stmt: &UnaryExpression, _node: &AstNode)

Visits a UnaryExpression node. Make sure to call walk on the UnaryExpression node to visit its children. Read more
Source§

fn visit_expression_list(&mut self, stmt: &Vec<AstNode>, _node: &AstNode)

Visits an ExpressionList node. Make sure to call walk on the Vec<AstNode> node to visit its children. Read more
Source§

fn visit_paren_expression(&mut self, inner: &AstNode, _node: &AstNode)

Visits a ParenExpression node. Make sure to call walk on the inner AstNode node to visit its children. Read more
Source§

fn visit_range_statement(&mut self, stmt: &RangeStatement, _node: &AstNode)

Visits a RangeStatement node. Make sure to call walk on the RangeStatement node to visit its children. Read more
Source§

fn visit_vla_range_statement(&mut self, _node: &AstNode)

Visits a VlaRangeStatement node. Read more
Source§

fn visit_assignment(&mut self, stmt: &Assignment, _node: &AstNode)

Visits an Assignment node. Make sure to call walk on the Assignment node to visit its children. Read more
Source§

fn visit_output_assignment(&mut self, stmt: &Assignment, _node: &AstNode)

Visits an OutputAssignment node. Make sure to call walk on the Assignment node to visit its children. Read more
Source§

fn visit_ref_assignment(&mut self, stmt: &Assignment, _node: &AstNode)

Visits an RefAssignment node. Make sure to call walk on the Assignment node to visit its children. Read more
Source§

fn visit_call_statement(&mut self, stmt: &CallStatement, _node: &AstNode)

Visits a CallStatement node. Make sure to call walk on the CallStatement node to visit its children. Read more
Source§

fn visit_control_statement( &mut self, stmt: &AstControlStatement, _node: &AstNode, )

Visits an AstControlStatement node. Make sure to call walk on the AstControlStatement node to visit its children. Read more
Source§

fn visit_case_condition(&mut self, child: &AstNode, _node: &AstNode)

Visits a CaseCondition node. Make sure to call walk on the child-AstNode node to visit its children. Read more
Source§

fn visit_exit_statement(&mut self, _node: &AstNode)

Visits an ExitStatement node. Read more
Source§

fn visit_continue_statement(&mut self, _node: &AstNode)

Visits a ContinueStatement node. Read more
Source§

fn visit_return_statement(&mut self, stmt: &ReturnStatement, _node: &AstNode)

Visits a ReturnStatement node. Make sure to call walk on the ReturnStatement node to visit its children. Read more
Source§

fn visit_jump_statement(&mut self, stmt: &JumpStatement, _node: &AstNode)

Visits a JumpStatement node. Make sure to call walk on the JumpStatement node to visit its children. Read more
Source§

fn visit_label_statement(&mut self, stmt: &LabelStatement, _node: &AstNode)

Visits a LabelStatement node. Read more
Source§

fn visit_allocation(&mut self, stmt: &Allocation, _node: &AstNode)

Visits an Allocation node Read more
Source§

fn visit_super(&mut self, _stmt: &AstStatement, _node: &AstNode)

Visits a Super node. Read more
Source§

fn visit_this(&mut self, _stmt: &AstStatement, _node: &AstNode)

Visits a This node. Read more
Source§

fn visit_statement_list(&mut self, stmts: &[AstNode])

Called when visiting a list of statements (e.g. implementation bodies, control flow branches). Override this to intercept statement-list processing.
Source§

fn visit_for_loop_statement(&mut self, stmt: &ForLoopStatement, _node: &AstNode)

Visits a ForLoop control statement. Read more
Source§

fn visit_while_loop_statement(&mut self, stmt: &LoopStatement, _node: &AstNode)

Visits a WhileLoop control statement. Make sure to call walk on the LoopStatement node to visit its children. Read more
Source§

fn visit_repeat_loop_statement(&mut self, stmt: &LoopStatement, _node: &AstNode)

Visits a RepeatLoop control statement. Make sure to call walk on the LoopStatement node to visit its children. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for AstSerializer<'a>

§

impl<'a> RefUnwindSafe for AstSerializer<'a>

§

impl<'a> Send for AstSerializer<'a>

§

impl<'a> Sync for AstSerializer<'a>

§

impl<'a> Unpin for AstSerializer<'a>

§

impl<'a> UnsafeUnpin for AstSerializer<'a>

§

impl<'a> UnwindSafe for AstSerializer<'a>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.