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:
Max Brunsfeld 2018-02-28 22:46:47 -08:00
parent 4920373ca4
commit 0d9f854862
5 changed files with 61821 additions and 58288 deletions

View File

@ -93,12 +93,10 @@ fi
(program (program
(if_statement (if_statement
(command (bracket_command
(command_name (word))
(string (command_substitution (command (command_name (word))))) (string (command_substitution (command (command_name (word)))))
(word) (word)
(raw_string) (raw_string))
(word))
(command (command_name (word)) (word)))) (command (command_name (word)) (word))))
==================================== ====================================

View File

@ -27,12 +27,10 @@ echo ]]] ===
(command (command_name (word)) (word)) (command (command_name (word)) (word))
(command (command_name (word)) (word) (word)) (command (command_name (word)) (word) (word))
(list (list
(command (bracket_command
(command_name (word))
(string) (string)
(word) (word)
(concatenation (word) (word)) (concatenation (word) (word)))
(word))
(command (command
(command_name (word)) (command_name (word))
(concatenation (word))))) (concatenation (word)))))

View File

@ -56,6 +56,7 @@ module.exports = grammar({
$.variable_assignment, $.variable_assignment,
$.command, $.command,
$.declaration_command, $.declaration_command,
$.bracket_command,
$.for_statement, $.for_statement,
$.while_statement, $.while_statement,
$.if_statement, $.if_statement,
@ -178,6 +179,11 @@ module.exports = grammar({
$._statement $._statement
)), )),
bracket_command: $ => choice(
seq('[', repeat1($._expression), ']'),
seq('[[', repeat1($._expression), ']]')
),
// Commands // Commands
command: $ => prec.left(seq( command: $ => prec.left(seq(

49
src/grammar.json vendored
View File

@ -36,6 +36,10 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "declaration_command" "name": "declaration_command"
}, },
{
"type": "SYMBOL",
"name": "bracket_command"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "for_statement" "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": { "command": {
"type": "PREC_LEFT", "type": "PREC_LEFT",
"value": 0, "value": 0,

120042
src/parser.c vendored

File diff suppressed because it is too large Load Diff