func lexShell(x *lexing.Lexer) *lexing.Token { r := x.Rune() if x.IsWhite(r) { panic("incorrect token start") } switch r { case '"': return lexing.LexString(x, String, '"') } if isBareRune(r) { return lexBare(x) } x.Errorf("illegal char %q", r) x.Next() return x.MakeToken(lexing.Illegal) }
func lexBare(x *lexing.Lexer) *lexing.Token { start := x.Rune() if !isBareRune(start) { panic("not starting with a bare rune") } for { x.Next() if !isBareRune(x.Rune()) { break } } return x.MakeToken(Bare) }