73 lines
1.3 KiB
C
73 lines
1.3 KiB
C
|
|
#include <debug.h>
|
|
|
|
#include <defines/N.h>
|
|
|
|
#include <globals/terminalcolors.h>
|
|
|
|
#include <stringtree/new.h>
|
|
#include <stringtree/prepend.h>
|
|
#include <stringtree/append.h>
|
|
#include <stringtree/free.h>
|
|
|
|
#include "../prettyprint.h"
|
|
|
|
#include "struct.h"
|
|
#include "prettyprint.h"
|
|
|
|
struct stringtree* lambda_expression_prettyprint(
|
|
int *out_chosen_color,
|
|
struct expression* super,
|
|
bool with_color)
|
|
{
|
|
ENTER;
|
|
|
|
struct lambda_expression* const this = (void*) super;
|
|
|
|
int chosen_color;
|
|
|
|
struct stringtree* tree = new_stringtree();
|
|
|
|
stringtree_append_cstr(tree, L"λ");
|
|
|
|
stringtree_append_string(tree, this->variable_name);
|
|
|
|
stringtree_append_cstr(tree, L": ");
|
|
|
|
struct stringtree* subtree = expression_prettyprint(
|
|
&chosen_color,
|
|
this->body,
|
|
with_color);
|
|
|
|
if (with_color)
|
|
{
|
|
int my_color = (chosen_color + 1) % (int) N(terminalcolors.precedences);
|
|
|
|
stringtree_prepend_cstr(tree, terminalcolors.precedences[my_color]);
|
|
|
|
stringtree_append_cstr(tree, terminalcolors.reset);
|
|
|
|
if (out_chosen_color)
|
|
*out_chosen_color = my_color;
|
|
}
|
|
|
|
stringtree_append_stringtree(tree, subtree);
|
|
|
|
free_stringtree(subtree);
|
|
|
|
EXIT;
|
|
return tree;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|