Generalize parsing of expansion operators
This commit is contained in:
parent
86c5561ba8
commit
2a5b01b885
|
@ -66,6 +66,27 @@ echo ${abc:
|
|||
(command (command_name (word)) (expansion (variable_name)))
|
||||
(command (command_name (word)) (expansion (variable_name))))
|
||||
|
||||
===================================
|
||||
Variable expansions with operators
|
||||
===================================
|
||||
|
||||
A="${B[0]# }"
|
||||
C="${D/#* -E /}"
|
||||
F="${G%% *}"
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(variable_assignment
|
||||
(variable_name)
|
||||
(string (expansion (subscript (variable_name) (word)))))
|
||||
(variable_assignment
|
||||
(variable_name)
|
||||
(string (expansion (variable_name) (word) (word))))
|
||||
(variable_assignment
|
||||
(variable_name)
|
||||
(string (expansion (variable_name) (word) (word)))))
|
||||
|
||||
===================================
|
||||
Variable expansions in strings
|
||||
===================================
|
||||
|
|
12
grammar.js
12
grammar.js
|
@ -322,9 +322,7 @@ module.exports = grammar({
|
|||
seq(
|
||||
$.variable_name,
|
||||
'=',
|
||||
optional(seq(
|
||||
$._expression
|
||||
))
|
||||
optional($._expression)
|
||||
),
|
||||
seq(
|
||||
choice(
|
||||
|
@ -332,11 +330,9 @@ module.exports = grammar({
|
|||
$._simple_variable_name,
|
||||
$._special_variable_name
|
||||
),
|
||||
optional(seq(
|
||||
choice(':', ':?', '=', ':-', '%', '/', '-'),
|
||||
optional(seq(
|
||||
$._expression
|
||||
))
|
||||
repeat(choice(
|
||||
$._expression,
|
||||
':', ':?', '=', ':-', '%', '/', '-', '#'
|
||||
))
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue