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
diff --git a/compiler/cpp/src/thriftl.ll b/compiler/cpp/src/thriftl.ll
index 762cb2f..c3d577e 100644
--- a/compiler/cpp/src/thriftl.ll
+++ b/compiler/cpp/src/thriftl.ll
@@ -59,6 +59,11 @@
exit(1);
}
+void unexpected_token(char* text) {
+ yyerror("Unexpected token in input: \"%s\"\n", text);
+ exit(1);
+}
+
%}
/**
@@ -357,6 +362,10 @@
}
}
+. {
+ unexpected_token(yytext);
+}
+
. {
/* Catch-all to let us catch "*" in the parser. */