work on type inference some more
[ccc.git] / parse.y
diff --git a/parse.y b/parse.y
index 6229385..29fa0ca 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -2,6 +2,7 @@
 #include <stdio.h>
 
 #include "ast.h"
+#include "list.h"
 #include "parse.h"
 
 int yylex(void);
@@ -28,7 +29,7 @@ int yywrap()
        struct stmt *stmt;
        struct list *list;
        struct vardecl *vardecl;
-       struct decl *decl;
+       struct fundecl *fundecl;
        struct type *type;
        char *ident;
 }
@@ -51,12 +52,12 @@ int yywrap()
 %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
 
 %%
 
@@ -64,7 +65,7 @@ start : decls { *result = ast($1); } ;
 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); }
@@ -72,9 +73,9 @@ vardecl
        ;
 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; }