hare

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

commit 4f81646c5d252d5d3b9b3835eb57062844fb358d
parent 760beba083fa7ef67a20d914c764a99bf34e4b4e
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon,  1 Feb 2021 17:57:34 -0500

main.ha: use strings::iter

Diffstat:
Mmain.ha | 7++-----
Mstdlib.mk | 33+++++++++++++++++----------------
2 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/main.ha b/main.ha @@ -1,13 +1,12 @@ -use encoding::utf8; use strings; use io; export fn main() void = { const expected = ['こ', 'ん', 'に', 'ち', 'は']; - let decoder = utf8::decode("こんにちは"); + let iter = strings::iter("こんにちは"); let i = 0z; for (true) { - match (utf8::next(&decoder)) { + match (strings::next(&iter)) { r: rune => { assert(r == expected[i]); i += 1z; @@ -16,8 +15,6 @@ export fn main() void = { assert(i == len(expected)); break; }, - utf8::more => abort("more"), - utf8::invalid => abort("invalid"), }; }; io::println("tada!"); diff --git a/stdlib.mk b/stdlib.mk @@ -91,28 +91,13 @@ $(HARECACHE)/io/io.ssa: $(libio_srcs) $(stdlib_rt) stdlib_io=$(HARECACHE)/io/io.o -# strings -libstrings_srcs=\ - $(STDLIB)/strings/cstrings.ha \ - $(STDLIB)/strings/dup.ha \ - $(STDLIB)/strings/utf8.ha - -libstrings_deps=$(stdlib_rt) $(stdlib_types) - -$(HARECACHE)/strings/strings.ssa: $(libstrings_srcs) $(libstrings_deps) - @printf 'HAREC \t$@\n' - @mkdir -p $(HARECACHE)/strings - @$(HAREC) -o $@ -Nstrings -t$(HARECACHE)/strings/strings.td $(libstrings_srcs) - -stdlib_strings=$(HARECACHE)/strings/strings.o - # encoding/utf8 # XXX: Also has ordering issues libencoding_utf8_srcs=\ $(STDLIB)/encoding/utf8/rune.ha \ $(STDLIB)/encoding/utf8/decode.ha -libencoding_utf8_deps=$(stdlib_rt) $(stdlib_types) $(stdlib_strings) +libencoding_utf8_deps=$(stdlib_rt) $(stdlib_types) $(HARECACHE)/encoding/utf8/encoding.utf8.ssa: $(libencoding_utf8_srcs) $(libencoding_utf8_deps) @printf 'HAREC \t$@\n' @@ -121,6 +106,22 @@ $(HARECACHE)/encoding/utf8/encoding.utf8.ssa: $(libencoding_utf8_srcs) $(libenco stdlib_encoding_utf8=$(HARECACHE)/encoding/utf8/encoding.utf8.o +# strings +libstrings_srcs=\ + $(STDLIB)/strings/cstrings.ha \ + $(STDLIB)/strings/dup.ha \ + $(STDLIB)/strings/iter.ha \ + $(STDLIB)/strings/utf8.ha + +libstrings_deps=$(stdlib_rt) $(stdlib_types) $(stdlib_encoding_utf8) + +$(HARECACHE)/strings/strings.ssa: $(libstrings_srcs) $(libstrings_deps) + @printf 'HAREC \t$@\n' + @mkdir -p $(HARECACHE)/strings + @$(HAREC) -o $@ -Nstrings -t$(HARECACHE)/strings/strings.td $(libstrings_srcs) + +stdlib_strings=$(HARECACHE)/strings/strings.o + # fmt libfmt_srcs=\ $(STDLIB)/fmt/fmt.ha