Trait regex_syntax::hir::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, _hir: &Hir) -> Result<(), Self::Err> { ... }
fn visit_post(&mut self, _hir: &Hir) -> Result<(), Self::Err> { ... }
fn visit_alternation_in(&mut self) -> Result<(), Self::Err> { ... }
fn visit_concat_in(&mut self) -> Result<(), Self::Err> { ... }
}
Expand description
A trait for visiting the high-level IR (HIR) in depth first order.
The principle aim of this trait is to enable callers to perform case analysis on a high-level intermediate representation of a regular expression 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 HIR may be proportional to end user input.
Typical usage of this trait involves providing an implementation and then
running it using the visit
function.
Required Associated Types§
Required Methods§
Provided Methods§
sourcefn visit_pre(&mut self, _hir: &Hir) -> Result<(), Self::Err>
fn visit_pre(&mut self, _hir: &Hir) -> Result<(), Self::Err>
This method is called on an Hir
before descending into child Hir
nodes.
sourcefn visit_post(&mut self, _hir: &Hir) -> Result<(), Self::Err>
fn visit_post(&mut self, _hir: &Hir) -> Result<(), Self::Err>
This method is called on an Hir
after descending all of its child
Hir
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.