From 6c928f3f5f91afa0917f4625f39b4048865a6027 Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Thu, 13 Oct 2011 21:32:52 +0000 Subject: [PATCH] THRIFT-1130. compiler: Add the ability to specify symbolic default value for optional boolean Patch: Nevo Hed git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1183115 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/thriftl.ll | 5 +++-- test/ThriftTest.thrift | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/cpp/src/thriftl.ll b/compiler/cpp/src/thriftl.ll index af033d6a..ab0976ef 100644 --- a/compiler/cpp/src/thriftl.ll +++ b/compiler/cpp/src/thriftl.ll @@ -110,6 +110,9 @@ literal_begin (['\"]) {symbol} { return yytext[0]; } "*" { return yytext[0]; } +"false" { yylval.iconst=0; return tok_int_constant; } +"true" { yylval.iconst=1; return tok_int_constant; } + "namespace" { return tok_namespace; } "cpp_namespace" { return tok_cpp_namespace; } "cpp_include" { return tok_cpp_include; } @@ -204,7 +207,6 @@ literal_begin (['\"]) "ensure" { thrift_reserved_keyword(yytext); } "except" { thrift_reserved_keyword(yytext); } "exec" { thrift_reserved_keyword(yytext); } -"false" { thrift_reserved_keyword(yytext); } "finally" { thrift_reserved_keyword(yytext); } "float" { thrift_reserved_keyword(yytext); } "for" { thrift_reserved_keyword(yytext); } @@ -250,7 +252,6 @@ literal_begin (['\"]) "this" { thrift_reserved_keyword(yytext); } "throw" { thrift_reserved_keyword(yytext); } "transient" { thrift_reserved_keyword(yytext); } -"true" { thrift_reserved_keyword(yytext); } "try" { thrift_reserved_keyword(yytext); } "undef" { thrift_reserved_keyword(yytext); } "union" { thrift_reserved_keyword(yytext); } diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift index 17b0295c..51f42b4f 100644 --- a/test/ThriftTest.thrift +++ b/test/ThriftTest.thrift @@ -226,3 +226,8 @@ struct ListBonks { struct NestedListsBonk { 1: list>> bonk } + +struct BoolTest { + 1: optional bool b = true; + 2: optional string s = "true"; +} -- 2.17.1