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

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

E-mail: