hare

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

commit 26df6419a8cec3a440ce6be518f93ee88919ea18
parent 4f81646c5d252d5d3b9b3835eb57062844fb358d
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue,  2 Feb 2021 13:45:21 -0500

stdlib: add ascii; fmt depends on strconv

Diffstat:
MMakefile | 1+
Mmain.ha | 22++++------------------
Mstdlib.mk | 20++++++++++++++++++--
3 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/Makefile b/Makefile @@ -24,6 +24,7 @@ $(HARECACHE)/hare.ssa: $(hare_srcs) @$(HAREC) -o $@ $(hare_srcs) hare_deps=\ + $(stdlib_ascii) \ $(stdlib_bytes) \ $(stdlib_encoding_utf8) \ $(stdlib_fmt) \ diff --git a/main.ha b/main.ha @@ -1,21 +1,7 @@ -use strings; -use io; +use fmt; +use os; export fn main() void = { - const expected = ['こ', 'ん', 'に', 'ち', 'は']; - let iter = strings::iter("こんにちは"); - let i = 0z; - for (true) { - match (strings::next(&iter)) { - r: rune => { - assert(r == expected[i]); - i += 1z; - }, - void => { - assert(i == len(expected)); - break; - }, - }; - }; - io::println("tada!"); + let x = 1337; + fmt::fprintf(os::stdout, "x: {} {}\n", 1337, "hello"); }; diff --git a/stdlib.mk b/stdlib.mk @@ -33,6 +33,17 @@ $(HARECACHE)/rt/rt.a: $(HARECACHE)/rt/rt.o $(HARECACHE)/rt/syscall.o stdlib_rt=$(HARECACHE)/rt/rt.a stdlib_start=$(HARECACHE)/rt/start.o +# ascii +libascii_srcs=\ + $(STDLIB)/ascii/ctype.ha + +$(HARECACHE)/ascii/ascii.ssa: $(libascii_srcs) $(stdlib_rt) + @printf 'HAREC \t$@\n' + @mkdir -p $(HARECACHE)/ascii + @$(HAREC) -o $@ -Nascii -t$(HARECACHE)/ascii/ascii.td $(libascii_srcs) + +stdlib_ascii=$(HARECACHE)/ascii/ascii.o + # bytes libbytes_srcs=\ $(STDLIB)/bytes/copy.ha \ @@ -95,7 +106,8 @@ stdlib_io=$(HARECACHE)/io/io.o # XXX: Also has ordering issues libencoding_utf8_srcs=\ $(STDLIB)/encoding/utf8/rune.ha \ - $(STDLIB)/encoding/utf8/decode.ha + $(STDLIB)/encoding/utf8/decode.ha \ + $(STDLIB)/encoding/utf8/encode.ha libencoding_utf8_deps=$(stdlib_rt) $(stdlib_types) @@ -126,7 +138,11 @@ stdlib_strings=$(HARECACHE)/strings/strings.o libfmt_srcs=\ $(STDLIB)/fmt/fmt.ha -libfmt_deps=$(stdlib_rt) $(stdlib_types) $(stdlib_io) +libfmt_deps=$(stdlib_rt) \ + $(stdlib_io) \ + $(stdlib_strconv) \ + $(stdlib_strings) \ + $(stdlib_types) $(HARECACHE)/fmt/fmt.ssa: $(libfmt_srcs) $(libfmt_deps) @printf 'HAREC \t$@\n'