Name variable node for expansions

This commit is contained in:
Camden Cheek 2021-05-10 17:35:00 -06:00
parent 0c4af3e20f
commit 74e7f4c3e6
No known key found for this signature in database
GPG key ID: 595BFFE3A04E48B9
6 changed files with 4422 additions and 5644 deletions

View file

@ -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)))))

View file

@ -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))))))

View file

@ -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)),

View file

@ -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": [

View file

@ -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

File diff suppressed because it is too large Load diff