Repository navigation
feat: add edition directive support to the parser - #16
Merged
Merged
Conversation
Sam PR ReviewVerdict: The patch correctly adds edition support, updates lexer, AST, parser, and tests. No obvious bugs or security issues were found. Advisory review generated by Sam with Groq. It does not approve or block the pull request; |
Owner
Author
|
Applied in
Verification: 129 pass, 1 skip, 0 fail; typecheck clean. |
- tokenize `edition` as a keyword and track the Sam edition on the AST - default the program edition to "2026" when no directive is present - parse `edition "2026"` at the top of the file and reject unsupported editions with the supported list - reject edition directives that appear after another declaration - add parser tests for the default, valid, unsupported, and misplaced edition cases
- import Token types directly from `../lexer/tokens` in parser/types.ts - resolve the edition once in parse() instead of checking EDITION twice - add a test asserting the line and column of an edition directive that follows a flow
SammyBytes
force-pushed
the
feat/edition-support
branch
from
November 17, 2026 04:34
14dbc6d to
5f1d13b
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the
editiondirective to the Sam parser and records the language edition on the AST. Branched directly frommain.Behavior
editionis now a lexer keyword.ProgramNodeexposesedition: SamEdition."2026".edition "2026"at the top of the file sets the program edition."2099") fail with the supported list.editiondirective after another declaration fails with its line and column.Tests
In
packages/compiler/src/parser/index.test.ts:edition→ast.edition === "2026".edition "2026"at the top →ast.edition === "2026".edition "2099"→Unsupported edition '2099'.edition "2026"below aprovider→ position error (line 6, column 5).Verification
bun test: 128 pass, 1 skip, 0 failbun run typecheck: no errors