Fix debug output in PEG parser generator (GH-20308)

This commit is contained in:
Pablo Galindo 2020-05-22 02:48:09 +01:00 committed by GitHub
parent ae14583302
commit b831129123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -487,7 +487,7 @@ class CParserGenerator(ParserGenerator, GrammarVisitor):
rhs, is_loop=False, is_gather=node.is_gather(), rulename=node.name, rhs, is_loop=False, is_gather=node.is_gather(), rulename=node.name,
) )
if self.debug: 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("_res = NULL;")
self.print(" done:") self.print(" done:")
with self.indent(): with self.indent():
@ -613,7 +613,7 @@ class CParserGenerator(ParserGenerator, GrammarVisitor):
else: else:
if self.debug: if self.debug:
self.print( 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( self.print(
f"_res = _PyPegen_dummy_name(p, {', '.join(self.local_variable_names)});" f"_res = _PyPegen_dummy_name(p, {', '.join(self.local_variable_names)});"
@ -621,7 +621,7 @@ class CParserGenerator(ParserGenerator, GrammarVisitor):
else: else:
if self.debug: if self.debug:
self.print( 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]};") self.print(f"_res = {self.local_variable_names[0]};")