Skip to content

Conversation

@mcy
Copy link
Member

@mcy mcy commented Nov 21, 2025

This PR contains various interdependent changes to the lexing framework:

  1. token.Punct is now token.Keyword, which indicates a hard keyword, i.e. a keyword that cannot be an identifier in the grammar.
  2. lexer.Lexer now distinguishes hard and soft keywords.
  3. Popular keywords (for, if, else, and operators like :=) are now available in the lexer.
  4. Newlines are always their own tokens in the lexer; they can be promoted to keywords with an impact on the grammar via a configurable callback, which can then be used to implement newline-terminated statements (like in Go).
  5. Various diagnostics and helpers from parser have been factored out into internal packages for re-use.

@mcy mcy requested a review from doriable November 21, 2025 22:59
@mcy mcy requested a review from doriable December 1, 2025 22:22
@mcy mcy enabled auto-merge (squash) December 1, 2025 22:36
@mcy mcy merged commit d833483 into main Dec 1, 2025
6 checks passed
@mcy mcy deleted the mcy/lexer-improvements branch December 1, 2025 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants