@@ -35,9 +35,28 @@ func NewErrIncompleteQuotedString(p *TextParser) *lexer.Error {
|
||||
return newErrIncomplete(p, "incomplete quoted string")
|
||||
}
|
||||
|
||||
// NewErrIncompleteEscaped returns a [lexer.Error]
|
||||
// indicating the text being parsed wasn't correctly
|
||||
// terminated
|
||||
func NewErrIncompleteEscaped(p *TextParser) *lexer.Error {
|
||||
return newErrIncomplete(p, "incomplete escaped string")
|
||||
}
|
||||
|
||||
func newErrIncomplete(p *TextParser, hint string) *lexer.Error {
|
||||
pos, s := p.Emit()
|
||||
pos.Add(GetPositionalLength(s))
|
||||
|
||||
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()
|
||||
|
||||
s = s[:len(s)-len(seq)]
|
||||
pos.Add(GetPositionalLength(s))
|
||||
|
||||
return NewError(pos, seq, "invalid escape character", fs.ErrInvalid)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user