Repository: thrift Updated Branches: refs/heads/master e52c046cb -> 89847dfaa
THRIFT-2499 Compiler: allow annotations without "= value" Client: compiler general Patch: Dave Watson This closes #87 commit 078ce57e816eeb3697acf6f2c50e09526da73d3b Author: Dave Watson <[email protected]> Date: 2014-03-21T19:42:31Z [thrift] Compiler: allow annotations without "= value" Summary: (foo) is the same as (foo = 1), for brevity Test: AnnotationTest.thrift still compiles Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/89847dfa Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/89847dfa Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/89847dfa Branch: refs/heads/master Commit: 89847dfaa014bb17bc68ca1167d3b295c5d3a357 Parents: e52c046 Author: Jens Geyer <[email protected]> Authored: Fri May 2 23:50:04 2014 +0200 Committer: Jens Geyer <[email protected]> Committed: Fri May 2 23:50:04 2014 +0200 ---------------------------------------------------------------------- compiler/cpp/src/thrifty.yy | 19 ++++++++++++++++--- test/AnnotationTest.thrift | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/89847dfa/compiler/cpp/src/thrifty.yy ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy index 62e13ba..da5c562 100644 --- a/compiler/cpp/src/thrifty.yy +++ b/compiler/cpp/src/thrifty.yy @@ -187,6 +187,7 @@ const int struct_is_union = 1; %type<ttype> TypeAnnotations %type<ttype> TypeAnnotationList %type<tannot> TypeAnnotation +%type<id> TypeAnnotationValue %type<tfield> Field %type<tfieldid> FieldIdentifier @@ -1273,12 +1274,24 @@ TypeAnnotationList: } TypeAnnotation: - tok_identifier '=' tok_literal CommaOrSemicolonOptional + tok_identifier TypeAnnotationValue CommaOrSemicolonOptional { - pdebug("TypeAnnotation -> tok_identifier = tok_literal"); + pdebug("TypeAnnotation -> TypeAnnotationValue"); $$ = new t_annotation; $$->key = $1; - $$->val = $3; + $$->val = $2; + } + +TypeAnnotationValue: + '=' tok_literal + { + pdebug("TypeAnnotationValue -> = tok_literal"); + $$ = $2; + } +| + { + pdebug("TypeAnnotationValue ->"); + $$ = strdup("1"); } %% http://git-wip-us.apache.org/repos/asf/thrift/blob/89847dfa/test/AnnotationTest.thrift ---------------------------------------------------------------------- diff --git a/test/AnnotationTest.thrift b/test/AnnotationTest.thrift index dac476f..06bf571 100644 --- a/test/AnnotationTest.thrift +++ b/test/AnnotationTest.thrift @@ -28,6 +28,7 @@ struct foo { cpp.type = "DenseFoo", python.type = "DenseFoo", java.final = "", + annotation.without.value, ) exception foo_error {
