(*kinds)
| 44 | |
| 45 | # noinspection PyShadowingNames |
| 46 | def expect(*kinds): |
| 47 | nonlocal cursor |
| 48 | assert kinds |
| 49 | if can_advance(): |
| 50 | token = tokens[cursor] |
| 51 | cursor += 1 |
| 52 | if token.kind in kinds: |
| 53 | return token |
| 54 | elif tokens: |
| 55 | token = tokens[-1]._replace( |
| 56 | start=tokens[-1].end + 0, |
| 57 | end=tokens[-1].end + 1, |
| 58 | ) |
| 59 | else: |
| 60 | token = None |
| 61 | if len(kinds) == 1: |
| 62 | suffix = kinds[0].to_name() |
| 63 | else: |
| 64 | suffix = ', '.join(kind.to_name() for kind in kinds[:-1]) |
| 65 | suffix += ' or ' + kinds[-1].to_name() |
| 66 | message = f'Expecting {suffix}' |
| 67 | raise NestedJSONSyntaxError(source, token, message) |
| 68 | |
| 69 | # noinspection PyShadowingNames |
| 70 | def parse_root(): |
no test coverage detected