Skip to content

Commit 427c696

Browse files
Fix debug output in PEG parser generator (GH-20308)
(cherry picked from commit b831129) Co-authored-by: Pablo Galindo <[email protected]>
1 parent 55c8923 commit 427c696

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Tools/peg_generator/pegen/c_generator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def _handle_default_rule_body(self, node: Rule, rhs: Rhs, result_type: str) -> N
487487
rhs, is_loop=False, is_gather=node.is_gather(), rulename=node.name,
488488
)
489489
if self.debug:
490-
self.print('fprintf(stderr, "Fail at %d: {node.name}\\n", p->mark);')
490+
self.print(f'fprintf(stderr, "Fail at %d: {node.name}\\n", p->mark);')
491491
self.print("_res = NULL;")
492492
self.print(" done:")
493493
with self.indent():
@@ -613,15 +613,15 @@ def emit_default_action(self, is_gather: bool, node: Alt) -> None:
613613
else:
614614
if self.debug:
615615
self.print(
616-
f'fprintf(stderr, "Hit without action [%d:%d]: %s\\n", mark, p->mark, "{node}");'
616+
f'fprintf(stderr, "Hit without action [%d:%d]: %s\\n", _mark, p->mark, "{node}");'
617617
)
618618
self.print(
619619
f"_res = _PyPegen_dummy_name(p, {', '.join(self.local_variable_names)});"
620620
)
621621
else:
622622
if self.debug:
623623
self.print(
624-
f'fprintf(stderr, "Hit with default action [%d:%d]: %s\\n", mark, p->mark, "{node}");'
624+
f'fprintf(stderr, "Hit with default action [%d:%d]: %s\\n", _mark, p->mark, "{node}");'
625625
)
626626
self.print(f"_res = {self.local_variable_names[0]};")
627627

0 commit comments

Comments
 (0)