Skip to content

Commit

Permalink
ivy: fix infinite loop on unbalanced quotes
Browse files Browse the repository at this point in the history
Generally: Just trigger a parse error when there is a scan error.
No need to track down all the cases an error could otherwise arrive.
  • Loading branch information
robpike committed Jan 8, 2015
1 parent 00a888c commit e9ae363
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ func (p *Parser) next() scan.Token {
} else {
tok = <-p.scanner.Tokens
}
if tok.Type == scan.Error {
p.errorf("%q", tok)
}
p.curTok = tok
if tok.Type != scan.Newline {
// Show the line number before we hit the newline.
Expand Down Expand Up @@ -251,8 +254,6 @@ func (p *Parser) Line() ([]value.Expr, bool) {
func (p *Parser) expressionList() ([]value.Expr, bool) {
tok := p.next()
switch tok.Type {
case scan.Error:
p.errorf("%q", tok)
case scan.EOF:
return nil, false
case scan.Newline:
Expand All @@ -264,8 +265,6 @@ func (p *Parser) expressionList() ([]value.Expr, bool) {
}
tok = p.next()
switch tok.Type {
case scan.Error:
p.errorf("%q", tok)
case scan.EOF, scan.Newline:
default:
p.errorf("unexpected %q", tok)
Expand Down

0 comments on commit e9ae363

Please sign in to comment.