(self)
| 412 | |
| 413 | @memoize |
| 414 | def lookahead(self) -> Optional[LookaheadOrCut]: |
| 415 | # lookahead: '&' ~ atom | '!' ~ atom | '~' |
| 416 | mark = self._mark() |
| 417 | cut = False |
| 418 | if ( |
| 419 | (literal := self.expect('&')) |
| 420 | and |
| 421 | (cut := True) |
| 422 | and |
| 423 | (atom := self.atom()) |
| 424 | ): |
| 425 | return PositiveLookahead ( atom ) |
| 426 | self._reset(mark) |
| 427 | if cut: return None |
| 428 | cut = False |
| 429 | if ( |
| 430 | (literal := self.expect('!')) |
| 431 | and |
| 432 | (cut := True) |
| 433 | and |
| 434 | (atom := self.atom()) |
| 435 | ): |
| 436 | return NegativeLookahead ( atom ) |
| 437 | self._reset(mark) |
| 438 | if cut: return None |
| 439 | if ( |
| 440 | (literal := self.expect('~')) |
| 441 | ): |
| 442 | return Cut ( ) |
| 443 | self._reset(mark) |
| 444 | return None |
| 445 | |
| 446 | @memoize |
| 447 | def item(self) -> Optional[Item]: |
no test coverage detected