Expect a certain token name next, failing with a syntax error otherwise. The token is *not* read.
(self, name: str, *, expected: str)
| 132 | return True |
| 133 | |
| 134 | def expect(self, name: str, *, expected: str) -> Token: |
| 135 | """Expect a certain token name next, failing with a syntax error otherwise. |
| 136 | |
| 137 | The token is *not* read. |
| 138 | """ |
| 139 | if not self.check(name): |
| 140 | raise self.raise_syntax_error(f"Expected {expected}") |
| 141 | return self.read() |
| 142 | |
| 143 | def read(self) -> Token: |
| 144 | """Consume the next token and return it.""" |
no test coverage detected