1package ssh_config 2 3import "fmt" 4 5type token struct { 6 Position 7 typ tokenType 8 val string 9} 10 11func (t token) String() string { 12 switch t.typ { 13 case tokenEOF: 14 return "EOF" 15 } 16 return fmt.Sprintf("%q", t.val) 17} 18 19type tokenType int 20 21const ( 22 eof = -(iota + 1) 23) 24 25const ( 26 tokenError tokenType = iota 27 tokenEOF 28 tokenEmptyLine 29 tokenComment 30 tokenKey 31 tokenEquals 32 tokenString 33) 34 35func isSpace(r rune) bool { 36 return r == ' ' || r == '\t' 37} 38 39func isKeyStartChar(r rune) bool { 40 return !(isSpace(r) || r == '\r' || r == '\n' || r == eof) 41} 42 43// I'm not sure that this is correct 44func isKeyChar(r rune) bool { 45 // Keys start with the first character that isn't whitespace or [ and end 46 // with the last non-whitespace character before the equals sign. Keys 47 // cannot contain a # character." 48 return !(r == '\r' || r == '\n' || r == eof || r == '=') 49} 50