00001 #ifndef NODE_HPP_ 00002 #define NODE_HPP_ 00003 00004 #include <iosfwd> 00005 #include <string> 00006 #include <vector> 00007 00009 class node_impl; 00010 00012 class node; 00013 00015 typedef std::vector<node> node_list; 00016 00018 typedef std::vector<std::string> identifier_list; 00019 00025 class node { 00026 public: 00028 node(); 00030 node(std::istream& stream); 00034 node(double number); 00038 node(std::string const& identifier); 00043 node(char op, node operand); 00049 node(node left, char op, node right); 00054 node(identifier_list const& parameters, node definition); 00059 node(std::string const& name, node_list const& arguments); 00064 node(node const& n); 00068 ~node(); 00069 00073 node& operator=(node const& n); 00074 00081 void print(std::ostream& stream, int indent = 0) const; 00085 double evaluate() const; 00090 std::string to_string() const; 00095 identifier_list const& get_parameters() const; 00096 00100 void save(std::ostream& stream) const; 00101 00102 private: 00104 static node_impl* make_binary_operator(node, char, node); 00105 00106 node_impl* pimpl_; 00107 }; 00108 00109 #endif