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

Class Rhs

Tools/peg_generator/pegen/grammar.py:135–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133
134
135class Rhs:
136 def __init__(self, alts: list[Alt]):
137 self.alts = alts
138
139 def __str__(self) -> str:
140 return " | ".join(str(alt) for alt in self.alts)
141
142 def __repr__(self) -> str:
143 return f"Rhs({self.alts!r})"
144
145 def __iter__(self) -> Iterator[list[Alt]]:
146 yield self.alts
147
148 @property
149 def can_be_inlined(self) -> bool:
150 if len(self.alts) != 1 or len(self.alts[0].items) != 1:
151 return False
152 # If the alternative has an action we cannot inline
153 if getattr(self.alts[0], "action", None) is not None:
154 return False
155 return True
156
157
158class Alt:

Callers 5

ruleMethod · 0.90
altsMethod · 0.90
more_altsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected