Bitshift
Some checks failed
Test / build (push) Waiting to run
Build / build (push) Has been cancelled

This commit is contained in:
Chuck Smith
2024-03-24 16:22:11 -04:00
parent a08fc1520c
commit 3c66b980e7
11 changed files with 76 additions and 12 deletions

View File

@@ -116,6 +116,11 @@ func (l *Lexer) NextToken() token.Token {
l.readChar()
tok = newToken(token.LTE, l.ch)
tok.Literal = "<="
} else if l.peekChar() == '<' {
ch := l.ch
l.readChar()
literal := string(ch) + string(l.ch)
tok = token.Token{Type: token.LEFT_SHIFT, Literal: literal}
} else {
tok = newToken(token.LT, l.ch)
}
@@ -124,6 +129,11 @@ func (l *Lexer) NextToken() token.Token {
l.readChar()
tok = newToken(token.GTE, l.ch)
tok.Literal = ">="
} else if l.peekChar() == '>' {
ch := l.ch
l.readChar()
literal := string(ch) + string(l.ch)
tok = token.Token{Type: token.RIGHT_SHIFT, Literal: literal}
} else {
tok = newToken(token.GT, l.ch)
}