Skip to content

Commit

Permalink
refactor: Remove unused GrammarVisitor::*_leave functions
Browse files Browse the repository at this point in the history
Easy to re-introduce once they're needed, otherwise it's just noise for
now.
  • Loading branch information
Xanewok committed Nov 15, 2023
1 parent 4db875b commit 7f9215b
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 28 deletions.
2 changes: 0 additions & 2 deletions crates/codegen/grammar/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ impl Into<GrammarElement> for PrecedenceParserDefinitionRef {

impl Visitable for GrammarElement {
fn accept_visitor<V: GrammarVisitor>(&self, visitor: &mut V) {
visitor.grammar_element_enter(self);
match self {
Self::ScannerDefinition(scanner) => scanner.accept_visitor(visitor),
Self::TriviaParserDefinition(trivia_parser) => trivia_parser.accept_visitor(visitor),
Expand All @@ -85,6 +84,5 @@ impl Visitable for GrammarElement {
precedence_parser.accept_visitor(visitor)
}
}
visitor.grammar_element_leave(self);
}
}
3 changes: 0 additions & 3 deletions crates/codegen/grammar/src/parser_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ impl Visitable for ParserDefinitionRef {
fn accept_visitor<V: GrammarVisitor>(&self, visitor: &mut V) {
visitor.parser_definition_enter(self);
self.node().accept_visitor(visitor);
visitor.parser_definition_leave(self);
}
}

Expand All @@ -32,7 +31,6 @@ impl Visitable for TriviaParserDefinitionRef {
fn accept_visitor<V: GrammarVisitor>(&self, visitor: &mut V) {
visitor.trivia_parser_definition_enter(self);
self.node().accept_visitor(visitor);
visitor.trivia_parser_definition_leave(self);
}
}

Expand Down Expand Up @@ -113,6 +111,5 @@ impl Visitable for ParserDefinitionNode {
| Self::ParserDefinition(_)
| Self::PrecedenceParserDefinition(_) => {}
}
visitor.parser_definition_node_leave(self);
}
}
2 changes: 0 additions & 2 deletions crates/codegen/grammar/src/precedence_parser_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ impl Visitable for PrecedenceParserDefinitionRef {
fn accept_visitor<V: GrammarVisitor>(&self, visitor: &mut V) {
visitor.precedence_parser_definition_enter(self);
self.node().accept_visitor(visitor);
visitor.precedence_parser_definition_leave(self);
}
}

Expand All @@ -34,7 +33,6 @@ impl Visitable for PrecedenceParserDefinitionNode {
fn accept_visitor<V: GrammarVisitor>(&self, visitor: &mut V) {
visitor.precedence_parser_definition_node_enter(self);
self.primary_expression.accept_visitor(visitor);
visitor.precedence_parser_definition_node_leave(self);
}
}

Expand Down
2 changes: 0 additions & 2 deletions crates/codegen/grammar/src/scanner_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ impl Visitable for ScannerDefinitionRef {
fn accept_visitor<V: GrammarVisitor>(&self, visitor: &mut V) {
visitor.scanner_definition_enter(self);
self.node().accept_visitor(visitor);
visitor.scanner_definition_leave(self);
}
}

Expand Down Expand Up @@ -64,6 +63,5 @@ impl Visitable for ScannerDefinitionNode {
| Self::Literal(_)
| Self::ScannerDefinition(_) => {}
}
visitor.scanner_definition_node_leave(self);
}
}
20 changes: 1 addition & 19 deletions crates/codegen/grammar/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,14 @@ pub trait GrammarVisitor {
fn grammar_enter(&mut self, _grammar: &Grammar) {}
fn grammar_leave(&mut self, _grammar: &Grammar) {}

fn grammar_element_enter(&mut self, _element: &GrammarElement) {}
fn grammar_element_leave(&mut self, _element: &GrammarElement) {}

fn scanner_definition_enter(&mut self, _scanner: &ScannerDefinitionRef) {}
fn scanner_definition_leave(&mut self, _scanner: &ScannerDefinitionRef) {}
fn trivia_parser_definition_enter(&mut self, _trivia_parser: &TriviaParserDefinitionRef) {}
fn trivia_parser_definition_leave(&mut self, _trivia_parser: &TriviaParserDefinitionRef) {}
fn parser_definition_enter(&mut self, _parser: &ParserDefinitionRef) {}
fn parser_definition_leave(&mut self, _parser: &ParserDefinitionRef) {}
fn precedence_parser_definition_enter(
&mut self,
_precedence_parser: &PrecedenceParserDefinitionRef,
) {
}
fn precedence_parser_definition_leave(
&mut self,
_precedence_parser: &PrecedenceParserDefinitionRef,
) {
}
fn precedence_parser_definition_enter(&mut self, _parser: &PrecedenceParserDefinitionRef) {}

fn scanner_definition_node_enter(&mut self, _node: &ScannerDefinitionNode) {}
fn scanner_definition_node_leave(&mut self, _node: &ScannerDefinitionNode) {}
fn parser_definition_node_enter(&mut self, _node: &ParserDefinitionNode) {}
fn parser_definition_node_leave(&mut self, _node: &ParserDefinitionNode) {}
fn precedence_parser_definition_node_enter(&mut self, _node: &PrecedenceParserDefinitionNode) {}
fn precedence_parser_definition_node_leave(&mut self, _node: &PrecedenceParserDefinitionNode) {}
}

pub trait Visitable {
Expand Down

0 comments on commit 7f9215b

Please sign in to comment.