| 445 | |
| 446 | @memoize |
| 447 | def item(self) -> Optional[Item]: |
| 448 | # item: '[' ~ alts ']' | atom '?' | atom '*' | atom '+' | atom '.' atom '+' | atom |
| 449 | mark = self._mark() |
| 450 | cut = False |
| 451 | if ( |
| 452 | (literal := self.expect('[')) |
| 453 | and |
| 454 | (cut := True) |
| 455 | and |
| 456 | (alts := self.alts()) |
| 457 | and |
| 458 | (literal_1 := self.expect(']')) |
| 459 | ): |
| 460 | return Opt ( alts ) |
| 461 | self._reset(mark) |
| 462 | if cut: return None |
| 463 | if ( |
| 464 | (atom := self.atom()) |
| 465 | and |
| 466 | (literal := self.expect('?')) |
| 467 | ): |
| 468 | return Opt ( atom ) |
| 469 | self._reset(mark) |
| 470 | if ( |
| 471 | (atom := self.atom()) |
| 472 | and |
| 473 | (literal := self.expect('*')) |
| 474 | ): |
| 475 | return Repeat0 ( atom ) |
| 476 | self._reset(mark) |
| 477 | if ( |
| 478 | (atom := self.atom()) |
| 479 | and |
| 480 | (literal := self.expect('+')) |
| 481 | ): |
| 482 | return Repeat1 ( atom ) |
| 483 | self._reset(mark) |
| 484 | if ( |
| 485 | (sep := self.atom()) |
| 486 | and |
| 487 | (literal := self.expect('.')) |
| 488 | and |
| 489 | (node := self.atom()) |
| 490 | and |
| 491 | (literal_1 := self.expect('+')) |
| 492 | ): |
| 493 | return Gather ( sep , node ) |
| 494 | self._reset(mark) |
| 495 | if ( |
| 496 | (atom := self.atom()) |
| 497 | ): |
| 498 | return atom |
| 499 | self._reset(mark) |
| 500 | return None |
| 501 | |
| 502 | @memoize |
| 503 | def atom(self) -> Optional[Plain]: |