From 453a59658725cb8bbc01f8f2129e99c5336d0459 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 25 Aug 2022 23:17:42 -0400 Subject: [PATCH] Added test case for new tokens --- lexer/lexer_test.go | 8 ++++++++ lexer/token.go | 8 ++++++++ tests/lexer/all.arf | 2 +- tests/parser/func/main.arf | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lexer/lexer_test.go b/lexer/lexer_test.go index e77d9f5..371269e 100644 --- a/lexer/lexer_test.go +++ b/lexer/lexer_test.go @@ -152,19 +152,27 @@ func TestTokenizeAll (test *testing.T) { quickToken(1, TokenKindAt, nil), quickToken(1, TokenKindExclamation, nil), quickToken(1, TokenKindPercent, nil), + quickToken(2, TokenKindPercentAssignment, nil), quickToken(1, TokenKindTilde, nil), + quickToken(2, TokenKindTildeAssignment, nil), quickToken(1, TokenKindEqualTo, nil), quickToken(2, TokenKindNotEqualTo, nil), quickToken(1, TokenKindLessThan, nil), quickToken(2, TokenKindLessThanEqualTo, nil), quickToken(2, TokenKindLShift, nil), + quickToken(3, TokenKindLShiftAssignment, nil), quickToken(1, TokenKindGreaterThan, nil), quickToken(2, TokenKindGreaterThanEqualTo, nil), quickToken(2, TokenKindRShift, nil), + quickToken(3, TokenKindRShiftAssignment, nil), quickToken(1, TokenKindBinaryOr, nil), + quickToken(2, TokenKindBinaryOrAssignment, nil), quickToken(2, TokenKindLogicalOr, nil), quickToken(1, TokenKindBinaryAnd, nil), + quickToken(2, TokenKindBinaryAndAssignment, nil), quickToken(2, TokenKindLogicalAnd, nil), + quickToken(1, TokenKindBinaryXor, nil), + quickToken(2, TokenKindBinaryXorAssignment, nil), quickToken(1, TokenKindNewline, nil), ) } diff --git a/lexer/token.go b/lexer/token.go index 3b41a41..8df2170 100644 --- a/lexer/token.go +++ b/lexer/token.go @@ -43,20 +43,28 @@ const ( TokenKindAt TokenKindExclamation TokenKindPercent + TokenKindPercentAssignment TokenKindTilde + TokenKindTildeAssignment TokenKindEqualTo TokenKindNotEqualTo TokenKindLessThanEqualTo TokenKindLessThan TokenKindLShift + TokenKindLShiftAssignment TokenKindGreaterThan TokenKindGreaterThanEqualTo TokenKindRShift + TokenKindRShiftAssignment TokenKindBinaryOr + TokenKindBinaryOrAssignment TokenKindLogicalOr TokenKindBinaryAnd + TokenKindBinaryAndAssignment TokenKindLogicalAnd + TokenKindBinaryXor + TokenKindBinaryXorAssignment ) // Token represents a single token. It holds its location in the file, as well diff --git a/tests/lexer/all.arf b/tests/lexer/all.arf index 51ae12e..a0b028c 100644 --- a/tests/lexer/all.arf +++ b/tests/lexer/all.arf @@ -1,3 +1,3 @@ :arf --- rw -> -349820394 932748397 239485.37520 "hello world!\n" 'E' helloWorld:.,..[]{} -+ - ++ -- * / @ ! % ~ = != < <= << > >= >> | || & && ++ - ++ -- * / @ ! % %= ~ ~= = != < <= << <<= > >= >> >>= | |= || & &= && ^ ^= diff --git a/tests/parser/func/main.arf b/tests/parser/func/main.arf index 4b356aa..811ed9a 100644 --- a/tests/parser/func/main.arf +++ b/tests/parser/func/main.arf @@ -39,7 +39,7 @@ func ro eMath -- y set z [+ [* 0392 00] 98 x [/ 9832 y] 930] - # TODO: need tokens |= &= ~= <<= >>= + # TODO: need tokens ~= ! true ~ 0b01