Fix the assumption that the stack only has infix operators.

This commit is contained in:
Danila Fedorin 2018-08-10 17:20:14 -07:00
parent 8192d767f2
commit 3c0648e473

View File

@ -1055,11 +1055,13 @@ libab_result _parse_expression(struct parser_state* state,
while (result == LIBAB_SUCCESS && op_stack.tail && while (result == LIBAB_SUCCESS && op_stack.tail &&
_parser_match_is_op(op_stack.tail->data)) { _parser_match_is_op(op_stack.tail->data)) {
_parser_find_operator_infix(state, op_stack.tail->data, libab_lexer_match* other_token = op_stack.tail->data;
&other_operator); if(other_token->type == TOKEN_OP_INFIX) {
_parser_find_operator_infix(state, op_stack.tail->data,
&other_operator);
}
if (((libab_lexer_match*)op_stack.tail->data)->type == if (other_token->type == TOKEN_OP_PREFIX ||
TOKEN_OP_PREFIX ||
(operator.associativity == - 1 && (operator.associativity == - 1 &&
operator.precedence <= other_operator.precedence) || operator.precedence <= other_operator.precedence) ||
(operator.associativity == 1 && (operator.associativity == 1 &&