hare

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

commit 174b82148bad5a601fc5d4561e3d956c8879d981
parent c3aa58e555fc8532bdc7243a6b32f7b24f006b82
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 14 Feb 2021 16:46:47 -0500

Update stdlib

Diffstat:
Mgen-stdlib | 19+++++++++++++++----
Mmain.ha | 22++++++++++------------
Mmk/stdlib.mk | 3++-
3 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/gen-stdlib b/gen-stdlib @@ -138,12 +138,23 @@ fmt() { gen_ssa fmt io os strconv strings types } -hare_lex() { - printf '# hare::lex\n' +gensrcs_hare_lex() { gen_srcs hare::lex \ token.ha \ - lex.ha - gen_ssa hare::lex io bufio strings types + lex.ha \ + $* +} + +hare_lex() { + printf '# hare::lex\n' + if [ $testing -eq 0 ] + then + gensrcs_hare_lex + else + gensrcs_hare_lex \ + +test.ha + fi + gen_ssa hare::lex io bufio strings types fmt } gensrcs_io() { diff --git a/main.ha b/main.ha @@ -5,17 +5,15 @@ use os; export fn main() void = { let lexer = lex::lexer_init(os::stdin, "<stdin>"); - for (true) { - match (lex::lex(&lexer)) { - t: (lex::token, lex::location) => { - let tok = t.0, loc = t.1; - fmt::println("{}@{},{}: '{}'", - loc.path, loc.line, loc.col, - lex::tokstr(tok)); - }, - err: lex::error => fmt::fatal("Error: {}", lex::errstr(err)), - io::EOF => break, - * => abort(), - }; + for (true) match (lex::lex(&lexer)) { + t: (lex::token, lex::location) => { + let tok = t.0, loc = t.1; + fmt::println("{}@{},{}: '{}'", + loc.path, loc.line, loc.col, + lex::tokstr(tok)); + }, + err: lex::error => fmt::fatal("Error: {}", lex::errstr(err)), + io::EOF => break, + * => abort(), }; }; diff --git a/mk/stdlib.mk b/mk/stdlib.mk @@ -436,7 +436,8 @@ $(TESTCACHE)/fmt/fmt.ssa: $(testlib_fmt_srcs) $(testlib_rt) $(testlib_io) $(test # hare::lex testlib_hare_lex_srcs= \ $(STDLIB)/hare/lex/token.ha \ - $(STDLIB)/hare/lex/lex.ha + $(STDLIB)/hare/lex/lex.ha \ + $(STDLIB)/hare/lex/+test.ha $(TESTCACHE)/hare/lex/hare.lex.ssa: $(testlib_hare_lex_srcs) $(testlib_rt) $(testlib_io) $(testlib_bufio) $(testlib_strings) $(testlib_types) @printf 'HAREC \t$@\n'