lisp-take-1/value/user_lambda/prettyprint.c
Zander Thannhauser 44fb99b663 .
- macros work in the new way (the "right" way?)
- added test.py script, with basic test cases. Need to fill out new test
  builtins.
2024-12-02 19:33:23 -06:00

73 lines
1.2 KiB
C

#include <assert.h>
#include <debug.h>
#include <stringtree/new.h>
#include <stringtree/append.h>
#include <stringtree/free.h>
#include "../struct.h"
#include "../prettyprint.h"
#include "struct.h"
#include "prettyprint.h"
struct stringtree* user_lambda_value_prettyprint(
const struct value* super)
{
ENTER;
assert(super->kind == vk_user_lambda);
const struct user_lambda_value* this = &super->subclass.user_lambda;
struct stringtree* tree = new_stringtree();
stringtree_append_string_const(tree, "(lambda");
if (this->is_macro)
{
stringtree_append_string_const(tree, "!");
}
stringtree_append_string_const(tree, " ");
{
struct stringtree* parameters = value_prettyprint(this->parameters);
stringtree_append_stringtree(tree, parameters);
free_stringtree(parameters);
}
stringtree_append_string_const(tree, " ");
{
struct stringtree* body = value_prettyprint(this->body);
stringtree_append_stringtree(tree, body);
free_stringtree(body);
}
stringtree_append_string_const(tree, ")");
EXIT;
return tree;
}