Add support for nested comments
Unfortunately, the 'extras' array expects single tokens only, so one can't really use a recursive parsing rule to express nesting comments...
This commit is contained in:
parent
75bb2c7009
commit
50a0eaa071
5 changed files with 1672 additions and 1661 deletions
20
grammar.js
20
grammar.js
|
|
@ -25,6 +25,11 @@ module.exports = grammar({
|
|||
[$._lvalue, $.array_expression],
|
||||
],
|
||||
|
||||
externals: ($) => [
|
||||
// Nested comments need to be tokenized externally
|
||||
$.comment,
|
||||
],
|
||||
|
||||
extras: ($) => [
|
||||
/( |\n|\r|\t)+/,
|
||||
$.comment,
|
||||
|
|
@ -36,21 +41,6 @@ module.exports = grammar({
|
|||
optional($._declaration_chunks),
|
||||
),
|
||||
|
||||
comment: ($) => token(
|
||||
seq(
|
||||
"/*",
|
||||
repeat(
|
||||
choice(
|
||||
// Match anything but the end-delimiter
|
||||
/(\*[^/]|[^*])+/,
|
||||
// Comments can be nested
|
||||
// $.comment,
|
||||
),
|
||||
),
|
||||
"*/",
|
||||
),
|
||||
),
|
||||
|
||||
// Expressions {{{
|
||||
|
||||
_expr: ($) => choice(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue