Skip to content

Commit

Permalink
Change visitor argument name to node.
Browse files Browse the repository at this point in the history
Signed-off-by: James Goppert <james.goppert@gmail.com>
  • Loading branch information
jgoppert committed Jan 17, 2025
1 parent 383c0a3 commit cd9aab8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
28 changes: 14 additions & 14 deletions src/s2_analysis/print_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ impl Visitor for PrintVisitor {
self.level -= 1;
}

fn enter_stored_definition(&mut self, _def: &mut ast::StoredDefinition) {
self.print("Stored Definition");
fn enter_stored_definition(&mut self, _node: &mut ast::StoredDefinition) {
self.print("Stored definition");
}

fn enter_class_definition(&mut self, def: &mut ast::ClassDefinition) {
if let ast::ClassSpecifier::Long { name, .. } = &def.specifier {
fn enter_class_definition(&mut self, node: &mut ast::ClassDefinition) {
if let ast::ClassSpecifier::Long { name, .. } = &node.specifier {
self.print(&format!("class {}", name));
}
}

fn exit_class_definition(&mut self, _def: &mut ast::ClassDefinition) {
fn exit_class_definition(&mut self, _node: &mut ast::ClassDefinition) {
println!("\n");
}

fn enter_expression(&mut self, def: &mut ast::Expression) {
match def {
fn enter_expression(&mut self, node: &mut ast::Expression) {
match node {
ast::Expression::Binary { op, .. } => {
self.print(&format!("{:?}", op));
}
Expand Down Expand Up @@ -79,8 +79,8 @@ impl Visitor for PrintVisitor {
}
}

fn enter_equation(&mut self, def: &mut ast::Equation) {
match def {
fn enter_equation(&mut self, node: &mut ast::Equation) {
match node {
ast::Equation::Connect { .. } => {
self.print("connect");
}
Expand All @@ -94,14 +94,14 @@ impl Visitor for PrintVisitor {
}
}

fn enter_component_declaration(&mut self, def: &mut ast::ComponentDeclaration) {
self.print(&format!("component: {}", def.declaration.name));
fn enter_component_declaration(&mut self, node: &mut ast::ComponentDeclaration) {
self.print(&format!("component: {}", node.declaration.name));
}

fn exit_component_reference(&mut self, def: &mut ast::ComponentReference) {
fn exit_component_reference(&mut self, node: &mut ast::ComponentReference) {
let mut s: String = "".to_string();
for (index, part) in def.parts.iter().enumerate() {
if index != 0 || def.local {
for (index, part) in node.parts.iter().enumerate() {
if index != 0 || node.local {
s += ".";
}
s += &part.name;
Expand Down
6 changes: 4 additions & 2 deletions src/s2_analysis/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ macro_rules! define_visitor_methods {
($($name:ident),*) => {
paste! {
$(
fn [<enter_ $name:snake>](&mut self, _def: &mut ast::$name) {}
fn [<exit_ $name:snake>](&mut self, _def: &mut ast::$name) {}
#[allow(unused_variables)]
fn [<enter_ $name:snake>](&mut self, node: &mut ast::$name) {}
#[allow(unused_variables)]
fn [<exit_ $name:snake>](&mut self, node: &mut ast::$name) {}
)*
}
};
Expand Down

0 comments on commit cd9aab8

Please sign in to comment.