From 3f9f0d637b367c08ea008d68dfd454ea0738263b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Oct 2008 17:10:39 -0700 Subject: allow trailing comma in braced initialized list R=ken OCL=17141 CL=17143 --- src/cmd/gc/go.y | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cmd/gc/go.y b/src/cmd/gc/go.y index b7eba4a47..25df8d305 100644 --- a/src/cmd/gc/go.y +++ b/src/cmd/gc/go.y @@ -60,7 +60,7 @@ %type interfacedcl_list_r interfacedcl %type structdcl_list_r structdcl %type fnres Afnres Bfnres fnliteral xfndcl fndcl fnbody -%type keyexpr_list keyval_list_r keyval +%type keyexpr_list braced_keyexpr_list keyval_list_r keyval %type typedclname new_type %type type Atype Btype @@ -871,7 +871,7 @@ pexpr: $$ = nod(OCONV, $3, N); $$->type = oldtype($1); } -| convtype '{' keyexpr_list '}' +| convtype '{' braced_keyexpr_list '}' { // composite literal $$ = rev($3); @@ -1598,7 +1598,32 @@ keyexpr_list: { $$ = rev($1); } -| oexpr_list +| expr_list + +/* + * have to spell this out using _r lists to avoid yacc conflict + */ +braced_keyexpr_list: + { + $$ = N; + } +| keyval_list_r + { + $$ = rev($1); + } +| keyval_list_r ',' + { + $$ = rev($1); + } +| expr_list_r + { + $$ = rev($1); + } +| expr_list_r ',' + { + $$ = rev($1); + } + /* * the one compromise of a -- cgit v1.2.3