Refactor FunctionDefinition towards instance methods (#654)

It felt weird to have a `Make` method in this case.
This commit is contained in:
Jon Meow
2021-07-15 14:55:44 -07:00
committed by GitHub
parent d2afd45214
commit ef785bb6e3
5 changed files with 28 additions and 35 deletions
+6 -5
View File
@@ -370,17 +370,18 @@ return_type:
;
function_definition:
FN identifier tuple return_type "{" statement_list "}"
{ $$ = MakeFunDef(yylineno, $2, $4, $3, $6); }
{ $$ = Carbon::FunctionDefinition(yylineno, $2, $3, $4, $6); }
| FN identifier tuple DBLARROW expression ";"
{
$$ = Carbon::MakeFunDef(yylineno, $2,
Carbon::Expression::MakeAutoTypeLiteral(yylineno),
$3, Carbon::Statement::MakeReturn(yylineno, $5));
$$ = Carbon::FunctionDefinition(
yylineno, $2, $3,
Carbon::Expression::MakeAutoTypeLiteral(yylineno),
Carbon::Statement::MakeReturn(yylineno, $5));
}
;
function_declaration:
FN identifier tuple return_type ";"
{ $$ = MakeFunDef(yylineno, $2, $4, $3, 0); }
{ $$ = Carbon::FunctionDefinition(yylineno, $2, $3, $4, 0); }
;
variable_declaration: identifier ":" expression
{ $$ = MakeField(yylineno, $1, $3); }