Skip to content

Commit a21957e

Browse files
committed
Change switch to badili and added numbers to allowed identifiers
1 parent 8503ad2 commit a21957e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lexer/lexer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func newToken(tokenType token.TokenType, line int, ch byte) token.Token {
191191
func (l *Lexer) readIdentifier() string {
192192
position := l.position
193193

194-
for isLetter(l.ch) {
194+
for isLetter(l.ch) || isDigit(l.ch) {
195195
l.readChar()
196196
}
197197
return l.input[position:l.position]

token/token.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const (
6868
CONTINUE = "ENDELEA"
6969
IN = "KTK"
7070
FOR = "KWA"
71-
SWITCH = "ENDAPO"
71+
SWITCH = "BADILI"
7272
CASE = "IKIWA"
7373
DEFAULT = "KAWAIDA"
7474
)
@@ -88,7 +88,7 @@ var keywords = map[string]TokenType{
8888
"tupu": NULL,
8989
"ktk": IN,
9090
"kwa": FOR,
91-
"endapo": SWITCH,
91+
"badili": SWITCH,
9292
"ikiwa": CASE,
9393
"kawaida": DEFAULT,
9494
}

0 commit comments

Comments
 (0)