adding subtypes

This commit is contained in:
hugogogo
2026-05-02 09:42:04 +02:00
parent bcbd3b2abb
commit 16d882e352
4 changed files with 307 additions and 54 deletions

View File

@@ -87,29 +87,41 @@ int main(int ac, char **av)
ft_printf("token %2i - type : ", i);
if (tokens[i].type == TOKEN_VARIABLE)
ft_printf("%20s", "TOKEN_VARIABLE");
else if (tokens[i].type == TOKEN_NUMBER_INT)
ft_printf("%20s", "TOKEN_NUMBER_INT");
else if (tokens[i].type == TOKEN_NUMBER_DOUBLE)
ft_printf("%20s", "TOKEN_NUMBER_DOUBLE");
ft_printf("%14s%30s", "TOKEN_VARIABLE", "");
else if (tokens[i].type == TOKEN_NUMBER)
{
ft_printf("%14s", "TOKEN_NUMBER");
if (tokens[i].subtype == TOKEN_NUMBER_INT)
ft_printf("%30s", "TOKEN_NUMBER_INT");
else if (tokens[i].subtype == TOKEN_NUMBER_DOUBLE)
ft_printf("%30s", "TOKEN_NUMBER_DOUBLE");
}
else if (tokens[i].type == TOKEN_POWER)
ft_printf("%20s", "TOKEN_POWER");
ft_printf("%14s%30s", "TOKEN_POWER", "");
else if (tokens[i].type == TOKEN_SIGN)
ft_printf("%20s", "TOKEN_SIGN");
{
ft_printf("%14s", "TOKEN_SIGN");
if (tokens[i].subtype == TOKEN_SIGN_PLUS)
ft_printf("%30s", "TOKEN_SIGN_PLUS");
else if (tokens[i].subtype == TOKEN_SIGN_MINUS)
ft_printf("%30s", "TOKEN_SIGN_MINUS");
}
else if (tokens[i].type == TOKEN_FACTOR)
ft_printf("%20s", "TOKEN_FACTOR");
{
ft_printf("%14s", "TOKEN_FACTOR");
if (tokens[i].subtype == TOKEN_FACTOR_MULTIPLICATION)
ft_printf("%30s", "TOKEN_FACTOR_MULTIPLICATION");
else if (tokens[i].subtype == TOKEN_FACTOR_DIVISION)
ft_printf("%30s", "TOKEN_FACTOR_DIVISION");
}
else if (tokens[i].type == TOKEN_EQUAL)
ft_printf("%20s", "TOKEN_EQUAL");
ft_printf("%14s%30s", "TOKEN_EQUAL", "");
else if (tokens[i].type == TOKEN_END)
ft_printf("%20s", "TOKEN_END");
ft_printf("%14s%30s", "TOKEN_END", "");
ft_putstr(" - value : ");
if (tokens[i].type == TOKEN_NUMBER_INT)
{
printf("%i\n", tokens[i].value_int);
}
else if (tokens[i].type == TOKEN_NUMBER_DOUBLE)
if (tokens[i].type == TOKEN_NUMBER)
{
printf("%g\n", tokens[i].value_double);
}