From 91573bf993dc595dcbc1f83c28c4f7ee66ac334b Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Wed, 11 Dec 2019 13:20:06 -0500 Subject: fixed some cgen stuff --- cgen.c | 4 +--- test.toc | 9 +++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cgen.c b/cgen.c index 0cd5536..7e50024 100644 --- a/cgen.c +++ b/cgen.c @@ -1707,7 +1707,7 @@ static bool cgen_val_ptr(CGenerator *g, void *v, Type *t, Location where) { case BUILTIN_U64: cgen_write(g, "%"PRIu64, *(U64 *)v); break; case BUILTIN_F32: cgen_write(g, F32_FMT"f", *(F32 *)v); break; case BUILTIN_F64: cgen_write(g, F64_FMT, *(F64 *)v); break; - case BUILTIN_CHAR: cgen_write(g, "\\x%02x", *(char *)v); break; + case BUILTIN_CHAR: cgen_write(g, "'\\x%02x'", *(char *)v); break; case BUILTIN_BOOL: cgen_write(g, "%s", *(bool *)v ? "true" : "false"); break; } break; @@ -1752,8 +1752,6 @@ static bool cgen_decl(CGenerator *g, Declaration *d) { if (!cgen_val_pre(g, *val, type, d->where)) return false; } - if (g->block != NULL) - cgen_write(g, "static "); if (!cgen_type_pre(g, type, d->where)) return false; cgen_write(g, " "); cgen_ident(g, i); diff --git a/test.toc b/test.toc index 74980c0..8cb0741 100644 --- a/test.toc +++ b/test.toc @@ -1,7 +1,8 @@ -f ::= fn(t::=, x :t) t { - x + 1 +P ::= struct { + x, y:int; }; - main ::= fn() { - f(13); + p:P; + x::="y"; + p[x]; }; \ No newline at end of file -- cgit v1.2.3