MCPcopy Index your code
hub / github.com/python/cpython / handle_alt_normal

Method handle_alt_normal

Tools/peg_generator/pegen/c_generator.py:781–802  ·  view source on GitHub ↗
(self, node: Alt, is_gather: bool, rulename: str | None)

Source from the content-addressed store, hash-verified

779 self.print("_res = _PyPegen_dummy_name(p);")
780
781 def handle_alt_normal(self, node: Alt, is_gather: bool, rulename: str | None) -> None:
782 self.join_conditions(keyword="if", node=node)
783 self.print("{")
784 # We have parsed successfully all the conditions for the option.
785 with self.indent():
786 node_str = str(node).replace('"', '\\"')
787 self.print(
788 f'D(fprintf(stderr, "%*c+ {rulename}[%d-%d]: %s succeeded!\\n", p->level, \' \', _mark, p->mark, "{node_str}"));'
789 )
790 # Prepare to emit the rule action and do so
791 if node.action and "EXTRA" in node.action:
792 self._set_up_token_end_metadata_extraction()
793 if self.skip_actions:
794 self.emit_dummy_action()
795 elif node.action:
796 self.emit_action(node)
797 else:
798 self.emit_default_action(is_gather, node)
799
800 # As the current option has parsed correctly, do not continue with the rest.
801 self.print("goto done;")
802 self.print("}")
803
804 def handle_alt_loop(self, node: Alt, is_gather: bool, rulename: str | None) -> None:
805 # Condition of the main body of the alternative

Callers 1

visit_AltMethod · 0.95

Calls 9

join_conditionsMethod · 0.95
emit_dummy_actionMethod · 0.95
emit_actionMethod · 0.95
emit_default_actionMethod · 0.95
strFunction · 0.85
printMethod · 0.45
indentMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected