From 2d55d707706b18564d63910bb84f9282bf492615 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 17 Apr 2011 22:23:04 -0700 Subject: [PATCH] more minor fixes --- bool.h | 4 ++-- env.c | 2 +- env.h | 4 ++-- int.h | 4 ++-- lake.c | 2 +- lake.h | 8 ++++---- list.h | 4 ++-- parse.c | 30 +++++++++++++++--------------- parse.h | 4 ++-- string.h | 4 ++-- sym.h | 4 ++-- 11 files changed, 35 insertions(+), 35 deletions(-) diff --git a/bool.h b/bool.h index 6ed9cf2..0e521d3 100644 --- a/bool.h +++ b/bool.h @@ -1,5 +1,5 @@ -#ifndef _BOOL_H -#define _BOOL_H 1 +#ifndef _LAKE_BOOL_H +#define _LAKE_BOOL_H 1 #include "lake.h" diff --git a/env.c b/env.c index 4425b1e..c02079e 100644 --- a/env.c +++ b/env.c @@ -100,7 +100,7 @@ LakeVal *env_eval(Env *env, LakeVal *expr) break; default: - printf("unrecognized value, type %d, size %lu bytes", expr->type, expr->size); + printf("unrecognized value, type %d, size %Zu bytes", expr->type, expr->size); die("we don't eval that around here!"); } diff --git a/env.h b/env.h index 34bd0a1..802835b 100644 --- a/env.h +++ b/env.h @@ -1,5 +1,5 @@ -#ifndef _ENV_H -#define _ENV_H 1 +#ifndef _LAKE_ENV_H +#define _LAKE_ENV_H 1 #include "hashtab.h" diff --git a/int.h b/int.h index b43c5d9..09056c3 100644 --- a/int.h +++ b/int.h @@ -1,5 +1,5 @@ -#ifndef _INT_H -#define _INT_H 1 +#ifndef _LAKE_INT_H +#define _LAKE_INT_H 1 #include "lake.h" diff --git a/lake.c b/lake.c index 18025b4..d0d0994 100644 --- a/lake.c +++ b/lake.c @@ -150,7 +150,7 @@ char *repr(LakeVal *expr) break; default: - printf("unrecognized value, type %d, size %lu bytes", expr->type, expr->size); + printf("unrecognized value, type %d, size %Zu bytes", expr->type, expr->size); s = strdup("unrecognized value"); } diff --git a/lake.h b/lake.h index dc5c010..dda8ec3 100644 --- a/lake.h +++ b/lake.h @@ -1,5 +1,5 @@ -#ifndef _LAKE_H -#define _LAKE_H 1 +#ifndef _LAKE_LAKE_H +#define _LAKE_LAKE_H 1 #include @@ -30,8 +30,8 @@ typedef struct lake_val LakeVal; LakeVal *NIL; typedef LakeVal *NILP; -#define VAL_SIZE(x) (x != NULL ? x->size : NIL->size) -#define VAL_OR_NIL(x) (x != NULL ? (LakeVal *)x : NIL) +#define VAL_SIZE(x) (x != NULL ? VAL(x)->size : NIL->size) +#define VAL_OR_NIL(x) (x != NULL ? VAL(x) : NIL) struct lake_sym { LakeVal base; diff --git a/list.h b/list.h index c439076..d8173d7 100644 --- a/list.h +++ b/list.h @@ -1,5 +1,5 @@ -#ifndef _LIST_H -#define _LIST_H 1 +#ifndef _LAKE_LIST_H +#define _LAKE_LIST_H 1 #include #include "lake.h" diff --git a/parse.c b/parse.c index 00191f9..f6e41e3 100644 --- a/parse.c +++ b/parse.c @@ -18,7 +18,7 @@ LakeVal *parse_expr(char *s, size_t n) Ctx ctx = { s, n, 0 }; LakeVal *result = _parse_expr(&ctx); if (ctx.i < ctx.n) { - printf("ignoring %lu trailing chars: %s\n", ctx.n - ctx.i - 1, ctx.s + ctx.i); + printf("ignoring %Zu trailing chars: %s\n", ctx.n - ctx.i - 1, ctx.s + ctx.i); } return result; } @@ -121,7 +121,7 @@ static char *parse_while(Ctx *ctx, int (*is_valid)(char)) return s; } -static LakeInt *parse_int(Ctx *ctx) +static LakeVal *parse_int(Ctx *ctx) { int n = 0; char c = peek(ctx); @@ -134,7 +134,7 @@ static LakeInt *parse_int(Ctx *ctx) n += c - '0'; consume1(ctx); } - return int_from_c(sign * n); + return VAL(int_from_c(sign * n)); } static int is_sym_char(char c) @@ -142,7 +142,7 @@ static int is_sym_char(char c) return is_letter(c) || is_symbol(c) || is_digit(c); } -static LakeSym *parse_sym(Ctx *ctx) +static LakeVal *parse_sym(Ctx *ctx) { static int size = 1024; char s[size]; @@ -154,7 +154,7 @@ static LakeSym *parse_sym(Ctx *ctx) } s[i] = 0; /* TODO: check for #t and #f and return true boolean values (LakeBool *) */ - return sym_intern(s); + return VAL(sym_intern(s)); } static char escape_char(char c) @@ -181,7 +181,7 @@ static char escape_char(char c) return c; } -static LakeStr *parse_str(Ctx *ctx) +static LakeVal *parse_str(Ctx *ctx) { size_t n = 8; size_t i = 0; @@ -209,10 +209,10 @@ static LakeStr *parse_str(Ctx *ctx) ch(ctx, '"'); LakeStr *str = str_from_c(s); free(s); - return str; + return VAL(str); } -static LakeList* parse_list(Ctx *ctx) +static LakeVal* parse_list(Ctx *ctx) { LakeList *list = list_make(); ch(ctx, '('); @@ -225,7 +225,7 @@ static LakeList* parse_list(Ctx *ctx) list_append(list, _parse_expr(ctx)); } ch(ctx, ')'); - return list; + return VAL(list); } static int is_not_newline(char c) @@ -244,26 +244,26 @@ static LakeVal *_parse_expr(Ctx *ctx) char c = peek(ctx); /*char d =*/ peek2(ctx); if (c >= '0' && c <= '9') { - result = (LakeVal *)parse_int(ctx); + result = VAL(parse_int(ctx)); } /* TODO: chars else if (c == '#' && d == '\\') { - result = (LakeVal *)parse_char(ctx); + result = parse_char(ctx); } */ else if (is_letter(c) || is_symbol(c)) { - result = (LakeVal *)parse_sym(ctx); + result = parse_sym(ctx); } else if (c == '"') { - result = (LakeVal *)parse_str(ctx); + result = parse_str(ctx); } /* TODO: quote else if (c == '\'') { - result = (LakeVal *)parse_quoted(ctx); + result = parse_quoted(ctx); } */ else if (c == '(') { - result = (LakeVal *)parse_list(ctx); + result = parse_list(ctx); } else if (c == ';') { parse_comment(ctx); diff --git a/parse.h b/parse.h index dc545cf..043e7a5 100644 --- a/parse.h +++ b/parse.h @@ -1,5 +1,5 @@ -#ifndef _PARSE_H -#define _PARSE_H 1 +#ifndef _LAKE_PARSE_H +#define _LAKE_PARSE_H 1 #include #include "lake.h" diff --git a/string.h b/string.h index 84a2fb9..f504868 100644 --- a/string.h +++ b/string.h @@ -1,5 +1,5 @@ -#ifndef _STRING_H -#define _STRING_H 1 +#ifndef _LAKE_STRING_H +#define _LAKE_STRING_H 1 #include "lake.h" diff --git a/sym.h b/sym.h index 4c48dc8..9fc4ef9 100644 --- a/sym.h +++ b/sym.h @@ -1,5 +1,5 @@ -#ifndef _SYM_H -#define _SYM_H 1 +#ifndef _LAKE_SYM_H +#define _LAKE_SYM_H 1 #include "lake.h"