commit eb72c729f534b1247d130af4d4bc3770c3ae581e
parent 9a29a949ccbb897b060cafbb8c3f07de744d3731
Author: thing1 <thing1@seacrossedlovers.xyz>
Date: Tue, 5 May 2026 17:28:18 +0100
confusing memory error
Diffstat:
5 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,7 +1,7 @@
.POSIX:
.SUFFIXES:
HARE=hare
-HAREFLAGS=
+HAREFLAGS= -lc
DESTDIR=
PREFIX=/usr/local
@@ -21,12 +21,12 @@ check:
$(HARE) test $(HAREFLAGS)
clean:
- rm -f zpy
+ rm -f zpyi
install:
- install -Dm755 zpy $(DESTDIR)$(BINDIR)/zpy
+ install -Dm755 zpyi $(DESTDIR)$(BINDIR)/zpyi
uninstall:
- rm -f $(DESTDIR)$(BINDIR)/zpy
+ rm -f $(DESTDIR)$(BINDIR)/zpyi
.PHONY: all check clean install uninstall release
diff --git a/zpy/lex/error.ha b/zpy/lex/error.ha
@@ -19,7 +19,7 @@ fn wanted(wanted: []types, l: *lexer) error = {
@test
fn WantedStr() void = {
- let lex = &new(&memio::fixed(strings::toutf8("(foo ")));
+ let lex = new(&memio::fixed(strings::toutf8("(foo ")));
next(lex)!;
next(lex)!;
assert((next(lex) as error).0 == "Wanted: NAME, NUM, '(', ')'");
@@ -27,7 +27,7 @@ fn WantedStr() void = {
@test
fn WantedPos() void = {
- let lex = &new(&memio::fixed(strings::toutf8("(foo ")));
+ let lex = new(&memio::fixed(strings::toutf8("(foo ")));
next(lex)!;
next(lex)!;
assert((next(lex) as error).1 == 5);
diff --git a/zpy/lex/lexer.ha b/zpy/lex/lexer.ha
@@ -30,6 +30,7 @@ fn getItem(l: *lexer, ty: types) lexItem = {
for (let item .. l.items) {
if (item.ty == ty) return item;
};
+ fmt::println(ty: int)!;
abort();
};
@@ -44,12 +45,12 @@ fn stripspace(l: *lexer) void = {
};
// Creates a new lexer object with the correct starting tokens
-export fn new(prog: *memio::stream) lexer = {
- return lexer{
+export fn new(prog: *memio::stream) *lexer = {
+ return alloc(lexer{
in = prog,
nexts = [types::OBRACE],
items = items
- };
+ })!;
};
// Gets the next token from the lexer, or returns an error, the error will
diff --git a/zpy/lex/tokens.ha b/zpy/lex/tokens.ha
@@ -21,6 +21,7 @@ export fn strtypes(ty: types) str = switch (ty) {
case types::NAME => yield "NAME";
case types::NUM => yield "NUM";
case types::EOF => yield "EOF";
+ case => yield "FUCK";
};
diff --git a/zpy/parse/parse.ha b/zpy/parse/parse.ha
@@ -1,6 +1,7 @@
use zpy::lex;
use io;
use strconv;
+use fmt;
export type error = !int;
@@ -29,6 +30,7 @@ export fn parseSexpr(l: *lex::lexer) (node | error) = {
case lex::token => yield;
case => abort();
};
+ fmt::println("got brace")!;
let name = try(l, [&parseName])?;