.gitignore
[prop.git] / tools / misc / bugfix3.cc
blobf4c5b2c42abdbcea6a2cbc9a589621f633b80eb5
1 ///////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.3.0),
3 // last updated on Feb 16, 1997.
4 // The original source file is "bugfix3.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #define PROP_REWRITING_USED
8 #define PROP_QUARK_USED
9 #include <propdefs.h>
10 #line 1 "bugfix3.pcc"
12 // Testing the rewriting features
14 #include <iostream.h>
16 #line 6 "bugfix3.pcc"
17 #line 11 "bugfix3.pcc"
18 ///////////////////////////////////////////////////////////////////////////////
19 // Forward class definition for EXP
20 ///////////////////////////////////////////////////////////////////////////////
21 #ifndef datatype_EXP_defined
22 #define datatype_EXP_defined
23 typedef class a_EXP * EXP;
24 #endif
26 ///////////////////////////////////////////////////////////////////////////////
27 // Class hierarchy for datatype EXP
28 ///////////////////////////////////////////////////////////////////////////////
29 class a_EXP; // base class for datatype EXP
30 class EXP_num; // subclass for 'num int'
31 class EXP_add; // subclass for 'add (EXP, EXP)'
32 class EXP_sub; // subclass for 'sub (EXP, EXP)'
33 class EXP_mul; // subclass for 'mul (EXP, EXP)'
34 class EXP_div; // subclass for 'div (EXP, EXP)'
36 ///////////////////////////////////////////////////////////////////////////////
37 // Base class for datatype 'EXP'
38 ///////////////////////////////////////////////////////////////////////////////
39 class a_EXP {
40 public:
41 enum Tag_EXP {
42 tag_num = 0, tag_add = 1, tag_sub = 2, tag_mul = 3,
43 tag_div = 4
46 protected:
47 const Tag_EXP _tag_;
48 inline a_EXP(Tag_EXP _t_) : _tag_(_t_) {}
49 public:
50 inline int untag() const { return _tag_; }
51 inline friend int boxed(const a_EXP * x) { return 1; }
52 inline friend int untag(const a_EXP * x) { return x->_tag_; }
53 ////////////////////////////////////////////////////////////////////////////
54 // Downcasting functions for EXP
55 ////////////////////////////////////////////////////////////////////////////
56 inline friend EXP_num * _num(EXP _x_) { return (EXP_num *)_x_; }
57 inline friend EXP_add * _add(EXP _x_) { return (EXP_add *)_x_; }
58 inline friend EXP_sub * _sub(EXP _x_) { return (EXP_sub *)_x_; }
59 inline friend EXP_mul * _mul(EXP _x_) { return (EXP_mul *)_x_; }
60 inline friend EXP_div * _div(EXP _x_) { return (EXP_div *)_x_; }
63 ///////////////////////////////////////////////////////////////////////////////
64 // class for constructor 'EXP::num int'
65 ///////////////////////////////////////////////////////////////////////////////
66 class EXP_num : public a_EXP {
67 public:
68 #line 6 "bugfix3.pcc"
69 int num;
70 inline EXP_num (int _xnum)
71 : a_EXP(a_EXP::tag_num), num(_xnum) {}
72 inline friend a_EXP * num (int _xnum)
73 { return new EXP_num (_xnum); }
76 ///////////////////////////////////////////////////////////////////////////////
77 // class for constructor 'EXP::add (EXP, EXP)'
78 ///////////////////////////////////////////////////////////////////////////////
79 class EXP_add : public a_EXP {
80 public:
81 #line 7 "bugfix3.pcc"
82 EXP _1; EXP _2;
83 inline EXP_add (EXP _x1, EXP _x2)
84 : a_EXP(a_EXP::tag_add), _1(_x1), _2(_x2) {}
85 inline friend a_EXP * add (EXP _x1, EXP _x2)
86 { return new EXP_add (_x1, _x2); }
89 ///////////////////////////////////////////////////////////////////////////////
90 // class for constructor 'EXP::sub (EXP, EXP)'
91 ///////////////////////////////////////////////////////////////////////////////
92 class EXP_sub : public a_EXP {
93 public:
94 #line 8 "bugfix3.pcc"
95 EXP _1; EXP _2;
96 inline EXP_sub (EXP _x1, EXP _x2)
97 : a_EXP(a_EXP::tag_sub), _1(_x1), _2(_x2) {}
98 inline friend a_EXP * sub (EXP _x1, EXP _x2)
99 { return new EXP_sub (_x1, _x2); }
102 ///////////////////////////////////////////////////////////////////////////////
103 // class for constructor 'EXP::mul (EXP, EXP)'
104 ///////////////////////////////////////////////////////////////////////////////
105 class EXP_mul : public a_EXP {
106 public:
107 #line 9 "bugfix3.pcc"
108 EXP _1; EXP _2;
109 inline EXP_mul (EXP _x1, EXP _x2)
110 : a_EXP(a_EXP::tag_mul), _1(_x1), _2(_x2) {}
111 inline friend a_EXP * mul (EXP _x1, EXP _x2)
112 { return new EXP_mul (_x1, _x2); }
115 ///////////////////////////////////////////////////////////////////////////////
116 // class for constructor 'EXP::div (EXP, EXP)'
117 ///////////////////////////////////////////////////////////////////////////////
118 class EXP_div : public a_EXP {
119 public:
120 #line 10 "bugfix3.pcc"
121 EXP _1; EXP _2;
122 inline EXP_div (EXP _x1, EXP _x2)
123 : a_EXP(a_EXP::tag_div), _1(_x1), _2(_x2) {}
124 inline friend a_EXP * div (EXP _x1, EXP _x2)
125 { return new EXP_div (_x1, _x2); }
128 #line 11 "bugfix3.pcc"
129 #line 11 "bugfix3.pcc"
132 #line 13 "bugfix3.pcc"
133 #line 13 "bugfix3.pcc"
134 class Simplify : public BURS {
135 private:
136 Simplify(const Simplify&); // no copy constructor
137 void operator = (const Simplify&); // no assignment
138 public:
139 struct Simplify_StateRec * stack__, * stack_top__;
140 public:
141 void labeler(const char *, int&, int);
142 void labeler(Quark, int&, int);
143 void labeler(EXP & redex, int&, int);
144 inline virtual void operator () (EXP & redex) { int s; labeler(redex,s,0); }
145 private:
147 #line 13 "bugfix3.pcc"
148 #line 13 "bugfix3.pcc"
152 #line 16 "bugfix3.pcc"
153 #line 31 "bugfix3.pcc"
154 static const TreeTables::Offset Simplify_accept_base [ 12 ] = {
155 0, 0, 1, 3, 7, 9, 11, 14, 18, 26, 30, 32
157 static const TreeTables::Rule Simplify_accept_vector [ 35 ] = {
158 -1, 1, -1, 0, 1, 10, -1, 0, -1, 2, -1, 2, 11, -1, 3, 5,
159 7, -1, 3, 4, 5, 6, 7, 8, 12, -1, 4, 6, 8, -1, 9, -1,
160 9, 13, -1
162 static const TreeTables::State Simplify_theta_1[2][2] = {
163 { 0, 2 },
164 { 4, 3 }
168 static const TreeTables::State Simplify_theta_2[2][2] = {
169 { 0, 5 },
170 { 0, 6 }
174 static const TreeTables::State Simplify_theta_3[2][2] = {
175 { 0, 7 },
176 { 9, 8 }
180 static const TreeTables::State Simplify_theta_4[2][2] = {
181 { 0, 10 },
182 { 0, 11 }
186 static const TreeTables::State Simplify_mu_1_0[12] = {
187 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
191 static const TreeTables::State Simplify_mu_1_1[12] = {
192 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
196 static const TreeTables::State Simplify_mu_2_0[12] = {
197 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
201 static const TreeTables::State Simplify_mu_2_1[12] = {
202 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
206 static const TreeTables::State Simplify_mu_3_0[12] = {
207 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
211 static const TreeTables::State Simplify_mu_3_1[12] = {
212 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
216 static const TreeTables::State Simplify_mu_4_0[12] = {
217 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
221 static const TreeTables::State Simplify_mu_4_1[12] = {
222 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
226 inline void Simplify::labeler(char const * redex,int& s__,int)
229 s__ = 0;
233 inline void Simplify::labeler(Quark redex,int& s__,int)
236 s__ = 0;
240 void Simplify::labeler (EXP & redex, int& s__, int r__)
242 replacement__:
243 switch(redex->untag()) {
244 case a_EXP::tag_num: {
245 int s0__;
246 s0__ = 0; // int
247 s__ = 1;} break;
248 case a_EXP::tag_add: {
249 int s0__;
250 int s1__;
251 labeler(_add(redex)->_1, s0__, r__);
252 labeler(_add(redex)->_2, s1__, r__);
253 s__ = Simplify_theta_1[Simplify_mu_1_0[s0__]][Simplify_mu_1_1[s1__]]; } break;
254 case a_EXP::tag_sub: {
255 int s0__;
256 int s1__;
257 labeler(_sub(redex)->_1, s0__, r__);
258 labeler(_sub(redex)->_2, s1__, r__);
259 s__ = Simplify_theta_2[Simplify_mu_2_0[s0__]][Simplify_mu_2_1[s1__]]; } break;
260 case a_EXP::tag_mul: {
261 int s0__;
262 int s1__;
263 labeler(_mul(redex)->_1, s0__, r__);
264 labeler(_mul(redex)->_2, s1__, r__);
265 s__ = Simplify_theta_3[Simplify_mu_3_0[s0__]][Simplify_mu_3_1[s1__]]; } break;
266 default: {
267 int s0__;
268 int s1__;
269 labeler(_div(redex)->_1, s0__, r__);
270 labeler(_div(redex)->_2, s1__, r__);
271 s__ = Simplify_theta_4[Simplify_mu_4_0[s0__]][Simplify_mu_4_1[s1__]]; } break;
273 const TreeTables::Rule * o__ = Simplify_accept_vector + Simplify_accept_base[s__];
274 accept__:
275 switch (*o__) {
276 case 13: {
277 #line 30 "bugfix3.pcc"
278 num(_num(_div(redex)->_1)->num / _num(_div(redex)->_2)->num);
279 #line 31 "bugfix3.pcc"
280 } break;
281 case 12: {
282 #line 29 "bugfix3.pcc"
283 num(_num(_mul(redex)->_1)->num * _num(_mul(redex)->_2)->num);
285 #line 30 "bugfix3.pcc"
286 } break;
287 case 11: {
288 #line 28 "bugfix3.pcc"
289 num(_num(_sub(redex)->_1)->num - _num(_sub(redex)->_2)->num);
291 #line 29 "bugfix3.pcc"
292 } break;
293 case 10: {
294 #line 27 "bugfix3.pcc"
295 num(_num(_add(redex)->_1)->num + _num(_add(redex)->_2)->num);
297 #line 28 "bugfix3.pcc"
298 } break;
299 case 9: if ((_num(_div(redex)->_2)->num == 1))
301 #line 26 "bugfix3.pcc"
302 _div(redex)->_1;
304 #line 27 "bugfix3.pcc"
306 else { ++o__; goto accept__; } break;
307 case 8: if ((_num(_mul(redex)->_1)->num == 2))
309 #line 25 "bugfix3.pcc"
310 add(_mul(redex)->_2,_mul(redex)->_2);
312 #line 26 "bugfix3.pcc"
314 else { ++o__; goto accept__; } break;
315 case 7: if ((_num(_mul(redex)->_2)->num == 2))
317 #line 24 "bugfix3.pcc"
318 add(_mul(redex)->_1,_mul(redex)->_1);
320 #line 25 "bugfix3.pcc"
322 else { ++o__; goto accept__; } break;
323 case 6: if ((_num(_mul(redex)->_1)->num == 1))
325 #line 23 "bugfix3.pcc"
326 _mul(redex)->_2;
328 #line 24 "bugfix3.pcc"
330 else { ++o__; goto accept__; } break;
331 case 5: if ((_num(_mul(redex)->_2)->num == 1))
333 #line 22 "bugfix3.pcc"
334 _mul(redex)->_1;
336 #line 23 "bugfix3.pcc"
338 else { ++o__; goto accept__; } break;
339 case 4: if ((_num(_mul(redex)->_1)->num == 0))
341 #line 21 "bugfix3.pcc"
342 num(0);
344 #line 22 "bugfix3.pcc"
346 else { ++o__; goto accept__; } break;
347 case 3: if ((_num(_mul(redex)->_2)->num == 0))
349 #line 20 "bugfix3.pcc"
350 num(0);
352 #line 21 "bugfix3.pcc"
354 else { ++o__; goto accept__; } break;
355 case 2: if ((_num(_sub(redex)->_2)->num == 0))
357 #line 19 "bugfix3.pcc"
358 _sub(redex)->_1;
360 #line 20 "bugfix3.pcc"
362 else { ++o__; goto accept__; } break;
363 case 1: if ((_num(_add(redex)->_2)->num == 0))
365 #line 18 "bugfix3.pcc"
366 _add(redex)->_1;
368 #line 19 "bugfix3.pcc"
370 else { ++o__; goto accept__; } break;
371 case 0: if ((_num(_add(redex)->_1)->num == 0))
373 #line 17 "bugfix3.pcc"
374 _add(redex)->_2;
376 #line 18 "bugfix3.pcc"
378 else { ++o__; goto accept__; } break;
383 #line 31 "bugfix3.pcc"
384 #line 31 "bugfix3.pcc"
387 #line 33 "bugfix3.pcc"
388 #line 35 "bugfix3.pcc"
389 ///////////////////////////////////////////////////////////////////////////////
390 // Forward class definition for NAT
391 ///////////////////////////////////////////////////////////////////////////////
392 #ifndef datatype_NAT_defined
393 #define datatype_NAT_defined
394 typedef class a_NAT * NAT;
395 #endif
397 ///////////////////////////////////////////////////////////////////////////////
398 // Class hierarchy for datatype NAT
399 ///////////////////////////////////////////////////////////////////////////////
400 class a_NAT; // base class for datatype NAT
402 ///////////////////////////////////////////////////////////////////////////////
403 // Base class for datatype 'NAT'
404 ///////////////////////////////////////////////////////////////////////////////
405 class a_NAT {
406 public:
407 # define zero (NAT)0
408 inline friend int boxed(const a_NAT * x) { return x != 0; }
409 inline friend int untag(const a_NAT * x) { return x ? 1 : 0; }
410 #line 34 "bugfix3.pcc"
411 NAT succ;
412 inline a_NAT (NAT _xsucc)
413 : succ(_xsucc) {}
414 inline friend a_NAT * succ (NAT _xsucc)
415 { return new a_NAT (_xsucc); }
418 #line 35 "bugfix3.pcc"
419 #line 35 "bugfix3.pcc"
422 #line 37 "bugfix3.pcc"
423 #line 39 "bugfix3.pcc"
424 class Number : public BURS {
425 private:
426 Number(const Number&); // no copy constructor
427 void operator = (const Number&); // no assignment
428 public:
429 struct Number_StateRec * stack__, * stack_top__;
430 public:
431 void labeler(const char *, int&, int);
432 void labeler(Quark, int&, int);
433 void labeler(NAT & redex, int&, int);
434 inline virtual void operator () (NAT & redex) { int s; labeler(redex,s,0); }
435 void labeler(EXP & redex, int&, int);
436 inline virtual void operator () (EXP & redex) { int s; labeler(redex,s,0); }
437 private:
438 #line 38 "bugfix3.pcc"
440 #line 39 "bugfix3.pcc"
442 #line 39 "bugfix3.pcc"
443 #line 39 "bugfix3.pcc"
446 #line 41 "bugfix3.pcc"
447 #line 51 "bugfix3.pcc"
448 static const TreeTables::State Number_theta_1[6] = {
449 2, 4, 5, 10, 11, 12
453 static const TreeTables::State Number_theta_3[2][2] = {
454 { 0, 0 },
455 { 0, 6 }
459 static const TreeTables::State Number_theta_4[2][2] = {
460 { 0, 0 },
461 { 0, 7 }
465 static const TreeTables::State Number_theta_5[2][2] = {
466 { 0, 0 },
467 { 0, 8 }
471 static const TreeTables::State Number_theta_6[2][2] = {
472 { 0, 0 },
473 { 0, 9 }
477 static const TreeTables::State Number_mu_1_0[13] = {
478 0, 1, 2, 0, 3, 4, 0, 0, 0, 0, 4, 5, 5
482 static const TreeTables::State Number_mu_3_0[13] = {
483 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
487 static const TreeTables::State Number_mu_3_1[13] = {
488 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
492 static const TreeTables::State Number_mu_4_0[13] = {
493 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
497 static const TreeTables::State Number_mu_4_1[13] = {
498 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
502 static const TreeTables::State Number_mu_5_0[13] = {
503 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
507 static const TreeTables::State Number_mu_5_1[13] = {
508 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
512 static const TreeTables::State Number_mu_6_0[13] = {
513 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
517 static const TreeTables::State Number_mu_6_1[13] = {
518 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
522 inline void Number::labeler(char const * redex,int& s__,int)
525 s__ = 0;
529 inline void Number::labeler(Quark redex,int& s__,int)
532 s__ = 0;
536 void Number::labeler (EXP & redex, int& s__, int r__)
538 replacement__:
539 switch(redex->untag()) {
540 case a_EXP::tag_num: {
541 int s0__;
542 s0__ = 0; // int
543 s__ = 3;} break;
544 case a_EXP::tag_add: {
545 int s0__;
546 int s1__;
547 labeler(_add(redex)->_1, s0__, r__);
548 labeler(_add(redex)->_2, s1__, r__);
549 s__ = Number_theta_3[Number_mu_3_0[s0__]][Number_mu_3_1[s1__]]; } break;
550 case a_EXP::tag_sub: {
551 int s0__;
552 int s1__;
553 labeler(_sub(redex)->_1, s0__, r__);
554 labeler(_sub(redex)->_2, s1__, r__);
555 s__ = Number_theta_4[Number_mu_4_0[s0__]][Number_mu_4_1[s1__]]; } break;
556 case a_EXP::tag_mul: {
557 int s0__;
558 int s1__;
559 labeler(_mul(redex)->_1, s0__, r__);
560 labeler(_mul(redex)->_2, s1__, r__);
561 s__ = Number_theta_5[Number_mu_5_0[s0__]][Number_mu_5_1[s1__]]; } break;
562 default: {
563 int s0__;
564 int s1__;
565 labeler(_div(redex)->_1, s0__, r__);
566 labeler(_div(redex)->_2, s1__, r__);
567 s__ = Number_theta_6[Number_mu_6_0[s0__]][Number_mu_6_1[s1__]]; } break;
569 switch (s__) {
570 case 9: {
571 #line 50 "bugfix3.pcc"
572 num(_num(_div(redex)->_1)->num / _num(_div(redex)->_2)->num);
573 #line 51 "bugfix3.pcc"
574 } break;
575 case 8: {
576 #line 49 "bugfix3.pcc"
577 num(_num(_mul(redex)->_1)->num * _num(_mul(redex)->_2)->num);
579 #line 50 "bugfix3.pcc"
580 } break;
581 case 7: {
582 #line 48 "bugfix3.pcc"
583 num(_num(_sub(redex)->_1)->num - _num(_sub(redex)->_2)->num);
585 #line 49 "bugfix3.pcc"
586 } break;
587 case 6: {
588 #line 47 "bugfix3.pcc"
589 num(_num(_add(redex)->_1)->num + _num(_add(redex)->_2)->num);
591 #line 48 "bugfix3.pcc"
592 } break;
597 void Number::labeler (NAT & redex, int& s__, int r__)
599 replacement__:
600 if ((redex)) {
601 int s0__;
602 labeler(redex->succ, s0__, r__);
603 s__ = Number_theta_1[Number_mu_1_0[s0__]];
604 } else {s__ = 1;
606 switch (s__) {
607 case 12:
608 case 11:
609 case 10:
610 case 5: {
611 #line 44 "bugfix3.pcc"
614 #line 45 "bugfix3.pcc"
615 } break;
616 case 4: {
617 #line 43 "bugfix3.pcc"
620 #line 44 "bugfix3.pcc"
621 } break;
622 case 1: {
623 #line 42 "bugfix3.pcc"
626 #line 43 "bugfix3.pcc"
627 } break;
632 #line 51 "bugfix3.pcc"
633 #line 51 "bugfix3.pcc"
635 #line 52 "bugfix3.pcc"
637 ------------------------------- Statistics -------------------------------
638 Merge matching rules = yes
639 Number of DFA nodes merged = 0
640 Number of ifs generated = 0
641 Number of switches generated = 0
642 Number of labels = 0
643 Number of gotos = 0
644 Adaptive matching = disabled
645 Fast string matching = disabled
646 Inline downcasts = disabled
647 --------------------------------------------------------------------------