iris

small scheme interpreter
git clone git://git.2f30.org/iris
Log | Files | Refs | LICENSE

commit b05003b726829c89d79aa895f7f7da1417779bfe
parent 8c1168fc1c6d93116ce70843e8e2f06e34ec18d5
Author: sin <sin@2f30.org>
Date:   Fri, 16 May 2014 13:19:07 +0100

Rename i.s to i.name for identifiers

Diffstat:
Mparser.c | 38+++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/parser.c b/parser.c @@ -34,7 +34,7 @@ struct object { } eof; /* identifier */ struct { - char *s; + char *name; } i; /* boolean */ struct { @@ -138,7 +138,7 @@ identifier(char *s) o = newobject(); o->type = OIdentifier; - o->d.i.s = estrdup(s); + o->d.i.name = estrdup(s); return o; } @@ -330,7 +330,7 @@ evaldefine(struct object *o) if (o->type != OPair) return NULL; if (car(o)->type != OIdentifier || - strcmp(car(o)->d.i.s, "define") != 0) + strcmp(car(o)->d.i.name, "define") != 0) return NULL; var = cadr(o); if (var->type != OIdentifier) @@ -342,7 +342,7 @@ evaldefine(struct object *o) val = eval(caddr(o)); if (val->type == OError) return val; - addsym(var->d.i.s, val); + addsym(var->d.i.name, val); return lookupsym("ok"); } @@ -354,7 +354,7 @@ evalif(struct object *o) if (o->type != OPair) return NULL; if (car(o)->type != OIdentifier || - strcmp(car(o)->d.i.s, "if") != 0) + strcmp(car(o)->d.i.name, "if") != 0) return NULL; predicate = eval(cadr(o)); if (predicate->type == OError) @@ -369,7 +369,7 @@ static struct object * evalok(struct object *o) { if (o->type == OIdentifier) - if (strcmp(o->d.i.s, "ok") == 0) + if (strcmp(o->d.i.name, "ok") == 0) return o; return NULL; } @@ -379,7 +379,7 @@ evalquote(struct object *o) { if (o->type == OPair) if (car(o)->type == OIdentifier && - strcmp(car(o)->d.i.s, "quote") == 0) + strcmp(car(o)->d.i.name, "quote") == 0) return cadr(o); return NULL; } @@ -392,12 +392,12 @@ evalset(struct object *o) if (o->type != OPair) return NULL; if (car(o)->type != OIdentifier || - strcmp(car(o)->d.i.s, "set") != 0) + strcmp(car(o)->d.i.name, "set") != 0) return NULL; var = cadr(o); if (var->type != OIdentifier) return error("expected identifier"); - if (!lookupsym(var->d.i.s)) + if (!lookupsym(var->d.i.name)) return error("unbound identifier"); if (!caddr(o)) return error("expected sexpression"); @@ -406,7 +406,7 @@ evalset(struct object *o) val = eval(caddr(o)); if (val->type == OError) return val; - addsym(var->d.i.s, val); + addsym(var->d.i.name, val); return lookupsym("ok"); } @@ -418,7 +418,7 @@ evalboolean(struct object *o) if (o->type != OPair) return NULL; if (car(o)->type != OIdentifier || - strcmp(car(o)->d.i.s, "boolean") != 0) + strcmp(car(o)->d.i.name, "boolean") != 0) return NULL; arg = eval(cadr(o)); if (arg->type == OError) @@ -454,7 +454,7 @@ evaldiff(struct object *o) if (o->type != OPair) return NULL; if (car(o)->type != OIdentifier || - strcmp(car(o)->d.i.s, "diff") != 0) + strcmp(car(o)->d.i.name, "diff") != 0) return NULL; n = eval(cadr(o)); if (n->type == OError) @@ -476,7 +476,7 @@ evalinteger(struct object *o) if (o->type != OPair) return NULL; if (car(o)->type != OIdentifier || - strcmp(car(o)->d.i.s, "integer") != 0) + strcmp(car(o)->d.i.name, "integer") != 0) return NULL; arg = eval(cadr(o)); if (arg->type == OError) @@ -496,7 +496,7 @@ evalnull(struct object *o) if (o->type != OPair) return NULL; if (car(o)->type != OIdentifier || - strcmp(car(o)->d.i.s, "null") != 0) + strcmp(car(o)->d.i.name, "null") != 0) return NULL; arg = eval(cadr(o)); if (arg->type == OError) @@ -530,7 +530,7 @@ evalplus(struct object *o) if (o->type != OPair) return NULL; if (car(o)->type != OIdentifier || - strcmp(car(o)->d.i.s, "plus") != 0) + strcmp(car(o)->d.i.name, "plus") != 0) return NULL; return doplus(cdr(o), integer(0)); } @@ -553,18 +553,18 @@ eval(struct object *o) } /* evaluate identifiers */ if (o->type == OIdentifier) { - otmp = lookupsym(o->d.i.s); + otmp = lookupsym(o->d.i.name); if (!otmp) return error("unbound identifier"); return otmp; } /* evaluate builtins and procedures */ if (o->type == OPair) { - otmp = lookupsym(car(o)->d.i.s); + otmp = lookupsym(car(o)->d.i.name); if (otmp) { if (otmp->type == OIdentifier) { for (i = 0; i < LEN(builtins); i++) - if (strcmp(otmp->d.i.s, builtins[i].name) == 0) + if (strcmp(otmp->d.i.name, builtins[i].name) == 0) return builtins[i].fn(o); } else if (otmp->type == OProc) { return otmp->d.proc.fn(o); @@ -603,7 +603,7 @@ print(struct object *o) printf("%s", o->d.eof.s); break; case OIdentifier: - printf("%s", o->d.i.s); + printf("%s", o->d.i.name); break; case OBoolean: printf("#%c", o->d.b.v == false ? 'f' : 't');