1 |
/* ASCEND modelling environment |
2 |
Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly |
3 |
Copyright (C) 2006 Carnegie Mellon University |
4 |
|
5 |
This program is free software; you can redistribute it and/or modify |
6 |
it under the terms of the GNU General Public License as published by |
7 |
the Free Software Foundation; either version 2, or (at your option) |
8 |
any later version. |
9 |
|
10 |
This program is distributed in the hope that it will be useful, |
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
GNU General Public License for more details. |
14 |
|
15 |
You should have received a copy of the GNU General Public License |
16 |
along with this program; if not, write to the Free Software |
17 |
Foundation, Inc., 59 Temple Place - Suite 330, |
18 |
Boston, MA 02111-1307, USA. |
19 |
*//** |
20 |
@file |
21 |
Permanent Statement Output routines. |
22 |
|
23 |
#include "fractions.h" |
24 |
#include "compiler.h" |
25 |
#include "dimen.h" |
26 |
#include "expr_types.h" |
27 |
#include "stattypes.h" |
28 |
#include "list.h" |
29 |
*//* |
30 |
by Tom Epperly |
31 |
Version: $Revision: 1.14 $ |
32 |
Version control file: $RCSfile: statio.h,v $ |
33 |
Date last modified: $Date: 1997/07/28 20:52:13 $ |
34 |
Last modified by: $Author: ballan $ |
35 |
*/ |
36 |
|
37 |
#ifndef ASC_STATIO_H |
38 |
#define ASC_STATIO_H |
39 |
|
40 |
/** @addtogroup compiler_stmt Compiler Statements |
41 |
@{ |
42 |
*/ |
43 |
|
44 |
#include <stdio.h> |
45 |
#include <stdarg.h> |
46 |
#include <ascend/general/platform.h> |
47 |
#include <ascend/utilities/error.h> |
48 |
#include "stattypes.h" |
49 |
|
50 |
ASC_DLLSPEC void statio_clear_stattypenames(void); |
51 |
/**< |
52 |
Clear global array of pointers to statement type names, needed after |
53 |
destruction of the symbol table. |
54 |
*/ |
55 |
|
56 |
ASC_DLLSPEC struct gl_list_t *GetTypeNamesFromStatList(CONST struct StatementList*sl); |
57 |
/**< |
58 |
* Return a gl_list of types referenced by the statement list |
59 |
* given. If no types referenced, list will be empty but not NULL. |
60 |
* List is sorted alphabetically. There may be duplicates. There |
61 |
* may be undefined types if the compiler allows it.<br><br> |
62 |
* |
63 |
* This operator should be reimplemented to use the childlist, since all |
64 |
* types are now caught in that list and it is much faster than |
65 |
* reprocessing the several lists that define a type. |
66 |
*/ |
67 |
|
68 |
ASC_DLLSPEC void WriteStatement(FILE *f, CONST struct Statement *s, int i); |
69 |
/**< |
70 |
* Print a statement with i leading blanks and a trailing newline. |
71 |
*/ |
72 |
|
73 |
extern unsigned long StatementListLength(CONST struct StatementList *sl); |
74 |
/**< |
75 |
* Returns the number of statements in the list, which may be 0. |
76 |
* On NULL input, returns 0 -- and much code relies on this fact. |
77 |
*/ |
78 |
|
79 |
extern void WriteDiffStatementList(FILE *f, CONST struct StatementList *sl1, |
80 |
CONST struct StatementList *sl2, int i); |
81 |
/**< |
82 |
* Print a statement list with i leading blanks for each line which |
83 |
* is the statements on sl2 that are not on sl1. |
84 |
* Avoid printing twice the statements inside a SELECT. |
85 |
*/ |
86 |
|
87 |
extern void WriteStatementList(FILE *f, CONST struct StatementList *sl, int i); |
88 |
/**< |
89 |
* Print a statement list with i leading blanks for each line. |
90 |
* Avoid printing twice the statements inside a SELECT. |
91 |
*/ |
92 |
|
93 |
#define WSS(f,s) WriteStatementSuppressed(f,s) |
94 |
/**< Shorhand for WriteStatementSuppressed(). */ |
95 |
extern void WriteStatementSuppressed(FILE *f, CONST struct Statement *stat); |
96 |
/**< |
97 |
* Notify the user that a statement is being suppressed with a message |
98 |
* printed on file f. |
99 |
*/ |
100 |
|
101 |
/** Write a ASC_PROG_NOTE message using WriteStatementErrorMessage(). |
102 |
@see WriteStatementError |
103 |
*/ |
104 |
#define WSNM(FILEP,STMT,MSG) WriteStatementErrorMessage(FILEP,STMT,MSG,1,-1) |
105 |
|
106 |
#define STATEMENT_NOTE(STMT,MSG) WriteStatementErrorMessage(ASCERR,STMT,MSG,1,-1) |
107 |
|
108 |
/** Write a verbose error message using WriteStatementErrorMessage(). |
109 |
@see WriteStatementError |
110 |
*/ |
111 |
#define WSEM(FILEP,STMT,MSG) WriteStatementErrorMessage(FILEP,STMT,MSG,1,0) |
112 |
|
113 |
#define STATEMENT_ERROR(STMT,MSG) WriteStatementErrorMessage(ASCERR,STMT,MSG,1,0) |
114 |
|
115 |
/** Write a brief error message using WriteStatementErrorMessage(). |
116 |
@see WriteStatementError |
117 |
*/ |
118 |
#define WSSM(FILEP,STMT,MSG,l) WriteStatementErrorMessage(FILEP,STMT,MSG,0,l) |
119 |
extern void WriteStatementErrorMessage(FILE *f, |
120 |
CONST struct Statement *stat, |
121 |
CONST char *message, |
122 |
int noisy, |
123 |
int level); |
124 |
/**< |
125 |
* This procedure is an attempt to standardize statement error printing, |
126 |
* so that all statement error messages are printed with the same formatting. |
127 |
* Typically this procedure will print the "message" followed by the filename |
128 |
* and line number where the error occurs.<br><br> |
129 |
* |
130 |
* If noisy != 0, will include expressions when writing relations. |
131 |
* FOR table information will also be displayed when appropriate. |
132 |
* |
133 |
* If level !=0, will write in different format: |
134 |
* - 1 => Asc-Style: Line %lu <filename>: \n\tmessage\n<statement> |
135 |
* - 2 => Asc-Warning: Line %lu <filename>: \n\tmessage\n<statement> |
136 |
* - 3 => Asc-Error: Line %lu <filename>: \n\tmessage\n<statement> |
137 |
* - 4 => Asc-Fatal: Line %lu <filename>: \n\tmessage\n<statement> |
138 |
|
139 |
@see WriteStatementError |
140 |
*/ |
141 |
|
142 |
extern CONST char *StatioLabel(int level); |
143 |
/**< |
144 |
* Returns an Asc-#######: label padded to a uniform length. |
145 |
* You don't own the string returned. |
146 |
* If you give us invalid level, label 0 is returned. |
147 |
* StatioLabels are defined in WriteStatementErrorMessage above. |
148 |
|
149 |
@see WriteStatementError |
150 |
*/ |
151 |
|
152 |
extern int *GetStatioSuppressions(void); |
153 |
/**< |
154 |
* Returns a table initialized so that all statement types are |
155 |
* NOT suppressed. To suppress a statement type, |
156 |
* set table[statement_enum_of_type_you_hate] = 1. |
157 |
*/ |
158 |
|
159 |
extern void DestroySuppressions(int *table); |
160 |
/**< |
161 |
* Destroys a table of suppressions from GetStatioSuppressions. |
162 |
*/ |
163 |
|
164 |
#define WSEMSPARSE(f,s,m,t) WriteStatementErrorSparse(f,s,m,t) |
165 |
/**< Shorthand for WriteStatementErrorSparse(). */ |
166 |
|
167 |
extern void WriteStatementErrorSparse(FILE *f, |
168 |
CONST struct Statement *stat, |
169 |
CONST char *message, |
170 |
int *table); |
171 |
/**< |
172 |
* This procedure is an attempt to standardize statement error printing, |
173 |
* so that all statement error messages are printed with the same formatting. |
174 |
* Typically this procedure will print the "message" followed by the filename |
175 |
* and line number where the error occurs. |
176 |
* FOR information will also be displayed when appropriate. |
177 |
|
178 |
@see WriteStatementError |
179 |
*/ |
180 |
|
181 |
extern void WriteStatementError(const error_severity_t sev |
182 |
, const struct Statement *stat |
183 |
, const int outputstatment |
184 |
, const char *msg |
185 |
, ... |
186 |
); |
187 |
/**< |
188 |
A simpler and more flexible statement error routine using var args. |
189 |
@param outputstatment whether to output the content of the statment (TRUE) |
190 |
or just its location (FALSE). |
191 |
*/ |
192 |
|
193 |
extern symchar *StatementTypeString(CONST struct Statement *stat); |
194 |
/**< |
195 |
* Returns a string from the symbol table corresponding to the |
196 |
* statement type given. |
197 |
*/ |
198 |
|
199 |
extern void Asc_StatErrMsg_NotAllowedMethod(FILE *f |
200 |
, CONST struct Statement *stat |
201 |
, CONST char *suggestion |
202 |
); |
203 |
/**< |
204 |
* Writes a message to the file given indicating the statement is not |
205 |
* allowed in a method. |
206 |
*/ |
207 |
|
208 |
extern void Asc_StatErrMsg_NotAllowedDeclarative(FILE *f |
209 |
, CONST struct Statement *stat |
210 |
, CONST char *suggestion |
211 |
); |
212 |
/**< |
213 |
* Writes a message to the file given indicating the statement is not |
214 |
* allowed in a declarative MODEL body. |
215 |
*/ |
216 |
|
217 |
/* @} */ |
218 |
|
219 |
#endif /* ASC_STATIO_H */ |
220 |
|