bitwise operators and boolean operators
Some checks failed
Test / build (push) Waiting to run
Build / build (push) Has been cancelled

This commit is contained in:
Chuck Smith
2024-03-23 10:00:02 -04:00
parent cbb430b47d
commit ef8c8f8f04
13 changed files with 427 additions and 188 deletions

View File

@@ -74,7 +74,7 @@ func (l *Lexer) NextToken() token.Token {
Literal: literal,
}
} else {
tok = newToken(token.BANG, l.ch)
tok = newToken(token.NOT, l.ch)
}
case '/':
@@ -83,12 +83,34 @@ func (l *Lexer) NextToken() token.Token {
tok.Type = token.COMMENT
tok.Literal = l.readLine()
} else {
tok = newToken(token.SLASH, l.ch)
tok = newToken(token.DIVIDE, l.ch)
}
case '*':
tok = newToken(token.ASTERISK, l.ch)
tok = newToken(token.MULTIPLY, l.ch)
case '%':
tok = newToken(token.PERCENT, l.ch)
tok = newToken(token.MODULO, l.ch)
case '&':
if l.peekChar() == '&' {
ch := l.ch
l.readChar()
literal := string(ch) + string(l.ch)
tok = token.Token{Type: token.AND, Literal: literal}
} else {
tok = newToken(token.BITWISE_AND, l.ch)
}
case '|':
if l.peekChar() == '|' {
ch := l.ch
l.readChar()
literal := string(ch) + string(l.ch)
tok = token.Token{Type: token.OR, Literal: literal}
} else {
tok = newToken(token.BITWISE_OR, l.ch)
}
case '^':
tok = newToken(token.BITWISE_XOR, l.ch)
case '~':
tok = newToken(token.BITWISE_NOT, l.ch)
case '<':
if l.peekChar() == '=' {
l.readChar()