Annotation of parser3/src/include/pa_exception.h, revision 1.5

1.1       paf         1: /*
1.5     ! paf         2:   $Id: pa_exception.h,v 1.4 2001/02/21 14:59:41 paf Exp $
1.1       paf         3: */
                      4: 
                      5: #ifndef PA_EXCEPTION_H
                      6: #define PA_EXCEPTION_H
                      7: 
                      8: #include <setjmp.h>
                      9: 
                     10: #include "pa_types.h"
                     11: #include "pa_string.h"
                     12: 
                     13: class Exception {
                     14: public:
                     15: 
                     16:        // address for long jump to jump to 
1.3       paf        17:        // regretfully public:
                     18:        //   can't make local unless sure of inlining
                     19:        //   for to-die stack frame ruins it all
1.5     ! paf        20:        mutable jmp_buf mark;
1.1       paf        21: 
1.5     ! paf        22:        void _throw(
1.1       paf        23:                const String *atype, const String *acode,
                     24:                const String *aproblem_source, 
1.5     ! paf        25:                const char *comment_fmt, ...) const;
1.1       paf        26: 
1.5     ! paf        27:        const String *type() const { return ftype; }
        !            28:        const String *code() const { return fcode; }
        !            29:        const String *problem_source() const { return fproblem_source; }
        !            30:        const char *comment() const { return fcomment[0]?fcomment:0; }
1.1       paf        31: 
                     32: private:
                     33: 
1.5     ! paf        34:        mutable const String *ftype, *fcode, *fproblem_source;
        !            35:        mutable char fcomment[MAX_STRING];
1.1       paf        36: };
                     37: 
1.5     ! paf        38: //#define EXCEPTION_TRY(e) (setjmp((e).mark)==0)
1.3       paf        39: // usage:
                     40: //   if(EXCEPTION_TRY(e)) { ...; if(?) e.raise(?); ...; } else { catch-code }
1.1       paf        41: 
                     42: #endif

E-mail: