]> Cypherpunks repositories - gostls13.git/commitdiff
- fixed bug in parser.go
authorRobert Griesemer <gri@golang.org>
Fri, 11 Jul 2008 03:50:38 +0000 (20:50 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 11 Jul 2008 03:50:38 +0000 (20:50 -0700)
- added more tests

SVN=126784

usr/gri/gosrc/parser.go

index 0e025f9d390c65cac16cdb6f86967f5e0e8ce400..ecf7699ae06d065e402915c308e667a232ea99a9 100644 (file)
@@ -592,10 +592,14 @@ func (P *Parser) ParseIfStat() {
        P.Trace("IfStat");
        P.Expect(Scanner.IF);
        if P.tok != Scanner.LBRACE {
-               P.ParseSimpleStat();
+               if P.tok != Scanner.SEMICOLON {
+                       P.ParseSimpleStat();
+               }
                if P.tok == Scanner.SEMICOLON {
                        P.Next();
-                       P.ParseExpression();
+                       if P.tok != Scanner.LBRACE {
+                               P.ParseExpression();
+                       }
                }
        }
        P.ParseBlock();
@@ -677,10 +681,14 @@ func (P *Parser) ParseSwitchStat() {
        P.Trace("SwitchStat");
        P.Expect(Scanner.SWITCH);
        if P.tok != Scanner.LBRACE {
-               P.ParseSimpleStat();
+               if P.tok != Scanner.SEMICOLON {
+                       P.ParseSimpleStat();
+               }
                if P.tok == Scanner.SEMICOLON {
                        P.Next();
-                       P.ParseExpression();
+                       if P.tok != Scanner.LBRACE {
+                               P.ParseExpression();
+                       }
                }
        }
        P.Expect(Scanner.LBRACE);