69 lines
1.3 KiB
C
69 lines
1.3 KiB
C
|
|
#include <debug.h>
|
|
|
|
#include <defines/N.h>
|
|
|
|
#include <stringtree/new.h>
|
|
#include <stringtree/prepend.h>
|
|
#include <stringtree/append.h>
|
|
|
|
#include <globals/terminalcolors.h>
|
|
|
|
#include "../prettyprint.h"
|
|
|
|
#include "struct.h"
|
|
#include "prettyprint.h"
|
|
|
|
struct stringtree* parenthesis_expression_prettyprint(
|
|
int *out_chosen_color,
|
|
struct expression* super,
|
|
bool with_color)
|
|
{
|
|
ENTER;
|
|
|
|
struct parenthesis_expression* const this = (void*) super;
|
|
|
|
int inner_color;
|
|
|
|
struct stringtree* tree = expression_prettyprint(
|
|
&inner_color,
|
|
this->subexpression,
|
|
with_color);
|
|
|
|
if (with_color)
|
|
{
|
|
int my_color = (inner_color + 1) % (int) N(terminalcolors.precedences);
|
|
|
|
stringtree_prepend_cstr(tree, terminalcolors.reset);
|
|
stringtree_prepend_cstr(tree, L"(");
|
|
stringtree_prepend_cstr(tree, terminalcolors.precedences[my_color]);
|
|
|
|
stringtree_append_cstr(tree, terminalcolors.precedences[my_color]);
|
|
stringtree_append_cstr(tree, L")");
|
|
stringtree_append_cstr(tree, terminalcolors.reset);
|
|
|
|
if (out_chosen_color)
|
|
*out_chosen_color = my_color;
|
|
}
|
|
else
|
|
{
|
|
stringtree_prepend_cstr(tree, L"(");
|
|
stringtree_append_cstr(tree, L")");
|
|
}
|
|
|
|
EXIT;
|
|
return tree;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|