mirror of https://github.com/python/cpython
Fix types in pegen parser generator (GH-120720)
This commit is contained in:
parent
eaaf6995a8
commit
ace2045ea6
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
Loading…
Reference in New Issue