OSDN Git Service

* Make-lang.in (gnat_ug_unx.info): Add dependency on stmp-docobjdir.
[pf3gnuchains/gcc-fork.git] / gcc / ada / sprint.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               S P R I N T                                --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2002, 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,  59 Temple Place - Suite 330,  Boston, --
20 -- MA 02111-1307, 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 Atree;    use Atree;
28 with Casing;   use Casing;
29 with Csets;    use Csets;
30 with Debug;    use Debug;
31 with Einfo;    use Einfo;
32 with Lib;      use Lib;
33 with Namet;    use Namet;
34 with Nlists;   use Nlists;
35 with Opt;      use Opt;
36 with Output;   use Output;
37 with Rtsfind;  use Rtsfind;
38 with Sinfo;    use Sinfo;
39 with Sinput;   use Sinput;
40 with Sinput.D; use Sinput.D;
41 with Snames;   use Snames;
42 with Stand;    use Stand;
43 with Stringt;  use Stringt;
44 with Uintp;    use Uintp;
45 with Uname;    use Uname;
46 with Urealp;   use Urealp;
47
48 package body Sprint is
49
50    Debug_Node : Node_Id := Empty;
51    --  If we are in Debug_Generated_Code mode, then this location is set
52    --  to the current node requiring Sloc fixup, until Set_Debug_Sloc is
53    --  called to set the proper value. The call clears it back to Empty.
54
55    Debug_Sloc : Source_Ptr;
56    --  Sloc of first byte of line currently being written if we are
57    --  generating a source debug file.
58
59    Dump_Original_Only : Boolean;
60    --  Set True if the -gnatdo (dump original tree) flag is set
61
62    Dump_Generated_Only : Boolean;
63    --  Set True if the -gnatG (dump generated tree) debug flag is set
64    --  or for Print_Generated_Code (-gnatG) or Dump_Gnerated_Code (-gnatD).
65
66    Dump_Freeze_Null : Boolean;
67    --  Set True if freeze nodes and non-source null statements output
68
69    Indent : Int := 0;
70    --  Number of columns for current line output indentation
71
72    Indent_Annull_Flag : Boolean := False;
73    --  Set True if subsequent Write_Indent call to be ignored, gets reset
74    --  by this call, so it is only active to suppress a single indent call.
75
76    Line_Limit : constant := 72;
77    --  Limit value for chopping long lines
78
79    Freeze_Indent : Int := 0;
80    --  Keep track of freeze indent level (controls blank lines before
81    --  procedures within expression freeze actions)
82
83    -------------------------------
84    -- Operator Precedence Table --
85    -------------------------------
86
87    --  This table is used to decide whether a subexpression needs to be
88    --  parenthesized. The rule is that if an operand of an operator (which
89    --  for this purpose includes AND THEN and OR ELSE) is itself an operator
90    --  with a lower precedence than the operator (or equal precedence if
91    --  appearing as the right operand), then parentheses are required.
92
93    Op_Prec : array (N_Subexpr) of Short_Short_Integer :=
94                (N_Op_And          => 1,
95                 N_Op_Or           => 1,
96                 N_Op_Xor          => 1,
97                 N_And_Then        => 1,
98                 N_Or_Else         => 1,
99
100                 N_In              => 2,
101                 N_Not_In          => 2,
102                 N_Op_Eq           => 2,
103                 N_Op_Ge           => 2,
104                 N_Op_Gt           => 2,
105                 N_Op_Le           => 2,
106                 N_Op_Lt           => 2,
107                 N_Op_Ne           => 2,
108
109                 N_Op_Add          => 3,
110                 N_Op_Concat       => 3,
111                 N_Op_Subtract     => 3,
112                 N_Op_Plus         => 3,
113                 N_Op_Minus        => 3,
114
115                 N_Op_Divide       => 4,
116                 N_Op_Mod          => 4,
117                 N_Op_Rem          => 4,
118                 N_Op_Multiply     => 4,
119
120                 N_Op_Expon        => 5,
121                 N_Op_Abs          => 5,
122                 N_Op_Not          => 5,
123
124                 others            => 6);
125
126    procedure Sprint_Left_Opnd (N : Node_Id);
127    --  Print left operand of operator, parenthesizing if necessary
128
129    procedure Sprint_Right_Opnd (N : Node_Id);
130    --  Print right operand of operator, parenthesizing if necessary
131
132    -----------------------
133    -- Local Subprograms --
134    -----------------------
135
136    procedure Col_Check (N : Nat);
137    --  Check that at least N characters remain on current line, and if not,
138    --  then start an extra line with two characters extra indentation for
139    --  continuing text on the next line.
140
141    procedure Indent_Annull;
142    --  Causes following call to Write_Indent to be ignored. This is used when
143    --  a higher level node wants to stop a lower level node from starting a
144    --  new line, when it would otherwise be inclined to do so (e.g. the case
145    --  of an accept statement called from an accept alternative with a guard)
146
147    procedure Indent_Begin;
148    --  Increase indentation level
149
150    procedure Indent_End;
151    --  Decrease indentation level
152
153    procedure Print_Debug_Line (S : String);
154    --  Used to print output lines in Debug_Generated_Code mode (this is used
155    --  as the argument for a call to Set_Special_Output in package Output).
156
157    procedure Process_TFAI_RR_Flags (Nod : Node_Id);
158    --  Given a divide, multiplication or division node, check the flags
159    --  Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
160    --  appropriate special syntax characters (# and @).
161
162    procedure Set_Debug_Sloc;
163    --  If Debug_Node is non-empty, this routine sets the appropriate value
164    --  in its Sloc field, from the current location in the debug source file
165    --  that is currently being written. Note that Debug_Node is always empty
166    --  if a debug source file is not being written.
167
168    procedure Sprint_Bar_List (List : List_Id);
169    --  Print the given list with items separated by vertical bars
170
171    procedure Sprint_Node_Actual (Node : Node_Id);
172    --  This routine prints its node argument. It is a lower level routine than
173    --  Sprint_Node, in that it does not bother about rewritten trees.
174
175    procedure Sprint_Node_Sloc (Node : Node_Id);
176    --  Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
177    --  sets the Sloc of the current debug node to be a copy of the Sloc
178    --  of the sprinted node Node. Note that this is done after printing
179    --  Node, so that the Sloc is the proper updated value for the debug file.
180
181    procedure Write_Char_Sloc (C : Character);
182    --  Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
183    --  called to ensure that the current node has a proper Sloc set.
184
185    procedure Write_Condition_And_Reason (Node : Node_Id);
186    --  Write Condition and Reason codes of Raise_xxx_Error node
187
188    procedure Write_Discr_Specs (N : Node_Id);
189    --  Output discriminant specification for node, which is any of the type
190    --  declarations that can have discriminants.
191
192    procedure Write_Ekind (E : Entity_Id);
193    --  Write the String corresponding to the Ekind without "E_".
194
195    procedure Write_Id (N : Node_Id);
196    --  N is a node with a Chars field. This procedure writes the name that
197    --  will be used in the generated code associated with the name. For a
198    --  node with no associated entity, this is simply the Chars field. For
199    --  the case where there is an entity associated with the node, we print
200    --  the name associated with the entity (since it may have been encoded).
201    --  One other special case is that an entity has an active external name
202    --  (i.e. an external name present with no address clause), then this
203    --  external name is output.
204
205    function Write_Identifiers (Node : Node_Id) return Boolean;
206    --  Handle node where the grammar has a list of defining identifiers, but
207    --  the tree has a separate declaration for each identifier. Handles the
208    --  printing of the defining identifier, and returns True if the type and
209    --  initialization information is to be printed, False if it is to be
210    --  skipped (the latter case happens when printing defining identifiers
211    --  other than the first in the original tree output case).
212
213    procedure Write_Implicit_Def (E : Entity_Id);
214    pragma Warnings (Off, Write_Implicit_Def);
215    --  Write the definition of the implicit type E according to its Ekind
216    --  For now a debugging procedure, but might be used in the future.
217
218    procedure Write_Indent;
219    --  Start a new line and write indentation spacing
220
221    function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
222    --  Like Write_Identifiers except that each new printed declaration
223    --  is at the start of a new line.
224
225    function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
226    --  Like Write_Indent_Identifiers except that in Debug_Generated_Code
227    --  mode, the Sloc of the current debug node is set to point ot the
228    --  first output identifier.
229
230    procedure Write_Indent_Str (S : String);
231    --  Start a new line and write indent spacing followed by given string
232
233    procedure Write_Indent_Str_Sloc (S : String);
234    --  Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
235    --  the Sloc of the current node is set to the first non-blank character
236    --  in the string S.
237
238    procedure Write_Name_With_Col_Check (N : Name_Id);
239    --  Write name (using Write_Name) with initial column check, and possible
240    --  initial Write_Indent (to get new line) if current line is too full.
241
242    procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
243    --  Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
244    --  mode, sets Sloc of current debug node to first character of name.
245
246    procedure Write_Operator (N : Node_Id; S : String);
247    --  Like Write_Str_Sloc, used for operators, encloses the string in
248    --  characters {} if the Do_Overflow flag is set on the node N.
249
250    procedure Write_Param_Specs (N : Node_Id);
251    --  Output parameter specifications for node (which is either a function
252    --  or procedure specification with a Parameter_Specifications field)
253
254    procedure Write_Rewrite_Str (S : String);
255    --  Writes out a string (typically containing <<< or >>>}) for a node
256    --  created by rewriting the tree. Suppressed if we are outputting the
257    --  generated code only, since in this case we don't specially mark nodes
258    --  created by rewriting).
259
260    procedure Write_Str_Sloc (S : String);
261    --  Like Write_Str, but sets debug Sloc of current debug node to first
262    --  non-blank character if a current debug node is active.
263
264    procedure Write_Str_With_Col_Check (S : String);
265    --  Write string (using Write_Str) with initial column check, and possible
266    --  initial Write_Indent (to get new line) if current line is too full.
267
268    procedure Write_Str_With_Col_Check_Sloc (S : String);
269    --  Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
270    --  node to first non-blank character if a current debug node is active.
271
272    procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
273    --  Write Uint (using UI_Write) with initial column check, and possible
274    --  initial Write_Indent (to get new line) if current line is too full.
275    --  The format parameter determines the output format (see UI_Write).
276    --  In addition, in Debug_Generated_Code mode, sets the current node
277    --  Sloc to the first character of the output value.
278
279    procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
280    --  Write Ureal (using same output format as UR_Write) with column checks
281    --  and a possible initial Write_Indent (to get new line) if current line
282    --  is too full. In addition, in Debug_Generated_Code mode, sets the
283    --  current node Sloc to the first character of the output value.
284
285    ---------------
286    -- Col_Check --
287    ---------------
288
289    procedure Col_Check (N : Nat) is
290    begin
291       if N + Column > Line_Limit then
292          Write_Indent_Str ("  ");
293       end if;
294    end Col_Check;
295
296    -------------------
297    -- Indent_Annull --
298    -------------------
299
300    procedure Indent_Annull is
301    begin
302       Indent_Annull_Flag := True;
303    end Indent_Annull;
304
305    ------------------
306    -- Indent_Begin --
307    ------------------
308
309    procedure Indent_Begin is
310    begin
311       Indent := Indent + 3;
312    end Indent_Begin;
313
314    ----------------
315    -- Indent_End --
316    ----------------
317
318    procedure Indent_End is
319    begin
320       Indent := Indent - 3;
321    end Indent_End;
322
323    --------
324    -- pg --
325    --------
326
327    procedure pg (Node : Node_Id) is
328    begin
329       Dump_Generated_Only := True;
330       Dump_Original_Only := False;
331       Sprint_Node (Node);
332       Write_Eol;
333    end pg;
334
335    --------
336    -- po --
337    --------
338
339    procedure po (Node : Node_Id) is
340    begin
341       Dump_Generated_Only := False;
342       Dump_Original_Only := True;
343       Sprint_Node (Node);
344       Write_Eol;
345    end po;
346
347    ----------------------
348    -- Print_Debug_Line --
349    ----------------------
350
351    procedure Print_Debug_Line (S : String) is
352    begin
353       Write_Debug_Line (S, Debug_Sloc);
354    end Print_Debug_Line;
355
356    ---------------------------
357    -- Process_TFAI_RR_Flags --
358    ---------------------------
359
360    procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
361    begin
362       if Treat_Fixed_As_Integer (Nod) then
363          Write_Char ('#');
364       end if;
365
366       if Rounded_Result (Nod) then
367          Write_Char ('@');
368       end if;
369    end Process_TFAI_RR_Flags;
370
371    --------
372    -- ps --
373    --------
374
375    procedure ps (Node : Node_Id) is
376    begin
377       Dump_Generated_Only := False;
378       Dump_Original_Only := False;
379       Sprint_Node (Node);
380       Write_Eol;
381    end ps;
382
383    --------------------
384    -- Set_Debug_Sloc --
385    --------------------
386
387    procedure Set_Debug_Sloc is
388    begin
389       if Present (Debug_Node) then
390          Set_Sloc (Debug_Node, Debug_Sloc + Source_Ptr (Column - 1));
391          Debug_Node := Empty;
392       end if;
393    end Set_Debug_Sloc;
394
395    -----------------
396    -- Source_Dump --
397    -----------------
398
399    procedure Source_Dump is
400
401       procedure Underline;
402       --  Put underline under string we just printed
403
404       procedure Underline is
405          Col : constant Int := Column;
406
407       begin
408          Write_Eol;
409
410          while Col > Column loop
411             Write_Char ('-');
412          end loop;
413
414          Write_Eol;
415       end Underline;
416
417    --  Start of processing for Tree_Dump.
418
419    begin
420       Dump_Generated_Only := Debug_Flag_G or
421                              Print_Generated_Code or
422                              Debug_Generated_Code;
423       Dump_Original_Only  := Debug_Flag_O;
424       Dump_Freeze_Null    := Debug_Flag_S or Debug_Flag_G;
425
426       --  Note that we turn off the tree dump flags immediately, before
427       --  starting the dump. This avoids generating two copies of the dump
428       --  if an abort occurs after printing the dump, and more importantly,
429       --  avoids an infinite loop if an abort occurs during the dump.
430
431       if Debug_Flag_Z then
432          Debug_Flag_Z := False;
433          Write_Eol;
434          Write_Eol;
435          Write_Str ("Source recreated from tree of Standard (spec)");
436          Underline;
437          Sprint_Node (Standard_Package_Node);
438          Write_Eol;
439          Write_Eol;
440       end if;
441
442       if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
443          Debug_Flag_G := False;
444          Debug_Flag_O := False;
445          Debug_Flag_S := False;
446
447          --  Dump requested units
448
449          for U in Main_Unit .. Last_Unit loop
450
451             --  Dump all units if -gnatdf set, otherwise we dump only
452             --  the source files that are in the extended main source.
453
454             if Debug_Flag_F
455               or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
456             then
457                --  If we are generating debug files, setup to write them
458
459                if Debug_Generated_Code then
460                   Set_Special_Output (Print_Debug_Line'Access);
461                   Create_Debug_Source (Source_Index (U), Debug_Sloc);
462                   Sprint_Node (Cunit (U));
463                   Write_Eol;
464                   Close_Debug_Source;
465                   Set_Special_Output (null);
466
467                --  Normal output to standard output file
468
469                else
470                   Write_Str ("Source recreated from tree for ");
471                   Write_Unit_Name (Unit_Name (U));
472                   Underline;
473                   Sprint_Node (Cunit (U));
474                   Write_Eol;
475                   Write_Eol;
476                end if;
477             end if;
478          end loop;
479       end if;
480    end Source_Dump;
481
482    ---------------------
483    -- Sprint_Bar_List --
484    ---------------------
485
486    procedure Sprint_Bar_List (List : List_Id) is
487       Node : Node_Id;
488
489    begin
490       if Is_Non_Empty_List (List) then
491          Node := First (List);
492
493          loop
494             Sprint_Node (Node);
495             Next (Node);
496             exit when Node = Empty;
497             Write_Str (" | ");
498          end loop;
499       end if;
500    end Sprint_Bar_List;
501
502    -----------------------
503    -- Sprint_Comma_List --
504    -----------------------
505
506    procedure Sprint_Comma_List (List : List_Id) is
507       Node : Node_Id;
508
509    begin
510       if Is_Non_Empty_List (List) then
511          Node := First (List);
512
513          loop
514             Sprint_Node (Node);
515             Next (Node);
516             exit when Node = Empty;
517
518             if not Is_Rewrite_Insertion (Node)
519               or else not Dump_Original_Only
520             then
521                Write_Str (", ");
522             end if;
523
524          end loop;
525       end if;
526    end Sprint_Comma_List;
527
528    --------------------------
529    -- Sprint_Indented_List --
530    --------------------------
531
532    procedure Sprint_Indented_List (List : List_Id) is
533    begin
534       Indent_Begin;
535       Sprint_Node_List (List);
536       Indent_End;
537    end Sprint_Indented_List;
538
539    ---------------------
540    -- Sprint_Left_Opnd --
541    ---------------------
542
543    procedure Sprint_Left_Opnd (N : Node_Id) is
544       Opnd : constant Node_Id := Left_Opnd (N);
545
546    begin
547       if Paren_Count (Opnd) /= 0
548         or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N))
549       then
550          Sprint_Node (Opnd);
551
552       else
553          Write_Char ('(');
554          Sprint_Node (Opnd);
555          Write_Char (')');
556       end if;
557    end Sprint_Left_Opnd;
558
559    -----------------
560    -- Sprint_Node --
561    -----------------
562
563    procedure Sprint_Node (Node : Node_Id) is
564    begin
565       if Is_Rewrite_Insertion (Node) then
566          if not Dump_Original_Only then
567
568             --  For special cases of nodes that always output <<< >>>
569             --  do not duplicate the output at this point.
570
571             if Nkind (Node) = N_Freeze_Entity
572               or else Nkind (Node) = N_Implicit_Label_Declaration
573             then
574                Sprint_Node_Actual (Node);
575
576             --  Normal case where <<< >>> may be required
577
578             else
579                Write_Rewrite_Str ("<<<");
580                Sprint_Node_Actual (Node);
581                Write_Rewrite_Str (">>>");
582             end if;
583          end if;
584
585       elsif Is_Rewrite_Substitution (Node) then
586
587          --  Case of dump generated only
588
589          if Dump_Generated_Only then
590             Sprint_Node_Actual (Node);
591
592          --  Case of dump original only
593
594          elsif Dump_Original_Only then
595             Sprint_Node_Actual (Original_Node (Node));
596
597          --  Case of both being dumped
598
599          else
600             Sprint_Node_Actual (Original_Node (Node));
601             Write_Rewrite_Str ("<<<");
602             Sprint_Node_Actual (Node);
603             Write_Rewrite_Str (">>>");
604          end if;
605
606       else
607          Sprint_Node_Actual (Node);
608       end if;
609    end Sprint_Node;
610
611    ------------------------
612    -- Sprint_Node_Actual --
613    ------------------------
614
615    procedure Sprint_Node_Actual (Node : Node_Id) is
616       Save_Debug_Node : constant Node_Id := Debug_Node;
617
618    begin
619       if Node = Empty then
620          return;
621       end if;
622
623       for J in 1 .. Paren_Count (Node) loop
624          Write_Str_With_Col_Check ("(");
625       end loop;
626
627       --  Setup node for Sloc fixup if writing a debug source file. Note
628       --  that we take care of any previous node not yet properly set.
629
630       if Debug_Generated_Code then
631          Debug_Node := Node;
632       end if;
633
634       if Nkind (Node) in N_Subexpr
635         and then Do_Range_Check (Node)
636       then
637          Write_Str_With_Col_Check ("{");
638       end if;
639
640       --  Select print circuit based on node kind
641
642       case Nkind (Node) is
643
644          when N_Abort_Statement =>
645             Write_Indent_Str_Sloc ("abort ");
646             Sprint_Comma_List (Names (Node));
647             Write_Char (';');
648
649          when N_Abortable_Part =>
650             Set_Debug_Sloc;
651             Write_Str_Sloc ("abort ");
652             Sprint_Indented_List (Statements (Node));
653
654          when N_Abstract_Subprogram_Declaration =>
655             Write_Indent;
656             Sprint_Node (Specification (Node));
657             Write_Str_With_Col_Check (" is ");
658             Write_Str_Sloc ("abstract;");
659
660          when N_Accept_Alternative =>
661             Sprint_Node_List (Pragmas_Before (Node));
662
663             if Present (Condition (Node)) then
664                Write_Indent_Str ("when ");
665                Sprint_Node (Condition (Node));
666                Write_Str (" => ");
667                Indent_Annull;
668             end if;
669
670             Sprint_Node_Sloc (Accept_Statement (Node));
671             Sprint_Node_List (Statements (Node));
672
673          when N_Accept_Statement =>
674             Write_Indent_Str_Sloc ("accept ");
675             Write_Id (Entry_Direct_Name (Node));
676
677             if Present (Entry_Index (Node)) then
678                Write_Str_With_Col_Check (" (");
679                Sprint_Node (Entry_Index (Node));
680                Write_Char (')');
681             end if;
682
683             Write_Param_Specs (Node);
684
685             if Present (Handled_Statement_Sequence (Node)) then
686                Write_Str_With_Col_Check (" do");
687                Sprint_Node (Handled_Statement_Sequence (Node));
688                Write_Indent_Str ("end ");
689                Write_Id (Entry_Direct_Name (Node));
690             end if;
691
692             Write_Char (';');
693
694          when N_Access_Definition =>
695             Write_Str_With_Col_Check_Sloc ("access ");
696             Sprint_Node (Subtype_Mark (Node));
697
698          when N_Access_Function_Definition =>
699             Write_Str_With_Col_Check_Sloc ("access ");
700
701             if Protected_Present (Node) then
702                Write_Str_With_Col_Check ("protected ");
703             end if;
704
705             Write_Str_With_Col_Check ("function");
706             Write_Param_Specs (Node);
707             Write_Str_With_Col_Check (" return ");
708             Sprint_Node (Subtype_Mark (Node));
709
710          when N_Access_Procedure_Definition =>
711             Write_Str_With_Col_Check_Sloc ("access ");
712
713             if Protected_Present (Node) then
714                Write_Str_With_Col_Check ("protected ");
715             end if;
716
717             Write_Str_With_Col_Check ("procedure");
718             Write_Param_Specs (Node);
719
720          when N_Access_To_Object_Definition =>
721             Write_Str_With_Col_Check_Sloc ("access ");
722
723             if All_Present (Node) then
724                Write_Str_With_Col_Check ("all ");
725             elsif Constant_Present (Node) then
726                Write_Str_With_Col_Check ("constant ");
727             end if;
728
729             Sprint_Node (Subtype_Indication (Node));
730
731          when N_Aggregate =>
732             if Null_Record_Present (Node) then
733                Write_Str_With_Col_Check_Sloc ("(null record)");
734
735             else
736                Write_Str_With_Col_Check_Sloc ("(");
737
738                if Present (Expressions (Node)) then
739                   Sprint_Comma_List (Expressions (Node));
740
741                   if Present (Component_Associations (Node)) then
742                      Write_Str (", ");
743                   end if;
744                end if;
745
746                if Present (Component_Associations (Node)) then
747                   Indent_Begin;
748
749                   declare
750                      Nd : Node_Id;
751
752                   begin
753                      Nd := First (Component_Associations (Node));
754
755                      loop
756                         Write_Indent;
757                         Sprint_Node (Nd);
758                         Next (Nd);
759                         exit when No (Nd);
760
761                         if not Is_Rewrite_Insertion (Nd)
762                           or else not Dump_Original_Only
763                         then
764                            Write_Str (", ");
765                         end if;
766                      end loop;
767                   end;
768
769                   Indent_End;
770                end if;
771
772                Write_Char (')');
773             end if;
774
775          when N_Allocator =>
776             Write_Str_With_Col_Check_Sloc ("new ");
777             Sprint_Node (Expression (Node));
778
779             if Present (Storage_Pool (Node)) then
780                Write_Str_With_Col_Check ("[storage_pool = ");
781                Sprint_Node (Storage_Pool (Node));
782                Write_Char (']');
783             end if;
784
785          when N_And_Then =>
786             Sprint_Left_Opnd (Node);
787             Write_Str_Sloc (" and then ");
788             Sprint_Right_Opnd (Node);
789
790          when N_At_Clause =>
791             Write_Indent_Str_Sloc ("for ");
792             Write_Id (Identifier (Node));
793             Write_Str_With_Col_Check (" use at ");
794             Sprint_Node (Expression (Node));
795             Write_Char (';');
796
797          when N_Assignment_Statement =>
798             Write_Indent;
799             Sprint_Node (Name (Node));
800             Write_Str_Sloc (" := ");
801             Sprint_Node (Expression (Node));
802             Write_Char (';');
803
804          when N_Asynchronous_Select =>
805             Write_Indent_Str_Sloc ("select");
806             Indent_Begin;
807             Sprint_Node (Triggering_Alternative (Node));
808             Indent_End;
809
810             --  Note: let the printing of Abortable_Part handle outputting
811             --  the ABORT keyword, so that the Slco can be set correctly.
812
813             Write_Indent_Str ("then ");
814             Sprint_Node (Abortable_Part (Node));
815             Write_Indent_Str ("end select;");
816
817          when N_Attribute_Definition_Clause =>
818             Write_Indent_Str_Sloc ("for ");
819             Sprint_Node (Name (Node));
820             Write_Char (''');
821             Write_Name_With_Col_Check (Chars (Node));
822             Write_Str_With_Col_Check (" use ");
823             Sprint_Node (Expression (Node));
824             Write_Char (';');
825
826          when N_Attribute_Reference =>
827             if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
828                Write_Indent;
829             end if;
830
831             Sprint_Node (Prefix (Node));
832             Write_Char_Sloc (''');
833             Write_Name_With_Col_Check (Attribute_Name (Node));
834             Sprint_Paren_Comma_List (Expressions (Node));
835
836             if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
837                Write_Char (';');
838             end if;
839
840          when N_Block_Statement =>
841             Write_Indent;
842
843             if Present (Identifier (Node))
844               and then (not Has_Created_Identifier (Node)
845                           or else not Dump_Original_Only)
846             then
847                Write_Rewrite_Str ("<<<");
848                Write_Id (Identifier (Node));
849                Write_Str (" : ");
850                Write_Rewrite_Str (">>>");
851             end if;
852
853             if Present (Declarations (Node)) then
854                Write_Str_With_Col_Check_Sloc ("declare");
855                Sprint_Indented_List (Declarations (Node));
856                Write_Indent;
857             end if;
858
859             Write_Str_With_Col_Check_Sloc ("begin");
860             Sprint_Node (Handled_Statement_Sequence (Node));
861             Write_Indent_Str ("end");
862
863             if Present (Identifier (Node))
864               and then (not Has_Created_Identifier (Node)
865                           or else not Dump_Original_Only)
866             then
867                Write_Rewrite_Str ("<<<");
868                Write_Char (' ');
869                Write_Id (Identifier (Node));
870                Write_Rewrite_Str (">>>");
871             end if;
872
873             Write_Char (';');
874
875          when N_Case_Statement =>
876             Write_Indent_Str_Sloc ("case ");
877             Sprint_Node (Expression (Node));
878             Write_Str (" is");
879             Sprint_Indented_List (Alternatives (Node));
880             Write_Indent_Str ("end case;");
881
882          when N_Case_Statement_Alternative =>
883             Write_Indent_Str_Sloc ("when ");
884             Sprint_Bar_List (Discrete_Choices (Node));
885             Write_Str (" => ");
886             Sprint_Indented_List (Statements (Node));
887
888          when N_Character_Literal =>
889             if Column > 70 then
890                Write_Indent_Str ("  ");
891             end if;
892
893             Write_Char_Sloc (''');
894             Write_Char_Code (Char_Literal_Value (Node));
895             Write_Char (''');
896
897          when N_Code_Statement =>
898             Write_Indent;
899             Set_Debug_Sloc;
900             Sprint_Node (Expression (Node));
901             Write_Char (';');
902
903          when N_Compilation_Unit =>
904             Sprint_Node_List (Context_Items (Node));
905             Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
906
907             if Private_Present (Node) then
908                Write_Indent_Str ("private ");
909                Indent_Annull;
910             end if;
911
912             Sprint_Node_Sloc (Unit (Node));
913
914             if Present (Actions (Aux_Decls_Node (Node)))
915                  or else
916                Present (Pragmas_After (Aux_Decls_Node (Node)))
917             then
918                Write_Indent;
919             end if;
920
921             Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
922             Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
923
924          when N_Compilation_Unit_Aux =>
925             null; -- nothing to do, never used, see above
926
927          when N_Component_Association =>
928             Set_Debug_Sloc;
929             Sprint_Bar_List (Choices (Node));
930             Write_Str (" => ");
931             Sprint_Node (Expression (Node));
932
933          when N_Component_Clause =>
934             Write_Indent;
935             Sprint_Node (Component_Name (Node));
936             Write_Str_Sloc (" at ");
937             Sprint_Node (Position (Node));
938             Write_Char (' ');
939             Write_Str_With_Col_Check ("range ");
940             Sprint_Node (First_Bit (Node));
941             Write_Str (" .. ");
942             Sprint_Node (Last_Bit (Node));
943             Write_Char (';');
944
945          when N_Component_Declaration =>
946             if Write_Indent_Identifiers_Sloc (Node) then
947                Write_Str (" : ");
948
949                if Aliased_Present (Node) then
950                   Write_Str_With_Col_Check ("aliased ");
951                end if;
952
953                Sprint_Node (Subtype_Indication (Node));
954
955                if Present (Expression (Node)) then
956                   Write_Str (" := ");
957                   Sprint_Node (Expression (Node));
958                end if;
959
960                Write_Char (';');
961             end if;
962
963          when N_Component_List =>
964             if Null_Present (Node) then
965                Indent_Begin;
966                Write_Indent_Str_Sloc ("null");
967                Write_Char (';');
968                Indent_End;
969
970             else
971                Set_Debug_Sloc;
972                Sprint_Indented_List (Component_Items (Node));
973                Sprint_Node (Variant_Part (Node));
974             end if;
975
976          when N_Conditional_Entry_Call =>
977             Write_Indent_Str_Sloc ("select");
978             Indent_Begin;
979             Sprint_Node (Entry_Call_Alternative (Node));
980             Indent_End;
981             Write_Indent_Str ("else");
982             Sprint_Indented_List (Else_Statements (Node));
983             Write_Indent_Str ("end select;");
984
985          when N_Conditional_Expression =>
986             declare
987                Condition : constant Node_Id := First (Expressions (Node));
988                Then_Expr : constant Node_Id := Next (Condition);
989                Else_Expr : constant Node_Id := Next (Then_Expr);
990
991             begin
992                Write_Str_With_Col_Check_Sloc ("(if ");
993                Sprint_Node (Condition);
994                Write_Str_With_Col_Check (" then ");
995                Sprint_Node (Then_Expr);
996                Write_Str_With_Col_Check (" else ");
997                Sprint_Node (Else_Expr);
998                Write_Char (')');
999             end;
1000
1001          when N_Constrained_Array_Definition =>
1002             Write_Str_With_Col_Check_Sloc ("array ");
1003             Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1004             Write_Str (" of ");
1005
1006             if Aliased_Present (Node) then
1007                Write_Str_With_Col_Check ("aliased ");
1008             end if;
1009
1010             Sprint_Node (Subtype_Indication (Node));
1011
1012          when N_Decimal_Fixed_Point_Definition =>
1013             Write_Str_With_Col_Check_Sloc (" delta ");
1014             Sprint_Node (Delta_Expression (Node));
1015             Write_Str_With_Col_Check ("digits ");
1016             Sprint_Node (Digits_Expression (Node));
1017             Sprint_Opt_Node (Real_Range_Specification (Node));
1018
1019          when N_Defining_Character_Literal =>
1020             Write_Name_With_Col_Check_Sloc (Chars (Node));
1021
1022          when N_Defining_Identifier =>
1023             Set_Debug_Sloc;
1024             Write_Id (Node);
1025
1026          when N_Defining_Operator_Symbol =>
1027             Write_Name_With_Col_Check_Sloc (Chars (Node));
1028
1029          when N_Defining_Program_Unit_Name =>
1030             Set_Debug_Sloc;
1031             Sprint_Node (Name (Node));
1032             Write_Char ('.');
1033             Write_Id (Defining_Identifier (Node));
1034
1035          when N_Delay_Alternative =>
1036             Sprint_Node_List (Pragmas_Before (Node));
1037
1038             if Present (Condition (Node)) then
1039                Write_Indent;
1040                Write_Str_With_Col_Check ("when ");
1041                Sprint_Node (Condition (Node));
1042                Write_Str (" => ");
1043                Indent_Annull;
1044             end if;
1045
1046             Sprint_Node_Sloc (Delay_Statement (Node));
1047             Sprint_Node_List (Statements (Node));
1048
1049          when N_Delay_Relative_Statement =>
1050             Write_Indent_Str_Sloc ("delay ");
1051             Sprint_Node (Expression (Node));
1052             Write_Char (';');
1053
1054          when N_Delay_Until_Statement =>
1055             Write_Indent_Str_Sloc ("delay until ");
1056             Sprint_Node (Expression (Node));
1057             Write_Char (';');
1058
1059          when N_Delta_Constraint =>
1060             Write_Str_With_Col_Check_Sloc ("delta ");
1061             Sprint_Node (Delta_Expression (Node));
1062             Sprint_Opt_Node (Range_Constraint (Node));
1063
1064          when N_Derived_Type_Definition =>
1065             if Abstract_Present (Node) then
1066                Write_Str_With_Col_Check ("abstract ");
1067             end if;
1068
1069             Write_Str_With_Col_Check_Sloc ("new ");
1070             Sprint_Node (Subtype_Indication (Node));
1071
1072             if Present (Record_Extension_Part (Node)) then
1073                Write_Str_With_Col_Check (" with ");
1074                Sprint_Node (Record_Extension_Part (Node));
1075             end if;
1076
1077          when N_Designator =>
1078             Sprint_Node (Name (Node));
1079             Write_Char_Sloc ('.');
1080             Write_Id (Identifier (Node));
1081
1082          when N_Digits_Constraint =>
1083             Write_Str_With_Col_Check_Sloc ("digits ");
1084             Sprint_Node (Digits_Expression (Node));
1085             Sprint_Opt_Node (Range_Constraint (Node));
1086
1087          when N_Discriminant_Association =>
1088             Set_Debug_Sloc;
1089
1090             if Present (Selector_Names (Node)) then
1091                Sprint_Bar_List (Selector_Names (Node));
1092                Write_Str (" => ");
1093             end if;
1094
1095             Set_Debug_Sloc;
1096             Sprint_Node (Expression (Node));
1097
1098          when N_Discriminant_Specification =>
1099             Set_Debug_Sloc;
1100
1101             if Write_Identifiers (Node) then
1102                Write_Str (" : ");
1103                Sprint_Node (Discriminant_Type (Node));
1104
1105                if Present (Expression (Node)) then
1106                   Write_Str (" := ");
1107                   Sprint_Node (Expression (Node));
1108                end if;
1109             else
1110                Write_Str (", ");
1111             end if;
1112
1113          when N_Elsif_Part =>
1114             Write_Indent_Str_Sloc ("elsif ");
1115             Sprint_Node (Condition (Node));
1116             Write_Str_With_Col_Check (" then");
1117             Sprint_Indented_List (Then_Statements (Node));
1118
1119          when N_Empty =>
1120             null;
1121
1122          when N_Entry_Body =>
1123             Write_Indent_Str_Sloc ("entry ");
1124             Write_Id (Defining_Identifier (Node));
1125             Sprint_Node (Entry_Body_Formal_Part (Node));
1126             Write_Str_With_Col_Check (" is");
1127             Sprint_Indented_List (Declarations (Node));
1128             Write_Indent_Str ("begin");
1129             Sprint_Node (Handled_Statement_Sequence (Node));
1130             Write_Indent_Str ("end ");
1131             Write_Id (Defining_Identifier (Node));
1132             Write_Char (';');
1133
1134          when N_Entry_Body_Formal_Part =>
1135             if Present (Entry_Index_Specification (Node)) then
1136                Write_Str_With_Col_Check_Sloc (" (");
1137                Sprint_Node (Entry_Index_Specification (Node));
1138                Write_Char (')');
1139             end if;
1140
1141             Write_Param_Specs (Node);
1142             Write_Str_With_Col_Check_Sloc (" when ");
1143             Sprint_Node (Condition (Node));
1144
1145          when N_Entry_Call_Alternative =>
1146             Sprint_Node_List (Pragmas_Before (Node));
1147             Sprint_Node_Sloc (Entry_Call_Statement (Node));
1148             Sprint_Node_List (Statements (Node));
1149
1150          when N_Entry_Call_Statement =>
1151             Write_Indent;
1152             Sprint_Node_Sloc (Name (Node));
1153             Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1154             Write_Char (';');
1155
1156          when N_Entry_Declaration =>
1157             Write_Indent_Str_Sloc ("entry ");
1158             Write_Id (Defining_Identifier (Node));
1159
1160             if Present (Discrete_Subtype_Definition (Node)) then
1161                Write_Str_With_Col_Check (" (");
1162                Sprint_Node (Discrete_Subtype_Definition (Node));
1163                Write_Char (')');
1164             end if;
1165
1166             Write_Param_Specs (Node);
1167             Write_Char (';');
1168
1169          when N_Entry_Index_Specification =>
1170             Write_Str_With_Col_Check_Sloc ("for ");
1171             Write_Id (Defining_Identifier (Node));
1172             Write_Str_With_Col_Check (" in ");
1173             Sprint_Node (Discrete_Subtype_Definition (Node));
1174
1175          when N_Enumeration_Representation_Clause =>
1176             Write_Indent_Str_Sloc ("for ");
1177             Write_Id (Identifier (Node));
1178             Write_Str_With_Col_Check (" use ");
1179             Sprint_Node (Array_Aggregate (Node));
1180             Write_Char (';');
1181
1182          when N_Enumeration_Type_Definition =>
1183             Set_Debug_Sloc;
1184
1185             --  Skip attempt to print Literals field if it's not there and
1186             --  we are in package Standard (case of Character, which is
1187             --  handled specially (without an explicit literals list).
1188
1189             if Sloc (Node) > Standard_Location
1190               or else Present (Literals (Node))
1191             then
1192                Sprint_Paren_Comma_List (Literals (Node));
1193             end if;
1194
1195          when N_Error =>
1196             Write_Str_With_Col_Check_Sloc ("<error>");
1197
1198          when N_Exception_Declaration =>
1199             if Write_Indent_Identifiers (Node) then
1200                Write_Str_With_Col_Check (" : ");
1201                Write_Str_Sloc ("exception;");
1202             end if;
1203
1204          when N_Exception_Handler =>
1205             Write_Indent_Str_Sloc ("when ");
1206
1207             if Present (Choice_Parameter (Node)) then
1208                Sprint_Node (Choice_Parameter (Node));
1209                Write_Str (" : ");
1210             end if;
1211
1212             Sprint_Bar_List (Exception_Choices (Node));
1213             Write_Str (" => ");
1214             Sprint_Indented_List (Statements (Node));
1215
1216          when N_Exception_Renaming_Declaration =>
1217             Write_Indent;
1218             Set_Debug_Sloc;
1219             Sprint_Node (Defining_Identifier (Node));
1220             Write_Str_With_Col_Check (" : exception renames ");
1221             Sprint_Node (Name (Node));
1222             Write_Char (';');
1223
1224          when N_Exit_Statement =>
1225             Write_Indent_Str_Sloc ("exit");
1226             Sprint_Opt_Node (Name (Node));
1227
1228             if Present (Condition (Node)) then
1229                Write_Str_With_Col_Check (" when ");
1230                Sprint_Node (Condition (Node));
1231             end if;
1232
1233             Write_Char (';');
1234
1235          when N_Explicit_Dereference =>
1236             Sprint_Node (Prefix (Node));
1237             Write_Char ('.');
1238             Write_Str_Sloc ("all");
1239
1240          when N_Extension_Aggregate =>
1241             Write_Str_With_Col_Check_Sloc ("(");
1242             Sprint_Node (Ancestor_Part (Node));
1243             Write_Str_With_Col_Check (" with ");
1244
1245             if Null_Record_Present (Node) then
1246                Write_Str_With_Col_Check ("null record");
1247             else
1248                if Present (Expressions (Node)) then
1249                   Sprint_Comma_List (Expressions (Node));
1250
1251                   if Present (Component_Associations (Node)) then
1252                      Write_Str (", ");
1253                   end if;
1254                end if;
1255
1256                if Present (Component_Associations (Node)) then
1257                   Sprint_Comma_List (Component_Associations (Node));
1258                end if;
1259             end if;
1260
1261             Write_Char (')');
1262
1263          when N_Floating_Point_Definition =>
1264             Write_Str_With_Col_Check_Sloc ("digits ");
1265             Sprint_Node (Digits_Expression (Node));
1266             Sprint_Opt_Node (Real_Range_Specification (Node));
1267
1268          when N_Formal_Decimal_Fixed_Point_Definition =>
1269             Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1270
1271          when N_Formal_Derived_Type_Definition =>
1272             Write_Str_With_Col_Check_Sloc ("new ");
1273             Sprint_Node (Subtype_Mark (Node));
1274
1275             if Private_Present (Node) then
1276                Write_Str_With_Col_Check (" with private");
1277             end if;
1278
1279          when N_Formal_Discrete_Type_Definition =>
1280             Write_Str_With_Col_Check_Sloc ("<>");
1281
1282          when N_Formal_Floating_Point_Definition =>
1283             Write_Str_With_Col_Check_Sloc ("digits <>");
1284
1285          when N_Formal_Modular_Type_Definition =>
1286             Write_Str_With_Col_Check_Sloc ("mod <>");
1287
1288          when N_Formal_Object_Declaration =>
1289             Set_Debug_Sloc;
1290
1291             if Write_Indent_Identifiers (Node) then
1292                Write_Str (" : ");
1293
1294                if In_Present (Node) then
1295                   Write_Str_With_Col_Check ("in ");
1296                end if;
1297
1298                if Out_Present (Node) then
1299                   Write_Str_With_Col_Check ("out ");
1300                end if;
1301
1302                Sprint_Node (Subtype_Mark (Node));
1303
1304                if Present (Expression (Node)) then
1305                   Write_Str (" := ");
1306                   Sprint_Node (Expression (Node));
1307                end if;
1308
1309                Write_Char (';');
1310             end if;
1311
1312          when N_Formal_Ordinary_Fixed_Point_Definition =>
1313             Write_Str_With_Col_Check_Sloc ("delta <>");
1314
1315          when N_Formal_Package_Declaration =>
1316             Write_Indent_Str_Sloc ("with package ");
1317             Write_Id (Defining_Identifier (Node));
1318             Write_Str_With_Col_Check (" is new ");
1319             Sprint_Node (Name (Node));
1320             Write_Str_With_Col_Check (" (<>);");
1321
1322          when N_Formal_Private_Type_Definition =>
1323             if Abstract_Present (Node) then
1324                Write_Str_With_Col_Check ("abstract ");
1325             end if;
1326
1327             if Tagged_Present (Node) then
1328                Write_Str_With_Col_Check ("tagged ");
1329             end if;
1330
1331             if Limited_Present (Node) then
1332                Write_Str_With_Col_Check ("limited ");
1333             end if;
1334
1335             Write_Str_With_Col_Check_Sloc ("private");
1336
1337          when N_Formal_Signed_Integer_Type_Definition =>
1338             Write_Str_With_Col_Check_Sloc ("range <>");
1339
1340          when N_Formal_Subprogram_Declaration =>
1341             Write_Indent_Str_Sloc ("with ");
1342             Sprint_Node (Specification (Node));
1343
1344             if Box_Present (Node) then
1345                Write_Str_With_Col_Check (" is <>");
1346             elsif Present (Default_Name (Node)) then
1347                Write_Str_With_Col_Check (" is ");
1348                Sprint_Node (Default_Name (Node));
1349             end if;
1350
1351             Write_Char (';');
1352
1353          when N_Formal_Type_Declaration =>
1354             Write_Indent_Str_Sloc ("type ");
1355             Write_Id (Defining_Identifier (Node));
1356
1357             if Present (Discriminant_Specifications (Node)) then
1358                Write_Discr_Specs (Node);
1359             elsif Unknown_Discriminants_Present (Node) then
1360                Write_Str_With_Col_Check ("(<>)");
1361             end if;
1362
1363             Write_Str_With_Col_Check (" is ");
1364             Sprint_Node (Formal_Type_Definition (Node));
1365             Write_Char (';');
1366
1367          when N_Free_Statement =>
1368             Write_Indent_Str_Sloc ("free ");
1369             Sprint_Node (Expression (Node));
1370             Write_Char (';');
1371
1372          when N_Freeze_Entity =>
1373             if Dump_Original_Only then
1374                null;
1375
1376             elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1377                Write_Indent;
1378                Write_Rewrite_Str ("<<<");
1379                Write_Str_With_Col_Check_Sloc ("freeze ");
1380                Write_Id (Entity (Node));
1381                Write_Str (" [");
1382
1383                if No (Actions (Node)) then
1384                   Write_Char (']');
1385
1386                else
1387                   Freeze_Indent := Freeze_Indent + 1;
1388                   Sprint_Indented_List (Actions (Node));
1389                   Freeze_Indent := Freeze_Indent - 1;
1390                   Write_Indent_Str ("]");
1391                end if;
1392
1393                Write_Rewrite_Str (">>>");
1394             end if;
1395
1396          when N_Full_Type_Declaration =>
1397             Write_Indent_Str_Sloc ("type ");
1398             Write_Id (Defining_Identifier (Node));
1399             Write_Discr_Specs (Node);
1400             Write_Str_With_Col_Check (" is ");
1401             Sprint_Node (Type_Definition (Node));
1402             Write_Char (';');
1403
1404          when N_Function_Call =>
1405             Set_Debug_Sloc;
1406             Sprint_Node (Name (Node));
1407             Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1408
1409          when N_Function_Instantiation =>
1410             Write_Indent_Str_Sloc ("function ");
1411             Sprint_Node (Defining_Unit_Name (Node));
1412             Write_Str_With_Col_Check (" is new ");
1413             Sprint_Node (Name (Node));
1414             Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1415             Write_Char (';');
1416
1417          when N_Function_Specification =>
1418             Write_Str_With_Col_Check_Sloc ("function ");
1419             Sprint_Node (Defining_Unit_Name (Node));
1420             Write_Param_Specs (Node);
1421             Write_Str_With_Col_Check (" return ");
1422             Sprint_Node (Subtype_Mark (Node));
1423
1424          when N_Generic_Association =>
1425             Set_Debug_Sloc;
1426
1427             if Present (Selector_Name (Node)) then
1428                Sprint_Node (Selector_Name (Node));
1429                Write_Str (" => ");
1430             end if;
1431
1432             Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1433
1434          when N_Generic_Function_Renaming_Declaration =>
1435             Write_Indent_Str_Sloc ("generic function ");
1436             Sprint_Node (Defining_Unit_Name (Node));
1437             Write_Str_With_Col_Check (" renames ");
1438             Sprint_Node (Name (Node));
1439             Write_Char (';');
1440
1441          when N_Generic_Package_Declaration =>
1442             Write_Indent;
1443             Write_Indent_Str_Sloc ("generic ");
1444             Sprint_Indented_List (Generic_Formal_Declarations (Node));
1445             Write_Indent;
1446             Sprint_Node (Specification (Node));
1447             Write_Char (';');
1448
1449          when N_Generic_Package_Renaming_Declaration =>
1450             Write_Indent_Str_Sloc ("generic package ");
1451             Sprint_Node (Defining_Unit_Name (Node));
1452             Write_Str_With_Col_Check (" renames ");
1453             Sprint_Node (Name (Node));
1454             Write_Char (';');
1455
1456          when N_Generic_Procedure_Renaming_Declaration =>
1457             Write_Indent_Str_Sloc ("generic procedure ");
1458             Sprint_Node (Defining_Unit_Name (Node));
1459             Write_Str_With_Col_Check (" renames ");
1460             Sprint_Node (Name (Node));
1461             Write_Char (';');
1462
1463          when N_Generic_Subprogram_Declaration =>
1464             Write_Indent;
1465             Write_Indent_Str_Sloc ("generic ");
1466             Sprint_Indented_List (Generic_Formal_Declarations (Node));
1467             Write_Indent;
1468             Sprint_Node (Specification (Node));
1469             Write_Char (';');
1470
1471          when N_Goto_Statement =>
1472             Write_Indent_Str_Sloc ("goto ");
1473             Sprint_Node (Name (Node));
1474             Write_Char (';');
1475
1476             if Nkind (Next (Node)) = N_Label then
1477                Write_Indent;
1478             end if;
1479
1480          when N_Handled_Sequence_Of_Statements =>
1481             Set_Debug_Sloc;
1482             Sprint_Indented_List (Statements (Node));
1483
1484             if Present (Exception_Handlers (Node)) then
1485                Write_Indent_Str ("exception");
1486                Indent_Begin;
1487                Sprint_Node_List (Exception_Handlers (Node));
1488                Indent_End;
1489             end if;
1490
1491             if Present (At_End_Proc (Node)) then
1492                Write_Indent_Str ("at end");
1493                Indent_Begin;
1494                Write_Indent;
1495                Sprint_Node (At_End_Proc (Node));
1496                Write_Char (';');
1497                Indent_End;
1498             end if;
1499
1500          when N_Identifier =>
1501             Set_Debug_Sloc;
1502             Write_Id (Node);
1503
1504          when N_If_Statement =>
1505             Write_Indent_Str_Sloc ("if ");
1506             Sprint_Node (Condition (Node));
1507             Write_Str_With_Col_Check (" then");
1508             Sprint_Indented_List (Then_Statements (Node));
1509             Sprint_Opt_Node_List (Elsif_Parts (Node));
1510
1511             if Present (Else_Statements (Node)) then
1512                Write_Indent_Str ("else");
1513                Sprint_Indented_List (Else_Statements (Node));
1514             end if;
1515
1516             Write_Indent_Str ("end if;");
1517
1518          when N_Implicit_Label_Declaration =>
1519             if not Dump_Original_Only then
1520                Write_Indent;
1521                Write_Rewrite_Str ("<<<");
1522                Set_Debug_Sloc;
1523                Write_Id (Defining_Identifier (Node));
1524                Write_Str (" : ");
1525                Write_Str_With_Col_Check ("label");
1526                Write_Rewrite_Str (">>>");
1527             end if;
1528
1529          when N_In =>
1530             Sprint_Left_Opnd (Node);
1531             Write_Str_Sloc (" in ");
1532             Sprint_Right_Opnd (Node);
1533
1534          when N_Incomplete_Type_Declaration =>
1535             Write_Indent_Str_Sloc ("type ");
1536             Write_Id (Defining_Identifier (Node));
1537
1538             if Present (Discriminant_Specifications (Node)) then
1539                Write_Discr_Specs (Node);
1540             elsif Unknown_Discriminants_Present (Node) then
1541                Write_Str_With_Col_Check ("(<>)");
1542             end if;
1543
1544             Write_Char (';');
1545
1546          when N_Index_Or_Discriminant_Constraint =>
1547             Set_Debug_Sloc;
1548             Sprint_Paren_Comma_List (Constraints (Node));
1549
1550          when N_Indexed_Component =>
1551             Sprint_Node_Sloc (Prefix (Node));
1552             Sprint_Opt_Paren_Comma_List (Expressions (Node));
1553
1554          when N_Integer_Literal =>
1555             if Print_In_Hex (Node) then
1556                Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1557             else
1558                Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1559             end if;
1560
1561          when N_Iteration_Scheme =>
1562             if Present (Condition (Node)) then
1563                Write_Str_With_Col_Check_Sloc ("while ");
1564                Sprint_Node (Condition (Node));
1565             else
1566                Write_Str_With_Col_Check_Sloc ("for ");
1567                Sprint_Node (Loop_Parameter_Specification (Node));
1568             end if;
1569
1570             Write_Char (' ');
1571
1572          when N_Itype_Reference =>
1573             Write_Indent_Str_Sloc ("reference ");
1574             Write_Id (Itype (Node));
1575
1576          when N_Label =>
1577             Write_Indent_Str_Sloc ("<<");
1578             Write_Id (Identifier (Node));
1579             Write_Str (">>");
1580
1581          when N_Loop_Parameter_Specification =>
1582             Set_Debug_Sloc;
1583             Write_Id (Defining_Identifier (Node));
1584             Write_Str_With_Col_Check (" in ");
1585
1586             if Reverse_Present (Node) then
1587                Write_Str_With_Col_Check ("reverse ");
1588             end if;
1589
1590             Sprint_Node (Discrete_Subtype_Definition (Node));
1591
1592          when N_Loop_Statement =>
1593             Write_Indent;
1594
1595             if Present (Identifier (Node))
1596               and then (not Has_Created_Identifier (Node)
1597                           or else not Dump_Original_Only)
1598             then
1599                Write_Rewrite_Str ("<<<");
1600                Write_Id (Identifier (Node));
1601                Write_Str (" : ");
1602                Write_Rewrite_Str (">>>");
1603                Sprint_Node (Iteration_Scheme (Node));
1604                Write_Str_With_Col_Check_Sloc ("loop");
1605                Sprint_Indented_List (Statements (Node));
1606                Write_Indent_Str ("end loop ");
1607                Write_Rewrite_Str ("<<<");
1608                Write_Id (Identifier (Node));
1609                Write_Rewrite_Str (">>>");
1610                Write_Char (';');
1611
1612             else
1613                Sprint_Node (Iteration_Scheme (Node));
1614                Write_Str_With_Col_Check_Sloc ("loop");
1615                Sprint_Indented_List (Statements (Node));
1616                Write_Indent_Str ("end loop;");
1617             end if;
1618
1619          when N_Mod_Clause =>
1620             Sprint_Node_List (Pragmas_Before (Node));
1621             Write_Str_With_Col_Check_Sloc ("at mod ");
1622             Sprint_Node (Expression (Node));
1623
1624          when N_Modular_Type_Definition =>
1625             Write_Str_With_Col_Check_Sloc ("mod ");
1626             Sprint_Node (Expression (Node));
1627
1628          when N_Not_In =>
1629             Sprint_Left_Opnd (Node);
1630             Write_Str_Sloc (" not in ");
1631             Sprint_Right_Opnd (Node);
1632
1633          when N_Null =>
1634             Write_Str_With_Col_Check_Sloc ("null");
1635
1636          when N_Null_Statement =>
1637             if Comes_From_Source (Node)
1638               or else Dump_Freeze_Null
1639               or else not Is_List_Member (Node)
1640               or else (No (Prev (Node)) and then No (Next (Node)))
1641             then
1642                Write_Indent_Str_Sloc ("null;");
1643             end if;
1644
1645          when N_Number_Declaration =>
1646             Set_Debug_Sloc;
1647
1648             if Write_Indent_Identifiers (Node) then
1649                Write_Str_With_Col_Check (" : constant ");
1650                Write_Str (" := ");
1651                Sprint_Node (Expression (Node));
1652                Write_Char (';');
1653             end if;
1654
1655          when N_Object_Declaration =>
1656
1657             --  Put extra blank line before and after if this is a handler
1658             --  record or a subprogram descriptor.
1659
1660             declare
1661                Typ : constant Entity_Id := Etype (Defining_Identifier (Node));
1662                Exc : constant Boolean :=
1663                        Is_RTE (Typ, RE_Handler_Record)
1664                          or else
1665                        Is_RTE (Typ, RE_Subprogram_Descriptor);
1666
1667             begin
1668                if Exc then
1669                   Write_Indent;
1670                end if;
1671
1672                Set_Debug_Sloc;
1673
1674                if Write_Indent_Identifiers (Node) then
1675                   Write_Str (" : ");
1676
1677                   if Aliased_Present (Node) then
1678                      Write_Str_With_Col_Check ("aliased ");
1679                   end if;
1680
1681                   if Constant_Present (Node) then
1682                      Write_Str_With_Col_Check ("constant ");
1683                   end if;
1684
1685                   Sprint_Node (Object_Definition (Node));
1686
1687                   if Present (Expression (Node)) then
1688                      Write_Str (" := ");
1689                      Sprint_Node (Expression (Node));
1690                   end if;
1691
1692                   Write_Char (';');
1693                end if;
1694
1695                if Exc then
1696                   Write_Indent;
1697                end if;
1698             end;
1699
1700          when N_Object_Renaming_Declaration =>
1701             Write_Indent;
1702             Set_Debug_Sloc;
1703             Sprint_Node (Defining_Identifier (Node));
1704             Write_Str (" : ");
1705             Sprint_Node (Subtype_Mark (Node));
1706             Write_Str_With_Col_Check (" renames ");
1707             Sprint_Node (Name (Node));
1708             Write_Char (';');
1709
1710          when N_Op_Abs =>
1711             Write_Operator (Node, "abs ");
1712             Sprint_Right_Opnd (Node);
1713
1714          when N_Op_Add =>
1715             Sprint_Left_Opnd (Node);
1716             Write_Operator (Node, " + ");
1717             Sprint_Right_Opnd (Node);
1718
1719          when N_Op_And =>
1720             Sprint_Left_Opnd (Node);
1721             Write_Operator (Node, " and ");
1722             Sprint_Right_Opnd (Node);
1723
1724          when N_Op_Concat =>
1725             Sprint_Left_Opnd (Node);
1726             Write_Operator (Node, " & ");
1727             Sprint_Right_Opnd (Node);
1728
1729          when N_Op_Divide =>
1730             Sprint_Left_Opnd (Node);
1731             Write_Char (' ');
1732             Process_TFAI_RR_Flags (Node);
1733             Write_Operator (Node, "/ ");
1734             Sprint_Right_Opnd (Node);
1735
1736          when N_Op_Eq =>
1737             Sprint_Left_Opnd (Node);
1738             Write_Operator (Node, " = ");
1739             Sprint_Right_Opnd (Node);
1740
1741          when N_Op_Expon =>
1742             Sprint_Left_Opnd (Node);
1743             Write_Operator (Node, " ** ");
1744             Sprint_Right_Opnd (Node);
1745
1746          when N_Op_Ge =>
1747             Sprint_Left_Opnd (Node);
1748             Write_Operator (Node, " >= ");
1749             Sprint_Right_Opnd (Node);
1750
1751          when N_Op_Gt =>
1752             Sprint_Left_Opnd (Node);
1753             Write_Operator (Node, " > ");
1754             Sprint_Right_Opnd (Node);
1755
1756          when N_Op_Le =>
1757             Sprint_Left_Opnd (Node);
1758             Write_Operator (Node, " <= ");
1759             Sprint_Right_Opnd (Node);
1760
1761          when N_Op_Lt =>
1762             Sprint_Left_Opnd (Node);
1763             Write_Operator (Node, " < ");
1764             Sprint_Right_Opnd (Node);
1765
1766          when N_Op_Minus =>
1767             Write_Operator (Node, "-");
1768             Sprint_Right_Opnd (Node);
1769
1770          when N_Op_Mod =>
1771             Sprint_Left_Opnd (Node);
1772
1773             if Treat_Fixed_As_Integer (Node) then
1774                Write_Str (" #");
1775             end if;
1776
1777             Write_Operator (Node, " mod ");
1778             Sprint_Right_Opnd (Node);
1779
1780          when N_Op_Multiply =>
1781             Sprint_Left_Opnd (Node);
1782             Write_Char (' ');
1783             Process_TFAI_RR_Flags (Node);
1784             Write_Operator (Node, "* ");
1785             Sprint_Right_Opnd (Node);
1786
1787          when N_Op_Ne =>
1788             Sprint_Left_Opnd (Node);
1789             Write_Operator (Node, " /= ");
1790             Sprint_Right_Opnd (Node);
1791
1792          when N_Op_Not =>
1793             Write_Operator (Node, "not ");
1794             Sprint_Right_Opnd (Node);
1795
1796          when N_Op_Or =>
1797             Sprint_Left_Opnd (Node);
1798             Write_Operator (Node, " or ");
1799             Sprint_Right_Opnd (Node);
1800
1801          when N_Op_Plus =>
1802             Write_Operator (Node, "+");
1803             Sprint_Right_Opnd (Node);
1804
1805          when N_Op_Rem =>
1806             Sprint_Left_Opnd (Node);
1807
1808             if Treat_Fixed_As_Integer (Node) then
1809                Write_Str (" #");
1810             end if;
1811
1812             Write_Operator (Node, " rem ");
1813             Sprint_Right_Opnd (Node);
1814
1815          when N_Op_Shift =>
1816             Set_Debug_Sloc;
1817             Write_Id (Node);
1818             Write_Char ('!');
1819             Write_Str_With_Col_Check ("(");
1820             Sprint_Node (Left_Opnd (Node));
1821             Write_Str (", ");
1822             Sprint_Node (Right_Opnd (Node));
1823             Write_Char (')');
1824
1825          when N_Op_Subtract =>
1826             Sprint_Left_Opnd (Node);
1827             Write_Operator (Node, " - ");
1828             Sprint_Right_Opnd (Node);
1829
1830          when N_Op_Xor =>
1831             Sprint_Left_Opnd (Node);
1832             Write_Operator (Node, " xor ");
1833             Sprint_Right_Opnd (Node);
1834
1835          when N_Operator_Symbol =>
1836             Write_Name_With_Col_Check_Sloc (Chars (Node));
1837
1838          when N_Ordinary_Fixed_Point_Definition =>
1839             Write_Str_With_Col_Check_Sloc ("delta ");
1840             Sprint_Node (Delta_Expression (Node));
1841             Sprint_Opt_Node (Real_Range_Specification (Node));
1842
1843          when N_Or_Else =>
1844             Sprint_Left_Opnd (Node);
1845             Write_Str_Sloc (" or else ");
1846             Sprint_Right_Opnd (Node);
1847
1848          when N_Others_Choice =>
1849             if All_Others (Node) then
1850                Write_Str_With_Col_Check ("all ");
1851             end if;
1852
1853             Write_Str_With_Col_Check_Sloc ("others");
1854
1855          when N_Package_Body =>
1856             Write_Indent;
1857             Write_Indent_Str_Sloc ("package body ");
1858             Sprint_Node (Defining_Unit_Name (Node));
1859             Write_Str (" is");
1860             Sprint_Indented_List (Declarations (Node));
1861
1862             if Present (Handled_Statement_Sequence (Node)) then
1863                Write_Indent_Str ("begin");
1864                Sprint_Node (Handled_Statement_Sequence (Node));
1865             end if;
1866
1867             Write_Indent_Str ("end ");
1868             Sprint_Node (Defining_Unit_Name (Node));
1869             Write_Char (';');
1870
1871          when N_Package_Body_Stub =>
1872             Write_Indent_Str_Sloc ("package body ");
1873             Sprint_Node (Defining_Identifier (Node));
1874             Write_Str_With_Col_Check (" is separate;");
1875
1876          when N_Package_Declaration =>
1877             Write_Indent;
1878             Write_Indent;
1879             Sprint_Node_Sloc (Specification (Node));
1880             Write_Char (';');
1881
1882          when N_Package_Instantiation =>
1883             Write_Indent;
1884             Write_Indent_Str_Sloc ("package ");
1885             Sprint_Node (Defining_Unit_Name (Node));
1886             Write_Str (" is new ");
1887             Sprint_Node (Name (Node));
1888             Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1889             Write_Char (';');
1890
1891          when N_Package_Renaming_Declaration =>
1892             Write_Indent_Str_Sloc ("package ");
1893             Sprint_Node (Defining_Unit_Name (Node));
1894             Write_Str_With_Col_Check (" renames ");
1895             Sprint_Node (Name (Node));
1896             Write_Char (';');
1897
1898          when N_Package_Specification =>
1899             Write_Str_With_Col_Check_Sloc ("package ");
1900             Sprint_Node (Defining_Unit_Name (Node));
1901             Write_Str (" is");
1902             Sprint_Indented_List (Visible_Declarations (Node));
1903
1904             if Present (Private_Declarations (Node)) then
1905                Write_Indent_Str ("private");
1906                Sprint_Indented_List (Private_Declarations (Node));
1907             end if;
1908
1909             Write_Indent_Str ("end ");
1910             Sprint_Node (Defining_Unit_Name (Node));
1911
1912          when N_Parameter_Association =>
1913             Sprint_Node_Sloc (Selector_Name (Node));
1914             Write_Str (" => ");
1915             Sprint_Node (Explicit_Actual_Parameter (Node));
1916
1917          when N_Parameter_Specification =>
1918             Set_Debug_Sloc;
1919
1920             if Write_Identifiers (Node) then
1921                Write_Str (" : ");
1922
1923                if In_Present (Node) then
1924                   Write_Str_With_Col_Check ("in ");
1925                end if;
1926
1927                if Out_Present (Node) then
1928                   Write_Str_With_Col_Check ("out ");
1929                end if;
1930
1931                Sprint_Node (Parameter_Type (Node));
1932
1933                if Present (Expression (Node)) then
1934                   Write_Str (" := ");
1935                   Sprint_Node (Expression (Node));
1936                end if;
1937             else
1938                Write_Str (", ");
1939             end if;
1940
1941          when N_Pragma =>
1942             Write_Indent_Str_Sloc ("pragma ");
1943             Write_Name_With_Col_Check (Chars (Node));
1944
1945             if Present (Pragma_Argument_Associations (Node)) then
1946                Sprint_Opt_Paren_Comma_List
1947                  (Pragma_Argument_Associations (Node));
1948             end if;
1949
1950             Write_Char (';');
1951
1952          when N_Pragma_Argument_Association =>
1953             Set_Debug_Sloc;
1954
1955             if Chars (Node) /= No_Name then
1956                Write_Name_With_Col_Check (Chars (Node));
1957                Write_Str (" => ");
1958             end if;
1959
1960             Sprint_Node (Expression (Node));
1961
1962          when N_Private_Type_Declaration =>
1963             Write_Indent_Str_Sloc ("type ");
1964             Write_Id (Defining_Identifier (Node));
1965
1966             if Present (Discriminant_Specifications (Node)) then
1967                Write_Discr_Specs (Node);
1968             elsif Unknown_Discriminants_Present (Node) then
1969                Write_Str_With_Col_Check ("(<>)");
1970             end if;
1971
1972             Write_Str (" is ");
1973
1974             if Tagged_Present (Node) then
1975                Write_Str_With_Col_Check ("tagged ");
1976             end if;
1977
1978             if Limited_Present (Node) then
1979                Write_Str_With_Col_Check ("limited ");
1980             end if;
1981
1982             Write_Str_With_Col_Check ("private;");
1983
1984          when N_Private_Extension_Declaration =>
1985             Write_Indent_Str_Sloc ("type ");
1986             Write_Id (Defining_Identifier (Node));
1987
1988             if Present (Discriminant_Specifications (Node)) then
1989                Write_Discr_Specs (Node);
1990             elsif Unknown_Discriminants_Present (Node) then
1991                Write_Str_With_Col_Check ("(<>)");
1992             end if;
1993
1994             Write_Str_With_Col_Check (" is new ");
1995             Sprint_Node (Subtype_Indication (Node));
1996             Write_Str_With_Col_Check (" with private;");
1997
1998          when N_Procedure_Call_Statement =>
1999             Write_Indent;
2000             Set_Debug_Sloc;
2001             Sprint_Node (Name (Node));
2002             Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2003             Write_Char (';');
2004
2005          when N_Procedure_Instantiation =>
2006             Write_Indent_Str_Sloc ("procedure ");
2007             Sprint_Node (Defining_Unit_Name (Node));
2008             Write_Str_With_Col_Check (" is new ");
2009             Sprint_Node (Name (Node));
2010             Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2011             Write_Char (';');
2012
2013          when N_Procedure_Specification =>
2014             Write_Str_With_Col_Check_Sloc ("procedure ");
2015             Sprint_Node (Defining_Unit_Name (Node));
2016             Write_Param_Specs (Node);
2017
2018          when N_Protected_Body =>
2019             Write_Indent_Str_Sloc ("protected body ");
2020             Write_Id (Defining_Identifier (Node));
2021             Write_Str (" is");
2022             Sprint_Indented_List (Declarations (Node));
2023             Write_Indent_Str ("end ");
2024             Write_Id (Defining_Identifier (Node));
2025             Write_Char (';');
2026
2027          when N_Protected_Body_Stub =>
2028             Write_Indent_Str_Sloc ("protected body ");
2029             Write_Id (Defining_Identifier (Node));
2030             Write_Str_With_Col_Check (" is separate;");
2031
2032          when N_Protected_Definition =>
2033             Set_Debug_Sloc;
2034             Sprint_Indented_List (Visible_Declarations (Node));
2035
2036             if Present (Private_Declarations (Node)) then
2037                Write_Indent_Str ("private");
2038                Sprint_Indented_List (Private_Declarations (Node));
2039             end if;
2040
2041             Write_Indent_Str ("end ");
2042
2043          when N_Protected_Type_Declaration =>
2044             Write_Indent_Str_Sloc ("protected type ");
2045             Write_Id (Defining_Identifier (Node));
2046             Write_Discr_Specs (Node);
2047             Write_Str (" is");
2048             Sprint_Node (Protected_Definition (Node));
2049             Write_Id (Defining_Identifier (Node));
2050             Write_Char (';');
2051
2052          when N_Qualified_Expression =>
2053             Sprint_Node (Subtype_Mark (Node));
2054             Write_Char_Sloc (''');
2055
2056             --  Print expression, make sure we have at least one level of
2057             --  parentheses around the expression. For cases of qualified
2058             --  expressions in the source, this is always the case, but
2059             --  for generated qualifications, there may be no explicit
2060             --  parentheses present.
2061
2062             if Paren_Count (Expression (Node)) /= 0 then
2063                Sprint_Node (Expression (Node));
2064             else
2065                Write_Char ('(');
2066                Sprint_Node (Expression (Node));
2067                Write_Char (')');
2068             end if;
2069
2070          when N_Raise_Constraint_Error =>
2071
2072             --  This node can be used either as a subexpression or as a
2073             --  statement form. The following test is a reasonably reliable
2074             --  way to distinguish the two cases.
2075
2076             if Is_List_Member (Node)
2077               and then Nkind (Parent (Node)) not in N_Subexpr
2078             then
2079                Write_Indent;
2080             end if;
2081
2082             Write_Str_With_Col_Check_Sloc ("[constraint_error");
2083             Write_Condition_And_Reason (Node);
2084
2085          when N_Raise_Program_Error =>
2086
2087             --  This node can be used either as a subexpression or as a
2088             --  statement form. The following test is a reasonably reliable
2089             --  way to distinguish the two cases.
2090
2091             if Is_List_Member (Node)
2092               and then Nkind (Parent (Node)) not in N_Subexpr
2093             then
2094                Write_Indent;
2095             end if;
2096
2097             Write_Str_With_Col_Check_Sloc ("[program_error");
2098             Write_Condition_And_Reason (Node);
2099
2100          when N_Raise_Storage_Error =>
2101
2102             --  This node can be used either as a subexpression or as a
2103             --  statement form. The following test is a reasonably reliable
2104             --  way to distinguish the two cases.
2105
2106             if Is_List_Member (Node)
2107               and then Nkind (Parent (Node)) not in N_Subexpr
2108             then
2109                Write_Indent;
2110             end if;
2111
2112             Write_Str_With_Col_Check_Sloc ("[storage_error");
2113             Write_Condition_And_Reason (Node);
2114
2115          when N_Raise_Statement =>
2116             Write_Indent_Str_Sloc ("raise ");
2117             Sprint_Node (Name (Node));
2118             Write_Char (';');
2119
2120          when N_Range =>
2121             Sprint_Node (Low_Bound (Node));
2122             Write_Str_Sloc (" .. ");
2123             Sprint_Node (High_Bound (Node));
2124
2125          when N_Range_Constraint =>
2126             Write_Str_With_Col_Check_Sloc ("range ");
2127             Sprint_Node (Range_Expression (Node));
2128
2129          when N_Real_Literal =>
2130             Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2131
2132          when N_Real_Range_Specification =>
2133             Write_Str_With_Col_Check_Sloc ("range ");
2134             Sprint_Node (Low_Bound (Node));
2135             Write_Str (" .. ");
2136             Sprint_Node (High_Bound (Node));
2137
2138          when N_Record_Definition =>
2139             if Abstract_Present (Node) then
2140                Write_Str_With_Col_Check ("abstract ");
2141             end if;
2142
2143             if Tagged_Present (Node) then
2144                Write_Str_With_Col_Check ("tagged ");
2145             end if;
2146
2147             if Limited_Present (Node) then
2148                Write_Str_With_Col_Check ("limited ");
2149             end if;
2150
2151             if Null_Present (Node) then
2152                Write_Str_With_Col_Check_Sloc ("null record");
2153
2154             else
2155                Write_Str_With_Col_Check_Sloc ("record");
2156                Sprint_Node (Component_List (Node));
2157                Write_Indent_Str ("end record");
2158             end if;
2159
2160          when N_Record_Representation_Clause =>
2161             Write_Indent_Str_Sloc ("for ");
2162             Sprint_Node (Identifier (Node));
2163             Write_Str_With_Col_Check (" use record ");
2164
2165             if Present (Mod_Clause (Node)) then
2166                Sprint_Node (Mod_Clause (Node));
2167             end if;
2168
2169             Sprint_Indented_List (Component_Clauses (Node));
2170             Write_Indent_Str ("end record;");
2171
2172          when N_Reference =>
2173             Sprint_Node (Prefix (Node));
2174             Write_Str_With_Col_Check_Sloc ("'reference");
2175
2176          when N_Requeue_Statement =>
2177             Write_Indent_Str_Sloc ("requeue ");
2178             Sprint_Node (Name (Node));
2179
2180             if Abort_Present (Node) then
2181                Write_Str_With_Col_Check (" with abort");
2182             end if;
2183
2184             Write_Char (';');
2185
2186          when N_Return_Statement =>
2187             if Present (Expression (Node)) then
2188                Write_Indent_Str_Sloc ("return ");
2189                Sprint_Node (Expression (Node));
2190                Write_Char (';');
2191             else
2192                Write_Indent_Str_Sloc ("return;");
2193             end if;
2194
2195          when N_Selective_Accept =>
2196             Write_Indent_Str_Sloc ("select");
2197
2198             declare
2199                Alt_Node : Node_Id;
2200
2201             begin
2202                Alt_Node := First (Select_Alternatives (Node));
2203                loop
2204                   Indent_Begin;
2205                   Sprint_Node (Alt_Node);
2206                   Indent_End;
2207                   Next (Alt_Node);
2208                   exit when No (Alt_Node);
2209                   Write_Indent_Str ("or");
2210                end loop;
2211             end;
2212
2213             if Present (Else_Statements (Node)) then
2214                Write_Indent_Str ("else");
2215                Sprint_Indented_List (Else_Statements (Node));
2216             end if;
2217
2218             Write_Indent_Str ("end select;");
2219
2220          when N_Signed_Integer_Type_Definition =>
2221             Write_Str_With_Col_Check_Sloc ("range ");
2222             Sprint_Node (Low_Bound (Node));
2223             Write_Str (" .. ");
2224             Sprint_Node (High_Bound (Node));
2225
2226          when N_Single_Protected_Declaration =>
2227             Write_Indent_Str_Sloc ("protected ");
2228             Write_Id (Defining_Identifier (Node));
2229             Write_Str (" is");
2230             Sprint_Node (Protected_Definition (Node));
2231             Write_Id (Defining_Identifier (Node));
2232             Write_Char (';');
2233
2234          when N_Single_Task_Declaration =>
2235             Write_Indent_Str_Sloc ("task ");
2236             Write_Id (Defining_Identifier (Node));
2237
2238             if Present (Task_Definition (Node)) then
2239                Write_Str (" is");
2240                Sprint_Node (Task_Definition (Node));
2241                Write_Id (Defining_Identifier (Node));
2242             end if;
2243
2244             Write_Char (';');
2245
2246          when N_Selected_Component | N_Expanded_Name =>
2247             Sprint_Node (Prefix (Node));
2248             Write_Char_Sloc ('.');
2249             Sprint_Node (Selector_Name (Node));
2250
2251          when N_Slice =>
2252             Set_Debug_Sloc;
2253             Sprint_Node (Prefix (Node));
2254             Write_Str_With_Col_Check (" (");
2255             Sprint_Node (Discrete_Range (Node));
2256             Write_Char (')');
2257
2258          when N_String_Literal =>
2259             if String_Length (Strval (Node)) + Column > 75 then
2260                Write_Indent_Str ("  ");
2261             end if;
2262
2263             Set_Debug_Sloc;
2264             Write_String_Table_Entry (Strval (Node));
2265
2266          when N_Subprogram_Body =>
2267             if Freeze_Indent = 0 then
2268                Write_Indent;
2269             end if;
2270
2271             Write_Indent;
2272             Sprint_Node_Sloc (Specification (Node));
2273             Write_Str (" is");
2274
2275             Sprint_Indented_List (Declarations (Node));
2276             Write_Indent_Str ("begin");
2277             Sprint_Node (Handled_Statement_Sequence (Node));
2278
2279             Write_Indent_Str ("end ");
2280             Sprint_Node (Defining_Unit_Name (Specification (Node)));
2281             Write_Char (';');
2282
2283             if Is_List_Member (Node)
2284               and then Present (Next (Node))
2285               and then Nkind (Next (Node)) /= N_Subprogram_Body
2286             then
2287                Write_Indent;
2288             end if;
2289
2290          when N_Subprogram_Body_Stub =>
2291             Write_Indent;
2292             Sprint_Node_Sloc (Specification (Node));
2293             Write_Str_With_Col_Check (" is separate;");
2294
2295          when N_Subprogram_Declaration =>
2296             Write_Indent;
2297             Sprint_Node_Sloc (Specification (Node));
2298             Write_Char (';');
2299
2300          when N_Subprogram_Info =>
2301             Sprint_Node (Identifier (Node));
2302             Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2303
2304          when N_Subprogram_Renaming_Declaration =>
2305             Write_Indent;
2306             Sprint_Node (Specification (Node));
2307             Write_Str_With_Col_Check_Sloc (" renames ");
2308             Sprint_Node (Name (Node));
2309             Write_Char (';');
2310
2311          when N_Subtype_Declaration =>
2312             Write_Indent_Str_Sloc ("subtype ");
2313             Write_Id (Defining_Identifier (Node));
2314             Write_Str (" is ");
2315             Sprint_Node (Subtype_Indication (Node));
2316             Write_Char (';');
2317
2318          when N_Subtype_Indication =>
2319             Sprint_Node_Sloc (Subtype_Mark (Node));
2320             Write_Char (' ');
2321             Sprint_Node (Constraint (Node));
2322
2323          when N_Subunit =>
2324             Write_Indent_Str_Sloc ("separate (");
2325             Sprint_Node (Name (Node));
2326             Write_Char (')');
2327             Write_Eol;
2328             Sprint_Node (Proper_Body (Node));
2329
2330          when N_Task_Body =>
2331             Write_Indent_Str_Sloc ("task body ");
2332             Write_Id (Defining_Identifier (Node));
2333             Write_Str (" is");
2334             Sprint_Indented_List (Declarations (Node));
2335             Write_Indent_Str ("begin");
2336             Sprint_Node (Handled_Statement_Sequence (Node));
2337             Write_Indent_Str ("end ");
2338             Write_Id (Defining_Identifier (Node));
2339             Write_Char (';');
2340
2341          when N_Task_Body_Stub =>
2342             Write_Indent_Str_Sloc ("task body ");
2343             Write_Id (Defining_Identifier (Node));
2344             Write_Str_With_Col_Check (" is separate;");
2345
2346          when N_Task_Definition =>
2347             Set_Debug_Sloc;
2348             Sprint_Indented_List (Visible_Declarations (Node));
2349
2350             if Present (Private_Declarations (Node)) then
2351                Write_Indent_Str ("private");
2352                Sprint_Indented_List (Private_Declarations (Node));
2353             end if;
2354
2355             Write_Indent_Str ("end ");
2356
2357          when N_Task_Type_Declaration =>
2358             Write_Indent_Str_Sloc ("task type ");
2359             Write_Id (Defining_Identifier (Node));
2360             Write_Discr_Specs (Node);
2361             if Present (Task_Definition (Node)) then
2362                Write_Str (" is");
2363                Sprint_Node (Task_Definition (Node));
2364                Write_Id (Defining_Identifier (Node));
2365             end if;
2366
2367             Write_Char (';');
2368
2369          when N_Terminate_Alternative =>
2370             Sprint_Node_List (Pragmas_Before (Node));
2371
2372             Write_Indent;
2373
2374             if Present (Condition (Node)) then
2375                Write_Str_With_Col_Check ("when ");
2376                Sprint_Node (Condition (Node));
2377                Write_Str (" => ");
2378             end if;
2379
2380             Write_Str_With_Col_Check_Sloc ("terminate;");
2381             Sprint_Node_List (Pragmas_After (Node));
2382
2383          when N_Timed_Entry_Call =>
2384             Write_Indent_Str_Sloc ("select");
2385             Indent_Begin;
2386             Sprint_Node (Entry_Call_Alternative (Node));
2387             Indent_End;
2388             Write_Indent_Str ("or");
2389             Indent_Begin;
2390             Sprint_Node (Delay_Alternative (Node));
2391             Indent_End;
2392             Write_Indent_Str ("end select;");
2393
2394          when N_Triggering_Alternative =>
2395             Sprint_Node_List (Pragmas_Before (Node));
2396             Sprint_Node_Sloc (Triggering_Statement (Node));
2397             Sprint_Node_List (Statements (Node));
2398
2399          when N_Type_Conversion =>
2400             Set_Debug_Sloc;
2401             Sprint_Node (Subtype_Mark (Node));
2402             Col_Check (4);
2403
2404             if Conversion_OK (Node) then
2405                Write_Char ('?');
2406             end if;
2407
2408             if Float_Truncate (Node) then
2409                Write_Char ('^');
2410             end if;
2411
2412             if Rounded_Result (Node) then
2413                Write_Char ('@');
2414             end if;
2415
2416             Write_Char ('(');
2417             Sprint_Node (Expression (Node));
2418             Write_Char (')');
2419
2420          when N_Unchecked_Expression =>
2421             Col_Check (10);
2422             Write_Str ("`(");
2423             Sprint_Node_Sloc (Expression (Node));
2424             Write_Char (')');
2425
2426          when N_Unchecked_Type_Conversion =>
2427             Sprint_Node (Subtype_Mark (Node));
2428             Write_Char ('!');
2429             Write_Str_With_Col_Check ("(");
2430             Sprint_Node_Sloc (Expression (Node));
2431             Write_Char (')');
2432
2433          when N_Unconstrained_Array_Definition =>
2434             Write_Str_With_Col_Check_Sloc ("array (");
2435
2436             declare
2437                Node1 : Node_Id;
2438
2439             begin
2440                Node1 := First (Subtype_Marks (Node));
2441                loop
2442                   Sprint_Node (Node1);
2443                   Write_Str_With_Col_Check (" range <>");
2444                   Next (Node1);
2445                   exit when Node1 = Empty;
2446                   Write_Str (", ");
2447                end loop;
2448             end;
2449
2450             Write_Str (") of ");
2451
2452             if Aliased_Present (Node) then
2453                Write_Str_With_Col_Check ("aliased ");
2454             end if;
2455
2456             Sprint_Node (Subtype_Indication (Node));
2457
2458          when N_Unused_At_Start | N_Unused_At_End =>
2459             Write_Indent_Str ("***** Error, unused node encountered *****");
2460             Write_Eol;
2461
2462          when N_Use_Package_Clause =>
2463             Write_Indent_Str_Sloc ("use ");
2464             Sprint_Comma_List (Names (Node));
2465             Write_Char (';');
2466
2467          when N_Use_Type_Clause =>
2468             Write_Indent_Str_Sloc ("use type ");
2469             Sprint_Comma_List (Subtype_Marks (Node));
2470             Write_Char (';');
2471
2472          when N_Validate_Unchecked_Conversion =>
2473             Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2474             Sprint_Node (Source_Type (Node));
2475             Write_Str (", ");
2476             Sprint_Node (Target_Type (Node));
2477             Write_Str (");");
2478
2479          when N_Variant =>
2480             Write_Indent_Str_Sloc ("when ");
2481             Sprint_Bar_List (Discrete_Choices (Node));
2482             Write_Str (" => ");
2483             Sprint_Node (Component_List (Node));
2484
2485          when N_Variant_Part =>
2486             Indent_Begin;
2487             Write_Indent_Str_Sloc ("case ");
2488             Sprint_Node (Name (Node));
2489             Write_Str (" is ");
2490             Sprint_Indented_List (Variants (Node));
2491             Write_Indent_Str ("end case");
2492             Indent_End;
2493
2494          when N_With_Clause =>
2495
2496             --  Special test, if we are dumping the original tree only,
2497             --  then we want to eliminate the bogus with clauses that
2498             --  correspond to the non-existent children of Text_IO.
2499
2500             if Dump_Original_Only
2501               and then Is_Text_IO_Kludge_Unit (Name (Node))
2502             then
2503                null;
2504
2505             --  Normal case, output the with clause
2506
2507             else
2508                if First_Name (Node) or else not Dump_Original_Only then
2509                   Write_Indent_Str ("with ");
2510                else
2511                   Write_Str (", ");
2512                end if;
2513
2514                Sprint_Node_Sloc (Name (Node));
2515
2516                if Last_Name (Node) or else not Dump_Original_Only then
2517                   Write_Char (';');
2518                end if;
2519             end if;
2520
2521          when N_With_Type_Clause =>
2522
2523             Write_Indent_Str ("with type ");
2524             Sprint_Node_Sloc (Name (Node));
2525
2526             if Tagged_Present (Node) then
2527                Write_Str (" is tagged;");
2528             else
2529                Write_Str (" is access;");
2530             end if;
2531
2532       end case;
2533
2534       if Nkind (Node) in N_Subexpr
2535         and then Do_Range_Check (Node)
2536       then
2537          Write_Str ("}");
2538       end if;
2539
2540       for J in 1 .. Paren_Count (Node) loop
2541          Write_Char (')');
2542       end loop;
2543
2544       pragma Assert (No (Debug_Node));
2545       Debug_Node := Save_Debug_Node;
2546    end Sprint_Node_Actual;
2547
2548    ----------------------
2549    -- Sprint_Node_List --
2550    ----------------------
2551
2552    procedure Sprint_Node_List (List : List_Id) is
2553       Node : Node_Id;
2554
2555    begin
2556       if Is_Non_Empty_List (List) then
2557          Node := First (List);
2558
2559          loop
2560             Sprint_Node (Node);
2561             Next (Node);
2562             exit when Node = Empty;
2563          end loop;
2564       end if;
2565    end Sprint_Node_List;
2566
2567    ----------------------
2568    -- Sprint_Node_Sloc --
2569    ----------------------
2570
2571    procedure Sprint_Node_Sloc (Node : Node_Id) is
2572    begin
2573       Sprint_Node (Node);
2574
2575       if Present (Debug_Node) then
2576          Set_Sloc (Debug_Node, Sloc (Node));
2577          Debug_Node := Empty;
2578       end if;
2579    end Sprint_Node_Sloc;
2580
2581    ---------------------
2582    -- Sprint_Opt_Node --
2583    ---------------------
2584
2585    procedure Sprint_Opt_Node (Node : Node_Id) is
2586    begin
2587       if Present (Node) then
2588          Write_Char (' ');
2589          Sprint_Node (Node);
2590       end if;
2591    end Sprint_Opt_Node;
2592
2593    --------------------------
2594    -- Sprint_Opt_Node_List --
2595    --------------------------
2596
2597    procedure Sprint_Opt_Node_List (List : List_Id) is
2598    begin
2599       if Present (List) then
2600          Sprint_Node_List (List);
2601       end if;
2602    end Sprint_Opt_Node_List;
2603
2604    ---------------------------------
2605    -- Sprint_Opt_Paren_Comma_List --
2606    ---------------------------------
2607
2608    procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2609    begin
2610       if Is_Non_Empty_List (List) then
2611          Write_Char (' ');
2612          Sprint_Paren_Comma_List (List);
2613       end if;
2614    end Sprint_Opt_Paren_Comma_List;
2615
2616    -----------------------------
2617    -- Sprint_Paren_Comma_List --
2618    -----------------------------
2619
2620    procedure Sprint_Paren_Comma_List (List : List_Id) is
2621       N           : Node_Id;
2622       Node_Exists : Boolean := False;
2623
2624    begin
2625
2626       if Is_Non_Empty_List (List) then
2627
2628          if Dump_Original_Only then
2629             N := First (List);
2630
2631             while Present (N) loop
2632
2633                if not Is_Rewrite_Insertion (N) then
2634                   Node_Exists := True;
2635                   exit;
2636                end if;
2637
2638                Next (N);
2639             end loop;
2640
2641             if not Node_Exists then
2642                return;
2643             end if;
2644          end if;
2645
2646          Write_Str_With_Col_Check ("(");
2647          Sprint_Comma_List (List);
2648          Write_Char (')');
2649       end if;
2650    end Sprint_Paren_Comma_List;
2651
2652    ----------------------
2653    -- Sprint_Right_Opnd --
2654    ----------------------
2655
2656    procedure Sprint_Right_Opnd (N : Node_Id) is
2657       Opnd : constant Node_Id := Right_Opnd (N);
2658
2659    begin
2660       if Paren_Count (Opnd) /= 0
2661         or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2662       then
2663          Sprint_Node (Opnd);
2664
2665       else
2666          Write_Char ('(');
2667          Sprint_Node (Opnd);
2668          Write_Char (')');
2669       end if;
2670    end Sprint_Right_Opnd;
2671
2672    ---------------------
2673    -- Write_Char_Sloc --
2674    ---------------------
2675
2676    procedure Write_Char_Sloc (C : Character) is
2677    begin
2678       if Debug_Generated_Code and then C /= ' ' then
2679          Set_Debug_Sloc;
2680       end if;
2681
2682       Write_Char (C);
2683    end Write_Char_Sloc;
2684
2685    --------------------------------
2686    -- Write_Condition_And_Reason --
2687    --------------------------------
2688
2689    procedure Write_Condition_And_Reason (Node : Node_Id) is
2690       Image : constant String := RT_Exception_Code'Image
2691                                    (RT_Exception_Code'Val
2692                                      (UI_To_Int (Reason (Node))));
2693
2694    begin
2695       if Present (Condition (Node)) then
2696          Write_Str_With_Col_Check (" when ");
2697          Sprint_Node (Condition (Node));
2698       end if;
2699
2700       Write_Str (" """);
2701
2702       for J in 4 .. Image'Last loop
2703          if Image (J) = '_' then
2704             Write_Char (' ');
2705          else
2706             Write_Char (Fold_Lower (Image (J)));
2707          end if;
2708       end loop;
2709
2710       Write_Str ("""]");
2711    end Write_Condition_And_Reason;
2712
2713    ------------------------
2714    --  Write_Discr_Specs --
2715    ------------------------
2716
2717    procedure Write_Discr_Specs (N : Node_Id) is
2718       Specs  : List_Id;
2719       Spec   : Node_Id;
2720
2721    begin
2722       Specs := Discriminant_Specifications (N);
2723
2724       if Present (Specs) then
2725          Write_Str_With_Col_Check (" (");
2726          Spec := First (Specs);
2727
2728          loop
2729             Sprint_Node (Spec);
2730             Next (Spec);
2731             exit when Spec = Empty;
2732
2733             --  Add semicolon, unless we are printing original tree and the
2734             --  next specification is part of a list (but not the first
2735             --  element of that list)
2736
2737             if not Dump_Original_Only or else not Prev_Ids (Spec) then
2738                Write_Str ("; ");
2739             end if;
2740          end loop;
2741
2742          Write_Char (')');
2743       end if;
2744    end Write_Discr_Specs;
2745
2746    -----------------
2747    -- Write_Ekind --
2748    -----------------
2749
2750    procedure Write_Ekind (E : Entity_Id) is
2751       S : constant String := Entity_Kind'Image (Ekind (E));
2752
2753    begin
2754       Name_Len := S'Length;
2755       Name_Buffer (1 .. Name_Len) := S;
2756       Set_Casing (Mixed_Case);
2757       Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2758    end Write_Ekind;
2759
2760    --------------
2761    -- Write_Id --
2762    --------------
2763
2764    procedure Write_Id (N : Node_Id) is
2765    begin
2766       --  Case of a defining identifier
2767
2768       if Nkind (N) = N_Defining_Identifier then
2769
2770          --  If defining identifier has an interface name (and no
2771          --  address clause), then we output the interface name.
2772
2773          if (Is_Imported (N) or else Is_Exported (N))
2774            and then Present (Interface_Name (N))
2775            and then No (Address_Clause (N))
2776          then
2777             String_To_Name_Buffer (Strval (Interface_Name (N)));
2778             Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2779
2780          --  If no interface name (or inactive because there was
2781          --  an address clause), then just output the Chars name.
2782
2783          else
2784             Write_Name_With_Col_Check (Chars (N));
2785          end if;
2786
2787       --  Case of selector of an expanded name where the expanded name
2788       --  has an associated entity, output this entity.
2789
2790       elsif Nkind (Parent (N)) = N_Expanded_Name
2791         and then Selector_Name (Parent (N)) = N
2792         and then Present (Entity (Parent (N)))
2793       then
2794          Write_Id (Entity (Parent (N)));
2795
2796       --  For any other kind of node with an associated entity, output it.
2797
2798       elsif Nkind (N) in N_Has_Entity
2799         and then Present (Entity (N))
2800       then
2801          Write_Id (Entity (N));
2802
2803       --  All other cases, we just print the Chars field
2804
2805       else
2806          Write_Name_With_Col_Check (Chars (N));
2807       end if;
2808    end Write_Id;
2809
2810    -----------------------
2811    -- Write_Identifiers --
2812    -----------------------
2813
2814    function Write_Identifiers (Node : Node_Id) return Boolean is
2815    begin
2816       Sprint_Node (Defining_Identifier (Node));
2817
2818       --  The remainder of the declaration must be printed unless we are
2819       --  printing the original tree and this is not the last identifier
2820
2821       return
2822          not Dump_Original_Only or else not More_Ids (Node);
2823
2824    end Write_Identifiers;
2825
2826    ------------------------
2827    -- Write_Implicit_Def --
2828    ------------------------
2829
2830    procedure Write_Implicit_Def (E : Entity_Id) is
2831       Ind : Node_Id;
2832
2833    begin
2834       case Ekind (E) is
2835          when E_Array_Subtype =>
2836             Write_Str_With_Col_Check ("subtype ");
2837             Write_Id (E);
2838             Write_Str_With_Col_Check (" is ");
2839             Write_Id (Base_Type (E));
2840             Write_Str_With_Col_Check (" (");
2841
2842             Ind := First_Index (E);
2843
2844             while Present (Ind) loop
2845                Sprint_Node (Ind);
2846                Next_Index (Ind);
2847
2848                if Present (Ind) then
2849                   Write_Str (", ");
2850                end if;
2851             end loop;
2852
2853             Write_Str (");");
2854
2855          when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
2856             Write_Str_With_Col_Check ("subtype ");
2857             Write_Id (E);
2858             Write_Str (" is ");
2859             Write_Id (Etype (E));
2860             Write_Str_With_Col_Check (" range ");
2861             Sprint_Node (Scalar_Range (E));
2862             Write_Str (";");
2863
2864          when others =>
2865             Write_Str_With_Col_Check ("type ");
2866             Write_Id (E);
2867             Write_Str_With_Col_Check (" is <");
2868             Write_Ekind (E);
2869             Write_Str (">;");
2870       end case;
2871
2872    end Write_Implicit_Def;
2873
2874    ------------------
2875    -- Write_Indent --
2876    ------------------
2877
2878    procedure Write_Indent is
2879    begin
2880       if Indent_Annull_Flag then
2881          Indent_Annull_Flag := False;
2882       else
2883          Write_Eol;
2884
2885          for J in 1 .. Indent loop
2886             Write_Char (' ');
2887          end loop;
2888       end if;
2889    end Write_Indent;
2890
2891    ------------------------------
2892    -- Write_Indent_Identifiers --
2893    ------------------------------
2894
2895    function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
2896    begin
2897       --  We need to start a new line for every node, except in the case
2898       --  where we are printing the original tree and this is not the first
2899       --  defining identifier in the list.
2900
2901       if not Dump_Original_Only or else not Prev_Ids (Node) then
2902          Write_Indent;
2903
2904       --  If printing original tree and this is not the first defining
2905       --  identifier in the list, then the previous call to this procedure
2906       --  printed only the name, and we add a comma to separate the names.
2907
2908       else
2909          Write_Str (", ");
2910       end if;
2911
2912       Sprint_Node (Defining_Identifier (Node));
2913
2914       --  The remainder of the declaration must be printed unless we are
2915       --  printing the original tree and this is not the last identifier
2916
2917       return
2918          not Dump_Original_Only or else not More_Ids (Node);
2919
2920    end Write_Indent_Identifiers;
2921
2922    -----------------------------------
2923    -- Write_Indent_Identifiers_Sloc --
2924    -----------------------------------
2925
2926    function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
2927    begin
2928       --  We need to start a new line for every node, except in the case
2929       --  where we are printing the original tree and this is not the first
2930       --  defining identifier in the list.
2931
2932       if not Dump_Original_Only or else not Prev_Ids (Node) then
2933          Write_Indent;
2934
2935       --  If printing original tree and this is not the first defining
2936       --  identifier in the list, then the previous call to this procedure
2937       --  printed only the name, and we add a comma to separate the names.
2938
2939       else
2940          Write_Str (", ");
2941       end if;
2942
2943       Set_Debug_Sloc;
2944       Sprint_Node (Defining_Identifier (Node));
2945
2946       --  The remainder of the declaration must be printed unless we are
2947       --  printing the original tree and this is not the last identifier
2948
2949       return
2950          not Dump_Original_Only or else not More_Ids (Node);
2951
2952    end Write_Indent_Identifiers_Sloc;
2953
2954    ----------------------
2955    -- Write_Indent_Str --
2956    ----------------------
2957
2958    procedure Write_Indent_Str (S : String) is
2959    begin
2960       Write_Indent;
2961       Write_Str (S);
2962    end Write_Indent_Str;
2963
2964    ---------------------------
2965    -- Write_Indent_Str_Sloc --
2966    ---------------------------
2967
2968    procedure Write_Indent_Str_Sloc (S : String) is
2969    begin
2970       Write_Indent;
2971       Write_Str_Sloc (S);
2972    end Write_Indent_Str_Sloc;
2973
2974    -------------------------------
2975    -- Write_Name_With_Col_Check --
2976    -------------------------------
2977
2978    procedure Write_Name_With_Col_Check (N : Name_Id) is
2979       J : Natural;
2980
2981    begin
2982       Get_Name_String (N);
2983
2984       --  Deal with -gnatI which replaces digits in an internal
2985       --  name by three dots (e.g. R7b becomes R...b).
2986
2987       if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
2988
2989          J := 2;
2990          while J < Name_Len loop
2991             exit when Name_Buffer (J) not in 'A' .. 'Z';
2992             J := J + 1;
2993          end loop;
2994
2995          if Name_Buffer (J) in '0' .. '9' then
2996             Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
2997             Write_Str ("...");
2998
2999             while J <= Name_Len loop
3000                if Name_Buffer (J) not in '0' .. '9' then
3001                   Write_Str (Name_Buffer (J .. Name_Len));
3002                   exit;
3003
3004                else
3005                   J := J + 1;
3006                end if;
3007             end loop;
3008
3009             return;
3010          end if;
3011       end if;
3012
3013       --  Fall through for normal case
3014
3015       Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3016    end Write_Name_With_Col_Check;
3017
3018    ------------------------------------
3019    -- Write_Name_With_Col_Check_Sloc --
3020    ------------------------------------
3021
3022    procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3023    begin
3024       Get_Name_String (N);
3025       Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3026    end Write_Name_With_Col_Check_Sloc;
3027
3028    --------------------
3029    -- Write_Operator --
3030    --------------------
3031
3032    procedure Write_Operator (N : Node_Id; S : String) is
3033       F : Natural := S'First;
3034       T : Natural := S'Last;
3035
3036    begin
3037       --  If no overflow check, just write string out, and we are done
3038
3039       if not Do_Overflow_Check (N) then
3040          Write_Str_Sloc (S);
3041
3042       --  If overflow check, we want to surround the operator with curly
3043       --  brackets, but not include spaces within the brackets.
3044
3045       else
3046          if S (F) = ' ' then
3047             Write_Char (' ');
3048             F := F + 1;
3049          end if;
3050
3051          if S (T) = ' ' then
3052             T := T - 1;
3053          end if;
3054
3055          Write_Char ('{');
3056          Write_Str_Sloc (S (F .. T));
3057          Write_Char ('}');
3058
3059          if S (S'Last) = ' ' then
3060             Write_Char (' ');
3061          end if;
3062       end if;
3063    end Write_Operator;
3064
3065    -----------------------
3066    -- Write_Param_Specs --
3067    -----------------------
3068
3069    procedure Write_Param_Specs (N : Node_Id) is
3070       Specs  : List_Id;
3071       Spec   : Node_Id;
3072       Formal : Node_Id;
3073
3074    begin
3075       Specs := Parameter_Specifications (N);
3076
3077       if Is_Non_Empty_List (Specs) then
3078          Write_Str_With_Col_Check (" (");
3079          Spec := First (Specs);
3080
3081          loop
3082             Sprint_Node (Spec);
3083             Formal := Defining_Identifier (Spec);
3084             Next (Spec);
3085             exit when Spec = Empty;
3086
3087             --  Add semicolon, unless we are printing original tree and the
3088             --  next specification is part of a list (but not the first
3089             --  element of that list)
3090
3091             if not Dump_Original_Only or else not Prev_Ids (Spec) then
3092                Write_Str ("; ");
3093             end if;
3094          end loop;
3095
3096          --  Write out any extra formals
3097
3098          while Present (Extra_Formal (Formal)) loop
3099             Formal := Extra_Formal (Formal);
3100             Write_Str ("; ");
3101             Write_Name_With_Col_Check (Chars (Formal));
3102             Write_Str (" : ");
3103             Write_Name_With_Col_Check (Chars (Etype (Formal)));
3104          end loop;
3105
3106          Write_Char (')');
3107       end if;
3108    end Write_Param_Specs;
3109
3110    --------------------------
3111    -- Write_Rewrite_Str --
3112    --------------------------
3113
3114    procedure Write_Rewrite_Str (S : String) is
3115    begin
3116       if not Dump_Generated_Only then
3117          if S'Length = 3 and then S = ">>>" then
3118             Write_Str (">>>");
3119          else
3120             Write_Str_With_Col_Check (S);
3121          end if;
3122       end if;
3123    end Write_Rewrite_Str;
3124
3125    --------------------
3126    -- Write_Str_Sloc --
3127    --------------------
3128
3129    procedure Write_Str_Sloc (S : String) is
3130    begin
3131       for J in S'Range loop
3132          Write_Char_Sloc (S (J));
3133       end loop;
3134    end Write_Str_Sloc;
3135
3136    ------------------------------
3137    -- Write_Str_With_Col_Check --
3138    ------------------------------
3139
3140    procedure Write_Str_With_Col_Check (S : String) is
3141    begin
3142       if Int (S'Last) + Column > Line_Limit then
3143          Write_Indent_Str ("  ");
3144
3145          if S (1) = ' ' then
3146             Write_Str (S (2 .. S'Length));
3147          else
3148             Write_Str (S);
3149          end if;
3150
3151       else
3152          Write_Str (S);
3153       end if;
3154    end Write_Str_With_Col_Check;
3155
3156    -----------------------------------
3157    -- Write_Str_With_Col_Check_Sloc --
3158    -----------------------------------
3159
3160    procedure Write_Str_With_Col_Check_Sloc (S : String) is
3161    begin
3162       if Int (S'Last) + Column > Line_Limit then
3163          Write_Indent_Str ("  ");
3164
3165          if S (1) = ' ' then
3166             Write_Str_Sloc (S (2 .. S'Length));
3167          else
3168             Write_Str_Sloc (S);
3169          end if;
3170
3171       else
3172          Write_Str_Sloc (S);
3173       end if;
3174    end Write_Str_With_Col_Check_Sloc;
3175
3176    ------------------------------------
3177    -- Write_Uint_With_Col_Check_Sloc --
3178    ------------------------------------
3179
3180    procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3181    begin
3182       Col_Check (UI_Decimal_Digits_Hi (U));
3183       Set_Debug_Sloc;
3184       UI_Write (U, Format);
3185    end Write_Uint_With_Col_Check_Sloc;
3186
3187    -------------------------------------
3188    -- Write_Ureal_With_Col_Check_Sloc --
3189    -------------------------------------
3190
3191    procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3192       D : constant Uint := Denominator (U);
3193       N : constant Uint := Numerator (U);
3194
3195    begin
3196       Col_Check
3197         (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3198       Set_Debug_Sloc;
3199       UR_Write (U);
3200    end Write_Ureal_With_Col_Check_Sloc;
3201
3202 end Sprint;