Module visitor

Module visitor 

Source
Expand description

AST visitor pattern for traversing logical expressions.

This module provides a visitor trait for walking the AST without mutation. It follows the standard visitor pattern with walk_* functions that handle recursive traversal and visit_* methods that can be overridden.

§Usage

Implement Visitor and override the visit_* methods you need:

struct VariableCollector {
    vars: Vec<Symbol>,
}

impl<'a> Visitor<'a> for VariableCollector {
    fn visit_term(&mut self, term: &'a Term<'a>) {
        if let Term::Variable(sym) = term {
            self.vars.push(*sym);
        }
        walk_term(self, term);
    }
}

Traits§

Visitor
Trait for visiting AST nodes.

Functions§

walk_expr
walk_np
walk_term