83 lines
1.7 KiB
C
83 lines
1.7 KiB
C
|
|
#include <sys/param.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <defines/N.h>
|
|
|
|
#include <stringtree/new.h>
|
|
#include <stringtree/prepend.h>
|
|
#include <stringtree/append.h>
|
|
#include <stringtree/free.h>
|
|
|
|
#include <globals/terminalcolors.h>
|
|
|
|
#include "../prettyprint.h"
|
|
|
|
#include "struct.h"
|
|
#include "prettyprint.h"
|
|
|
|
struct stringtree* substatements_statement_prettyprint(
|
|
int *out_chosen_color,
|
|
struct statement* super,
|
|
bool with_color)
|
|
{
|
|
ENTER;
|
|
|
|
struct substatements_statement* const this = (void*) super;
|
|
|
|
int left_color, right_color;
|
|
|
|
struct stringtree* left = statement_prettyprint(
|
|
&left_color,
|
|
/* instance: */ this->left,
|
|
with_color);
|
|
|
|
struct stringtree* right = statement_prettyprint(
|
|
&right_color,
|
|
/* instance: */ this->right,
|
|
with_color);
|
|
|
|
struct stringtree* semicolon = new_stringtree();
|
|
|
|
stringtree_append_cstr(semicolon, L"; ");
|
|
|
|
if (with_color)
|
|
{
|
|
int my_color =
|
|
(MAX(left_color, right_color) + 1) % (int) N(terminalcolors.precedences);
|
|
|
|
dpvu(my_color);
|
|
|
|
stringtree_prepend_cstr(semicolon, terminalcolors.precedences[my_color]);
|
|
|
|
stringtree_prepend_cstr(semicolon, terminalcolors.reset);
|
|
|
|
if (out_chosen_color)
|
|
*out_chosen_color = my_color;
|
|
}
|
|
|
|
struct stringtree* tree = new_stringtree();
|
|
|
|
stringtree_append_stringtree(tree, left);
|
|
stringtree_append_stringtree(tree, semicolon);
|
|
stringtree_append_stringtree(tree, right);
|
|
|
|
free_stringtree(left);
|
|
|
|
free_stringtree(semicolon);
|
|
|
|
free_stringtree(right);
|
|
|
|
EXIT;
|
|
return tree;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|