60 lines
3.0 KiB
Rust
60 lines
3.0 KiB
Rust
use full_moon::ast::*;
|
|
|
|
pub trait Visitor {
|
|
fn visit<'a>(&mut self, tree: Ast<'a>) {
|
|
let nodes = tree.nodes();
|
|
for stmt in nodes.stmts() {
|
|
self.visit_statement(stmt)
|
|
}
|
|
}
|
|
|
|
fn visit_statement<'a>(&mut self, stmt: &Stmt<'a>) {
|
|
match stmt {
|
|
Stmt::Assignment(assignment) => self.visit_assignment(assignment),
|
|
Stmt::Do(do_) => self.visit_do(do_),
|
|
Stmt::FunctionCall(function_call) => self.visit_function_call(function_call),
|
|
Stmt::FunctionDeclaration(function_declaration) => {
|
|
self.visit_function_declaration(function_declaration)
|
|
}
|
|
Stmt::GenericFor(generic_for) => self.visit_generic_for(generic_for),
|
|
Stmt::If(if_) => self.visit_if(if_),
|
|
Stmt::LocalAssignment(local_assignment) => {
|
|
self.visit_local_assignment(local_assignment)
|
|
}
|
|
Stmt::LocalFunction(local_function) => self.visit_local_function(local_function),
|
|
Stmt::NumericFor(numeric_for) => self.visit_numeric_for(numeric_for),
|
|
Stmt::Repeat(repeat) => self.visit_repeat(repeat),
|
|
Stmt::While(while_) => self.visit_while(while_),
|
|
// Stmt::CompoundAssignment(compound_assignment) => {
|
|
// self.visit_compound_assignment(compound_assignment)
|
|
// }
|
|
// Stmt::ExportedTypeDeclaration(exported_type_declaration) => {
|
|
// self.visit_exported_type_declaration(exported_type_declaration)
|
|
// }
|
|
// Stmt::TypeDeclaration(type_declaration) => {
|
|
// self.visit_type_declaration(type_declaration)
|
|
// }
|
|
Stmt::Goto(goto) => self.visit_goto(goto),
|
|
Stmt::Label(label) => self.visit_label(label),
|
|
_ => {}
|
|
};
|
|
}
|
|
|
|
fn visit_assignment<'a>(&mut self, assignment: &Assignment<'a>);
|
|
fn visit_do<'a>(&mut self, do_: &Do<'a>);
|
|
fn visit_function_call<'a>(&mut self, function_call: &FunctionCall<'a>);
|
|
fn visit_function_declaration<'a>(&mut self, function_declaration: &FunctionDeclaration<'a>);
|
|
fn visit_generic_for<'a>(&mut self, generic_for: &GenericFor<'a>);
|
|
fn visit_if<'a>(&mut self, if_: &If<'a>);
|
|
fn visit_local_assignment<'a>(&mut self, local_assignment: &LocalAssignment<'a>);
|
|
fn visit_local_function<'a>(&mut self, local_function: &LocalFunction<'a>);
|
|
fn visit_numeric_for<'a>(&mut self, numeric_for: &NumericFor<'a>);
|
|
fn visit_repeat<'a>(&mut self, repeat: &Repeat<'a>);
|
|
fn visit_while<'a>(&mut self, while_: &While<'a>);
|
|
// fn visit_compound_assignment<'a>(&mut self, compound_assignment: &CompoundAssignment<'a>);
|
|
// fn visit_exported_type_declaration<'a>(&mut self, exported_type_declaration: &ExportedTypeDeclaration<'a>);
|
|
// fn visit_type_declaration<'a>(&mut self, type_declaration: &TypeDeclaration<'a>);
|
|
fn visit_goto<'a>(&mut self, goto: &lua52::Goto<'a>);
|
|
fn visit_label<'a>(&mut self, label: &lua52::Label<'a>);
|
|
}
|