Skip to content

Update the TextMate grammar for rzk v0.11.0 - #78

Merged
fizruk merged 3 commits into
mainfrom
syntax-v0.11.0
Jul 21, 2026
Merged

Update the TextMate grammar for rzk v0.11.0#78
fizruk merged 3 commits into
mainfrom
syntax-v0.11.0

Conversation

@fizruk

@fizruk fizruk commented Jul 21, 2026

Copy link
Copy Markdown
Member

This PR updates the TextMate grammar to the rzk v0.11.0 syntax. TextMate colouring is the fallback while the language server has not yet checked a file (and the baseline below the semantic tokens), so the new constructs should not appear as plain text.

Added highlighting:

  • the #data command: the command keyword colours as for #define, the declared name as a type, and the uses clause is supported;
  • match and into as control keywords, and the eliminator clause of a #data body;
  • the branch arrows / =>;
  • the lattice operations: sup / inf beside the other builtin functions, and / as operators.

Removed: the pattern for brace parameters {p : A | φ}, whose syntax rzk v0.11.0 removed (rzk-lang/rzk#304), and the bracketing of the old modal-type syntax <| m | A |>. This turned out to fix a mis-highlighting: a single-line block comment containing a colon, such as {- pretends to be #define foo : U := bar -}, matched the brace-parameter pattern and was coloured as a parameter list instead of a comment; the updated block-comments snapshot shows the fix.

With the modal-type bar gone, the tope of a paren-form shaped parameter (t : 2 | φ) now colours the way the brace form used to (a tope bar followed by the tope): the only bare | left inside a parameter is the shape separator, so the rule is unambiguous. Making that safe surfaced a latent bug, also fixed here: the parameter-region opener let its identifier part cross a closing paren, so a non-parameter group before a later colon (as in (xs : vec A (suc n)) : A) opened a region spanning to the next line and mis-coloured it. The identifier part now only crosses balanced paren groups (pair patterns of any nesting depth, via Oniguruma subexpression recursion).

Screenshots

Before semantic highlighting via Rzk language server:

Снимок экрана — 2026-07-21 в 15 31 51

With semantic highlighting:

Снимок экрана — 2026-07-21 в 15 32 10

fizruk added 3 commits July 21, 2026 13:59
Highlight the new syntax: the #data command (the declared name as a
type, with a uses clause as for #define), the match and into keywords
and the eliminator clause, the branch arrows (Unicode and ASCII), and
the lattice operations on cubes (sup, inf and their Unicode forms).

Drop the pattern for brace parameters, removed in rzk v0.11.0. This
also fixes a mis-highlighting: a single-line block comment containing
a colon matched the brace-parameter pattern and was coloured as a
parameter list instead of a comment (visible in the updated
block-comments snapshot).

The tope highlighting of paren-form shaped parameters is left to the
term rules on purpose: a dedicated tope-bar rule cannot be told apart
from the middle separator of a modal type <| m | A |>, and would
restyle modal types in parameter position.

New colorize assertions and a snapshot fixture cover #data, match
(including an into motive), and the lattice operators.
The bracketing rule dates from the first modal-syntax PR; the modal
syntax has since moved on (see #74), so the old spelling should not
read as highlighted syntax. The tags and let mod/mod keywords are
untouched.
With the modal-type bar dropped, the only bare | inside a paren
parameter is the shape separator, so the tope-bar rule from the
removed brace form is unambiguous and returns for (t : 2 | phi).

Making it safe surfaced a latent bug, fixed here: the parameter-region
opener let its identifier part cross a closing paren, so a
non-parameter group before a later colon, as in

  #define vhead (xs : vec A (suc n)) : A

opened a region at (suc n that spanned to the next line and
mis-coloured it (a match-branch bar read as a tope bar). The
identifier part now crosses only balanced paren groups, at any
nesting depth via Oniguruma subexpression recursion, which keeps
pair-pattern parameters like ( ( (a , b) , c) : A) styled.

Colorize assertions cover the shaped-param tope, a nested pair
pattern, and the non-spanning regression; the common fixture
snapshot is unchanged.
@fizruk
fizruk merged commit ceca97a into main Jul 21, 2026
1 check passed
@fizruk
fizruk deleted the syntax-v0.11.0 branch July 21, 2026 10:35
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.

1 participant