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

Class Opt

Tools/peg_generator/pegen/grammar.py:241–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239
240
241class Opt:
242 def __init__(self, node: Item):
243 self.node = node
244
245 def __str__(self) -> str:
246 s = str(self.node)
247 # TODO: Decide whether to use [X] or X? based on type of X
248 if " " in s:
249 return f"[{s}]"
250 else:
251 return f"{s}?"
252
253 def __repr__(self) -> str:
254 return f"Opt({self.node!r})"
255
256 def __iter__(self) -> Iterator[Item]:
257 yield self.node
258
259
260class Repeat:

Callers 1

itemMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected