bitwise operators and boolean operators
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user