Add missing array syntax
This commit is contained in:
parent
2a034b5252
commit
145d4e86a4
|
@ -149,6 +149,7 @@ echo ${a[@]}
|
||||||
echo ${#b[@]}
|
echo ${#b[@]}
|
||||||
|
|
||||||
a[$i]=50
|
a[$i]=50
|
||||||
|
a+=(foo "bar" $(baz))
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -159,4 +160,10 @@ a[$i]=50
|
||||||
(command (command_name (word)) (expansion (variable_name)))
|
(command (command_name (word)) (expansion (variable_name)))
|
||||||
(environment_variable_assignment
|
(environment_variable_assignment
|
||||||
(subscript (variable_name) (simple_expansion (variable_name)))
|
(subscript (variable_name) (simple_expansion (variable_name)))
|
||||||
(word)))
|
(word))
|
||||||
|
(environment_variable_assignment
|
||||||
|
(variable_name)
|
||||||
|
(array
|
||||||
|
(word)
|
||||||
|
(string)
|
||||||
|
(command_substitution (command (command_name (word)))))))
|
||||||
|
|
|
@ -182,7 +182,10 @@ module.exports = grammar({
|
||||||
$.variable_name,
|
$.variable_name,
|
||||||
$.subscript
|
$.subscript
|
||||||
),
|
),
|
||||||
'=',
|
choice(
|
||||||
|
'=',
|
||||||
|
'+='
|
||||||
|
),
|
||||||
choice(
|
choice(
|
||||||
$._expression,
|
$._expression,
|
||||||
$.array,
|
$.array,
|
||||||
|
@ -271,7 +274,7 @@ module.exports = grammar({
|
||||||
|
|
||||||
array: $ => seq(
|
array: $ => seq(
|
||||||
'(',
|
'(',
|
||||||
repeat($.word),
|
repeat($._expression),
|
||||||
')'
|
')'
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
|
@ -602,8 +602,17 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "CHOICE",
|
||||||
"value": "="
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "+="
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
|
@ -939,7 +948,7 @@
|
||||||
"type": "REPEAT",
|
"type": "REPEAT",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "word"
|
"name": "_expression"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -170,14 +170,27 @@ struct Scanner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_number && valid_symbols[FILE_DESCRIPTOR] && (lexer->lookahead == '>' || lexer->lookahead == '<')) {
|
if (is_number &&
|
||||||
|
valid_symbols[FILE_DESCRIPTOR] &&
|
||||||
|
(lexer->lookahead == '>' || lexer->lookahead == '<')) {
|
||||||
lexer->result_symbol = FILE_DESCRIPTOR;
|
lexer->result_symbol = FILE_DESCRIPTOR;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid_symbols[VARIABLE_NAME] && (lexer->lookahead == '=' || lexer->lookahead == '[')) {
|
if (valid_symbols[VARIABLE_NAME]) {
|
||||||
lexer->result_symbol = VARIABLE_NAME;
|
if (lexer->lookahead == '+') {
|
||||||
return true;
|
lexer->mark_end(lexer);
|
||||||
|
advance(lexer);
|
||||||
|
if (lexer->lookahead == '=') {
|
||||||
|
lexer->result_symbol = VARIABLE_NAME;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (lexer->lookahead == '=' || lexer->lookahead == '[') {
|
||||||
|
lexer->result_symbol = VARIABLE_NAME;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue