Skip to content

Commit 04899dd

Browse files
nixel2007claude
andcommitted
SDBL: accept {...} configuration blocks as BraceGroup
ANTLR's SDBLLexer.g4 routes brace contents to a hidden channel via BRACE_MODE; for a highlight-only parser we model them as a nested BraceGroup that re-uses the same fragment* rule, so queries embedding data-composition-system parameter blocks (a common pattern in 1C config modules) parse cleanly without error tokens. Added matching named LBrace/RBrace tokens and styleTags for BraceGroup (t.meta) and the braces themselves (t.brace). Added a regression test in sdbl-overlay.test.js. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent bdc9355 commit 04899dd

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ export const sdblLanguage = sdblParser.configure({
125125
"Parameter/Ampersand": t.modifier,
126126
// Punctuation
127127
"LParen RParen": t.paren,
128+
// `{...}` configuration blocks — tag the whole group as t.meta so a
129+
// theme can fade them; the braces themselves get the brace tag.
130+
"LBrace RBrace": t.brace,
131+
BraceGroup: t.meta,
128132
"AddOp MulOp": t.arithmeticOperator,
129133
CmpOp: t.compareOperator,
130134
Punct: t.punctuation,

src/sdbl.grammar

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ fragment {
3333
Number |
3434
StringLit |
3535
ParenGroup |
36+
BraceGroup |
3637
AddOp |
3738
MulOp |
3839
CmpOp |
@@ -41,6 +42,13 @@ fragment {
4142

4243
ParenGroup { LParen fragment* RParen }
4344

45+
// `{...}` blocks in SDBL carry data-composition-system parameters that the
46+
// 1C query engine consumes out-of-band; ANTLR routes their contents to a
47+
// hidden channel. For highlighting purposes we let them sit as a nested
48+
// group so the surrounding query keeps parsing cleanly and styleTags can
49+
// pick the whole group out as configuration metadata.
50+
BraceGroup { LBrace fragment* RBrace }
51+
4452
Parameter { Ampersand Identifier }
4553

4654
AddOp { Plus | Minus }
@@ -79,6 +87,8 @@ Punct { Comma | Semicolon | Colon | Dot | Hash }
7987
// with the upstream ANTLR token vocabulary.
8088
LParen { "(" }
8189
RParen { ")" }
90+
LBrace { "{" }
91+
RBrace { "}" }
8292
Comma { "," }
8393
Colon { ":" }
8494
Semicolon { ";" }

test/sdbl-overlay.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ describe("SDBL parser standalone", () => {
2626
const en = sdblLanguage.parse("SELECT TOP 10 FROM Справочник.Товары").toString()
2727
assert.equal(ru, en)
2828
})
29+
30+
it("parses `{...}` configuration blocks as a BraceGroup", () => {
31+
// 1C data-composition-system queries embed `{...}` blocks that the query
32+
// engine consumes out-of-band; we don't need to enforce their structure
33+
// but the parser must accept them without error tokens.
34+
const repr = sdblLanguage.parse(
35+
"ВЫБРАТЬ {Поле1, Поле2} ИЗ Справочник.Контрагенты"
36+
).toString()
37+
assert.match(repr, /BraceGroup\(LBrace[^)]*RBrace\)/)
38+
// No error markers anywhere in the tree.
39+
assert.doesNotMatch(repr, //)
40+
})
2941
})
3042

3143
describe("SDBL embedded inside BSL string literal via parseMixed", () => {

0 commit comments

Comments
 (0)