2019-01-08 22:19:29 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
void printValue(object input);
|
|
|
|
|
|
|
|
void print(object input)
|
|
|
|
{
|
2019-01-14 03:16:25 +01:00
|
|
|
if (input.type == errorObject)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "\nГРЕШКА: %s\n\n", ERRMSG(input));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("\n; Value: ");
|
|
|
|
printValue(input);
|
|
|
|
printf("\n\n");
|
|
|
|
}
|
2019-01-08 22:19:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void printValue(object input)
|
|
|
|
{
|
|
|
|
if (input.type == nilObject)
|
|
|
|
{
|
2019-01-14 03:16:25 +01:00
|
|
|
printf("()");
|
2019-01-08 22:19:29 +01:00
|
|
|
}
|
|
|
|
else if (input.type == numberObject)
|
|
|
|
{
|
2019-01-14 03:16:25 +01:00
|
|
|
printf("%lld", NUM(input));
|
2019-01-08 22:19:29 +01:00
|
|
|
}
|
|
|
|
else if (input.type == symbolObject)
|
|
|
|
{
|
2019-01-14 03:16:25 +01:00
|
|
|
printf("%s", SYM(input));
|
2019-01-08 22:19:29 +01:00
|
|
|
}
|
|
|
|
else if (input.type == consObject)
|
|
|
|
{
|
|
|
|
printf("(");
|
2019-01-14 03:16:25 +01:00
|
|
|
printValue(CAR(input));
|
2019-01-08 22:19:29 +01:00
|
|
|
printf(" . ");
|
2019-01-14 03:16:25 +01:00
|
|
|
printValue(CDR(input));
|
2019-01-08 22:19:29 +01:00
|
|
|
printf(")");
|
|
|
|
}
|
|
|
|
}
|