adding zsh expansion flagsSee https://zsh.sourceforge.io/Doc/Release/Expansion.html\#Parameter-Expansion-Flags (#115)
This commit is contained in:
parent
4094e3a040
commit
275effdfc0
|
@ -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))))))
|
|
@ -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(
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
"scope": "source.bash",
|
||||
"file-types": [
|
||||
"sh",
|
||||
"bash"
|
||||
"bash",
|
||||
"zsh"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
">>"
|
||||
"<"
|
||||
"|"
|
||||
(expansion_flags)
|
||||
] @operator
|
||||
|
||||
(
|
||||
|
|
|
@ -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": [
|
||||
|
|
|
@ -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,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue