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:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user