1 ///////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.3.6),
3 // last updated on Nov 2, 1999.
4 // The original source file is "basics.ph".
5 ///////////////////////////////////////////////////////////////////////////////
8 ///////////////////////////////////////////////////////////////////////////////
10 // This file contains the basic definitions used in the
11 // Prop -> C++ translator, including various flags and memory
14 ///////////////////////////////////////////////////////////////////////////////
15 #ifndef basic_definitions_h
16 #define basic_definitions_h
20 #include <AD/generic/generic.h> // generic definitions from the library
21 #include <AD/memory/mempool.h> // memory pool
22 #include <AD/memory/strpool.h> // string pool
25 ///////////////////////////////////////////////////////////////////////////////
27 // The following is used to deal with the new ANSI conformance
28 // of the "for" statement involving scoping of variables defined in
29 // an "if". Variables defined inside a for statement are not visible
30 // only with the scope of the construct.
32 ///////////////////////////////////////////////////////////////////////////////
33 #define for if (0) ; else for
35 ///////////////////////////////////////////////////////////////////////////////
37 // Two memory pools are kept for fast memory allocation.
38 // Memory allocated from the global pool is persistent during the run
39 // of the translator, while memory allocated from the local pool can
40 // be deallocated in a stack-like fashion. Also, there is a pool for
41 // string objects. These are persistent like the global pool.
43 ///////////////////////////////////////////////////////////////////////////////
44 extern MemPool mem_pool
; // memory pool for local objects
45 extern MemPool global_pool
; // memory pool for global objects
46 extern StringPool str_pool
; // string pool for strings
48 ///////////////////////////////////////////////////////////////////////////////
50 // Class 'MEM' is a memory management class. Objects deriving from
51 // this class are allocates from the memory pools. By default,
52 // the local memory pool is used. The methods 'use_global_pools'
53 // and 'use_local_pools' can be used to switch between the global
56 ///////////////////////////////////////////////////////////////////////////////
59 void * operator new (size_t); // allocation member
60 // void operator delete(void *); // disable deletion
61 static void use_global_pools(); // switch to the global pool
62 static void use_local_pools(); // switch to the local pol
63 // allocate a vector from the pool
66 ///////////////////////////////////////////////////////////////////////////////
68 // The input/output/logging streams and the output file name(if applicable).
70 ///////////////////////////////////////////////////////////////////////////////
71 extern std::istream
* input_stream
; // The current input stream
72 extern std::ostream
* output_stream
; // The current output stream
73 extern std::ostream
* log_stream
; // The current logging stream
74 extern std::ostream
& open_logfile(); // Open the logfile
75 extern std::ostream
* open_output_file(const char []); // open a file for output
76 extern void encode_string(char *, const char *); // Encode a string.
78 ///////////////////////////////////////////////////////////////////////////////
80 // Errors and messages routines.
82 ///////////////////////////////////////////////////////////////////////////////
83 extern int errors
; // number of errors found
84 std::ostream
& pr_msg (const char *, va_list); // generic print message routine
85 std::ostream
& error (const char *, ...); // error message
86 std::ostream
& msg (const char *, ...); // generic message
87 std::ostream
& debug_msg(const char *, ...); // debugging message
88 void bug (const char *, ...); // abort and generate a bug report
90 ///////////////////////////////////////////////////////////////////////////////
92 // Polymorphic lists, pairs and identifiers. These are used throughout the
93 // rest of the translator.
95 ///////////////////////////////////////////////////////////////////////////////
98 ///////////////////////////////////////////////////////////////////////////////
100 // Forward class definition for List<T>
102 ///////////////////////////////////////////////////////////////////////////////
103 #ifndef datatype_List_defined
104 #define datatype_List_defined
105 template <class T
> class a_List
;
106 #define List(T) a_List<T> *
111 ///////////////////////////////////////////////////////////////////////////////
113 // Forward class definition for Pair<A, B>
115 ///////////////////////////////////////////////////////////////////////////////
116 #ifndef datatype_Pair_defined
117 #define datatype_Pair_defined
118 template <class A
, class B
> class a_Pair
;
119 #define Pair(A, B) a_Pair<A, B> *
122 ///////////////////////////////////////////////////////////////////////////////
123 // Definition of type Id
124 ///////////////////////////////////////////////////////////////////////////////
126 typedef char const * Id
;
128 ///////////////////////////////////////////////////////////////////////////////
129 // Definition of type Ids
130 ///////////////////////////////////////////////////////////////////////////////
132 typedef a_List
<Id
> * Ids
;
134 ///////////////////////////////////////////////////////////////////////////////
136 // Class for datatype constructor List<T>::#[...]
138 ///////////////////////////////////////////////////////////////////////////////
139 template <class T
> class a_List
: public MEM
{
142 T _1
; a_List
<T
> * _2
;
143 inline a_List (T x_1
, a_List
<T
> * x_2
)
147 inline a_List (T x_1
)
148 : _1(x_1
), _2((a_List
<T
> *)0)
152 template <class T
> inline int boxed(const a_List
<T
> * x
) { return x
!= 0; }
153 template <class T
> inline int untag(const a_List
<T
> * x
) { return x
? 1 : 0; }
154 ///////////////////////////////////////////////////////////////////////////////
156 // Datatype constructor functions for List<T>
158 ///////////////////////////////////////////////////////////////////////////////
159 template <class T
> inline a_List
<T
> * list_1_ (T x_1
, a_List
<T
> * x_2
)
161 return new a_List
<T
> (x_1
, x_2
);
163 template <class T
> inline a_List
<T
> * list_1_ (T x_1
)
165 return new a_List
<T
> (x_1
);
167 ///////////////////////////////////////////////////////////////////////////////
169 // Downcasting functions for List<T>
171 ///////////////////////////////////////////////////////////////////////////////
174 ///////////////////////////////////////////////////////////////////////////////
176 // Class for datatype constructor Pair<A, B>::pair
178 ///////////////////////////////////////////////////////////////////////////////
179 template <class A
, class B
> class a_Pair
: public MEM
{
183 inline a_Pair (A x_fst
, B x_snd
)
184 : fst(x_fst
), snd(x_snd
)
188 template <class A
, class B
> inline int boxed(const a_Pair
<A
, B
> *) { return 1; }
189 template <class A
, class B
> inline int untag(const a_Pair
<A
, B
> *) { return 0; }
190 ///////////////////////////////////////////////////////////////////////////////
192 // Datatype constructor functions for Pair<A, B>
194 ///////////////////////////////////////////////////////////////////////////////
195 template <class A
, class B
> inline a_Pair
<A
, B
> * pair (A x_fst
, B x_snd
)
197 return new a_Pair
<A
, B
> (x_fst
, x_snd
);
199 ///////////////////////////////////////////////////////////////////////////////
201 // Downcasting functions for Pair<A, B>
203 ///////////////////////////////////////////////////////////////////////////////
206 #line 100 "basics.ph"
207 #line 100 "basics.ph"
210 ///////////////////////////////////////////////////////////////////////////////
212 // Macro to iterate over a list.
214 ///////////////////////////////////////////////////////////////////////////////
215 #define APPEND_(a,b) a ## b
216 #define NEWVAR2_(a,b) APPEND_(a,b)
217 #define NEWVAR(a) NEWVAR2_(a,__LINE__)
218 #define for_each(T,i,l) \
220 for (List(T) NEWVAR(_i_) = l; \
221 NEWVAR(_i_) && (i = NEWVAR(_i_)->_1, 1); \
222 NEWVAR(_i_) = NEWVAR(_i_)->_2)
224 ///////////////////////////////////////////////////////////////////////////////
226 // We keep track of the current source location in the following global
227 // variables. These are updated continuously by the parser, lexer and the
228 // semantic processing routines.
230 ///////////////////////////////////////////////////////////////////////////////
231 extern int line
; // the current line number
232 extern int first_line
; // the first line of the current construct
233 extern Id file
; // the current input file.
235 ///////////////////////////////////////////////////////////////////////////////
237 // The following class, Loc, is used to keep track of the source location.
238 // Objects derived from this class will contain the source location in
239 // which it is constructed; useful for AST nodes.
241 ///////////////////////////////////////////////////////////////////////////////
242 struct Loc
: public MEM
{
245 int begin_line
, end_line
;
248 inline const Loc
* loc() const { return this; }
249 void set_loc() const;
253 #line 145 "basics.ph"
255 ------------------------------- Statistics -------------------------------
256 Merge matching rules = yes
257 Number of DFA nodes merged = 0
258 Number of ifs generated = 0
259 Number of switches generated = 0
262 Adaptive matching = enabled
263 Fast string matching = disabled
264 Inline downcasts = enabled
265 --------------------------------------------------------------------------