hare

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

commit eecfabb69c6fe45e8aa1643a81931352142e534f
parent 2529f630402370e81e43322b3fb7df078b7e4339
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Mon, 22 Feb 2021 09:49:42 -0500

Update for switch/match cases being scope expressions

Diffstat:
Mcrypto/random/+linux.ha | 4+---
Mcrypto/random/random.ha | 4+---
Mfmt/fmt.ha | 44+++++++++++---------------------------------
Mhare/lex/lex.ha | 8++------
4 files changed, 15 insertions(+), 45 deletions(-)

diff --git a/crypto/random/+linux.ha b/crypto/random/+linux.ha @@ -13,9 +13,7 @@ export fn buffer(buf: []u8) void = { rt::EINTR => void, * => abort(), }, - z: size => { - n += z; - }, + z: size => n += z, }; }; }; diff --git a/crypto/random/random.ha b/crypto/random/random.ha @@ -32,9 +32,7 @@ export let stream: *io::stream = null: *io::stream; let test: []u8 = []; match (io::read(stream, buf[..])) { (io::error | io::EOF) => abort(), - n: size => { - test = buf[..n]; - }, + n: size => test = buf[..n], }; assert(len(test) > 0); diff --git a/fmt/fmt.ha b/fmt/fmt.ha @@ -155,15 +155,11 @@ export fn fprintf( match (io::write(s, utf8::encode_rune('}'))) { err: io::error => return err, - w: size => { - n += w; - }, + w: size => n += w, }; } else match (io::write(s, utf8::encode_rune(r))) { err: io::error => return err, - w: size => { - n += w; - }, + w: size => n += w, }; }; @@ -247,18 +243,10 @@ fn scan_modifier_flags(iter: *strings::iterator, mod: *modifiers) void = { }; switch (r) { - '0' => { - flags |= modflags::ZERO; - }, - '-' => { - flags |= modflags::MINUS; - }, - ' ' => { - flags |= modflags::SPACE; - }, - '+' => { - flags |= modflags::PLUS; - }, + '0' => flags |= modflags::ZERO, + '-' => flags |= modflags::MINUS, + ' ' => flags |= modflags::SPACE, + '+' => flags |= modflags::PLUS, * => { strings::push(iter, r); break; @@ -315,21 +303,11 @@ fn scan_modifier_base(iter: *strings::iterator, mod: *modifiers) void = { }; switch (r) { - 'x' => { - mod.base = strconv::base::HEX_LOWER; - }, - 'X' => { - mod.base = strconv::base::HEX_UPPER; - }, - 'o' => { - mod.base = strconv::base::OCT; - }, - 'b' => { - mod.base = strconv::base::BIN; - }, - * => { - strings::push(iter, r); - }, + 'x' => mod.base = strconv::base::HEX_LOWER, + 'X' => mod.base = strconv::base::HEX_UPPER, + 'o' => mod.base = strconv::base::OCT, + 'b' => mod.base = strconv::base::BIN, + * => strings::push(iter, r), }; }; diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha @@ -518,12 +518,8 @@ fn lexloc(lex: *lexer, r: rune) void = { lex.loc.0 += 1; lex.loc.1 = 1; }, - '\t' => { - lex.loc.1 += 8; - }, - * => { - lex.loc.1 += 1; - }, + '\t' => lex.loc.1 += 8, + * => lex.loc.1 += 1, }; };