It werks
This commit is contained in:
parent
6128ab0884
commit
f5d8b75987
6 changed files with 17 additions and 5 deletions
1
TODO.md
1
TODO.md
|
@ -1,6 +1,5 @@
|
|||
tmp:
|
||||
- Finish varuse : ~
|
||||
- Fix crash on (newline)
|
||||
|
||||
- Load files
|
||||
- Benchmarks
|
||||
|
|
|
@ -166,7 +166,6 @@ void print_ast(Statement *base){
|
|||
#if LOG
|
||||
printf("AST :\n");
|
||||
print_ast1(base, 0);
|
||||
printf("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "config.h"
|
||||
#include "byte_defs.h"
|
||||
#include "code_defs.h"
|
||||
#include "exec_common.h"
|
||||
|
@ -56,6 +57,14 @@ Statement *make_iconst(i32 val){
|
|||
return stat;
|
||||
}
|
||||
|
||||
Statement *make_fconst(float val){
|
||||
Statement *stat = &stack->statements[stack->curr_statement++];
|
||||
stat->type = ST_Const;
|
||||
stat->cons = (Value){{.v4B = {.vfl=val}},{.is_array=0,.type=T_float}};
|
||||
stat->child_n = 0;
|
||||
return stat;
|
||||
}
|
||||
|
||||
Statement *make_strconst(char *str){
|
||||
|
||||
}
|
||||
|
@ -144,7 +153,7 @@ Statement *make_operation(i32 type, Tag vtype, char *name, i32 nparam, ...){
|
|||
#if LOG
|
||||
printf("id : %d\n", ret->id);
|
||||
#endif
|
||||
if(ret->is_const && ret->type == T_fn){
|
||||
if(ret->is_const && ((Tag*)&ret->type)->type == T_fn){
|
||||
type = ST_Call;
|
||||
stat->func = ret->fnsig;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ Tag get_type(char *str);
|
|||
|
||||
Statement *make_iconst(i32 val);
|
||||
|
||||
//TODO
|
||||
Statement *make_fconst(float val);
|
||||
//TODO
|
||||
Statement *make_strconst(char *str);
|
||||
|
||||
Statement *declare(i32 type, Tag vtype, char *name, Statement *assign);
|
||||
|
|
|
@ -38,6 +38,11 @@
|
|||
return G_IDENT;
|
||||
}
|
||||
|
||||
[0-9]+"."[0-9]+ {
|
||||
yylval.st = make_fconst(atof(yytext));
|
||||
return CST;
|
||||
}
|
||||
|
||||
[0-9]+ {
|
||||
yylval.st = make_iconst(atoi(yytext));
|
||||
return CST;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
program:
|
||||
expr_list ';' {print_ast($1);execute($1);}
|
||||
| expr_list YYEOF {execute($1);}
|
||||
| expr_list YYEOF {print_ast($1);execute($1);}
|
||||
;
|
||||
|
||||
type:
|
||||
|
|
Loading…
Add table
Reference in a new issue