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
comment: ($) => choice($.template_comment, $.html_comment),
// Template comment: @* ... *@
template_comment: ($) => seq("@*", optional($.comment_content), "*@"),
// Template comments support variable asterisk counts: @* *@, @** **@, @*** ***@
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: ($) => 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",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tree-sitter-waltzing",
"name": "waltzing-tree-sitter",
"version": "0.1.0",
"license": "MIT",
"dependencies": {

View File

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

View File

@ -2572,6 +2572,23 @@
]
},
"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",
"members": [
{
@ -2583,7 +2600,7 @@
"members": [
{
"type": "SYMBOL",
"name": "comment_content"
"name": "comment_content_1"
},
{
"type": "BLANK"
@ -2596,10 +2613,68 @@
}
]
},
"comment_content": {
"comment_content_1": {
"type": "PATTERN",
"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": {
"type": "SEQ",
"members": [

View File

@ -1330,12 +1330,65 @@
"type": "template_comment",
"named": true,
"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": {
"multiple": false,
"required": false,
"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
}
]
@ -1601,6 +1654,14 @@
"type": "*",
"named": false
},
{
"type": "***@",
"named": false
},
{
"type": "**@",
"named": false
},
{
"type": "*@",
"named": false
@ -1701,6 +1762,14 @@
"type": "@*",
"named": false
},
{
"type": "@**",
"named": false
},
{
"type": "@***",
"named": false
},
{
"type": "@```",
"named": false
@ -1790,7 +1859,15 @@
"named": false
},
{
"type": "comment_content",
"type": "comment_content_1",
"named": true
},
{
"type": "comment_content_2",
"named": true
},
{
"type": "comment_content_3",
"named": true
},
{

32955
src/parser.c

File diff suppressed because it is too large Load Diff