Skip to content

Commit

Permalink
Fixed parsing logic for variable declaration expression.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Oct 23, 2024
1 parent 63ac7fc commit d8ed7ec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/zhivo/parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ std::unique_ptr<ASTNode> Parser::exprVal() {
}

std::map<Token, std::unique_ptr<ASTNode>> declarations;
while(!this->isNext(";", TokenType::OPERATOR)) {
while(true) {
if(!declarations.empty())
this->consume(",");

Expand All @@ -889,6 +889,9 @@ std::unique_ptr<ASTNode> Parser::exprVal() {
);

declarations.insert({variable, std::move(value)});

if(!this->isNext(",", TokenType::OPERATOR))
break;
}

return std::make_unique<VariableDeclarationExpression>(
Expand Down

0 comments on commit d8ed7ec

Please sign in to comment.