#ifndef __ABSTRACT_SYNTAX_TREE_H__ #define __ABSTRACT_SYNTAX_TREE_H__ class abstract_syntax_tree { private: int line; int type; double number; std::string str; std::string name; std::list children; public: // basic abstract_syntax_tree(); abstract_syntax_tree(const abstract_syntax_tree&); ~abstract_syntax_tree(); abstract_syntax_tree& operator=(const abstract_syntax_tree&); // main functions // print void print_tree(const int); // set void set_clear(); void set_type(const int); void set_line(const int); void set_string(std::string); void set_number(std::string); void set_name(std::string); void add_child(abstract_syntax_tree); // get int get_type(); int get_line(); double get_number(); std::string get_string(); std::string get_name(); std::list& get_children(); }; abstract_syntax_tree::abstract_syntax_tree() { type=0; line=0; number=0; str=""; name=""; children.clear(); return; } abstract_syntax_tree::abstract_syntax_tree(const abstract_syntax_tree& p) { type=p.type; line=p.line; number=p.number; str=p.str; name=p.name; children=p.children; return; } abstract_syntax_tree::~abstract_syntax_tree() { children.clear(); return; } abstract_syntax_tree& abstract_syntax_tree::operator=(const abstract_syntax_tree& p) { type=p.type; line=p.line; number=p.number; str=p.str; name=p.name; children.clear(); children=p.children; return *this; } void abstract_syntax_tree::print_tree(const int n) { std::string __str=""; for(int i=0;iprint_tree(n+1); } return; } void abstract_syntax_tree::set_clear() { type=0; line=0; number=0; str=""; name=""; children.clear(); return; } void abstract_syntax_tree::set_type(const int __type) { type=__type; return; } void abstract_syntax_tree::set_line(const int __line) { if(__line>=0) line=__line; else { std::cout<<">> [Abstract-syntax-tree-warning] incorrect line under 0: "<<__line<<"."<& abstract_syntax_tree::get_children() { return children; } #endif