Додате функције у сврху дебагирања, и мање стилске промене
This commit is contained in:
parent
4228b81870
commit
bd36290735
|
@ -4,7 +4,7 @@ LIBPREFIX = $(PREFIX)/lib
|
|||
|
||||
# флегови за C компајлер и линкер
|
||||
CPPFLAGS = -D_POSIX_C_SOURCE=2 -DDESTDIR=\"$(DESTDIR)\" -DVERSION=\"$(VERSION)\"
|
||||
# CFLAGS = -g -std=c99 -pedantic -Wall -Wextra -Wno-maybe-uninitialized -O0
|
||||
# CFLAGS = -DDEBUG -g -std=c99 -pedantic -Wall -Wextra -Wno-maybe-uninitialized -O0
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Wextra -Wno-maybe-uninitialized -O3
|
||||
LDFLAGS = -lm
|
||||
|
||||
|
|
|
@ -168,8 +168,9 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
printf("Добродошли у ЋИРИЛИСП ЧПШП окружење, верзија: " VERSION "\n");
|
||||
while (Print(Eval(Read("Ћ> ", stdin), globalEnv)))
|
||||
;
|
||||
object current;
|
||||
while (Print(current = Eval(Read("Ћ> ", stdin), globalEnv)))
|
||||
deleteObject(current);
|
||||
printf("\nДостигнут крај улазног тока.\nЗбогом и дођите нам опет!\n");
|
||||
|
||||
exitCirilisp(0);
|
||||
|
|
29
print.c
29
print.c
|
@ -20,7 +20,7 @@ int Print(object input)
|
|||
printValue(input);
|
||||
printf("\n\n");
|
||||
}
|
||||
deleteObject(input);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -101,3 +101,30 @@ void printValue(object input)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void PrintEntry(entry *e)
|
||||
{
|
||||
if (e == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PrintEntry(e->left);
|
||||
printf("%s: ", e->name);
|
||||
Print(e->value);
|
||||
PrintEntry(e->right);
|
||||
}
|
||||
|
||||
void PrintEnv(env environment)
|
||||
{
|
||||
printf("%p", (void *) environment);
|
||||
env enclosings = environment->enclosing;
|
||||
while (enclosings != NULL)
|
||||
{
|
||||
printf(" <-- %p", (void *) enclosings);
|
||||
enclosings = enclosings->enclosing;
|
||||
}
|
||||
printf("\n");
|
||||
PrintEntry(environment->table);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue