Added statements to the Parser, currently just the Print and Expression statements. 8.1 isn't quite done yet, maybe half way there.

This commit is contained in:
2022-03-23 19:43:46 +00:00
parent bf59a98628
commit 73067fcc1f
5 changed files with 79 additions and 2 deletions
+21
View File
@@ -0,0 +1,21 @@
#include "statement.h"
Stmt* CreateStatement(Expr* expression, StatementType type) {
Stmt* stmt = calloc(1, sizeof(Stmt));
if (!stmt) {
fprintf(stderr, "Failed to calloc space for Statement. %s.\n", strerror(errno));
return NULL;
}
stmt->expression = expression;
stmt->type = type;
return stmt;
}
void FreeStatement(Stmt* stmt) {
if (!stmt) return;
free(stmt);
}