Trait regex_syntax::ast::visitor::Visitor
source · pub trait Visitor {
type Output;
type Err;
// Required method
fn finish(self) -> Result<Self::Output, Self::Err>;
// Provided methods
fn start(&mut self) { ... }
fn visit_pre(&mut self, _ast: &Ast) -> Result<(), Self::Err> { ... }
fn visit_post(&mut self, _ast: &Ast) -> Result<(), Self::Err> { ... }
fn visit_alternation_in(&mut self) -> Result<(), Self::Err> { ... }
fn visit_concat_in(&mut self) -> Result<(), Self::Err> { ... }
fn visit_class_set_item_pre(
&mut self,
_ast: &ClassSetItem,
) -> Result<(), Self::Err> { ... }
fn visit_class_set_item_post(
&mut self,
_ast: &ClassSetItem,
) -> Result<(), Self::Err> { ... }
fn visit_class_set_binary_op_pre(
&mut self,
_ast: &ClassSetBinaryOp,
) -> Result<(), Self::Err> { ... }
fn visit_class_set_binary_op_post(
&mut self,
_ast: &ClassSetBinaryOp,
) -> Result<(), Self::Err> { ... }
fn visit_class_set_binary_op_in(
&mut self,
_ast: &ClassSetBinaryOp,
) -> Result<(), Self::Err> { ... }
}
Expand description
A trait for visiting an abstract syntax tree (AST) in depth first order.
The principle aim of this trait is to enable callers to perform case analysis on an abstract syntax tree without necessarily using recursion. In particular, this permits callers to do case analysis with constant stack usage, which can be important since the size of an abstract syntax tree may be proportional to end user input.
Typical usage of this trait involves providing an implementation and then
running it using the visit
function.
Note that the abstract syntax tree for a regular expression is quite
complex. Unless you specifically need it, you might be able to use the much
simpler high-level intermediate representation and its
corresponding Visitor
trait instead.
Required Associated Types§
Required Methods§
Provided Methods§
sourcefn visit_pre(&mut self, _ast: &Ast) -> Result<(), Self::Err>
fn visit_pre(&mut self, _ast: &Ast) -> Result<(), Self::Err>
This method is called on an Ast
before descending into child Ast
nodes.
sourcefn visit_post(&mut self, _ast: &Ast) -> Result<(), Self::Err>
fn visit_post(&mut self, _ast: &Ast) -> Result<(), Self::Err>
This method is called on an Ast
after descending all of its child
Ast
nodes.
sourcefn visit_alternation_in(&mut self) -> Result<(), Self::Err>
fn visit_alternation_in(&mut self) -> Result<(), Self::Err>
This method is called between child nodes of an
Alternation
.
sourcefn visit_concat_in(&mut self) -> Result<(), Self::Err>
fn visit_concat_in(&mut self) -> Result<(), Self::Err>
This method is called between child nodes of a concatenation.
sourcefn visit_class_set_item_pre(
&mut self,
_ast: &ClassSetItem,
) -> Result<(), Self::Err>
fn visit_class_set_item_pre( &mut self, _ast: &ClassSetItem, ) -> Result<(), Self::Err>
This method is called on every ClassSetItem
before descending into child nodes.
sourcefn visit_class_set_item_post(
&mut self,
_ast: &ClassSetItem,
) -> Result<(), Self::Err>
fn visit_class_set_item_post( &mut self, _ast: &ClassSetItem, ) -> Result<(), Self::Err>
This method is called on every ClassSetItem
after descending into child nodes.
sourcefn visit_class_set_binary_op_pre(
&mut self,
_ast: &ClassSetBinaryOp,
) -> Result<(), Self::Err>
fn visit_class_set_binary_op_pre( &mut self, _ast: &ClassSetBinaryOp, ) -> Result<(), Self::Err>
This method is called on every
ClassSetBinaryOp
before descending into
child nodes.
sourcefn visit_class_set_binary_op_post(
&mut self,
_ast: &ClassSetBinaryOp,
) -> Result<(), Self::Err>
fn visit_class_set_binary_op_post( &mut self, _ast: &ClassSetBinaryOp, ) -> Result<(), Self::Err>
This method is called on every
ClassSetBinaryOp
after descending into child
nodes.
sourcefn visit_class_set_binary_op_in(
&mut self,
_ast: &ClassSetBinaryOp,
) -> Result<(), Self::Err>
fn visit_class_set_binary_op_in( &mut self, _ast: &ClassSetBinaryOp, ) -> Result<(), Self::Err>
This method is called between the left hand and right hand child nodes
of a ClassSetBinaryOp
.