unoidl2

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/unoidl2.git/
Log | Files | Refs

commit 4100d8255c96bee1c1fd37fdb1bb5baca4d15b9d
parent 41b86ae8d92d07587308f68c56b2f4722bc833c5
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun, 18 Mar 2012 18:44:40 +0100

print understands sym1, no inf loop

Diffstat:
Munoidl2.c | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/unoidl2.c b/unoidl2.c @@ -27,7 +27,7 @@ #define NCHARA 256 struct any { - enum {CONS, TOKEN, INUM, CHARA, SYMB} tag; + enum {CONS, TOKEN, INUM, CHARA, SYM1, SYM2} tag; union { struct { struct any *car; @@ -78,8 +78,10 @@ Any intern1(char *x) { for(; *x; x++) { Any k = chara(*x); Any r = find(k, cdr(p), equal, caar); - if(NIL == r) + if(NIL == r) { con(p, cons(r = list1(cons(k, p)), cdr(p))); + r->tag = SYM1; + } p = r; } return p; @@ -228,7 +230,10 @@ Any print(Any x) { case CHARA: printf("%c", x->u.inum); break; - case SYMB: + case SYM1: + print_sym1(x); + break; + case SYM2: print_sym2(x); break; /* default: error? */ @@ -275,7 +280,7 @@ static Any intern2rel(Any k, Any p) { Any r = find(k, cdr(p), equal, caar); if(NIL == r) { con(p, cons(r = list1(list2(k, p)), cdr(p))); - r->tag = SYMB; + r->tag = SYM2; } return r; }