Thrift supports HEX notation for int consts and proper python/php sets

Reviewed By: yishan-tbr


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664883 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/thrift.l b/compiler/cpp/src/thrift.l
index 0c113cb..a353786 100644
--- a/compiler/cpp/src/thrift.l
+++ b/compiler/cpp/src/thrift.l
@@ -28,6 +28,7 @@
  */
 
 intconstant  ([+-]?[0-9]+)
+hexconstant  ("0x"[0-9A-Fa-f]+)
 dubconstant  ([+-]?[0-9]*(\.[0-9]+)?([eE][+-]?[0-9]+)?)
 identifier   ([a-zA-Z_][\.a-zA-Z_0-9]*)
 whitespace   ([ \t\r\n]*)
@@ -80,6 +81,12 @@
   return tok_int_constant;
 }
 
+{hexconstant} {
+  sscanf(yytext+2, "%x", &yylval.iconst);
+  printf("%d\n", yylval.iconst);
+  return tok_int_constant;
+}
+
 {dubconstant} {
   yylval.dconst = atof(yytext);
   return tok_dub_constant;