Fix image alias
This commit is contained in:
parent
3055288ce1
commit
c281dc9daa
21
corpus/combo.txt
Normal file
21
corpus/combo.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
==================
|
||||
From and Copy
|
||||
==================
|
||||
|
||||
FROM sourcegraph/alpine:3.12@sha256:ce099fbcd3cf70b338fc4cb2a4e1fa9ae847de21afdb0a849a393b87d94fb174 as libsqlite3-pcre
|
||||
|
||||
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)))
|
||||
|
|
@ -69,5 +69,5 @@ FROM sourcegraph/alpine:3.12@sha256:ce099fbcd3cf70b338fc4cb2a4e1fa9ae847de21afdb
|
|||
name: (image_name)
|
||||
tag: (image_tag)
|
||||
digest: (image_digest))
|
||||
as: (name)))
|
||||
as: (image_alias)))
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ FROM foo/$FOO:$BAR@sha256:$BAZ AS baz$QUX
|
|||
(env_spec))
|
||||
digest: (image_digest
|
||||
(env_spec)))
|
||||
as: (name
|
||||
as: (image_alias
|
||||
(env_spec))))
|
||||
|
||||
==================
|
||||
|
|
13
grammar.js
13
grammar.js
|
@ -33,7 +33,7 @@ module.exports = grammar({
|
|||
$.image_spec,
|
||||
optional(seq(
|
||||
alias(/[aA][sS]/, "AS"),
|
||||
field("as", $.name),
|
||||
field("as", $.image_alias),
|
||||
)),
|
||||
),
|
||||
|
||||
|
@ -181,7 +181,6 @@ module.exports = grammar({
|
|||
$.string_array,
|
||||
),
|
||||
|
||||
// path: $ => /[^-\[][^\s]*/,
|
||||
path: $ => seq(
|
||||
choice(
|
||||
/[^-\s]/, // cannot start with a '-' to avoid conflicts with params
|
||||
|
@ -240,14 +239,14 @@ module.exports = grammar({
|
|||
),
|
||||
|
||||
image_name: $ => repeat1(choice(
|
||||
token.immediate(/[^:@\s\$]+/),
|
||||
token.immediate(/[^@:\s\$]+/),
|
||||
$.env_spec,
|
||||
)),
|
||||
|
||||
image_tag: $ => seq(
|
||||
token.immediate(":"),
|
||||
repeat1(choice(
|
||||
token.immediate(/[^\s@\$]+/),
|
||||
token.immediate(/[^@\s\$]+/),
|
||||
$.env_spec,
|
||||
))
|
||||
),
|
||||
|
@ -255,7 +254,7 @@ module.exports = grammar({
|
|||
image_digest: $ => seq(
|
||||
token.immediate("@"),
|
||||
repeat1(choice(
|
||||
token.immediate(/[^\s\$]+/),
|
||||
token.immediate(/[a-zA-Z0-9:]+/),
|
||||
$.env_spec,
|
||||
)),
|
||||
),
|
||||
|
@ -267,8 +266,8 @@ module.exports = grammar({
|
|||
field("value", token.immediate(/[^\s]+/)),
|
||||
),
|
||||
|
||||
name: $ => repeat1(choice(
|
||||
/[-a-z_]+/,
|
||||
image_alias: $ => repeat1(choice(
|
||||
/[-a-zA-Z0-9_]+/,
|
||||
$.env_spec,
|
||||
)),
|
||||
|
||||
|
|
26
queries/highlights.scm
Normal file
26
queries/highlights.scm
Normal file
|
@ -0,0 +1,26 @@
|
|||
[
|
||||
; "FROM"
|
||||
"RUN"
|
||||
"CMD"
|
||||
"LABEL"
|
||||
"EXPOSE"
|
||||
"ENV"
|
||||
"ADD"
|
||||
"COPY"
|
||||
"ENTRYPOINT"
|
||||
"VOLUME"
|
||||
"USER"
|
||||
"WORKDIR"
|
||||
"ARG"
|
||||
"ONBUILD"
|
||||
"STOPSIGNAL"
|
||||
"HEALTHCHECK"
|
||||
"SHELL"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
":"
|
||||
"@"
|
||||
] @operator
|
||||
|
||||
(comment) @comment
|
|
@ -142,7 +142,7 @@
|
|||
"name": "as",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "name"
|
||||
"name": "image_alias"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -1016,7 +1016,7 @@
|
|||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[^:@\\s\\$]+"
|
||||
"value": "[^@:\\s\\$]+"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1045,7 +1045,7 @@
|
|||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[^\\s@\\$]+"
|
||||
"value": "[^@\\s\\$]+"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1076,7 +1076,7 @@
|
|||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[^\\s\\$]+"
|
||||
"value": "[a-zA-Z0-9:]+"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1126,14 +1126,14 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"name": {
|
||||
"image_alias": {
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[-a-z_]+"
|
||||
"value": "[-a-zA-Z0-9_]+"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
|
|
@ -218,7 +218,7 @@
|
|||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "name",
|
||||
"type": "image_alias",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
@ -258,6 +258,21 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "image_alias",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "env_spec",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "image_digest",
|
||||
"named": true,
|
||||
|
@ -384,21 +399,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "name",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "env_spec",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "onbuild_instruction",
|
||||
"named": true,
|
||||
|
|
10004
src/parser.c
10004
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue