prettier printing
This commit is contained in:
parent
41f05b9556
commit
38b044921f
27
main.c
27
main.c
|
@ -764,48 +764,49 @@ static void display(struct uns_ctr *ctr)
|
|||
tmp.p = gc.record_get_ptr(ctr->p, 1);
|
||||
display(&tmp);
|
||||
|
||||
tmp.p = gc.record_get_ptr(ctr->p, 2);
|
||||
switch (get_type(tmp.p)) {
|
||||
case EMPTY_LIST:
|
||||
printf(")");
|
||||
goto remove;
|
||||
case CELL:
|
||||
ctr->p = gc.record_get_ptr(ctr->p, 2);
|
||||
while (get_type(ctr->p) == CELL) {
|
||||
printf(" ");
|
||||
tmp.p = gc.record_get_ptr(ctr->p, 1);
|
||||
display(&tmp);
|
||||
ctr->p = gc.record_get_ptr(ctr->p, 2);
|
||||
}
|
||||
|
||||
switch (get_type(ctr->p)) {
|
||||
case EMPTY_LIST:
|
||||
printf(")");
|
||||
break;
|
||||
default:
|
||||
printf(" . ");
|
||||
display(&tmp);
|
||||
display(ctr);
|
||||
printf(")");
|
||||
break;
|
||||
}
|
||||
|
||||
remove:
|
||||
uns_root_remove(&gc, &tmp);
|
||||
return;
|
||||
case INTEGER:
|
||||
memcpy(&l, gc.record_get_ptr(ctr->p, 1), sizeof(long));
|
||||
printf("%ld ", l);
|
||||
printf("%ld", l);
|
||||
return;
|
||||
case FLOAT:
|
||||
memcpy(&f, gc.record_get_ptr(ctr->p, 1), sizeof(double));
|
||||
printf("%f ", f);
|
||||
printf("%f", f);
|
||||
return;
|
||||
case STRING:
|
||||
tmp.p = gc.record_get_ptr(ctr->p, 1);
|
||||
uns_root_add(&gc, &tmp);
|
||||
printf("\"%s\" ", uns_string_cstring(&gc, &tmp));
|
||||
printf("\"%s\"", uns_string_cstring(&gc, &tmp));
|
||||
uns_root_remove(&gc, &tmp);
|
||||
return;
|
||||
case SYMBOL:
|
||||
tmp.p = gc.record_get_ptr(ctr->p, 1);
|
||||
uns_root_add(&gc, &tmp);
|
||||
printf("%s ", uns_string_cstring(&gc, &tmp));
|
||||
printf("%s", uns_string_cstring(&gc, &tmp));
|
||||
uns_root_remove(&gc, &tmp);
|
||||
return;
|
||||
case EMPTY_LIST:
|
||||
printf("'() ");
|
||||
printf("'()");
|
||||
return;
|
||||
default:
|
||||
abort();
|
||||
|
|
Reference in New Issue