Skip to content

Commit

Permalink
Fixed some small bugs in Parser::ParseExpr and Parser::ParseVarDecl f…
Browse files Browse the repository at this point in the history
…unctions.
  • Loading branch information
ax-6 committed Nov 21, 2024
1 parent e05a919 commit b0935cd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion prototype/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,8 @@ VarDeclNode* Parser::ParseVarDecl(Token* token, size_t length, size_t& index) {
return var_decl;
std::cout << "END PVD FUNC E5" << std::endl;
}
if (token[index].value._operator == Token::OperatorType::equal)
std::cout << "IS = " << std::endl;
switch (token[index].value._operator) {
case Token::OperatorType::l_square: {
ExprNode* size = ParseExpr(token, length, ++index);
Expand Down Expand Up @@ -1857,10 +1859,13 @@ VarDeclNode* Parser::ParseVarDecl(Token* token, size_t length, size_t& index) {
}
dynamic_cast<ArrayDeclNode*>(var_decl)->SetArrayDeclNode(type, name,
size);
break;
}
case Token::OperatorType::equal: {
std::cout<<"EQUAL RUN IN PVD FUNC"<<std::endl;
ExprNode* value = ParseExpr(token, length, ++index);
var_decl->SetVarDeclNode(type, name, value);
break;
}
default:
std::cout << index;
Expand Down Expand Up @@ -2238,9 +2243,11 @@ ExprNode* Parser::ParsePrimaryExpr(Token* token, size_t length, size_t& index) {
}

ExprNode* Parser::ParseExpr(Token* token, size_t length, size_t& index) {
if (length >= index) return nullptr;
std::cout<<"START PE FUNC"<<std::endl;
if (index >= length) return nullptr;
ExprNode* expr = ParsePrimaryExpr(token, length, index);
expr = ParseBinaryExpr(token, length, index, expr, 0);
std::cout<<"END PE FUNC"<<std::endl;
return expr;
}

Expand Down

0 comments on commit b0935cd

Please sign in to comment.