Name variable node for expansions
This commit is contained in:
parent
0c4af3e20f
commit
74e7f4c3e6
|
@ -60,7 +60,8 @@ LABEL key="value${FOO}"
|
|||
(label_pair
|
||||
key: (unquoted_string)
|
||||
value: (double_quoted_string
|
||||
(expansion)))))
|
||||
(expansion
|
||||
(variable))))))
|
||||
|
||||
==================
|
||||
Stopsignal
|
||||
|
@ -72,7 +73,8 @@ STOPSIGNAL $FOO
|
|||
|
||||
(source_file
|
||||
(stopsignal_instruction
|
||||
(expansion)))
|
||||
(expansion
|
||||
(variable))))
|
||||
|
||||
==================
|
||||
User
|
||||
|
@ -85,8 +87,10 @@ USER foo$FOO:bar$BAR
|
|||
(source_file
|
||||
(user_instruction
|
||||
user: (unquoted_string
|
||||
(expansion))
|
||||
(expansion
|
||||
(variable)))
|
||||
group: (unquoted_string
|
||||
(expansion))))
|
||||
(expansion
|
||||
(variable)))))
|
||||
|
||||
|
||||
|
|
|
@ -9,9 +9,11 @@ ADD /$FOO ./${bar}
|
|||
(source_file
|
||||
(add_instruction
|
||||
(path
|
||||
(expansion))
|
||||
(expansion
|
||||
(variable)))
|
||||
(path
|
||||
(expansion))))
|
||||
(expansion
|
||||
(variable)))))
|
||||
|
||||
==================
|
||||
Copy
|
||||
|
@ -24,9 +26,11 @@ COPY $FOO ./${bar}
|
|||
(source_file
|
||||
(copy_instruction
|
||||
(path
|
||||
(expansion))
|
||||
(expansion
|
||||
(variable)))
|
||||
(path
|
||||
(expansion))))
|
||||
(expansion
|
||||
(variable)))))
|
||||
|
||||
==================
|
||||
Special chars
|
||||
|
@ -39,9 +43,11 @@ COPY $FOO ./${bar:-abc}
|
|||
(source_file
|
||||
(copy_instruction
|
||||
(path
|
||||
(expansion))
|
||||
(expansion
|
||||
(variable)))
|
||||
(path
|
||||
(expansion))))
|
||||
(expansion
|
||||
(variable)))))
|
||||
|
||||
==================
|
||||
Env
|
||||
|
@ -60,19 +66,23 @@ ENV TEST="foo$BAR" \
|
|||
(env_pair
|
||||
name: (unquoted_string)
|
||||
value: (double_quoted_string
|
||||
(expansion)))
|
||||
(expansion
|
||||
(variable))))
|
||||
(env_pair
|
||||
name: (unquoted_string)
|
||||
value: (unquoted_string
|
||||
(expansion)))
|
||||
(expansion
|
||||
(variable))))
|
||||
(env_pair
|
||||
name: (unquoted_string)
|
||||
value: (double_quoted_string
|
||||
(expansion)))
|
||||
(expansion
|
||||
(variable))))
|
||||
(env_pair
|
||||
name: (unquoted_string)
|
||||
value: (unquoted_string
|
||||
(expansion)))))
|
||||
(expansion
|
||||
(variable))))))
|
||||
|
||||
==================
|
||||
Expose
|
||||
|
@ -86,7 +96,8 @@ EXPOSE $FOO
|
|||
(source_file
|
||||
(expose_instruction
|
||||
(expose_port
|
||||
(expansion))))
|
||||
(expansion
|
||||
(variable)))))
|
||||
|
||||
==================
|
||||
From
|
||||
|
@ -100,13 +111,17 @@ FROM foo/$FOO:$BAR@sha256:$BAZ AS baz$QUX
|
|||
(from_instruction
|
||||
(image_spec
|
||||
name: (image_name
|
||||
(expansion))
|
||||
(expansion
|
||||
(variable)))
|
||||
tag: (image_tag
|
||||
(expansion))
|
||||
(expansion
|
||||
(variable)))
|
||||
digest: (image_digest
|
||||
(expansion)))
|
||||
(expansion
|
||||
(variable))))
|
||||
as: (image_alias
|
||||
(expansion))))
|
||||
(expansion
|
||||
(variable)))))
|
||||
|
||||
==================
|
||||
Label
|
||||
|
@ -121,7 +136,8 @@ LABEL key="value$FOO"
|
|||
(label_pair
|
||||
key: (unquoted_string)
|
||||
value: (double_quoted_string
|
||||
(expansion)))))
|
||||
(expansion
|
||||
(variable))))))
|
||||
|
||||
==================
|
||||
Stopsignal
|
||||
|
@ -133,7 +149,8 @@ STOPSIGNAL $FOO
|
|||
|
||||
(source_file
|
||||
(stopsignal_instruction
|
||||
(expansion)))
|
||||
(expansion
|
||||
(variable))))
|
||||
|
||||
==================
|
||||
User
|
||||
|
@ -146,9 +163,11 @@ USER foo$FOO:bar${bar}
|
|||
(source_file
|
||||
(user_instruction
|
||||
user: (unquoted_string
|
||||
(expansion))
|
||||
(expansion
|
||||
(variable)))
|
||||
group: (unquoted_string
|
||||
(expansion))))
|
||||
(expansion
|
||||
(variable)))))
|
||||
|
||||
==================
|
||||
Volume
|
||||
|
@ -162,9 +181,11 @@ volume /my$FOO /my${bar}
|
|||
(source_file
|
||||
(volume_instruction
|
||||
(path
|
||||
(expansion))
|
||||
(expansion
|
||||
(variable)))
|
||||
(path
|
||||
(expansion))))
|
||||
(expansion
|
||||
(variable)))))
|
||||
|
||||
==================
|
||||
Workdir
|
||||
|
@ -177,7 +198,8 @@ WORKDIR /tmp/$FOO
|
|||
(source_file
|
||||
(workdir_instruction
|
||||
(path
|
||||
(expansion))))
|
||||
(expansion
|
||||
(variable)))))
|
||||
|
||||
|
||||
==================
|
||||
|
@ -192,6 +214,8 @@ ONBUILD ADD /$FOO ./${bar}
|
|||
(onbuild_instruction
|
||||
(add_instruction
|
||||
(path
|
||||
(expansion))
|
||||
(expansion
|
||||
(variable)))
|
||||
(path
|
||||
(expansion)))))
|
||||
(expansion
|
||||
(variable))))))
|
||||
|
|
10
grammar.js
10
grammar.js
|
@ -194,12 +194,14 @@ module.exports = grammar({
|
|||
|
||||
expansion: $ => seq(
|
||||
'$',
|
||||
repeat1(choice(
|
||||
token.immediate(/[a-zA-Z][a-zA-Z0-9_]*/),
|
||||
seq('{', /[^\}]+/, '}'),
|
||||
))
|
||||
choice(
|
||||
$.variable,
|
||||
seq('{', alias(/[^\}]+/, $.variable), '}'),
|
||||
)
|
||||
),
|
||||
|
||||
variable: $ => token.immediate(/[a-zA-Z][a-zA-Z0-9_]*/),
|
||||
|
||||
|
||||
env_pair: $ => seq(
|
||||
field("name", alias(/[a-zA-Z][a-zA-Z0-9_]+[a-zA-Z0-9]/, $.unquoted_string)),
|
||||
|
|
|
@ -801,39 +801,45 @@
|
|||
"value": "$"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[a-zA-Z][a-zA-Z0-9_]*"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "variable"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[^\\}]+"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
"named": true,
|
||||
"value": "variable"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"variable": {
|
||||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[a-zA-Z][a-zA-Z0-9_]*"
|
||||
}
|
||||
},
|
||||
"env_pair": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
|
|
@ -177,7 +177,17 @@
|
|||
{
|
||||
"type": "expansion",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "variable",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "expose_instruction",
|
||||
|
@ -861,6 +871,10 @@
|
|||
"type": "escape_sequence",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "variable",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "{",
|
||||
"named": false
|
||||
|
|
9896
src/parser.c
9896
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue