OSDN Git Service

* gcc.dg/tree-ssa/ssa-dse-10.c: Clean up all dse dump files.
[pf3gnuchains/gcc-fork.git] / gcc / ada / prj-pp.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               P R J . P P                                --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --          Copyright (C) 2001-2007, Free Software Foundation, Inc.         --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 with Ada.Characters.Handling; use Ada.Characters.Handling;
28
29 with Output;   use Output;
30 with Snames;
31
32 package body Prj.PP is
33
34    use Prj.Tree;
35
36    Not_Tested : array (Project_Node_Kind) of Boolean := (others => True);
37
38    Max_Line_Length : constant := 255;
39    --  Maximum length of a line. This is chosen to be compatible with older
40    --  versions of GNAT that had a strict limit on the maximum line length.
41
42    Column : Natural := 0;
43    --  Column number of the last character in the line. Used to avoid
44    --  outputing lines longer than Max_Line_Length.
45
46    First_With_In_List : Boolean := True;
47    --  Indicate that the next with clause is first in a list such as
48    --    with "A", "B";
49    --  First_With_In_List will be True for "A", but not for "B".
50
51    procedure Indicate_Tested (Kind : Project_Node_Kind);
52    --  Set the corresponding component of array Not_Tested to False.
53    --  Only called by pragmas Debug.
54
55    ---------------------
56    -- Indicate_Tested --
57    ---------------------
58
59    procedure Indicate_Tested (Kind : Project_Node_Kind) is
60    begin
61       Not_Tested (Kind) := False;
62    end Indicate_Tested;
63
64    ------------------
65    -- Pretty_Print --
66    ------------------
67
68    procedure Pretty_Print
69      (Project                            : Prj.Tree.Project_Node_Id;
70       In_Tree                            : Prj.Tree.Project_Node_Tree_Ref;
71       Increment                          : Positive      := 3;
72       Eliminate_Empty_Case_Constructions : Boolean       := False;
73       Minimize_Empty_Lines               : Boolean       := False;
74       W_Char                             : Write_Char_Ap := null;
75       W_Eol                              : Write_Eol_Ap  := null;
76       W_Str                              : Write_Str_Ap  := null;
77       Backward_Compatibility             : Boolean)
78    is
79       procedure Print (Node : Project_Node_Id; Indent : Natural);
80       --  A recursive procedure that traverses a project file tree and outputs
81       --  its source. Current_Prj is the project that we are printing. This
82       --  is used when printing attributes, since in nested packages they
83       --  need to use a fully qualified name.
84
85       procedure Output_Attribute_Name (Name : Name_Id);
86       --  Outputs an attribute name, taking into account the value of
87       --  Backward_Compatibility.
88
89       procedure Output_Name (Name : Name_Id; Capitalize : Boolean := True);
90       --  Outputs a name
91
92       procedure Start_Line (Indent : Natural);
93       --  Outputs the indentation at the beginning of the line
94
95       procedure Output_String (S : Name_Id);
96       procedure Output_String (S : Path_Name_Type);
97       --  Outputs a string using the default output procedures
98
99       procedure Write_Empty_Line (Always : Boolean := False);
100       --  Outputs an empty line, only if the previous line was not empty
101       --  already and either Always is True or Minimize_Empty_Lines is False.
102
103       procedure Write_Line (S : String);
104       --  Outputs S followed by a new line
105
106       procedure Write_String (S : String; Truncated : Boolean := False);
107       --  Outputs S using Write_Str, starting a new line if line would
108       --  become too long, when Truncated = False.
109       --  When Truncated = True, only the part of the string that can fit on
110       --  the line is output.
111
112       procedure Write_End_Of_Line_Comment (Node : Project_Node_Id);
113
114       Write_Char : Write_Char_Ap := Output.Write_Char'Access;
115       Write_Eol  : Write_Eol_Ap  := Output.Write_Eol'Access;
116       Write_Str  : Write_Str_Ap  := Output.Write_Str'Access;
117       --  These three access to procedure values are used for the output
118
119       Last_Line_Is_Empty : Boolean := False;
120       --  Used to avoid two consecutive empty lines
121
122       ---------------------------
123       -- Output_Attribute_Name --
124       ---------------------------
125
126       procedure Output_Attribute_Name (Name : Name_Id) is
127       begin
128          if Backward_Compatibility then
129             case Name is
130                when Snames.Name_Spec =>
131                   Output_Name (Snames.Name_Specification);
132
133                when Snames.Name_Spec_Suffix =>
134                   Output_Name (Snames.Name_Specification_Suffix);
135
136                when Snames.Name_Body =>
137                   Output_Name (Snames.Name_Implementation);
138
139                when Snames.Name_Body_Suffix =>
140                   Output_Name (Snames.Name_Implementation_Suffix);
141
142                when others =>
143                   Output_Name (Name);
144             end case;
145
146          else
147             Output_Name (Name);
148          end if;
149       end Output_Attribute_Name;
150
151       -----------------
152       -- Output_Name --
153       -----------------
154
155       procedure Output_Name (Name : Name_Id; Capitalize : Boolean := True) is
156          Capital : Boolean := Capitalize;
157
158       begin
159          Get_Name_String (Name);
160
161          --  If line would become too long, create new line
162
163          if Column + Name_Len > Max_Line_Length then
164             Write_Eol.all;
165             Column := 0;
166          end if;
167
168          for J in 1 .. Name_Len loop
169             if Capital then
170                Write_Char (To_Upper (Name_Buffer (J)));
171             else
172                Write_Char (Name_Buffer (J));
173             end if;
174
175             if Capitalize then
176                Capital :=
177                  Name_Buffer (J) = '_'
178                  or else Is_Digit (Name_Buffer (J));
179             end if;
180          end loop;
181
182          Column := Column + Name_Len;
183       end Output_Name;
184
185       -------------------
186       -- Output_String --
187       -------------------
188
189       procedure Output_String (S : Name_Id) is
190       begin
191          Get_Name_String (S);
192
193          --  If line could become too long, create new line.
194          --  Note that the number of characters on the line could be
195          --  twice the number of character in the string (if every
196          --  character is a '"') plus two (the initial and final '"').
197
198          if Column + Name_Len + Name_Len + 2 > Max_Line_Length then
199             Write_Eol.all;
200             Column := 0;
201          end if;
202
203          Write_Char ('"');
204          Column := Column + 1;
205          Get_Name_String (S);
206
207          for J in 1 .. Name_Len loop
208             if Name_Buffer (J) = '"' then
209                Write_Char ('"');
210                Write_Char ('"');
211                Column := Column + 2;
212             else
213                Write_Char (Name_Buffer (J));
214                Column := Column + 1;
215             end if;
216
217             --  If the string does not fit on one line, cut it in parts
218             --  and concatenate.
219
220             if J < Name_Len and then Column >= Max_Line_Length then
221                Write_Str (""" &");
222                Write_Eol.all;
223                Write_Char ('"');
224                Column := 1;
225             end if;
226          end loop;
227
228          Write_Char ('"');
229          Column := Column + 1;
230       end Output_String;
231
232       procedure Output_String (S : Path_Name_Type) is
233       begin
234          Output_String (Name_Id (S));
235       end Output_String;
236
237       ----------------
238       -- Start_Line --
239       ----------------
240
241       procedure Start_Line (Indent : Natural) is
242       begin
243          if not Minimize_Empty_Lines then
244             Write_Str ((1 .. Indent => ' '));
245             Column := Column + Indent;
246          end if;
247       end Start_Line;
248
249       ----------------------
250       -- Write_Empty_Line --
251       ----------------------
252
253       procedure Write_Empty_Line (Always : Boolean := False) is
254       begin
255          if (Always or else not Minimize_Empty_Lines)
256            and then not Last_Line_Is_Empty then
257             Write_Eol.all;
258             Column := 0;
259             Last_Line_Is_Empty := True;
260          end if;
261       end Write_Empty_Line;
262
263       -------------------------------
264       -- Write_End_Of_Line_Comment --
265       -------------------------------
266
267       procedure Write_End_Of_Line_Comment (Node : Project_Node_Id) is
268          Value : constant Name_Id := End_Of_Line_Comment (Node, In_Tree);
269
270       begin
271          if Value /= No_Name then
272             Write_String (" --");
273             Write_String (Get_Name_String (Value), Truncated => True);
274          end if;
275
276          Write_Line ("");
277       end Write_End_Of_Line_Comment;
278
279       ----------------
280       -- Write_Line --
281       ----------------
282
283       procedure Write_Line (S : String) is
284       begin
285          Write_String (S);
286          Last_Line_Is_Empty := False;
287          Write_Eol.all;
288          Column := 0;
289       end Write_Line;
290
291       ------------------
292       -- Write_String --
293       ------------------
294
295       procedure Write_String (S : String; Truncated : Boolean := False) is
296          Length : Natural := S'Length;
297       begin
298          --  If the string would not fit on the line,
299          --  start a new line.
300
301          if Column + Length > Max_Line_Length then
302             if Truncated then
303                Length := Max_Line_Length - Column;
304
305             else
306                Write_Eol.all;
307                Column := 0;
308             end if;
309          end if;
310
311          Write_Str (S (S'First .. S'First + Length - 1));
312          Column := Column + Length;
313       end Write_String;
314
315       -----------
316       -- Print --
317       -----------
318
319       procedure Print (Node   : Project_Node_Id; Indent : Natural) is
320       begin
321          if Node /= Empty_Node then
322
323             case Kind_Of (Node, In_Tree) is
324
325                when N_Project  =>
326                   pragma Debug (Indicate_Tested (N_Project));
327                   if First_With_Clause_Of (Node, In_Tree) /= Empty_Node then
328
329                      --  with clause(s)
330
331                      First_With_In_List := True;
332                      Print (First_With_Clause_Of (Node, In_Tree), Indent);
333                      Write_Empty_Line (Always => True);
334                   end if;
335
336                   Print (First_Comment_Before (Node, In_Tree), Indent);
337                   Start_Line (Indent);
338                   Write_String ("project ");
339                   Output_Name (Name_Of (Node, In_Tree));
340
341                   --  Check if this project extends another project
342
343                   if Extended_Project_Path_Of (Node, In_Tree) /= No_Path then
344                      Write_String (" extends ");
345
346                      if Is_Extending_All (Node, In_Tree) then
347                         Write_String ("all ");
348                      end if;
349
350                      Output_String (Extended_Project_Path_Of (Node, In_Tree));
351                   end if;
352
353                   Write_String (" is");
354                   Write_End_Of_Line_Comment (Node);
355                   Print
356                     (First_Comment_After (Node, In_Tree), Indent + Increment);
357                   Write_Empty_Line (Always => True);
358
359                   --  Output all of the declarations in the project
360
361                   Print (Project_Declaration_Of (Node, In_Tree), Indent);
362                   Print
363                     (First_Comment_Before_End (Node, In_Tree),
364                      Indent + Increment);
365                   Start_Line (Indent);
366                   Write_String ("end ");
367                   Output_Name (Name_Of (Node, In_Tree));
368                   Write_Line (";");
369                   Print (First_Comment_After_End (Node, In_Tree), Indent);
370
371                when N_With_Clause =>
372                   pragma Debug (Indicate_Tested (N_With_Clause));
373
374                   --  The with clause will sometimes contain an invalid name
375                   --  when we are importing a virtual project from an
376                   --  extending all project. Do not output anything in this
377                   --  case
378
379                   if Name_Of (Node, In_Tree) /= No_Name
380                     and then String_Value_Of (Node, In_Tree) /= No_Name
381                   then
382                      if First_With_In_List then
383                         Print (First_Comment_Before (Node, In_Tree), Indent);
384                         Start_Line (Indent);
385
386                         if Non_Limited_Project_Node_Of (Node, In_Tree) =
387                              Empty_Node
388                         then
389                            Write_String ("limited ");
390                         end if;
391
392                         Write_String ("with ");
393                      end if;
394
395                      Output_String (String_Value_Of (Node, In_Tree));
396
397                      if Is_Not_Last_In_List (Node, In_Tree) then
398                         Write_String (", ");
399                         First_With_In_List := False;
400
401                      else
402                         Write_String (";");
403                         Write_End_Of_Line_Comment (Node);
404                         Print (First_Comment_After (Node, In_Tree), Indent);
405                         First_With_In_List := True;
406                      end if;
407                   end if;
408
409                   Print (Next_With_Clause_Of (Node, In_Tree), Indent);
410
411                when N_Project_Declaration =>
412                   pragma Debug (Indicate_Tested (N_Project_Declaration));
413
414                   if
415                     First_Declarative_Item_Of (Node, In_Tree) /= Empty_Node
416                   then
417                      Print
418                        (First_Declarative_Item_Of (Node, In_Tree),
419                         Indent + Increment);
420                      Write_Empty_Line (Always => True);
421                   end if;
422
423                when N_Declarative_Item =>
424                   pragma Debug (Indicate_Tested (N_Declarative_Item));
425                   Print (Current_Item_Node (Node, In_Tree), Indent);
426                   Print (Next_Declarative_Item (Node, In_Tree), Indent);
427
428                when N_Package_Declaration =>
429                   pragma Debug (Indicate_Tested (N_Package_Declaration));
430                   Write_Empty_Line (Always => True);
431                   Print (First_Comment_Before (Node, In_Tree), Indent);
432                   Start_Line (Indent);
433                   Write_String ("package ");
434                   Output_Name (Name_Of (Node, In_Tree));
435
436                   if Project_Of_Renamed_Package_Of (Node, In_Tree) /=
437                        Empty_Node
438                   then
439                      Write_String (" renames ");
440                      Output_Name
441                        (Name_Of
442                           (Project_Of_Renamed_Package_Of (Node, In_Tree),
443                            In_Tree));
444                      Write_String (".");
445                      Output_Name (Name_Of (Node, In_Tree));
446                      Write_String (";");
447                      Write_End_Of_Line_Comment (Node);
448                      Print (First_Comment_After_End (Node, In_Tree), Indent);
449
450                   else
451                      Write_String (" is");
452                      Write_End_Of_Line_Comment (Node);
453                      Print (First_Comment_After (Node, In_Tree),
454                             Indent + Increment);
455
456                      if First_Declarative_Item_Of (Node, In_Tree) /=
457                           Empty_Node
458                      then
459                         Print
460                           (First_Declarative_Item_Of (Node, In_Tree),
461                            Indent + Increment);
462                      end if;
463
464                      Print (First_Comment_Before_End (Node, In_Tree),
465                             Indent + Increment);
466                      Start_Line (Indent);
467                      Write_String ("end ");
468                      Output_Name (Name_Of (Node, In_Tree));
469                      Write_Line (";");
470                      Print (First_Comment_After_End (Node, In_Tree), Indent);
471                      Write_Empty_Line;
472                   end if;
473
474                when N_String_Type_Declaration =>
475                   pragma Debug (Indicate_Tested (N_String_Type_Declaration));
476                   Print (First_Comment_Before (Node, In_Tree), Indent);
477                   Start_Line (Indent);
478                   Write_String ("type ");
479                   Output_Name (Name_Of (Node, In_Tree));
480                   Write_Line (" is");
481                   Start_Line (Indent + Increment);
482                   Write_String ("(");
483
484                   declare
485                      String_Node : Project_Node_Id :=
486                        First_Literal_String (Node, In_Tree);
487
488                   begin
489                      while String_Node /= Empty_Node loop
490                         Output_String (String_Value_Of (String_Node, In_Tree));
491                         String_Node :=
492                           Next_Literal_String (String_Node, In_Tree);
493
494                         if String_Node /= Empty_Node then
495                            Write_String (", ");
496                         end if;
497                      end loop;
498                   end;
499
500                   Write_String (");");
501                   Write_End_Of_Line_Comment (Node);
502                   Print (First_Comment_After (Node, In_Tree), Indent);
503
504                when N_Literal_String =>
505                   pragma Debug (Indicate_Tested (N_Literal_String));
506                   Output_String (String_Value_Of (Node, In_Tree));
507
508                   if Source_Index_Of (Node, In_Tree) /= 0 then
509                      Write_String (" at ");
510                      Write_String (Source_Index_Of (Node, In_Tree)'Img);
511                   end if;
512
513                when N_Attribute_Declaration =>
514                   pragma Debug (Indicate_Tested (N_Attribute_Declaration));
515                   Print (First_Comment_Before (Node, In_Tree), Indent);
516                   Start_Line (Indent);
517                   Write_String ("for ");
518                   Output_Attribute_Name (Name_Of (Node, In_Tree));
519
520                   if Associative_Array_Index_Of (Node, In_Tree) /= No_Name then
521                      Write_String (" (");
522                      Output_String
523                        (Associative_Array_Index_Of (Node, In_Tree));
524
525                      if Source_Index_Of (Node, In_Tree) /= 0 then
526                         Write_String (" at ");
527                         Write_String (Source_Index_Of (Node, In_Tree)'Img);
528                      end if;
529
530                      Write_String (")");
531                   end if;
532
533                   Write_String (" use ");
534                   Print (Expression_Of (Node, In_Tree), Indent);
535                   Write_String (";");
536                   Write_End_Of_Line_Comment (Node);
537                   Print (First_Comment_After (Node, In_Tree), Indent);
538
539                when N_Typed_Variable_Declaration =>
540                   pragma Debug
541                     (Indicate_Tested (N_Typed_Variable_Declaration));
542                   Print (First_Comment_Before (Node, In_Tree), Indent);
543                   Start_Line (Indent);
544                   Output_Name (Name_Of (Node, In_Tree));
545                   Write_String (" : ");
546                   Output_Name
547                     (Name_Of (String_Type_Of (Node, In_Tree), In_Tree));
548                   Write_String (" := ");
549                   Print (Expression_Of (Node, In_Tree), Indent);
550                   Write_String (";");
551                   Write_End_Of_Line_Comment (Node);
552                   Print (First_Comment_After (Node, In_Tree), Indent);
553
554                when N_Variable_Declaration =>
555                   pragma Debug (Indicate_Tested (N_Variable_Declaration));
556                   Print (First_Comment_Before (Node, In_Tree), Indent);
557                   Start_Line (Indent);
558                   Output_Name (Name_Of (Node, In_Tree));
559                   Write_String (" := ");
560                   Print (Expression_Of (Node, In_Tree), Indent);
561                   Write_String (";");
562                   Write_End_Of_Line_Comment (Node);
563                   Print (First_Comment_After (Node, In_Tree), Indent);
564
565                when N_Expression =>
566                   pragma Debug (Indicate_Tested (N_Expression));
567                   declare
568                      Term : Project_Node_Id := First_Term (Node, In_Tree);
569
570                   begin
571                      while Term /= Empty_Node loop
572                         Print (Term, Indent);
573                         Term := Next_Term (Term, In_Tree);
574
575                         if Term /= Empty_Node then
576                            Write_String (" & ");
577                         end if;
578                      end loop;
579                   end;
580
581                when N_Term =>
582                   pragma Debug (Indicate_Tested (N_Term));
583                   Print (Current_Term (Node, In_Tree), Indent);
584
585                when N_Literal_String_List =>
586                   pragma Debug (Indicate_Tested (N_Literal_String_List));
587                   Write_String ("(");
588
589                   declare
590                      Expression : Project_Node_Id :=
591                        First_Expression_In_List (Node, In_Tree);
592
593                   begin
594                      while Expression /= Empty_Node loop
595                         Print (Expression, Indent);
596                         Expression :=
597                           Next_Expression_In_List (Expression, In_Tree);
598
599                         if Expression /= Empty_Node then
600                            Write_String (", ");
601                         end if;
602                      end loop;
603                   end;
604
605                   Write_String (")");
606
607                when N_Variable_Reference =>
608                   pragma Debug (Indicate_Tested (N_Variable_Reference));
609                   if Project_Node_Of (Node, In_Tree) /= Empty_Node then
610                      Output_Name
611                        (Name_Of (Project_Node_Of (Node, In_Tree), In_Tree));
612                      Write_String (".");
613                   end if;
614
615                   if Package_Node_Of (Node, In_Tree) /= Empty_Node then
616                      Output_Name
617                        (Name_Of (Package_Node_Of (Node, In_Tree), In_Tree));
618                      Write_String (".");
619                   end if;
620
621                   Output_Name (Name_Of (Node, In_Tree));
622
623                when N_External_Value =>
624                   pragma Debug (Indicate_Tested (N_External_Value));
625                   Write_String ("external (");
626                   Print (External_Reference_Of (Node, In_Tree), Indent);
627
628                   if External_Default_Of (Node, In_Tree) /= Empty_Node then
629                      Write_String (", ");
630                      Print (External_Default_Of (Node, In_Tree), Indent);
631                   end if;
632
633                   Write_String (")");
634
635                when N_Attribute_Reference =>
636                   pragma Debug (Indicate_Tested (N_Attribute_Reference));
637
638                   if Project_Node_Of (Node, In_Tree) /= Empty_Node
639                     and then Project_Node_Of (Node, In_Tree) /= Project
640                   then
641                      Output_Name
642                        (Name_Of (Project_Node_Of (Node, In_Tree), In_Tree));
643
644                      if Package_Node_Of (Node, In_Tree) /= Empty_Node then
645                         Write_String (".");
646                         Output_Name
647                           (Name_Of (Package_Node_Of (Node, In_Tree), In_Tree));
648                      end if;
649
650                   elsif Package_Node_Of (Node, In_Tree) /= Empty_Node then
651                      Output_Name
652                        (Name_Of (Package_Node_Of (Node, In_Tree), In_Tree));
653
654                   else
655                      Write_String ("project");
656                   end if;
657
658                   Write_String ("'");
659                   Output_Attribute_Name (Name_Of (Node, In_Tree));
660
661                   declare
662                      Index : constant Name_Id :=
663                                Associative_Array_Index_Of (Node, In_Tree);
664
665                   begin
666                      if Index /= No_Name then
667                         Write_String (" (");
668                         Output_String (Index);
669                         Write_String (")");
670                      end if;
671                   end;
672
673                when N_Case_Construction =>
674                   pragma Debug (Indicate_Tested (N_Case_Construction));
675
676                   declare
677                      Case_Item    : Project_Node_Id;
678                      Is_Non_Empty : Boolean := False;
679
680                   begin
681                      Case_Item := First_Case_Item_Of (Node, In_Tree);
682                      while Case_Item /= Empty_Node loop
683                         if First_Declarative_Item_Of (Case_Item, In_Tree) /=
684                              Empty_Node
685                           or else not Eliminate_Empty_Case_Constructions
686                         then
687                            Is_Non_Empty := True;
688                            exit;
689                         end if;
690
691                         Case_Item := Next_Case_Item (Case_Item, In_Tree);
692                      end loop;
693
694                      if Is_Non_Empty then
695                         Write_Empty_Line;
696                         Print (First_Comment_Before (Node, In_Tree), Indent);
697                         Start_Line (Indent);
698                         Write_String ("case ");
699                         Print
700                           (Case_Variable_Reference_Of (Node, In_Tree),
701                            Indent);
702                         Write_String (" is");
703                         Write_End_Of_Line_Comment (Node);
704                         Print
705                           (First_Comment_After (Node, In_Tree),
706                            Indent + Increment);
707
708                         declare
709                            Case_Item : Project_Node_Id :=
710                                          First_Case_Item_Of (Node, In_Tree);
711                         begin
712                            while Case_Item /= Empty_Node loop
713                               pragma Assert
714                                 (Kind_Of (Case_Item, In_Tree) = N_Case_Item);
715                               Print (Case_Item, Indent + Increment);
716                               Case_Item :=
717                                 Next_Case_Item (Case_Item, In_Tree);
718                            end loop;
719                         end;
720
721                         Print (First_Comment_Before_End (Node, In_Tree),
722                                Indent + Increment);
723                         Start_Line (Indent);
724                         Write_Line ("end case;");
725                         Print
726                           (First_Comment_After_End (Node, In_Tree), Indent);
727                      end if;
728                   end;
729
730                when N_Case_Item =>
731                   pragma Debug (Indicate_Tested (N_Case_Item));
732
733                   if First_Declarative_Item_Of (Node, In_Tree) /= Empty_Node
734                     or else not Eliminate_Empty_Case_Constructions
735                   then
736                      Write_Empty_Line;
737                      Print (First_Comment_Before (Node, In_Tree), Indent);
738                      Start_Line (Indent);
739                      Write_String ("when ");
740
741                      if First_Choice_Of (Node, In_Tree) = Empty_Node then
742                         Write_String ("others");
743
744                      else
745                         declare
746                            Label : Project_Node_Id :=
747                                      First_Choice_Of (Node, In_Tree);
748                         begin
749                            while Label /= Empty_Node loop
750                               Print (Label, Indent);
751                               Label := Next_Literal_String (Label, In_Tree);
752
753                               if Label /= Empty_Node then
754                                  Write_String (" | ");
755                               end if;
756                            end loop;
757                         end;
758                      end if;
759
760                      Write_String (" =>");
761                      Write_End_Of_Line_Comment (Node);
762                      Print
763                        (First_Comment_After (Node, In_Tree),
764                         Indent + Increment);
765
766                      declare
767                         First : constant Project_Node_Id :=
768                                   First_Declarative_Item_Of (Node, In_Tree);
769                      begin
770                         if First = Empty_Node then
771                            Write_Empty_Line;
772                         else
773                            Print (First, Indent + Increment);
774                         end if;
775                      end;
776                   end if;
777
778                when N_Comment_Zones =>
779
780                --  Nothing to do, because it will not be processed directly
781
782                   null;
783
784                when N_Comment =>
785                   pragma Debug (Indicate_Tested (N_Comment));
786
787                   if Follows_Empty_Line (Node, In_Tree) then
788                      Write_Empty_Line;
789                   end if;
790
791                   Start_Line (Indent);
792                   Write_String ("--");
793                   Write_String
794                     (Get_Name_String (String_Value_Of (Node, In_Tree)),
795                      Truncated => True);
796                   Write_Line ("");
797
798                   if Is_Followed_By_Empty_Line (Node, In_Tree) then
799                      Write_Empty_Line;
800                   end if;
801
802                   Print (Next_Comment (Node, In_Tree), Indent);
803             end case;
804          end if;
805       end Print;
806
807    --  Start of processing for Pretty_Print
808
809    begin
810       if W_Char = null then
811          Write_Char := Output.Write_Char'Access;
812       else
813          Write_Char := W_Char;
814       end if;
815
816       if W_Eol = null then
817          Write_Eol := Output.Write_Eol'Access;
818       else
819          Write_Eol := W_Eol;
820       end if;
821
822       if W_Str = null then
823          Write_Str := Output.Write_Str'Access;
824       else
825          Write_Str := W_Str;
826       end if;
827
828       Print (Project, 0);
829
830       if W_Char = null or else W_Str = null then
831          Output.Write_Eol;
832       end if;
833    end Pretty_Print;
834
835    -----------------------
836    -- Output_Statistics --
837    -----------------------
838
839    procedure Output_Statistics is
840    begin
841       Output.Write_Line ("Project_Node_Kinds not tested:");
842
843       for Kind in Project_Node_Kind loop
844          if Kind /= N_Comment_Zones and then Not_Tested (Kind) then
845             Output.Write_Str ("   ");
846             Output.Write_Line (Project_Node_Kind'Image (Kind));
847          end if;
848       end loop;
849
850       Output.Write_Eol;
851    end Output_Statistics;
852
853 end Prj.PP;