]> Cypherpunks repositories - gostls13.git/commitdiff
go/parser: consume auto-inserted semi when calling ParseExpr()
authorRobert Griesemer <gri@golang.org>
Thu, 21 Oct 2010 15:40:33 +0000 (08:40 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 21 Oct 2010 15:40:33 +0000 (08:40 -0700)
Fixes #1170.

R=rsc
CC=golang-dev
https://golang.org/cl/2622041

src/pkg/go/parser/interface.go

index 39476f07204b1470a01186870d67bae237012e28..e451a4fe3db15fc3e31518a94249f31df5044ada 100644 (file)
@@ -69,7 +69,11 @@ func ParseExpr(filename string, src interface{}) (ast.Expr, os.Error) {
 
        var p parser
        p.init(filename, data, 0)
-       return p.parseExpr(), p.parseEOF()
+       x := p.parseExpr()
+       if p.tok == token.SEMICOLON {
+               p.next() // consume automatically inserted semicolon, if any
+       }
+       return x, p.parseEOF()
 }