| 147 | |
| 148 | @memoize |
| 149 | def rule(self) -> Optional[Rule]: |
| 150 | # rule: rulename flags? ":" alts NEWLINE INDENT more_alts DEDENT | rulename flags? ":" NEWLINE INDENT more_alts DEDENT | rulename flags? ":" alts NEWLINE |
| 151 | mark = self._mark() |
| 152 | if ( |
| 153 | (rulename := self.rulename()) |
| 154 | and |
| 155 | (flags := self.flags(),) |
| 156 | and |
| 157 | (literal := self.expect(":")) |
| 158 | and |
| 159 | (alts := self.alts()) |
| 160 | and |
| 161 | (_newline := self.expect('NEWLINE')) |
| 162 | and |
| 163 | (_indent := self.expect('INDENT')) |
| 164 | and |
| 165 | (more_alts := self.more_alts()) |
| 166 | and |
| 167 | (_dedent := self.expect('DEDENT')) |
| 168 | ): |
| 169 | return Rule ( rulename [0] , rulename [1] , Rhs ( alts . alts + more_alts . alts ) , flags = flags ) |
| 170 | self._reset(mark) |
| 171 | if ( |
| 172 | (rulename := self.rulename()) |
| 173 | and |
| 174 | (flags := self.flags(),) |
| 175 | and |
| 176 | (literal := self.expect(":")) |
| 177 | and |
| 178 | (_newline := self.expect('NEWLINE')) |
| 179 | and |
| 180 | (_indent := self.expect('INDENT')) |
| 181 | and |
| 182 | (more_alts := self.more_alts()) |
| 183 | and |
| 184 | (_dedent := self.expect('DEDENT')) |
| 185 | ): |
| 186 | return Rule ( rulename [0] , rulename [1] , more_alts , flags = flags ) |
| 187 | self._reset(mark) |
| 188 | if ( |
| 189 | (rulename := self.rulename()) |
| 190 | and |
| 191 | (flags := self.flags(),) |
| 192 | and |
| 193 | (literal := self.expect(":")) |
| 194 | and |
| 195 | (alts := self.alts()) |
| 196 | and |
| 197 | (_newline := self.expect('NEWLINE')) |
| 198 | ): |
| 199 | return Rule ( rulename [0] , rulename [1] , alts , flags = flags ) |
| 200 | self._reset(mark) |
| 201 | return None |
| 202 | |
| 203 | @memoize |
| 204 | def rulename(self) -> Optional[RuleName]: |