Trait Visitor

trait Visitor

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.

Associated Types

type Output

The result of visiting an HIR.

type Err

An error that visiting an HIR might return.

Required Methods

fn finish(self: Self) -> Result<<Self as >::Output, <Self as >::Err>

All implementors of Visitor must provide a finish method, which yields the result of visiting the HIR or an error.

Provided Methods

fn start(self: &mut Self)

This method is called before beginning traversal of the HIR.

fn visit_pre(self: &mut Self, _hir: &Hir) -> Result<(), <Self as >::Err>

This method is called on an Hir before descending into child Hir nodes.

fn visit_post(self: &mut Self, _hir: &Hir) -> Result<(), <Self as >::Err>

This method is called on an Hir after descending all of its child Hir nodes.

fn visit_alternation_in(self: &mut Self) -> Result<(), <Self as >::Err>

This method is called between child nodes of an alternation.

fn visit_concat_in(self: &mut Self) -> Result<(), <Self as >::Err>

This method is called between child nodes of a concatenation.