parser: Unquoted(), AcceptQuotedString()
TODO: reduce quoted strings with escaped characters Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
|
||||
"asciigoat.org/core/lexer"
|
||||
)
|
||||
|
||||
@@ -25,3 +27,24 @@ func ErrPlusPosition(pos lexer.Position, e *lexer.Error) *lexer.Error {
|
||||
|
||||
return NewError(pos, e.Content, e.Hint, e.Err)
|
||||
}
|
||||
|
||||
// NewErrIncompleteQuotedString returns a [lexer.Error]
|
||||
// indicating the quoted string being parsed wasn't correctly
|
||||
// terminated
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user