Skip to content

Commit

Permalink
fix: _comment_action rule
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhas07 committed Jan 13, 2025
1 parent ca52fbf commit 7684032
Show file tree
Hide file tree
Showing 5 changed files with 6,091 additions and 5,441 deletions.
20 changes: 12 additions & 8 deletions make_grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,16 @@ module.exports = function make_grammar(dialect) {
),

_comment_action: ($) =>
seq($._left_delimiter, $.comment, $._right_delimiter),
choice(
seq(token('{{'), $.comment, token.immediate('}}')),
seq(
token('{{-'),
token.immediate(' '),
$.comment,
token.immediate(' '),
token.immediate('-}}')
)
),

_pipeline_action: ($) =>
seq($._left_delimiter, $._pipeline, $._right_delimiter),
Expand Down Expand Up @@ -435,13 +444,8 @@ module.exports = function make_grammar(dialect) {
),

// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
comment: ($) =>
token(
choice(
seq('//', /.*/),
seq('/*', /[^*]*\*+([^/*][^*]*\*+)*/, '/')
)
),
comment: (_) =>
token.immediate(seq('/*', /[^*]*\*+([^/*][^*]*\*+)*/, '/')),

_left_delimiter: ($) => choice(token('{{'), token('{{-')),
_right_delimiter: ($) => choice(token('}}'), token('-}}')),
Expand Down
104 changes: 67 additions & 37 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,67 @@
}
},
"_comment_action": {
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_left_delimiter"
},
{
"type": "SYMBOL",
"name": "comment"
"type": "SEQ",
"members": [
{
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "{{"
}
},
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "}}"
}
}
]
},
{
"type": "SYMBOL",
"name": "_right_delimiter"
"type": "SEQ",
"members": [
{
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "{{-"
}
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": " "
}
},
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": " "
}
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "-}}"
}
}
]
}
]
},
Expand Down Expand Up @@ -3434,39 +3482,21 @@
}
},
"comment": {
"type": "TOKEN",
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "CHOICE",
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "//"
},
{
"type": "PATTERN",
"value": ".*"
}
]
"type": "STRING",
"value": "/*"
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "/*"
},
{
"type": "PATTERN",
"value": "[^*]*\\*+([^/*][^*]*\\*+)*"
},
{
"type": "STRING",
"value": "/"
}
]
"type": "PATTERN",
"value": "[^*]*\\*+([^/*][^*]*\\*+)*"
},
{
"type": "STRING",
"value": "/"
}
]
}
Expand Down
36 changes: 36 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@
"multiple": true,
"required": false,
"types": [
{
"type": " ",
"named": false
},
{
"type": "-}}",
"named": false
Expand Down Expand Up @@ -515,6 +519,10 @@
"multiple": true,
"required": false,
"types": [
{
"type": " ",
"named": false
},
{
"type": "-}}",
"named": false
Expand Down Expand Up @@ -716,6 +724,10 @@
"multiple": true,
"required": false,
"types": [
{
"type": " ",
"named": false
},
{
"type": "-}}",
"named": false
Expand Down Expand Up @@ -932,6 +944,10 @@
"multiple": true,
"required": false,
"types": [
{
"type": " ",
"named": false
},
{
"type": "-}}",
"named": false
Expand Down Expand Up @@ -1066,6 +1082,10 @@
"multiple": true,
"required": false,
"types": [
{
"type": " ",
"named": false
},
{
"type": "-}}",
"named": false
Expand Down Expand Up @@ -1338,6 +1358,10 @@
"multiple": true,
"required": false,
"types": [
{
"type": " ",
"named": false
},
{
"type": "-}}",
"named": false
Expand Down Expand Up @@ -1472,6 +1496,10 @@
"multiple": true,
"required": false,
"types": [
{
"type": " ",
"named": false
},
{
"type": "-}}",
"named": false
Expand Down Expand Up @@ -2194,6 +2222,10 @@
"multiple": true,
"required": false,
"types": [
{
"type": " ",
"named": false
},
{
"type": "-}}",
"named": false
Expand Down Expand Up @@ -2410,6 +2442,10 @@
"multiple": true,
"required": false,
"types": [
{
"type": " ",
"named": false
},
{
"type": "-}}",
"named": false
Expand Down
Loading

0 comments on commit 7684032

Please sign in to comment.