Implemented thos bad boys

main
Sasha Koshka 3 months ago
parent b536b01eeb
commit 9232432c35
  1. 21
      lexer/lexer.go
  2. 6
      lexer/lexer_test.go
  3. 2
      tests/lexer/all.arf

@ -242,9 +242,15 @@ func (lexer *LexingOperation) tokenizeSymbolBeginning () (err error) {
err = lexer.nextRune()
case '!':
token := lexer.newToken()
err = lexer.nextRune()
if err != nil { return }
token.kind = TokenKindExclamation
if lexer.char == '=' {
token.kind = TokenKindNotEqualTo
err = lexer.nextRune()
token.location.SetWidth(2)
}
lexer.addToken(token)
err = lexer.nextRune()
case '%':
token := lexer.newToken()
token.kind = TokenKindPercent
@ -255,6 +261,11 @@ func (lexer *LexingOperation) tokenizeSymbolBeginning () (err error) {
token.kind = TokenKindTilde
lexer.addToken(token)
err = lexer.nextRune()
case '=':
token := lexer.newToken()
token.kind = TokenKindEqualTo
lexer.addToken(token)
err = lexer.nextRune()
case '<':
token := lexer.newToken()
err = lexer.nextRune()
@ -264,6 +275,10 @@ func (lexer *LexingOperation) tokenizeSymbolBeginning () (err error) {
token.kind = TokenKindLShift
err = lexer.nextRune()
token.location.SetWidth(2)
} else if lexer.char == '=' {
token.kind = TokenKindLessThanEqualTo
err = lexer.nextRune()
token.location.SetWidth(2)
}
lexer.addToken(token)
case '>':
@ -275,6 +290,10 @@ func (lexer *LexingOperation) tokenizeSymbolBeginning () (err error) {
token.kind = TokenKindRShift
err = lexer.nextRune()
token.location.SetWidth(2)
} else if lexer.char == '=' {
token.kind = TokenKindGreaterThanEqualTo
err = lexer.nextRune()
token.location.SetWidth(2)
}
lexer.addToken(token)
case '|':

@ -154,12 +154,12 @@ func TestTokenizeAll (test *testing.T) {
quickToken(1, TokenKindPercent, nil),
quickToken(1, TokenKindTilde, nil),
quickToken(1, TokenKindEqualTo, nil),
quickToken(1, TokenKindNotEqualTo, nil),
quickToken(2, TokenKindNotEqualTo, nil),
quickToken(1, TokenKindLessThan, nil),
quickToken(1, TokenKindLessThanEqualTo, nil),
quickToken(2, TokenKindLessThanEqualTo, nil),
quickToken(2, TokenKindLShift, nil),
quickToken(1, TokenKindGreaterThan, nil),
quickToken(1, TokenKindGreaterThanEqualTo, nil),
quickToken(2, TokenKindGreaterThanEqualTo, nil),
quickToken(2, TokenKindRShift, nil),
quickToken(1, TokenKindBinaryOr, nil),
quickToken(2, TokenKindLogicalOr, nil),

@ -1,3 +1,3 @@
:arf
--- rw -> -349820394 932748397 239485.37520 "hello world!\n" 'E' helloWorld:.,..[]{}
+ - ++ -- * / @ ! % ~ = != < <= << > => >> | || & &&
+ - ++ -- * / @ ! % ~ = != < <= << > >= >> | || & &&