1
0
mirror of https://github.com/golang/go synced 2024-11-22 09:34:54 -07:00

go/parser: consume auto-inserted semi when calling ParseExpr()

Fixes #1170.

R=rsc
CC=golang-dev
https://golang.org/cl/2622041
This commit is contained in:
Robert Griesemer 2010-10-21 08:40:33 -07:00
parent 49084db386
commit b57b10f992

View File

@ -69,7 +69,11 @@ func ParseExpr(filename string, src interface{}) (ast.Expr, os.Error) {
var p parser var p parser
p.init(filename, data, 0) 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()
} }