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
(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))))
====================================

View File

@ -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)))))

View File

@ -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(

49
src/grammar.json vendored
View File

@ -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,

120042
src/parser.c vendored

File diff suppressed because it is too large Load Diff