Skip to content
Permalink
Browse files
Stop parsing if the parser panics.
--HG--
branch : calculator-experiment
  • Loading branch information
icculus committed Feb 8, 2010
1 parent 8c720f9 commit 07e212ad05a2a99cb69a2231ddc02187ef2f24c6
Showing with 6 additions and 3 deletions.
  1. +1 −1 calculator.c
  2. +5 −2 calculator.lemon
@@ -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);
}

@@ -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)...

0 comments on commit 07e212a

Please sign in to comment.