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:
|
tmp:
|
||||||
- Finish varuse : ~
|
- Finish varuse : ~
|
||||||
- Fix crash on (newline)
|
|
||||||
|
|
||||||
- Load files
|
- Load files
|
||||||
- Benchmarks
|
- Benchmarks
|
||||||
|
|
|
@ -166,7 +166,6 @@ void print_ast(Statement *base){
|
||||||
#if LOG
|
#if LOG
|
||||||
printf("AST :\n");
|
printf("AST :\n");
|
||||||
print_ast1(base, 0);
|
print_ast1(base, 0);
|
||||||
printf("\n");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "config.h"
|
||||||
#include "byte_defs.h"
|
#include "byte_defs.h"
|
||||||
#include "code_defs.h"
|
#include "code_defs.h"
|
||||||
#include "exec_common.h"
|
#include "exec_common.h"
|
||||||
|
@ -56,6 +57,14 @@ Statement *make_iconst(i32 val){
|
||||||
return stat;
|
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){
|
Statement *make_strconst(char *str){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -144,7 +153,7 @@ Statement *make_operation(i32 type, Tag vtype, char *name, i32 nparam, ...){
|
||||||
#if LOG
|
#if LOG
|
||||||
printf("id : %d\n", ret->id);
|
printf("id : %d\n", ret->id);
|
||||||
#endif
|
#endif
|
||||||
if(ret->is_const && ret->type == T_fn){
|
if(ret->is_const && ((Tag*)&ret->type)->type == T_fn){
|
||||||
type = ST_Call;
|
type = ST_Call;
|
||||||
stat->func = ret->fnsig;
|
stat->func = ret->fnsig;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ Tag get_type(char *str);
|
||||||
|
|
||||||
Statement *make_iconst(i32 val);
|
Statement *make_iconst(i32 val);
|
||||||
|
|
||||||
//TODO
|
|
||||||
Statement *make_fconst(float val);
|
Statement *make_fconst(float val);
|
||||||
|
//TODO
|
||||||
Statement *make_strconst(char *str);
|
Statement *make_strconst(char *str);
|
||||||
|
|
||||||
Statement *declare(i32 type, Tag vtype, char *name, Statement *assign);
|
Statement *declare(i32 type, Tag vtype, char *name, Statement *assign);
|
||||||
|
|
|
@ -38,6 +38,11 @@
|
||||||
return G_IDENT;
|
return G_IDENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[0-9]+"."[0-9]+ {
|
||||||
|
yylval.st = make_fconst(atof(yytext));
|
||||||
|
return CST;
|
||||||
|
}
|
||||||
|
|
||||||
[0-9]+ {
|
[0-9]+ {
|
||||||
yylval.st = make_iconst(atoi(yytext));
|
yylval.st = make_iconst(atoi(yytext));
|
||||||
return CST;
|
return CST;
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
program:
|
program:
|
||||||
expr_list ';' {print_ast($1);execute($1);}
|
expr_list ';' {print_ast($1);execute($1);}
|
||||||
| expr_list YYEOF {execute($1);}
|
| expr_list YYEOF {print_ast($1);execute($1);}
|
||||||
;
|
;
|
||||||
|
|
||||||
type:
|
type:
|
||||||
|
|
Loading…
Add table
Reference in a new issue