Hashes
This commit is contained in:
@@ -98,6 +98,8 @@ func (l *Lexer) NextToken() token.Token {
|
||||
tok = newToken(token.LBRACKET, l.ch)
|
||||
case ']':
|
||||
tok = newToken(token.RBRACKET, l.ch)
|
||||
case ':':
|
||||
tok = newToken(token.COLON, l.ch)
|
||||
default:
|
||||
if isLetter(l.ch) {
|
||||
tok.Literal = l.readIdentifier()
|
||||
|
||||
@@ -28,6 +28,7 @@ func TestNextToken(t *testing.T) {
|
||||
"foobar"
|
||||
"foo bar"
|
||||
[1, 2];
|
||||
{"foo": "bar"}
|
||||
`
|
||||
|
||||
tests := []struct {
|
||||
@@ -126,6 +127,12 @@ func TestNextToken(t *testing.T) {
|
||||
{token.RBRACKET, "]"},
|
||||
{token.SEMICOLON, ";"},
|
||||
|
||||
{token.LBRACE, "{"},
|
||||
{token.STRING, "foo"},
|
||||
{token.COLON, ":"},
|
||||
{token.STRING, "bar"},
|
||||
{token.RBRACE, "}"},
|
||||
|
||||
{token.EOF, ""},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user