add comments

This commit is contained in:
Dmitriy Pleshevskiy 2022-12-07 12:09:27 +03:00
parent 1095c58b33
commit b539703965
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
5 changed files with 36 additions and 2 deletions

View file

@ -3,7 +3,7 @@ const spaces = repeat(" ");
module.exports = grammar({
name: "d2",
extras: ($) => [],
extras: ($) => [$.line_comment],
word: ($) => $._word,
@ -175,6 +175,8 @@ module.exports = grammar({
seq("`", repeat(token.immediate(/[^`\n]+/)), "`")
),
line_comment: ($) => token(seq("#", /.*/)),
_word: ($) => /[\w\d]+/,
_emptyline: ($) => seq(spaces, $._eof),

View file

@ -3,12 +3,19 @@
(identifier) @variable
(attr_key) @keyword
; Literals
;-------------------------------------------------------------------------------
(string) @string
(label) @string
(attr_value) @string
; Comments
;-------------------------------------------------------------------------------
(line_comment) @comment.line
; Punctiation
;-------------------------------------------------------------------------------
(arrow) @operator

View file

@ -969,6 +969,22 @@
}
]
},
"line_comment": {
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "#"
},
{
"type": "PATTERN",
"value": ".*"
}
]
}
},
"_word": {
"type": "PATTERN",
"value": "[\\w\\d]+"
@ -1028,7 +1044,12 @@
]
}
},
"extras": [],
"extras": [
{
"type": "SYMBOL",
"name": "line_comment"
}
],
"conflicts": [
[
"identifier"

View file

@ -269,6 +269,10 @@
"type": "label",
"named": false
},
{
"type": "line_comment",
"named": true
},
{
"type": "link",
"named": false

Binary file not shown.