9 Commits

Author SHA1 Message Date
amery bfbf7861cb Unmarshal: WIP
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-08-30 18:59:16 +00:00
amery 75d79f3d3d Decoder: WIP
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-08-30 18:59:16 +00:00
amery 36da7c086e basic: WIP
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-08-30 18:59:16 +00:00
amery 5514583962 parser: WIP
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-08-30 18:57:09 +00:00
amery 8e98b927dd parser: emitError
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-08-30 18:57:09 +00:00
amery 72d69a2b48 build-sys: use local asciigoat.org/core [DO-NOT-MERGE]
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-08-30 18:38:07 +00:00
amery 27ca07b8a0 parser: introduce parsing callbacks
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-08-30 18:10:39 +00:00
amery 235c8ad85c parser: implement initial tokeniser
only logging position, errors and non-whitespace elements

Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-08-30 17:53:40 +00:00
amery 1dba6d6b48 parser: add placeholder for ini Parser
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-08-30 17:53:34 +00:00
2 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ go 1.19
replace asciigoat.org/core => ../core
require (
asciigoat.org/core v0.3.4
asciigoat.org/core v0.3.6
github.com/mgechev/revive v1.3.3
)
+16 -2
View File
@@ -13,10 +13,24 @@ type Parser struct {
pos lexer.Position
// OnSection is called after a [section] is parsed.
// Returning an error will abort the process.
OnSection func(pos lexer.Position, name, subname string, hasSubname bool) error
OnField func(pos lexer.Position, key, value string) error
// OnField is called after a `key = value` entry is parsed
// Returning an error will abort the process.
OnField func(pos lexer.Position, key, value string) error
// OnComment is called after a comment is parsed
// Returning an error will abort the process.
OnComment func(pos lexer.Position, comment string) error
OnError func(pos lexer.Position, content string, err error) error
// OnError is called after each parsing error, which you are allowed to
// override.
// OnError is called for EOF as well, but this error isn't returned as such by
// Parser.Run(). The caller will receive (nil, nil) instead indicating the
// processes terminated correctly.
OnError func(pos lexer.Position, content string, err error) error
}
func defaultOnSection(_ lexer.Position, _, _ string, _ bool) error { return nil }