parse working
This commit is contained in:
12
src/parser.c
12
src/parser.c
@@ -237,14 +237,14 @@ int parse(token *tokens, term *terms, int terms_count_max)
|
||||
term_position = TERM_LEFT;
|
||||
while (tokens[i].type != TOKEN_END && terms_count < terms_count_max)
|
||||
{
|
||||
ft_printf("- token[%i]\n", i); // debug
|
||||
// ft_printf("- token[%i]\n", i); // debug
|
||||
|
||||
// equal
|
||||
if (tokens[i].type == TOKEN_EQUAL)
|
||||
{
|
||||
term_position = TERM_RIGHT;
|
||||
i++;
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
// position
|
||||
@@ -254,19 +254,19 @@ int parse(token *tokens, term *terms, int terms_count_max)
|
||||
term_sign ret_sign = get_sign(tokens, i, &token_count);
|
||||
terms[terms_count].sign = ret_sign;
|
||||
i += token_count;
|
||||
ft_printf("term[%i] get_sign: (%i)[%s], token_count: [%d]\n", terms_count, ret_sign, term_sign_to_str(ret_sign), token_count); // debug
|
||||
// ft_printf("term[%i] get_sign: (%i)[%s], token_count: [%d]\n", terms_count, ret_sign, term_sign_to_str(ret_sign), token_count); // debug
|
||||
|
||||
// coefficient
|
||||
double ret_coefficient = get_coefficient(tokens, i, &token_count);
|
||||
terms[terms_count].coefficient = ret_coefficient;
|
||||
i += token_count;
|
||||
printf("term[%i] get_coefficient: [%g], token_count: [%d]\n", terms_count, ret_coefficient, token_count); // debug
|
||||
// printf("term[%i] get_coefficient: [%g], token_count: [%d]\n", terms_count, ret_coefficient, token_count); // debug
|
||||
|
||||
// exponent
|
||||
int ret_exponent = get_exponent(tokens, i, &token_count);
|
||||
terms[terms_count].exponent = ret_exponent;
|
||||
i += token_count;
|
||||
ft_printf("term[%i] get_exponent: [%i], token_count: [%d]\n", terms_count, ret_exponent, token_count); // debug
|
||||
// ft_printf("term[%i] get_exponent: [%i], token_count: [%d]\n", terms_count, ret_exponent, token_count); // debug
|
||||
|
||||
terms_count++;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ int parse(token *tokens, term *terms, int terms_count_max)
|
||||
}
|
||||
else
|
||||
{
|
||||
stop_errors(ERROR_PARSING, "deal with that later");
|
||||
stop_errors(ERROR_PARSING, "terms_count: %i, terms_count_max: %i, tokens[%i].type: %s", terms_count, terms_count_max, i, token_type_to_str(tokens[i].type));
|
||||
}
|
||||
|
||||
return terms_count;
|
||||
|
||||
Reference in New Issue
Block a user