Make comments a single node in the grammar
This looks to be a *strong* idiom in tree-sitter parsers.
This commit is contained in:
parent
aa8472e73f
commit
b62fc19da9
6 changed files with 588 additions and 723 deletions
10
grammar.js
10
grammar.js
|
|
@ -11,8 +11,7 @@ module.exports = grammar({
|
|||
|
||||
extras: ($) => [
|
||||
/\s+/,
|
||||
$.line_comment,
|
||||
$.block_comment,
|
||||
$.comment,
|
||||
],
|
||||
|
||||
rules: {
|
||||
|
|
@ -23,9 +22,10 @@ module.exports = grammar({
|
|||
$.module,
|
||||
),
|
||||
|
||||
line_comment: (_) => seq("//", /[^\n]*/),
|
||||
|
||||
block_comment: (_) => seq("/*", /[^*]*\*+([^/*][^*]*\*+)*/, '/'),
|
||||
comment: (_) => choice(
|
||||
seq("//", /[^\n]*/),
|
||||
seq("/*", /[^*]*\*+([^/*][^*]*\*+)*/, '/'),
|
||||
),
|
||||
|
||||
// Definitions {{{
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue