From: Mark Slee Date: Thu, 2 Nov 2006 18:43:12 +0000 (+0000) Subject: Make commas and/or semicolons both optional in thrift X-Git-Tag: 0.2.0~1608 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=207cb46af86e3cda525a7bbeefba6c2f2f231ef3;p=common%2Fthrift.git Make commas and/or semicolons both optional in thrift Reviewed by: karl git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664864 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/thrift.y b/compiler/cpp/src/thrift.y index 7d1ba1e1..71c70781 100644 --- a/compiler/cpp/src/thrift.y +++ b/compiler/cpp/src/thrift.y @@ -285,18 +285,20 @@ Enum: $$->set_name($2); } +CommaOrSemicolonOptional: + ',' + {} +| ';' + {} +| + {} + EnumDefList: - EnumDefList ',' EnumDef + EnumDefList EnumDef { pdebug("EnumDefList -> EnumDefList EnumDef"); $$ = $1; - $$->append($3); - } -| EnumDef - { - pdebug("EnumDefList -> EnumDef"); - $$ = new t_enum(g_program); - $$->append($1); + $$->append($2); } | { @@ -305,7 +307,7 @@ EnumDefList: } EnumDef: - tok_identifier '=' tok_int_constant + tok_identifier '=' tok_int_constant CommaOrSemicolonOptional { pdebug("EnumDef => tok_identifier = tok_int_constant"); if ($3 < 0) { @@ -367,7 +369,7 @@ ExtendsOptional: } FunctionList: - FunctionList Function CommaOptional + FunctionList Function { pdebug("FunctionList -> FunctionList Function"); $$ = $1; @@ -379,14 +381,8 @@ FunctionList: $$ = new t_service(g_program); } -CommaOptional: - ',' - {} -| - {} - Function: - AsyncOptional FunctionType tok_identifier '(' FieldList ')' ThrowsOptional + AsyncOptional FunctionType tok_identifier '(' FieldList ')' ThrowsOptional CommaOrSemicolonOptional { $5->set_name(std::string($3) + "_args"); $$ = new t_function($2, $3, $5, $7, $1); @@ -415,17 +411,11 @@ ThrowsOptional: } FieldList: - FieldList ',' Field + FieldList Field { pdebug("FieldList -> FieldList , Field"); $$ = $1; - $$->append($3); - } -| Field - { - pdebug("FieldList -> Field"); - $$ = new t_struct(g_program); - $$->append($1); + $$->append($2); } | { @@ -434,7 +424,7 @@ FieldList: } Field: - tok_int_constant ':' FieldType tok_identifier + tok_int_constant ':' FieldType tok_identifier CommaOrSemicolonOptional { pdebug("tok_int_constant : Field -> FieldType tok_identifier"); if ($1 <= 0) {