From af6d4dc3c339d8ca4edc74a88a59e7e20b94f7e5 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sat, 18 Oct 2014 12:25:16 -0400 Subject: [PATCH] make eof token type private --- parse/lex/lex.go | 6 +++--- parse/lex/lex_test.go | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/parse/lex/lex.go b/parse/lex/lex.go index ce98af7..c95a665 100644 --- a/parse/lex/lex.go +++ b/parse/lex/lex.go @@ -16,7 +16,7 @@ const ( OpenParen CloseParen Err - EOF + eof ) var invalidBareStringRunes = map[rune]bool{ @@ -79,7 +79,7 @@ func (l *Lexer) spin() { func (l *Lexer) Next() *Token { t := <-l.ch - if t.Type == EOF { + if t.Type == eof { return nil } return t @@ -118,7 +118,7 @@ func (l *Lexer) readRune() (rune, error) { func (l *Lexer) err(err error) lexerFunc { if err == io.EOF { - l.ch <- &Token{EOF, ""} + l.ch <- &Token{eof, ""} } else { l.ch <- &Token{Err, err.Error()} } diff --git a/parse/lex/lex_test.go b/parse/lex/lex_test.go index a06c553..aba3edf 100644 --- a/parse/lex/lex_test.go +++ b/parse/lex/lex_test.go @@ -7,34 +7,34 @@ import ( func TestLexer(t *T) { m := map[string][]Token{ - "": {{EOF, ""}}, - " \t": {{EOF, ""}}, + "": {{eof, ""}}, + " \t": {{eof, ""}}, "a b c": {{BareString, "a"}, {BareString, "b"}, {BareString, "c"}, - {EOF, ""}}, + {eof, ""}}, "\"foo\" bar": {{QuotedString, "\"foo\""}, {BareString, "bar"}, - {EOF, ""}}, + {eof, ""}}, "\"foo\nbar\" baz": {{QuotedString, "\"foo\nbar\""}, {BareString, "baz"}, - {EOF, ""}}, + {eof, ""}}, "( foo bar ) baz": {{OpenParen, "("}, {BareString, "foo"}, {BareString, "bar"}, {CloseParen, ")"}, {BareString, "baz"}, - {EOF, ""}}, + {eof, ""}}, "((foo-bar))": {{OpenParen, "("}, {OpenParen, "("}, {BareString, "foo-bar"}, {CloseParen, ")"}, {CloseParen, ")"}, - {EOF, ""}}, + {eof, ""}}, "(\"foo\nbar\")": {{OpenParen, "("}, {QuotedString, "\"foo\nbar\""}, {CloseParen, ")"}, - {EOF, ""}}, + {eof, ""}}, } for input, output := range m { @@ -43,7 +43,7 @@ func TestLexer(t *T) { for i := range output { tok := l.Next() if tok == nil { - if output[i].Type == EOF { + if output[i].Type == eof { continue } t.Fatalf("input: %q (%d) %#v != %#v", input, i, output[i], tok)