Add missing array syntax
This commit is contained in:
parent
2a034b5252
commit
145d4e86a4
|
@ -149,6 +149,7 @@ echo ${a[@]}
|
|||
echo ${#b[@]}
|
||||
|
||||
a[$i]=50
|
||||
a+=(foo "bar" $(baz))
|
||||
|
||||
---
|
||||
|
||||
|
@ -159,4 +160,10 @@ a[$i]=50
|
|||
(command (command_name (word)) (expansion (variable_name)))
|
||||
(environment_variable_assignment
|
||||
(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,
|
||||
$.subscript
|
||||
),
|
||||
'=',
|
||||
choice(
|
||||
'=',
|
||||
'+='
|
||||
),
|
||||
choice(
|
||||
$._expression,
|
||||
$.array,
|
||||
|
@ -271,7 +274,7 @@ module.exports = grammar({
|
|||
|
||||
array: $ => seq(
|
||||
'(',
|
||||
repeat($.word),
|
||||
repeat($._expression),
|
||||
')'
|
||||
),
|
||||
|
||||
|
|
|
@ -602,8 +602,17 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "="
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "="
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "+="
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
|
@ -939,7 +948,7 @@
|
|||
"type": "REPEAT",
|
||||
"content": {
|
||||
"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;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (valid_symbols[VARIABLE_NAME] && (lexer->lookahead == '=' || lexer->lookahead == '[')) {
|
||||
lexer->result_symbol = VARIABLE_NAME;
|
||||
return true;
|
||||
if (valid_symbols[VARIABLE_NAME]) {
|
||||
if (lexer->lookahead == '+') {
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue