Implemented thos bad boys

This commit is contained in:
Sasha Koshka 2022-08-25 00:05:40 -04:00
parent b536b01eeb
commit 9232432c35
3 changed files with 25 additions and 6 deletions

View File

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

View File

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

View File

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