MCPcopy Create free account
hub / github.com/python/cpython / emit_action

Method emit_action

Tools/peg_generator/pegen/c_generator.py:739–753  ·  view source on GitHub ↗
(self, node: Alt, cleanup_code: str | None = None)

Source from the content-addressed store, hash-verified

737 self.print(")")
738
739 def emit_action(self, node: Alt, cleanup_code: str | None = None) -> None:
740 self.print(f"_res = {node.action};")
741
742 self.print("if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) {")
743 with self.indent():
744 self.print("p->error_indicator = 1;")
745 if cleanup_code:
746 self.print(cleanup_code)
747 self.add_return("NULL")
748 self.print("}")
749
750 if self.debug:
751 self.print(
752 f'D(fprintf(stderr, "Hit with action [%d-%d]: %s\\n", _mark, p->mark, "{node}"));'
753 )
754
755 def emit_default_action(self, is_gather: bool, node: Alt) -> None:
756 if len(self.local_variable_names) > 1:

Callers 2

handle_alt_normalMethod · 0.95
handle_alt_loopMethod · 0.95

Calls 3

add_returnMethod · 0.95
printMethod · 0.45
indentMethod · 0.45

Tested by

no test coverage detected