aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compile.c2
-rw-r--r--nextlang.c2
-rw-r--r--nextlang.h10
3 files changed, 8 insertions, 6 deletions
diff --git a/compile.c b/compile.c
index 3170369d..1f036c25 100644
--- a/compile.c
+++ b/compile.c
@@ -31,7 +31,7 @@ CORD compile(ast_t *ast)
{
switch (ast->tag) {
case Nil: return CORD_asprintf("(%r)NULL", compile_type(Match(ast, Nil)->type));
- case Bool: return Match(ast, Bool)->b ? "true" : "false";
+ case Bool: return Match(ast, Bool)->b ? "yes" : "no";
case Var: return Match(ast, Var)->name;
case Int: return CORD_asprintf("((Int%ld_t)%ld)", Match(ast, Int)->precision, Match(ast, Int)->i);
case Num: return CORD_asprintf(Match(ast, Num)->precision == 64 ? "%g" : "%gf", Match(ast, Num)->n);
diff --git a/nextlang.c b/nextlang.c
index cc364660..dcff4b91 100644
--- a/nextlang.c
+++ b/nextlang.c
@@ -20,7 +20,7 @@ int main(int argc, char *argv[])
errx(1, "Couldn't set printf specifier");
const char *autofmt = getenv("AUTOFMT");
- if (!autofmt) autofmt = "indent -kr -nut";
+ if (!autofmt) autofmt = "indent -kr -l100 -nbbo -nut";
file_t *f = load_file(argv[1]);
diff --git a/nextlang.h b/nextlang.h
index 18e49dee..bc252bb2 100644
--- a/nextlang.h
+++ b/nextlang.h
@@ -23,12 +23,14 @@
#define String_t CORD
#define Bool_t bool
+#define yes (Bool_t)true
+#define no (Bool_t)false
#define Void_t void
#define __Array(t) array_t
-CORD as_cord(void *x, const char *fmt, ...);
+CORD as_cord(void *x, bool use_color, const char *fmt, ...);
#define CORD_asprintf(...) ({ CORD __c; CORD_sprintf(&__c, __VA_ARGS__); __c; })
#define __declare(var, val) __typeof(val) var = val
@@ -39,10 +41,10 @@ CORD as_cord(void *x, const char *fmt, ...);
double: CORD_asprintf("%g", x), float: CORD_asprintf("%g", x), \
CORD: x, \
char*: (CORD)({ const char *__str = x; __str && __str[0] ? __str : CORD_EMPTY;}), \
- array_t: as_cord(&(x), "[ ]"), \
+ array_t: as_cord(&(x), false, "[ ]"), \
default: "???")
#define __heap(x) (__typeof(x)*)memcpy(GC_MALLOC(sizeof(x)), (__typeof(x)[1]){x}, sizeof(x))
-#define __stack(x) &(x)
+#define __stack(x) (__typeof(x)*)((__typeof(x)[1]){x})
#define __length(x) _Generic(x, default: (x).length)
// Convert negative indices to back-indexed without branching: index0 = index + (index < 0)*(len+1)) - 1
#define __index(x, i) _Generic(x, array_t: ({ __typeof(x) __obj; int64_t __offset = i; __offset += (__offset < 0) * (__obj.length + 1) - 1; assert(__offset >= 0 && offset < __obj.length); __obj.data + __obj.stride * __offset;}))
@@ -78,7 +80,7 @@ CORD as_cord(void *x, const char *fmt, ...);
#define say(str) puts(CORD_to_const_char_star(__cord(str)))
#define __test(src, expr, expected) do { \
CORD __result = __cord(expr); \
- say(CORD_catn(5, USE_COLOR ? "\x1b[33;1m>>\x1b[0m " : ">> ", src, USE_COLOR ? "\n\x1b[0;2m=\x1b[0;35m " : "\n= ", __result, "\x1b[m")); \
+ say(CORD_catn(5, USE_COLOR ? "\x1b[33;1m>>\x1b[0m " : ">> ", src, USE_COLOR ? "\n\x1b[0;2m=\x1b[m " : "\n= ", __result, "\x1b[m")); \
if (expected && CORD_cmp(__result, expected)) { \
errx(1, "I expected:\n%s but got:\n%s", CORD_to_const_char_star(expected), CORD_to_const_char_star(__result)); \
} \