Add block comments
This commit is contained in:
parent
6d3dd1c8cb
commit
eec21c84da
|
@ -12,6 +12,7 @@ module.exports = grammar({
|
|||
extras: ($) => [
|
||||
/\s+/,
|
||||
$.line_comment,
|
||||
$.block_comment,
|
||||
],
|
||||
|
||||
rules: {
|
||||
|
@ -24,6 +25,8 @@ module.exports = grammar({
|
|||
|
||||
line_comment: (_) => seq("//", /.*/),
|
||||
|
||||
block_comment: (_) => seq("/*", /[^*]*\*+([^/*][^*]*\*+)*/, '/'),
|
||||
|
||||
// Definitions {{{
|
||||
|
||||
assignment: ($) => seq(
|
||||
|
|
21
src/grammar.json
generated
21
src/grammar.json
generated
|
@ -34,6 +34,23 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"block_comment": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "/*"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[^*]*\\*+([^/*][^*]*\\*+)*"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "/"
|
||||
}
|
||||
]
|
||||
},
|
||||
"assignment": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
@ -936,6 +953,10 @@
|
|||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "line_comment"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "block_comment"
|
||||
}
|
||||
],
|
||||
"conflicts": [],
|
||||
|
|
13
src/node-types.json
generated
13
src/node-types.json
generated
|
@ -167,6 +167,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block_comment",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "boolean_literal",
|
||||
"named": true,
|
||||
|
@ -648,6 +653,14 @@
|
|||
"type": "-",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "/",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "/*",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "//",
|
||||
"named": false
|
||||
|
|
3965
src/parser.c
generated
3965
src/parser.c
generated
File diff suppressed because it is too large
Load diff
|
@ -32,3 +32,92 @@ Multiple comments
|
|||
(source_file
|
||||
(line_comment)
|
||||
(line_comment))
|
||||
|
||||
================================================================================
|
||||
Empty block comment
|
||||
================================================================================
|
||||
|
||||
/**/
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(block_comment))
|
||||
|
||||
================================================================================
|
||||
Whitespace block comment
|
||||
================================================================================
|
||||
|
||||
/* */
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(block_comment))
|
||||
|
||||
================================================================================
|
||||
Block comment
|
||||
================================================================================
|
||||
|
||||
/* This is a comment */
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(block_comment))
|
||||
|
||||
================================================================================
|
||||
Block comment with slashes
|
||||
================================================================================
|
||||
|
||||
/* /// */
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(block_comment))
|
||||
|
||||
================================================================================
|
||||
Block comment with asterisks
|
||||
================================================================================
|
||||
|
||||
/* *** */
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(block_comment))
|
||||
|
||||
================================================================================
|
||||
Block comment is not recursive
|
||||
================================================================================
|
||||
|
||||
/* /* */
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(block_comment))
|
||||
|
||||
================================================================================
|
||||
Unterminated comment
|
||||
================================================================================
|
||||
|
||||
/*
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(ERROR))
|
||||
|
||||
================================================================================
|
||||
Comment end-delimiter only
|
||||
================================================================================
|
||||
|
||||
*/
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(ERROR
|
||||
(UNEXPECTED '*')))
|
||||
|
|
Loading…
Reference in a new issue