'Minor' bug fix for the StatementList, forgot to set the capacity.
This commit is contained in:
@@ -50,7 +50,7 @@ void RunFile(const char* path) {
|
||||
StatementList* statements = Parse(tokens);
|
||||
//PrintExpressionTree(tree);
|
||||
printf("\n");
|
||||
Interpret(tree);
|
||||
//Interpret(tree);
|
||||
FreeStatementList(statements);
|
||||
//FreeExpressionTree(tree);
|
||||
DestroyTokenList(tokens);
|
||||
|
||||
+10
-2
@@ -64,7 +64,10 @@ Stmt* Statement(void) {
|
||||
Stmt* PrintStatement(void) {
|
||||
Expr* value = Expression();
|
||||
|
||||
if (!Match(1, Semicolon)) fprintf(stderr, "Expected ';' after value\n");
|
||||
if (!Match(1, Semicolon)) {
|
||||
fprintf(stderr, "Expected ';' after value\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AdvanceParser();
|
||||
|
||||
@@ -74,7 +77,10 @@ Stmt* PrintStatement(void) {
|
||||
Stmt* ExpressionStatement(void) {
|
||||
Expr* expr = Expression();
|
||||
|
||||
if (!Match(1, Semicolon)) fprintf(stderr, "Expected ';' after expression\n");
|
||||
if (!Match(1, Semicolon)) {
|
||||
fprintf(stderr, "Expected ';' after expression\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AdvanceParser();
|
||||
|
||||
@@ -333,6 +339,8 @@ StatementList* CreateStatementList(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
list->capacity = STATEMENTLIST_DEFAULT_SIZE;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user