fix null coefficient skipped
This commit is contained in:
10
src/parser.c
10
src/parser.c
@@ -208,7 +208,7 @@ void parse(s_token *tokens, s_term *terms, int terms_count_max)
|
||||
|
||||
check_variables(tokens);
|
||||
|
||||
print_debug("PARSER STEPS :\n"); // debug
|
||||
print_debug("PARSER STEPS :\n");
|
||||
|
||||
terms_count = 0;
|
||||
token_count = 0;
|
||||
@@ -216,7 +216,7 @@ void parse(s_token *tokens, s_term *terms, int terms_count_max)
|
||||
term_position = TERM_LEFT;
|
||||
while (tokens[i].type != TOKEN_END && terms_count < terms_count_max)
|
||||
{
|
||||
print_debug("- token[%i]\n", i); // debug
|
||||
print_debug("- token[%i]\n", i);
|
||||
|
||||
// equal
|
||||
if (tokens[i].type == TOKEN_EQUAL)
|
||||
@@ -238,19 +238,19 @@ void parse(s_token *tokens, s_term *terms, int terms_count_max)
|
||||
sign = -1;
|
||||
}
|
||||
i += token_count;
|
||||
print_debug("term[%i] get_sign: (%i)[%s], token_count: [%d]\n", terms_count, ret_sign, term_sign_to_str(ret_sign), token_count); // debug
|
||||
print_debug("term[%i] get_sign: (%i)[%s], token_count: [%d]\n", terms_count, ret_sign, term_sign_to_str(ret_sign), token_count);
|
||||
|
||||
// coefficient
|
||||
double ret_coefficient = get_coefficient(tokens, i, &token_count);
|
||||
terms[terms_count].coefficient = ret_coefficient * sign;
|
||||
i += token_count;
|
||||
print_debug("term[%i] get_coefficient: [%g], token_count: [%d]\n", terms_count, ret_coefficient, token_count); // debug
|
||||
print_debug("term[%i] get_coefficient: [%g], token_count: [%d]\n", terms_count, ret_coefficient, token_count);
|
||||
|
||||
// exponent
|
||||
int ret_exponent = get_exponent(tokens, i, &token_count);
|
||||
terms[terms_count].exponent = ret_exponent;
|
||||
i += token_count;
|
||||
print_debug("term[%i] get_exponent: [%i], token_count: [%d]\n", terms_count, ret_exponent, token_count); // debug
|
||||
print_debug("term[%i] get_exponent: [%i], token_count: [%d]\n", terms_count, ret_exponent, token_count);
|
||||
|
||||
terms_count++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user