2024-05-07 13:22:52 +00:00
|
|
|
//
|
|
|
|
// Created by servostar on 5/7/24.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <ast/ast.h>
|
|
|
|
#include <sys/log.h>
|
2024-06-05 18:00:14 +00:00
|
|
|
#include <mem/cache.h>
|
2024-05-07 13:22:52 +00:00
|
|
|
|
|
|
|
int main(void) {
|
2024-06-05 18:00:14 +00:00
|
|
|
mem_init();
|
2024-05-07 13:22:52 +00:00
|
|
|
|
2024-07-02 14:43:59 +00:00
|
|
|
struct AST_Node_t* node = AST_new_node(empty_location(NULL), AST_If, NULL);
|
2024-05-07 13:22:52 +00:00
|
|
|
|
2024-07-02 14:43:59 +00:00
|
|
|
struct AST_Node_t* child = AST_new_node(empty_location(NULL), AST_Add, NULL);
|
|
|
|
AST_push_node(child, AST_new_node(empty_location(NULL), AST_Int, "43"));
|
|
|
|
AST_push_node(child, AST_new_node(empty_location(NULL), AST_Int, "9"));
|
2024-05-07 13:22:52 +00:00
|
|
|
|
|
|
|
AST_push_node(node, child);
|
2024-07-02 14:43:59 +00:00
|
|
|
AST_push_node(node, AST_new_node(empty_location(NULL), AST_Expr, NULL));
|
|
|
|
AST_push_node(node, AST_new_node(empty_location(NULL), AST_Expr, NULL));
|
2024-05-07 13:22:52 +00:00
|
|
|
|
|
|
|
FILE* out = fopen("ast.gv", "w+");
|
|
|
|
// convert this file ^^^^^^
|
|
|
|
// to an svg with: `dot -Tsvg ast.gv > graph.svg`
|
|
|
|
|
|
|
|
AST_fprint_graphviz(out, node);
|
|
|
|
|
|
|
|
AST_delete_node(node);
|
|
|
|
|
|
|
|
fflush(out);
|
|
|
|
fclose(out);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|