1 ///////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.3.6),
3 // last updated on Nov 2, 1999.
4 // The original source file is "printing.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #define PROP_STRCMP_USED
8 #define PROP_QUARK_USED
10 ///////////////////////////////////////////////////////////////////////////////
12 ///////////////////////////////////////////////////////////////////////////////
13 static const Quark
_p_r_i_n_t_i_n_gco_c_c_Q1("x_");
14 #line 1 "printing.pcc"
15 ///////////////////////////////////////////////////////////////////////////////
17 // This file implements various pretty printing and formating routines.
19 ///////////////////////////////////////////////////////////////////////////////
23 #include <AD/contain/bitset.h>
24 #include <AD/strings/charesc.h>
25 #include <AD/strings/quark.h>
34 #include "graphtype.h"
36 ///////////////////////////////////////////////////////////////////////////////
38 // Flags controlling printing formats of types.
40 ///////////////////////////////////////////////////////////////////////////////
41 Bool pretty_print_ty
= true;
42 Bool pretty_print_pattern
= false;
43 Bool pretty_print_exp
= false;
44 Bool print_semantic_stack
= false;
45 Bool print_inner_action
= false;
46 Bool print_default_value
= true;
48 Parameter ty_parameter
= TYformal
;
50 ///////////////////////////////////////////////////////////////////////////////
52 // Print an identifier list
54 ///////////////////////////////////////////////////////////////////////////////
55 std::ostream
& operator << (std::ostream
& f
, Ids vars
)
56 { for(Ids vs
= vars
; vs
; vs
= vs
->_2
)
57 { f
<< vs
->_1
; if (vs
->_2
) f
<< ", "; }
61 ///////////////////////////////////////////////////////////////////////////////
65 ///////////////////////////////////////////////////////////////////////////////
66 std::ostream
& operator << (std::ostream
& f
, Scope s
)
68 #line 53 "printing.pcc"
69 #line 57 "printing.pcc"
73 #line 56 "printing.pcc"
76 #line 57 "printing.pcc"
78 case PROTECTEDscope
: {
79 #line 55 "printing.pcc"
82 #line 56 "printing.pcc"
85 #line 54 "printing.pcc"
88 #line 55 "printing.pcc"
92 #line 57 "printing.pcc"
93 #line 57 "printing.pcc"
98 ///////////////////////////////////////////////////////////////////////////////
99 // Return the label for an tuple element index
100 ///////////////////////////////////////////////////////////////////////////////
101 Id
index_of(int i
,Id prefix
)
102 { if (prefix
== 0) prefix
= "";
103 return Quark(Quark(prefix
,"_"),i
);
106 ///////////////////////////////////////////////////////////////////////////////
108 // Print a persistent id.
110 ///////////////////////////////////////////////////////////////////////////////
111 std::ostream
& operator << (std::ostream
& f
, Pid pid
)
113 #line 75 "printing.pcc"
114 #line 78 "printing.pcc"
117 #line 76 "printing.pcc"
119 #line 76 "printing.pcc"
122 #line 78 "printing.pcc"
123 #line 78 "printing.pcc"
128 ///////////////////////////////////////////////////////////////////////////////
132 ///////////////////////////////////////////////////////////////////////////////
133 std::ostream
& operator << (std::ostream
& f
, Literal l
)
135 #line 88 "printing.pcc"
136 #line 109 "printing.pcc"
139 case a_Literal::tag_INTlit
: {
140 #line 89 "printing.pcc"
141 f
<< ((Literal_INTlit
*)l
)->INTlit
;
142 #line 89 "printing.pcc"
144 case a_Literal::tag_BOOLlit
: {
145 #line 90 "printing.pcc"
146 f
<< (((Literal_BOOLlit
*)l
)->BOOLlit
? "true" : "false");
147 #line 90 "printing.pcc"
149 case a_Literal::tag_CHARlit
: {
150 #line 91 "printing.pcc"
151 char b
[32]; print_char(b
,((Literal_CHARlit
*)l
)->CHARlit
); f
<< '\'' << b
<< '\'';
152 #line 91 "printing.pcc"
154 case a_Literal::tag_REALlit
: {
155 #line 93 "printing.pcc"
156 // use sprintf due to library problems in libg++ 2.5.8 on Linux
158 sprintf(buf
,"%lf", ((Literal_REALlit
*)l
)->REALlit
);
160 // ostrstream S(buf,sizeof(buf));
161 // std::ostream& S2 = S;
165 #line 101 "printing.pcc"
167 case a_Literal::tag_STRINGlit
: {
168 #line 102 "printing.pcc"
169 f
<< ((Literal_STRINGlit
*)l
)->STRINGlit
;
170 #line 102 "printing.pcc"
172 case a_Literal::tag_REGEXPlit
: {
173 #line 103 "printing.pcc"
174 f
<< ((Literal_REGEXPlit
*)l
)->REGEXPlit
;
175 #line 103 "printing.pcc"
177 case a_Literal::tag_QUARKlit
: {
178 #line 104 "printing.pcc"
179 if (pretty_print_pattern
) f
<< '#' << ((Literal_QUARKlit
*)l
)->QUARKlit
;
180 else f
<< MatchCompiler::quark_name(((Literal_QUARKlit
*)l
)->QUARKlit
);
182 #line 106 "printing.pcc"
185 #line 107 "printing.pcc"
186 if (pretty_print_pattern
) f
<< "#" << ((Literal_BIGINTlit
*)l
)->BIGINTlit
;
187 else f
<< ((Literal_BIGINTlit
*)l
)->BIGINTlit
;
189 #line 109 "printing.pcc"
193 #line 110 "printing.pcc"
194 #line 110 "printing.pcc"
199 ///////////////////////////////////////////////////////////////////////////////
203 ///////////////////////////////////////////////////////////////////////////////
204 std::ostream
& operator << (std::ostream
& f
, Tys tys
)
205 { for(Tys t
= tys
; t
; t
= t
->_2
) {
208 #line 122 "printing.pcc"
209 #line 122 "printing.pcc"
211 #line 122 "printing.pcc"
212 #line 122 "printing.pcc"
218 ///////////////////////////////////////////////////////////////////////////////
220 // Print type variables (i.e. template actual arguments)
222 ///////////////////////////////////////////////////////////////////////////////
223 void print_tyvars(std::ostream
& f
, Tys tys
, Bool is_datatype
)
225 #line 133 "printing.pcc"
226 #line 133 "printing.pcc"
228 #line 133 "printing.pcc"
229 #line 133 "printing.pcc"
231 if (is_datatype
) f
<< "(" << tys
<< ")";
232 else f
<< '<' << tys
<< "> ";
235 ///////////////////////////////////////////////////////////////////////////////
237 // Print type variables (i.e. formal template arguments)
239 ///////////////////////////////////////////////////////////////////////////////
240 void print_tyvars(std::ostream
& f
, TyVars tyvars
, char open
, char close
, Bool header
)
242 #line 144 "printing.pcc"
243 #line 144 "printing.pcc"
245 #line 144 "printing.pcc"
246 #line 144 "printing.pcc"
248 if (header
) f
<< "template ";
250 for(TyVars t
= tyvars
; t
; t
= t
->_2
) {
251 if (header
) f
<< "class ";
253 if (t
->_2
) f
<< ", ";
256 if (header
) f
<< ' ';
260 ///////////////////////////////////////////////////////////////////////////////
262 // Print a tuple type.
264 ///////////////////////////////////////////////////////////////////////////////
265 void print_tuple(std::ostream
& f
, Tys tys
)
266 { if (pretty_print_ty
) {
267 f
<< '(' << tys
<< ')';
271 for (Tys t
= tys
; t
; t
= t
->_2
) {
275 #line 171 "printing.pcc"
276 #line 171 "printing.pcc"
278 #line 171 "printing.pcc"
279 #line 171 "printing.pcc"
286 ///////////////////////////////////////////////////////////////////////////////
288 // Print a mktuple type
290 ///////////////////////////////////////////////////////////////////////////////
291 void print_mktuple(std::ostream
& f
, Tys tys
)
292 { if (pretty_print_ty
) {
293 f
<< ".[" << tys
<< ']';
295 f
<< "Tuple" << length(tys
);
296 print_tyvars(f
,tys
,false);
300 ///////////////////////////////////////////////////////////////////////////////
302 // Print a record type.
304 ///////////////////////////////////////////////////////////////////////////////
305 void print_record(std::ostream
& f
, Ids labs
, Tys tys
, Bool flex
)
306 { if (! pretty_print_ty
) f
<< "struct ";
309 for (t
= tys
, l
= labs
; t
&& l
; t
= t
->_2
, l
= l
->_2
) {
310 if (pretty_print_ty
) {
311 f
<< l
->_1
<< " : " << t
->_1
;
312 if (t
->_2
) f
<< ", ";
314 ty_id
= l
->_1
; f
<< t
->_1
<< "; ";
316 #line 206 "printing.pcc"
317 #line 206 "printing.pcc"
319 #line 206 "printing.pcc"
320 #line 206 "printing.pcc"
324 if (pretty_print_ty
&& flex
) f
<< " ... ";
328 ///////////////////////////////////////////////////////////////////////////////
330 // Print a function parameter.
332 ///////////////////////////////////////////////////////////////////////////////
333 void print_parameter (std::ostream
& f
, Ty ty
, Id id
, Parameter p
)
334 { Parameter save
= ty_parameter
;
335 Bool sp
= pretty_print_ty
;
336 pretty_print_ty
= false;
339 #line 223 "printing.pcc"
340 #line 269 "printing.pcc"
344 switch (_V1
->tag__
) {
345 case a_Ty::tag_TYCONty
: {
346 if (boxed(((Ty_TYCONty
*)_V1
)->_1
)) {
347 switch (((Ty_TYCONty
*)_V1
)->_1
->tag__
) {
348 case a_TyCon::tag_RECORDtycon
: {
349 #line 241 "printing.pcc"
352 if (p
== TYformal
|| p
== TYsimpleformal
||
353 p
== TYactual
&& ((Ty_TYCONty
*)_V1
)->_2
!=
354 #line 244 "printing.pcc"
355 #line 244 "printing.pcc"
357 #line 244 "printing.pcc"
358 #line 244 "printing.pcc"
360 for (l
= ((TyCon_RECORDtycon
*)((Ty_TYCONty
*)_V1
)->_1
)->_1
, t
= ((Ty_TYCONty
*)_V1
)->_2
; l
&& t
; l
= l
->_2
, t
= t
->_2
) {
363 #line 247 "printing.pcc"
364 #line 247 "printing.pcc"
365 _p_r_i_n_t_i_n_gco_c_c_Q1
366 #line 247 "printing.pcc"
367 #line 247 "printing.pcc"
371 if (p
!= TYactual
) f
<< t
->_1
;
373 if (p
!= TYbody
) { if (t
->_2
) f
<< ", "; }
376 #line 254 "printing.pcc"
377 #line 254 "printing.pcc"
379 #line 254 "printing.pcc"
380 #line 254 "printing.pcc"
383 if (p
== TYformal
|| p
== TYsimpleformal
||
384 p
== TYactual
&& ((Ty_TYCONty
*)_V1
)->_2
!=
385 #line 257 "printing.pcc"
386 #line 257 "printing.pcc"
388 #line 257 "printing.pcc"
389 #line 257 "printing.pcc"
392 #line 258 "printing.pcc"
396 #line 259 "printing.pcc"
397 if (p
!= TYbody
) f
<< '(';
400 #line 261 "printing.pcc"
401 #line 261 "printing.pcc"
402 _p_r_i_n_t_i_n_gco_c_c_Q1
403 #line 261 "printing.pcc"
404 #line 261 "printing.pcc"
408 if (p
!= TYactual
) f
<< _V1
;
410 if (p
== TYbody
) f
<< "; ";
412 if (p
!= TYbody
) f
<< ')';
414 #line 269 "printing.pcc"
418 switch ((int)((Ty_TYCONty
*)_V1
)->_1
) {
419 case ((int)TUPLEtycon
): {
420 #line 225 "printing.pcc"
422 if (p
== TYformal
|| p
== TYsimpleformal
||
423 p
== TYactual
&& ((Ty_TYCONty
*)_V1
)->_2
!=
424 #line 227 "printing.pcc"
425 #line 227 "printing.pcc"
427 #line 227 "printing.pcc"
428 #line 227 "printing.pcc"
430 for (Tys ts
= ((Ty_TYCONty
*)_V1
)->_2
; ts
; ts
= ts
->_2
) {
431 ty_id
= index_of(i
,(p
!= TYbody
? "x" : ""));
432 if (p
!= TYactual
) f
<< ts
->_1
;
434 if (p
!= TYbody
) { if (ts
->_2
) f
<< ", "; }
438 #line 235 "printing.pcc"
439 #line 235 "printing.pcc"
441 #line 235 "printing.pcc"
442 #line 235 "printing.pcc"
445 if (p
== TYformal
|| p
== TYsimpleformal
||
446 p
== TYactual
&& ((Ty_TYCONty
*)_V1
)->_2
!=
447 #line 238 "printing.pcc"
448 #line 238 "printing.pcc"
450 #line 238 "printing.pcc"
451 #line 238 "printing.pcc"
454 #line 239 "printing.pcc"
456 default: { goto L1
; } break;
460 default: { goto L1
; } break;
464 #line 270 "printing.pcc"
465 #line 270 "printing.pcc"
468 pretty_print_ty
= sp
;
471 ///////////////////////////////////////////////////////////////////////////////
473 // Method to print a type expression.
475 ///////////////////////////////////////////////////////////////////////////////
476 std::ostream
& operator << (std::ostream
& f
, Ty ty
)
478 if (ty_id
) { this_id
= ty_id
; ty_id
= 0; }
481 #line 284 "printing.pcc"
482 #line 350 "printing.pcc"
486 case a_Ty::tag_VARty
: {
487 #line 286 "printing.pcc"
489 #line 286 "printing.pcc"
491 case a_Ty::tag_INDty
: {
492 #line 287 "printing.pcc"
493 f
<< ((Ty_INDty
*)ty
)->_1
;
494 #line 287 "printing.pcc"
496 case a_Ty::tag_QUALty
: {
497 #line 331 "printing.pcc"
498 if (((Ty_QUALty
*)ty
)->_1
& QUALunsigned
) f
<< "unsigned ";
499 if (((Ty_QUALty
*)ty
)->_1
& QUALsigned
) f
<< "signed ";
500 if ((ty_parameter
== TYformal
|| ty_parameter
== TYsimpleformal
)
501 && (((Ty_QUALty
*)ty
)->_1
& QUALclass
))
502 f
<< (TYCONty(REFtycon
,
503 #line 335 "printing.pcc"
504 #line 335 "printing.pcc"
505 list_1_(QUALty(QUALconst
,((Ty_QUALty
*)ty
)->_2
))
506 #line 335 "printing.pcc"
507 #line 335 "printing.pcc"
510 f
<< ((Ty_QUALty
*)ty
)->_2
;
511 if (((Ty_QUALty
*)ty
)->_1
& QUALconst
) f
<< " const";
513 #line 339 "printing.pcc"
515 case a_Ty::tag_TYCONty
: {
516 if (boxed(((Ty_TYCONty
*)ty
)->_1
)) {
517 switch (((Ty_TYCONty
*)ty
)->_1
->tag__
) {
518 case a_TyCon::tag_IDtycon
: {
519 #line 300 "printing.pcc"
520 if (options
.new_type_format
&& ((Ty_TYCONty
*)ty
)->_2
!=
521 #line 300 "printing.pcc"
522 #line 300 "printing.pcc"
524 #line 300 "printing.pcc"
525 #line 300 "printing.pcc"
528 #line 301 "printing.pcc"
529 #line 310 "printing.pcc"
531 Ty _V2
= deref_all(ty
);
533 switch (_V2
->tag__
) {
534 case a_Ty::tag_TYCONty
: {
535 if (boxed(((Ty_TYCONty
*)_V2
)->_1
)) {
536 switch (((Ty_TYCONty
*)_V2
)->_1
->tag__
) {
537 case a_TyCon::tag_DATATYPEtycon
: {
538 #line 303 "printing.pcc"
539 if (! pretty_print_ty
) f
<< "a_";
540 f
<< ((TyCon_DATATYPEtycon
*)((Ty_TYCONty
*)_V2
)->_1
)->id
; print_tyvars(f
,((Ty_TYCONty
*)ty
)->_2
,false);
541 if (! pretty_print_ty
)
542 { if (((Ty_TYCONty
*)ty
)->_2
==
543 #line 306 "printing.pcc"
544 #line 306 "printing.pcc"
546 #line 306 "printing.pcc"
547 #line 306 "printing.pcc"
552 #line 309 "printing.pcc"
556 #line 310 "printing.pcc"
557 f
<< ((TyCon_IDtycon
*)((Ty_TYCONty
*)ty
)->_1
)->IDtycon
; print_tyvars(f
,((Ty_TYCONty
*)ty
)->_2
,false);
558 #line 310 "printing.pcc"
563 default: { goto L2
; } break;
567 #line 311 "printing.pcc"
568 #line 311 "printing.pcc"
571 { f
<< ((TyCon_IDtycon
*)((Ty_TYCONty
*)ty
)->_1
)->IDtycon
;
573 #line 314 "printing.pcc"
574 #line 316 "printing.pcc"
576 Ty _V3
= deref_all(ty
);
578 switch (_V3
->tag__
) {
579 case a_Ty::tag_TYCONty
: {
580 if (boxed(((Ty_TYCONty
*)_V3
)->_1
)) {
581 switch (((Ty_TYCONty
*)_V3
)->_1
->tag__
) {
582 case a_TyCon::tag_DATATYPEtycon
: {
583 #line 315 "printing.pcc"
584 print_tyvars(f
,((Ty_TYCONty
*)ty
)->_2
,! pretty_print_ty
);
585 #line 315 "printing.pcc"
589 #line 316 "printing.pcc"
590 print_tyvars(f
,((Ty_TYCONty
*)ty
)->_2
,false);
591 #line 316 "printing.pcc"
596 default: { goto L3
; } break;
600 #line 317 "printing.pcc"
601 #line 317 "printing.pcc"
605 #line 319 "printing.pcc"
607 case a_TyCon::tag_RECORDtycon
: {
608 #line 298 "printing.pcc"
609 print_record(f
,((TyCon_RECORDtycon
*)((Ty_TYCONty
*)ty
)->_1
)->_1
,((Ty_TYCONty
*)ty
)->_2
,((TyCon_RECORDtycon
*)((Ty_TYCONty
*)ty
)->_1
)->_2
);
610 #line 298 "printing.pcc"
612 case a_TyCon::tag_ARRAYtycon
: {
613 if (((Ty_TYCONty
*)ty
)->_2
) {
614 if (((Ty_TYCONty
*)ty
)->_2
->_2
) {
616 #line 350 "printing.pcc"
617 bug ("operator << (std::ostream&, Ty)");
618 #line 350 "printing.pcc"
620 #line 321 "printing.pcc"
621 if (this_id
) { ty_id
= this_id
; this_id
= 0; }
622 f
<< ((Ty_TYCONty
*)ty
)->_2
->_1
<< '[' << ((TyCon_ARRAYtycon
*)((Ty_TYCONty
*)ty
)->_1
)->ARRAYtycon
<< ']';
624 #line 323 "printing.pcc"
628 case a_TyCon::tag_DATATYPEtycon
: {
629 if (((Ty_TYCONty
*)ty
)->_2
) {
630 #line 342 "printing.pcc"
631 if (! pretty_print_ty
) f
<< "a_";
632 f
<< ((TyCon_DATATYPEtycon
*)((Ty_TYCONty
*)ty
)->_1
)->id
; print_tyvars(f
,((Ty_TYCONty
*)ty
)->_2
,false);
633 if (! pretty_print_ty
)
634 { if (((Ty_TYCONty
*)ty
)->_2
==
635 #line 345 "printing.pcc"
636 #line 345 "printing.pcc"
638 #line 345 "printing.pcc"
639 #line 345 "printing.pcc"
644 #line 348 "printing.pcc"
646 #line 340 "printing.pcc"
647 f
<< ((TyCon_DATATYPEtycon
*)((Ty_TYCONty
*)ty
)->_1
)->id
;
648 #line 340 "printing.pcc"
651 case a_TyCon::tag_GRAPHtycon
: {
652 #line 293 "printing.pcc"
653 f
<< ((TyCon_GRAPHtycon
*)((Ty_TYCONty
*)ty
)->_1
)->GRAPHtycon
->class_name
;
654 #line 293 "printing.pcc"
656 case a_TyCon::tag_NODEtycon
: {
657 #line 294 "printing.pcc"
658 f
<< ((TyCon_NODEtycon
*)((Ty_TYCONty
*)ty
)->_1
)->NODEtycon
->graph()->class_name
<<"::"<< ((TyCon_NODEtycon
*)((Ty_TYCONty
*)ty
)->_1
)->NODEtycon
->name();
659 #line 294 "printing.pcc"
661 case a_TyCon::tag_EDGEtycon
: {
662 #line 295 "printing.pcc"
663 f
<< "edge " << ((TyCon_EDGEtycon
*)((Ty_TYCONty
*)ty
)->_1
)->EDGEtycon
->name();
664 #line 295 "printing.pcc"
666 default: { goto L4
; } break;
669 switch ((int)((Ty_TYCONty
*)ty
)->_1
) {
670 case ((int)POINTERtycon
): {
671 if (((Ty_TYCONty
*)ty
)->_2
) {
672 if (((Ty_TYCONty
*)ty
)->_2
->_2
) { goto L4
; } else {
673 #line 290 "printing.pcc"
674 f
<< ((Ty_TYCONty
*)ty
)->_2
->_1
<< " *";
675 #line 290 "printing.pcc"
679 case ((int)REFtycon
): {
680 if (((Ty_TYCONty
*)ty
)->_2
) {
681 if (((Ty_TYCONty
*)ty
)->_2
->_2
) { goto L4
; } else {
682 #line 291 "printing.pcc"
683 f
<< ((Ty_TYCONty
*)ty
)->_2
->_1
<< " &";
684 #line 291 "printing.pcc"
688 case ((int)TUPLEtycon
): {
689 #line 296 "printing.pcc"
690 print_tuple(f
,((Ty_TYCONty
*)ty
)->_2
);
691 #line 296 "printing.pcc"
693 case ((int)EXTUPLEtycon
): {
694 #line 297 "printing.pcc"
695 print_mktuple(f
,((Ty_TYCONty
*)ty
)->_2
);
696 #line 297 "printing.pcc"
698 case ((int)FUNtycon
): {
699 if (((Ty_TYCONty
*)ty
)->_2
) {
700 if (((Ty_TYCONty
*)ty
)->_2
->_2
) {
701 if (((Ty_TYCONty
*)ty
)->_2
->_2
->_2
) { goto L4
; } else {
702 #line 292 "printing.pcc"
703 f
<< ((Ty_TYCONty
*)ty
)->_2
->_1
<< " -> " << ((Ty_TYCONty
*)ty
)->_2
->_2
->_1
;
704 #line 292 "printing.pcc"
710 if (((Ty_TYCONty
*)ty
)->_2
) { goto L4
; } else {
711 #line 289 "printing.pcc"
713 #line 289 "printing.pcc"
719 case a_Ty::tag_POLYty
: {
720 #line 288 "printing.pcc"
721 f
<< ((Ty_POLYty
*)ty
)->_1
;
722 #line 288 "printing.pcc"
724 case a_Ty::tag_DEFVALty
: {
725 #line 325 "printing.pcc"
726 if (this_id
) { ty_id
= this_id
; this_id
= 0; }
727 f
<< ((Ty_DEFVALty
*)ty
)->_1
;
728 if (ty_parameter
!= TYbody
&& ty_parameter
!= TYsimpleformal
729 && print_default_value
) f
<< " = " << ((Ty_DEFVALty
*)ty
)->_2
;
731 #line 329 "printing.pcc"
734 #line 349 "printing.pcc"
735 f
<< ((Ty_NESTEDty
*)ty
)->_1
<< "::" << ((Ty_NESTEDty
*)ty
)->_2
;
736 #line 349 "printing.pcc"
740 #line 285 "printing.pcc"
742 #line 285 "printing.pcc"
745 #line 351 "printing.pcc"
746 #line 351 "printing.pcc"
748 if (this_id
) f
<< ' ' << this_id
;
753 ///////////////////////////////////////////////////////////////////////////////
755 // Method to print a pattern list.
757 ///////////////////////////////////////////////////////////////////////////////
758 void print (std::ostream
& f
, Pats pats
, Id open
, Id close
,
759 Bool flex1
, Pat p
, Bool flex2
= false,
760 Pat len
= NOpat
, Pat array
= NOpat
)
764 if (array
!= NOpat
) f
<< " : " << array
;
767 if (flex2
) f
<< " ... ";
768 for (Pats ps
= pats
; ps
; ps
= ps
->_2
) {
770 if (ps
->_2
) f
<< ", ";
773 #line 376 "printing.pcc"
774 #line 376 "printing.pcc"
776 #line 376 "printing.pcc"
777 #line 376 "printing.pcc"
778 && p
!= NOpat
) f
<< " ... ";
779 if (p
!= NOpat
) f
<< p
;
783 ///////////////////////////////////////////////////////////////////////////////
785 // Method to print a labeled pattern list.
787 ///////////////////////////////////////////////////////////////////////////////
788 void print (std::ostream
& f
, LabPats lab_pats
, Bool flex
)
790 for (LabPats ps
= lab_pats
; ps
; ps
= ps
->_2
) {
791 f
<< ps
->_1
.label
<< " = " << ps
->_1
.pat
;
792 if (ps
->_2
) f
<< ", ";
797 ///////////////////////////////////////////////////////////////////////////////
799 // Methods extract the open and close brace of a list.
801 ///////////////////////////////////////////////////////////////////////////////
804 #line 401 "printing.pcc"
805 #line 406 "printing.pcc"
808 #line 402 "printing.pcc"
810 s
[0] = c
->name
[0]; s
[1] = c
->name
[1]; s
[2] = '\0';
813 #line 405 "printing.pcc"
815 #line 406 "printing.pcc"
817 #line 406 "printing.pcc"
820 #line 407 "printing.pcc"
821 #line 407 "printing.pcc"
827 #line 411 "printing.pcc"
828 #line 413 "printing.pcc"
831 #line 412 "printing.pcc"
833 #line 412 "printing.pcc"
835 #line 413 "printing.pcc"
837 #line 413 "printing.pcc"
840 #line 414 "printing.pcc"
841 #line 414 "printing.pcc"
847 #line 418 "printing.pcc"
848 #line 420 "printing.pcc"
851 #line 419 "printing.pcc"
852 return c
->name
+strlen(c
->name
)-2;
853 #line 419 "printing.pcc"
855 #line 420 "printing.pcc"
857 #line 420 "printing.pcc"
860 #line 421 "printing.pcc"
861 #line 421 "printing.pcc"
865 ///////////////////////////////////////////////////////////////////////////////
867 // Method to print a pattern list.
869 ///////////////////////////////////////////////////////////////////////////////
870 std::ostream
& operator << (std::ostream
& f
, Pats ps
)
871 { print(f
,ps
,"","",false,NOpat
); return f
; }
873 ///////////////////////////////////////////////////////////////////////////////
875 // Method to print a pattern.
877 ///////////////////////////////////////////////////////////////////////////////
878 std::ostream
& operator << (std::ostream
& f
, Pat p
)
880 #line 438 "printing.pcc"
881 #line 486 "printing.pcc"
885 case a_Pat::tag_WILDpat
: {
886 #line 440 "printing.pcc"
888 #line 440 "printing.pcc"
890 case a_Pat::tag_INDpat
: {
891 #line 443 "printing.pcc"
892 f
<< '?' << ((Pat_INDpat
*)p
)->_1
;
893 #line 443 "printing.pcc"
895 case a_Pat::tag_POLYpat
: {
896 if (((Pat_POLYpat
*)p
)->_3
) {
897 #line 468 "printing.pcc"
898 f
<< ((Pat_POLYpat
*)p
)->_1
<< '(' << ((Pat_POLYpat
*)p
)->_3
<< ") = " << ((Pat_POLYpat
*)p
)->_4
;
899 #line 468 "printing.pcc"
901 #line 467 "printing.pcc"
902 f
<< ((Pat_POLYpat
*)p
)->_1
<< " = " << ((Pat_POLYpat
*)p
)->_4
;
903 #line 467 "printing.pcc"
906 case a_Pat::tag_IDpat
: {
907 #line 442 "printing.pcc"
908 f
<< ((Pat_IDpat
*)p
)->_1
;
909 #line 442 "printing.pcc"
911 case a_Pat::tag_CONSpat
: {
912 if (((Pat_CONSpat
*)p
)->CONSpat
) {
913 if (((Pat_CONSpat
*)p
)->CONSpat
->alg_ty
) {
914 switch (((Pat_CONSpat
*)p
)->CONSpat
->alg_ty
->tag__
) {
915 case a_Ty::tag_TYCONty
: {
916 if (boxed(((Ty_TYCONty
*)((Pat_CONSpat
*)p
)->CONSpat
->alg_ty
)->_1
)) {
917 switch (((Ty_TYCONty
*)((Pat_CONSpat
*)p
)->CONSpat
->alg_ty
)->_1
->tag__
) {
918 case a_TyCon::tag_DATATYPEtycon
: {
920 #line 461 "printing.pcc"
921 (((Pat_CONSpat
*)p
)->CONSpat
->qual
& QUALvariable
)
922 #line 461 "printing.pcc"
925 #line 462 "printing.pcc"
926 f
<< ((TyCon_DATATYPEtycon
*)((Ty_TYCONty
*)((Pat_CONSpat
*)p
)->CONSpat
->alg_ty
)->_1
)->id
<< "?";
927 #line 462 "printing.pcc"
931 #line 463 "printing.pcc"
932 f
<< ((Pat_CONSpat
*)p
)->CONSpat
->name
;
933 #line 463 "printing.pcc"
936 default: { goto L5
; } break;
940 default: { goto L5
; } break;
944 #line 464 "printing.pcc"
946 #line 464 "printing.pcc"
949 case a_Pat::tag_APPpat
: {
950 #line 465 "printing.pcc"
951 f
<< ((Pat_APPpat
*)p
)->_1
<< ' ' << ((Pat_APPpat
*)p
)->_2
;
952 #line 465 "printing.pcc"
954 case a_Pat::tag_TYPEDpat
: {
955 #line 445 "printing.pcc"
956 f
<< ((Pat_TYPEDpat
*)p
)->_1
<< " : " << ((Pat_TYPEDpat
*)p
)->_2
;
957 #line 445 "printing.pcc"
959 case a_Pat::tag_ASpat
: {
960 #line 444 "printing.pcc"
961 f
<< ((Pat_ASpat
*)p
)->_1
<< " as " << ((Pat_ASpat
*)p
)->_2
;
962 #line 444 "printing.pcc"
964 case a_Pat::tag_LITERALpat
: {
965 #line 482 "printing.pcc"
966 Bool save
= pretty_print_pattern
;
967 pretty_print_pattern
= true;
968 f
<< ((Pat_LITERALpat
*)p
)->LITERALpat
;
969 pretty_print_pattern
= save
;
971 #line 486 "printing.pcc"
973 case a_Pat::tag_CONTEXTpat
: {
974 #line 474 "printing.pcc"
976 for (Conses ids
= ((Pat_CONTEXTpat
*)p
)->_1
; ids
; ids
= ids
->_2
)
977 { if (ids
->_1
!= NOcons
) f
<< ids
->_1
->name
;
978 if (ids
->_2
) f
<< ", ";
980 f
<< ">>" << ((Pat_CONTEXTpat
*)p
)->_2
;
982 #line 480 "printing.pcc"
984 case a_Pat::tag_LEXEMEpat
: {
985 #line 466 "printing.pcc"
986 f
<< "lexeme class " << ((Pat_LEXEMEpat
*)p
)->_1
;
987 #line 466 "printing.pcc"
989 case a_Pat::tag_ARRAYpat
: {
990 #line 448 "printing.pcc"
991 print(f
,((Pat_ARRAYpat
*)p
)->_1
,"[","]",((Pat_ARRAYpat
*)p
)->_2
,NOpat
);
992 #line 448 "printing.pcc"
994 case a_Pat::tag_TUPLEpat
: {
995 #line 446 "printing.pcc"
996 print(f
,((Pat_TUPLEpat
*)p
)->TUPLEpat
,"(",")",false,NOpat
);
997 #line 446 "printing.pcc"
999 case a_Pat::tag_EXTUPLEpat
: {
1000 #line 447 "printing.pcc"
1001 print(f
,((Pat_EXTUPLEpat
*)p
)->EXTUPLEpat
,".(",")",false,NOpat
);
1002 #line 447 "printing.pcc"
1004 case a_Pat::tag_RECORDpat
: {
1005 #line 449 "printing.pcc"
1006 print(f
,((Pat_RECORDpat
*)p
)->_1
,((Pat_RECORDpat
*)p
)->_2
);
1007 #line 449 "printing.pcc"
1009 case a_Pat::tag_LISTpat
: {
1010 #line 472 "printing.pcc"
1011 print(f
,((Pat_LISTpat
*)p
)->head
,open_of(((Pat_LISTpat
*)p
)->nil
),close_of(((Pat_LISTpat
*)p
)->nil
),true,((Pat_LISTpat
*)p
)->tail
);
1012 #line 472 "printing.pcc"
1014 case a_Pat::tag_VECTORpat
: {
1015 #line 470 "printing.pcc"
1016 print(f
,((Pat_VECTORpat
*)p
)->elements
,open_of(((Pat_VECTORpat
*)p
)->cons
),close_of2(((Pat_VECTORpat
*)p
)->cons
),((Pat_VECTORpat
*)p
)->tail_flex
,NOpat
,((Pat_VECTORpat
*)p
)->head_flex
,((Pat_VECTORpat
*)p
)->len
,((Pat_VECTORpat
*)p
)->array
);
1017 #line 470 "printing.pcc"
1019 case a_Pat::tag_APPENDpat
: {
1020 #line 457 "printing.pcc"
1021 f
<< '(' << ((Pat_APPENDpat
*)p
)->_1
<< " ; " << ((Pat_APPENDpat
*)p
)->_2
<< ')';
1022 #line 457 "printing.pcc"
1024 case a_Pat::tag_GUARDpat
: {
1025 #line 456 "printing.pcc"
1026 f
<< ((Pat_GUARDpat
*)p
)->_1
<< " | " << ((Pat_GUARDpat
*)p
)->_2
;
1027 #line 456 "printing.pcc"
1029 case a_Pat::tag_LOGICALpat
: {
1030 switch (((Pat_LOGICALpat
*)p
)->_1
) {
1032 #line 450 "printing.pcc"
1033 f
<< "(! " << ((Pat_LOGICALpat
*)p
)->_2
<< ")";
1034 #line 450 "printing.pcc"
1037 #line 451 "printing.pcc"
1038 f
<< '(' << ((Pat_LOGICALpat
*)p
)->_2
<< " && " << ((Pat_LOGICALpat
*)p
)->_3
<< ')';
1039 #line 451 "printing.pcc"
1042 #line 452 "printing.pcc"
1043 f
<< '(' << ((Pat_LOGICALpat
*)p
)->_2
<< " || " << ((Pat_LOGICALpat
*)p
)->_3
<< ')';
1044 #line 452 "printing.pcc"
1047 #line 454 "printing.pcc"
1048 f
<< '(' << ((Pat_LOGICALpat
*)p
)->_2
<< " equiv: " << ((Pat_LOGICALpat
*)p
)->_3
<< ')';
1049 #line 454 "printing.pcc"
1052 #line 455 "printing.pcc"
1053 f
<< '(' << ((Pat_LOGICALpat
*)p
)->_2
<< " xor: " << ((Pat_LOGICALpat
*)p
)->_3
<< ')';
1054 #line 455 "printing.pcc"
1057 #line 453 "printing.pcc"
1058 f
<< '(' << ((Pat_LOGICALpat
*)p
)->_2
<< " implies: " << ((Pat_LOGICALpat
*)p
)->_3
<< ')';
1059 #line 453 "printing.pcc"
1063 case a_Pat::tag_BACKEDGEpat
: {
1064 #line 441 "printing.pcc"
1065 f
<< '<' << ((Pat_BACKEDGEpat
*)p
)->_2
<< '>';
1066 #line 441 "printing.pcc"
1068 case a_Pat::tag_UNIFYpat
: {
1069 #line 458 "printing.pcc"
1070 f
<< '(' << ((Pat_UNIFYpat
*)p
)->_1
<< " := " << ((Pat_UNIFYpat
*)p
)->_2
<< ")";
1071 #line 458 "printing.pcc"
1074 #line 459 "printing.pcc"
1075 f
<< ((Pat_MARKEDpat
*)p
)->_2
;
1076 #line 459 "printing.pcc"
1081 #line 487 "printing.pcc"
1082 #line 487 "printing.pcc"
1087 ///////////////////////////////////////////////////////////////////////////////
1089 // Convert a string into a suitable encoding
1091 ///////////////////////////////////////////////////////////////////////////////
1092 void encode_string(char * buf
, const char * s
)
1094 { unsigned char c
= *s
++;
1096 { *buf
++ = 'X'; *buf
++ = 'X';
1097 } else if (isalnum(c
) || c
== '_')
1098 { *buf
++ = '_'; *buf
++ = c
;
1101 int lo
= c
% 16, hi
= c
/ 16;
1109 ///////////////////////////////////////////////////////////////////////////////
1111 // Method to print the mangled name of list constructors.
1113 ///////////////////////////////////////////////////////////////////////////////
1114 #line 518 "printing.pcc"
1115 #line 532 "printing.pcc"
1116 Id
mangle (char const * x_1
);
1117 Id
mangle (char const * x_1
)
1121 #line 518 "printing.pcc"
1123 #line 518 "printing.pcc"
1126 if (_less_string(x_1
,"#{}")) {
1127 if (_less_string(x_1
,"#[]")) {
1128 if (_equal_string(x_1
,"#()")) {
1129 #line 523 "printing.pcc"
1131 #line 523 "printing.pcc"
1133 else if (_equal_string(x_1
,"#(...)")) {
1134 #line 520 "printing.pcc"
1136 #line 520 "printing.pcc"
1138 else if (_equal_string(x_1
,"#[...]")) {
1139 #line 519 "printing.pcc"
1141 #line 519 "printing.pcc"
1144 if ((x_1
[0] == '\"')) {
1146 #line 529 "printing.pcc"
1147 char buf
[256]; encode_string(buf
,x_1
);
1149 #line 530 "printing.pcc"
1152 #line 531 "printing.pcc"
1154 #line 531 "printing.pcc"
1158 if (_equal_string(x_1
,"#[]")) {
1159 #line 522 "printing.pcc"
1161 #line 522 "printing.pcc"
1163 else if (_equal_string(x_1
,"#{...}")) {
1164 #line 521 "printing.pcc"
1166 #line 521 "printing.pcc"
1169 if ((x_1
[0] == '\"')) {
1171 #line 529 "printing.pcc"
1172 char buf
[256]; encode_string(buf
,x_1
);
1174 #line 530 "printing.pcc"
1177 #line 531 "printing.pcc"
1179 #line 531 "printing.pcc"
1184 if (_equal_string(x_1
,"#{}")) {
1185 #line 524 "printing.pcc"
1187 #line 524 "printing.pcc"
1189 else if (_equal_string(x_1
,"(|...|)")) {
1190 #line 526 "printing.pcc"
1192 #line 526 "printing.pcc"
1194 else if (_equal_string(x_1
,"[|...|]")) {
1195 #line 525 "printing.pcc"
1197 #line 525 "printing.pcc"
1199 else if (_equal_string(x_1
,"{|...|}")) {
1200 #line 527 "printing.pcc"
1202 #line 527 "printing.pcc"
1205 if ((x_1
[0] == '\"')) {
1207 #line 529 "printing.pcc"
1208 char buf
[256]; encode_string(buf
,x_1
);
1210 #line 530 "printing.pcc"
1213 #line 531 "printing.pcc"
1215 #line 531 "printing.pcc"
1221 #line 532 "printing.pcc"
1222 #line 532 "printing.pcc"
1225 ///////////////////////////////////////////////////////////////////////////////
1227 // Method to print the name of a constructor
1229 ///////////////////////////////////////////////////////////////////////////////
1230 std::ostream
& print_cons (std::ostream
& f
, Cons cons
)
1232 #line 540 "printing.pcc"
1233 #line 548 "printing.pcc"
1237 switch (cons
->alg_ty
->tag__
) {
1238 case a_Ty::tag_TYCONty
: {
1240 if (boxed(((Ty_TYCONty
*)cons
->alg_ty
)->_1
)) {
1241 switch (((Ty_TYCONty
*)cons
->alg_ty
)->_1
->tag__
) {
1242 case a_TyCon::tag_DATATYPEtycon
: {
1244 #line 543 "printing.pcc"
1245 if (((TyCon_DATATYPEtycon
*)((Ty_TYCONty
*)cons
->alg_ty
)->_1
)->opt
& OPTsubclassless
)
1246 f
<< "a_" << ((TyCon_DATATYPEtycon
*)((Ty_TYCONty
*)cons
->alg_ty
)->_1
)->id
;
1248 f
<< ((TyCon_DATATYPEtycon
*)((Ty_TYCONty
*)cons
->alg_ty
)->_1
)->id
<< "_" << mangle(cons
->name
);
1250 #line 547 "printing.pcc"
1254 #line 548 "printing.pcc"
1255 bug("print_cons()");
1256 #line 548 "printing.pcc"
1262 #line 541 "printing.pcc"
1263 f
<< mangle(cons
->name
);
1264 #line 541 "printing.pcc"
1269 if (cons
->ty
) { goto L7
; } else { goto L8
; }
1275 #line 549 "printing.pcc"
1276 #line 549 "printing.pcc"
1281 ///////////////////////////////////////////////////////////////////////////////
1283 // Method to print an expression list
1285 ///////////////////////////////////////////////////////////////////////////////
1286 std::ostream
& operator << (std::ostream
& f
, Exps es
)
1287 { for (Exps l
= es
; l
; l
= l
->_2
) {
1288 f
<< l
->_1
; if (l
->_2
) f
<< ',';
1293 ///////////////////////////////////////////////////////////////////////////////
1295 // Method to print an expression.
1297 ///////////////////////////////////////////////////////////////////////////////
1298 std::ostream
& operator << (std::ostream
& f
, Exp e
)
1300 #line 571 "printing.pcc"
1301 #line 725 "printing.pcc"
1305 case a_Exp::tag_LITERALexp
: {
1306 #line 577 "printing.pcc"
1307 f
<< ((Exp_LITERALexp
*)e
)->LITERALexp
;
1308 #line 577 "printing.pcc"
1310 case a_Exp::tag_IDexp
: {
1311 #line 573 "printing.pcc"
1312 f
<< ((Exp_IDexp
*)e
)->IDexp
;
1313 #line 573 "printing.pcc"
1315 case a_Exp::tag_RELexp
: {
1317 #line 574 "printing.pcc"
1319 #line 574 "printing.pcc"
1322 #line 574 "printing.pcc"
1324 #line 574 "printing.pcc"
1327 #line 575 "printing.pcc"
1328 f
<< '_' << ((Exp_RELexp
*)e
)->RELexp
;
1329 #line 575 "printing.pcc"
1332 case a_Exp::tag_DOTexp
: {
1333 if (((Exp_DOTexp
*)e
)->_1
) {
1334 switch (((Exp_DOTexp
*)e
)->_1
->tag__
) {
1335 case a_Exp::tag_SELECTORexp
: {
1337 #line 579 "printing.pcc"
1339 #line 579 "printing.pcc"
1342 #line 580 "printing.pcc"
1343 f
<< ((Exp_SELECTORexp
*)((Exp_DOTexp
*)e
)->_1
)->_1
<< '!' << ((Exp_SELECTORexp
*)((Exp_DOTexp
*)e
)->_1
)->_2
->name
<< '.';
1344 int n
= atol(((Exp_DOTexp
*)e
)->_2
+1);
1345 if (n
> 0) f
<< n
; else f
<< ((Exp_DOTexp
*)e
)->_2
;
1347 #line 583 "printing.pcc"
1350 #line 587 "printing.pcc"
1351 f
<< MatchCompiler::make_select(((Exp_SELECTORexp
*)((Exp_DOTexp
*)e
)->_1
)->_1
,((Exp_SELECTORexp
*)((Exp_DOTexp
*)e
)->_1
)->_2
,((Exp_SELECTORexp
*)((Exp_DOTexp
*)e
)->_1
)->_3
,((Exp_DOTexp
*)e
)->_2
);
1352 #line 587 "printing.pcc"
1355 case a_Exp::tag_DEREFexp
: {
1356 #line 589 "printing.pcc"
1357 f
<< ((Exp_DEREFexp
*)((Exp_DOTexp
*)e
)->_1
)->DEREFexp
<< "->" << ((Exp_DOTexp
*)e
)->_2
;
1358 #line 589 "printing.pcc"
1362 #line 590 "printing.pcc"
1363 f
<< ((Exp_DOTexp
*)e
)->_1
<< '.' << ((Exp_DOTexp
*)e
)->_2
;
1364 #line 590 "printing.pcc"
1367 } else { goto L10
; }
1369 case a_Exp::tag_SELECTORexp
: {
1371 #line 584 "printing.pcc"
1373 #line 584 "printing.pcc"
1376 #line 585 "printing.pcc"
1377 f
<< ((Exp_SELECTORexp
*)e
)->_1
<< '!' << ((Exp_SELECTORexp
*)e
)->_2
->name
;
1378 #line 585 "printing.pcc"
1381 #line 588 "printing.pcc"
1382 f
<< MatchCompiler::make_select(((Exp_SELECTORexp
*)e
)->_1
,((Exp_SELECTORexp
*)e
)->_2
,((Exp_SELECTORexp
*)e
)->_3
);
1383 #line 588 "printing.pcc"
1386 case a_Exp::tag_DEREFexp
: {
1387 #line 591 "printing.pcc"
1388 f
<< "(*" << ((Exp_DEREFexp
*)e
)->DEREFexp
<< ')';
1389 #line 591 "printing.pcc"
1391 case a_Exp::tag_ARROWexp
: {
1392 #line 592 "printing.pcc"
1393 f
<< ((Exp_ARROWexp
*)e
)->_1
<< "->" << ((Exp_ARROWexp
*)e
)->_2
;
1394 #line 592 "printing.pcc"
1396 case a_Exp::tag_INDEXexp
: {
1397 #line 594 "printing.pcc"
1398 f
<< ((Exp_INDEXexp
*)e
)->_1
<< '[' << ((Exp_INDEXexp
*)e
)->_2
<< ']';
1399 #line 594 "printing.pcc"
1401 case a_Exp::tag_BINOPexp
: {
1402 #line 595 "printing.pcc"
1403 f
<< '(' << ((Exp_BINOPexp
*)e
)->_2
<< ' ' << ((Exp_BINOPexp
*)e
)->_1
<< ' ' << ((Exp_BINOPexp
*)e
)->_3
<< ')';
1404 #line 595 "printing.pcc"
1406 case a_Exp::tag_PREFIXexp
: {
1407 #line 596 "printing.pcc"
1408 f
<< '(' << ((Exp_PREFIXexp
*)e
)->_1
<< ' ' << ((Exp_PREFIXexp
*)e
)->_2
<< ')';
1409 #line 596 "printing.pcc"
1411 case a_Exp::tag_POSTFIXexp
: {
1412 #line 597 "printing.pcc"
1413 f
<< '(' << ((Exp_POSTFIXexp
*)e
)->_2
<< ' ' << ((Exp_POSTFIXexp
*)e
)->_1
<< ')';
1414 #line 597 "printing.pcc"
1416 case a_Exp::tag_APPexp
: {
1417 #line 593 "printing.pcc"
1418 f
<< ((Exp_APPexp
*)e
)->_1
<< '(' << ((Exp_APPexp
*)e
)->_2
<< ')';
1419 #line 593 "printing.pcc"
1421 case a_Exp::tag_ASSIGNexp
: {
1422 #line 578 "printing.pcc"
1423 f
<< '(' << ((Exp_ASSIGNexp
*)e
)->_1
<< " = " << ((Exp_ASSIGNexp
*)e
)->_2
<< ')';
1424 #line 578 "printing.pcc"
1426 case a_Exp::tag_IFexp
: {
1427 #line 610 "printing.pcc"
1428 f
<< '(' << ((Exp_IFexp
*)e
)->_1
<< " ? " << ((Exp_IFexp
*)e
)->_2
<< " : " << ((Exp_IFexp
*)e
)->_3
<<')';
1429 #line 610 "printing.pcc"
1431 case a_Exp::tag_TUPLEexp
: {
1432 #line 608 "printing.pcc"
1433 f
<< ((Exp_TUPLEexp
*)e
)->TUPLEexp
;
1434 #line 608 "printing.pcc"
1436 case a_Exp::tag_EXTUPLEexp
: {
1437 #line 609 "printing.pcc"
1438 f
<< "mkTuple" << length(((Exp_EXTUPLEexp
*)e
)->EXTUPLEexp
) << '(' << ((Exp_EXTUPLEexp
*)e
)->EXTUPLEexp
<< ')';
1439 #line 609 "printing.pcc"
1441 case a_Exp::tag_RECORDexp
: {
1442 #line 685 "printing.pcc"
1444 for (LabExps l
= ((Exp_RECORDexp
*)e
)->RECORDexp
; l
; l
= l
->_2
) {
1445 f
<< l
->_1
.label
<< " = " << l
->_1
.exp
;
1446 if (l
->_2
) f
<< ", ";
1450 #line 691 "printing.pcc"
1452 case a_Exp::tag_LISTexp
: {
1454 #line 692 "printing.pcc"
1456 #line 692 "printing.pcc"
1459 #line 693 "printing.pcc"
1460 f
<< open_of(((Exp_LISTexp
*)e
)->_2
);
1461 for(Exps exp_list
= ((Exp_LISTexp
*)e
)->_3
; exp_list
; exp_list
= exp_list
->_2
)
1462 { f
<< exp_list
->_1
;
1463 if (exp_list
->_2
) f
<< ", ";
1465 if (((Exp_LISTexp
*)e
)->_4
!= NOexp
)
1466 { f
<< " ... " << ((Exp_LISTexp
*)e
)->_4
; }
1467 f
<< close_of(((Exp_LISTexp
*)e
)->_2
);
1469 #line 701 "printing.pcc"
1472 if (((Exp_LISTexp
*)e
)->_1
) {
1473 if (((Exp_LISTexp
*)e
)->_2
) {
1474 #line 703 "printing.pcc"
1476 for(Exps exp_list
= ((Exp_LISTexp
*)e
)->_3
; exp_list
; exp_list
= exp_list
->_2
)
1477 { Exp exp
= exp_list
->_1
;
1478 f
<< mangle(((Exp_LISTexp
*)e
)->_1
->name
) << '(' << exp
;
1479 if (exp_list
->_2
) f
<< ',';
1482 if (((Exp_LISTexp
*)e
)->_4
!= NOexp
) f
<< ',' << ((Exp_LISTexp
*)e
)->_4
;
1483 else if (((Exp_LISTexp
*)e
)->_3
==
1484 #line 711 "printing.pcc"
1485 #line 711 "printing.pcc"
1487 #line 711 "printing.pcc"
1488 #line 711 "printing.pcc"
1489 ) f
<< mangle(((Exp_LISTexp
*)e
)->_2
->name
);
1490 while (i
-- > 0) f
<< ')';
1492 #line 713 "printing.pcc"
1495 } else { goto L11
; }
1498 case a_Exp::tag_VECTORexp
: {
1499 if (((Exp_VECTORexp
*)e
)->_1
) {
1500 #line 716 "printing.pcc"
1501 f
<< mangle(((Exp_VECTORexp
*)e
)->_1
->name
) << '(';
1502 { for(Exps exps
= ((Exp_VECTORexp
*)e
)->_2
; exps
; exps
= exps
->_2
)
1505 #line 719 "printing.pcc"
1506 #line 719 "printing.pcc"
1508 #line 719 "printing.pcc"
1509 #line 719 "printing.pcc"
1515 #line 723 "printing.pcc"
1518 case a_Exp::tag_CONSexp
: {
1519 if (((Exp_CONSexp
*)e
)->_1
) {
1520 if (((Exp_CONSexp
*)e
)->_3
) {
1521 switch (((Exp_CONSexp
*)e
)->_3
->tag__
) {
1522 case a_Exp::tag_RECORDexp
: {
1523 if (((Exp_CONSexp
*)e
)->_1
->ty
) {
1524 switch (((Exp_CONSexp
*)e
)->_1
->ty
->tag__
) {
1525 case a_Ty::tag_TYCONty
: {
1526 if (boxed(((Ty_TYCONty
*)((Exp_CONSexp
*)e
)->_1
->ty
)->_1
)) {
1527 switch (((Ty_TYCONty
*)((Exp_CONSexp
*)e
)->_1
->ty
)->_1
->tag__
) {
1528 case a_TyCon::tag_RECORDtycon
: {
1529 if (((Exp_CONSexp
*)e
)->_3
) {
1530 switch (((Exp_CONSexp
*)e
)->_3
->tag__
) {
1531 case a_Exp::tag_RECORDexp
: {
1533 #line 632 "printing.pcc"
1534 // rearrange arguments to
1535 if (((Exp_CONSexp
*)e
)->_2
)
1536 { f
<< "new (" << ((Exp_CONSexp
*)e
)->_2
<< ") "; print_cons(f
,((Exp_CONSexp
*)e
)->_1
); }
1538 { f
<< mangle(((Exp_CONSexp
*)e
)->_1
->name
); }
1541 { for_each (LabExp
, i
, ((Exp_RECORDexp
*)((Exp_CONSexp
*)e
)->_3
)->RECORDexp
) {
1542 for_each (Id
, j
, ((TyCon_RECORDtycon
*)((Ty_TYCONty
*)((Exp_CONSexp
*)e
)->_1
->ty
)->_1
)->_1
) if (i
.label
== j
) goto next
;
1543 error ("%Lillegal record label '%s' in expression: %s%e\n",
1544 i
.label
,((Exp_CONSexp
*)e
)->_1
->name
,((Exp_CONSexp
*)e
)->_3
);
1548 { Bool comma
= false;
1550 for(is
= ((TyCon_RECORDtycon
*)((Ty_TYCONty
*)((Exp_CONSexp
*)e
)->_1
->ty
)->_1
)->_1
, ts
= ((Ty_TYCONty
*)((Exp_CONSexp
*)e
)->_1
->ty
)->_2
; is
; is
= is
->_2
, ts
= ts
->_2
) {
1553 for_each (LabExp
, j
, ((Exp_RECORDexp
*)((Exp_CONSexp
*)e
)->_3
)->RECORDexp
) {
1556 error ("%Lduplicated label '%s' in expression: %s%e\n",
1557 j
.label
,((Exp_CONSexp
*)e
)->_1
->name
,((Exp_CONSexp
*)e
)->_3
);
1559 if (comma
) f
<< ", "; comma
= true;
1565 #line 662 "printing.pcc"
1566 #line 665 "printing.pcc"
1568 Exp _V4
= default_val(ts
->_1
);
1570 #line 665 "printing.pcc"
1571 if (comma
) f
<< ", "; comma
= true; f
<< _V4
;
1572 #line 665 "printing.pcc"
1574 #line 663 "printing.pcc"
1575 error ("%Lmissing label '%s' in expression: %s%e\n",
1576 i
, ((Exp_CONSexp
*)e
)->_1
->name
, ((Exp_CONSexp
*)e
)->_3
);
1577 #line 664 "printing.pcc"
1580 #line 666 "printing.pcc"
1581 #line 666 "printing.pcc"
1588 #line 671 "printing.pcc"
1592 #line 673 "printing.pcc"
1593 error("%Lconstructor '%s' doesn't take labeled arguments\n", ((Exp_CONSexp
*)e
)->_1
->name
);
1595 #line 674 "printing.pcc"
1598 } else { goto L13
; }
1600 default: { goto L13
; } break;
1602 } else { goto L13
; }
1604 default: { goto L13
; } break;
1606 } else { goto L13
; }
1610 if (((Exp_CONSexp
*)e
)->_1
->ty
) {
1611 switch (((Exp_CONSexp
*)e
)->_1
->ty
->tag__
) {
1612 case a_Ty::tag_TYCONty
: {
1614 if (boxed(((Ty_TYCONty
*)((Exp_CONSexp
*)e
)->_1
->ty
)->_1
)) {
1615 switch (((Ty_TYCONty
*)((Exp_CONSexp
*)e
)->_1
->ty
)->_1
->tag__
) {
1616 case a_TyCon::tag_RECORDtycon
: {
1618 if (((Exp_CONSexp
*)e
)->_3
) {
1619 switch (((Exp_CONSexp
*)e
)->_3
->tag__
) {
1620 case a_Exp::tag_RECORDexp
: { goto L12
; } break;
1623 #line 678 "printing.pcc"
1624 if (((Exp_CONSexp
*)e
)->_2
)
1625 { f
<< "new (" << ((Exp_CONSexp
*)e
)->_2
<< ") "; print_cons(f
,((Exp_CONSexp
*)e
)->_1
); }
1627 { f
<< mangle(((Exp_CONSexp
*)e
)->_1
->name
); }
1628 f
<< '(' << ((Exp_CONSexp
*)e
)->_3
<< ')';
1630 #line 683 "printing.pcc"
1633 } else { goto L17
; }
1635 default: { goto L17
; } break;
1637 } else { goto L17
; }
1639 default: { goto L17
; } break;
1643 if (((Exp_CONSexp
*)e
)->_3
) { goto L17
; } else {
1645 if (((Exp_CONSexp
*)e
)->_2
) { goto L17
; } else {
1647 #line 676 "printing.pcc"
1648 f
<< mangle(((Exp_CONSexp
*)e
)->_1
->name
);
1649 #line 676 "printing.pcc"
1655 } else { goto L14
; }
1658 #line 725 "printing.pcc"
1659 bug("operator << (std::ostream&, Exp);");
1660 #line 725 "printing.pcc"
1663 case a_Exp::tag_CASTexp
: {
1664 #line 598 "printing.pcc"
1665 Bool save
= pretty_print_ty
;
1666 pretty_print_ty
= false;
1667 f
<< "((" << ((Exp_CASTexp
*)e
)->_1
<< ')' << ((Exp_CASTexp
*)e
)->_2
<< ')';
1668 pretty_print_ty
= save
;
1670 #line 602 "printing.pcc"
1672 case a_Exp::tag_QUALexp
: {
1673 #line 603 "printing.pcc"
1674 f
<< ((Exp_QUALexp
*)e
)->_1
<< "::" << ((Exp_QUALexp
*)e
)->_2
;
1675 #line 603 "printing.pcc"
1677 case a_Exp::tag_EQexp
: {
1678 #line 604 "printing.pcc"
1679 f
<< "equality_of(" << ((Exp_EQexp
*)e
)->_2
<< ',' << ((Exp_EQexp
*)e
)->_3
<< ')';
1680 #line 604 "printing.pcc"
1682 case a_Exp::tag_UNIFYexp
: {
1683 #line 605 "printing.pcc"
1684 f
<< "unify(" << ((Exp_UNIFYexp
*)e
)->_2
<< ',' << ((Exp_UNIFYexp
*)e
)->_3
<< ')';
1685 #line 605 "printing.pcc"
1687 case a_Exp::tag_LTexp
: {
1688 #line 606 "printing.pcc"
1689 f
<< '(' << ((Exp_LTexp
*)e
)->_2
<< " < " << ((Exp_LTexp
*)e
)->_3
<< ')';
1690 #line 606 "printing.pcc"
1692 case a_Exp::tag_HASHexp
: {
1693 #line 607 "printing.pcc"
1694 f
<< "hash(" << ((Exp_HASHexp
*)e
)->_2
<< ')';
1695 #line 607 "printing.pcc"
1697 case a_Exp::tag_THISCOSTexp
: {
1698 #line 628 "printing.pcc"
1700 #line 628 "printing.pcc"
1702 case a_Exp::tag_COSTexp
: {
1703 #line 627 "printing.pcc"
1704 f
<< "t__->kids[" << ((Exp_COSTexp
*)e
)->COSTexp
<< "]->cost";
1705 #line 627 "printing.pcc"
1707 case a_Exp::tag_THISSYNexp
: {
1708 #line 622 "printing.pcc"
1709 if (((Exp_THISSYNexp
*)e
)->_3
)
1712 f
<< "t__->u._" << ((Exp_THISSYNexp
*)e
)->_1
;
1714 #line 626 "printing.pcc"
1716 case a_Exp::tag_SYNexp
: {
1717 #line 612 "printing.pcc"
1718 if (((Exp_SYNexp
*)e
)->_4
)
1719 f
<< '_' << ((Exp_SYNexp
*)e
)->_1
<< "__";
1720 else if (((Exp_SYNexp
*)e
)->_2
< 0) // parser semantic action
1721 { if (((Exp_SYNexp
*)e
)->_1
== 0) f
<< "syn_" << "._" << -((Exp_SYNexp
*)e
)->_2
;
1722 else f
<< "t__[" << ((Exp_SYNexp
*)e
)->_1
<< "+to__]._" << -((Exp_SYNexp
*)e
)->_2
;
1725 f
<< "t__->kids[" << ((Exp_SYNexp
*)e
)->_1
<< "]->u._" << ((Exp_SYNexp
*)e
)->_2
;
1727 #line 620 "printing.pcc"
1729 case a_Exp::tag_MARKEDexp
: {
1730 #line 576 "printing.pcc"
1731 f
<< ((Exp_MARKEDexp
*)e
)->_2
;
1732 #line 576 "printing.pcc"
1734 default: { goto L21
; } break;
1737 #line 572 "printing.pcc"
1739 #line 572 "printing.pcc"
1742 #line 726 "printing.pcc"
1743 #line 726 "printing.pcc"
1748 ///////////////////////////////////////////////////////////////////////////////
1750 // Method to print an inheritance type.
1752 ///////////////////////////////////////////////////////////////////////////////
1753 std::ostream
& operator << (std::ostream
& f
, Inherit i
)
1754 { if (i
->qualifiers
& QUALvirtual
) f
<< "virtual ";
1755 return f
<< i
->scope
<< ' ' << i
->super_class
;
1758 ///////////////////////////////////////////////////////////////////////////////
1760 // Method to print a class inheritance list.
1762 ///////////////////////////////////////////////////////////////////////////////
1763 std::ostream
& operator << (std::ostream
& f
, Inherits i
)
1764 { for ( ;i
; i
= i
->_2
) {
1766 if (i
->_2
) f
<< ", ";
1771 ///////////////////////////////////////////////////////////////////////////////
1773 // Method to print a cost expression
1775 ///////////////////////////////////////////////////////////////////////////////
1776 std::ostream
& operator << (std::ostream
& f
, Cost c
)
1778 #line 759 "printing.pcc"
1779 #line 762 "printing.pcc"
1784 #line 762 "printing.pcc"
1785 f
<< " \\ " << ((Cost_INTcost
*)derefp(c
))->INTcost
;
1786 #line 762 "printing.pcc"
1789 #line 761 "printing.pcc"
1790 f
<< " \\ " << ((Cost_EXPcost
*)c
)->_1
;
1791 #line 761 "printing.pcc"
1795 #line 763 "printing.pcc"
1796 #line 763 "printing.pcc"
1801 ///////////////////////////////////////////////////////////////////////////////
1803 // Method to print a qualified identifier.
1805 ///////////////////////////////////////////////////////////////////////////////
1806 std::ostream
& operator << (std::ostream
& f
, QualId id
)
1808 #line 773 "printing.pcc"
1809 #line 776 "printing.pcc"
1814 #line 775 "printing.pcc"
1815 isalpha(((QualId_SIMPLEid
*)derefp(id
))->SIMPLEid
[0])
1816 #line 775 "printing.pcc"
1819 #line 775 "printing.pcc"
1820 f
<< ((QualId_SIMPLEid
*)derefp(id
))->SIMPLEid
;
1821 #line 775 "printing.pcc"
1824 #line 776 "printing.pcc"
1825 f
<< "operator " << ((QualId_SIMPLEid
*)derefp(id
))->SIMPLEid
;
1826 #line 776 "printing.pcc"
1830 #line 774 "printing.pcc"
1831 f
<< ((QualId_NESTEDid
*)id
)->_1
<< "::" << ((QualId_NESTEDid
*)id
)->_2
;
1832 #line 774 "printing.pcc"
1835 #line 777 "printing.pcc"
1836 #line 777 "printing.pcc"
1841 ///////////////////////////////////////////////////////////////////////////////
1842 // Method to print a pattern match rule.
1843 ///////////////////////////////////////////////////////////////////////////////
1844 std::ostream
& operator << (std::ostream
& f
, MatchRule mr
)
1846 #line 785 "printing.pcc"
1847 #line 794 "printing.pcc"
1849 #line 787 "printing.pcc"
1850 Bool save
= pretty_print_exp
;
1851 pretty_print_exp
= true;
1852 if (mr
->_1
) f
<< mr
->_1
<< " -> ";
1854 if (mr
->_3
!= NOexp
) f
<< " | " << mr
->_3
;
1855 f
<< mr
->_4
<< ": ...";
1856 pretty_print_exp
= save
;
1858 #line 794 "printing.pcc"
1860 #line 795 "printing.pcc"
1861 #line 795 "printing.pcc"
1866 ///////////////////////////////////////////////////////////////////////////////
1868 // Method to pretty print a decision tree.
1870 ///////////////////////////////////////////////////////////////////////////////
1871 std::ostream
& operator << (std::ostream
& f
, Match m
)
1873 #line 805 "printing.pcc"
1874 #line 861 "printing.pcc"
1878 case a_Match::tag_SUCCESSmatch
: {
1879 #line 809 "printing.pcc"
1880 f
<< ((Match_SUCCESSmatch
*)m
)->_1
;
1881 #line 809 "printing.pcc"
1883 case a_Match::tag_SUCCESSESmatch
: {
1884 #line 812 "printing.pcc"
1887 for (int i
= 0; i
< ((Match_SUCCESSESmatch
*)m
)->_1
; i
++)
1888 if ((*((Match_SUCCESSESmatch
*)m
)->_2
)[i
]) {
1889 if (comma
) f
<< ", ";
1895 #line 821 "printing.pcc"
1897 case a_Match::tag_COSTmatch
: {
1898 #line 823 "printing.pcc"
1901 for (int i
= 0; i
< ((Match_COSTmatch
*)m
)->_1
; i
++)
1902 if ((*((Match_COSTmatch
*)m
)->_3
)[i
]) {
1903 if (comma
) f
<< ", ";
1904 f
<< ((Match_COSTmatch
*)m
)->_2
[i
] << " = " << i
;
1909 #line 832 "printing.pcc"
1911 case a_Match::tag_GUARDmatch
: {
1912 #line 810 "printing.pcc"
1913 f
<< ((Match_GUARDmatch
*)m
)->_1
<< '(' << ((Match_GUARDmatch
*)m
)->_2
<< ',' << ((Match_GUARDmatch
*)m
)->_3
<< ')';
1914 #line 810 "printing.pcc"
1916 case a_Match::tag_LITERALmatch
: {
1917 switch (((Match_LITERALmatch
*)m
)->_3
[0]->tag__
) {
1918 case a_Literal::tag_REGEXPlit
: {
1919 #line 838 "printing.pcc"
1921 for (int i
= 0; i
< ((Match_LITERALmatch
*)m
)->_4
; i
++)
1922 { f
<< " {" << i
<< "}" << ((Match_LITERALmatch
*)m
)->_3
[i
] << " => " << ((Match_LITERALmatch
*)m
)->_5
[i
] << ",\n";
1924 f
<< ((Match_LITERALmatch
*)m
)->_6
<< ']';
1926 #line 843 "printing.pcc"
1929 #line 845 "printing.pcc"
1931 for (int i
= 0; i
< ((Match_LITERALmatch
*)m
)->_4
; i
++)
1932 { f
<< ((Match_LITERALmatch
*)m
)->_3
[i
] << ':' << ((Match_LITERALmatch
*)m
)->_5
[i
] << ", "; }
1933 f
<< ((Match_LITERALmatch
*)m
)->_6
<< ']';
1935 #line 849 "printing.pcc"
1939 case a_Match::tag_RANGEmatch
: {
1940 #line 860 "printing.pcc"
1941 f
<< '[' << ((Match_RANGEmatch
*)m
)->_3
<< ".." << ((Match_RANGEmatch
*)m
)->_4
<< ": " << ((Match_RANGEmatch
*)m
)->_5
<< ", " << ((Match_RANGEmatch
*)m
)->_6
<< ']';
1942 #line 860 "printing.pcc"
1944 case a_Match::tag_CONSmatch
: {
1945 if (((Match_CONSmatch
*)m
)->_4
) {
1946 switch (((Match_CONSmatch
*)m
)->_4
->tag__
) {
1947 case a_Ty::tag_TYCONty
: {
1948 if (boxed(((Ty_TYCONty
*)((Match_CONSmatch
*)m
)->_4
)->_1
)) {
1949 switch (((Ty_TYCONty
*)((Match_CONSmatch
*)m
)->_4
)->_1
->tag__
) {
1950 case a_TyCon::tag_DATATYPEtycon
: {
1951 #line 851 "printing.pcc"
1952 f
<< ((TyCon_DATATYPEtycon
*)((Ty_TYCONty
*)((Match_CONSmatch
*)m
)->_4
)->_1
)->id
<< '[';
1953 for (int i
= 0; i
< ((Match_CONSmatch
*)m
)->_5
; i
++) {
1954 f
<< ((Match_CONSmatch
*)m
)->_6
[i
];
1955 if (i
< ((Match_CONSmatch
*)m
)->_5
- 1) f
<< ", ";
1957 if (((TyCon_DATATYPEtycon
*)((Ty_TYCONty
*)((Match_CONSmatch
*)m
)->_4
)->_1
)->qualifiers
& QUALextensible
) f
<< ", " << ((Match_CONSmatch
*)m
)->_7
;
1960 #line 858 "printing.pcc"
1964 #line 861 "printing.pcc"
1965 bug("operator << (std::ostream&, Match);");
1966 #line 861 "printing.pcc"
1969 } else { goto L22
; }
1971 default: { goto L22
; } break;
1973 } else { goto L22
; }
1975 case a_Match::tag_TREECOSTmatch
: {
1976 #line 834 "printing.pcc"
1977 f
<< "TREE{" << *((Match_TREECOSTmatch
*)m
)->_2
<< "} => " << ((Match_TREECOSTmatch
*)m
)->_1
;
1978 #line 834 "printing.pcc"
1980 case a_Match::tag_TREELABELmatch
: {
1981 #line 836 "printing.pcc"
1982 f
<< "LABEL{" << ((Match_TREELABELmatch
*)m
)->_2
<< "(" << ((Match_TREELABELmatch
*)m
)->_4
<< ")} => " << ((Match_TREELABELmatch
*)m
)->_1
;
1983 #line 836 "printing.pcc"
1986 #line 808 "printing.pcc"
1987 f
<< '<' << ((Match_BACKEDGEmatch
*)m
)->_2
<< '>';
1988 #line 808 "printing.pcc"
1994 #line 807 "printing.pcc"
1996 #line 807 "printing.pcc"
1999 #line 806 "printing.pcc"
2001 #line 806 "printing.pcc"
2005 #line 862 "printing.pcc"
2006 #line 862 "printing.pcc"
2010 #line 865 "printing.pcc"
2012 ------------------------------- Statistics -------------------------------
2013 Merge matching rules = yes
2014 Number of DFA nodes merged = 4392
2015 Number of ifs generated = 77
2016 Number of switches generated = 31
2017 Number of labels = 22
2018 Number of gotos = 47
2019 Adaptive matching = enabled
2020 Fast string matching = disabled
2021 Inline downcasts = enabled
2022 --------------------------------------------------------------------------