hare

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

commit 020b987abdf0894b1f14afa57c007f81403ffe19
parent c31f7a9669404a592aa3c51d669d52cad93b14a6
Author: Ember Sawady <ecs@d2evs.net>
Date:   Sun, 29 Jan 2023 19:00:05 +0000

Simplify lex2 for '-' and ':'

They used to have special cases for negative literals and labels
respectively, but handling of both of those was moved into the parser

Signed-off-by: Ember Sawady <ecs@d2evs.net>

Diffstat:
Mhare/lex/lex.ha | 30++----------------------------
1 file changed, 2 insertions(+), 28 deletions(-)

diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha @@ -640,35 +640,9 @@ fn lex2(lexr: *lexer) (token | error) = { case '+' => yield (ltok::PLUS, [('=', ltok::PLUSEQ)]); case '-' => - match (next(lexr)?) { - case let r: (rune, location) => - switch (r.0) { - case '=' => - line_comment(lexr)?; - return (ltok::MINUSEQ, void, first.1); - case => - unget(lexr, r); - line_comment(lexr)?; - return (ltok::MINUS, void, first.1); - }; - case io::EOF => - return (ltok::MINUS, void, first.1); - }; + yield (ltok::MINUS, [('=', ltok::MINUSEQ)]); case ':' => - match (next(lexr)?) { - case let r: (rune, location) => - switch (r.0) { - case ':' => - line_comment(lexr)?; - return (ltok::DOUBLE_COLON, void, first.1); - case => - unget(lexr, r); - line_comment(lexr)?; - return (ltok::COLON, void, first.1); - }; - case io::EOF => - return (ltok::COLON, void, first.1); - }; + yield (ltok::COLON, [(':', ltok::DOUBLE_COLON)]); case '!' => yield (ltok::LNOT, [('=', ltok::NEQUAL)]); case '=' =>