This commit is contained in:
Valk Richard Li 2019-11-15 11:54:41 +08:00 committed by GitHub
parent bccd2089c3
commit d695b0e9ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -673,13 +673,23 @@ void abstract_syntax_tree::run_root()
else if(i->type==__while) else if(i->type==__while)
{ {
scope.add_new_block_scope(); scope.add_new_block_scope();
i->run_loop(); int ret_type=i->run_loop();
if(ret_type==__return)
{
std::cout<<"[Runtime-error] line "<<line<<": incorrect use of break/continue."<<std::endl;
exit_type=__error_command_use;
}
scope.pop_last_block_scope(); scope.pop_last_block_scope();
} }
else if(i->type==__ifelse) else if(i->type==__ifelse)
{ {
scope.add_new_block_scope(); scope.add_new_block_scope();
i->run_ifelse(); int ret_type=i->run_ifelse();
if(ret_type==__continue || ret_type==__break || ret_type==__return)
{
std::cout<<"[Runtime-error] line "<<line<<": incorrect use of break/continue."<<std::endl;
exit_type=__error_command_use;
}
scope.pop_last_block_scope(); scope.pop_last_block_scope();
} }
if(exit_type!=__process_exited_successfully) if(exit_type!=__process_exited_successfully)

View File

@ -115,6 +115,8 @@ class resource_file
resource.push_back(' '); resource.push_back(' ');
} }
resource.push_back('\n'); resource.push_back('\n');
resource.push_back(';');
resource.pudh_back('\n');
return; return;
} }
std::list<char>& get_resource() std::list<char>& get_resource()