frame finished but bad_any_cast
This commit is contained in:
@@ -124,7 +124,7 @@ std::any ASTPrinter::visitFuncFParam(SysYParser::FuncFParamContext *ctx){
|
||||
}
|
||||
|
||||
std::any ASTPrinter::visitBlockStmt(SysYParser::BlockStmtContext *ctx){
|
||||
cout << ' ' << ctx->LBRACE()->getText() << endl;
|
||||
cout << ctx->LBRACE()->getText() << endl;
|
||||
indentLevel++;
|
||||
for (auto item : ctx->blockItem()) item->accept(this);
|
||||
indentLevel--;
|
||||
@@ -134,6 +134,7 @@ std::any ASTPrinter::visitBlockStmt(SysYParser::BlockStmtContext *ctx){
|
||||
// std::any ASTPrinter::visitBlockItem(SysYParser::BlockItemContext *ctx);
|
||||
|
||||
std::any ASTPrinter::visitAssignStmt(SysYParser::AssignStmtContext *ctx){
|
||||
cout << getIndent();
|
||||
ctx->lValue()->accept(this);
|
||||
cout << ' ' << ctx->ASSIGN()->getText() << ' ';
|
||||
ctx->exp()->accept(this);
|
||||
@@ -142,6 +143,7 @@ std::any ASTPrinter::visitAssignStmt(SysYParser::AssignStmtContext *ctx){
|
||||
}
|
||||
|
||||
std::any ASTPrinter::visitExpStmt(SysYParser::ExpStmtContext *ctx){
|
||||
cout << getIndent();
|
||||
if (ctx->exp()) {
|
||||
ctx->exp()->accept(this);
|
||||
}
|
||||
@@ -153,7 +155,17 @@ std::any ASTPrinter::visitIfStmt(SysYParser::IfStmtContext *ctx){
|
||||
cout << getIndent() << ctx->IF()->getText() << ' ' << ctx->LPAREN()->getText();
|
||||
ctx->cond()->accept(this);
|
||||
cout << ctx->RPAREN()->getText() << ' ';
|
||||
ctx->stmt(0)->accept(this);
|
||||
//格式化有问题
|
||||
if(ctx->stmt(0)) {
|
||||
ctx->stmt(0)->accept(this);
|
||||
}
|
||||
else {
|
||||
cout << '{' << endl;
|
||||
indentLevel++;
|
||||
ctx->stmt(0)->accept(this);
|
||||
indentLevel--;
|
||||
cout << getIndent() << '}' << endl;
|
||||
}
|
||||
if (ctx->ELSE()) {
|
||||
cout << getIndent() << ctx->ELSE()->getText() << ' ';
|
||||
ctx->stmt(1)->accept(this);
|
||||
|
||||
Reference in New Issue
Block a user