tree-sitter-lmscript skill
Use tree-sitter-lmscript to parse outer .lms programs, locate _lmcode_ data block boundaries, and inject the companion lmscript_lmcode grammar.
Purpose
Parse LMScript statements, imports, packages, recover points, command literals, formatted strings, and queued _lmcode_ / data blocks with accurate byte ranges.
When to use it
Use tree-sitter-lmscript when building editor highlighting, code navigation, or static analysis tools for .lms files and their embedded _lmcode_ blocks.
Install
Use Node 24+, a C compiler, and tree-sitter-cli 0.27.1 installed in a private prefix, then run npm test.
Commands
npm install --prefix /tmp/lmscript-tree-sitter tree-sitter-cli@0.27.1
export TREE_SITTER=/tmp/lmscript-tree-sitter/node_modules/.bin/tree-sitter
npm test
node scripts/conformance.mjs
Inputs and outputs
- Input: .lms source files containing outer LMScript statements and queued _lmcode_ or _dsl_ blocks.
- Output: outer LMScript syntax tree with lmcode_body byte ranges ready for tree-sitter-lmcode or lmscript_lmcode injection.
- Manifest: MONO-PIN and corpus-manifest.json recording 119 verified .lms file hashes.
Safety rules
- Do not use tree-sitter-lmscript as a substitute for the authoritative lmscript type-checker or runtime.
- Reparse lmcode_body byte ranges with lmscript_lmcode (or tree-sitter-lmcode) and rebase node positions in the host tool.
- Keep f"..." body templates in the companion lmscript_lmcode parser rather than standalone tree-sitter-lmcode.
Worked examples
# Run live corpus verification when local mono and skills-scripts checkouts are present
export MONO_ROOT=/path/to/lmctl-mono
export SKILLS_ROOT=/path/to/skills-scripts
node scripts/conformance.mjs --live
Errors and exit codes
| Exit code | Stage | Result | Condition |
|---|---|---|---|
| 0 | parse / test | Exit 0 | Grammar generation, the generated-file freshness check and the corpus conformance cases all pass |
| 1 | conformance | Exit 1 | A corpus conformance case fails; the failing case is printed with a FAIL prefix |
| 1 | freshness | Exit 1 | Generated src/parser.c, grammar.json, or node-types.json differs from grammar.js after tree-sitter generate |
How to verify
export TREE_SITTER=/tmp/lmscript-tree-sitter/node_modules/.bin/tree-sitter
npm test