#include <stdio.h>
#include "ast.h"
+#include "list.h"
#include "parse.h"
int yylex(void);
struct stmt *stmt;
struct list *list;
struct vardecl *vardecl;
- struct decl *decl;
+ struct fundecl *fundecl;
struct type *type;
char *ident;
}
%right POWER
%type <ast> start
-%type <decl> fundecl
%type <expr> expr
%type <list> args body decls fargs field fnargs nargs funtype bbody
%type <stmt> stmt
%type <type> type ftype
%type <vardecl> vardecl
+%type <fundecl> fundecl
%%
decls
: /* empty */ { $$ = NULL; }
| decls vardecl { $$ = list_cons(decl_var($2), $1); }
- | decls fundecl { $$ = list_cons($2, $1); }
+ | decls fundecl { $$ = list_cons(decl_fun($2), $1); }
;
vardecl
: VAR IDENT ASSIGN expr SEMICOLON { $$ = vardecl(NULL, $2, $4); }
;
fundecl
: IDENT BOPEN args BCLOSE COPEN body CCLOSE
- { $$ = decl_fun($1, $3, NULL, NULL, $6); }
+ { $$ = fundecl($1, $3, NULL, NULL, $6); }
| IDENT BOPEN args BCLOSE CONS CONS funtype ARROW ftype COPEN body CCLOSE
- { $$ = decl_fun($1, $3, $7, $9, $11); }
+ { $$ = fundecl($1, $3, $7, $9, $11); }
;
funtype
: /* empty */ { $$ = NULL; }