@@ -32,24 +32,24 @@ ModuleAnnotation {
3232 PreprocNativeDirective
3333}
3434
35- PreprocUseDirective { "#" PreprocUse useTarget }
35+ PreprocUseDirective { Hash PreprocUse useTarget }
3636useTarget { String | Identifier }
37- PreprocNativeDirective { "#" PreprocNative }
37+ PreprocNativeDirective { Hash PreprocNative }
3838
3939// ---- Compiler directives & annotations ----
4040
4141Annotation {
42- "&" AnnotationName AnnotationParams?
42+ Ampersand AnnotationName AnnotationParams?
4343}
4444
4545AnnotationName { Identifier }
4646
4747AnnotationParams {
48- "(" (AnnotationParam ("," AnnotationParam)*)? ")"
48+ LParen (AnnotationParam (Comma AnnotationParam)*)? RParen
4949}
5050
5151AnnotationParam {
52- AnnotationParamName ("=" annotationValue)? |
52+ AnnotationParamName (Assign annotationValue)? |
5353 annotationValue
5454}
5555
@@ -71,10 +71,10 @@ decoration { Annotation }
7171// (LR(1) cannot pick between reducing here and shifting `;` as the next stmt).
7272VarStatement {
7373 decoration*
74- Var varDeclList ";"
74+ Var varDeclList Semicolon
7575}
7676
77- varDeclList { VarDeclaration ("," VarDeclaration)* }
77+ varDeclList { VarDeclaration (Comma VarDeclaration)* }
7878
7979VarDeclaration { Identifier Export? }
8080
@@ -83,27 +83,27 @@ VarDeclaration { Identifier Export? }
8383ProcedureDecl {
8484 decoration*
8585 Async?
86- Procedure SubName "(" paramList? ")" Export?
86+ Procedure SubName LParen paramList? RParen Export?
8787 body
8888 EndProcedure
8989}
9090
9191FunctionDecl {
9292 decoration*
9393 Async?
94- Function SubName "(" paramList? ")" Export?
94+ Function SubName LParen paramList? RParen Export?
9595 body
9696 EndFunction
9797}
9898
9999SubName { Identifier }
100100
101- paramList { Param ("," Param)* }
101+ paramList { Param (Comma Param)* }
102102
103103Param {
104104 Annotation*
105105 Val?
106- Identifier ("=" DefaultValue)?
106+ Identifier (Assign DefaultValue)?
107107}
108108
109109DefaultValue { unaryConstValue }
@@ -133,15 +133,15 @@ body { (BodyStatement | Preprocessor | VarStatement)* }
133133// that lets Label sit on its own *or* prefix the next statement.
134134BodyStatement {
135135 Label ~labelOpt flatStatement |
136- Label ~labelOpt flatStatement !stmtSemi ";" |
136+ Label ~labelOpt flatStatement !stmtSemi Semicolon |
137137 Label ~labelOpt blockStatement ~blockSemi |
138- Label ~labelOpt blockStatement ~blockSemi !stmtSemi ";" |
138+ Label ~labelOpt blockStatement ~blockSemi !stmtSemi Semicolon |
139139 Label ~labelOpt |
140140 flatStatement |
141- flatStatement !stmtSemi ";" |
141+ flatStatement !stmtSemi Semicolon |
142142 blockStatement ~blockSemi |
143- blockStatement ~blockSemi !stmtSemi ";" |
144- ";"
143+ blockStatement ~blockSemi !stmtSemi Semicolon |
144+ Semicolon
145145}
146146
147147flatStatement {
@@ -166,10 +166,10 @@ blockStatement {
166166 TryStatement
167167}
168168
169- Label { "~" LabelName ":" }
169+ Label { Tilda LabelName Colon }
170170LabelName { Identifier }
171171
172- Assignment { lvalue "=" expression }
172+ Assignment { lvalue Assign expression }
173173
174174CallStatement { reference }
175175
@@ -185,7 +185,7 @@ ElseBranch { Else body }
185185WhileStatement { While expression Do body EndDo }
186186
187187ForStatement {
188- For Identifier "=" expression To expression Do body EndDo
188+ For Identifier Assign expression To expression Do body EndDo
189189}
190190
191191ForEachStatement {
@@ -211,9 +211,9 @@ RaiseStatement[@dynamicPrecedence=1] {
211211ContinueStatement { Continue }
212212BreakStatement { Break }
213213ExecuteStatement { Execute expression }
214- GotoStatement { Goto "~" Identifier }
215- AddHandlerStatement { AddHandler expression "," expression }
216- RemoveHandlerStatement { RemoveHandler expression "," expression }
214+ GotoStatement { Goto Tilda Identifier }
215+ AddHandlerStatement { AddHandler expression Comma expression }
216+ RemoveHandlerStatement { RemoveHandler expression Comma expression }
217217AwaitStatement { Await expression }
218218
219219// ---- Expressions ----
@@ -239,10 +239,10 @@ UnaryExpr { !unary UnaryOp expression }
239239
240240OrOp { Or }
241241AndOp { And }
242- CmpOp { "=" | "<>" | "<" | "<=" | ">" | ">=" }
243- AddOp { "+" | "-" }
244- MulOp { "*" | "/" | "%" }
245- UnaryOp { "+" | "-" | Not }
242+ CmpOp { Assign | NotEqual | Less | LessOrEqual | Greater | GreaterOrEqual }
243+ AddOp { Plus | Minus }
244+ MulOp { Mul | Quotient | Modulo }
245+ UnaryOp { Plus | Minus | Not }
246246
247247primary {
248248 constValue |
@@ -253,7 +253,7 @@ primary {
253253 reference
254254}
255255
256- ParenExpr { "(" expression ")" accessChain }
256+ ParenExpr { LParen expression RParen accessChain }
257257
258258reference { refHead accessChain }
259259
@@ -274,8 +274,8 @@ access {
274274// as identifiers. We can't do mode-shifting in Lezer's specializer, so the
275275// parser rules below explicitly accept every BSL keyword term *or* a plain
276276// Identifier in the dot position.
277- PropertyAccess { "." dotIdentifier }
278- CallAccess { "." dotIdentifier callArgs }
277+ PropertyAccess { Dot dotIdentifier }
278+ CallAccess { Dot dotIdentifier callArgs }
279279
280280dotIdentifier { Identifier | dotKeyword }
281281
@@ -292,17 +292,17 @@ dotKeyword {
292292 And | Or | Not |
293293 True | False | Undefined | Null
294294}
295- IndexAccess { "[" expression "]" }
295+ IndexAccess { LBrack expression RBrack }
296296
297297// Argument list — comma-skipping (`Метод(a,,b)` / `Метод(,a)`) is not
298298// supported. Removed the failed attempt to model `,` as a stand-alone item;
299299// it fundamentally collides with `f(g(...))` inner-call parsing in LR(1).
300300// See README → Limitations for context.
301- callArgs { "(" callArgsList? ")" }
302- callArgsList { callArg ("," callArg)* }
301+ callArgs { LParen callArgsList? RParen }
302+ callArgsList { callArg (Comma callArg)* }
303303callArg { expression }
304304
305- TernaryOp { "?" "(" expression "," expression "," expression ")" }
305+ TernaryOp { Question LParen expression Comma expression Comma expression RParen }
306306NewExpr { New (Identifier callArgs? | callArgs) }
307307AwaitExpr { Await expression }
308308
@@ -334,8 +334,8 @@ Preprocessor {
334334 PreprocessorEndInsert
335335}
336336
337- Region { "#" PreprocRegion RegionName }
338- EndRegion { "#" PreprocEndRegion }
337+ Region { Hash PreprocRegion RegionName }
338+ EndRegion { Hash PreprocEndRegion }
339339RegionName { Identifier }
340340
341341// Preprocessor `#Если/#ИначеЕсли/#Иначе/#КонецЕсли/#Тогда` and their logical
@@ -344,24 +344,24 @@ RegionName { Identifier }
344344// cannot do natively against the existing identifier specialize hook), we
345345// reuse the BSL terms here and let styleTags discriminate via parent
346346// selectors like `"PreprocessorIf/If": t.macroName`.
347- PreprocessorIf { "#" If preprocExpr Then }
348- PreprocessorElsif { "#" Elsif preprocExpr Then }
349- PreprocessorElse { "#" Else }
350- PreprocessorEndIf { "#" EndIf }
347+ PreprocessorIf { Hash If preprocExpr Then }
348+ PreprocessorElsif { Hash Elsif preprocExpr Then }
349+ PreprocessorElse { Hash Else }
350+ PreprocessorEndIf { Hash EndIf }
351351
352352// Configuration-extension preprocessor markers. `#Удаление`/`#КонецУдаления`
353353// brackets code that the *base* configuration has but that the extension
354354// removes; `#Вставка`/`#КонецВставки` brackets code the extension *adds*.
355355// For highlighting purposes both are simple bracket-style directive pairs;
356356// the BSL between them stays in the regular token stream.
357- PreprocessorDelete { "#" PreprocDelete }
358- PreprocessorEndDelete { "#" PreprocEndDelete }
359- PreprocessorInsert { "#" PreprocInsert }
360- PreprocessorEndInsert { "#" PreprocEndInsert }
357+ PreprocessorDelete { Hash PreprocDelete }
358+ PreprocessorEndDelete { Hash PreprocEndDelete }
359+ PreprocessorInsert { Hash PreprocInsert }
360+ PreprocessorEndInsert { Hash PreprocEndInsert }
361361
362362preprocExpr {
363363 Not preprocExpr |
364- "(" preprocExpr ")" |
364+ LParen preprocExpr RParen |
365365 preprocExpr !preprocBool preprocBoolOp preprocExpr |
366366 PreprocSymbol
367367}
@@ -431,18 +431,41 @@ preprocBoolOp { Or | And }
431431 // Shebang line — matched as a single token so its content is not parsed.
432432 ShebangLine { "#!" ![\n]* }
433433
434- // Punctuation
435- "(" ")" "[" "]" "{" "}"
436- "," ":" ";" "."
437- "+" "-" "*" "/" "%"
438- "=" "<>" "<=" ">=" "<" ">"
439- "?" "&" "~" "#"
440-
441- @precedence { "<=", "<>", "<" }
442- @precedence { ">=", ">" }
443- @precedence { DocComment, LineComment, "/" }
444- @precedence { Number, "." }
445- @precedence { ShebangLine, "#" }
434+ // Named punctuation and operator tokens. Naming each lexeme mirrors the
435+ // upstream ANTLR convention from `1c-syntax/bsl-parser` (AMPERSAND, HASH,
436+ // DOT, …) and — more pragmatically — sidesteps @lezer/highlight's
437+ // selector mini-language, which only accepts identifier-shaped names in
438+ // path positions. With named tokens the styleTags selectors can read
439+ // `Annotation/Ampersand` instead of the awkward quoted `Annotation/"&"`.
440+ LParen { "(" }
441+ RParen { ")" }
442+ LBrack { "[" }
443+ RBrack { "]" }
444+ Comma { "," }
445+ Colon { ":" }
446+ Semicolon { ";" }
447+ Dot { "." }
448+ Plus { "+" }
449+ Minus { "-" }
450+ Mul { "*" }
451+ Quotient { "/" }
452+ Modulo { "%" }
453+ Assign { "=" }
454+ NotEqual { "<>" }
455+ LessOrEqual { "<=" }
456+ GreaterOrEqual { ">=" }
457+ Less { "<" }
458+ Greater { ">" }
459+ Question { "?" }
460+ Ampersand { "&" }
461+ Tilda { "~" }
462+ Hash { "#" }
463+
464+ @precedence { LessOrEqual, NotEqual, Less }
465+ @precedence { GreaterOrEqual, Greater }
466+ @precedence { DocComment, LineComment, Quotient }
467+ @precedence { Number, Dot }
468+ @precedence { ShebangLine, Hash }
446469}
447470
448471// ---- External specialization: case-insensitive keyword matching ----
0 commit comments