whitespace

master
Jordan Orelli 10 years ago
parent ed55f2c4ad
commit 0c29239856

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"io" "io"
"strings" "strings"
"unicode"
) )
type tokenType int type tokenType int
@ -91,6 +92,9 @@ func lexRoot(l *lexer) (stateFn, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if unicode.IsSpace(r) {
return lexRoot, nil
}
switch r { switch r {
case '"', '`': case '"', '`':
return lexStringLiteral(r), nil return lexStringLiteral(r), nil

@ -13,6 +13,7 @@ var primitivesTests = []struct {
{`"this one has spaces"`, token{t_string, "this one has spaces"}}, {`"this one has spaces"`, token{t_string, "this one has spaces"}},
{`"this one has \"quotes\" in it"`, token{t_string, `this one has "quotes" in it`}}, {`"this one has \"quotes\" in it"`, token{t_string, `this one has "quotes" in it`}},
{"`this one is delimited by backticks`", token{t_string, "this one is delimited by backticks"}}, {"`this one is delimited by backticks`", token{t_string, "this one is delimited by backticks"}},
{` "this one has white space on either end" `, token{t_string, "this one has white space on either end"}},
} }
func TestLexPrimities(t *testing.T) { func TestLexPrimities(t *testing.T) {

Loading…
Cancel
Save