Expand function definition to support subshell and tests (#83)

Fixes https://github.com/tree-sitter/tree-sitter-bash/issues/60
This commit is contained in:
Kenneth Skovhus 2020-05-15 20:25:46 +02:00 committed by GitHub
parent 0477cc4460
commit 38e8ba4a3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 74753 additions and 74524 deletions

View File

@ -365,6 +365,12 @@ do_something() {
echo ok
}
run_subshell_command() (
true
)
run_test_command() [[ -e foo ]]
function do_something_else() {
a | xargs -I{} find xml/{} -type f
}
@ -379,6 +385,12 @@ function do_yet_another_thing {
(function_definition
(word)
(compound_statement (command (command_name (word)) (word))))
(function_definition
(word)
(subshell (command (command_name (word)))))
(function_definition
(word)
(test_command (unary_expression (test_operator) (word))))
(function_definition
(word)
(compound_statement

View File

@ -213,7 +213,13 @@ module.exports = grammar({
'(', ')'
)
),
field('body', $.compound_statement)
field(
'body',
choice(
$.compound_statement,
$.subshell,
$.test_command)
)
),
compound_statement: $ => seq(

13
src/grammar.json vendored
View File

@ -839,8 +839,21 @@
"type": "FIELD",
"name": "body",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "compound_statement"
},
{
"type": "SYMBOL",
"name": "subshell"
},
{
"type": "SYMBOL",
"name": "test_command"
}
]
}
}
]

8
src/node-types.json vendored
View File

@ -714,6 +714,14 @@
{
"type": "compound_statement",
"named": true
},
{
"type": "subshell",
"named": true
},
{
"type": "test_command",
"named": true
}
]
},

149232
src/parser.c vendored

File diff suppressed because it is too large Load Diff