Skip to content

Conversation

tlively
Copy link
Member

@tlively tlively commented Apr 25, 2024

Lex them on demand instead to avoid wasted work.

@tlively tlively requested a review from kripken April 25, 2024 03:02
Copy link
Member Author

tlively commented Apr 25, 2024


std::optional<std::string_view> Lexer::takeKeyword() {
if (curr) {
return std::nullopt;
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tlively
Copy link
Member Author

tlively commented Apr 25, 2024

Looks like this causes the spec tests to hang forever for some reason. Will investigate.

@tlively tlively force-pushed the parser-no-tok-parens branch from 45f9c5a to d1df91c Compare April 26, 2024 00:03
@tlively tlively force-pushed the parser-no-tok-keyword branch 2 times, most recently from e47dc44 to b08c1d7 Compare April 26, 2024 01:34
Copy link
Member Author

tlively commented Apr 26, 2024

Merge activity

  • Apr 25, 11:47 PM EDT: @tlively started a stack merge that includes this pull request via Graphite.
  • Apr 25, 11:49 PM EDT: Graphite rebased this pull request as part of a merge.
  • Apr 26, 12:19 AM EDT: @tlively merged this pull request with Graphite.
Base automatically changed from parser-no-tok-parens to main April 26, 2024 03:48
Lex them on demand instead to avoid wasted work.
@tlively tlively force-pushed the parser-no-tok-keyword branch from b08c1d7 to 5fa865a Compare April 26, 2024 03:48
@tlively tlively merged commit eccf9f9 into main Apr 26, 2024
@tlively tlively deleted the parser-no-tok-keyword branch April 26, 2024 04:19
@gkdn gkdn mentioned this pull request Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants