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)),
|
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(
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
"scope": "source.bash",
|
"scope": "source.bash",
|
||||||
"file-types": [
|
"file-types": [
|
||||||
"sh",
|
"sh",
|
||||||
"bash"
|
"bash",
|
||||||
|
"zsh"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
">>"
|
">>"
|
||||||
"<"
|
"<"
|
||||||
"|"
|
"|"
|
||||||
|
(expansion_flags)
|
||||||
] @operator
|
] @operator
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|
|
@ -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": [
|
||||||
|
|
|
@ -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,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue