#ifndef __ABSTRACT_SYNTAX_TREE_CPP__ #define __ABSTRACT_SYNTAX_TREE_CPP__ #include "abstract_syntax_tree.h" int exit_type=0; bool abstract_syntax_tree::check() { return true; } var abstract_syntax_tree::call_id() { var temp; if(scope.search_var(name)) temp=scope.get_var(name); else { std::cout<<">>[Runtime-error] cannot find a var named \'"<::iterator i=children.begin();i!=children.end();++i) { new_var=i->get_value(); temp.append_array(new_var); } } else if(type==__hash) { var new_var; for(std::list::iterator i=children.begin();i!=children.end();++i) { new_var=i->children.begin()->get_value(); new_var.set_name(i->name); temp.append_array(new_var); } } else if(type==__function) temp.set_function(*this); else { std::cout<<">>[Runtime-error] incorrect value."<::iterator i=children.begin();i!=children.end();++i) { if(i->type==__definition) { var new_var; std::list::iterator j=i->children.begin(); std::string _name=j->name; if(!scope.search_var(_name)) { ++j; if(j!=i->children.end()) new_var=j->get_value(); new_var.set_name(_name); scope.add_new_var(new_var); } else { std::cout<<">>[Runtime-error] redeclaration of \'"<<_name<<"\'."<type==__number) std::cout<number<type==__string) std::cout<str<type==__id) std::cout<call_id().get_name()<type==__while) { scope.add_new_block_scope(); i->run_loop(); scope.pop_last_block_scope(); } else if(i->type==__ifelse) { scope.add_new_block_scope(); i->run_ifelse(); scope.pop_last_block_scope(); } if(exit_type!=__process_exited_successfully) break; } end_time=time(NULL); std::cout<<"--------------------------------------------------------------------------------------"<>[Runtime] process exited after "<::iterator i=children.begin();i!=children.end();++i) { if(i->type==__definition) { var new_var; std::list::iterator j=i->children.begin(); std::string _name=j->name; if(!scope.search_var(_name)) { ++j; if(j!=i->children.end()) new_var=j->get_value(); new_var.set_name(_name); scope.add_new_var(new_var); } else { std::cout<<">>[Runtime-error] redeclaration of \'"<<_name<<"\'."<type==__number) std::cout<number<type==__string) std::cout<str<type==__id) std::cout<call_id().get_name()<type==__while) i->run_loop(); else if(i->type==__ifelse) i->run_ifelse(); else if(i->type==__continue) { return __continue; // else // { // std::cout<<">>[Runtime-error] must use \'continue\' in a loop."<type==__break) { return __loop; // else // { // std::cout<<">>[Runtime-error] must use \'continue\' in a loop."<type==__return) { break; } if(exit_type!=__process_exited_successfully) break; } scope.pop_last_local_scope(); return 0; } #endif