Skip to content

Commit

Permalink
parse binary
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Chen committed Oct 8, 2023
1 parent 16411fc commit bdcbe2e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ class Parser {

std::unique_ptr<ExpressionAST> parseBinaryExpression(){
getNextToken(); // eat (
std::unique_ptr<ExpressionAST> LHS = parseExpression();
std::unique_ptr<BinaryExpressionAST> binary = std::make_unique<BinaryExpressionAST>();
binary->LHS = parseExpression();
if(currentToken == ')') {
// no RHS, eat ) and return LHS
return LHS;
getNextToken();
return std::move(binary->LHS);
} else if (currentToken == Token::tok_positive || currentToken == Token::tok_neg) {
std::unique_ptr<BinaryExpressionAST> binary;
binary->LHS = std::move(LHS);
// currently support pos and neg
Token op = static_cast<Token>(currentToken);
binary->op = op;
Expand Down

0 comments on commit bdcbe2e

Please sign in to comment.