Revert "Don't parse square bracket commands as special syntax"
This reverts commit c34619a1c4
.
Bracket command syntax was actually not interfering with the parsing
of words with special characters.
This commit is contained in:
parent
4920373ca4
commit
0d9f854862
|
@ -93,12 +93,10 @@ fi
|
|||
|
||||
(program
|
||||
(if_statement
|
||||
(command
|
||||
(command_name (word))
|
||||
(bracket_command
|
||||
(string (command_substitution (command (command_name (word)))))
|
||||
(word)
|
||||
(raw_string)
|
||||
(word))
|
||||
(raw_string))
|
||||
(command (command_name (word)) (word))))
|
||||
|
||||
====================================
|
||||
|
|
|
@ -27,12 +27,10 @@ echo ]]] ===
|
|||
(command (command_name (word)) (word))
|
||||
(command (command_name (word)) (word) (word))
|
||||
(list
|
||||
(command
|
||||
(command_name (word))
|
||||
(bracket_command
|
||||
(string)
|
||||
(word)
|
||||
(concatenation (word) (word))
|
||||
(word))
|
||||
(concatenation (word) (word)))
|
||||
(command
|
||||
(command_name (word))
|
||||
(concatenation (word)))))
|
||||
|
|
|
@ -56,6 +56,7 @@ module.exports = grammar({
|
|||
$.variable_assignment,
|
||||
$.command,
|
||||
$.declaration_command,
|
||||
$.bracket_command,
|
||||
$.for_statement,
|
||||
$.while_statement,
|
||||
$.if_statement,
|
||||
|
@ -178,6 +179,11 @@ module.exports = grammar({
|
|||
$._statement
|
||||
)),
|
||||
|
||||
bracket_command: $ => choice(
|
||||
seq('[', repeat1($._expression), ']'),
|
||||
seq('[[', repeat1($._expression), ']]')
|
||||
),
|
||||
|
||||
// Commands
|
||||
|
||||
command: $ => prec.left(seq(
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
"type": "SYMBOL",
|
||||
"name": "declaration_command"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "bracket_command"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "for_statement"
|
||||
|
@ -593,6 +597,51 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"bracket_command": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "["
|
||||
},
|
||||
{
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "[["
|
||||
},
|
||||
{
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "]]"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"command": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue