* Go patch committed: Better parses
@ 2011-09-24 6:09 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2011-09-24 6:09 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 228 bytes --]
This patch to the Go frontend improves the parsing of a non-identifier
on the left hand side of :=, and of a non-type in a type switch.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.
Ian
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1166 bytes --]
diff -r ffdb8cbbc880 go/parse.cc
--- a/go/parse.cc Fri Sep 23 08:28:44 2011 -0700
+++ b/go/parse.cc Fri Sep 23 14:51:52 2011 -0700
@@ -3506,7 +3506,21 @@
else if (return_exp != NULL)
return this->verify_not_sink(exp);
else
- this->expression_stat(this->verify_not_sink(exp));
+ {
+ exp = this->verify_not_sink(exp);
+
+ if (token->is_op(OPERATOR_COLONEQ))
+ {
+ if (!exp->is_error_expression())
+ error_at(token->location(), "non-name on left side of %<:=%>");
+ while (!token->is_op(OPERATOR_SEMICOLON)
+ && !token->is_eof())
+ token = this->advance_token();
+ return NULL;
+ }
+
+ this->expression_stat(exp);
+ }
return NULL;
}
@@ -4287,8 +4301,19 @@
while (true)
{
Type* t = this->type();
+
if (!t->is_error_type())
types->push_back(t);
+ else
+ {
+ token = this->peek_token();
+ while (!token->is_op(OPERATOR_COLON)
+ && !token->is_op(OPERATOR_COMMA)
+ && !token->is_op(OPERATOR_RCURLY)
+ && !token->is_eof())
+ token = this->advance_token();
+ }
+
if (!this->peek_token()->is_op(OPERATOR_COMMA))
break;
this->advance_token();
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-09-23 22:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-24 6:09 Go patch committed: Better parses Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).