From b0935cd60b46a834d4cd6001d293e17bea251a93 Mon Sep 17 00:00:00 2001 From: Xie Zicong Date: Thu, 21 Nov 2024 22:30:10 +0800 Subject: [PATCH] Fixed some small bugs in Parser::ParseExpr and Parser::ParseVarDecl functions. --- prototype/compiler.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/prototype/compiler.cc b/prototype/compiler.cc index 1274846..b4619d4 100644 --- a/prototype/compiler.cc +++ b/prototype/compiler.cc @@ -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); @@ -1857,10 +1859,13 @@ VarDeclNode* Parser::ParseVarDecl(Token* token, size_t length, size_t& index) { } dynamic_cast(var_decl)->SetArrayDeclNode(type, name, size); + break; } case Token::OperatorType::equal: { + std::cout<<"EQUAL RUN IN PVD FUNC"<SetVarDeclNode(type, name, value); + break; } default: std::cout << index; @@ -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"<= length) return nullptr; ExprNode* expr = ParsePrimaryExpr(token, length, index); expr = ParseBinaryExpr(token, length, index, expr, 0); + std::cout<<"END PE FUNC"<