diff options
author | Silvan Jegen <s.jegen@gmail.com> | 2016-12-25 14:45:13 +0100 |
---|---|---|
committer | Silvan Jegen <s.jegen@gmail.com> | 2016-12-25 14:45:13 +0100 |
commit | be3749d9f77e1410c11d0e8b7158a13e51faa41c (patch) | |
tree | d511852b1af04c740b29e41133a1f47de7e54f7c /conf/parser.go | |
parent | b0c4b2fbd4098f88b1abc854854fa24c7402c70a (diff) |
Implement lexer based on Scanner
We also add the skeleton of a recursive descent parser.
Diffstat (limited to 'conf/parser.go')
-rw-r--r-- | conf/parser.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/conf/parser.go b/conf/parser.go new file mode 100644 index 0000000..21bc604 --- /dev/null +++ b/conf/parser.go @@ -0,0 +1,28 @@ +package conf + +import ( + "fmt" + "io" + "os" +) + +// Having a Config to Manager function could be nice? +// Or we could just return a Manager from here. +type Config struct { +} + +type parser struct { + scanner +} + +func NewConfig(r io.Reader) *Config { + s := newScanner(r) + tt, tok, err := s.Next() + for err == nil { + fmt.Fprintf(os.Stderr, "tokentype: %d, token: %q, err: %v\n", tt, tok, err) + tt, tok, err = s.Next() + } + fmt.Fprintf(os.Stderr, "Error: tokentype: %d, token: %q, err: %v\n", tt, tok, err) + + return &Config{} +} |