add comments
This commit is contained in:
parent
1095c58b33
commit
b539703965
5 changed files with 36 additions and 2 deletions
|
@ -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),
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -269,6 +269,10 @@
|
|||
"type": "label",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "line_comment",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"named": false
|
||||
|
|
BIN
src/parser.c
BIN
src/parser.c
Binary file not shown.
Loading…
Reference in a new issue