This commit is contained in:
Ryan Despain 2021-12-15 09:53:04 -07:00 committed by GitHub
parent 4094e3a040
commit 275effdfc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 125768 additions and 100181 deletions

35
corpus/zsh.txt Normal file
View File

@ -0,0 +1,35 @@
# See https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion-Flags
=============================
Parameter Expansion Flags
=============================
echo ${(v)V}
echo ${(s.:.)V}
echo ${(@)V}
echo ${()V}
---
(program
(command (command_name (word)) (expansion (expansion_flags) (variable_name)))
(command (command_name (word)) (expansion (expansion_flags) (variable_name)))
(command (command_name (word)) (expansion (expansion_flags) (variable_name)))
(command (command_name (word)) (expansion (expansion_flags) (variable_name))))
=============================
Parameter Expansion Flags Quotes
=============================
echo "${(v_sldkfj_sdklfj)V}"
---
(program
(command (command_name (word)) (string (expansion (expansion_flags) (variable_name)))))
=============================
Parameter Expansion Invalid Flags
=============================
echo "${(())V}"
---
(program
(command (command_name (word)) (string (expansion (ERROR) (expansion_flags) (ERROR (word))))))

View File

@ -490,8 +490,12 @@ module.exports = grammar({
string_expansion: $ => seq('$', choice($.string, $.raw_string)),
// See https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion-Flags
expansion_flags: ($) => seq("(", repeat(/[^()]/), ")"),
expansion: $ => seq(
'${',
optional($.expansion_flags),
optional(choice('#', '!')),
optional(choice(
seq(

View File

@ -30,7 +30,8 @@
"scope": "source.bash",
"file-types": [
"sh",
"bash"
"bash",
"zsh"
]
}
]

View File

@ -46,6 +46,7 @@
">>"
"<"
"|"
(expansion_flags)
] @operator
(

32
src/grammar.json vendored
View File

@ -2153,6 +2153,26 @@
}
]
},
"expansion_flags": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "REPEAT",
"content": {
"type": "PATTERN",
"value": "[^()]"
}
},
{
"type": "STRING",
"value": ")"
}
]
},
"expansion": {
"type": "SEQ",
"members": [
@ -2160,6 +2180,18 @@
"type": "STRING",
"value": "${"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "expansion_flags"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [

9
src/node-types.json vendored
View File

@ -638,6 +638,10 @@
"type": "concatenation",
"named": true
},
{
"type": "expansion_flags",
"named": true
},
{
"type": "regex",
"named": true
@ -657,6 +661,11 @@
]
}
},
{
"type": "expansion_flags",
"named": true,
"fields": {}
},
{
"type": "file_redirect",
"named": true,

225865
src/parser.c vendored

File diff suppressed because it is too large Load Diff