44 lines
648 B
C
44 lines
648 B
C
#include <stdio.h>
|
|
|
|
#include "util.h"
|
|
|
|
void printValue(object input);
|
|
|
|
void print(object input)
|
|
{
|
|
if (input.type == errorObject)
|
|
{
|
|
fprintf(stderr, "\nГРЕШКА: %s\n\n", ERRMSG(input));
|
|
}
|
|
else
|
|
{
|
|
printf("\n; Value: ");
|
|
printValue(input);
|
|
printf("\n\n");
|
|
}
|
|
}
|
|
|
|
void printValue(object input)
|
|
{
|
|
if (input.type == nilObject)
|
|
{
|
|
printf("()");
|
|
}
|
|
else if (input.type == numberObject)
|
|
{
|
|
printf("%lld", NUM(input));
|
|
}
|
|
else if (input.type == symbolObject)
|
|
{
|
|
printf("%s", SYM(input));
|
|
}
|
|
else if (input.type == consObject)
|
|
{
|
|
printf("(");
|
|
printValue(CAR(input));
|
|
printf(" . ");
|
|
printValue(CDR(input));
|
|
printf(")");
|
|
}
|
|
}
|