Rename new -> New and next_token -> NextToken, because of go's weird requirement that first letter
of public methods in a package that would be used in another package must be capitalized. git-svn-id: https://svn.tlawal.org/svn/monkey@4 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
This commit is contained in:
parent
fec8dd9152
commit
ee8ab63809
@ -9,7 +9,7 @@ type Lexer struct {
|
||||
current_char byte
|
||||
}
|
||||
|
||||
func new(input string) *Lexer {
|
||||
func New(input string) *Lexer {
|
||||
l := &Lexer{input: input}
|
||||
l.read_char()
|
||||
return l
|
||||
@ -67,7 +67,7 @@ func is_digit(ch byte) bool {
|
||||
return '0' <= ch && ch <= '9'
|
||||
}
|
||||
|
||||
func (lexer *Lexer) next_token() token.Token {
|
||||
func (lexer *Lexer) NextToken() token.Token {
|
||||
var tok token.Token
|
||||
lexer.skip_whitespace()
|
||||
|
||||
|
@ -114,9 +114,9 @@ func TestNextToken(t *testing.T) {
|
||||
{token.EOF, ""},
|
||||
}
|
||||
|
||||
l := new(input)
|
||||
l := New(input)
|
||||
for i, tt := range tests {
|
||||
tok := l.next_token()
|
||||
tok := l.NextToken()
|
||||
if tok.Type != tt.expectedType {
|
||||
t.Fatalf("test[%d] - tokentype wrong. expected=%q, got=%q", i, tt.expectedType, tok.Type)
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ func Start(in io.Reader, out io.Writer){
|
||||
}
|
||||
|
||||
line := scanner.Text()
|
||||
l := lexer.new(line)
|
||||
l := lexer.New(line)
|
||||
|
||||
for tok := l.next_token(); tok.Type != token.EOF; tok = l.next_token(){
|
||||
for tok := l.NextToken(); tok.Type != token.EOF; tok = l.NextToken() {
|
||||
fmt.Fprintf(out, "%+v\n", tok)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user