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
11 ///////////////////////////////////////////////////////////////////////////////
13 // Forward class definition for Exp
15 ///////////////////////////////////////////////////////////////////////////////
16 #ifndef datatype_Exp_defined
17 #define datatype_Exp_defined
22 ///////////////////////////////////////////////////////////////////////////////
24 // Base class for datatype Exp
26 ///////////////////////////////////////////////////////////////////////////////
30 tag_INT
= 0, tag_ADD
= 1, tag_SUB
= 2,
31 tag_MUL
= 3, tag_DIV
= 4
35 const Tag_Exp tag__
; // variant tag
37 inline a_Exp(Tag_Exp t__
) : tag__(t__
) {}
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 ///////////////////////////////////////////////////////////////////////////////
48 extern std::ostream
& operator<<(std::ostream
&, Exp
);
49 extern PrettyOStream
& operator<<(PrettyOStream
&, Exp
);
50 ///////////////////////////////////////////////////////////////////////////////
52 // Class for datatype constructor Exp::INT
54 ///////////////////////////////////////////////////////////////////////////////
55 class Exp_INT
: public a_Exp
{
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
{
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
{
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
{
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
{
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_
; }
167 ///////////////////////////////////////////////////////////////////////////////
169 // Interface specification of datatype Exp
171 ///////////////////////////////////////////////////////////////////////////////
173 ///////////////////////////////////////////////////////////////////////////////
175 // Pretty printing methods for Exp
177 ///////////////////////////////////////////////////////////////////////////////
178 std::ostream
& operator << (std::ostream
& strm__
, Exp obj__
);
179 PrettyOStream
& operator << (PrettyOStream
& strm__
, Exp obj__
);
181 ///////////////////////////////////////////////////////////////////////////////
183 // Instantiation of datatype Exp
185 ///////////////////////////////////////////////////////////////////////////////
187 ///////////////////////////////////////////////////////////////////////////////
189 // Pretty printing methods for Exp
191 ///////////////////////////////////////////////////////////////////////////////
192 std::ostream
& operator << (std::ostream
& strm__
, Exp obj__
)
193 { PrettyOStream
S(strm__
); S
<< obj__
; return strm__
; }
195 PrettyOStream
& operator << (PrettyOStream
& strm__
, Exp obj__
)
197 switch (untag(obj__
))
200 strm__
<< _INT(obj__
)->INT
; // int
203 strm__
<< _ADD(obj__
)->_1
; // Exp
205 strm__
<< _ADD(obj__
)->_2
; // Exp
208 strm__
<< _SUB(obj__
)->_1
; // Exp
210 strm__
<< _SUB(obj__
)->_2
; // Exp
213 strm__
<< _MUL(obj__
)->_1
; // Exp
215 strm__
<< _MUL(obj__
)->_2
; // Exp
218 strm__
<< _DIV(obj__
)->_1
; // Exp
220 strm__
<< _DIV(obj__
)->_2
; // Exp
234 class Foo
: public LR1Parser
{
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
251 ////////////////////////////////////////////////////////////////////////////
252 // Semantic value stack
253 ////////////////////////////////////////////////////////////////////////////
254 union Foo_semantic_stack_type
* t__
, * bot__
;
256 int heap_allocated__
;
258 ////////////////////////////////////////////////////////////////////////////
259 // Constructor and parsing method
260 ////////////////////////////////////////////////////////////////////////////
262 virtual void parse();
263 void action_driver(const Rule
);
265 void adjust_stack(int);
266 void grow_semantic_stack();
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,
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,
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 ] = {
300 static const DFATables::ProductionLength Foo_ncount
[ 6 ] = {
303 static const DFATables::ShortSymbol Foo_lhs
[ 6 ] = {
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,
325 ///////////////////////////////////////////////////////////////////////////////
326 // Debugging tables for syntax class Foo
327 ///////////////////////////////////////////////////////////////////////////////
330 static const int Foo_line
[] =
332 21, 22, 23, 24, 25, 0
335 static const char * const Foo_symbolname
[] =
337 "?", "\'(\'", "\')\'", "\'+\'", "\'-\'", "\'*\'", "\'/\'", "???",
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
[] =
360 ///////////////////////////////////////////////////////////////////////////////
361 // Semantic value stack for syntax class Foo
362 ///////////////////////////////////////////////////////////////////////////////
363 union Foo_semantic_stack_type
{
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 ////////////////////////////////////////////////////////////////////////////
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_
] << ' ';
390 ////////////////////////////////////////////////////////////////////////////
391 // Actions for syntax class Foo
392 ////////////////////////////////////////////////////////////////////////////
393 t__
-= Foo_ncount
[_r_
];
400 syn_
._1
.value
= t__
[1+to__
]._3
.value
;
405 syn_
._6
.value
= t__
[1+to__
]._7
.value
+ t__
[2+to__
]._9
.value
;
410 syn_
._11
.value
= t__
[1+to__
]._12
.value
- t__
[2+to__
]._14
.value
;
415 syn_
._16
.value
= t__
[1+to__
]._17
.value
* t__
[2+to__
]._19
.value
;
420 syn_
._21
.value
= t__
[1+to__
]._22
.value
/ t__
[2+to__
]._24
.value
;
424 if (t__
>= bot__
+ stack_size__
) grow_semantic_stack();
428 ///////////////////////////////////////////////////////////////////////////////
429 // Parsing method for parser class Foo
430 ///////////////////////////////////////////////////////////////////////////////
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;
438 LR1ParserDriver
<Foo
,(LR1Parser::State
)9> drv
;
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__
);
456 stack_size__
= N
- 1;
457 heap_allocated__
= 1;
461 : Super(Foo_base
,Foo_check
,Foo_def
,Foo_defact
,Foo_next
,
462 Foo_len
,Foo_ncount
,Foo_lhs
,Foo_equiv
,256,256,258)
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
483 Adaptive matching = disabled
484 Fast string matching = disabled
485 Inline downcasts = disabled
486 --------------------------------------------------------------------------