#ifndef __AST_GENERATOR_H__ #define __AST_GENERATOR_H__ class ast_generator { private: ast_tree_node root; std::stack parse; std::stack node_cache; bool error; public: ast_generator() { error=false; } void input_token_stack(std::stack& temp) { parse=temp; return; } void number_gen() { number_expr t; t.set_line(parse.top().line); t.set_number(parse.top().content); if(node_cache.empty()) node_cache.push(t); else if((node_cache.top().return_type()==__add_operator || node_cache.top().return_type()==__sub_operator || node_cache.top().return_type()==__mul_operator || node_cache.top().return_type()==__div_operator) && (node_cache.top().child_num()==1)) node_cache.top().add_child(t); else { std::cout<<">>[Error] parse error in line "<>[Error] parse error in line "<>[Error] parse error in line "<>[Error] parse error in line "<>[Error] parse error in line "<>[Error] parse error in line "<>[Error] parse error in line "<>[Parse] Error(s) occurred."<>[Parse] Complete parsing."<>[Parse] 0 error."<>[Parse] Complete parsing."<>[Abstract-syntax-tree]"<>[Parse] Error(s) occurred,stop running the code."<