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:
parent
b25f86c3b2
commit
d812f3a7fc
|
@ -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))
|
|
||||||
|
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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+"
|
||||||
|
|
|
@ -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
|
||||||
|
|
8574
src/parser.c
8574
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue