Skip to content

Commit

Permalink
Simplify some return/break logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdan committed Jan 23, 2016
1 parent 9900ec8 commit b028dc8
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ func (p *parser) command() {
}
p.want(DONE)
case p.got(WORD):
args:
for p.tok != EOF {
lval := p.val
switch {
Expand All @@ -355,29 +356,29 @@ func (p *parser) command() {
if p.got('&') {
p.command()
}
return
break args
case p.got('|'):
p.got('|')
p.command()
return
break args
case p.got('('):
if !ident.MatchString(lval) {
p.col -= utf8.RuneCountInString(lval)
p.col--
p.lineErr("invalid func name %q", lval)
return
break args
}
p.want(')')
p.command()
return
break args
case p.got('>'):
p.redirectDest()
case p.got('<'):
p.want(WORD)
case p.got(';'):
return
break args
case p.got('\n'):
return
break args
default:
p.errAfterStr("command")
}
Expand All @@ -395,19 +396,15 @@ func (p *parser) command() {
if p.got('&') {
p.command()
}
return
case p.got('|'):
p.got('|')
p.command()
return
case p.got('>'):
p.redirectDest()
case p.got('<'):
p.want(WORD)
case p.got(';'):
return
case p.got('\n'):
return
default:
p.errAfterStr("block")
}
Expand Down

0 comments on commit b028dc8

Please sign in to comment.