-
Notifications
You must be signed in to change notification settings - Fork 831
[Parser] Do not eagerly lex keywords #6541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
|
||
| std::optional<std::string_view> Lexer::takeKeyword() { | ||
| if (curr) { | ||
| return std::nullopt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this part? It reads as "if there is a current token, ignore it and return nullopt". Why is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This goes away at the end of the patch sequence, but it is required for correctness at these intermediate steps. Let's say the lexer reaches an integer and eagerly lexes it into a token stored in curr. That integer may be followed by a keyword, but takeKeyword() should fail until takeU32() (or similar) has been called first. Without this check, takeKeyword() would succeed even though the preceeding integer was never consumed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks. Which is the PR where I can see the final step where it goes away, to get an idea for the direction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Looks like this causes the spec tests to hang forever for some reason. Will investigate. |
45f9c5a to
d1df91c
Compare
e47dc44 to
b08c1d7
Compare
Lex them on demand instead to avoid wasted work.
b08c1d7 to
5fa865a
Compare

Lex them on demand instead to avoid wasted work.