# HoldFast editor syntax assets

Tree-sitter and TextMate color complete or incomplete source without a language
server. Pinned consumers qualify on Linux ARM64.
[Tree-sitter assets](https://github.com/symbiogenesis/HoldFast/tree/main/tools/editor/tree-sitter) ·
[TextMate extension](https://github.com/symbiogenesis/HoldFast/tree/main/tools/editor/textmate) ·
[Consumer pins](https://github.com/symbiogenesis/HoldFast/blob/main/THIRD-PARTY.md#independent-syntax-consumers)

The generator translates canonical Menhir productions, expands parameterized
lists and removes semantic actions. Explicit GLR conflicts model lexer
lookahead. Both editors derive keywords from the compiler lexer. The external
scanner handles nested block comments, arbitrary raw-string quote delimiters
and bounded interpolation nesting. Generated upstream C parser/runtime and
consumer packages stay outside tracked source.
[Canonical parser](../parser/) · [Generator](https://github.com/symbiogenesis/HoldFast/blob/main/tools/toolchain/highlight.py) ·
[External scanner](https://github.com/symbiogenesis/HoldFast/blob/main/tools/editor/tree-sitter/src/scanner.c)

## Use and regeneration

Load the TextMate directory as a local VS Code extension for `.hf` with
`source.holdfast`. Copy the ABI 15 Tree-sitter directory, build with the pinned
generator and load into a compatible consumer. The `queries/highlights.scm`
query classifies names, literals, keywords, comments and punctuation.

Run `python tools/run.py holdfast-highlight check` to verify generated bytes, or
`python tools/run.py holdfast-highlight generate` to explicitly refresh them after
changing canonical syntax. The repository `check` gate also rejects asset drift.
Check and qualification preserve authored source bytes.

## Executable qualification

Provision the exact consumers recorded in
[THIRD-PARTY.md](https://github.com/symbiogenesis/HoldFast/blob/main/THIRD-PARTY.md#independent-syntax-consumers) before
qualification. Keep their licenses and notices beside the external packages.
The Windows runner dispatches this invocation to WSL. Supply consumer paths as
seen from WSL.

```powershell
python tools/run.py holdfast-highlight qualify `
  --tree-sitter /path/to/tree-sitter `
  --textmate-package /path/to/vscode-textmate `
  --oniguruma-package /path/to/vscode-oniguruma `
  --node /usr/bin/node `
  --output out/highlight-qualification.json
```

On Linux, use `python3 tools/run.py` on one line. Reports must be regular `.json`
files under `out/`, distinct from consumer inputs. Check executable/package bytes
before use and again with source/asset bindings before atomic publication.
Reports bind grammar/query bytes, both generator modules, shared corpus, recovery
inventory, compiler lexer/grammar and canonical parser build receipt.

The [qualifier](https://github.com/symbiogenesis/HoldFast/blob/main/tools/toolchain/highlight_qualification.py) exercises the
authored examples and the versioned [surface corpus](https://github.com/symbiogenesis/HoldFast/blob/main/tools/toolchain/surface.py).
It independently rechecks the canonical parser's expected results, then checks
each projected Tree-sitter result against the frozen
[recovery dispositions](https://github.com/symbiogenesis/HoldFast/blob/main/tools/editor/recovery.json). The stock query engine
renders Unicode HTML whose decoded text must equal the exact source, and the
stock TextMate engine tokenizes every projected shared-corpus source. Independent
[fixtures](https://github.com/symbiogenesis/HoldFast/blob/main/tools/editor/fixtures.json) additionally assert token scopes for
nested comments, raw delimiters, escaped characters, dependent generic syntax,
Unicode, nested interpolation braces and lifetime apostrophes. Edit fixtures compare
complete incremental and fresh Tree-sitter trees, including byte ranges, for
valid changes, incomplete comments/generics/raw strings and repairs.
Nine [concise syntax fixtures](../../language/surface-grammar/#concise-syntax-refinements)
each remove a required token. Menhir refuses the incomplete source and
Tree-sitter exposes a recovery node. Reversing the edit on the same incremental
tree restores the full tree and ranges of a fresh parse. The mathematical
formatter also refuses each incomplete edit, preserves its bytes on disk, and
formats the repaired source to a stable layout with the authored spelling.
[Formatter cases](https://github.com/symbiogenesis/HoldFast/blob/main/tools/tests/test_holdfast_mathematical_authoring.py)

Resource bounds are 65,536 UTF-8 source bytes, two seconds per Tree-sitter parse,
60 seconds per consumer process and 100 milliseconds per TextMate line. Scanner
comment/interpolation nesting is limited to 256. Timeouts, changed consumers, unexpected recovery, stale assets and malformed
fixture outcomes fail qualification.

## Recovery and acceptance boundaries

The editor parser approximates lexical lookahead and omits compiler semantic
actions. Canonical positive cases parse without recovery. Some refused source
retains an editor tree, including
reserved words and retired `void` in name positions, declaration modifiers and
constant or proof-signature restrictions, constructor spellings, pattern grades
and binding shape, unsupported null spellings, bare typed locals, generic
applications before [operators outside the follow set](../../language/surface-grammar/#bindings-match-arms-and-generic-calls),
invalid comparison chains, raw-string layout, and malformed interpolation
expressions or specifiers.
The [recovery fixtures](https://github.com/symbiogenesis/HoldFast/blob/main/tools/editor/recovery.json) define those dispositions. Invalid
UTF-8 and compiler resource-limit cases retain their canonical refusals and are
outside the projected editor envelope.

Lexical highlighting deliberately tolerates malformed numeric separators and
escapes, and interpolation scanning does not validate expression punctuation,
nonempty format specifiers or line-break legality. Explicit negative neighbors
show these recovering as syntax coloring while the canonical lexer refuses them.
TextMate keeps an unfinished string/comment scope through the available text;
Tree-sitter instead exposes `ERROR` or missing nodes. Nested interpolation braces
and lifetime apostrophes are supported and independently checked. There are no
embedded foreign-language injections.

Every report states `semantic_acceptance: false`. The syntax-asset qualifier
checks coloring and syntax recovery. Separate compiler and assurance checks
establish semantic acceptance, proof validity, source correspondence and
artifact admission. [Tooling contract](../tooling-protocols/#syntax-grammars-and-highlighting)
