Tree-sitter grammars for Haskell-ecosystem file formats.
- tree-sitter-cabal:
.cabalpackage description files - tree-sitter-cabal-project:
cabal.projectand*.projectworkspace files - tree-sitter-ghc-core: GHC Core dumps (
-ddump-simpland the other Core passes) - tree-sitter-ghc-core-explain: GHC simplifier-explanation logs (
-ddump-rule-firings,-ddump-inlinings) - tree-sitter-ghc-stg: GHC STG dumps (
-ddump-stg-finaland the other STG passes) - tree-sitter-ghc-cmm: GHC Cmm dumps (
-ddump-cmmand the pipeline-stage passes) - tree-sitter-ghc-dump: container grammar that injects the per-IL grammars into multi-section dump files
The .cabal grammar was initially forked from magus/tree-sitter-cabal.
nix develop # enter dev shell (provides tree-sitter, just, etc.)All commands run across every grammar via the top-level justfile.
| Command | Description |
|---|---|
just |
Run every grammar's full suite (default) |
just test |
Per grammar: query compile, parse-corpus, inline tests, and the GHC dump matrix across every flake.nix ghcVersions GHC. Runs all suites to completion, then fails if any failed (heavy) |
just test --fast |
Same, but the GHC dump matrix uses only the default nixpkgs GHC (quick) |
just build |
Generate each parser and build its shared library |
just check |
Validate every grammar without building |
just fmt |
Format grammar files and the flake (prettier and nixfmt) |
just gen-corpus |
Build and parse the GHC dump-flag matrix as a TAP suite for the default GHC; set GEN_GHC=all for every ghcVersions GHC (needs a GHC compiler) |
just clean |
Remove build artifacts |
Per-grammar commands are available as just <name>::<cmd>, where <name> is
one of cabal, cabal-project, ghc-core, ghc-stg, ghc-cmm, ghc-dump.
The cabal grammars parse a corpus drawn from the cabal and haskell-language-server source trees.
The GHC grammars parse a harvested corpus of real dumps from the GHC test suite.
On top of that, gen-corpus compiles a handful of fixtures with GHC across a
matrix of dump and display flags.
-
just testruns the matrix once per version listed inflake.nixghcVersions, validating against several compilers. -
just test --fastand the CI pull-request gate restrict it to the one GHC in the pinned nixpkgs.
- Tree-sitter: Creating parsers
- Cabal: .cabal file reference
- Cabal: cabal.project reference
- GHC: dumping intermediate output
Disclaimer: co-produced with a coding agent.