Skip to content

Commit

Permalink
Make sure that operator token is saved correctly for operator express…
Browse files Browse the repository at this point in the history
…ions

Function arguments are not guaranteed to be executed in any particular order
  • Loading branch information
lluiscamino committed Jul 2, 2024
1 parent 4f77ff5 commit 0e576fb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/em/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,19 @@ std::unique_ptr<ast::exprs::Expression> Parser::parseAssignment() {
std::unique_ptr<ast::exprs::Expression> Parser::parseBelonging() {
auto left = parseEquality();
while (match({TokenType::ELEMENT_OF})) {
auto operatorToken = previous();
left = std::make_unique<ast::exprs::OperatorExpression>(
std::move(left), previous(), parseSetOperation());
std::move(left), operatorToken, parseSetOperation());
}
return left;
}

std::unique_ptr<ast::exprs::Expression> Parser::parseEquality() {
auto left = parseSetOperation();
while (match({TokenType::EQUAL, TokenType::NOT_EQUAL})) {
auto operatorToken = previous();
left = std::make_unique<ast::exprs::OperatorExpression>(
std::move(left), previous(), parseSetOperation());
std::move(left), operatorToken, parseSetOperation());
}
return left;
}
Expand All @@ -76,8 +78,9 @@ std::unique_ptr<ast::exprs::Expression> Parser::parseSetOperation() {
auto left = parseSet();
while (match({TokenType::UNION, TokenType::INTERSECTION, TokenType::SUBSET,
TokenType::NOT_SUBSET})) {
auto operatorToken = previous();
left = std::make_unique<ast::exprs::OperatorExpression>(
std::move(left), previous(), parseSet());
std::move(left), operatorToken, parseSet());
}
return left;
}
Expand Down

0 comments on commit 0e576fb

Please sign in to comment.