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:
parent
0477cc4460
commit
38e8ba4a3d
|
@ -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
|
||||
|
|
|
@ -213,7 +213,13 @@ module.exports = grammar({
|
|||
'(', ')'
|
||||
)
|
||||
),
|
||||
field('body', $.compound_statement)
|
||||
field(
|
||||
'body',
|
||||
choice(
|
||||
$.compound_statement,
|
||||
$.subshell,
|
||||
$.test_command)
|
||||
)
|
||||
),
|
||||
|
||||
compound_statement: $ => seq(
|
||||
|
|
|
@ -839,8 +839,21 @@
|
|||
"type": "FIELD",
|
||||
"name": "body",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "compound_statement"
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "compound_statement"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "subshell"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "test_command"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -714,6 +714,14 @@
|
|||
{
|
||||
"type": "compound_statement",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "subshell",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "test_command",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue