#ifndef _SYMBOL_TABLE_H #define _SYMBOL_TABLE_H #include #include #include #include "gpl_type.h" class Symbol_table; #include "expression.h" using namespace std; typedef union { long t_int; double t_double; string *t_string; } Gpl_value; class Symbol { public: string *name; int type; Gpl_value value; void print(ostream &target); }; class Symbol_table { public: static Symbol_table *m_instance; map contents; void add_symbol(string *name, int type, Expression *init); long as_int(string *name); double as_float(string *name); int type(string *name); string *as_string(string *name); void del_symbol(string *name); bool has_symbol(string *name) { return contents.count(*name) != 0; }; void print(ostream &target); static Symbol_table *instance(); Symbol_table() {}; }; #endif