more minor fixes

This commit is contained in:
Sami Samhuri 2011-04-17 22:23:04 -07:00
parent ebf84f5761
commit 2d55d70770
11 changed files with 35 additions and 35 deletions

4
bool.h
View file

@ -1,5 +1,5 @@
#ifndef _BOOL_H
#define _BOOL_H 1
#ifndef _LAKE_BOOL_H
#define _LAKE_BOOL_H 1
#include "lake.h"

2
env.c
View file

@ -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!");
}

4
env.h
View file

@ -1,5 +1,5 @@
#ifndef _ENV_H
#define _ENV_H 1
#ifndef _LAKE_ENV_H
#define _LAKE_ENV_H 1
#include "hashtab.h"

4
int.h
View file

@ -1,5 +1,5 @@
#ifndef _INT_H
#define _INT_H 1
#ifndef _LAKE_INT_H
#define _LAKE_INT_H 1
#include "lake.h"

2
lake.c
View file

@ -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");
}

8
lake.h
View file

@ -1,5 +1,5 @@
#ifndef _LAKE_H
#define _LAKE_H 1
#ifndef _LAKE_LAKE_H
#define _LAKE_LAKE_H 1
#include <stdlib.h>
@ -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;

4
list.h
View file

@ -1,5 +1,5 @@
#ifndef _LIST_H
#define _LIST_H 1
#ifndef _LAKE_LIST_H
#define _LAKE_LIST_H 1
#include <stdlib.h>
#include "lake.h"

30
parse.c
View file

@ -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);

View file

@ -1,5 +1,5 @@
#ifndef _PARSE_H
#define _PARSE_H 1
#ifndef _LAKE_PARSE_H
#define _LAKE_PARSE_H 1
#include <stdlib.h>
#include "lake.h"

View file

@ -1,5 +1,5 @@
#ifndef _STRING_H
#define _STRING_H 1
#ifndef _LAKE_STRING_H
#define _LAKE_STRING_H 1
#include "lake.h"

4
sym.h
View file

@ -1,5 +1,5 @@
#ifndef _SYM_H
#define _SYM_H 1
#ifndef _LAKE_SYM_H
#define _LAKE_SYM_H 1
#include "lake.h"