THRIFT-3477 Parser fails on enum item that starts with 'E' letter and continues with number
Client: Compiler (general)
Patch: Jens Geyer
diff --git a/compiler/cpp/src/thriftl.ll b/compiler/cpp/src/thriftl.ll
index 76acda1..7e68dbc 100644
--- a/compiler/cpp/src/thriftl.ll
+++ b/compiler/cpp/src/thriftl.ll
@@ -325,11 +325,6 @@
   return tok_int_constant;
 }
 
-{dubconstant} {
-  yylval.dconst = atof(yytext);
-  return tok_dub_constant;
-}
-
 {identifier} {
   yylval.id = strdup(yytext);
   return tok_identifier;
@@ -340,6 +335,12 @@
   return tok_st_identifier;
 }
 
+{dubconstant} {
+ /* Deliberately placed after identifier, since "e10" is NOT a double literal (THRIFT-3477) */
+  yylval.dconst = atof(yytext);
+  return tok_dub_constant;
+}
+
 {literal_begin} {
   char mark = yytext[0];
   std::string result;
diff --git a/test/ConstantsDemo.thrift b/test/ConstantsDemo.thrift
index 9a71ac8..0e3c1d9 100644
--- a/test/ConstantsDemo.thrift
+++ b/test/ConstantsDemo.thrift
@@ -47,6 +47,8 @@
 const double GEn_DU = 085.2355
 const string GEN_STRING = "asldkjasfd"
 
+const double e10 = 1e10   // fails with 0.9.3 and earlier
+
 const map<i32,i32> GEN_MAP = { 35532 : 233, 43523 : 853 }
 const list<i32> GEN_LIST = [ 235235, 23598352, 3253523 ]
 
diff --git a/test/EnumTest.thrift b/test/EnumTest.thrift
index 17af408..f38cec3 100644
--- a/test/EnumTest.thrift
+++ b/test/EnumTest.thrift
@@ -66,6 +66,11 @@
   // represented with an i32.
 }
 
+enum MyEnum5 {
+  e1        // fails with 0.9.3 and earlier
+  e2 = 42   // fails with 0.9.3 and earlier
+}
+
 struct MyStruct {
   1: MyEnum2 me2_2 = MyEnum1.ME2_2
   2: MyEnum3 me3_n2 = MyEnum3.ME3_N2