-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: allowlist instead of denylist
In this commit, instead of trying to whack-a-mole denying token sequences, being explicit about which tokens are allowed to follow one another is much more maintainable. It means that when you add new tokens to the language, you only need to think about where they are allowed to go, and otherwise it will error. It also makes it easier to prevent illegal syntax – there are edge cases in the "before" case here that an explicit allowlist solves. Attempting to parse "x2" still fails, but with a more cryptic error code: `runtime.boundsError{x:0, y:0, signed:true, code:0x0}`. Now we get a more helpful error message: `Unexpected token 'X' at the beginning of the sequence`. The same is true for other elements that start with "x" like "(x2)", which used to return a boundsError and now errors earlier in the parsing step.
- Loading branch information
Showing
2 changed files
with
34 additions
and
20 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