Added equals assignment operator

The set phrase will be removed and just replaced with a single
equals sign. Double equals will be used for comparison. This will
be much easier to understand.
This commit is contained in:
Sasha Koshka 2022-09-03 20:23:27 -04:00
parent aff2e55aa5
commit cc14292c63
4 changed files with 14 additions and 4 deletions

View File

@ -275,9 +275,15 @@ func (lexer *LexingOperation) tokenizeSymbolBeginning () (err error) {
lexer.addToken(token)
case '=':
token := lexer.newToken()
token.kind = TokenKindEqualTo
lexer.addToken(token)
err = lexer.nextRune()
if err != nil { return }
token.kind = TokenKindAssignment
if lexer.char == '=' {
token.kind = TokenKindEqualTo
err = lexer.nextRune()
token.location.SetWidth(2)
}
lexer.addToken(token)
case '<':
token := lexer.newToken()
err = lexer.nextRune()

View File

@ -155,7 +155,8 @@ func TestTokenizeAll (test *testing.T) {
quickToken(2, TokenKindPercentAssignment, nil),
quickToken(1, TokenKindTilde, nil),
quickToken(2, TokenKindTildeAssignment, nil),
quickToken(1, TokenKindEqualTo, nil),
quickToken(1, TokenKindAssignment, nil),
quickToken(2, TokenKindEqualTo, nil),
quickToken(2, TokenKindNotEqualTo, nil),
quickToken(1, TokenKindLessThan, nil),
quickToken(2, TokenKindLessThanEqualTo, nil),

View File

@ -47,6 +47,7 @@ const (
TokenKindTilde
TokenKindTildeAssignment
TokenKindAssignment
TokenKindEqualTo
TokenKindNotEqualTo
TokenKindLessThanEqualTo
@ -197,6 +198,8 @@ func (tokenKind TokenKind) Describe () (description string) {
description = "Tilde"
case TokenKindTildeAssignment:
description = "TildeAssignment"
case TokenKindAssignment:
description = "Assignment"
case TokenKindEqualTo:
description = "EqualTo"
case TokenKindNotEqualTo:

View File

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