Fix types in pegen parser generator (GH-120720)

This commit is contained in:
yf-yang 2024-06-19 22:12:40 +08:00 committed by GitHub
parent eaaf6995a8
commit ace2045ea6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View File

@ -212,7 +212,7 @@ class CCallMakerVisitor(GrammarVisitor):
if node.can_be_inlined:
self.cache[node] = self.generate_call(node.alts[0].items[0])
else:
name = self.gen.artifical_rule_from_rhs(node)
name = self.gen.artificial_rule_from_rhs(node)
self.cache[node] = FunctionCall(
assigned_variable=f"{name}_var",
function=f"{name}_rule",
@ -331,7 +331,7 @@ class CCallMakerVisitor(GrammarVisitor):
def visit_Gather(self, node: Gather) -> FunctionCall:
if node in self.cache:
return self.cache[node]
name = self.gen.artifical_rule_from_gather(node)
name = self.gen.artificial_rule_from_gather(node)
self.cache[node] = FunctionCall(
assigned_variable=f"{name}_var",
function=f"{name}_rule",

View File

@ -167,7 +167,7 @@ class ParserGenerator:
self.keyword_counter += 1
return self.keyword_counter
def artifical_rule_from_rhs(self, rhs: Rhs) -> str:
def artificial_rule_from_rhs(self, rhs: Rhs) -> str:
self.counter += 1
name = f"_tmp_{self.counter}" # TODO: Pick a nicer name.
self.all_rules[name] = Rule(name, None, rhs)
@ -183,7 +183,7 @@ class ParserGenerator:
self.all_rules[name] = Rule(name, None, Rhs([Alt([NamedItem(None, node)])]))
return name
def artifical_rule_from_gather(self, node: Gather) -> str:
def artificial_rule_from_gather(self, node: Gather) -> str:
self.counter += 1
name = f"_gather_{self.counter}"
self.counter += 1

View File

@ -116,7 +116,7 @@ class PythonCallMakerVisitor(GrammarVisitor):
if len(node.alts) == 1 and len(node.alts[0].items) == 1:
self.cache[node] = self.visit(node.alts[0].items[0])
else:
name = self.gen.artifical_rule_from_rhs(node)
name = self.gen.artificial_rule_from_rhs(node)
self.cache[node] = name, f"self.{name}()"
return self.cache[node]
@ -168,7 +168,7 @@ class PythonCallMakerVisitor(GrammarVisitor):
def visit_Gather(self, node: Gather) -> Tuple[str, str]:
if node in self.cache:
return self.cache[node]
name = self.gen.artifical_rule_from_gather(node)
name = self.gen.artificial_rule_from_gather(node)
self.cache[node] = name, f"self.{name}()" # No trailing comma here either!
return self.cache[node]