| 133 | |
| 134 | |
| 135 | class 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 | |
| 158 | class Alt: |
no outgoing calls
no test coverage detected