1
0
mirror of https://github.com/golang/go synced 2024-11-13 17:40:23 -07:00

cmd/compile/internal/parser: use same logic for stmtList as for other lists (cleanup)

Change-Id: I2c2571b33603f0fd0ba5a79400da7b845d246b8c
Reviewed-on: https://go-review.googlesource.com/71290
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
griesemer 2017-10-16 21:24:27 -07:00 committed by Robert Griesemer
parent 47193dcc0c
commit c37090f00f

View File

@ -2063,14 +2063,11 @@ func (p *parser) stmtList() (l []Stmt) {
break
}
l = append(l, s)
// customized version of osemi:
// ';' is optional before a closing ')' or '}'
if p.tok == _Rparen || p.tok == _Rbrace {
continue
}
if !p.got(_Semi) {
// ";" is optional before "}"
if !p.got(_Semi) && p.tok != _Rbrace {
p.syntax_error("at end of statement")
p.advance(_Semi, _Rbrace)
p.advance(_Semi, _Rbrace, _Case, _Default)
p.got(_Semi) // avoid spurious empty statement
}
}
return