comments must start at beginning of line

Previously, this grammar allowed comments to start partway through
lines, but per the Dockerfile spec, that is not valid.
This commit is contained in:
Camden Cheek 2021-06-20 11:35:37 -06:00
parent b25f86c3b2
commit d812f3a7fc
No known key found for this signature in database
GPG key ID: 595BFFE3A04E48B9
5 changed files with 3605 additions and 5009 deletions

View file

@ -8,18 +8,3 @@ Full line comment
(source_file (source_file
(comment)) (comment))
==================
Comment after instruction
==================
ADD /src ./dst # Test comment
---
(source_file
(add_instruction
(path)
(path))
(comment))

View file

@ -1,10 +1,10 @@
module.exports = grammar({ module.exports = grammar({
name: "dockerfile", name: "dockerfile",
extras: ($) => [$.comment, /\s+/, "\\\n"], extras: ($) => [/\s+/, "\\\n"],
rules: { rules: {
source_file: ($) => repeat(seq($._instruction, "\n")), source_file: ($) => repeat(seq(choice($._instruction, $.comment), "\n")),
_instruction: ($) => _instruction: ($) =>
choice( choice(

View file

@ -7,8 +7,17 @@
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "CHOICE",
"name": "_instruction" "members": [
{
"type": "SYMBOL",
"name": "_instruction"
},
{
"type": "SYMBOL",
"name": "comment"
}
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -1488,10 +1497,6 @@
} }
}, },
"extras": [ "extras": [
{
"type": "SYMBOL",
"name": "comment"
},
{ {
"type": "PATTERN", "type": "PATTERN",
"value": "\\s+" "value": "\\s+"

View file

@ -602,6 +602,10 @@
"type": "cmd_instruction", "type": "cmd_instruction",
"named": true "named": true
}, },
{
"type": "comment",
"named": true
},
{ {
"type": "copy_instruction", "type": "copy_instruction",
"named": true "named": true

File diff suppressed because it is too large Load diff