allow space after backslash to act as line continuation (#49)

This commit is contained in:
Camden Cheek 2024-04-19 15:02:25 -06:00 committed by GitHub
parent ecea7ac2c9
commit 40eceeff30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 4854 additions and 6355 deletions

View file

@ -405,7 +405,7 @@ module.exports = grammar({
)
),
line_continuation: ($) => "\\\n",
line_continuation: ($) => /\\[ \t]*\n/,
required_line_continuation: ($) => "\\\n",
_comment_line: ($) => seq(alias($._anon_comment, $.comment), "\n"),

4
src/grammar.json generated
View file

@ -1670,8 +1670,8 @@
}
},
"line_continuation": {
"type": "STRING",
"value": "\\\n"
"type": "PATTERN",
"value": "\\\\[ \\t]*\\n"
},
"required_line_continuation": {
"type": "STRING",

13
src/node-types.json generated
View file

@ -485,11 +485,6 @@
}
}
},
{
"type": "line_continuation",
"named": true,
"fields": {}
},
{
"type": "maintainer_instruction",
"named": true,
@ -1061,10 +1056,6 @@
"type": "\\",
"named": false
},
{
"type": "\\\n",
"named": false
},
{
"type": "\\ ",
"named": false
@ -1093,6 +1084,10 @@
"type": "heredoc_marker",
"named": true
},
{
"type": "line_continuation",
"named": true
},
{
"type": "mount",
"named": false

11175
src/parser.c generated

File diff suppressed because it is too large Load diff

View file

@ -31,6 +31,21 @@ RUN echo "test" \
(line_continuation)
(shell_fragment))))
==================
Shell command multiline space after continuation
==================
RUN echo "test" \
echo "foo"
---
(source_file
(run_instruction
(shell_command
(shell_fragment
(line_continuation)))))
==================
Run with shell empty array
==================