summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2008-10-14 17:10:39 -0700
committerRuss Cox <rsc@golang.org>2008-10-14 17:10:39 -0700
commit3f9f0d637b367c08ea008d68dfd454ea0738263b (patch)
treeccf5b1f14e39cd871d59aa806981b3760fac5311 /src
parent4f9b7e7c0272dca1ddd572bfa8c8fae672510a4a (diff)
downloadgolang-3f9f0d637b367c08ea008d68dfd454ea0738263b.tar.gz
allow trailing comma in braced initialized list
R=ken OCL=17141 CL=17143
Diffstat (limited to 'src')
-rw-r--r--src/cmd/gc/go.y31
1 files changed, 28 insertions, 3 deletions
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 <node> interfacedcl_list_r interfacedcl
%type <node> structdcl_list_r structdcl
%type <node> fnres Afnres Bfnres fnliteral xfndcl fndcl fnbody
-%type <node> keyexpr_list keyval_list_r keyval
+%type <node> keyexpr_list braced_keyexpr_list keyval_list_r keyval
%type <type> typedclname new_type
%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