return res;
}
-struct vardecl vardecl(char *ident, struct expr *expr)
-{
- return (struct vardecl) {.ident=ident, .expr=expr};
-}
-
struct decl *decl_fun(char *ident, struct list *args, struct list *body)
{
struct decl *res = safe_malloc(sizeof(struct decl));
return;
for (int i = 0; i<ast->ndecls; i++)
decl_free(ast->decls[i]);
+ free(ast->decls);
free(ast);
}
struct ast *ast(struct list *decls);
-struct vardecl vardecl(char *ident, struct expr *expr);
-
struct decl *decl_fun(char *ident, struct list *args, struct list *body);
struct decl *decl_var(struct vardecl vardecl);
--- /dev/null
+var x = 5 == 5;
+var y = x;
+fun(x){
+ var x = 5;
+ 6;
+ if(true){5;}else{5;}
+ '\t';
+return 5;
+f();
+f(x); f(1, 2, []);
+y = 5+x.fst.snd;
+}
| decls fundecl { $$ = list_cons($2, $1); }
;
vardecl
- : VAR IDENT ASSIGN expr { $$ = vardecl($2, $4); }
+ : VAR IDENT ASSIGN expr { $$ = (struct vardecl) {.ident=$2, .expr=$4}; }
;
fundecl
: IDENT BOPEN args BCLOSE COPEN body CCLOSE