]> Cypherpunks.ru repositories - gostls13.git/commitdiff
gc: insert semicolon at EOF if needed
authorRuss Cox <rsc@golang.org>
Tue, 28 Sep 2010 14:35:02 +0000 (10:35 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 28 Sep 2010 14:35:02 +0000 (10:35 -0400)
R=ken2, gri
CC=golang-dev
https://golang.org/cl/2208053

src/cmd/gc/lex.c
test/eof.go [new file with mode: 0644]

index b46aa2ae0850e46356204e7c1aba507e210a07ed..8289648ba97572549086a512f4a8e7f120a0f275 100644 (file)
@@ -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 (file)
index 0000000..81f9fd0
--- /dev/null
@@ -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