THRIFT-1274. compiler: fail compilation if an unexpected token is encountered
authorBryan Duxbury <bryanduxbury@apache.org>
Fri, 19 Aug 2011 18:27:47 +0000 (18:27 +0000)
committerBryan Duxbury <bryanduxbury@apache.org>
Fri, 19 Aug 2011 18:27:47 +0000 (18:27 +0000)
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

index 762cb2f..c3d577e 100644 (file)
@@ -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. */