/[ascend]/trunk/base/generic/compiler/statio.h
ViewVC logotype

Contents of /trunk/base/generic/compiler/statio.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 978 - (show annotations) (download) (as text)
Wed Dec 20 10:26:04 2006 UTC (17 years, 7 months ago) by johnpye
File MIME type: text/x-chdr
File size: 7216 byte(s)
Failed 'ASSERT' statements in a METHOD now cause the statement to be output (as well as its location).
Improved code docs/GPL header for a few files.
Added support for 'ASSERT' in WriteStatement.
Added new WriteStatementError that included var-arg support.
Fixed ASC_ASSERT_RANGE in AscPanic.
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 #include <stdio.h>
41 #include <stdarg.h>
42 #include <utilities/ascConfig.h>
43 #include <utilities/error.h>
44 #include "stattypes.h"
45
46 ASC_DLLSPEC(struct gl_list_t *) GetTypeNamesFromStatList(CONST struct StatementList*sl);
47 /**<
48 * Return a gl_list of types referenced by the statement list
49 * given. If no types referenced, list will be empty but not NULL.
50 * List is sorted alphabetically. There may be duplicates. There
51 * may be undefined types if the compiler allows it.<br><br>
52 *
53 * This operator should be reimplemented to use the childlist, since all
54 * types are now caught in that list and it is much faster than
55 * reprocessing the several lists that define a type.
56 */
57
58 ASC_DLLSPEC(void ) WriteStatement(FILE *f, CONST struct Statement *s, int i);
59 /**<
60 * Print a statement with i leading blanks and a trailing newline.
61 */
62
63 extern unsigned long StatementListLength(CONST struct StatementList *sl);
64 /**<
65 * Returns the number of statements in the list, which may be 0.
66 * On NULL input, returns 0 -- and much code relies on this fact.
67 */
68
69 extern void WriteDiffStatementList(FILE *f, CONST struct StatementList *sl1,
70 CONST struct StatementList *sl2, int i);
71 /**<
72 * Print a statement list with i leading blanks for each line which
73 * is the statements on sl2 that are not on sl1.
74 * Avoid printing twice the statements inside a SELECT.
75 */
76
77 extern void WriteStatementList(FILE *f, CONST struct StatementList *sl, int i);
78 /**<
79 * Print a statement list with i leading blanks for each line.
80 * Avoid printing twice the statements inside a SELECT.
81 */
82
83 #define WSS(f,s) WriteStatementSuppressed(f,s)
84 /**< Shorhand for WriteStatementSuppressed(). */
85 extern void WriteStatementSuppressed(FILE *f, CONST struct Statement *stat);
86 /**<
87 * Notify the user that a statement is being suppressed with a message
88 * printed on file f.
89 */
90
91 /** Write a ASC_PROG_NOTE message using WriteStatementErrorMessage().
92 @see WriteStatementError
93 */
94 #define WSNM(FILEP,STMT,MSG) WriteStatementErrorMessage(FILEP,STMT,MSG,1,-1)
95
96 #define STATEMENT_NOTE(STMT,MSG) WriteStatementErrorMessage(ASCERR,STMT,MSG,1,-1)
97
98 /** Write a verbose error message using WriteStatementErrorMessage().
99 @see WriteStatementError
100 */
101 #define WSEM(FILEP,STMT,MSG) WriteStatementErrorMessage(FILEP,STMT,MSG,1,0)
102
103 #define STATEMENT_ERROR(STMT,MSG) WriteStatementErrorMessage(ASCERR,STMT,MSG,1,0)
104
105 /** Write a brief error message using WriteStatementErrorMessage().
106 @see WriteStatementError
107 */
108 #define WSSM(FILEP,STMT,MSG,l) WriteStatementErrorMessage(FILEP,STMT,MSG,0,l)
109 extern void WriteStatementErrorMessage(FILE *f,
110 CONST struct Statement *stat,
111 CONST char *message,
112 int noisy,
113 int level);
114 /**<
115 * This procedure is an attempt to standardize statement error printing,
116 * so that all statement error messages are printed with the same formatting.
117 * Typically this procedure will print the "message" followed by the filename
118 * and line number where the error occurs.<br><br>
119 *
120 * If noisy != 0, will include expressions when writing relations.
121 * FOR table information will also be displayed when appropriate.
122 *
123 * If level !=0, will write in different format:
124 * - 1 => Asc-Style: Line %lu <filename>: \n\tmessage\n<statement>
125 * - 2 => Asc-Warning: Line %lu <filename>: \n\tmessage\n<statement>
126 * - 3 => Asc-Error: Line %lu <filename>: \n\tmessage\n<statement>
127 * - 4 => Asc-Fatal: Line %lu <filename>: \n\tmessage\n<statement>
128
129 @see WriteStatementError
130 */
131
132 extern CONST char *StatioLabel(int level);
133 /**<
134 * Returns an Asc-#######: label padded to a uniform length.
135 * You don't own the string returned.
136 * If you give us invalid level, label 0 is returned.
137 * StatioLabels are defined in WriteStatementErrorMessage above.
138
139 @see WriteStatementError
140 */
141
142 extern int *GetStatioSuppressions(void);
143 /**<
144 * Returns a table initialized so that all statement types are
145 * NOT suppressed. To suppress a statement type,
146 * set table[statement_enum_of_type_you_hate] = 1.
147 */
148
149 extern void DestroySuppressions(int *table);
150 /**<
151 * Destroys a table of suppressions from GetStatioSuppressions.
152 */
153
154 #define WSEMSPARSE(f,s,m,t) WriteStatementErrorSparse(f,s,m,t)
155 /**< Shorthand for WriteStatementErrorSparse(). */
156
157 extern void WriteStatementErrorSparse(FILE *f,
158 CONST struct Statement *stat,
159 CONST char *message,
160 int *table);
161 /**<
162 * This procedure is an attempt to standardize statement error printing,
163 * so that all statement error messages are printed with the same formatting.
164 * Typically this procedure will print the "message" followed by the filename
165 * and line number where the error occurs.
166 * FOR information will also be displayed when appropriate.
167
168 @see WriteStatementError
169 */
170
171 extern void WriteStatementError(const error_severity_t sev
172 , const struct Statement *stat
173 , const int outputstatment
174 , const char *msg
175 , ...
176 );
177 /**<
178 A simpler and more flexible statement error routine using var args.
179 @param outputstatment whether to output the content of the statment (TRUE)
180 or just its location (FALSE).
181 */
182
183 extern symchar *StatementTypeString(CONST struct Statement *stat);
184 /**<
185 * Returns a string from the symbol table corresponding to the
186 * statement type given.
187 */
188
189 extern void Asc_StatErrMsg_NotAllowedMethod(FILE *f
190 , CONST struct Statement *stat
191 , CONST char *suggestion
192 );
193 /**<
194 * Writes a message to the file given indicating the statement is not
195 * allowed in a method.
196 */
197
198 extern void Asc_StatErrMsg_NotAllowedDeclarative(FILE *f
199 , CONST struct Statement *stat
200 , CONST char *suggestion
201 );
202 /**<
203 * Writes a message to the file given indicating the statement is not
204 * allowed in a declarative MODEL body.
205 */
206
207 #endif /* ASC_STATIO_H */
208

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22