The 'match' primitive of RD parsers. * Verifies that the current token is of the given kind (kind can be a tuple, in which the kind must match one of its members). * Returns the value of the current token * Reads in the next token
(self, kind)
| 376 | _id_kinds = (TokenKind.ConstructorId, TokenKind.TypeId) |
| 377 | |
| 378 | def _match(self, kind): |
| 379 | """The 'match' primitive of RD parsers. |
| 380 | |
| 381 | * Verifies that the current token is of the given kind (kind can |
| 382 | be a tuple, in which the kind must match one of its members). |
| 383 | * Returns the value of the current token |
| 384 | * Reads in the next token |
| 385 | """ |
| 386 | if (isinstance(kind, tuple) and self.cur_token.kind in kind or |
| 387 | self.cur_token.kind == kind |
| 388 | ): |
| 389 | value = self.cur_token.value |
| 390 | self._advance() |
| 391 | return value |
| 392 | else: |
| 393 | raise ASDLSyntaxError( |
| 394 | 'Unmatched {} (found {})'.format(kind, self.cur_token.kind), |
| 395 | self.cur_token.lineno) |
| 396 | |
| 397 | def _at_keyword(self, keyword): |
| 398 | return (self.cur_token.kind == TokenKind.TypeId and |
no test coverage detected