Skip to content

Commit af90e6d

Browse files
isatyamksAA-Turner
andauthored
Update Tools/peg_generator/pegen/grammar.py
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent b67b1aa commit af90e6d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Tools/peg_generator/pegen/grammar.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ class GrammarError(Exception):
1919
class GrammarVisitor:
2020
def visit(self, node: Any, *args: Any, **kwargs: Any) -> Any:
2121
"""Visit a node."""
22-
method = "visit_" + node.__class__.__name__
22+
node_cls = node.__class__.__name__
23+
method = f"visit_{node_cls}"
2324
if len(node.__class__.__name__) == 1:
24-
method = "visit_single_" + node.__class__.__name__
25+
method = f"visit_single_{node_cls}"
2526
elif len(node.__class__.__name__) > 1:
26-
method = "visit_multi_" + node.__class__.__name__
27+
method = f"visit_multi_{node_cls}"
2728
visitor = getattr(self, method, self.generic_visit)
2829
return visitor(node, *args, **kwargs)
2930

0 commit comments

Comments
 (0)