Add special variable @, expressions in declarations
This commit is contained in:
parent
b13862adec
commit
4920373ca4
|
@ -48,6 +48,21 @@ echo $abc
|
||||||
(program
|
(program
|
||||||
(command (command_name (word)) (simple_expansion (variable_name))))
|
(command (command_name (word)) (simple_expansion (variable_name))))
|
||||||
|
|
||||||
|
=============================
|
||||||
|
Special variable expansions
|
||||||
|
=============================
|
||||||
|
|
||||||
|
echo $# $* $@
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(program
|
||||||
|
(command
|
||||||
|
(command_name (word))
|
||||||
|
(simple_expansion (special_variable_name))
|
||||||
|
(simple_expansion (special_variable_name))
|
||||||
|
(simple_expansion (special_variable_name))))
|
||||||
|
|
||||||
=============================
|
=============================
|
||||||
Variable expansions
|
Variable expansions
|
||||||
=============================
|
=============================
|
||||||
|
@ -286,6 +301,23 @@ export FOOBAR PATH="$PATH:/usr/foobar/bin"
|
||||||
(variable_name)
|
(variable_name)
|
||||||
(variable_assignment (variable_name) (string (simple_expansion (variable_name))))))
|
(variable_assignment (variable_name) (string (simple_expansion (variable_name))))))
|
||||||
|
|
||||||
|
===========================================
|
||||||
|
Expressions passed to declaration commands
|
||||||
|
===========================================
|
||||||
|
|
||||||
|
export "$(echo ${key} | tr [:lower:] [:upper:])=${p_key#*=}"
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(program
|
||||||
|
(declaration_command
|
||||||
|
(string
|
||||||
|
(command_substitution
|
||||||
|
(pipeline
|
||||||
|
(command (command_name (word)) (expansion (variable_name)))
|
||||||
|
(command (command_name (word)) (concatenation (word)) (concatenation (word)))))
|
||||||
|
(expansion (variable_name) (word)))))
|
||||||
|
|
||||||
=========================================
|
=========================================
|
||||||
Arrays and array expansions
|
Arrays and array expansions
|
||||||
=========================================
|
=========================================
|
||||||
|
|
13
grammar.js
13
grammar.js
|
@ -204,14 +204,14 @@ module.exports = grammar({
|
||||||
$._assignment
|
$._assignment
|
||||||
),
|
),
|
||||||
|
|
||||||
declaration_command: $ => seq(
|
declaration_command: $ => prec.left(seq(
|
||||||
choice('declare', 'typeset', 'export', 'readonly', 'local'),
|
choice('declare', 'typeset', 'export', 'readonly', 'local'),
|
||||||
repeat(choice(
|
repeat(choice(
|
||||||
$.word,
|
$._expression,
|
||||||
$._simple_variable_name,
|
$._simple_variable_name,
|
||||||
$.variable_assignment
|
$.variable_assignment
|
||||||
))
|
))
|
||||||
),
|
)),
|
||||||
|
|
||||||
_assignment: $ => seq(
|
_assignment: $ => seq(
|
||||||
choice(
|
choice(
|
||||||
|
@ -323,7 +323,12 @@ module.exports = grammar({
|
||||||
|
|
||||||
simple_expansion: $ => seq(
|
simple_expansion: $ => seq(
|
||||||
'$',
|
'$',
|
||||||
choice($._simple_variable_name, $._special_variable_name)
|
choice(
|
||||||
|
$._simple_variable_name,
|
||||||
|
$._special_variable_name,
|
||||||
|
alias('#', $.special_variable_name),
|
||||||
|
$.string
|
||||||
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
expansion: $ => seq(
|
expansion: $ => seq(
|
||||||
|
|
|
@ -676,6 +676,9 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"declaration_command": {
|
"declaration_command": {
|
||||||
|
"type": "PREC_LEFT",
|
||||||
|
"value": 0,
|
||||||
|
"content": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
|
@ -710,7 +713,7 @@
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "word"
|
"name": "_expression"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
|
@ -724,6 +727,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"_assignment": {
|
"_assignment": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
|
@ -1180,6 +1184,19 @@
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_special_variable_name"
|
"name": "_special_variable_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "#"
|
||||||
|
},
|
||||||
|
"named": true,
|
||||||
|
"value": "special_variable_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "string"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue