--- /dev/null
+#include "scopestack.h"
+
+using namespace std;
+
+ScopeStack::ScopeStack()
+{
+}
+
+ScopeStack::~ScopeStack()
+{
+}
+
+void ScopeStack::startScope()
+{
+ scope_stack.push_front( sym_table_t() );
+}
+
+void ScopeStack::stopScope()
+{
+ scope_stack.pop_front();
+}
+
+void ScopeStack::define(const std::string& name)
+{
+ sym_pair_t pair(name, Symbol(name));
+ scope_stack.front().insert( pair );
+}
+
+void ScopeStack::define(const std::string& name, symtype_t type)
+{
+ sym_pair_t pair(name, Symbol(name,type));
+ scope_stack.front().insert( pair );
+}
+
+const Symbol* ScopeStack::lookup(const std::string& name)
+{
+ Symbol* p_sym = NULL;
+ list<sym_table_t>::iterator it;
+ for(it = scope_stack.begin(); it != scope_stack.end(); it++)
+ {
+ sym_table_t::iterator p_val = (*it).find(name);
+ if( p_val != (*it).end())
+ {
+ p_sym = &(p_val->second);
+ }
+ }
+ return p_sym;
+}
+
+bool ScopeStack::isLocal(const std::string& name) const
+{
+ return false;
+}
+
+bool ScopeStack::isGlobal(const std::string& name) const
+{
+ return false;
+}
+
--- /dev/null
+#ifndef SCOPE_TREE_H
+#define SCOPE_TREE_H
+
+#include <string>
+#include <list>
+#include <map>
+#include "symbol.h"
+
+typedef std::pair<std::string,Symbol> sym_pair_t;
+typedef std::map<std::string,Symbol> sym_table_t;
+
+class ScopeStack {
+ protected:
+ std::list<sym_table_t> scope_stack;
+ public:
+ ScopeStack();
+ virtual ~ScopeStack();
+
+ void startScope();
+ void stopScope();
+ void define(const std::string& name);
+ void define(const std::string& name, symtype_t type);
+ const Symbol* lookup(const std::string& name);
+ bool isLocal(const std::string& name) const;
+ bool isGlobal(const std::string& name) const;
+};
+
+#endif
--- /dev/null
+#include "symbol.h"
+
+Symbol::Symbol(const std::string& name) : sym_name(name), sym_type(0)
+{
+}
+
+Symbol::Symbol(const std::string& name, symtype_t type) : sym_name(name), sym_type(0)
+{
+}
+
+Symbol::~Symbol()
+{
+}
+
+symtype_t Symbol::type() const
+{
+ return sym_type;
+}
+
+void Symbol::type(symtype_t type)
+{
+ sym_type = type;
+}
+
+const std::string& Symbol::name() const
+{
+ return sym_name;
+}
+
+void Symbol::name(const std::string& name)
+{
+ sym_name = name;
+}
+
--- /dev/null
+#ifndef SYMBOL_H
+#define SYMBOL_H
+
+#include <string>
+
+typedef unsigned int symtype_t;
+
+class Symbol {
+ protected:
+ std::string sym_name;
+ symtype_t sym_type;
+ public:
+ Symbol(const std::string& name);
+ Symbol(const std::string& name, symtype_t type);
+ virtual ~Symbol();
+ symtype_t type() const;
+ void type(symtype_t type);
+ const std::string& name() const;
+ void name(const std::string& name);
+};
+
+#endif