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
}
function do_yet_another_thing {
echo ok
} 2>&1
---
(program
(function_definition (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))))
(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(
optional('function'),
$.word,
'(',
')',
$.compound_statement
optional(seq('(', ')')),
$.compound_statement,
optional($.file_redirect)
),
compound_statement: $ => seq(

25
src/grammar.json vendored
View File

@ -329,6 +329,12 @@
"type": "SYMBOL",
"name": "word"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
@ -336,10 +342,29 @@
{
"type": "STRING",
"value": ")"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"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