Click here to Skip to main content
15,893,622 members
Articles / Programming Languages / C++

Building a simple C++ script compiler from Scintilla and CINT

Rate me:
Please Sign up or sign in to vote.
4.74/5 (26 votes)
8 Jul 2006CPOL7 min read 154.4K   7.6K   85  
How to build a simple C++ script compiler from Scintilla and CINT.
#ifndef G__EXCEPTION_H
#define G__EXCEPTION_H

//namespace std {

class exception;
class bad_exception;
typedef void (*unexpected_handler)();
unexpected_handler set_unexpected(unexpected_handler f) /* throw() */ ;
void unexpected();
typedef void (*terminate_handler)();
terminate_handler set_terminate(terminate_handler f) /* throw() */ ;
void terminate();
bool uncaught_exception();

/////////////////////////////////////////////////////////////////////////
class exception {
 public:
  exception() /* throw() */ { msg=0; }
  exception(const exception& x) /* throw() */ {
    if(x.msg) {
      msg = new char[strlen(x.msg)+1];
      strcpy(msg,x.msg);
    }
    else msg = 0;
  }
  exception& operator=(const exception& x) /* throw() */ {
    delete[] msg;
    if(x.msg) {
      msg = new char[strlen(x.msg)+1];
      strcpy(msg,x.msg);
    }
    else msg = 0;
  }
  virtual ~exception() /* throw() */ { delete[] msg; }
  virtual const char* what() const /* throw() */{return(msg);}

  exception(const char* msgin) { 
    msg = new char[strlen(msgin)+1];
    strcpy(msg,msgin);
  }
 private:
  char* msg;
};

/////////////////////////////////////////////////////////////////////////
class bad_exception : public exception {
 public:
  bad_exception() /* throw() */ {}
  bad_exception(const bad_exception&) /* throw() */ {}
  bad_exception& operator=(const bad_exception&) /* throw() */ {}
  virtual ~bad_exception() /* throw() */ {}
  virtual const char* what() const /* throw() */ {return("Unknown bad_exception");} 
};

#ifdef __MAKECINT__

#pragma link off class exception;
#pragma link off class bad_exception;
#pragma link off function set_unexpected;
#pragma link off function unexpected;
#pragma link off function set_terminate;
#pragma link off function terminate;
#pragma link off function uncaught_exception;
#pragma link off typedef bool;

#endif

//}

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions