Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3bf20948c0 | |||
| 0dd29272e9 | |||
| 7fab1a799a | |||
| 16dfde1503 | |||
| 41d7c6e04d | |||
| 48adaeb8a8 | |||
| 99ca8d0b3b | |||
| 986b6d1c6d | |||
| d41cd781d9 | |||
| 651fcb6215 |
@@ -49,6 +49,9 @@ func newErrIncomplete(p *TextParser, hint string) *lexer.Error {
|
||||
return NewError(pos, s, hint, fs.ErrInvalid)
|
||||
}
|
||||
|
||||
// NewErrInvalidEscapeSequence returns a [lexer.Error] indicating
|
||||
// the specified sequence, at the end of the accepted buffer,
|
||||
// is invalid
|
||||
func NewErrInvalidEscapeSequence(p *TextParser, seq string) *lexer.Error {
|
||||
pos, s := p.Position(), p.String()
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ func lexQuotedStringEscaped(p *TextParser) (string, *lexer.Error) {
|
||||
var result strings.Builder
|
||||
|
||||
// append what was accepted before the escape character
|
||||
result.WriteString(p.String()[1:])
|
||||
_, _ = result.WriteString(p.String()[1:])
|
||||
|
||||
for {
|
||||
r, _, err := p.ReadRune()
|
||||
@@ -101,14 +101,13 @@ func lexQuotedStringEscaped(p *TextParser) (string, *lexer.Error) {
|
||||
default:
|
||||
// TODO: check valid escape character and
|
||||
// append to result
|
||||
p.UnreadRune()
|
||||
s := string([]rune{r, r2})
|
||||
err := NewErrInvalidEscapeSequence(p, s)
|
||||
return "", err
|
||||
}
|
||||
default:
|
||||
// normal, append to result
|
||||
result.WriteRune(r)
|
||||
_, _ = result.WriteRune(r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user