Tree-sitter grammar for the
***plain spec-driven language (Codeplain).
It powers .plain syntax highlighting in editors — it's the grammar behind the
plyn editor tooling (Zed, VS Code,
Cursor).
- Language scope:
source.plain - File extension:
.plain - Grammar id:
plain
***plain is a prose-heavy, line-oriented spec format: mostly free
natural-language text with a few special constructs.
- Concepts —
:concept_name:tokens. - Section headers —
***definitions***,***functional specs***,***test reqs***,***implementation reqs***, and (indented)***acceptance tests***. - Frontmatter — a
---…---block with keys likeimport,requires,description,required_concepts,exported_concepts. - Comments — lines starting with
>. - Bullets (
-), template expressions ({{ … }}), include directives, markdown links, and strings.
See test/sample.plain for a full example.
Editors normally consume this grammar through the relevant plyn extension, which references it by Git URL + commit. To work with it directly:
npm install
npx tree-sitter generate # regenerate src/parser.c from grammar.js
npx tree-sitter test # run the corpus tests in test/corpus/
npx tree-sitter parse test/sample.plain # print the parse tree for a file- The grammar source of truth is
grammar.js. After editing it you must runnpx tree-sitter generate—src/parser.c(andsrc/grammar.json,src/node-types.json) are committed and do not regenerate automatically. - Disambiguation is driven entirely by lexer token precedence (no external
scanner, no
conflicts). Place a new construct's token precedence correctly or it loses the longest-match race to the catch-alltexttoken. - New top-level section names and frontmatter keys are added to the
TOP_SECTION_NAMES/FRONTMATTER_KEYSconstants at the top ofgrammar.js. - Highlight queries live in
queries/highlights.scm; add an entry whenever you introduce a node that should be highlighted. Theinjections.scmandbrackets.scmqueries are intentionally empty placeholders. - Add a case to
test/corpus/for any grammar change and keepnpx tree-sitter testgreen.
MIT