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)), 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( expansion: $ => seq(
'${', '${',
optional($.expansion_flags),
optional(choice('#', '!')), optional(choice('#', '!')),
optional(choice( optional(choice(
seq( seq(

View File

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

View File

@ -46,6 +46,7 @@
">>" ">>"
"<" "<"
"|" "|"
(expansion_flags)
] @operator ] @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": { "expansion": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -2160,6 +2180,18 @@
"type": "STRING", "type": "STRING",
"value": "${" "value": "${"
}, },
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "expansion_flags"
},
{
"type": "BLANK"
}
]
},
{ {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [

9
src/node-types.json vendored
View File

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

225865
src/parser.c vendored

File diff suppressed because it is too large Load Diff