preliminary work on sea of nodes based intermediate representation.
This commit is contained in:
parent
989a32fa7b
commit
849e0b6863
13 changed files with 918 additions and 58 deletions
9
lc.c
9
lc.c
|
|
@ -4,6 +4,7 @@
|
|||
#include "lexer.h"
|
||||
#include "parser.h"
|
||||
#include "sema.h"
|
||||
#include "ir.h"
|
||||
|
||||
void print_indent(int depth) {
|
||||
for (int i = 0; i < depth; i++) printf(" ");
|
||||
|
|
@ -17,6 +18,7 @@ const char* get_op_str(binary_op op) {
|
|||
case OP_MUL: return "*";
|
||||
case OP_EQ: return "==";
|
||||
case OP_ASSIGN: return "=";
|
||||
case OP_ASSIGN_PTR: return "<-";
|
||||
case OP_AND: return "&&";
|
||||
case OP_OR: return "||";
|
||||
case OP_NEQ: return "!=";
|
||||
|
|
@ -215,7 +217,7 @@ void print_ast(ast_node *node, int depth) {
|
|||
|
||||
int main(void)
|
||||
{
|
||||
FILE *fp = fopen("examples/hello_world.l", "r");
|
||||
FILE *fp = fopen("test.l", "r");
|
||||
usize size = 0;
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size = ftell(fp);
|
||||
|
|
@ -228,8 +230,11 @@ int main(void)
|
|||
arena a = arena_init(0x1000 * 0x1000 * 64);
|
||||
lexer *l = lexer_init(src, size, &a);
|
||||
parser *p = parser_init(l, &a);
|
||||
print_ast(p->ast, 0);
|
||||
//print_ast(p->ast, 0);
|
||||
sema *s = sema_init(p, &a);
|
||||
//(void) s;
|
||||
|
||||
ir_build(p->ast);
|
||||
|
||||
arena_deinit(a);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue