basic: introduce basic one-shot INI-style decoder

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-09-01 14:21:55 +00:00
parent c92e0df47b
commit 174f72c4cf
5 changed files with 270 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package basic
import (
"errors"
"asciigoat.org/core/lexer"
)
var (
errInvalidToken = errors.New("invalid token")
)
func newErrInvalidToken(t *token) *lexer.Error {
err := &lexer.Error{
Line: t.pos.Line,
Column: t.pos.Column,
Content: t.value,
Err: errInvalidToken,
}
return err
}
func (dec *decoder) OnError(pos lexer.Position, content string, err error) error {
err = &lexer.Error{
Line: pos.Line,
Column: pos.Column,
Content: content,
Err: err,
}
dec.executeFinal()
return err
}