tree-sitter-clean
v1.2.5
Published
Clean grammar for tree-sitter
Maintainers
Readme
tree-sitter-clean
Clean grammar for tree-sitter.
Description
Clean is a general-purpose, purely functional programming language with uniqueness typing. This grammar supports:
- Module system (
module,import,from...import) - Type system (
::, algebraic data types, records, type classes) - Functions (named, guards,
where/withclauses) - Patterns (variables, constructors, wildcards, lists, tuples)
- Expressions (application, infix operators, let, case, lambda)
- Comprehensions (list comprehensions with generators, guards, let qualifiers)
- Records (construction, update, field access)
Coverage
The grammar is validated against the real-world Clean corpus
(clean-stdlib, Clyde, cloogle.org — 120 .icl + 119 .dcl files):
- 1833 ERROR nodes across the
.iclcorpus vs 5129 before the grammar overhaul (2.8× better), with the core stdlib (StdEnv, StdList, StdString, StdMaybe) at 0 errors - 13 ERROR nodes across the
.dclcorpus (down from 282) - 55/55 corpus tests, parse throughput ~1.3× the pre-overhaul parser
Known Gaps
Clean constructs the grammar does not (fully) parse yet are documented in GRAMMAR-GAPS.md, along with the approaches that were tried and rejected on the full corpus. Remaining gaps are confined to regions the reference parser also fails heavily; closing them is blocked by a tree-sitter generator action-table ceiling (see the doc).
Node Types
The grammar produces 189 named node types for precise AST analysis, including:
application— function/constructor call detectionfield_access— record field accesslist_comprehension— withgenerator,guard,let_qualifierrecord_expression/record_update— record manipulationwildcard—_patterntype_definition/type_signature/class_context— the type system
Usage
Rust
let mut parser = tree_sitter::Parser::new();
parser.set_language(&tree_sitter_clean::LANGUAGE.into())?;Add tree-sitter-clean to your Cargo.toml to use it as a dependency:
[dependencies]
tree-sitter-clean = "1.2"JavaScript
const Parser = require("tree-sitter");
const Clean = require("tree-sitter-clean");
const parser = new Parser();
parser.setLanguage(Clean);Python
import tree_sitter_cleanReferences
Releasing
See RELEASE.md for the verified procedure to publish to npm, PyPI, and crates.io.
