Fix multi-asterisk comments and update highlights

- Support variable asterisk counts: @* *@, @** **@, @*** ***@
- Add template_comment_1, template_comment_2, template_comment_3 rules
- Update highlights.scm to handle all comment variants
- Fix safe_expression highlighting (use node pattern instead of literal)
- Remove invalid :: punctuation rule (inside token())

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Michael Netshipise 2026-01-19 07:53:21 +02:00
parent 8ea8f5eaed
commit f3a7ee0c2e
6 changed files with 17181 additions and 15966 deletions

View File

@ -512,10 +512,24 @@ module.exports = grammar({
// Comments // Comments
comment: ($) => choice($.template_comment, $.html_comment), comment: ($) => choice($.template_comment, $.html_comment),
// Template comment: @* ... *@ // Template comments support variable asterisk counts: @* *@, @** **@, @*** ***@
template_comment: ($) => seq("@*", optional($.comment_content), "*@"), template_comment: ($) =>
choice($.template_comment_1, $.template_comment_2, $.template_comment_3),
comment_content: ($) => /([^*]|\*[^@])*/, // Single asterisk: @* ... *@
template_comment_1: ($) =>
seq("@*", optional($.comment_content_1), "*@"),
comment_content_1: ($) => /([^*]|\*[^@])*/,
// Double asterisk: @** ... **@
template_comment_2: ($) =>
seq("@**", optional($.comment_content_2), "**@"),
comment_content_2: ($) => /([^*]|\*[^*]|\*\*[^@])*/,
// Triple asterisk: @*** ... ***@
template_comment_3: ($) =>
seq("@***", optional($.comment_content_3), "***@"),
comment_content_3: ($) => /([^*]|\*[^*]|\*\*[^*]|\*\*\*[^@])*/,
// HTML comment: <!-- ... --> // HTML comment: <!-- ... -->
html_comment: ($) => seq("<!--", optional($.html_comment_content), "-->"), html_comment: ($) => seq("<!--", optional($.html_comment_content), "-->"),

4
package-lock.json generated
View File

@ -1,11 +1,11 @@
{ {
"name": "tree-sitter-waltzing", "name": "waltzing-tree-sitter",
"version": "0.1.0", "version": "0.1.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "tree-sitter-waltzing", "name": "waltzing-tree-sitter",
"version": "0.1.0", "version": "0.1.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {

View File

@ -1,10 +1,13 @@
; Waltzing Template Highlights ; Waltzing Template Highlights
; Comments ; Comments (all template comment variants)
(template_comment) @comment (template_comment) @comment
(template_comment_1) @comment
(template_comment_2) @comment
(template_comment_3) @comment
(html_comment) @comment (html_comment) @comment
; Keywords - using @keyword for all ; Keywords
"@use" @keyword "@use" @keyword
"@import" @keyword "@import" @keyword
"@struct" @keyword "@struct" @keyword
@ -82,6 +85,7 @@
; Attributes ; Attributes
(attribute_name) @attribute (attribute_name) @attribute
(attribute_list) @attribute
(attribute (identifier) @attribute) (attribute (identifier) @attribute)
; Module paths ; Module paths

View File

@ -2572,6 +2572,23 @@
] ]
}, },
"template_comment": { "template_comment": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "template_comment_1"
},
{
"type": "SYMBOL",
"name": "template_comment_2"
},
{
"type": "SYMBOL",
"name": "template_comment_3"
}
]
},
"template_comment_1": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
@ -2583,7 +2600,7 @@
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "comment_content" "name": "comment_content_1"
}, },
{ {
"type": "BLANK" "type": "BLANK"
@ -2596,10 +2613,68 @@
} }
] ]
}, },
"comment_content": { "comment_content_1": {
"type": "PATTERN", "type": "PATTERN",
"value": "([^*]|\\*[^@])*" "value": "([^*]|\\*[^@])*"
}, },
"template_comment_2": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "@**"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment_content_2"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "**@"
}
]
},
"comment_content_2": {
"type": "PATTERN",
"value": "([^*]|\\*[^*]|\\*\\*[^@])*"
},
"template_comment_3": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "@***"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment_content_3"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "***@"
}
]
},
"comment_content_3": {
"type": "PATTERN",
"value": "([^*]|\\*[^*]|\\*\\*[^*]|\\*\\*\\*[^@])*"
},
"html_comment": { "html_comment": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [

View File

@ -1330,12 +1330,65 @@
"type": "template_comment", "type": "template_comment",
"named": true, "named": true,
"fields": {}, "fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "template_comment_1",
"named": true
},
{
"type": "template_comment_2",
"named": true
},
{
"type": "template_comment_3",
"named": true
}
]
}
},
{
"type": "template_comment_1",
"named": true,
"fields": {},
"children": { "children": {
"multiple": false, "multiple": false,
"required": false, "required": false,
"types": [ "types": [
{ {
"type": "comment_content", "type": "comment_content_1",
"named": true
}
]
}
},
{
"type": "template_comment_2",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": false,
"types": [
{
"type": "comment_content_2",
"named": true
}
]
}
},
{
"type": "template_comment_3",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": false,
"types": [
{
"type": "comment_content_3",
"named": true "named": true
} }
] ]
@ -1601,6 +1654,14 @@
"type": "*", "type": "*",
"named": false "named": false
}, },
{
"type": "***@",
"named": false
},
{
"type": "**@",
"named": false
},
{ {
"type": "*@", "type": "*@",
"named": false "named": false
@ -1701,6 +1762,14 @@
"type": "@*", "type": "@*",
"named": false "named": false
}, },
{
"type": "@**",
"named": false
},
{
"type": "@***",
"named": false
},
{ {
"type": "@```", "type": "@```",
"named": false "named": false
@ -1790,7 +1859,15 @@
"named": false "named": false
}, },
{ {
"type": "comment_content", "type": "comment_content_1",
"named": true
},
{
"type": "comment_content_2",
"named": true
},
{
"type": "comment_content_3",
"named": true "named": true
}, },
{ {

32955
src/parser.c

File diff suppressed because it is too large Load Diff