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

Class Alt

Tools/peg_generator/pegen/grammar.py:158–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156
157
158class Alt:
159 def __init__(self, items: list[NamedItem], *, icut: int = -1, action: str | None = None):
160 self.items = items
161 self.icut = icut
162 self.action = action
163
164 def __str__(self) -> str:
165 core = " ".join(str(item) for item in self.items)
166 if not SIMPLE_STR and self.action:
167 return f"{core} {{ {self.action} }}"
168 else:
169 return core
170
171 def __repr__(self) -> str:
172 args = [repr(self.items)]
173 if self.icut >= 0:
174 args.append(f"icut={self.icut}")
175 if self.action:
176 args.append(f"action={self.action!r}")
177 return f"Alt({', '.join(args)})"
178
179 def __iter__(self) -> Iterator[list[NamedItem]]:
180 yield self.items
181
182
183class NamedItem:

Callers 3

altMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected