Annotation of parser3/src/include/pa_exception.h, revision 1.4
1.1 paf 1: /*
1.4 ! paf 2: $Id: pa_exception.h,v 1.3 2001/01/30 13:43:42 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.1 paf 20: jmp_buf mark;
21:
22: void raise(
23: const String *atype, const String *acode,
24: const String *aproblem_source,
25: const char *comment_fmt, ...);
26:
27: const String *type() { return ftype; }
28: const String *code() { return fcode; }
29: const String *problem_source() { return fproblem_source; }
1.2 paf 30: const char *comment() { return fcomment[0]?fcomment:0; }
1.1 paf 31:
32: private:
33:
34: const String *ftype, *fcode, *fproblem_source;
35: char fcomment[MAX_STRING];
36: };
37:
1.4 ! 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: