chiru 0.7.0

A parser generator similar to antlr4.
Documentation




use chiru::runtime::ast::{rule_context::RuleContext, ast_context::ASTContext};

use super::{{ grammar_name.0 }}_listener::{{grammar_name.2}}Listener;



pub trait {{grammar_name.2}}Walker {
  fn walk(&self, listener: &mut dyn {{grammar_name.2}}Listener, ast: &RuleContext) {
    listener.enter_every_rule(ast);
    listener.enter(ast);

    for child in ast.children.iter() {
      match child {
        ASTContext::Terminal(ctx) => {
          listener.enter_terminal(ctx);
          listener.exit_terminal(ctx);
        },
        ASTContext::Rule(ctx) => self.walk(listener, ctx),
        ASTContext::Error(ctx) => {
          listener.enter_errornode(ctx);
          listener.exit_errornode(ctx);
        },
      }
    }

    listener.exit(ast);
    listener.exit_every_rule(ast);
  }
}