package conf import ( "bufio" "io" ) type tokentype int const ( Name tokentype = iota Literal Delimiter Nothing IfStatement ) type token struct { Type tokentype } type scanner struct { r io.Reader bs bufio.Scanner prev token cur token } func newScanner(r io.Reader) *scanner { ns := bufio.NewScanner(r) ns.Split(bufio.ScanWords) sc := scanner{ r: r, bs: *ns, } return &sc } func getTokenType(s string) tokentype { return Nothing } func (s *scanner) Next() (tokentype, string, error) { more := s.bs.Scan() if !more { err := s.bs.Err() if err != nil { return Nothing, "", err } return Nothing, "", io.EOF } tokstr := s.bs.Text() token := getTokenType(tokstr) return token, tokstr, nil } func (s *scanner) peek() (tokentype, string, error) { return Nothing, "", nil }