Skip to content

feat(lexers): add Quint and TLA+ lexers - #1493

Merged
alecthomas merged 1 commit into
alecthomas:masterfrom
martynovs:add-quint-tlaplus-lexers
Nov 16, 2026
Merged

alecthomas merged 1 commit into
alecthomas:masterfrom
martynovs:add-quint-tlaplus-lexers

Conversation

@martynovs

Copy link
Copy Markdown
Contributor

Adds lexers for two specification languages that currently have none:

  • Quint (*.qnt, alias quint)
  • TLA+ (*.tla, aliases tla and tlaplus), including PlusCal inside (* --algorithm ... *) blocks

Keyword sets follow the languages' VS Code grammars (quint-vscode, vscode-tlaplus); the rest is written from the language references. TLA+ handles nested (* *) comments, \h/\b/\o literals, \in-style operators, unicode operators, Module!Op references, and operator definitions. Quint handles /// doc comments, sum-type variants, and def/val/action/type declaration names.

Tests: lexers/testdata/quint.* and tlaplus.* (inputs written for this PR). go test ./lexers passes, and lexers_gen.go is regenerated.

The rules use plain pattern regexes (no words=), so the same XML also loads on Chroma v2; I checked it against v2.23.1 and v2.27.0 because Forgejo pins v2 and I built it with these lexers to confirm files and Markdown fences highlight.

🤖 Generated with Claude Code

Quint (*.qnt) and TLA+ (*.tla, aliases tla/tlaplus), including PlusCal
inside (* --algorithm ... *) blocks. Rules are plain patterns, so the XML
also loads on Chroma v2.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@alecthomas
alecthomas enabled auto-merge (squash) November 16, 2026 21:29
@alecthomas
alecthomas merged commit 937b54a into alecthomas:master Nov 16, 2026
4 checks passed
github-actions Bot pushed a commit that referenced this pull request Nov 17, 2026
Follow-up to #1493. The TLA+ lexer only knew the ASCII spellings plus
part of the Unicode set, so Unicode specs (as written by tools such as
[tlauc](https://github.com/tlaplus-community/tlauc)) lost highlighting
on the rest.

This covers every symbol in tlauc's `tla-unicode.csv`, which comes from
the TLA+ standard's ASCII-to-Unicode table:

- `≜` is now treated like `==`, so `Foo ≜ ...` and `M ≜ INSTANCE ...`
mark the defined name
- `⟨ ⟩` are punctuation like `<< >>`
- arrows and temporal operators: `→ ← ↦ ↝ □ ◇ ⇔ ⇸`
- turnstiles, dots and the rest: `⊢ ⊣ ⫤ ‖ ‥ … ‼ ⁇ ⁺ ∷ ≔ ⩴`, plus `∖`
- `ℕ ℤ ℝ` as builtins

New test `lexers/testdata/tlaplus/unicode.*` exercises them; a check
over its recorded output shows no non-ASCII symbol left as plain `Text`.
`go test ./lexers` passes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants