We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2cc1855 commit b2d295aCopy full SHA for b2d295a
lexer/lexer.go
@@ -1,3 +1,5 @@
1
+// This will convert the sequence of characters into a sequence of tokens
2
+
3
package lexer
4
5
import (
@@ -13,7 +15,7 @@ type Lexer struct {
13
15
}
14
16
17
func New(input string) *Lexer {
- l := &Lexer{input: []rune(input)}
18
+ l := &Lexer{input: []rune(input), line: 1}
19
l.readChar()
20
return l
21
@@ -176,6 +178,11 @@ func (l *Lexer) NextToken() token.Token {
176
178
tok.Type = token.LookupIdent(tok.Literal)
177
179
tok.Line = l.line
180
return tok
181
+ } else if isDigit(l.ch) && isLetter(l.peekChar()) {
182
+ tok.Literal = l.readIdentifier()
183
+ tok.Type = token.LookupIdent(tok.Literal)
184
+ tok.Line = l.line
185
+ return tok
186
} else if isDigit(l.ch) {
187
tok = l.readDecimal()
188
0 commit comments