Add tree-sitter-fe grammar to monorepo#1264
Merged
micahscopes merged 9 commits intoargotorg:masterfrom Feb 21, 2026
Merged
Conversation
Consolidates the tree-sitter grammar (previously in a separate repo) into the main Fe repository for easier maintenance and testing.
Move tree-sitter-fe grammar into crates/ as a workspace member. Add dir-test driven integration tests to the parser crate that parse all existing .fe fixtures (syntax nodes, formatter, core/std ingots) with tree-sitter and assert no ERROR nodes. Fix unsafe extern block for edition 2024 compatibility. 92 of 117 fixtures pass; failures are expected on files using ref/own/mut syntax not yet supported by the grammar.
Grammar fixes:
- Add labeled parameter support (from sender: address)
- Add mode_type (ref/mut/own type prefixes) and mode_expression
- Add mode prefix in call_arg for (mut x) arguments
- Extend scoped_path with generic args on path segments (Foo<T>::method)
- Fix nested record/path_tuple patterns in record_pattern_field
- Add pattern bindings in recv_arm_pattern
- Fix scanner < disambiguation: track paren/bracket/brace depth,
reject ||/&&/=>/.. as generic markers, handle << for nested
qualified paths, distinguish { block bodies from {expr} const generics
Build system:
- Auto-run tree-sitter generate when grammar.js is newer than parser.c
- Always optimize parser.c at -O2 (96K-line state machine is unusable
at -O0 in debug builds)
Tests:
- Split into strict test (110 files, must be 100%) and coverage test
(363 files, regression threshold at 83%)
- Coverage spans syntax_node, fmt, core/std ingots, fe_test, cli_output,
and all uitest fixture suites
- Exclude intentionally broken files (parse_error.fe) and standalone
pattern fragments (pats/)
- Support combined receiver modes (`mut own self`, `mut ref self`)
- Make mode expressions bare prefix operators instead of requiring parens
- Add mut_pattern for mutable bindings in patterns (`Some(mut t)`)
- Support qualified paths in recv arm patterns and record pattern fields
- Add attribute call expressions (`#[selector = sol("...")]`)
- Support generic args in uses clauses (`uses Storage<T>`) and with params
- Remove redundant mode-prefixed call_arg variant (handled by mode_expression)
Raises coverage test pass rate from 87% to threshold-passing levels.
Strict test (110 files) still passes at 100%.
Unary + is a real Fe operator (prefix binding power 145 in the native parser). Naively adding it conflicted with + as the type bound separator in where clauses — tree-sitter preferred unary + over continuing the bound list. Fix: make type_bound_list explicitly left-recursive with prec.right(UNARY+1) so the + continuation always wins over the unary interpretation. Both `+expr` and `T: A + B + C` now parse correctly.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b285d3c31
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
2 tasks
The scanner stopped searching for a matching '>' after 256 characters, causing valid generic argument lists longer than that to be mistokenized as COMPARISON_LT. Remove the cap so disambiguation runs to completion.
Collapses parser.c, grammar.json, and node-types.json in GitHub diffs.
Use println! for cargo:warning= directives in build.rs (Cargo reads build script directives from stdout, not stderr). Allow print_stderr clippy lint in tree-sitter parse test file for progress output.
Collaborator
Author
|
@g-r-a-n-t this should be ready for review now |
g-r-a-n-t
approved these changes
Feb 21, 2026
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
crates/tree-sitter-fe, consolidated from the standalone repo for easier co-maintenance with the compilerscanner.c) for<disambiguation (generics vs comparison), automatic semicolons, and method chainingcrates/parserthat parse all.fefixtures with tree-sitter: a strict suite (110 files, 100% pass) and a coverage regression suite (363 files)Test plan
cargo test -p parserpasses (tree-sitter fixture parse tests)cargo build -p tree-sitter-fesucceedscrates/tree-sitter-fepath