aboutsummaryrefslogtreecommitdiff
path: root/lexer/lexer.go
diff options
context:
space:
mode:
Diffstat (limited to 'lexer/lexer.go')
-rw-r--r--lexer/lexer.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/lexer/lexer.go b/lexer/lexer.go
index cffd925..8deda73 100644
--- a/lexer/lexer.go
+++ b/lexer/lexer.go
@@ -51,6 +51,8 @@ func (l *Lexer) NextToken() token.Token {
tok = newToken(token.GT, l.ch)
case ';':
tok = newToken(token.SEMICOLON, l.ch)
+ case ':':
+ tok = newToken(token.COLON, l.ch)
case ',':
tok = newToken(token.COMMA, l.ch)
case '{':
@@ -61,6 +63,13 @@ func (l *Lexer) NextToken() token.Token {
tok = newToken(token.LPAREN, l.ch)
case ')':
tok = newToken(token.RPAREN, l.ch)
+ case '"':
+ tok.Type = token.STRING
+ tok.Literal = l.readString()
+ case '[':
+ tok = newToken(token.LBRACKET, l.ch)
+ case ']':
+ tok = newToken(token.RBRACKET, l.ch)
case 0:
tok.Literal = ""
tok.Type = token.EOF
@@ -122,6 +131,17 @@ func (l *Lexer) readNumber() string {
return l.input[position:l.position]
}
+func (l *Lexer) readString() string {
+ position := l.position + 1
+ for {
+ l.readChar()
+ if l.ch == '"' {
+ break
+ }
+ }
+ return l.input[position:l.position]
+}
+
func isLetter(ch byte) bool {
return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_'
}