package parse import ( "git.makaay.nl/mauricem/go-parsekit/parse" "git.makaay.nl/mauricem/go-toml/ast" ) type parser struct { doc *ast.Document strFlags byte // A helper field used for string parsing. } func newParser() *parser { doc := ast.NewDocument() return &parser{doc: doc} } // Run the TOML parser against the provided input data. // // For an overview of allowed inputs, take a look at the documentation for // parsekit.read.New(). At the time of writing, you can make use of // strings, types implementing io.Reader and bufio.Readers. // // This function returns a TOML abstract syntax table structure and an // error (or nil when no error occurred). When an error occurred, the // TOML ast struct will contain the data that could be parsed up to the error. func Run(input interface{}) (ast.Table, error) { p := newParser() err := parse.New(p.startDocument)(input) return p.doc.Root, err }