hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 33d56cc248af22b3ce6bc2dc6b12d51c16929140
parent 7160f3adf59f2c06329de4fdc80dff04042303f7
Author: Drew DeVault <sir@cmpwn.com>
Date:   Fri, 19 Feb 2021 14:28:10 -0500

hare::lex2: add missing div/diveq tokens

Diffstat:
Mhare/lex/+test.ha | 6++++--
Mhare/lex/lex.ha | 7+++++++
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/hare/lex/+test.ha b/hare/lex/+test.ha @@ -80,7 +80,7 @@ fn lextest(in: str, expected: [](uint, uint, token)) void = { @test fn lex2() void = { // Ends with = to test =, EOF - const in = "^ ^^ ^= * *= % %= + += - -= : :: & && &= | || |= = == ="; + const in = "^ ^^ ^= * *= % %= + += - -= : :: & && &= | || |= = == / /= ="; const expected: [_](uint, uint, token) = [ (1, 1, btoken::BXOR), (1, 3, btoken::LXOR), @@ -103,7 +103,9 @@ fn lextest(in: str, expected: [](uint, uint, token)) void = { (1, 47, btoken::OREQ), (1, 50, btoken::EQUAL), (1, 52, btoken::LEQUAL), - (1, 55, btoken::EQUAL), + (1, 55, btoken::DIV), + (1, 57, btoken::DIVEQ), + (1, 60, btoken::EQUAL), ]; lextest(in, expected); }; diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha @@ -158,6 +158,13 @@ fn lex2( }, io::EOF => btoken::TIMES, }, + '/' => match (n) { + r: rune => switch (r) { + '=' => return (btoken::DIVEQ: token, loc), + * => btoken::DIV, + }, + io::EOF => btoken::DIV, + }, '%' => match (n) { r: rune => switch (r) { '=' => return (btoken::MODEQ: token, loc),