-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
TokenId
to track parser progress (#10486)
## Summary This PR updates the parser progress mechanism to use a token id instead of the token kind and range. The ID is stored on the Parser and is incremented every time the `next_token` method is called. The old logic would lead to panic if there were multiple levels of indentation before the program ends when the lexer would emit `Dedent` tokens for the same range. This makes it seem that the parser isn't progressing. ## Test Plan Tested it with the following program which gets stuck on `dhruv/parser` because the parser isn't able to recover from the invalid mapping key pattern: ```py match subject: case {*key}: pass ``` The reason it's only failing for invalid programs is because otherwise the parsing logic (`parse_block`) would consume the `Dedent` token.
- Loading branch information
1 parent
23bea51
commit 1cf7954
Showing
2 changed files
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters