dfilter: Improve syntax tree display format for sets

This commit is contained in:
João Valverde 2022-04-20 11:27:24 +01:00
parent 8c9480214b
commit 164f3ce9a2
1 changed files with 23 additions and 0 deletions

View File

@ -375,7 +375,9 @@ static void
visit_tree(wmem_strbuf_t *buf, stnode_t *node, int level)
{
stnode_t *left, *right;
stnode_t *lower, *upper;
GSList *params;
GSList *nodelist;
if (stnode_type_id(node) == STTYPE_TEST ||
stnode_type_id(node) == STTYPE_ARITHMETIC) {
@ -396,6 +398,27 @@ visit_tree(wmem_strbuf_t *buf, stnode_t *node, int level)
ws_assert_not_reached();
}
}
else if (stnode_type_id(node) == STTYPE_SET) {
nodelist = stnode_data(node);
wmem_strbuf_append_printf(buf, "SET(#%u):\n", g_slist_length(nodelist) / 2);
while (nodelist) {
indent(buf, level + 1);
lower = nodelist->data;
wmem_strbuf_append(buf, stnode_tostr(lower, FALSE));
/* Set elements are always in pairs; upper may be null. */
nodelist = g_slist_next(nodelist);
ws_assert(nodelist);
upper = nodelist->data;
if (upper != NULL) {
wmem_strbuf_append(buf, " .. ");
wmem_strbuf_append(buf, stnode_tostr(upper, FALSE));
}
nodelist = g_slist_next(nodelist);
if (nodelist != NULL) {
wmem_strbuf_append_c(buf, '\n');
}
}
}
else if (stnode_type_id(node) == STTYPE_FUNCTION) {
wmem_strbuf_append_printf(buf, "%s:\n", stnode_todebug(node));
params = sttype_function_params(node);