diff options
author | Russ Cox <rsc@golang.org> | 2010-09-28 10:35:02 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-09-28 10:35:02 -0400 |
commit | ad070035d177b45ecb00e900b95795fd0a8a901a (patch) | |
tree | 1ca00ab135d2a1570523ee47131af36905b2792f | |
parent | f6221ccf4701037f8f7cc8756a093ac5e554a9fe (diff) | |
download | go-ad070035d177b45ecb00e900b95795fd0a8a901a.tar.gz |
gc: insert semicolon at EOF if needed
R=ken2, gri
CC=golang-dev
http://codereview.appspot.com/2208053
-rw-r--r-- | src/cmd/gc/lex.c | 9 | ||||
-rw-r--r-- | test/eof.go | 9 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c index b46aa2ae0..8289648ba 100644 --- a/src/cmd/gc/lex.c +++ b/src/cmd/gc/lex.c @@ -1247,13 +1247,8 @@ yylex(void) lx = _yylex(); if(curio.nlsemi && lx == EOF) { - // if the nlsemi bit is set, we'd be willing to - // insert a ; if we saw a \n, but we didn't. - // that means the final \n is missing. - // complain here, because we can give a - // good message. the syntax error we'd get - // otherwise is inscrutable. - yyerror("missing newline at end of file"); + // Treat EOF as "end of line" for the purposes + // of inserting a semicolon. lx = ';'; } diff --git a/test/eof.go b/test/eof.go new file mode 100644 index 000000000..81f9fd028 --- /dev/null +++ b/test/eof.go @@ -0,0 +1,9 @@ +// $G $D/$F.go + +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// No newline at the end of this file. + +package main
\ No newline at end of file |