parser: Unescaped [WIP]

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-09-04 15:33:46 +00:00
parent 7968b06d7e
commit 8709f39194
2 changed files with 71 additions and 21 deletions
+12
View File
@@ -48,3 +48,15 @@ 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()
s = s[:len(s)-len(seq)]
pos.Add(GetPositionalLength(s))
return NewError(pos, seq, "invalid escape character", fs.ErrInvalid)
}