Skip to content

Commit

Permalink
Fix debug output in PEG parser generator (pythonGH-20308)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablogsal authored May 22, 2020
1 parent ae14583 commit b831129
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Tools/peg_generator/pegen/c_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def _handle_default_rule_body(self, node: Rule, rhs: Rhs, result_type: str) -> N
rhs, is_loop=False, is_gather=node.is_gather(), rulename=node.name,
)
if self.debug:
self.print('fprintf(stderr, "Fail at %d: {node.name}\\n", p->mark);')
self.print(f'fprintf(stderr, "Fail at %d: {node.name}\\n", p->mark);')
self.print("_res = NULL;")
self.print(" done:")
with self.indent():
Expand Down Expand Up @@ -613,15 +613,15 @@ def emit_default_action(self, is_gather: bool, node: Alt) -> None:
else:
if self.debug:
self.print(
f'fprintf(stderr, "Hit without action [%d:%d]: %s\\n", mark, p->mark, "{node}");'
f'fprintf(stderr, "Hit without action [%d:%d]: %s\\n", _mark, p->mark, "{node}");'
)
self.print(
f"_res = _PyPegen_dummy_name(p, {', '.join(self.local_variable_names)});"
)
else:
if self.debug:
self.print(
f'fprintf(stderr, "Hit with default action [%d:%d]: %s\\n", mark, p->mark, "{node}");'
f'fprintf(stderr, "Hit with default action [%d:%d]: %s\\n", _mark, p->mark, "{node}");'
)
self.print(f"_res = {self.local_variable_names[0]};")

Expand Down

0 comments on commit b831129

Please sign in to comment.