Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/agcore/error.cpp @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /* | |
2 * AnaGram, A System for Syntax Directed Programming | |
3 * Copyright 1993-2002 Parsifal Software. All Rights Reserved. | |
4 * See the file COPYING for license and usage terms. | |
5 * | |
6 * error.cpp - Error reporting module | |
7 */ | |
8 | |
9 #include "config.h" | |
10 #include "error.h" | |
11 #include "pgg24-defs.h" | |
12 #include "stacks.h" | |
13 | |
14 //#define INCLUDE_LOGGING | |
15 #include "log.h" | |
16 | |
17 | |
18 AgString errorReportFile(""); | |
19 | |
20 int charRangeDiagnostic; | |
21 int negativeCharDiagnostic; | |
22 int eventDrivenDiagnostic; | |
23 int errorResynchDiagnostic; | |
24 | |
25 AgStack<Error> errorList; | |
26 | |
27 const char *Error::keyString[] = {"Warning", "Error"}; | |
28 | |
29 void reset_errors(void) { | |
30 charRangeDiagnostic = 0; | |
31 eventDrivenDiagnostic = 0; | |
32 negativeCharDiagnostic = 0; | |
33 errorResynchDiagnostic = 0; | |
34 } | |
35 | |
36 void checkParams() { | |
37 LOGSECTION("checkParams"); | |
38 if (!eventDrivenDiagnostic && event_driven && pointer_input) { | |
39 eventDrivenDiagnostic = 1; | |
40 log_error("Event driven parser cannot use pointer input"); | |
41 } | |
42 if (!errorResynchDiagnostic && error_token && auto_resynch) { | |
43 log_error("Both error token resynch and auto resynch specified"); | |
44 errorResynchDiagnostic = 1; | |
45 } | |
46 } | |
47 | |
48 /* | |
49 * XXX. Sometime we need to go through and check up on all calls to | |
50 * the next two versions of log_error(), distinguishing those where | |
51 * a meaningful location can be fetched from the pgg24 PCB and | |
52 * those that should have no location. | |
53 * | |
54 * (Note: the direct Error constructor calls have been checked.) | |
55 */ | |
56 | |
57 void log_error(const char *msg) { | |
58 LOGSECTION("log_error(const char *)"); | |
59 errorList.push(Error(pgcb.line, pgcb.column, msg)); | |
60 } | |
61 | |
62 void log_error() { | |
63 LOGSECTION("log_error()"); | |
64 LOGS(string_base); | |
65 errorList.push(Error(pgcb.line, pgcb.column, string_base)); | |
66 rcs(); | |
67 } | |
68 | |
69 void log_error(int l, int c) { | |
70 LOGSECTION("log_error(int,int)"); | |
71 LOGV(l) LCV(c) LV(string_base); | |
72 errorList.push(Error(l, c, string_base)); | |
73 rcs(); | |
74 } | |
75 | |
76 /* | |
77 * XXX the equivalent of this function used to always report the last | |
78 * line and column, not the first. But this function is for cases | |
79 * where that's not appropriate, so how about arranging things so it | |
80 * doesn't report any at all? | |
81 */ | |
82 | |
83 Error::Error(AgString msg) | |
84 : file(errorReportFile), | |
85 line(1), | |
86 column(1), | |
87 key(warn), | |
88 message(msg) | |
89 { | |
90 LOGSECTION("Error::Error(AgString)"); | |
91 // Nothing here | |
92 } | |
93 | |
94 Error::Error(int l, int c, AgString msg) | |
95 : file(errorReportFile), | |
96 line(l), | |
97 column(c), | |
98 key(warn), | |
99 message(msg) | |
100 { | |
101 LOGSECTION("Error::Error(int, int, AgString)"); | |
102 LOGV(line) LCV(column) LCV(msg.pointer()); | |
103 // Nothing here | |
104 } | |
105 | |
106 Error::Error(int l, int c, AgString f, AgString msg) | |
107 : file(f), | |
108 line(l), | |
109 column(c), | |
110 key(warn), | |
111 message(msg) | |
112 { | |
113 // Nothing here | |
114 } | |
115 |