Add comments
For now it only supports non-nested comments. It seems like I *will* need to write an external lexer to account for nesting properly.
This commit is contained in:
parent
e5e958cac9
commit
75bb2c7009
5 changed files with 2239 additions and 1718 deletions
20
grammar.js
20
grammar.js
|
|
@ -25,12 +25,32 @@ module.exports = grammar({
|
|||
[$._lvalue, $.array_expression],
|
||||
],
|
||||
|
||||
extras: ($) => [
|
||||
/( |\n|\r|\t)+/,
|
||||
$.comment,
|
||||
],
|
||||
|
||||
rules: {
|
||||
source_file: ($) => choice(
|
||||
$._expr,
|
||||
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