Skip to content

Commit

Permalink
Stop parsing if the parser panics.
Browse files Browse the repository at this point in the history
--HG--
branch : calculator-experiment
  • Loading branch information
icculus committed Feb 8, 2010
1 parent 8c720f9 commit 07e212a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion calculator.c
Expand Up @@ -526,7 +526,7 @@ static void MOJOSHADER_compile(const char *filename,
// !!! FIXME: when a rule reduces down later.
TokenData token = { ctx.token, ctx.tokenlen };
ParseCalculator(pParser, convert_to_lemon_token(&ctx), token, &ctx);
} while (ctx.tokenval != TOKEN_EOI);
} while ((!ctx.isfail) && (ctx.tokenval != TOKEN_EOI));
ParseCalculatorFree(pParser, f, d);
}

Expand Down
7 changes: 5 additions & 2 deletions calculator.lemon
Expand Up @@ -36,11 +36,14 @@
}

%parse_failure {
fprintf(stderr,"Giving up. Parser is hopelessly lost...\n");
ctx->isfail = 1;
fprintf(stderr, "Giving up. Parser is hopelessly lost...\n");

}

%stack_overflow {
fprintf(stderr,"Giving up. Parser stack overflow\n");
ctx->isfail = 1;
fprintf(stderr, "Giving up. Parser stack overflow\n");
}

// operator precedence (matches C spec)...
Expand Down

0 comments on commit 07e212a

Please sign in to comment.