1 ///////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.3.5),
3 // last updated on Jun 18, 1997.
4 // The original source file is "timespace.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #define PROP_REWRITING_USED
8 #define PROP_QUARK_USED
10 #line 1 "timespace.pcc"
11 ///////////////////////////////////////////////////////////////////////////////
13 // This file implements the time and space complexity
14 // datatypes. These datatypes are used to represent time and space
15 // complexity in the SETL-like extension language.
17 ///////////////////////////////////////////////////////////////////////////////
21 #include "timespace.h"
23 ///////////////////////////////////////////////////////////////////////////////
25 // Instantiate the time and space datatypes
27 ///////////////////////////////////////////////////////////////////////////////
28 #line 18 "timespace.pcc"
29 #line 18 "timespace.pcc"
30 ///////////////////////////////////////////////////////////////////////////////
32 // Interface specification of datatype Complexity
34 ///////////////////////////////////////////////////////////////////////////////
35 #line 18 "timespace.pcc"
38 ///////////////////////////////////////////////////////////////////////////////
40 // Interface specification of datatype Time
42 ///////////////////////////////////////////////////////////////////////////////
43 #line 18 "timespace.pcc"
46 ///////////////////////////////////////////////////////////////////////////////
48 // Interface specification of datatype Space
50 ///////////////////////////////////////////////////////////////////////////////
51 #line 18 "timespace.pcc"
54 ///////////////////////////////////////////////////////////////////////////////
56 // Instantiation of datatype Complexity
58 ///////////////////////////////////////////////////////////////////////////////
59 #line 18 "timespace.pcc"
62 ///////////////////////////////////////////////////////////////////////////////
64 // Instantiation of datatype Time
66 ///////////////////////////////////////////////////////////////////////////////
67 #line 18 "timespace.pcc"
70 ///////////////////////////////////////////////////////////////////////////////
72 // Instantiation of datatype Space
74 ///////////////////////////////////////////////////////////////////////////////
75 #line 18 "timespace.pcc"
78 #line 18 "timespace.pcc"
79 #line 18 "timespace.pcc"
82 ///////////////////////////////////////////////////////////////////////////////
84 // Pretty print the complexity
86 ///////////////////////////////////////////////////////////////////////////////
87 ostream& operator << (ostream& f, Complexity c)
89 #line 26 "timespace.pcc"
90 #line 36 "timespace.pcc"
93 case a_Complexity::tag_Var: {
94 #line 27 "timespace.pcc"
96 #line 27 "timespace.pcc"
98 case a_Complexity::tag_Add: {
99 #line 28 "timespace.pcc"
100 f << '(' << _Add(c)->_1 << " + " << _Add(c)->_2 << ')';
101 #line 28 "timespace.pcc"
103 case a_Complexity::tag_Mul: {
104 #line 29 "timespace.pcc"
105 f << '(' << _Mul(c)->_1 << " * " << _Mul(c)->_2 << ')';
106 #line 29 "timespace.pcc"
108 case a_Complexity::tag_Div: {
109 #line 30 "timespace.pcc"
110 f << '(' << _Div(c)->_1 << " / " << _Div(c)->_2 << ')';
111 #line 30 "timespace.pcc"
113 case a_Complexity::tag_Power: {
114 #line 31 "timespace.pcc"
115 f << '(' << _Power(c)->_1 << " ^ " << _Power(c)->_2 << ')';
116 #line 31 "timespace.pcc"
118 case a_Complexity::tag_Log: {
119 #line 32 "timespace.pcc"
120 f << "log " << _Log(c)->Log;
121 #line 32 "timespace.pcc"
123 case a_Complexity::tag_Const: {
124 #line 33 "timespace.pcc"
125 f << _Const(c)->Const;
126 #line 33 "timespace.pcc"
128 case a_Complexity::tag_BigOh: {
129 #line 34 "timespace.pcc"
130 f << "O(" << _BigOh(c)->BigOh << ')';
131 #line 34 "timespace.pcc"
133 case a_Complexity::tag_Omega: {
134 #line 35 "timespace.pcc"
135 f << "Omega(" << _Omega(c)->Omega << ')';
136 #line 35 "timespace.pcc"
139 #line 36 "timespace.pcc"
140 f << "o(" << _LittleOh(c)->LittleOh << ')';
141 #line 36 "timespace.pcc"
145 #line 37 "timespace.pcc"
146 #line 37 "timespace.pcc"
151 ///////////////////////////////////////////////////////////////////////////////
153 // Pretty print the time complexity
155 ///////////////////////////////////////////////////////////////////////////////
156 ostream& operator << (ostream& f, Time t)
157 { return f << "Time(" << t << ")"; }
159 ///////////////////////////////////////////////////////////////////////////////
161 // Pretty print the space complexity
163 ///////////////////////////////////////////////////////////////////////////////
164 ostream& operator << (ostream& f, Space s)
165 { return f << "Space(" << s << ")"; }
167 ///////////////////////////////////////////////////////////////////////////////
169 // Function to simplify a complexity expression
171 ///////////////////////////////////////////////////////////////////////////////
172 Complexity simplify (Complexity c)
174 #line 63 "timespace.pcc"
175 #line 69 "timespace.pcc"
176 extern void _t_i_m_e_s_p_a_c_eco_X1_rewrite(Complexity & );
177 _t_i_m_e_s_p_a_c_eco_X1_rewrite(c);
178 #line 69 "timespace.pcc"
179 #line 69 "timespace.pcc"
183 #line 72 "timespace.pcc"
184 class _t_i_m_e_s_p_a_c_eco_X1 : public BURS {
186 _t_i_m_e_s_p_a_c_eco_X1(const _t_i_m_e_s_p_a_c_eco_X1&); // no copy constructor
187 void operator = (const _t_i_m_e_s_p_a_c_eco_X1&); // no assignment
189 struct _t_i_m_e_s_p_a_c_eco_X1_StateRec * stack__, * stack_top__;
191 void labeler(const char *, int&, int);
192 void labeler(Quark, int&, int);
193 void labeler(Complexity & redex, int&, int);
194 inline virtual void operator () (Complexity & redex) { int s; labeler(redex,s,0); }
197 inline _t_i_m_e_s_p_a_c_eco_X1() {}
199 void _t_i_m_e_s_p_a_c_eco_X1_rewrite(Complexity & _x_)
200 { _t_i_m_e_s_p_a_c_eco_X1 _r_;
204 ///////////////////////////////////////////////////////////////////////////////
206 // This macro can be redefined by the user for debugging
208 ///////////////////////////////////////////////////////////////////////////////
209 #ifndef DEBUG__t_i_m_e_s_p_a_c_eco_X1
210 #define DEBUG__t_i_m_e_s_p_a_c_eco_X1(repl,redex,file,line,rule) repl
212 static const char * _t_i_m_e_s_p_a_c_eco_X1_file_name = "timespace.pcc";
215 static const TreeTables::Offset _t_i_m_e_s_p_a_c_eco_X1_accept_base [ 7 ] = {
218 static const TreeTables::ShortRule _t_i_m_e_s_p_a_c_eco_X1_accept_vector [ 11 ] = {
219 -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1
221 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_1[2][2] = {
227 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_2[2][2] = {
233 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_3[2][2] = {
239 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_4[2][2] = {
245 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_5[2] = {
250 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_1_0[7] = {
255 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_1_1[7] = {
260 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_2_0[7] = {
265 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_2_1[7] = {
270 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_3_0[7] = {
275 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_3_1[7] = {
280 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_4_0[7] = {
285 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_4_1[7] = {
290 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_5_0[7] = {
295 inline void _t_i_m_e_s_p_a_c_eco_X1::labeler(char const * redex,int& s__,int)
302 inline void _t_i_m_e_s_p_a_c_eco_X1::labeler(Quark redex,int& s__,int)
309 void _t_i_m_e_s_p_a_c_eco_X1::labeler (Complexity & redex, int& s__, int r__)
312 switch(redex->tag__) {
313 case a_Complexity::tag_Var: {
315 labeler(_Var(redex)->Var, s0__, r__);
317 case a_Complexity::tag_Add: {
320 labeler(_Add(redex)->_1, s0__, r__);
321 labeler(_Add(redex)->_2, s1__, r__);
322 s__ = _t_i_m_e_s_p_a_c_eco_X1_theta_1[_t_i_m_e_s_p_a_c_eco_X1_mu_1_0[s0__]][_t_i_m_e_s_p_a_c_eco_X1_mu_1_1[s1__]]; } break;
323 case a_Complexity::tag_Mul: {
326 labeler(_Mul(redex)->_1, s0__, r__);
327 labeler(_Mul(redex)->_2, s1__, r__);
328 s__ = _t_i_m_e_s_p_a_c_eco_X1_theta_2[_t_i_m_e_s_p_a_c_eco_X1_mu_2_0[s0__]][_t_i_m_e_s_p_a_c_eco_X1_mu_2_1[s1__]]; } break;
329 case a_Complexity::tag_Div: {
332 labeler(_Div(redex)->_1, s0__, r__);
333 labeler(_Div(redex)->_2, s1__, r__);
334 s__ = _t_i_m_e_s_p_a_c_eco_X1_theta_3[_t_i_m_e_s_p_a_c_eco_X1_mu_3_0[s0__]][_t_i_m_e_s_p_a_c_eco_X1_mu_3_1[s1__]]; } break;
335 case a_Complexity::tag_Power: {
338 labeler(_Power(redex)->_1, s0__, r__);
339 labeler(_Power(redex)->_2, s1__, r__);
340 s__ = _t_i_m_e_s_p_a_c_eco_X1_theta_4[_t_i_m_e_s_p_a_c_eco_X1_mu_4_0[s0__]][_t_i_m_e_s_p_a_c_eco_X1_mu_4_1[s1__]]; } break;
341 case a_Complexity::tag_Log: {
343 labeler(_Log(redex)->Log, s0__, r__);
344 s__ = _t_i_m_e_s_p_a_c_eco_X1_theta_5[_t_i_m_e_s_p_a_c_eco_X1_mu_5_0[s0__]]; } break;
345 case a_Complexity::tag_Const: {
349 case a_Complexity::tag_BigOh: {
351 labeler(_BigOh(redex)->BigOh, s0__, r__);
353 case a_Complexity::tag_Omega: {
355 labeler(_Omega(redex)->Omega, s0__, r__);
359 labeler(_LittleOh(redex)->LittleOh, s0__, r__);
362 const TreeTables::ShortRule * o__ = _t_i_m_e_s_p_a_c_eco_X1_accept_vector + _t_i_m_e_s_p_a_c_eco_X1_accept_base[s__];
365 case 4: if (equality_of(_Const(_Log(redex)->Log)->Const,))
367 #line 68 "timespace.pcc"
368 { redex = DEBUG__t_i_m_e_s_p_a_c_eco_X1(Const(log(_Const(_Log(redex)->Log)->Const)),redex,_t_i_m_e_s_p_a_c_eco_X1_file_name,68,"Log Const i | equality_of(redex!Log!Const,): ...");
369 r__ = 1; goto replacement__; }
370 #line 69 "timespace.pcc"
372 else { ++o__; goto accept__; } break;
373 case 3: if ((equality_of(_Const(_Power(redex)->_1)->Const,) && equality_of(_Const(_Power(redex)->_2)->Const,)))
375 #line 67 "timespace.pcc"
376 { redex = DEBUG__t_i_m_e_s_p_a_c_eco_X1(Const(exp((log(_Const(_Power(redex)->_1)->Const) * _Const(_Power(redex)->_2)->Const))),redex,_t_i_m_e_s_p_a_c_eco_X1_file_name,67,"Power (Const i, Const j) | (equality_of(redex!Power.1!Const,) && equality_of(redex!Power.2!Const,)): ...");
377 r__ = 1; goto replacement__; }
378 #line 68 "timespace.pcc"
380 else { ++o__; goto accept__; } break;
381 case 2: if ((equality_of(_Const(_Div(redex)->_1)->Const,) && equality_of(_Const(_Div(redex)->_2)->Const,)))
383 #line 66 "timespace.pcc"
384 { redex = DEBUG__t_i_m_e_s_p_a_c_eco_X1(Const((_Const(_Div(redex)->_1)->Const / _Const(_Div(redex)->_2)->Const)),redex,_t_i_m_e_s_p_a_c_eco_X1_file_name,66,"Div (Const i, Const j) | (equality_of(redex!Div.1!Const,) && equality_of(redex!Div.2!Const,)): ...");
385 r__ = 1; goto replacement__; }
386 #line 67 "timespace.pcc"
388 else { ++o__; goto accept__; } break;
389 case 1: if ((equality_of(_Const(_Mul(redex)->_1)->Const,) && equality_of(_Const(_Mul(redex)->_2)->Const,)))
391 #line 65 "timespace.pcc"
392 { redex = DEBUG__t_i_m_e_s_p_a_c_eco_X1(Const((_Const(_Mul(redex)->_1)->Const * _Const(_Mul(redex)->_2)->Const)),redex,_t_i_m_e_s_p_a_c_eco_X1_file_name,65,"Mul (Const i, Const j) | (equality_of(redex!Mul.1!Const,) && equality_of(redex!Mul.2!Const,)): ...");
393 r__ = 1; goto replacement__; }
394 #line 66 "timespace.pcc"
396 else { ++o__; goto accept__; } break;
397 case 0: if ((equality_of(_Const(_Add(redex)->_1)->Const,) && equality_of(_Const(_Add(redex)->_2)->Const,)))
399 #line 64 "timespace.pcc"
400 { redex = DEBUG__t_i_m_e_s_p_a_c_eco_X1(Const((_Const(_Add(redex)->_1)->Const + _Const(_Add(redex)->_2)->Const)),redex,_t_i_m_e_s_p_a_c_eco_X1_file_name,64,"Add (Const i, Const j) | (equality_of(redex!Add.1!Const,) && equality_of(redex!Add.2!Const,)): ...");
401 r__ = 1; goto replacement__; }
402 #line 65 "timespace.pcc"
404 else { ++o__; goto accept__; } break;
410 ------------------------------- Statistics -------------------------------
411 Merge matching rules = yes
412 Number of DFA nodes merged = 0
413 Number of ifs generated = 0
414 Number of switches generated = 1
417 Adaptive matching = disabled
418 Fast string matching = disabled
419 Inline downcasts = disabled
420 --------------------------------------------------------------------------