fix error in stop_errors and add debug term output
This commit is contained in:
18
src/parser.c
18
src/parser.c
@@ -44,14 +44,6 @@ static int get_exponent(token *tokens, int *token_count)
|
||||
|
||||
int parse(token *tokens, term *terms, int terms_count_max)
|
||||
{
|
||||
/*
|
||||
if (tokens)
|
||||
{
|
||||
terms[0].exponent = 0;
|
||||
}
|
||||
return 1;
|
||||
*/
|
||||
|
||||
int i;
|
||||
int terms_count;
|
||||
int token_count;
|
||||
@@ -89,7 +81,15 @@ int parse(token *tokens, term *terms, int terms_count_max)
|
||||
terms_count++;
|
||||
}
|
||||
|
||||
if (tokens[i].type != TOKEN_END && terms_count >= terms_count_max)
|
||||
// last token is TOKEN_END, and terms[] should have at least one more spot for a null
|
||||
if (tokens[i].type == TOKEN_END && terms_count < terms_count_max)
|
||||
{
|
||||
terms[terms_count].position = TERM_END;
|
||||
terms[terms_count].sign = TERM_NULL;
|
||||
terms[terms_count].coefficient = 0;
|
||||
terms[terms_count].exponent = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
stop_errors(ERROR_PARSING, "deal with that later");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user