summaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
Diffstat (limited to 'conf')
-rw-r--r--conf/scanner.go66
1 files changed, 66 insertions, 0 deletions
diff --git a/conf/scanner.go b/conf/scanner.go
new file mode 100644
index 0000000..fd2a3cf
--- /dev/null
+++ b/conf/scanner.go
@@ -0,0 +1,66 @@
+package conf
+
+import (
+ "bufio"
+ "io"
+)
+
+type token int
+
+const (
+ Name token = iota
+ Delimiter token = iota
+ Nothing token = iota
+ IfStatement token = iota
+)
+
+// Having a Config to Manager function could be nice?
+// Or we could just return a Manager from here.
+type Config struct {
+}
+
+type scanner struct {
+ r io.Reader
+ ss bufio.Scanner
+ prev token
+ cur token
+}
+
+func NewConfig(r io.Reader) *Config {
+ br := bufio.NewReader(r)
+ s := newScanner(br)
+ s.next()
+
+ return &Config{}
+}
+
+func newScanner(r io.Reader) *scanner {
+ ns := bufio.NewScanner(r)
+ ns.Split(bufio.ScanWords)
+
+ sc := scanner{
+ r: r,
+ ss: *ns,
+ }
+
+ return &sc
+}
+
+func getTokenType(s string) token {
+ return Nothing
+}
+
+func (s *scanner) next() (token, string, error) {
+ stop := s.ss.Scan()
+ if stop {
+ return Nothing, "", s.ss.Err()
+ }
+ tokstr := s.ss.Text()
+ token := getTokenType(tokstr)
+
+ return token, tokstr, nil
+}
+
+func (s *scanner) peek() (token, string, error) {
+ return Nothing, "", nil
+}