use extra to allow comments anywhere
This commit is contained in:
parent
b4a90e2b98
commit
439c3e7b8a
10
grammar.js
10
grammar.js
|
@ -1,7 +1,7 @@
|
|||
module.exports = grammar({
|
||||
name: "dockerfile",
|
||||
|
||||
extras: ($) => [/\s+/, $.line_continuation],
|
||||
extras: ($) => [/\s+/, $.line_continuation, $.comment],
|
||||
externals: ($) => [
|
||||
$.heredoc_marker,
|
||||
$.heredoc_line,
|
||||
|
@ -11,7 +11,7 @@ module.exports = grammar({
|
|||
],
|
||||
|
||||
rules: {
|
||||
source_file: ($) => repeat(seq(choice($._instruction, $.comment), "\n")),
|
||||
source_file: ($) => repeat(seq($._instruction, "\n")),
|
||||
|
||||
_instruction: ($) =>
|
||||
choice(
|
||||
|
@ -373,12 +373,10 @@ module.exports = grammar({
|
|||
|
||||
shell_command: ($) =>
|
||||
seq(
|
||||
repeat($._comment_line),
|
||||
$.shell_fragment,
|
||||
repeat(
|
||||
seq(
|
||||
alias($.required_line_continuation, $.line_continuation),
|
||||
repeat($._comment_line),
|
||||
$.shell_fragment
|
||||
)
|
||||
)
|
||||
|
@ -408,10 +406,6 @@ module.exports = grammar({
|
|||
line_continuation: () => /\\[ \t]*\n/,
|
||||
required_line_continuation: () => "\\\n",
|
||||
|
||||
_comment_line: ($) => seq(alias($._anon_comment, $.comment), "\n"),
|
||||
|
||||
_anon_comment: () => seq("#", /.*/),
|
||||
|
||||
json_string_array: ($) =>
|
||||
seq(
|
||||
"[",
|
||||
|
|
62
src/grammar.json
generated
62
src/grammar.json
generated
|
@ -7,17 +7,8 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_instruction"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "comment"
|
||||
}
|
||||
]
|
||||
"type": "SYMBOL",
|
||||
"name": "_instruction"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
|
@ -1591,13 +1582,6 @@
|
|||
"shell_command": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_comment_line"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "shell_fragment"
|
||||
|
@ -1616,13 +1600,6 @@
|
|||
"named": true,
|
||||
"value": "line_continuation"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_comment_line"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "shell_fragment"
|
||||
|
@ -1677,37 +1654,6 @@
|
|||
"type": "STRING",
|
||||
"value": "\\\n"
|
||||
},
|
||||
"_comment_line": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_anon_comment"
|
||||
},
|
||||
"named": true,
|
||||
"value": "comment"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\n"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_anon_comment": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "#"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": ".*"
|
||||
}
|
||||
]
|
||||
},
|
||||
"json_string_array": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
@ -1962,6 +1908,10 @@
|
|||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "line_continuation"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "comment"
|
||||
}
|
||||
],
|
||||
"conflicts": [],
|
||||
|
|
21
src/node-types.json
generated
21
src/node-types.json
generated
|
@ -75,11 +75,6 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "comment",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "copy_instruction",
|
||||
"named": true,
|
||||
|
@ -675,10 +670,6 @@
|
|||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "comment",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "line_continuation",
|
||||
"named": true
|
||||
|
@ -755,10 +746,6 @@
|
|||
"type": "cmd_instruction",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "comment",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "copy_instruction",
|
||||
"named": true
|
||||
|
@ -924,10 +911,6 @@
|
|||
"type": "\"",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "#",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "$",
|
||||
"named": false
|
||||
|
@ -1068,6 +1051,10 @@
|
|||
"type": "_heredoc_nl",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "comment",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "escape_sequence",
|
||||
"named": true
|
||||
|
|
11684
src/parser.c
generated
11684
src/parser.c
generated
File diff suppressed because it is too large
Load diff
|
@ -9,15 +9,15 @@ COPY libsqlite3-pcre-install-alpine.sh /libsqlite3-pcre-install-alpine.sh
|
|||
---
|
||||
|
||||
(source_file
|
||||
(from_instruction
|
||||
(image_spec
|
||||
name: (image_name)
|
||||
tag: (image_tag)
|
||||
digest: (image_digest))
|
||||
as: (image_alias))
|
||||
(copy_instruction
|
||||
(path)
|
||||
(path)))
|
||||
(from_instruction
|
||||
(image_spec
|
||||
name: (image_name)
|
||||
tag: (image_tag)
|
||||
digest: (image_digest))
|
||||
as: (image_alias))
|
||||
(copy_instruction
|
||||
(path)
|
||||
(path)))
|
||||
|
||||
==================
|
||||
Run interrupted with comment
|
||||
|
@ -31,13 +31,13 @@ RUN echo hello \
|
|||
---
|
||||
|
||||
(source_file
|
||||
(run_instruction
|
||||
(shell_command
|
||||
(shell_fragment)
|
||||
(line_continuation)
|
||||
(comment)
|
||||
(comment)
|
||||
(shell_fragment))))
|
||||
(run_instruction
|
||||
(shell_command
|
||||
(shell_fragment)
|
||||
(line_continuation)
|
||||
(comment)
|
||||
(comment)
|
||||
(shell_fragment))))
|
||||
|
||||
==================
|
||||
Run with immediate line continuation
|
||||
|
@ -50,11 +50,11 @@ RUN \
|
|||
---
|
||||
|
||||
(source_file
|
||||
(run_instruction
|
||||
(line_continuation)
|
||||
(shell_command
|
||||
(comment)
|
||||
(shell_fragment))))
|
||||
(run_instruction
|
||||
(line_continuation)
|
||||
(comment)
|
||||
(shell_command
|
||||
(shell_fragment))))
|
||||
|
||||
==================
|
||||
Run with immediate continuation and comment
|
||||
|
@ -68,10 +68,10 @@ RUN \
|
|||
---
|
||||
|
||||
(source_file
|
||||
(run_instruction
|
||||
(line_continuation)
|
||||
(shell_command
|
||||
(shell_fragment)
|
||||
(line_continuation)
|
||||
(comment)
|
||||
(shell_fragment))))
|
||||
(run_instruction
|
||||
(line_continuation)
|
||||
(shell_command
|
||||
(shell_fragment)
|
||||
(line_continuation)
|
||||
(comment)
|
||||
(shell_fragment))))
|
||||
|
|
|
@ -139,3 +139,21 @@ ENV TZ America/Toronto
|
|||
(env_pair
|
||||
name: (unquoted_string)
|
||||
value: (unquoted_string))))
|
||||
|
||||
================================================================================
|
||||
Comment immediately after continuation
|
||||
================================================================================
|
||||
|
||||
ENV \
|
||||
# Where do you live?
|
||||
TZ America/Toronto
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(env_instruction
|
||||
(line_continuation)
|
||||
(comment)
|
||||
(env_pair
|
||||
name: (unquoted_string)
|
||||
value: (unquoted_string))))
|
||||
|
|
Loading…
Reference in a new issue