initial
[prop.git] / prop-src / T1.cc
blobb547371d85311cdddc411b89bf6daec9647ff9d0
1 ///////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.3.3),
3 // last updated on Mar 23, 1997.
4 // The original source file is "T1.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #define PROP_PRINTER_USED
8 #define PROP_PARSER_USED
9 #include <propdefs.h>
10 #line 6 "T1.pcc"
11 ///////////////////////////////////////////////////////////////////////////////
13 // Forward class definition for Exp
15 ///////////////////////////////////////////////////////////////////////////////
16 #ifndef datatype_Exp_defined
17 #define datatype_Exp_defined
18 class a_Exp;
19 typedef a_Exp * Exp;
20 #endif
22 ///////////////////////////////////////////////////////////////////////////////
24 // Base class for datatype Exp
26 ///////////////////////////////////////////////////////////////////////////////
27 class a_Exp {
28 public:
29 enum Tag_Exp {
30 tag_INT = 0, tag_ADD = 1, tag_SUB = 2,
31 tag_MUL = 3, tag_DIV = 4
34 public:
35 const Tag_Exp tag__; // variant tag
36 protected:
37 inline a_Exp(Tag_Exp t__) : tag__(t__) {}
38 public:
40 inline int boxed(const a_Exp *) { return 1; }
41 inline int untag(const a_Exp * x) { return x->tag__; }
42 ///////////////////////////////////////////////////////////////////////////////
44 // Pretty printing methods for Exp
46 ///////////////////////////////////////////////////////////////////////////////
47 class PrettyOStream;
48 extern ostream& operator<<(ostream&, Exp);
49 extern PrettyOStream& operator<<(PrettyOStream&, Exp);
50 ///////////////////////////////////////////////////////////////////////////////
52 // Class for datatype constructor Exp::INT
54 ///////////////////////////////////////////////////////////////////////////////
55 class Exp_INT : public a_Exp {
56 public:
57 #line 1 "T1.pcc"
58 int INT;
59 inline Exp_INT (int x_INT)
60 : a_Exp(tag_INT), INT(x_INT)
65 ///////////////////////////////////////////////////////////////////////////////
67 // Class for datatype constructor Exp::ADD
69 ///////////////////////////////////////////////////////////////////////////////
70 class Exp_ADD : public a_Exp {
71 public:
72 #line 1 "T1.pcc"
73 Exp _1; Exp _2;
74 inline Exp_ADD (Exp x_1, Exp x_2)
75 : a_Exp(tag_ADD), _1(x_1), _2(x_2)
80 ///////////////////////////////////////////////////////////////////////////////
82 // Class for datatype constructor Exp::SUB
84 ///////////////////////////////////////////////////////////////////////////////
85 class Exp_SUB : public a_Exp {
86 public:
87 #line 2 "T1.pcc"
88 Exp _1; Exp _2;
89 inline Exp_SUB (Exp x_1, Exp x_2)
90 : a_Exp(tag_SUB), _1(x_1), _2(x_2)
95 ///////////////////////////////////////////////////////////////////////////////
97 // Class for datatype constructor Exp::MUL
99 ///////////////////////////////////////////////////////////////////////////////
100 class Exp_MUL : public a_Exp {
101 public:
102 #line 3 "T1.pcc"
103 Exp _1; Exp _2;
104 inline Exp_MUL (Exp x_1, Exp x_2)
105 : a_Exp(tag_MUL), _1(x_1), _2(x_2)
110 ///////////////////////////////////////////////////////////////////////////////
112 // Class for datatype constructor Exp::DIV
114 ///////////////////////////////////////////////////////////////////////////////
115 class Exp_DIV : public a_Exp {
116 public:
117 #line 4 "T1.pcc"
118 Exp _1; Exp _2;
119 inline Exp_DIV (Exp x_1, Exp x_2)
120 : a_Exp(tag_DIV), _1(x_1), _2(x_2)
125 ///////////////////////////////////////////////////////////////////////////////
127 // Datatype constructor functions for Exp
129 ///////////////////////////////////////////////////////////////////////////////
130 inline a_Exp * INT (int x_INT)
132 return new Exp_INT (x_INT);
134 inline a_Exp * ADD (Exp x_1, Exp x_2)
136 return new Exp_ADD (x_1, x_2);
138 inline a_Exp * SUB (Exp x_1, Exp x_2)
140 return new Exp_SUB (x_1, x_2);
142 inline a_Exp * MUL (Exp x_1, Exp x_2)
144 return new Exp_MUL (x_1, x_2);
146 inline a_Exp * DIV (Exp x_1, Exp x_2)
148 return new Exp_DIV (x_1, x_2);
150 ///////////////////////////////////////////////////////////////////////////////
152 // Downcasting functions for Exp
154 ///////////////////////////////////////////////////////////////////////////////
155 inline Exp_INT * _INT(const a_Exp * _x_) { return (Exp_INT *)_x_; }
156 inline Exp_ADD * _ADD(const a_Exp * _x_) { return (Exp_ADD *)_x_; }
157 inline Exp_SUB * _SUB(const a_Exp * _x_) { return (Exp_SUB *)_x_; }
158 inline Exp_MUL * _MUL(const a_Exp * _x_) { return (Exp_MUL *)_x_; }
159 inline Exp_DIV * _DIV(const a_Exp * _x_) { return (Exp_DIV *)_x_; }
161 #line 6 "T1.pcc"
162 #line 6 "T1.pcc"
165 #line 8 "T1.pcc"
166 #line 8 "T1.pcc"
167 ///////////////////////////////////////////////////////////////////////////////
169 // Interface specification of datatype Exp
171 ///////////////////////////////////////////////////////////////////////////////
172 #line 8 "T1.pcc"
173 ///////////////////////////////////////////////////////////////////////////////
175 // Pretty printing methods for Exp
177 ///////////////////////////////////////////////////////////////////////////////
178 ostream& operator << (ostream& strm__, Exp obj__);
179 PrettyOStream& operator << (PrettyOStream& strm__, Exp obj__);
181 ///////////////////////////////////////////////////////////////////////////////
183 // Instantiation of datatype Exp
185 ///////////////////////////////////////////////////////////////////////////////
186 #line 8 "T1.pcc"
187 ///////////////////////////////////////////////////////////////////////////////
189 // Pretty printing methods for Exp
191 ///////////////////////////////////////////////////////////////////////////////
192 ostream& operator << (ostream& strm__, Exp obj__)
193 { PrettyOStream S(strm__); S << obj__; return strm__; }
195 PrettyOStream& operator << (PrettyOStream& strm__, Exp obj__)
197 switch (untag(obj__))
199 case a_Exp::tag_INT:
200 strm__ << _INT(obj__)->INT; // int
201 break;
202 case a_Exp::tag_ADD:
203 strm__ << _ADD(obj__)->_1; // Exp
204 strm__ << '+';
205 strm__ << _ADD(obj__)->_2; // Exp
206 break;
207 case a_Exp::tag_SUB:
208 strm__ << _SUB(obj__)->_1; // Exp
209 strm__ << '-';
210 strm__ << _SUB(obj__)->_2; // Exp
211 break;
212 case a_Exp::tag_MUL:
213 strm__ << _MUL(obj__)->_1; // Exp
214 strm__ << '*';
215 strm__ << _MUL(obj__)->_2; // Exp
216 break;
217 case a_Exp::tag_DIV:
218 strm__ << _DIV(obj__)->_1; // Exp
219 strm__ << '/';
220 strm__ << _DIV(obj__)->_2; // Exp
221 break;
223 return strm__;
228 #line 8 "T1.pcc"
229 #line 8 "T1.pcc"
232 #line 10 "T1.pcc"
233 #line 12 "T1.pcc"
234 class Foo : public LR1Parser {
235 public:
236 ////////////////////////////////////////////////////////////////////////////
237 // Parser table type definitions
238 ////////////////////////////////////////////////////////////////////////////
239 typedef LR1Parser Super;
240 typedef Super::Offset Offset;
241 typedef Super::State State;
242 typedef Super::Rule Rule;
243 typedef Super::Symbol Symbol;
244 typedef Super::ProductionLength ProductionLength;
245 typedef Super::ShortSymbol ShortSymbol;
246 typedef Super::EquivMap EquivMap;
247 enum { INITIAL_STACK_SIZE_ = 256,
248 MAX_STACK_SIZE_ = 8192
250 protected:
251 ////////////////////////////////////////////////////////////////////////////
252 // Semantic value stack
253 ////////////////////////////////////////////////////////////////////////////
254 union Foo_semantic_stack_type * t__, * bot__;
255 int stack_size__;
256 int heap_allocated__;
257 public:
258 ////////////////////////////////////////////////////////////////////////////
259 // Constructor and parsing method
260 ////////////////////////////////////////////////////////////////////////////
261 Foo();
262 virtual void parse();
263 void action_driver(const Rule);
264 private:
265 void adjust_stack(int);
266 void grow_semantic_stack();
267 #line 11 "T1.pcc"
269 #line 12 "T1.pcc"
271 #line 12 "T1.pcc"
272 #line 12 "T1.pcc"
275 #line 14 "T1.pcc"
276 #line 27 "T1.pcc"
277 ///////////////////////////////////////////////////////////////////////////////
278 // Encoded parser tables for syntax class Foo
279 ///////////////////////////////////////////////////////////////////////////////
280 static const DFATables::Offset Foo_base [ 15 ] = {
281 0, 0, 8, 0, 5, 7, 6, 5, 3, 0, 0, 5, 0, 0, 0
283 static const DFATables::State Foo_check [ 19 ] = {
284 0, 1, 0, 3, 3, 3, 3, 4, 3, 1, 11, 11, 8, 4, 7, 6,
285 5, 2, 0
287 static const DFATables::State Foo_next [ 19 ] = {
288 0, 2, 0, 5, 6, 7, 8, 16394, 9, 3, 7, 8, 16398, 0, 16397, 12,
289 11, 4, 0
291 static const DFATables::State Foo_def [ 15 ] = {
292 0, 0, 1, 0, 3, 1, 1, 1, 1, 0, 0, 0, 11, 0, 0
294 static const DFATables::State Foo_defact [ 15 ] = {
295 0, 0, 0, 0, 0, 0, 0, 0, 0, 32773, 32768, 32769, 32770, 32771, 32772
297 static const DFATables::ProductionLength Foo_len [ 6 ] = {
298 3, 3, 3, 3, 3, 2
300 static const DFATables::ProductionLength Foo_ncount [ 6 ] = {
301 1, 2, 2, 2, 2, 1
303 static const DFATables::ShortSymbol Foo_lhs [ 6 ] = {
304 9, 9, 9, 9, 9, 10
306 static const DFATables::EquivMap Foo_equiv [ 261 ] = {
307 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
308 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
309 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 5, 3, 0, 4, 0,
310 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
311 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
312 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
313 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
314 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
315 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
316 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
317 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
318 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
319 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
320 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
321 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
322 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
323 0, 0, 0, 9, 10
325 ///////////////////////////////////////////////////////////////////////////////
326 // Debugging tables for syntax class Foo
327 ///////////////////////////////////////////////////////////////////////////////
329 #ifdef DEBUG_Foo
330 static const int Foo_line[] =
332 21, 22, 23, 24, 25, 0
335 static const char * const Foo_symbolname[] =
337 "?", "\'(\'", "\')\'", "\'+\'", "\'-\'", "\'*\'", "\'/\'", "???",
338 "???", "exp", "???"
341 static const DFATables::ShortSymbol Foo_rhs_0[] = { 1, 9, 2, -1 };
342 static const DFATables::ShortSymbol Foo_rhs_1[] = { 9, 3, 9, -1 };
343 static const DFATables::ShortSymbol Foo_rhs_2[] = { 9, 4, 9, -1 };
344 static const DFATables::ShortSymbol Foo_rhs_3[] = { 9, 5, 9, -1 };
345 static const DFATables::ShortSymbol Foo_rhs_4[] = { 9, 6, 9, -1 };
346 static const DFATables::ShortSymbol Foo_rhs_5[] = { 9, 8, -1 };
347 static const DFATables::ShortSymbol * Foo_rhs[] =
349 Foo_rhs_0,
350 Foo_rhs_1,
351 Foo_rhs_2,
352 Foo_rhs_3,
353 Foo_rhs_4,
354 Foo_rhs_5
358 #endif
360 ///////////////////////////////////////////////////////////////////////////////
361 // Semantic value stack for syntax class Foo
362 ///////////////////////////////////////////////////////////////////////////////
363 union Foo_semantic_stack_type {
364 int dummy;
365 #line 20 "T1.pcc"
366 typedef struct { int value; } ATTRIBUTE_0;
367 ATTRIBUTE_0 _24, _22, _21, _19, _17, _16, _14, _12, _11, _9, _7, _6, _3, _1;
371 ///////////////////////////////////////////////////////////////////////////////
372 // Parser driver for syntax class Foo
373 ///////////////////////////////////////////////////////////////////////////////
374 inline void Foo::action_driver(const Rule _r_)
376 Foo_semantic_stack_type syn_;
377 ////////////////////////////////////////////////////////////////////////////
378 // Tracing code for syntax class Foo
379 ////////////////////////////////////////////////////////////////////////////
380 #ifdef DEBUG_Foo
381 { cerr << "Reducing via rule " << _r_ << " at line "
382 << Foo_line[_r_] << ", "
383 << Foo_symbolname[Foo_lhs[_r_]] << " <- ";
384 for (const DFATables::ShortSymbol * _p_ = Foo_rhs[_r_]; *_p_ >= 0; _p_++)
385 cerr << Foo_symbolname[*_p_] << ' ';
386 cerr << '\n';
388 #endif
390 ////////////////////////////////////////////////////////////////////////////
391 // Actions for syntax class Foo
392 ////////////////////////////////////////////////////////////////////////////
393 t__ -= Foo_ncount[_r_];
394 switch (_r_) {
396 #undef to__
397 #define to__ 0
398 case 0: {
399 #line 21 "T1.pcc"
400 syn_._1.value = t__[1+to__]._3.value;
401 #line 21 "T1.pcc"
402 } break;
403 case 1: {
404 #line 22 "T1.pcc"
405 syn_._6.value = t__[1+to__]._7.value + t__[2+to__]._9.value;
406 #line 22 "T1.pcc"
407 } break;
408 case 2: {
409 #line 23 "T1.pcc"
410 syn_._11.value = t__[1+to__]._12.value - t__[2+to__]._14.value;
411 #line 23 "T1.pcc"
412 } break;
413 case 3: {
414 #line 24 "T1.pcc"
415 syn_._16.value = t__[1+to__]._17.value * t__[2+to__]._19.value;
416 #line 24 "T1.pcc"
417 } break;
418 case 4: {
419 #line 25 "T1.pcc"
420 syn_._21.value = t__[1+to__]._22.value / t__[2+to__]._24.value;
421 #line 25 "T1.pcc"
422 } break;
424 if (t__ >= bot__ + stack_size__) grow_semantic_stack();
425 *++t__ = syn_;
428 ///////////////////////////////////////////////////////////////////////////////
429 // Parsing method for parser class Foo
430 ///////////////////////////////////////////////////////////////////////////////
431 void Foo::parse()
433 Foo_semantic_stack_type stack__[INITIAL_STACK_SIZE_];
434 t__ = bot__ = stack__;
435 stack_size__ = sizeof(stack__)/sizeof(stack__[0]) - 1;
436 heap_allocated__ = 0;
437 parser_prefix();
438 LR1ParserDriver<Foo,(LR1Parser::State)9> drv;
439 drv.driver(*this);
440 parser_suffix();
441 if (bot__ != stack__) delete [] bot__;
444 void Foo::adjust_stack(int offset) { t__ += offset; }
446 void Foo::grow_semantic_stack()
448 int N = (stack_size__ + 1) * 2;
449 Foo_semantic_stack_type * S = new Foo_semantic_stack_type [N];
450 if (N >= LR1Parser::SEMANTIC_STACK_SIZE)
451 error_report("Warning: semantic stack overflow");
452 memcpy(S, bot__, sizeof(Foo_semantic_stack_type) * (stack_size__ + 1));
453 if (heap_allocated__) delete [] bot__;
454 t__ = S + (t__ - bot__);
455 bot__ = S;
456 stack_size__ = N - 1;
457 heap_allocated__ = 1;
460 Foo::Foo ()
461 : Super(Foo_base,Foo_check,Foo_def,Foo_defact,Foo_next,
462 Foo_len,Foo_ncount,Foo_lhs,Foo_equiv,256,256,258)
465 #line 27 "T1.pcc"
466 #line 27 "T1.pcc"
470 int main()
472 //Exp e = `?x+?y`;
474 #line 34 "T1.pcc"
476 ------------------------------- Statistics -------------------------------
477 Merge matching rules = yes
478 Number of DFA nodes merged = 0
479 Number of ifs generated = 0
480 Number of switches generated = 0
481 Number of labels = 0
482 Number of gotos = 0
483 Adaptive matching = disabled
484 Fast string matching = disabled
485 Inline downcasts = disabled
486 --------------------------------------------------------------------------