1 #include "ptoc.h"
2 
3 
4 typedef unsigned char short_;
5 const int min_short_ = 1;
6 const int max_short_ = 10;
7 typedef array<min_short_,max_short_,integer> as_;
8 typedef array<0,10,char> tarr;
9 enum color {red, blue, green, yellow, white, last_color};
10 typedef set_of_enum(color) cset;
11 typedef array<1,11,char> str11;
12 struct rec {
13            integer x;
14            integer y;
15            color c;
16            union {
17                real r;
18                                 /*no components*/
19                struct {boolean p, q; tarr v;} s_green;
20                struct {array<1,2,integer> f, g;} s_yellow;
21            };
22 };
23 typedef rec* recptr;
24 struct complex { real im, re; };
25 
26 const complex zero = {0.0, 0.0};
27 const as_ primes = {{1, 3, 5, 7, 11, 13, 17, 19, 23, 29}};
28 const char hello[] = "Hello world";
29 const set letters = set::of('a', 'b', range('p','q'), 'z', eos);
30 const real pi = 3.14;
31 
32 cset cs;
33 integer i, j, k;   /* integer variables */
34 char c;
35 complex* cp;
36 set alp;
37 enum {     one,   /*1*/
38            two,   /*2*/
39            three, /*3*/
40            four,  /*4*/
41            five} state; /*5*/
42 
43 array<0,last_color,integer> a;
44 recptr p;
45 tarr arr;
46 str11 str;
47 struct A2 {
48          integer i;
49          struct A1 {
50                  integer j;
51                  struct A3 {
52                         integer k;
53                  } r;
54          } rr;
55 } rrr;
56 
57 /*** Procedures declaration ***/
58 
59 void recursive_proc();
60 
inner(integer & out)61 static void inner(integer& out)
62 {
63    i = (short_)(i);
64    out = 0;
65    recursive_proc();
66 }    /* inner */
67 
recursive_proc()68 void recursive_proc()
69 {
70    integer out;
71 
72    inner(out);
73 }
74 
75 
76 str11 foo(conf_array<char> a, conf_array<char> b);
77 
78 static integer i1, j2, k1;
79 
80 static matrix<1,10, 1,10,real> p1;
81 
82 static matrix<1,10,1,10,real> q;
83 
84 const real e = 2.81;
85 
86 
87 const set empty_set = set::of(eos);
88 
89 static integer f1();
90 
91 typedef integer x;
92 
93 
94 
h(integer x)95 static void h(integer x)
96 {;
97 }
98 
99 
100 
101 /* function g (inside f1) */
g(void (* f)(integer x))102 static integer g(void (*f)(integer x))
103 {
104     integer g_result;
105     if (k1 < 0)  g_result = j2;
106     else g_result = trunc(e) + -j2;
107     j2 = succ(color,red);
108     f(0);
109     return g_result;
110 }   /*g*/
111 
112 
113 
f1()114 static integer f1()
115 
116 {     /*f1*/
117     integer f1_result;
118     p1 = q;
119     f1_result = i1 + g(h);
120     return f1_result;
121 }   /*f1*/
122 
123 static integer f2(conf_matrix<real> m)
124              ;
125 
126 
g1(conf_matrix<real> & m,integer & i)127 static integer g1(conf_matrix<real>& m, integer& i) /*yet another g*/
128 {
129     const int l1 = m.low1;
130     const int h1 = m.high1;
131     const int l2 = m.low2;
132     const int h2 = m.high2;
133     copy_conformant_array(m);
134     integer g1_result;
135     g1_result = trunc(m[1][1]);
136     cs = cs + set_of_enum(color)::of(red, green, eos);
137     if (cs == set_of_enum(color)::of(eos))  cs = set_of_enum(color)::of(eos);
138 
139     switch (i) {
140       case RANGE_26('a','z'): case RANGE_10('0','9'): g1_result = 0;
141       break;
142       case RANGE_32(0,31): g1_result = 32;
143       break;
144       case -1 : g1_result = -1; break;
145       case 1  : {
146               g1_result = 1;
147            }
148            break;
149       default: g1_result = 0;
150     }
151     return g1_result;
152 }            /*g*/
153 
154 
155 
f2(conf_matrix<real> m)156 static integer f2(conf_matrix<real> m)
157 
158 /*
159  * function g (inside f2)
160  */
161 {
162     integer i, j;
163 
164       /*f2*/
165     const int l1 = m.low1;
166     const int h1 = m.high1;
167     const int l2 = m.low2;
168     const int h2 = m.high2;
169     copy_conformant_array(m);
170     integer f2_result;
171     for( i = l1; i <= h1; i ++)
172         for( j = h2; j >= l2; j --)
173             m[i][j] = m[j][i];
174     f2_result = g1(m, i);
175     return f2_result;
176 }        /*f2*/
177 
foo(conf_array<char> a,conf_array<char> b)178 str11 foo(conf_array<char> a, conf_array<char> b)
179 {
180     boolean bool_;
181     real r;
182     rec struct_;
183     file<rec> f;
184 
185 
186       /*foo*/
187     const int l = a.low;
188     const int h = a.high;
189     str11 foo_result;
190     i1 = 1;
191     do {
192         j2 = 1;
193         while (j2 < 012)
194         {
195             q[i1][j2] = 1.0;
196             j2 = j2 + 1;
197         }
198         i1 = i1 + 1;
199     } while (!(i1 == 10));
200 
201     p1 = q;
202     bool_ = true;
203     i1 = 1;
204     j2 = i1 + 1;
205     k1 = (i1 + j2) * 2 / 2;
206     r = pi;
207 
208     output << "bool = " << btos(bool_) << "i = " << format(i1,2) << "r = " << format(r,5,3) << NL;
209     output << "bool = " << btos(bool_) << "i = " << format(i1,2) << "r = " << format(r,5,3);
210     output << "bool = " << btos(bool_) << "i = " << format(i1,2) << "r = " << format(r,5,3) << NL;
211     output << "bool = " << btos(bool_) << "i = " << format(i1,2) << "r = " << format(r,5,3);
212 
213     struct_.s_green.p = struct_.s_green.q;
214     if (! eof())
215        input >> i1 >> struct_.s_green.v >> j2 >> NL;
216     input >> i1 >> struct_.s_green.v >> j2;
217 
218     f << struct_ << struct_;
219     f >> struct_ >> struct_;
220     struct_ = *f;
221     store(f, struct_);
222 
223     i1 = f1() + f1();
224     j2 = f2(p1) + f2(q);
225     k1 = i1 % j2;
226 
227     foo_result = "abcdefgijkl";
228     return foo_result;
229 }   /*foo*/
230 
231 
232 
main(int argc,const char * argv[])233 int main(int argc, const char* argv[])
234 {
235     pio_initialize(argc, argv);
236     if (arr > "aaaaaaaaaaa")
237        str = foo("hello","world");
238     str = foo(foo(str,str),foo(str,str));
239     a[green] = 0377;
240     a[red] = 0xff00;
241     a[blue] = 0;
242     str = "\"a*z\"'\"A*Z\"";
243     str[5] = '\'';
244     str[5] = '-';
245     output << arr << NL;
246 
247     if (letters.has(c))  alp = alp + set::of(range('0','9'), range('a','f'), eos);
248 
249     p = new rec;
250     p->x = 1;
251     p->x = p->y;
252     *p = *p;
253     cp = &zero;
254     {
255         rec& with = *p;
256         complex& with1 = *cp;
257 
258         with.x = 1;
259         with.y = 2;
260         with1.re = with1.im;
261         with.r = with1.re;
262         with1.im = with.r;
263     }
264     delete p;
265     {
266        A2::A1& with1 = rrr.rr;
267        A2::A1::A3& with2 = rrr.rr.r;
268 
269        rrr.i = with1.j;
270        with1.j = with2.k;
271     }
272     return EXIT_SUCCESS;
273 }
274 
275 
276