From 235f8b5899b2c5b75cb83975695da1377f0cac0c Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Fri, 19 Aug 2011 18:27:47 +0000 Subject: [PATCH] THRIFT-1274. compiler: fail compilation if an unexpected token is encountered This patch makes the lexer throw an exception when an unexpected token is encountered, as opposed to the standard behavior of just printing it out and doing nothing. Patch: Adam Simpkins git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1159733 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/thriftl.ll | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/cpp/src/thriftl.ll b/compiler/cpp/src/thriftl.ll index 762cb2fd..c3d577e9 100644 --- a/compiler/cpp/src/thriftl.ll +++ b/compiler/cpp/src/thriftl.ll @@ -59,6 +59,11 @@ void integer_overflow(char* text) { exit(1); } +void unexpected_token(char* text) { + yyerror("Unexpected token in input: \"%s\"\n", text); + exit(1); +} + %} /** @@ -357,6 +362,10 @@ literal_begin (['\"]) } } +. { + unexpected_token(yytext); +} + . { /* Catch-all to let us catch "*" in the parser. */ -- 2.17.1