Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

paranoid_visitor.h

Go to the documentation of this file.
00001 // AUTOMATICALLY GENERATED -- DO NOT EDIT!         -*- c++ -*-
00002 
00003 #ifndef paranoid_visitor_h
00004 #define paranoid_visitor_h
00005 
00006 #include "ptree_program_visitor.h"
00007 
00008 //
00009 // INTERFACE definition follows 
00010 //
00011 
00017 template<typename T>
00018 class Paranoid_visitor : public Ptree_program_visitor<T> {
00019     typedef Ptree_program_visitor<T> Super;
00020  public:
00021     using Super::operator new;
00022     using Super::operator delete;
00023 
00024     Paranoid_visitor(Source* src)
00025         : Super(src), Ptree_visitor<T>(src) { }
00026 
00027 public:  
00028   // FIXME: move this to Ptree_visitor?
00029   T visit_and_catch(Ptree* p);
00030 
00031 private:  
00032   virtual T default_action(Ptree* p);
00033 };
00034 
00035 //
00036 // IMPLEMENTATION includes follow (for use by inline functions)
00037 //
00038 
00039 
00040 #include <string>
00041 #include <typeinfo>
00042 #include "except.h"
00043 
00044 //
00045 // IMPLEMENTATION of function templates
00046 //
00047 
00048 
00049 
00050 
00051 template<typename T> T
00052 Paranoid_visitor<T>::default_action(Ptree* p)
00053 {
00054     if (p)
00055         bogus_ptree_error(std::string("Unexpected node type `") + typeid(*p).name() + "' encountered", p);
00056     else
00057         bogus_ptree_error("Unexpected empty node encountered", p);
00058     return T(0);                // silence compiler
00059 }
00060 
00061 
00062 // FIXME: move this to Ptree_visitor?
00063 
00064 template<typename T> T
00065 Paranoid_visitor<T>::visit_and_catch(Ptree* p)
00066 {
00067     try {
00068         return visit(p);
00069     }
00070     catch(Compile_error& e) {
00071         e.print(std::cerr, p);
00072         return T(0);
00073     }
00074 }
00075 
00076 #endif // paranoid_visitor_h

Generated on Mon Feb 10 17:32:52 2003 for VFiasco Semantics Compiler by doxygen1.2.15