|
|
@@ -13,9 +13,23 @@ type Parser struct {
|
|
|
|
|
|
|
|
|
|
|
|
pos lexer.Position
|
|
|
|
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
|
|
|
|
OnSection func(pos lexer.Position, name, subname string, hasSubname bool) 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
|
|
|
|
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
|
|
|
|
OnComment func(pos lexer.Position, comment string) 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
|
|
|
|
OnError func(pos lexer.Position, content string, err error) error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|