From 8c9acafc932541d9a1c09f1fa0a93ac992254309 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Fri, 17 Aug 2018 19:10:48 -0700 Subject: [PATCH] Fix bug in shunting yard implementation. --- src/parser.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/parser.c b/src/parser.c index 1e185a6..8c8dcaf 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1056,16 +1056,15 @@ libab_result _parse_expression(struct parser_state* state, while (result == LIBAB_SUCCESS && op_stack.tail && _parser_match_is_op(op_stack.tail->data)) { libab_lexer_match* other_token = op_stack.tail->data; - if(other_token->type == TOKEN_OP_INFIX) { - _parser_find_operator_infix(state, op_stack.tail->data, - &other_operator); + if(other_token->type == TOKEN_OP_INFIX || other_token->type == TOKEN_OP_RESERVED) { + _parser_find_operator_infix(state, other_token, &other_operator); } if (other_token->type == TOKEN_OP_PREFIX || (operator.associativity == - 1 && operator.precedence <= other_operator.precedence) || (operator.associativity == 1 && - operator.precedence