#ifndef ENV_HPP #define ENV_HPP #include #include #include #include "util.hpp" template struct Environment { typedef std::map Frame; typedef std::vector stack; private: stack stack_; public: void push_frame(const Frame& f) { stack_.push_back(f); } void pop_frame() { stack_.pop_back(); } T lookup(const std::string& name) const { stack::const_reverse_iterator it; for(it = stack_.rbegin(); it != stack_.rend(); ++it) { Frame::const_iterator mit(it->find(name)); if (mit != it->end()) { return *mit; } } error("Unbound variable name: " + name); } bool is_bound(const std::string& name) const { try { T t(lookup(name)); return true; } catch (std::string) { return false; } } }; #endif /* env.hpp: In member function ‘T Environment::lookup(const std::string&) const’: env.hpp:25: error: expected `;' before ‘it’ env.hpp:26: error: ‘it’ was not declared in this scope env.hpp:27: error: expected `;' before ‘mit’ env.hpp:28: error: ‘mit’ was not declared in this scope env.hpp: In member function ‘T Environment::lookup(const std::string&) const [with T = ValuePtr]’: value.hpp:108: instantiated from here env.hpp:25: error: dependent-name ‘std::vector, std::allocator >, T, std::less, std::allocator > >, std::allocator, std::allocator >, T> > >,std::allocator, std::allocator >, T, std::less, std::allocator > >, std::allocator, std::allocator >, T> > > > >::const_reverse_iterator’ is parsed as a non-type, but instantiation yields a type env.hpp:25: note: say ‘typename std::vector, std::allocator >, T, std::less, std::allocator > >, std::allocator, std::allocator >, T> > >,std::allocator, std::allocator >, T, std::less, std::allocator > >, std::allocator, std::allocator >, T> > > > >::const_reverse_iterator’ if a type is meant value.hpp:108: instantiated from here env.hpp:27: error: dependent-name ‘std::map, std::allocator >,T,std::less, std::allocator > >,std::allocator, std::allocator >, T> > >::const_iterator’ is parsed as a non-type, but instantiation yields a type env.hpp:27: note: say ‘typename std::map, std::allocator >,T,std::less, std::allocator > >,std::allocator, std::allocator >, T> > >::const_iterator’ if a type is meant make: *** [parser.o] Error 1 */