Skip to content

Commit

Permalink
Better table builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro-Salerno committed Oct 31, 2021
1 parent b3c9d8f commit 2e013a1
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions src/calgo.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,32 +110,48 @@ void calgoDrawTable(vector(node) nodes)
string name = "",
type = "",
value = Str("(undefined)");

if (nodes->buffer[i]->type != CALGO_DECLARE_NODE)
continue;

type = nodes->buffer[i]->arguments->buffer[1];
name = nodes->buffer[i]->arguments->buffer[2];

if (nodes->buffer[i]->arguments->len == 3)
goto tab_push;


if (nodes->buffer[i]->type == CALGO_DECLARE_NODE)
if (strCompare(nodes->buffer[i]->arguments->buffer[3], "STR"))
sprintf(value, "\"%s\"", nodes->buffer[i]->arguments->buffer[4]);

else if (strCompare(nodes->buffer[i]->arguments->buffer[3], "EXP"))
{
type = nodes->buffer[i]->arguments->buffer[1];
name = nodes->buffer[i]->arguments->buffer[2];
value = strClear(value);

if (nodes->buffer[i]->arguments->len >= 4)
for (int j = 3; j < nodes->buffer[i]->arguments->len; j++)
{
if (strCompare(nodes->buffer[i]->arguments->buffer[3], "STR"))
sprintf(value, "\"%s\"", nodes->buffer[i]->arguments->buffer[4]);
if (strCompare(nodes->buffer[i]->arguments->buffer[j], "EXP"))
sprintf(value, "%s %s", value, "(");

else if (strCompare(nodes->buffer[i]->arguments->buffer[3], "EXP"))
{
value = strClear(value);
else if (strCompare(nodes->buffer[i]->arguments->buffer[j], "/EXP"))
sprintf(value, "%s %s", value, ")");

// There is a bug with nested expressions here
for (int j = 4; !strCompare(nodes->buffer[i]->arguments->buffer[j], "/EXP"); j++)
sprintf(value, "%s %s", value, nodes->buffer[i]->arguments->buffer[j]);
else if (strCompare(nodes->buffer[i]->arguments->buffer[j], "STR"))
{
j++;
sprintf(value, "%s \"%s\"", value, nodes->buffer[i]->arguments->buffer[j]);
}

else
value = nodes->buffer[i]->arguments->buffer[3];
sprintf(value, "%s %s", value, nodes->buffer[i]->arguments->buffer[j]);
}
}

else
value = nodes->buffer[i]->arguments->buffer[3];

tab_push:
tabPush(tab, name, type, value);
}
}

tabDraw(tab);
Expand Down

0 comments on commit 2e013a1

Please sign in to comment.