parser: keep seeking until eof
This commit is contained in:
parent
d9f54300c3
commit
e6bae8d916
1 changed files with 5 additions and 11 deletions
|
@ -71,22 +71,16 @@ func scanModelfile(data []byte, atEOF bool) (advance int, token []byte, err erro
|
|||
if start := bytes.Index(data, []byte(`"""`)); start >= 0 && start < newline {
|
||||
end := bytes.Index(data[start+3:], []byte(`"""`))
|
||||
if end < 0 {
|
||||
if atEOF {
|
||||
return 0, nil, errors.New(`unterminated multiline string: """`)
|
||||
} else {
|
||||
return 0, nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
n := start + 3 + end + 3
|
||||
return n, bytes.Replace(data[:n], []byte(`"""`), []byte(""), 2), nil
|
||||
}
|
||||
|
||||
if start := bytes.Index(data, []byte(`'''`)); start >= 0 && start < newline {
|
||||
end := bytes.Index(data[start+3:], []byte(`'''`))
|
||||
if end < 0 {
|
||||
return 0, nil, errors.New("unterminated multiline string: '''")
|
||||
}
|
||||
|
||||
n := start + 3 + end + 3
|
||||
return n, bytes.Replace(data[:n], []byte("'''"), []byte(""), 2), nil
|
||||
}
|
||||
|
||||
return bufio.ScanLines(data, atEOF)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue