aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/ast.c b/src/ast.c
new file mode 100644
index 0000000..719d48e
--- /dev/null
+++ b/src/ast.c
@@ -0,0 +1,41 @@
+#include "../include/ast.h"
+
+Ast ast_none() {
+ Ast ast;
+ ast.value.func_decl = NULL;
+ ast.type = AST_NONE;
+ return ast;
+}
+
+void ast_deinit(Ast *ast) {
+ /* TODO: Cleanup the different types of ast */
+ (void)ast;
+}
+
+void funcdecl_init(FunctionDecl *self) {
+ self->name = create_buffer_view_null();
+ buffer_init(&self->body);
+}
+
+void funcdecl_deinit(FunctionDecl *self) {
+ buffer_deinit(&self->body);
+}
+
+int funcdecl_add_to_body(FunctionDecl *self, Ast ast) {
+ return_if_error(buffer_append(&self->body, &ast, sizeof(ast)));
+ return BUFFER_OK;
+}
+
+void funccall_init(FunctionCall *self, BufferView name) {
+ self->name = name;
+}
+
+void lhsexpr_init(LhsExpr *self, int isConst, BufferView var_name) {
+ self->isConst = isConst;
+ self->var_name = var_name;
+ self->rhs_expr = ast_none();
+}
+
+void lhsexpr_deinit(LhsExpr *self) {
+ ast_deinit(&self->rhs_expr);
+} \ No newline at end of file