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)))
|
||||||
(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
|
Variable expansions in strings
|
||||||
===================================
|
===================================
|
||||||
|
|
12
grammar.js
12
grammar.js
|
@ -322,9 +322,7 @@ module.exports = grammar({
|
||||||
seq(
|
seq(
|
||||||
$.variable_name,
|
$.variable_name,
|
||||||
'=',
|
'=',
|
||||||
optional(seq(
|
optional($._expression)
|
||||||
$._expression
|
|
||||||
))
|
|
||||||
),
|
),
|
||||||
seq(
|
seq(
|
||||||
choice(
|
choice(
|
||||||
|
@ -332,11 +330,9 @@ module.exports = grammar({
|
||||||
$._simple_variable_name,
|
$._simple_variable_name,
|
||||||
$._special_variable_name
|
$._special_variable_name
|
||||||
),
|
),
|
||||||
optional(seq(
|
repeat(choice(
|
||||||
choice(':', ':?', '=', ':-', '%', '/', '-'),
|
$._expression,
|
||||||
optional(seq(
|
':', ':?', '=', ':-', '%', '/', '-', '#'
|
||||||
$._expression
|
|
||||||
))
|
|
||||||
))
|
))
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue