diff --git a/go.mod b/go.mod index de11f86..d7df36b 100644 --- a/go.mod +++ b/go.mod @@ -4,25 +4,10 @@ go 1.19 replace asciigoat.org/core => ../core -require github.com/mgechev/revive v1.3.3 - -require ( - github.com/BurntSushi/toml v1.3.2 // indirect - github.com/chavacava/garif v0.0.0-20230608123814-4bd63c2919ab // indirect - github.com/fatih/color v1.15.0 // indirect - github.com/fatih/structtag v1.2.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect - github.com/mattn/go-runewidth v0.0.9 // indirect - github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/pkg/errors v0.9.1 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/tools v0.12.0 // indirect -) - -require github.com/mgechev/revive v1.3.3 +require ( + asciigoat.org/core v0.3.0 + github.com/mgechev/revive v1.3.3 +) require ( github.com/BurntSushi/toml v1.3.2 // indirect diff --git a/parser/parser.go b/parser/parser.go new file mode 100644 index 0000000..b960481 --- /dev/null +++ b/parser/parser.go @@ -0,0 +1,36 @@ +// Package parser parses dosini-style files +package parser + +import ( + "io" + + "asciigoat.org/core/lexer" +) + +// Parser parses a dosini-style document +type Parser struct { + src *lexer.Lexer +} + +func (*Parser) init() error { return nil } + +// Run parses the source +func (p *Parser) Run() error { + if err := p.init(); err != nil { + return err + } + + return lexer.Run(p.initialState) +} + +// NewParser creates a dosini-style parser using +// an [io.Reader] as source +func NewParser(r io.Reader) *Parser { + if r == nil { + return nil + } + + return &Parser{ + src: lexer.NewLexerReader(r), + } +} diff --git a/parser/states.go b/parser/states.go new file mode 100644 index 0000000..166f21b --- /dev/null +++ b/parser/states.go @@ -0,0 +1,7 @@ +package parser + +import "asciigoat.org/core/lexer" + +func (*Parser) initialState() (lexer.StateFn, error) { + return nil, nil +}