Add missing function definition forms

This commit is contained in:
Max Brunsfeld 2017-12-26 14:27:05 -08:00
parent 75833b90ea
commit 52d54bb173
4 changed files with 17619 additions and 15346 deletions

View File

@ -129,8 +129,20 @@ function do_something_else() {
echo ok echo ok
} }
function do_yet_another_thing {
echo ok
} 2>&1
--- ---
(program (program
(function_definition (word) (compound_statement (command (command_name (word)) (word)))) (function_definition
(function_definition (word) (compound_statement (command (command_name (word)) (word))))) (word)
(compound_statement (command (command_name (word)) (word))))
(function_definition
(word)
(compound_statement (command (command_name (word)) (word))))
(function_definition
(word)
(compound_statement (command (command_name (word)) (word)))
(file_redirect (file_descriptor) (word))))

View File

@ -124,9 +124,9 @@ module.exports = grammar({
function_definition: $ => seq( function_definition: $ => seq(
optional('function'), optional('function'),
$.word, $.word,
'(', optional(seq('(', ')')),
')', $.compound_statement,
$.compound_statement optional($.file_redirect)
), ),
compound_statement: $ => seq( compound_statement: $ => seq(

37
src/grammar.json vendored
View File

@ -330,16 +330,41 @@
"name": "word" "name": "word"
}, },
{ {
"type": "STRING", "type": "CHOICE",
"value": "(" "members": [
}, {
{ "type": "SEQ",
"type": "STRING", "members": [
"value": ")" {
"type": "STRING",
"value": "("
},
{
"type": "STRING",
"value": ")"
}
]
},
{
"type": "BLANK"
}
]
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "compound_statement" "name": "compound_statement"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "file_redirect"
},
{
"type": "BLANK"
}
]
} }
] ]
}, },

32906
src/parser.c vendored

File diff suppressed because it is too large Load Diff