THRIFT-3477 Parser fails on enum item that starts with 'E' letter and continues with number
Client: Compiler (general)
Patch: Jens Geyer
Fixes the issue with negative doubles. The "-" was recognized as valid st_identifier, which is only a leftover from THRIFT-3416 that is no longer used at all.
diff --git a/compiler/cpp/src/thriftl.ll b/compiler/cpp/src/thriftl.ll
index 7e68dbc..e3478a6 100644
--- a/compiler/cpp/src/thriftl.ll
+++ b/compiler/cpp/src/thriftl.ll
@@ -116,7 +116,6 @@
comment ("//"[^\n]*)
unixcomment ("#"[^\n]*)
symbol ([:;\,\{\}\(\)\=<>\[\]])
-st_identifier ([a-zA-Z-](\.[a-zA-Z_0-9-]|[a-zA-Z_0-9-])*)
literal_begin (['\"])
%%
@@ -330,11 +329,6 @@
return tok_identifier;
}
-{st_identifier} {
- yylval.id = strdup(yytext);
- return tok_st_identifier;
-}
-
{dubconstant} {
/* Deliberately placed after identifier, since "e10" is NOT a double literal (THRIFT-3477) */
yylval.dconst = atof(yytext);
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index 546196a..dee4cb9 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -99,7 +99,6 @@
%token<id> tok_identifier
%token<id> tok_literal
%token<dtext> tok_doctext
-%token<id> tok_st_identifier
/**
* Constant values
diff --git a/test/ConstantsDemo.thrift b/test/ConstantsDemo.thrift
index 0e3c1d9..b99bdb2 100644
--- a/test/ConstantsDemo.thrift
+++ b/test/ConstantsDemo.thrift
@@ -48,6 +48,7 @@
const string GEN_STRING = "asldkjasfd"
const double e10 = 1e10 // fails with 0.9.3 and earlier
+const double e11 = -1e10
const map<i32,i32> GEN_MAP = { 35532 : 233, 43523 : 853 }
const list<i32> GEN_LIST = [ 235235, 23598352, 3253523 ]