From bfdc8d2d843c08bd01517256a63518d03da236f6 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 27 Jul 2021 21:10:34 +0200 Subject: Started treeify --- inc/treeify.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 inc/treeify.h (limited to 'inc/treeify.h') diff --git a/inc/treeify.h b/inc/treeify.h new file mode 100644 index 0000000..3af67f8 --- /dev/null +++ b/inc/treeify.h @@ -0,0 +1,71 @@ +#ifndef TREEIFY_H +#define TREEIFY_H + +#include + +enum node_type { + EXPRESSION, + DECLARATION, +}; + +/** + * Expressions + */ + +// (*f* x y) +struct node_expression_identifier { + ctx_string name; // f + ctx_string type; // u32 +}; + +// (f *x* *y*) +struct node_expression_parameter { + ctx_string name; // x or y + ctx_string type; // u32 +}; + +// *(f x y)* +struct node_expression { + struct node_expression_identifier *callee; // f + struct node_expression_parameter *parameters; // x y +}; + +/** + * Declarations + */ + +// *u32:f* u32:x u32:y = (...) +struct node_declaration_callee { + ctx_string name; // f + ctx_string type; // u32 +}; + +// u32:f *u32:x* *u32:y* = (...) +struct node_declaration_parameter { + ctx_string name; // x or y + ctx_string type; // u32 +}; + +// *u32:f u32:x u32:y* = (...) OR +// *u32:a* = ... +struct node_declaration { + struct node_declaration_callee callee; // f + struct node_declaration_parameter *parameters; // x y OR NULL +}; + +struct node { + enum node_type type; + /* struct node *next; */ + void *data; +}; + +struct tree { + struct node *node; +}; + +struct tree *tree_create(void); +void tree_destroy(struct tree *tree); + +void treeify(struct ctx *ctx); + +#endif -- cgit v1.2.3