Added a reminder in the Parser in the event of bad syntax.
This commit is contained in:
@@ -133,9 +133,13 @@ Expr* Primary() {
|
||||
if (Match(1, LParen)) {
|
||||
expr = Expression();
|
||||
|
||||
Expr* temp = calloc(1, sizeof(Expr));
|
||||
if (!Check(RParen)) printf("Unbalanced\n"); //Todo: something or another...
|
||||
if (!Check(RParen)) {
|
||||
free(expr);
|
||||
printf("Unbalanced\n"); //Todo: something or another...
|
||||
return NULL;
|
||||
}
|
||||
//Consume(RParen, "Expect ')' after expression.");
|
||||
Expr* temp = calloc(1, sizeof(Expr));
|
||||
temp->type = GROUPING;
|
||||
temp->expression.Grouping.expression = expr;
|
||||
|
||||
@@ -183,7 +187,11 @@ Token* AdvanceParser() {
|
||||
|
||||
return Previous();
|
||||
}
|
||||
|
||||
//In the Java implementation this get's called in catch blocks.
|
||||
//Obviously that's not going to fly in C, so I need some way to
|
||||
//"unwind" the stack. Maybe synchronizing (setting the Current variable)
|
||||
//will be enough, and simply return NULLs up the call stack.
|
||||
//Naive but might work in the future for this.
|
||||
void SynchronizeParser(void) {
|
||||
AdvanceParser();
|
||||
//Discard tokens until we find a statement boundary, or at least something that looks like one.
|
||||
|
||||
Reference in New Issue
Block a user