]> Cypherpunks repositories - gostls13.git/commitdiff
make 6g match spec:
authorRuss Cox <rsc@golang.org>
Wed, 16 Sep 2009 00:29:08 +0000 (17:29 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 16 Sep 2009 00:29:08 +0000 (17:29 -0700)
no semicolon allowd after package clause.
semicolon allowed after import statement.
no doubled semicolons allowed

R=ken
OCL=34674
CL=34674

src/cmd/gc/go.y

index ea9cd3aed57caf3cba16adcd5e25321e269eadb0..7b1f772242b6a3cd8b35b027bca5a62e83157bab 100644 (file)
 
 %left          '{'
 
+%left          NotSemi
+%left          ';'
+
 %%
 file:
        loadsys
@@ -154,9 +157,9 @@ imports:
 |      imports import
 
 import:
-       LIMPORT import_stmt
-|      LIMPORT '(' import_stmt_list osemi ')'
-|      LIMPORT '(' ')'
+       LIMPORT import_stmt osemi
+|      LIMPORT '(' import_stmt_list osemi ')' osemi
+|      LIMPORT '(' ')' osemi
 
 import_stmt:
        import_here import_package import_there
@@ -268,18 +271,19 @@ import_there:
  * declarations
  */
 xdcl:
-       common_dcl
-|      xfndcl
+       common_dcl osemi
+|      xfndcl osemi
        {
                $$ = list1($1);
        }
-|      ';'
+|      error osemi
        {
                $$ = nil;
        }
-|      error xdcl
+|      ';'
        {
-               $$ = $2;
+               yyerror("empty top-level declaration");
+               $$ = nil;
        }
 
 common_dcl:
@@ -1479,6 +1483,7 @@ braced_keyval_list:
  * optional things
  */
 osemi:
+       %prec NotSemi
 |      ';'
 
 ocomma: