aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-09-02 14:16:01 -0400
committerRuss Cox <rsc@golang.org>2010-09-02 14:16:01 -0400
commitdea283750b9b7774cd0ee0d320a038dbff90803f (patch)
treed0e7fe8d4a69fee9d17653e30c36f3db37c3efe2
parentebe837d6eb05035ef74f475a6a1bc7b0d8bb8f2e (diff)
downloadgo-dea283750b9b7774cd0ee0d320a038dbff90803f.tar.gz
go-dea283750b9b7774cd0ee0d320a038dbff90803f.zip
gc: fix spurious syntax error
Fixes #1071. R=ken2 CC=golang-dev https://golang.org/cl/2136043
-rw-r--r--src/cmd/gc/go.y31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/cmd/gc/go.y b/src/cmd/gc/go.y
index baa589241f..73b1ff4942 100644
--- a/src/cmd/gc/go.y
+++ b/src/cmd/gc/go.y
@@ -20,6 +20,17 @@
%{
#include <stdio.h> /* if we don't, bison will, and go.h re-#defines getc */
#include "go.h"
+
+static void
+fixlbrace(int lbr)
+{
+ // If the opening brace was an LBODY,
+ // set up for another one now that we're done.
+ // See comment in lex.c about loophack.
+ if(lbr == LBODY)
+ loophack = 1;
+}
+
%}
%union {
Node* node;
@@ -861,12 +872,8 @@ pexpr_no_paren:
// composite expression
$$ = nod(OCOMPLIT, N, $1);
$$->list = $3;
-
- // If the opening brace was an LBODY,
- // set up for another one now that we're done.
- // See comment in lex.c about loophack.
- if($2 == LBODY)
- loophack = 1;
+
+ fixlbrace($2);
}
| pexpr_no_paren '{' braced_keyval_list '}'
{
@@ -1063,25 +1070,29 @@ recvchantype:
}
structtype:
- LSTRUCT '{' structdcl_list osemi '}'
+ LSTRUCT lbrace structdcl_list osemi '}'
{
$$ = nod(OTSTRUCT, N, N);
$$->list = $3;
+ fixlbrace($2);
}
-| LSTRUCT '{' '}'
+| LSTRUCT lbrace '}'
{
$$ = nod(OTSTRUCT, N, N);
+ fixlbrace($2);
}
interfacetype:
- LINTERFACE '{' interfacedcl_list osemi '}'
+ LINTERFACE lbrace interfacedcl_list osemi '}'
{
$$ = nod(OTINTER, N, N);
$$->list = $3;
+ fixlbrace($2);
}
-| LINTERFACE '{' '}'
+| LINTERFACE lbrace '}'
{
$$ = nod(OTINTER, N, N);
+ fixlbrace($2);
}
keyval: