Skip to content

Commit f1423fe

Browse files
nixel2007claude
andcommitted
SDBL: unify &/name colouring of query parameters + accept keyword-shaped names
Two related fixes for query parameters like '&НачалоПериода': 1. Grammar — the old 'Parameter { Ampersand Identifier }' rule rejected any name that the @external specialize hook turned into a SDBL keyword (e.g. 'началопериода' matches BEGINOFPERIOD in FuncKw). Real configs use such names routinely. Replaced Identifier with an inlined 'sdblName' alternative that accepts Identifier OR any category-keyword term, so the specializer never breaks parameter parsing. 2. styleTags — previously Parameter/Ampersand was t.modifier and Parameter/Identifier was t.local(t.variableName), so '&Имя' rendered in two different theme colours. Now every possible leaf inside Parameter (Ampersand plus every category keyword that may appear as the name) shares t.special(t.variableName) so the parameter renders as one visual block — verified by inspecting the live demo's spans: both '&' and 'НачалоПериода' end up in the same ͼ class. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent dce8d47 commit f1423fe

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,15 @@ export const sdblLanguage = sdblParser.configure({
118118
Identifier: t.variableName,
119119
Number: t.number,
120120
StringLit: t.string,
121-
// Parameter references (&ИмяПараметра) — tagged as a typed local so
122-
// they stand out from regular identifiers; the `&` punctuation gets
123-
// the modifier tag so it renders together with the parameter name.
124-
"Parameter/Identifier": t.local(t.variableName),
125-
"Parameter/Ampersand": t.modifier,
121+
// Parameter references (&ИмяПараметра) — the `sdblName` rule is
122+
// inlined (lowercase), so its children sit directly under Parameter
123+
// in the tree. Both the `&` and every possible inner-leaf token
124+
// (Identifier *or* a category-keyword term that the specializer
125+
// produced for the name) get the same `t.special(t.variableName)`
126+
// tag so the parameter renders as one visual block. We enumerate the
127+
// keyword categories because @lezer/highlight resolves at the leaf
128+
// level and the global FuncKw / StmtKw / etc. tags would otherwise win.
129+
"Parameter/Ampersand Parameter/Identifier Parameter/StmtKw Parameter/OpKw Parameter/FuncKw Parameter/TypeKw Parameter/MdoKw Parameter/VtKw Parameter/FieldKw Parameter/BoolLit Parameter/NullLit Parameter/UndefinedLit": t.special(t.variableName),
126130
// Punctuation
127131
"LParen RParen": t.paren,
128132
// `{...}` configuration blocks — tag the whole group as t.meta so a

src/sdbl.grammar

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,17 @@ ParenGroup { LParen fragment* RParen }
4949
// pick the whole group out as configuration metadata.
5050
BraceGroup { LBrace fragment* RBrace }
5151

52-
Parameter { Ampersand Identifier }
52+
// Parameter name accepts any identifier-shaped token, including ones that
53+
// the @external specialize hook turns into category keywords (the most
54+
// common case is `&НачалоПериода` where `началопериода` matches the
55+
// BEGINOFPERIOD function name in the SDBL keyword table). Without this the
56+
// parser produces an error token where the keyword sits and the parameter
57+
// stops being recognised.
58+
Parameter { Ampersand sdblName }
59+
sdblName {
60+
Identifier | StmtKw | OpKw | FuncKw | TypeKw | MdoKw | VtKw | FieldKw |
61+
BoolLit | NullLit | UndefinedLit
62+
}
5363

5464
AddOp { Plus | Minus }
5565
MulOp { Mul | Quotient }

0 commit comments

Comments
 (0)