301 |
printf("\"%s\"", (char*)stack_head->item->content.ptr); |
printf("\"%s\"", (char*)stack_head->item->content.ptr); |
302 |
break; |
break; |
303 |
case symb: |
case symb: |
304 |
printf("'%s'", ((symbol *)(stack_head->item->content.ptr))->id); |
printf("%s", ((symbol *)(stack_head->item->content.ptr))->id); |
305 |
break; |
break; |
306 |
case func: |
case func: |
307 |
printf("#<function %p>", (funcp)(stack_head->item->content.ptr)); |
printf("#<function %p>", (funcp)(stack_head->item->content.ptr)); |
428 |
extern void eval(environment *env) |
extern void eval(environment *env) |
429 |
{ |
{ |
430 |
funcp in_func; |
funcp in_func; |
431 |
|
value* temp_val; |
432 |
|
stackitem* iterator; |
433 |
|
|
434 |
if(env->head==NULL) { |
if(env->head==NULL) { |
435 |
printerr("Too Few Arguments"); |
printerr("Too Few Arguments"); |
436 |
env->err=1; |
env->err=1; |
454 |
toss(env); |
toss(env); |
455 |
if(env->err) return; |
if(env->err) return; |
456 |
(*in_func)(env); |
(*in_func)(env); |
457 |
|
return; |
458 |
|
} |
459 |
|
|
460 |
|
/* If it's a list */ |
461 |
|
if(env->head->item->type==list) { |
462 |
|
temp_val= env->head->item; |
463 |
|
env->head->item->refcount++; |
464 |
|
toss(env); |
465 |
|
if(env->err) return; |
466 |
|
iterator= (stackitem*)temp_val->content.ptr; |
467 |
|
while(iterator!=NULL && iterator->item!=NULL) { |
468 |
|
push_val(&(env->head), iterator->item); |
469 |
|
if(env->head->item->type==symb |
470 |
|
&& strcmp(";", ((symbol*)(env->head->item->content.ptr))->id)==0) { |
471 |
|
toss(env); |
472 |
|
if(env->err) return; |
473 |
|
eval(env); |
474 |
|
} |
475 |
|
iterator= iterator->next; |
476 |
|
} |
477 |
|
free_val(temp_val); |
478 |
} |
} |
479 |
} |
} |
480 |
|
|
481 |
/* Reverse a list */ |
/* Reverse (flip) a list */ |
482 |
extern void rev(environment *env){ |
extern void rev(environment *env){ |
483 |
stackitem *old_head, *new_head, *item; |
stackitem *old_head, *new_head, *item; |
484 |
|
|